From d7370d00d8548763e8d839c92379322e62f33848 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Fri, 28 Jul 2017 08:12:43 +0200 Subject: [PATCH] WIP: new ptm sequence delegate --- src/CMakeLists.txt | 2 + src/grouping/ptm/ptmsamplescan.h | 3 +- .../ptmpeptidelistwindow.cpp | 4 ++ .../ptmpeptidetablemodel.cpp | 2 +- .../ptmsequencedelegate.cpp | 49 +++++++++++++++++ .../ptmsequencedelegate.h | 52 +++++++++++++++++++ 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp create mode 100644 src/gui/ptm_peptide_list_view/ptmsequencedelegate.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3895ace75..f3ef52a3f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -131,6 +131,7 @@ SET(XTPCPP_SRCS ./gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp ./gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp ./gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp + ./gui/ptm_peptide_list_view/ptmsequencedelegate.cpp ./gui/waiting_message_dialog/waitingmessagedialog.cpp ./gui/workerthread.cpp ./utils/workmonitor.cpp @@ -181,6 +182,7 @@ SET(XTPCPP_MOC_HDRS ./gui/ptm_peptide_list_view/ptmpeptidelistwindow.h ./gui/ptm_peptide_list_view/ptmpeptidetablemodel.h ./gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h + ./gui/ptm_peptide_list_view/ptmsequencedelegate.h ./gui/waiting_message_dialog/waitingmessagedialog.h ./gui/workerthread.h ./utils/workmonitor.h diff --git a/src/grouping/ptm/ptmsamplescan.h b/src/grouping/ptm/ptmsamplescan.h index 9036a2768..0756aecb2 100644 --- a/src/grouping/ptm/ptmsamplescan.h +++ b/src/grouping/ptm/ptmsamplescan.h @@ -44,7 +44,7 @@ typedef std::shared_ptr<PtmSampleScan> PtmSampleScanSp; class PtmSampleScan { public: - PtmSampleScan(const PeptideMatch * p_peptide_match); + PtmSampleScan(const PeptideMatch * p_peptide_match=nullptr); PtmSampleScan(const PtmSampleScan& other); ~PtmSampleScan(); @@ -58,4 +58,5 @@ private: }; +Q_DECLARE_METATYPE(PtmSampleScan *) #endif // PTMSAMPLESCAN_H diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp index 15ec5d135..bd6541224 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp @@ -29,6 +29,8 @@ #include "ptmpeptidelistwindow.h" #include "../ptm_island_list_view/ptmislandlistwindow.h" +#include "ptmpeptidetablemodel.h" +#include "ptmsequencedelegate.h" #include "ui_ptm_peptide_list_view.h" @@ -48,6 +50,8 @@ PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWi ui->ptm_peptide_tableview->setModel( _ptm_proxy_model_p ); ui->ptm_peptide_tableview->setSortingEnabled(true); ui->ptm_peptide_tableview->setAlternatingRowColors(true); + PtmSequenceDelegate * p_sequence_delegate = new PtmSequenceDelegate(); + ui->ptm_peptide_tableview->setItemDelegateForColumn((std::int8_t) PtmPeptideListColumn::sequence, p_sequence_delegate); diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp index 9a7a17818..8a9bf2f03 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp @@ -199,7 +199,7 @@ QVariant PtmPeptideTableModel::data(const QModelIndex &index, int role ) const { return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getCharge()); break; case (std::int8_t)PtmPeptideListColumn::sequence: - return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getSequence(); + return QVariant::fromValue( _ptm_sample_scan_list.at(row).get()); break; case (std::int8_t)PtmPeptideListColumn::modifs: return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getModifString(); diff --git a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp new file mode 100644 index 000000000..371eb3527 --- /dev/null +++ b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.cpp @@ -0,0 +1,49 @@ +/** + * \file gui/ptm_peptide_list_window/ptmsequencedelegate.cpp + * \date 28/7/2017 + * \author Olivier Langella + */ + +/******************************************************************************* +* Copyright (c) 2017 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 "ptmsequencedelegate.h" + +PtmSequenceDelegate::PtmSequenceDelegate(QWidget *parent) : QStyledItemDelegate(parent) { + +} + +void PtmSequenceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + /*if (index.data().canConvert<StarRating>()) { + StarRating starRating = qvariant_cast<StarRating>(index.data()); + + if (option.state & QStyle::State_Selected) + painter->fillRect(option.rect, option.palette.highlight()); + + starRating.paint(painter, option.rect, option.palette, + StarRating::ReadOnly); + } else {*/ + QStyledItemDelegate::paint(painter, option, index); + //} +} diff --git a/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h new file mode 100644 index 000000000..526092fa3 --- /dev/null +++ b/src/gui/ptm_peptide_list_view/ptmsequencedelegate.h @@ -0,0 +1,52 @@ +/** + * \file gui/ptm_peptide_list_window/ptmsequencedelegate.h + * \date 28/7/2017 + * \author Olivier Langella + */ + +/******************************************************************************* +* Copyright (c) 2017 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 PTMSEQUENCEDELEGATE_H +#define PTMSEQUENCEDELEGATE_H + +#include <QStyledItemDelegate> + +class PtmSequenceDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + PtmSequenceDelegate(QWidget *parent = 0); + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + void setEditorData(QWidget *editor, const QModelIndex &index) const override; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const override; + +}; +#endif // PTMSEQUENCEDELEGATE_H -- GitLab