From f0db979de890bc6b1e4742650be4db43d4188d47 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Sun, 9 Jul 2017 17:37:07 +0200 Subject: [PATCH] peptide list column sizes --- .../peptide_list_view/peptidetablemodel.cpp | 34 ++++++++++++++++--- src/gui/peptide_list_view/peptidetablemodel.h | 6 ++-- .../protein_list_view/proteintablemodel.cpp | 8 ++--- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp index f3dec865..68d7a7f4 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.cpp +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -25,14 +25,16 @@ #include <QDebug> #include <QColor> +#include <QSize> +#include "peptidelistwindow.h" #include <pappsomspp/grouping/grppeptide.h> #include "../../core/labeling/label.h" -PeptideTableModel::PeptideTableModel(QObject *parent) +PeptideTableModel::PeptideTableModel(PeptideListWindow * parent) :QAbstractTableModel(parent) { - + _p_peptide_list_window = parent; //ui->tableView->show(); // QModelIndex topLeft = createIndex(0,0); //emit a signal to make the view reread identified data @@ -49,7 +51,7 @@ void PeptideTableModel::setProteinMatch(ProteinMatch * p_protein_match) { //QModelIndex topLeft = createIndex(0,0); //QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - + _p_peptide_list_window->resizeColumnsToContents(); //emit dataChanged(topLeft, topLeft); //emit headerDataChanged(Qt::Horizontal, 0,3); qDebug() << "PeptideTableModel::setProteinMatch end " ; @@ -110,6 +112,10 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const { return QVariant(QColor("grey")); } break; + case Qt::SizeHintRole : + //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); + return QSize( PeptideTableModel::getColumnWidth(col), 30 ); + break; case Qt::DisplayRole: if (_p_protein_match == nullptr) { } @@ -218,7 +224,7 @@ void PeptideTableModel::onPeptideDataChanged() { -PeptideListColumn PeptideTableModel::getPeptideListColumn(std::int8_t column){ +PeptideListColumn PeptideTableModel::getPeptideListColumn(std::int8_t column) { return static_cast<PeptideListColumn>(column); } const QString PeptideTableModel::getTitle(PeptideListColumn column) { @@ -351,3 +357,23 @@ const QString PeptideTableModel::getDescription(std::int8_t column) { } return ""; } + +int PeptideTableModel::getColumnWidth(int column) { + qDebug() << "PeptideTableModel::getColumnWidth " << column; + switch (column) { + + case (int) PeptideListColumn::checked: + break; + + case (int) PeptideListColumn::peptide_grouping_id: + return 120; + break; + case (int) PeptideListColumn::sample: + return 250; + break; + case (int) PeptideListColumn::sequence: + return 250; + break; + } + return 100; +} diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h index 33d1ec2c..7efe6a53 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.h +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -51,13 +51,13 @@ enum class PeptideListColumn: std::int8_t { hyperscore=16 }; -class PeptideTableModel; +class PeptideListWindow; class PeptideTableModel: public QAbstractTableModel { Q_OBJECT public: - PeptideTableModel(QObject *parent=0); + PeptideTableModel(PeptideListWindow *parent); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; @@ -80,8 +80,10 @@ public slots: private : static const QString getTitle(std::int8_t column); static const QString getDescription(std::int8_t column); + static int getColumnWidth(int column); private : ProteinMatch * _p_protein_match= nullptr; + PeptideListWindow * _p_peptide_list_window=nullptr; }; #endif // PEPTIDETABLEMODEL_H diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index b495df5f..2e229441 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -244,10 +244,10 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { } } break; - case Qt::SizeHintRole : - //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); - return QSize( ProteinTableModel::getColumnWidth(col), 30 ); - break; + case Qt::SizeHintRole : + //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); + return QSize( ProteinTableModel::getColumnWidth(col), 30 ); + break; case Qt::BackgroundRole: if (_p_identification_group->getProteinMatchList().at(row)->isValid() == false) { -- GitLab