Skip to content
Snippets Groups Projects
Commit 2fa0e54c authored by Langella Olivier's avatar Langella Olivier
Browse files

new item delegate to display percent and mass correctly

parent 90bde36b
No related branches found
No related tags found
No related merge requests found
......@@ -226,6 +226,7 @@ SET(XTPCPP_MOC_HDRS
./gui/waiting_message_dialog/waitingmessagedialog.h
./gui/widgets/automatic_filter_widget/automaticfilterwidget.h
./gui/widgets/contaminant_widget/contaminantwidget.h
./gui/widgets/massitemdelegate.h
./gui/xic_view/xic_box/xicbox.h
./gui/xic_view/xicwindow.h
./gui/xic_view/xicworkerthread.h
......
......@@ -22,12 +22,12 @@
******************************************************************************/
#include <QSettings>
#include "../widgets/massitemdelegate.h"
#include "peptidelistwindow.h"
#include "../project_view/projectwindow.h"
#include "ui_peptide_view.h"
PeptideListQactionColumn::PeptideListQactionColumn(PeptideListWindow * parent, PeptideListColumn column):QAction(parent) {
this->setText(PeptideTableModel::getTitle(column));
......@@ -82,6 +82,11 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent):
ui->tableView->setSortingEnabled(true);
ui->tableView->setAlternatingRowColors(true);
MassItemDelegate * item_delegate = new MassItemDelegate(ui->tableView);
ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::experimental_mhplus, item_delegate);
ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::theoretical_mhplus, item_delegate);
ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::experimental_mz, item_delegate);
//connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
......
......@@ -45,7 +45,7 @@ public:
explicit PeptideListQactionColumn(PeptideListWindow * parent, PeptideListColumn column);
~PeptideListQactionColumn();
public slots:
void doToggled(bool toggled);
......@@ -76,16 +76,16 @@ public slots:
// void setColor(const QColor &color);
// void setShape(Shape shape);
void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
protected slots:
void showContextMenu(const QPoint & pos);
signals:
void identificationGroupEdited(IdentificationGroup * p_identification_group);
void peptideDataChanged();
//void peptideChanged(pappso::PeptideSp peptide);
protected :
void askPeptideDetailView(PeptideEvidence * p_peptide_evidence);
......@@ -99,7 +99,7 @@ protected slots:
void doScanNumberSearch(int scan_num);
void doSearchOn(QString search_on);
void updateStatusBar();
private:
Ui::PeptideView *ui;
PeptideTableModel * _peptide_table_model_p = nullptr;
......
......@@ -149,7 +149,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getCharge());
break;
case (std::int8_t)PeptideListColumn::experimental_mz:
return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMz());
return QVariant (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMz());
break;
case (std::int8_t)PeptideListColumn::sequence:
return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getSequence();
......@@ -186,7 +186,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getEvalue());
break;
case (std::int8_t)PeptideListColumn::experimental_mhplus:
return QVariant((qreal) (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMass()+pappso::MHPLUS));
return QVariant((_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getExperimentalMass()+pappso::MHPLUS));
break;
case (std::int8_t)PeptideListColumn::theoretical_mhplus:
return QVariant(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1));
......
......@@ -25,6 +25,7 @@
#include "ui_protein_view.h"
#include "../mainwindow.h"
#include "../widgets/massitemdelegate.h"
#include <QSettings>
ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column):QAction(parent) {
......@@ -80,6 +81,9 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
ui->tableView->setModel( _p_proxy_model );
ui->tableView->setSortingEnabled(true);
ui->tableView->setAlternatingRowColors(true);
PercentItemDelegate * item_delegate = new PercentItemDelegate(ui->tableView);
ui->tableView->setItemDelegateForColumn((std::int8_t) ProteinListColumn::coverage, item_delegate);
QSettings settings;
bool hide = settings.value("proteinview/hidenotvalid", "true").toBool();
......
/**
* \file /gui/widgets/massitemdelegate.cpp
* \date 23/3/2018
* \author Olivier Langella
* \brief writes mass in table columns with convenient precision
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "massitemdelegate.h"
/**
* \file /gui/widgets/massitemdelegate.h
* \date 23/3/2018
* \author Olivier Langella
* \brief writes mass in table columns with convenient precision
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef MASSITEMDELEGATE_H
#define MASSITEMDELEGATE_H
#include <QStyledItemDelegate>
class PercentItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
PercentItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
QString displayText(const QVariant & value, const QLocale & locale) const override
{
QString str = QString("%1 %").arg(QString::number(value.toDouble()*100.0, 'f', 2));
return str;
}
};
class MassItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
MassItemDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
QString displayText(const QVariant & value, const QLocale & locale) const override
{
QString str = QString::number(value.toDouble(), 'f', 5);
return str;
}
};
#endif // MASSITEMDELEGATE_H
/**
* \file /output/mcqrspectralcount.h
* \file /output/mcqrspectralcount.cpp
* \date 23/3/2018
* \author Olivier Langella
* \brief write simple TSV file for MassChroqR spectral count studies
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment