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

column resize in protein list

parent cbd840cd
No related branches found
Tags xtpcpp_0.2.31-2
No related merge requests found
......@@ -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();
}
......@@ -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();
......
......@@ -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();
}
......@@ -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);
......
......@@ -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)
{
......
......@@ -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
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