From 75033be96a20335818c00807ec30f31dd734f3c8 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 20 Apr 2017 23:03:46 +0200 Subject: [PATCH] search combo box --- src/gui/project_view/projectwindow.cpp | 16 ++--- src/gui/protein_list_view/protein_view.ui | 66 ++++++++++++++++++- .../protein_list_view/proteinlistwindow.cpp | 8 ++- src/gui/protein_list_view/proteinlistwindow.h | 1 + .../proteintableproxymodel.cpp | 27 +++++++- .../proteintableproxymodel.h | 2 + 6 files changed, 107 insertions(+), 13 deletions(-) diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 3c2a0b23..acb57431 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -260,8 +260,8 @@ void ProjectWindow::doViewPeptideList(IdentificationGroup * p_ident_group, Prote _p_current_peptide_list_window->setProteinMatch(p_ident_group, protein_match); _p_current_peptide_list_window->show(); - _p_current_peptide_list_window->raise(); - _p_current_peptide_list_window->activateWindow(); + //_p_current_peptide_list_window->raise(); + //_p_current_peptide_list_window->activateWindow(); qDebug() << "ProjectWindow::doViewPeptideList end"; } @@ -279,8 +279,8 @@ void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) { _p_current_peptide_detail_window->setPeptideMatch(peptide_match); _p_current_peptide_detail_window->show(); - _p_current_peptide_detail_window->raise(); - _p_current_peptide_detail_window->activateWindow(); + //_p_current_peptide_detail_window->raise(); + //_p_current_peptide_detail_window->activateWindow(); emit peptideMatchSelected(peptide_match); qDebug() << "ProjectWindow::doViewPeptideDetail end"; @@ -301,8 +301,8 @@ void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) { _p_current_protein_detail_window->setProteinMatch(protein_match); _p_current_protein_detail_window->show(); - _p_current_protein_detail_window->raise(); - _p_current_protein_detail_window->activateWindow(); + //_p_current_protein_detail_window->raise(); + //_p_current_protein_detail_window->activateWindow(); qDebug() << "ProjectWindow::doViewProteinDetail end"; } @@ -320,8 +320,8 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou _p_current_protein_list_window->show(); - _p_current_protein_list_window->raise(); - _p_current_protein_list_window->activateWindow(); + //_p_current_protein_list_window->raise(); + //_p_current_protein_list_window->activateWindow(); qDebug() << "ProjectWindow::doViewProteinList end " << p_identification_group; _p_current_protein_list_window->setIdentificationGroup(p_identification_group); diff --git a/src/gui/protein_list_view/protein_view.ui b/src/gui/protein_list_view/protein_view.ui index dedeb0a9..13cf419c 100644 --- a/src/gui/protein_list_view/protein_view.ui +++ b/src/gui/protein_list_view/protein_view.ui @@ -61,7 +61,37 @@ </widget> </item> <item> - <widget class="QLineEdit" name="proteinSearchEdit"/> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>search</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="search_combobox"> + <item> + <property name="text"> + <string>accession</string> + </property> + </item> + <item> + <property name="text"> + <string>description</string> + </property> + </item> + <item> + <property name="text"> + <string>group</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLineEdit" name="protein_search_edit"/> + </item> + </layout> </item> </layout> </widget> @@ -127,10 +157,44 @@ </hint> </hints> </connection> + <connection> + <sender>protein_search_edit</sender> + <signal>textChanged(QString)</signal> + <receiver>ProteinView</receiver> + <slot>onProteinSearchEdit(QString)</slot> + <hints> + <hint type="sourcelabel"> + <x>352</x> + <y>363</y> + </hint> + <hint type="destinationlabel"> + <x>879</x> + <y>391</y> + </hint> + </hints> + </connection> + <connection> + <sender>search_combobox</sender> + <signal>activated(QString)</signal> + <receiver>ProteinView</receiver> + <slot>doSearchOn(QString)</slot> + <hints> + <hint type="sourcelabel"> + <x>121</x> + <y>354</y> + </hint> + <hint type="destinationlabel"> + <x>867</x> + <y>386</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>doNotValidHide(bool)</slot> <slot>doNotCheckedHide(bool)</slot> <slot>doNotGroupedHide(bool)</slot> + <slot>onProteinSearchEdit(QString)</slot> + <slot>doSearchOn(QString)</slot> </slots> </ui> diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 8515a4d9..c426e957 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -77,7 +77,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged())); 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->proteinSearchEdit, SIGNAL(textChanged(QString)), this, SLOT(onProteinSearchEdit(QString))); + //connect(ui->protein_search_edit, SIGNAL(textChanged(QString)), this, SLOT(onProteinSearchEdit(QString))); //connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) ); @@ -187,6 +187,12 @@ void ProteinListWindow::doNotGroupedHide(bool hide) { qDebug() << "ProteinListWindow::doNotGroupedHide end"; } +void ProteinListWindow::doSearchOn(QString search_on) { + qDebug() << "ProteinTableProxyModel::doSearchOn begin " << search_on; + _p_proxy_model->setSearchOn( search_on); + emit proteinDataChanged(); +} + void ProteinListWindow::onProteinSearchEdit(QString protein_search_string) { qDebug() << "ProteinTableProxyModel::onProteinSearchEdit begin " << protein_search_string; diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 45961379..a4460a4e 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -70,6 +70,7 @@ protected slots: void showAccessionColumn(bool show); void updateStatusBar(); void onProteinSearchEdit(QString protein_search_string); + void doSearchOn(QString search_on); protected : void askProteinDetailView(ProteinMatch * p_protein_match); diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp index e447e879..234bf5e1 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.cpp +++ b/src/gui/protein_list_view/proteintableproxymodel.cpp @@ -40,8 +40,27 @@ bool ProteinTableProxyModel::filterAcceptsRow(int source_row, //qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " << source_row; if (!_protein_search_string.isEmpty()) { - if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { - return false; + if (_search_on == "accession") { + if (!protein_match->getProteinXtpSp().get()->getAccession().contains(_protein_search_string)) { + return false; + } + } + else if (_search_on == "group") { + pappso::GrpProtein * p_grp_prot = protein_match->getGrpProteinSp().get(); + if (p_grp_prot == nullptr) { + return false; + } + else { + p_grp_prot->getGroupingId(); + if (!p_grp_prot->getGroupingId().startsWith(_protein_search_string)) { + return false; + } + } + } + else { + if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { + return false; + } } } @@ -172,7 +191,9 @@ void ProteinTableProxyModel::hideNotChecked(bool hide) { void ProteinTableProxyModel::hideNotGrouped(bool hide) { _hide_not_grouped = hide; } - +void ProteinTableProxyModel::setSearchOn(QString search_on) { + _search_on = search_on; +} void ProteinTableProxyModel::setProteinSearchString(QString protein_search_string) { _protein_search_string = protein_search_string; } diff --git a/src/gui/protein_list_view/proteintableproxymodel.h b/src/gui/protein_list_view/proteintableproxymodel.h index ee08bab7..e97d3276 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.h +++ b/src/gui/protein_list_view/proteintableproxymodel.h @@ -47,6 +47,7 @@ public: void hideNotChecked(bool hide); void hideNotGrouped(bool hide); void setProteinSearchString(QString protein_search_string); + void setSearchOn(QString search_on); public slots: void onTableClicked(const QModelIndex &index); @@ -54,6 +55,7 @@ public slots: private: ProteinTableModel* _protein_table_model_p; ProteinListWindow * _p_protein_list_window; + QString _search_on = "accession"; QString _protein_search_string; bool _hide_not_valid = true; bool _hide_not_checked = true; -- GitLab