libpappsomspp
Library for mass spectrometry
obolistproxymodel.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/widget/obo/obolistwidget/obolistproxymodel.cpp
3 * \date 19/04/2021
4 * \author Olivier Langella
5 * \brief MVC proxy model of OBO term list
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 "obolistproxymodel.h"
31#include "../../../obo/obopsimod.h"
32#include "../../../mzrange.h"
33#include <QDebug>
34
35using namespace pappso;
36
37OboListProxyModel::OboListProxyModel(OboListModel *source_model,
38 QObject *parent)
39 : QSortFilterProxyModel(parent)
40{
41 setFilterRole(Qt::DisplayRole);
42 mp_sourceModel = source_model;
43}
44
46{
47}
48
49bool
50pappso::OboListProxyModel::lessThan(const QModelIndex &source_left,
51 const QModelIndex &source_right) const
52{
53 // qDebug();
54
55 QVariant leftData = sourceModel()->data(source_left, Qt::UserRole);
56 QVariant rightData = sourceModel()->data(source_right, Qt::UserRole);
57
58 return leftData.value<OboPsiModTerm>().m_diffMono <
59 rightData.value<OboPsiModTerm>().m_diffMono;
60}
61
62void
64 pappso::PrecisionPtr precision)
65{
66 m_precisionPtr = precision;
67 m_mzTarget = target_mz;
68 invalidateFilter();
69}
70
71bool
73 const QModelIndex &source_parent
74 [[maybe_unused]]) const
75{
76 // qDebug();
77 if(m_precisionPtr != nullptr)
78 {
79 MzRange range(m_mzTarget, m_precisionPtr);
80 OboPsiModTerm term = mp_sourceModel->getOboPsiModTerm(source_row);
81 /*
82 qDebug() << source_row << " " << source_parent.row() << " "
83 << range.toString() << " " << term.m_diffMono << " "
84 << term.m_accession;
85 */
86 if(range.contains(term.m_diffMono))
87 {
88 // qDebug();
89 }
90 else
91 {
92 // qDebug() << "false";
93 return false;
94 }
95 }
96 return true;
97}
bool contains(pappso_double) const
Definition: mzrange.cpp:120
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void filterMzPrecision(double target_mz, PrecisionPtr precision)
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.