diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 167f128a81e59f75acb0cce9501d2f8ad787c997..37cc24fdb7d3ea6ee8c25ba1b89b7482620af101 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -83,9 +83,7 @@ void ProjectWindow::connectNewProteinListWindow() { */ #else // Qt4 code - connect (_p_current_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this,SLOT(doViewPeptideList(ProteinMatch *))); - connect (_p_current_protein_list_window, SIGNAL(proteinMatchDoubleClicked(ProteinMatch *)), this,SLOT(doViewProteinDetail(ProteinMatch *))); - connect (_p_current_protein_list_window, SIGNAL(identificationGroupEdited(IdentificationGroup *)), this,SLOT(doIdentificationGroupEdited(IdentificationGroup *))); +//connect (_p_current_protein_list_window, SIGNAL(proteinMatchDoubleClicked(ProteinMatch *)), this,SLOT(doViewProteinDetail(ProteinMatch *))); connect (this, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), _p_current_protein_list_window,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); #endif @@ -132,7 +130,7 @@ void ProjectWindow::connectNewPeptideListWindow() { // Qt4 code //connect (_p_current_peptide_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this,SLOT(doViewPeptideList(ProteinMatch *))); //connect (_p_current_peptide_list_window, SIGNAL(identificationGroupEdited(IdentificationGroup *)), this,SLOT(doIdentificationGroupEdited(IdentificationGroup *))); - // connect (this, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), _p_current_peptide_list_window,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + // connect (this, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), _p_current_peptide_list_window,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); #endif @@ -140,7 +138,7 @@ void ProjectWindow::connectNewPeptideListWindow() { } void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { - + qDebug() << "ProjectWindow::refreshGroup begin"; vector< MsRunIdSp > ms_run_list = p_ident_group->getMsRunIdSpList(); ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); @@ -148,6 +146,7 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { ui->subgroup_number_display->setText(QString("%1").arg(p_ident_group->countSubGroup())); ui->protein_number_display->setText(QString("%1").arg(p_ident_group->countGrouped())); emit identificationGroupGrouped(p_ident_group); + qDebug() << "ProjectWindow::refreshGroup end"; } void ProjectWindow::doIdentificationGroupEdited(IdentificationGroup * p_ident_group) { @@ -212,6 +211,7 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou _p_current_protein_list_window->setIdentificationGroup(p_identification_group); _p_current_protein_list_window->show(); + qDebug() << "ProjectWindow::doViewProteinList end"; } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index 3522a96c890dc99a80a28e800c4f1c26b756d652..f5f94643e3092f6d299a784a1d38e03b65c51a8d 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.h @@ -40,6 +40,7 @@ class ProjectView; class ProjectWindow: public QMainWindow { Q_OBJECT + friend class ProteinListWindow; public: explicit ProjectWindow(MainWindow * parent = 0); @@ -48,21 +49,24 @@ public: public slots: void doViewProteinList(IdentificationGroup* p_identification_group =nullptr); - void doViewPeptideList(ProteinMatch * protein_match); - void doViewProteinDetail(ProteinMatch * protein_match); - void doIdentificationGroupEdited(IdentificationGroup * p_identification_group); void setDefaultProteinListWindow(ProteinListWindow* p_protein_list_window); // void setColor(const QColor &color); // void setShape(Shape shape); signals: void identificationGroupGrouped(IdentificationGroup * p_identification_group); //void peptideChanged(pappso::PeptideSp peptide); + +protected : + void doViewPeptideList(ProteinMatch * protein_match); + void doViewProteinDetail(ProteinMatch * protein_match); + void doIdentificationGroupEdited(IdentificationGroup * p_identification_group); private : void connectNewProteinListWindow(); void connectNewPeptideListWindow(); void connectNewProteinDetailWindow(); void refreshGroup(IdentificationGroup * p_ident_group); + private: Ui::ProjectView *ui; MainWindow * main_window; diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 53464b8ed1f2acb8856699bcd463eac6a91d0cd9..f1f3533a7b874b04a25f5670a68cc5ec8f56dc10 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -40,9 +40,9 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); - _p_proxy_model->setSourceModel(_protein_table_model_p); - _p_proxy_model->setDynamicSortFilter(true); - ui->tableView->setModel( _p_proxy_model ); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + //_p_proxy_model->setDynamicSortFilter(true); + ui->tableView->setModel( _protein_table_model_p ); ui->tableView->setSortingEnabled(true); QSettings settings; @@ -73,21 +73,23 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): #else // Qt4 code connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); - connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); + //connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); connect(ui->proteinSearchEdit, SIGNAL(textChanged(QString)), _protein_table_model_p, SLOT(onProteinSearchEdit(QString))); - connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) ); + //connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) ); connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &))); - connect(_p_proxy_model, SIGNAL(layoutChanged()), - this, SLOT(doProxyLayoutChanged())); + //connect(_p_proxy_model, SIGNAL(layoutChanged()), + // this, SLOT(doProxyLayoutChanged())); //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); #endif } void ProteinListWindow::doProxyLayoutChanged() { - updateStatusBar(); + qDebug() << "ProteinListWindow::doProxyLayoutChanged begin"; + //updateStatusBar(); + qDebug() << "ProteinListWindow::doProxyLayoutChanged end"; } void ProteinListWindow::showEvalueColumn(bool show) { _display_evalue = show; @@ -101,12 +103,16 @@ void ProteinListWindow::showAccessionColumn(bool show) { ui->tableView->setColumnHidden(2,!show); } -void ProteinListWindow::clickOnproteinMatch(ProteinMatch * p_protein_match) { - emit proteinMatchClicked(p_protein_match); +void ProteinListWindow::askPeptideListView(ProteinMatch * p_protein_match) { + qDebug() << "ProteinListWindow::askPeptideListView begin"; + _project_window->doViewPeptideList(p_protein_match); + qDebug() << "ProteinListWindow::askPeptideListView end"; //updateStatusBar(); } -void ProteinListWindow::doubleclickOnproteinMatch(ProteinMatch * p_protein_match) { - emit proteinMatchDoubleClicked(p_protein_match); +void ProteinListWindow::askProteinDetailView(ProteinMatch * p_protein_match) { + qDebug() << "ProteinListWindow::askProteinDetailView begin"; + _project_window->doViewProteinDetail(p_protein_match); + qDebug() << "ProteinListWindow::askProteinDetailView end"; //updateStatusBar(); } void ProteinListWindow::doFocusReceived(bool has_focus) { @@ -120,7 +126,7 @@ void ProteinListWindow::doFocusReceived(bool has_focus) { void ProteinListWindow::showContextMenu(const QPoint & pos) { QMenu contextMenu(tr("Context menu"), this); - + QAction accession_action("accession", this); accession_action.setCheckable(true); accession_action.setChecked(_display_evalue); @@ -147,8 +153,8 @@ ProteinListWindow::~ProteinListWindow() void ProteinListWindow::edited() { qDebug() << "ProteinListWindow::edited begin"; //emit dataChanged(index, index); - emit identificationGroupEdited(_p_identification_group); - updateStatusBar(); + _project_window->doIdentificationGroupEdited(_p_identification_group); + //updateStatusBar(); qDebug() << "ProteinListWindow::edited end"; } @@ -177,24 +183,36 @@ void ProteinListWindow::doNotGroupedHide(bool hide) { void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { qDebug() << "ProteinListWindow::doIdentificationGroupGrouped begin"; if (_p_identification_group == p_identification_group) { - _p_proxy_model->setSourceModel(_protein_table_model_p); + //_p_proxy_model->setSourceModel(_protein_table_model_p); } qDebug() << "ProteinListWindow::doIdentificationGroupGrouped end"; } void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { + qDebug() << "ProteinListWindow::setIdentificationGroup begin"; if (_p_identification_group != p_identification_group) { _p_identification_group = p_identification_group; _protein_table_model_p->setIdentificationGroup(p_identification_group); _p_proxy_model->setSourceModel(_protein_table_model_p); } + qDebug() << "ProteinListWindow::setIdentificationGroup end"; } + + +void ProteinListWindow::refresh() { + if (_p_identification_group == nullptr) return; + qDebug() << "ProteinListWindow::refresh begin " << _p_identification_group->getProteinMatchList().size(); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + qDebug() << "ProteinListWindow::refresh end "; +} + + void ProteinListWindow::updateStatusBar() { if (_p_identification_group == nullptr) { } else { - ui->statusbar->showMessage(tr("proteins %1 valid, %2 checked, %3 displayed").arg(_p_identification_group->countValid()).arg(_p_identification_group->countValidAndChecked()).arg(_p_proxy_model->rowCount())); + ui->statusbar->showMessage(tr("proteins %1 valid, %2 checked, %3 displayed").arg(_p_identification_group->countValid()).arg(_p_identification_group->countValidAndChecked()).arg(_p_proxy_model->rowCount())); } } diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 71edbe90b72e180bce0ee6291672bd479c03d219..b0840f4c1ead83514253dcd662fdfc4b01267271 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -38,13 +38,14 @@ class ProteinView; class ProteinListWindow: public QMainWindow { Q_OBJECT - friend ProteinTableModel; + friend class ProteinTableModel; + friend class ProteinTableProxyModel; public: explicit ProteinListWindow(ProjectWindow * parent = 0); ~ProteinListWindow(); void setIdentificationGroup(IdentificationGroup * p_identification_group); - + void edited(); public slots: @@ -54,8 +55,6 @@ public slots: // void setColor(const QColor &color); // void setShape(Shape shape); signals: - void proteinMatchClicked(ProteinMatch * p_protein_match); - void proteinMatchDoubleClicked(ProteinMatch * p_protein_match); void identificationGroupEdited(IdentificationGroup * p_identification_group); @@ -67,12 +66,13 @@ protected slots: void showContextMenu(const QPoint &); void showEvalueColumn(bool show); void showAccessionColumn(bool show); -protected : +protected : + void refresh(); void updateStatusBar(); - void doubleclickOnproteinMatch(ProteinMatch * p_protein_match); - void clickOnproteinMatch(ProteinMatch * p_protein_match); - - + void askProteinDetailView(ProteinMatch * p_protein_match); + void askPeptideListView(ProteinMatch * p_protein_match); + + private: IdentificationGroup * _p_identification_group=nullptr; diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index ed2daa36ebe29c8f15d9404ad88e364490926fa0..eb0d5dfcd5b8549bf9d65ada0908b5ee6e6b3fea 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -42,19 +42,41 @@ bool ProteinTableProxyModel::filterAcceptsRow(int source_row, //return true; } + + void ProteinTableProxyModel::onTableClicked(const QModelIndex &index) { qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); - _protein_table_model_p->onTableClicked(this->mapToSource(index)); -} -void ProteinTableProxyModel::onTableDoubleClicked(const QModelIndex &index) -{ - qDebug() << "ProteinTableProxyModel::onTableDoubleClicked begin " << index.row(); - qDebug() << "ProteinTableProxyModel::onTableDoubleClicked begin " << this->mapToSource(index).row(); - _protein_table_model_p->onTableDoubleClicked(this->mapToSource(index)); + //_protein_table_model_p->onTableClicked(this->mapToSource(index)); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + int col = source_index.column(); + ProteinMatch* p_protein_match = _protein_table_model_p->getIdentificationGroup()->getProteinMatchList().at(row); + if (col == 0) //add a checkbox to cell(1,0) + { + + if ( p_protein_match->isChecked()) { + p_protein_match->setChecked(false); + } + else { + p_protein_match->setChecked(true); + } + _p_protein_list_window->edited(); + } + else { + if ((col == 2)||(col == 3)) { + _p_protein_list_window->askProteinDetailView(p_protein_match); + } + else { + _p_protein_list_window->askPeptideListView(p_protein_match); + } + } + qDebug() << "ProteinTableProxyModel::onTableClicked end " << index.row(); + } + bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const { QVariant leftData = sourceModel()->data(left); QVariant rightData = sourceModel()->data(right); @@ -92,10 +114,14 @@ QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orienta role); } +IdentificationGroup * ProteinTableModel::getIdentificationGroup() { + return _p_identification_group; +} ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) :QAbstractTableModel(p_protein_list_window) { _p_protein_list_window = p_protein_list_window; + _p_identification_group = nullptr; //ui->tableView->show(); // QModelIndex topLeft = createIndex(0,0); //emit a signal to make the view reread identified data @@ -103,11 +129,15 @@ ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) } void ProteinTableModel::refresh() { - qDebug() << "ProteinTableModel::refresh begin "; + if (_p_identification_group == nullptr) return; + qDebug() << "ProteinTableModel::refresh begin " << _p_identification_group->getProteinMatchList().size(); + _p_protein_list_window->refresh(); + //emit layoutAboutToBeChanged(); QModelIndex topLeft = createIndex(0,0); QModelIndex bottomRight = createIndex(rowCount(),columnCount()); + qDebug() << "ProteinTableModel::refresh emit dataChanged "; emit dataChanged(topLeft, bottomRight); - emit layoutChanged(); + //emit layoutChanged(); qDebug() << "ProteinTableModel::refresh end "; } @@ -117,8 +147,10 @@ void ProteinTableModel::hideNotValid(bool hide) { } void ProteinTableModel::hideNotChecked(bool hide) { + qDebug() << "ProteinTableModel::hideNotChecked begin "; _hide_not_checked = hide; refresh(); + qDebug() << "ProteinTableModel::hideNotChecked end "; } void ProteinTableModel::hideNotGrouped(bool hide) { _hide_not_grouped = hide; @@ -130,21 +162,22 @@ void ProteinTableModel::onProteinSearchEdit(QString protein_search_string) { QModelIndex topLeft = createIndex(0,0); QModelIndex bottomRight = createIndex(rowCount(),columnCount()); emit dataChanged(topLeft, bottomRight); - emit layoutChanged(); + //emit layoutChanged(); } void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { qDebug() << "ProteinTableModel::setIdentificationGroup begin " << p_identification_group->getProteinMatchList().size(); + beginResetModel(); _p_identification_group = p_identification_group; - QModelIndex topLeft = createIndex(0,0); - QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - emit dataChanged(topLeft, topLeft); - emit headerDataChanged(Qt::Horizontal, 0,3); - emit layoutChanged(); + //emit headerDataChanged(Qt::Horizontal, 0,11); + //refresh(); + endResetModel(); + qDebug() << "ProteinTableModel::setIdentificationGroup end "; } int ProteinTableModel::rowCount(const QModelIndex &parent ) const { + qDebug() << "ProteinTableModel::rowCount begin "; if (_p_identification_group != nullptr) { //qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); return _p_identification_group->getProteinMatchList().size(); @@ -152,7 +185,11 @@ int ProteinTableModel::rowCount(const QModelIndex &parent ) const { return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - return 11; + qDebug() << "ProteinTableModel::columnCount begin "; + if (_p_identification_group != nullptr) { + return 11; + } + return 0; } QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -280,40 +317,16 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { return QVariant(); } -void ProteinTableModel::onTableClicked(const QModelIndex &index) -{ - int row = index.row(); - int col = index.column(); - if (col == 0) //add a checkbox to cell(1,0) - { - if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) { - _p_identification_group->getProteinMatchList().at(row)->setChecked(false); - } - else { - _p_identification_group->getProteinMatchList().at(row)->setChecked(true); - } - _p_protein_list_window->edited(); - } - else { - _p_protein_list_window->clickOnproteinMatch(_p_identification_group->getProteinMatchList().at(row)); - } -} - -void ProteinTableModel::onTableDoubleClicked(const QModelIndex &index) -{ - int row = index.row(); - int col = index.column(); - _p_protein_list_window->doubleclickOnproteinMatch(_p_identification_group->getProteinMatchList().at(row)); -} - bool ProteinTableModel::acceptRow(int source_row) { try { ProteinMatch * protein_match = _p_identification_group->getProteinMatchList().at(source_row); + if (!_protein_search_string.isEmpty()) { if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { return false; } } + if (_hide_not_valid) { if (! protein_match->isValid()) { return false; @@ -337,12 +350,12 @@ bool ProteinTableModel::acceptRow(int source_row) { catch (pappso::PappsoException exception_pappso) { //QMessageBox::warning(this, // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_pappso.qwhat(); + qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_pappso.qwhat(); } catch (std::exception exception_std) { //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_std.what(); + // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); + qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_std.what(); } return true; diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 452de6c435f321eb0acc93ed37ca6db632541570..47c38557f81745aeac7494d88522da7362ccccc1 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -45,7 +45,6 @@ public: public slots: void onTableClicked(const QModelIndex &index); - void onTableDoubleClicked(const QModelIndex &index); private: ProteinTableModel* _protein_table_model_p; ProteinListWindow * _p_protein_list_window; @@ -56,13 +55,14 @@ class ProteinTableModel: public QAbstractTableModel Q_OBJECT public: ProteinTableModel(ProteinListWindow * p_protein_list_window); - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - 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; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; void setIdentificationGroup(IdentificationGroup * p_identification_group); + IdentificationGroup * getIdentificationGroup(); bool acceptRow(int source_row); void hideNotValid(bool hide); @@ -70,8 +70,6 @@ public: void hideNotGrouped(bool hide); public slots: - void onTableClicked(const QModelIndex &index); - void onTableDoubleClicked(const QModelIndex &index); void onProteinSearchEdit(QString protein_search_string); private :