libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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"
33#include <QDebug>
34
35using namespace pappso;
36
38 : QSortFilterProxyModel(parent)
39{
40 setFilterRole(Qt::DisplayRole);
41 mp_sourceModel = source_model;
42}
43
47
48bool
49pappso::OboListProxyModel::lessThan(const QModelIndex &source_left,
50 const QModelIndex &source_right) const
51{
52 // qDebug();
53
54 QVariant leftData = sourceModel()->data(source_left, Qt::UserRole);
55 QVariant rightData = sourceModel()->data(source_right, Qt::UserRole);
56
57 return leftData.value<OboPsiModTerm>().m_diffMono < rightData.value<OboPsiModTerm>().m_diffMono;
58}
59
60void
62{
63 m_precisionPtr = precision;
64 m_mzTarget = target_mz;
65 invalidateFilter();
66}
67
68bool
70 const QModelIndex &source_parent [[maybe_unused]]) const
71{
72 // qDebug();
73 if(m_precisionPtr != nullptr)
74 {
76 OboPsiModTerm term = mp_sourceModel->getOboPsiModTerm(source_row);
77 /*
78 qDebug() << source_row << " " << source_parent.row() << " "
79 << range.toString() << " " << term.m_diffMono << " "
80 << term.m_accession;
81 */
82 if(range.contains(term.m_diffMono))
83 {
84 // qDebug();
85 }
86 else
87 {
88 // qDebug() << "false";
89 return false;
90 }
91 }
92 return true;
93}
bool contains(pappso_double) const
Definition mzrange.cpp:115
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
OboListProxyModel(OboListModel *source_model, QObject *parent=nullptr)
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
const PrecisionBase * PrecisionPtr
Definition precision.h:122