diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc235eb4fde141a8b9b96326e1bcdea559c865fa..6e9c67b53d7208cbef934e80479a82ac1b645acd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp index f313fe52764d8263f78322e20d617d1aaa95ec79..fd89c31c4566625d1f424570a34e230da7d23ac6 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.cpp +++ b/src/gui/peptide_list_view/peptidelistwindow.cpp @@ -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 &))); diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h index 7188d3ebebf7cc3b2b94222316e5f4c4aad4412f..0ed4a7135a16eb004a64f95752b3b3306b6e6a5e 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.h +++ b/src/gui/peptide_list_view/peptidelistwindow.h @@ -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; diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp index 3fb37addb217f522f359a3fdb2f0fd0ed8065348..fb93131e1792be679de181f2a2d8d45ecb1007b8 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.cpp +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -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)); diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 2255a7b6a28a9fbf9792df043ffbfc3f53fa8009..1a1db5a327d8c2af4d20aefa1b4c74dcd51b7c2d 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -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(); diff --git a/src/gui/widgets/massitemdelegate.cpp b/src/gui/widgets/massitemdelegate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd11881ea6156bf59d99eb0b0153c9f3822bdd0b --- /dev/null +++ b/src/gui/widgets/massitemdelegate.cpp @@ -0,0 +1,31 @@ +/** + * \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" diff --git a/src/gui/widgets/massitemdelegate.h b/src/gui/widgets/massitemdelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..4d941f864c9a951e348af13d2ed143a4d1edf44b --- /dev/null +++ b/src/gui/widgets/massitemdelegate.h @@ -0,0 +1,66 @@ +/** + * \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 diff --git a/src/output/mcqrspectralcount.cpp b/src/output/mcqrspectralcount.cpp index 3e5b1377422138daeca754781e733bb9333c0dad..960d4cb3bf13f120bcc099e656c3bedaf03b9d88 100644 --- a/src/output/mcqrspectralcount.cpp +++ b/src/output/mcqrspectralcount.cpp @@ -1,5 +1,5 @@ /** - * \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