Loading...
Searching...
No Matches
obolistwidget.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/widget/obo/obolistwidget/obolistwidget.cpp
* \date 17/04/2021
* \author Olivier Langella
* \brief handles a list of obo term, select and click
*/
/*******************************************************************************
* Copyright (c) 2021 Olivier Langella
*<Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "obolistwidget.h"
#include "ui_uiobolistwidget.h"
#include <QDebug>
#include "obolistproxymodel.h"
#include "../../../mzrange.h"
using namespace pappso;
OboListWidget::OboListWidget(QWidget *parent)
: QWidget(parent), ui(new Ui::OboListWidgetForm)
{
qDebug();
ui->setupUi(this);
mpa_oboListModel = new OboListModel(this);
mpa_oboListModel->loadPsiMod();
mpa_oboListProxyModel = new OboListProxyModel(mpa_oboListModel, this);
mpa_oboListProxyModel->setSourceModel(mpa_oboListModel);
// mpa_oboListProxyModel->setSortRole(Qt::UserRole);
ui->oboTermListView->setModel(mpa_oboListProxyModel);
mpa_oboListProxyModel->sort(Qt::AscendingOrder);
connect(ui->oboTermListView->selectionModel(),
&QItemSelectionModel::selectionChanged,
this,
&OboListWidget::onSelectionChanged);
}
OboListWidget::~OboListWidget()
{
delete ui;
if(mpa_oboListProxyModel != nullptr)
{
delete mpa_oboListProxyModel;
}
if(mpa_oboListModel != nullptr)
{
delete mpa_oboListModel;
}
}
void
pappso::OboListWidget::onSelectionChanged(const QItemSelection &selected,
const QItemSelection &deselected
[[maybe_unused]])
{
QModelIndexList index_list =
mpa_oboListProxyModel->mapSelectionToSource(selected).indexes();
if(index_list.size() > 0)
{
QModelIndex index = index_list.first();
OboPsiModTerm term =
mpa_oboListModel->data(index, Qt::UserRole).value<OboPsiModTerm>();
qDebug() << term.m_accession;
emit oboTermChanged(term);
}
}
void
pappso::OboListWidget::filterMzPrecision(double target_mz,
pappso::PrecisionPtr precision)
{
qDebug();
mpa_oboListProxyModel->filterMzPrecision(target_mz, precision);
if(precision == nullptr)
{
ui->massFilterGroupBox->setChecked(false);
ui->mzSpinBox->setValue(target_mz);
}
else
{
ui->massFilterGroupBox->setChecked(true);
ui->precisionWidget->setPrecision(precision);
ui->mzSpinBox->setValue(target_mz);
}
}
void
pappso::OboListWidget::onFilterChanged()
{
qDebug();
if(ui->massFilterGroupBox->isChecked())
{
mpa_oboListProxyModel->filterMzPrecision(
ui->mzSpinBox->value(), ui->precisionWidget->getPrecision());
}
else
{
mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
}
}
void
pappso::OboListWidget::onFilterChanged(double value [[maybe_unused]])
{
qDebug();
if(ui->massFilterGroupBox->isChecked())
{
mpa_oboListProxyModel->filterMzPrecision(
ui->mzSpinBox->value(), ui->precisionWidget->getPrecision());
}
else
{
mpa_oboListProxyModel->filterMzPrecision(0, nullptr);
}
}
void
pappso::OboListWidget::onFilterChanged(pappso::PrecisionPtr precision
[[maybe_unused]])
{
onFilterChanged();
}
double
pappso::OboListWidget::getMzTarget() const
{
return ui->mzSpinBox->value();
}
pappso::PrecisionPtr
pappso::OboListWidget::getPrecisionPtr() const
{
if(ui->massFilterGroupBox->isChecked())
{
return ui->precisionWidget->getPrecision();
}
return nullptr;
}
pappso::OboListModel
Definition obolistmodel.h:46
pappso::OboListModel::loadPsiMod
void loadPsiMod()
Definition obolistmodel.cpp:67
pappso::OboListProxyModel
Definition obolistproxymodel.h:43
pappso::OboListWidget::getPrecisionPtr
PrecisionPtr getPrecisionPtr() const
get the current precision used to filter term list
Definition obolistwidget.cpp:155
pappso::OboListWidget::filterMzPrecision
void filterMzPrecision(double target_mz, PrecisionPtr precision)
Definition obolistwidget.cpp:93
pappso::OboListWidget::OboListWidget
OboListWidget(QWidget *parent=nullptr)
Definition obolistwidget.cpp:38
pappso::OboListWidget::ui
Ui::OboListWidgetForm * ui
Definition obolistwidget.h:87
pappso::OboListWidget::getMzTarget
double getMzTarget() const
get the current mz value used to filter term list
Definition obolistwidget.cpp:149
pappso::OboListWidget::mpa_oboListProxyModel
OboListProxyModel * mpa_oboListProxyModel
Definition obolistwidget.h:90
pappso::OboListWidget::onFilterChanged
void onFilterChanged()
Definition obolistwidget.cpp:112
pappso::OboListWidget::onSelectionChanged
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Definition obolistwidget.cpp:75
pappso::OboListWidget::~OboListWidget
~OboListWidget()
Definition obolistwidget.cpp:61
pappso::OboListWidget::mpa_oboListModel
OboListModel * mpa_oboListModel
Definition obolistwidget.h:89
pappso::OboPsiModTerm
Definition obopsimodterm.h:32
pappso::OboPsiModTerm::m_accession
QString m_accession
Definition obopsimodterm.h:48
pappso::PrecisionBase
Definition precision.h:44
Ui
Definition obochooserwidget.h:38
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
obolistproxymodel.h
MVC proxy model of OBO term list.
obolistwidget.h
handles a list of obo term, select and click