Skip to content
Snippets Groups Projects
Commit 494a5dab authored by Olivier Langella's avatar Olivier Langella
Browse files

first protein table view

parent 05666e51
No related branches found
No related tags found
No related merge requests found
......@@ -78,5 +78,10 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) {
}
void Project::addProteinSp(pappso::ProteinSp makeProteinSp) {
void Project::addProteinSp(pappso::ProteinSp protein_sp) {
_protein_list.push_back(protein_sp);
}
std::vector<pappso::ProteinSp> & Project::getProteinList() {
return _protein_list;
}
\ No newline at end of file
......@@ -39,9 +39,12 @@ public:
ProjectSp makeProjectSp() const;
void readXpipFile(QFileInfo xpip_source);
void addProteinSp(pappso::ProteinSp makeProteinSp);
void addProteinSp(pappso::ProteinSp protein_sp);
std::vector<pappso::ProteinSp> & getProteinList();
pappso::GrpExperiment * _p_grp_experiment= nullptr;
pappso::GrpExperiment * _p_grp_experiment= nullptr;
private :
std::vector<pappso::ProteinSp> _protein_list;
};
#endif // PROJECT_H
......@@ -24,6 +24,12 @@
XpipFile::XpipFile(const QUrl & xpip_source) : _xpip_source(xpip_source)
{
}
XpipFile::XpipFile(const QFileInfo & xpip_source): _xpip_source(xpip_source.absoluteFilePath())
{
}
XpipFile::~XpipFile()
......
......@@ -23,12 +23,14 @@
#define XPIPFILE_H
#include <QUrl>
#include <QFileInfo>
#include "../core/project.h"
class XpipFile
{
public:
XpipFile(const QUrl & xpip_source);
XpipFile(const QFileInfo & xpip_source);
~XpipFile();
ProjectSp getProjectSp() const;
......
......@@ -20,7 +20,7 @@
<x>0</x>
<y>0</y>
<width>286</width>
<height>22</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -39,5 +39,25 @@
</action>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>actionLoad</sender>
<signal>triggered()</signal>
<receiver>Main</receiver>
<slot>selectXpipFile()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>142</x>
<y>185</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>selectXpipFile()</slot>
</slots>
</ui>
......@@ -22,9 +22,12 @@
******************************************************************************/
#include <QDockWidget>
#include <QSettings>
#include <QFileDialog>
#include "mainwindow.h"
#include "ui_main.h"
#include "files/xpipfile.h"
MainWindow::MainWindow(QWidget *parent):
......@@ -69,3 +72,26 @@ MainWindow::~MainWindow()
delete ui;
}
void MainWindow::selectXpipFile() {
QSettings settings;
QString default_location = settings.value("path/xpipfile", "").toString();
QString filename = QFileDialog::getOpenFileName(this,
tr("Open XPIP File"), default_location,
tr("xpip files (*.xpip);;all files (*)"));
if (filename.isEmpty()) {
return;
}
QFileInfo new_xpip_file;
new_xpip_file.setFile(filename);
XpipFile xpip_file(new_xpip_file);
_project_sp = xpip_file.getProjectSp();
_protein_list_window->setProject(_project_sp.get());
}
......@@ -34,6 +34,7 @@
#include <pwiz/data/msdata/MSDataFile.hpp>
#include "../utils/readspectrum.h"
#include "protein_list_view/proteinlistwindow.h"
#include "core/project.h"
......@@ -45,7 +46,7 @@ class Main;
class PwizLoaderThread : public QObject
{
Q_OBJECT
public:
public:
public slots:
void doMsDataFileLoad(const QString & parameter) {
......@@ -58,7 +59,7 @@ signals:
void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file);
};
class MainWindow: public QMainWindow {
class MainWindow: public QMainWindow {
Q_OBJECT
QThread workerThread;
......@@ -68,6 +69,7 @@ public:
~MainWindow();
public slots:
void selectXpipFile();
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
......@@ -76,10 +78,13 @@ signals:
private:
Ui::Main *ui;
ProteinListWindow * _protein_list_window=nullptr;
private :
ProjectSp _project_sp=nullptr;
};
#endif // MAINWINDOW_H
......@@ -24,7 +24,6 @@
#include "proteinlistwindow.h"
#include "ui_protein_view.h"
#include "proteintablemodel.h"
ProteinListWindow::ProteinListWindow(QWidget *parent):
......@@ -51,8 +50,8 @@ ProteinListWindow::ProteinListWindow(QWidget *parent):
/*
*/
ProteinTableModel * p_myModel = new ProteinTableModel(0);
ui->tableView->setModel( p_myModel );
_protein_table_model_p = new ProteinTableModel(0);
ui->tableView->setModel( _protein_table_model_p );
}
ProteinListWindow::~ProteinListWindow()
......@@ -60,4 +59,9 @@ ProteinListWindow::~ProteinListWindow()
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
delete ui;
}
\ No newline at end of file
}
void ProteinListWindow::setProject(Project* project_p) {
_protein_table_model_p->setProject(project_p);
}
\ No newline at end of file
......@@ -26,6 +26,7 @@
#include <QMainWindow>
#include "proteintablemodel.h"
//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html
namespace Ui {
......@@ -39,6 +40,7 @@ public:
explicit ProteinListWindow(QWidget * parent = 0);
~ProteinListWindow();
void setProject(Project* project_p);
public slots:
//void peptideEdited(QString peptideStr);
......@@ -49,6 +51,7 @@ signals:
private:
Ui::ProteinView *ui;
ProteinTableModel * _protein_table_model_p = nullptr;
};
......
......@@ -35,8 +35,21 @@ ProteinTableModel::ProteinTableModel(QObject *parent)
//emit dataChanged(topLeft, topLeft);
}
void ProteinTableModel::setProject(Project * p_project) {
qDebug() << "ProteinTableModel::setProject begin " << p_project->getProteinList().size();
_p_project = p_project;
QModelIndex topLeft = createIndex(0,0);
emit headerDataChanged(Qt::Horizontal, 0,3);
emit dataChanged(topLeft, topLeft);
}
int ProteinTableModel::rowCount(const QModelIndex &parent ) const {
return 2;
if (_p_project != nullptr) {
return _p_project->getProteinList().size();
}
return 0;
}
int ProteinTableModel::columnCount(const QModelIndex &parent ) const {
return 3;
......@@ -67,6 +80,11 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const {
.arg(row).arg(col).arg(role);
if (role == Qt::DisplayRole)
{
if (col == 2) {
if (_p_project != nullptr) {
return _p_project->getProteinList().at(row).get()->getDescription();
}
}
return QString("Row%1, Column%2")
.arg(index.row() + 1)
.arg(index.column() +1);
......
......@@ -25,6 +25,7 @@
#define PROTEINTABLEMODEL_H
#include <QAbstractTableModel>
#include "../../core/project.h"
class ProteinTableModel: public QAbstractTableModel
{
......@@ -35,6 +36,12 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void setProject(Project * p_project);
private :
Project * _p_project = nullptr;
};
#endif // PROTEINTABLEMODEL_H
......@@ -41,9 +41,9 @@ bool XpipSaxHandler::startElement(const QString & namespaceURI, const QString &
try {
//startElement_group
if (qName == "group")
if (qName == "protein")
{
//is_ok = startElement_group(attributes);
is_ok = startElement_protein(attributes);
}
_current_text.clear();
}
......@@ -64,10 +64,13 @@ bool XpipSaxHandler::endElement(const QString & namespaceURI, const QString & lo
bool is_ok = true;
// endElement_peptide_list
try {
if (qName == "group")
if (qName == "protein")
{
//is_ok = endElement_group();
is_ok = endElement_protein();
}
else if (qName == "sequence") {
is_ok = endElement_sequence();
}
// end of detection_moulon
// else if ((_tag_stack.size() > 1) &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment