libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
obolistmodel.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/widget/obo/obolistwidget/obolistmodel.h
3 * \date 19/04/2021
4 * \author Olivier Langella
5 * \brief MVC 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 "obolistmodel.h"
32#include "obolistwidget.h"
34
35#include <QColor>
36#include <QDebug>
37
38using namespace pappso;
39
40OboListModel::OboListModel(QObject *parent) : QStringListModel(parent)
41{
42}
43
47
52
56
57void
59{
60 mp_parent->m_oboPsiModTermList.push_back(term);
61}
62
63
64void
66{
67 OboPsiModHandler handler(this);
68 OboPsiMod reader(handler);
69
70 qDebug() << m_oboPsiModTermList.size();
71}
72
73QVariant
74pappso::OboListModel::data(const QModelIndex &index, int role) const
75{
76
77 // generate a log message when this method gets called
78 std::size_t row = index.row();
79 // int col = index.column();
80 // qDebug() << QString("row %1, col%2, role %3")
81 // .arg(row).arg(col).arg(role);
82 if(row < m_oboPsiModTermList.size())
83 {
84
85 switch(role)
86 {
87 case Qt::CheckStateRole:
88
89 break;
90 case Qt::BackgroundRole:
91 // return QVariant(QColor("grey"));
92 break;
93 case Qt::SizeHintRole:
94 // qDebug() << "ProteinTableModel::headerData " <<
95 // ProteinTableModel::getColumnWidth(section);
96 // return QSize(PeptideTableModel::getColumnWidth(col), 30);
97 break;
98 case Qt::ToolTipRole:
99 break;
100 case Qt::DisplayRole:
101 return QVariant(QString("%1 %2 %3")
102 .arg(m_oboPsiModTermList[row].getAccession())
103 .arg(m_oboPsiModTermList[row].m_diffMono)
104 .arg(m_oboPsiModTermList[row].m_name));
105 break;
106 case Qt::UserRole:
107 QVariant value;
108 value.setValue(m_oboPsiModTermList[row]);
109 return value;
110 break;
111 }
112 }
113 return QVariant();
114}
115
116int
117pappso::OboListModel::rowCount(const QModelIndex &parent [[maybe_unused]]) const
118{
119 return (int)m_oboPsiModTermList.size();
120}
121
124{
125 if(row < (int)m_oboPsiModTermList.size())
126 {
127 return m_oboPsiModTermList[row];
128 }
129 else
130 {
131 throw pappso::ExceptionNotFound(tr("OBO term not found"));
132 }
133}
void setOboPsiModTerm(const OboPsiModTerm &term) override
triggered function on each obo term when parsing obo file
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
const OboPsiModTerm & getOboPsiModTerm(int row) const
OboListModel(QObject *parent=nullptr)
std::vector< OboPsiModTerm > m_oboPsiModTermList
int rowCount(const QModelIndex &parent=QModelIndex()) const override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39