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"
34#include "../../../mzrange.h"
35
36using namespace pappso;
37
39 : QWidget(parent), ui(new Ui::OboListWidgetForm)
40{
41 qDebug();
42 ui->setupUi(this);
43
46
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 {
67 }
68 if(mpa_oboListModel != nullptr)
69 {
70 delete mpa_oboListModel;
71 }
72}
73
74void
75pappso::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
92void
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
111void
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
126void
127pappso::OboListWidget::onFilterChanged(double value [[maybe_unused]])
128{
129 qDebug();
130 if(ui->massFilterGroupBox->isChecked())
131 {
132 mpa_oboListProxyModel->filterMzPrecision(
133 ui->mzSpinBox->value(), ui->precisionWidget->getPrecision());
134 }
135 else
136 {
137 mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
138 }
139}
140
141void
143 [[maybe_unused]])
144{
145 onFilterChanged();
146}
147
148double
150{
151 return ui->mzSpinBox->value();
152}
153
156{
157 if(ui->massFilterGroupBox->isChecked())
158 {
159 return ui->precisionWidget->getPrecision();
160 }
161 return nullptr;
162}
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 onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
OboListModel * mpa_oboListModel
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