libpappsomspp
Library for mass spectrometry
obolistwidget.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/widget/obo/obolistwidget/obolistwidget.cpp
3  * \date 17/04/2021
4  * \author Olivier Langella
5  * \brief handles a list of obo term, select and click
6  */
7 
8 
9 /*******************************************************************************
10  * Copyright (c) 2021 Olivier Langella
11  *<Olivier.Langella@universite-paris-saclay.fr>.
12  *
13  * This file is part of the PAPPSOms++ library.
14  *
15  * PAPPSOms++ is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * PAPPSOms++ is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
27  *
28  ******************************************************************************/
29 
30 #include "obolistwidget.h"
31 #include "ui_uiobolistwidget.h"
32 #include <QDebug>
33 #include "obolistproxymodel.h"
34 #include "../../../mzrange.h"
35 
36 using namespace pappso;
37 
39  : QWidget(parent), ui(new Ui::OboListWidgetForm)
40 {
41  qDebug();
42  ui->setupUi(this);
43 
44  mpa_oboListModel = new OboListModel(this);
46 
48  mpa_oboListProxyModel->setSourceModel(mpa_oboListModel);
49  // mpa_oboListProxyModel->setSortRole(Qt::UserRole);
50 
51  ui->oboTermListView->setModel(mpa_oboListProxyModel);
52 
53  mpa_oboListProxyModel->sort(Qt::AscendingOrder);
54 
55  connect(ui->oboTermListView->selectionModel(),
56  &QItemSelectionModel::selectionChanged,
57  this,
59 }
60 
62 {
63  delete ui;
64  if(mpa_oboListProxyModel != nullptr)
65  {
66  delete mpa_oboListProxyModel;
67  }
68  if(mpa_oboListModel != nullptr)
69  {
70  delete mpa_oboListModel;
71  }
72 }
73 
74 void
75 pappso::OboListWidget::onSelectionChanged(const QItemSelection &selected,
76  const QItemSelection &deselected
77  [[maybe_unused]])
78 {
79  QModelIndexList index_list =
80  mpa_oboListProxyModel->mapSelectionToSource(selected).indexes();
81 
82  if(index_list.size() > 0)
83  {
84  QModelIndex index = index_list.first();
85  OboPsiModTerm term =
86  mpa_oboListModel->data(index, Qt::UserRole).value<OboPsiModTerm>();
87  qDebug() << term.m_accession;
88  emit oboTermChanged(term);
89  }
90 }
91 
92 void
94  pappso::PrecisionPtr precision)
95 {
96  qDebug();
97  mpa_oboListProxyModel->filterMzPrecision(target_mz, precision);
98  if(precision == nullptr)
99  {
100  ui->massFilterGroupBox->setChecked(false);
101  ui->mzSpinBox->setValue(target_mz);
102  }
103  else
104  {
105  ui->massFilterGroupBox->setChecked(true);
106  ui->precisionWidget->setPrecision(precision);
107  ui->mzSpinBox->setValue(target_mz);
108  }
109 }
110 
111 void
113 {
114  qDebug();
115  if(ui->massFilterGroupBox->isChecked())
116  {
117  mpa_oboListProxyModel->filterMzPrecision(
118  ui->mzSpinBox->value(), ui->precisionWidget->getPrecision());
119  }
120  else
121  {
122  mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
123  }
124 }
125 
126 void
128  [[maybe_unused]])
129 {
130  onFilterChanged();
131 }
132 
133 double
135 {
136  return ui->mzSpinBox->value();
137 }
138 
141 {
142  if(ui->massFilterGroupBox->isChecked())
143  {
144  return ui->precisionWidget->getPrecision();
145  }
146  return nullptr;
147 }
PrecisionPtr getPrecisionPtr() const
get the current precision used to filter term list
void filterMzPrecision(double target_mz, PrecisionPtr precision)
OboListWidget(QWidget *parent=nullptr)
Ui::OboListWidgetForm * ui
Definition: obolistwidget.h:85
double getMzTarget() const
get the current mz value used to filter term list
OboListProxyModel * mpa_oboListProxyModel
Definition: obolistwidget.h:88
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
OboListModel * mpa_oboListModel
Definition: obolistwidget.h:87
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
MVC proxy model of OBO term list.
handles a list of obo term, select and click