libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
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
"
31
#include "
../../../core/obo/obopsimod.h
"
32
#include "
../../../core/mzrange.h
"
33
#include <QDebug>
34
35
using namespace
pappso
;
36
37
OboListProxyModel::OboListProxyModel
(
OboListModel
*source_model, QObject *parent)
38
: QSortFilterProxyModel(parent)
39
{
40
setFilterRole(Qt::DisplayRole);
41
mp_sourceModel
= source_model;
42
}
43
44
OboListProxyModel::~OboListProxyModel
()
45
{
46
}
47
48
bool
49
pappso::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
60
void
61
pappso::OboListProxyModel::filterMzPrecision
(
double
target_mz,
pappso::PrecisionPtr
precision)
62
{
63
m_precisionPtr
= precision;
64
m_mzTarget
= target_mz;
65
invalidateFilter();
66
}
67
68
bool
69
pappso::OboListProxyModel::filterAcceptsRow
(
int
source_row,
70
const
QModelIndex &source_parent [[maybe_unused]])
const
71
{
72
// qDebug();
73
if
(
m_precisionPtr
!=
nullptr
)
74
{
75
MzRange
range(
m_mzTarget
,
m_precisionPtr
);
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
}
pappso::MzRange
Definition
mzrange.h:46
pappso::MzRange::contains
bool contains(pappso_double) const
Definition
mzrange.cpp:115
pappso::OboListModel
Definition
obolistmodel.h:46
pappso::OboListModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition
obolistmodel.cpp:89
pappso::OboListProxyModel::m_mzTarget
double m_mzTarget
Definition
obolistproxymodel.h:65
pappso::OboListProxyModel::~OboListProxyModel
~OboListProxyModel()
Definition
obolistproxymodel.cpp:44
pappso::OboListProxyModel::OboListProxyModel
OboListProxyModel(OboListModel *source_model, QObject *parent=nullptr)
Definition
obolistproxymodel.cpp:37
pappso::OboListProxyModel::m_precisionPtr
PrecisionPtr m_precisionPtr
Definition
obolistproxymodel.h:64
pappso::OboListProxyModel::mp_sourceModel
OboListModel * mp_sourceModel
Definition
obolistproxymodel.h:66
pappso::OboListProxyModel::lessThan
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Definition
obolistproxymodel.cpp:49
pappso::OboListProxyModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition
obolistproxymodel.cpp:69
pappso::OboListProxyModel::filterMzPrecision
void filterMzPrecision(double target_mz, PrecisionPtr precision)
Definition
obolistproxymodel.cpp:61
pappso::OboPsiModTerm
Definition
obopsimodterm.h:34
pappso::OboPsiModTerm::m_diffMono
double m_diffMono
Definition
obopsimodterm.h:66
mzrange.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition
precision.h:122
obolistproxymodel.h
obopsimod.h
pappsomspp
gui
obo
obolistwidget
obolistproxymodel.cpp
Generated on
for libpappsomspp by
1.17.0