diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp index a47a4bbe7df719b760c85c54a5d97007190bd2fb..3834b0d41fa9d1dd694868003a31c5dd16d697b9 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.cpp +++ b/src/gui/peptide_list_view/peptidelistwindow.cpp @@ -184,3 +184,7 @@ void PeptideListWindow::updateStatusBar() { ui->statusbar->showMessage(tr("peptides all:%1 valid:%2 valid&checked:%3 displayed:%4").arg(_p_protein_match->countPeptideMatch(ValidationState::notValid)).arg(_p_protein_match->countPeptideMatch(ValidationState::valid)).arg(_p_protein_match->countPeptideMatch(ValidationState::validAndChecked)).arg(_p_proxy_model->rowCount())); } } + +void PeptideListWindow::resizeColumnsToContents() { + ui->tableView->resizeColumnsToContents(); +} diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h index fd3ce5b94c6431a7d600befd35bf6ff9d145a2a7..d6d291e8be7b5eeebb5ff4a7c30f073d84ef9365 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.h +++ b/src/gui/peptide_list_view/peptidelistwindow.h @@ -47,6 +47,7 @@ public: explicit PeptideListWindow(ProjectWindow * parent = 0); ~PeptideListWindow(); void setProteinMatch(IdentificationGroup * p_identification_group, ProteinMatch * p_protein_match); + void resizeColumnsToContents(); void edited(); ProjectWindow * getProjectWindow(); diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 263dc250dacd069a5fc2212ee88a39a18b90fb9e..7471e5eca96ea78db1a439c406d9eacdc11c76ac 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -61,7 +61,7 @@ void ProteinListQactionColumn::doToggled(bool toggled) { qDebug() << "ProteinListQactionColumn::doToggled begin " << toggled; setChecked(toggled); _p_protein_list_window->setProteinListColumnDisplay(_column, toggled); - + qDebug() << "ProteinListQactionColumn::doToggled end"; } @@ -132,17 +132,6 @@ void ProteinListWindow::doProxyLayoutChanged() { //updateStatusBar(); qDebug() << "ProteinListWindow::doProxyLayoutChanged end"; } -void ProteinListWindow::showEvalueColumn(bool show) { - _display_evalue = show; - - ui->tableView->setColumnHidden(4,!show); -} - -void ProteinListWindow::showAccessionColumn(bool show) { - _display_accession = show; - - ui->tableView->setColumnHidden(2,!show); -} void ProteinListWindow::askPeptideListView(ProteinMatch * p_protein_match) { qDebug() << "ProteinListWindow::askPeptideListView begin"; @@ -167,16 +156,16 @@ void ProteinListWindow::doFocusReceived(bool has_focus) { void ProteinListWindow::showContextMenu(const QPoint & pos) { if (_p_context_menu == nullptr) { - _p_context_menu = new QMenu(tr("Context menu"), this); + _p_context_menu = new QMenu(tr("Context menu"), this); - ProteinListQactionColumn * p_action; - for (unsigned int i=0; i < _protein_table_model_p->columnCount(); i++) { - p_action = new ProteinListQactionColumn(this,ProteinTableModel::getProteinListColumn(i)); - _p_context_menu->addAction(p_action); - } + ProteinListQactionColumn * p_action; + for (unsigned int i=0; i < _protein_table_model_p->columnCount(); i++) { + p_action = new ProteinListQactionColumn(this,ProteinTableModel::getProteinListColumn(i)); + _p_context_menu->addAction(p_action); + } - _p_context_menu->exec(mapToGlobal(pos)); + _p_context_menu->exec(mapToGlobal(pos)); } _p_context_menu->show(); } @@ -276,10 +265,12 @@ void ProteinListWindow::updateStatusBar() { } } - void ProteinListWindow::setProteinListColumnDisplay(ProteinListColumn column, bool toggled) { _p_proxy_model->setProteinListColumnDisplay(column, toggled); } bool ProteinListWindow::getProteinListColumnDisplay(ProteinListColumn column) const { return _p_proxy_model->getProteinListColumnDisplay(column); } +void ProteinListWindow::resizeColumnsToContents() { + ui->tableView->resizeColumnsToContents(); +} diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 79dee349c83129aa1445d502de13f20f394cec12..0b30860fc980f2542a5ed29186f514217f8b69c7 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -66,6 +66,7 @@ public: void setIdentificationGroup(IdentificationGroup * p_identification_group); void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); bool getProteinListColumnDisplay(ProteinListColumn column) const; + void resizeColumnsToContents(); void edited(); @@ -86,8 +87,6 @@ protected slots: void doNotGroupedHide(bool hide); void doProxyLayoutChanged(); void showContextMenu(const QPoint &); - void showEvalueColumn(bool show); - void showAccessionColumn(bool show); void updateStatusBar(); void onProteinSearchEdit(QString protein_search_string); void doSearchOn(QString search_on); diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index 8d7eb2fc2cf8b4aba22d63d31d52ac15fc06291b..b495df5f82a0952cdbfcaef956548fae6617c6bf 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -49,6 +49,8 @@ void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identific //refresh(); qDebug() << "ProteinTableModel::setIdentificationGroup end "; endResetModel(); + + _p_protein_list_window->resizeColumnsToContents(); } @@ -79,7 +81,7 @@ const QString ProteinTableModel::getDescription(ProteinListColumn column) { } const QString ProteinTableModel::getTitle(std::int8_t column) { - + qDebug() << "ProteinTableModel::getTitle begin " << column; switch (column) { @@ -128,7 +130,7 @@ const QString ProteinTableModel::getTitle(std::int8_t column) { } const QString ProteinTableModel::getDescription(std::int8_t column) { - + qDebug() << "ProteinTableModel::getDescription begin " << column; switch (column) { @@ -187,13 +189,37 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, case Qt::ToolTipRole : return QVariant(getDescription(section)); break; - + case Qt::SizeHintRole : + //qDebug() << "ProteinTableModel::headerData " << ProteinTableModel::getColumnWidth(section); + return QSize( ProteinTableModel::getColumnWidth(section), 40 ); + break; } } return QVariant(); } -ProteinListColumn ProteinTableModel::getProteinListColumn(std::int8_t column){ +int ProteinTableModel::getColumnWidth(int column) { + qDebug() << "ProteinTableModel::getColumnWidth " << column; + switch (column) { + + case (int) ProteinListColumn::checked: + break; + + case (int) ProteinListColumn::protein_grouping_id: + return 120; + break; + case (int) ProteinListColumn::accession: + qDebug() << "ProteinTableModel::getColumnWidth accession " << column; + return 250; + break; + case (int) ProteinListColumn::description: + return 400; + break; + } + return 100; +} + +ProteinListColumn ProteinTableModel::getProteinListColumn(std::int8_t column) { return static_cast<ProteinListColumn>(column); } @@ -218,6 +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::BackgroundRole: if (_p_identification_group->getProteinMatchList().at(row)->isValid() == false) { diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 2c0924d42362f342b1b3f713e1b47ef2deab656f..99642418d02605811ab0d39b97683cb0af27bb1c 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -73,11 +73,11 @@ public slots: void onProteinDataChanged(); private : + static int getColumnWidth(int column); void refresh(); private : IdentificationGroup * _p_identification_group = nullptr; ProteinListWindow * _p_protein_list_window; - QStringList _columns; }; #endif // PROTEINTABLEMODEL_H