libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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"
35
36using namespace pappso;
37
38OboListWidget::OboListWidget(QWidget *parent) : QWidget(parent), ui(new Ui::OboListWidgetForm)
39{
40 qDebug();
41 ui->setupUi(this);
42
44 mpa_oboListModel->loadPsiMod();
45
48 // mpa_oboListProxyModel->setSortRole(Qt::UserRole);
49
50 ui->oboTermListView->setModel(mpa_oboListProxyModel);
51
52 mpa_oboListProxyModel->sort(Qt::AscendingOrder);
53
54 connect(ui->oboTermListView->selectionModel(),
55 &QItemSelectionModel::selectionChanged,
56 this,
58}
59
61{
62 delete ui;
63 if(mpa_oboListProxyModel != nullptr)
64 {
66 }
67 if(mpa_oboListModel != nullptr)
68 {
69 delete mpa_oboListModel;
70 }
71}
72
73void
74pappso::OboListWidget::onSelectionChanged(const QItemSelection &selected,
75 const QItemSelection &deselected [[maybe_unused]])
76{
77 QModelIndexList index_list = mpa_oboListProxyModel->mapSelectionToSource(selected).indexes();
78
79 if(index_list.size() > 0)
80 {
81 QModelIndex index = index_list.first();
82 OboPsiModTerm term = mpa_oboListModel->data(index, Qt::UserRole).value<OboPsiModTerm>();
83 qDebug() << term.getAccession();
84 emit oboTermChanged(term);
85 }
86}
87
88void
90{
91 qDebug();
92 mpa_oboListProxyModel->filterMzPrecision(target_mz, precision);
93 if(precision == nullptr)
94 {
95 ui->massFilterGroupBox->setChecked(false);
96 ui->mzSpinBox->setValue(target_mz);
97 }
98 else
99 {
100 ui->massFilterGroupBox->setChecked(true);
101 ui->precisionWidget->setPrecision(precision);
102 ui->mzSpinBox->setValue(target_mz);
103 }
104}
105
106void
108{
109 qDebug();
110 if(ui->massFilterGroupBox->isChecked())
111 {
112 mpa_oboListProxyModel->filterMzPrecision(ui->mzSpinBox->value(),
113 ui->precisionWidget->getPrecision());
114 }
115 else
116 {
117 mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
118 }
119}
120
121void
122pappso::OboListWidget::onFilterChanged(double value [[maybe_unused]])
123{
124 qDebug();
125 if(ui->massFilterGroupBox->isChecked())
126 {
127 mpa_oboListProxyModel->filterMzPrecision(ui->mzSpinBox->value(),
128 ui->precisionWidget->getPrecision());
129 }
130 else
131 {
132 mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
133 }
134}
135
136void
141
142double
144{
145 return ui->mzSpinBox->value();
146}
147
150{
151 if(ui->massFilterGroupBox->isChecked())
152 {
153 return ui->precisionWidget->getPrecision();
154 }
155 return nullptr;
156}
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
double getMzTarget() const
get the current mz value used to filter term list
OboListProxyModel * mpa_oboListProxyModel
void oboTermChanged(OboPsiModTerm oboTerm) const
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
OboListModel * mpa_oboListModel
void onFilterChanged(pappso::PrecisionPtr precision)
const QString & getAccession() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
const PrecisionBase * PrecisionPtr
Definition precision.h:122