Newer
Older
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#include "proteinlistwindow.h"
#include "ui_protein_view.h"
ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
QMainWindow(parent),
ui(new Ui::ProteinView)
{
_protein_table_model_p = new ProteinTableModel(this);
_p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p);
_p_proxy_model->setSourceModel(_protein_table_model_p);
_p_proxy_model->setDynamicSortFilter(true);
QSettings settings;
bool hide = settings.value("proteinview/hidenotvalid", "true").toBool();
if (hide) {
ui->hideNotValidCheckBox->setCheckState(Qt::Checked);
}
_protein_table_model_p->hideNotValid(hide);
hide = settings.value("proteinview/hidenotchecked", "false").toBool();
if (hide) {
ui->hideNotCheckedCheckBox->setCheckState(Qt::Checked);
}
_protein_table_model_p->hideNotChecked(hide);
hide = settings.value("proteinview/hidenotgrouped", "false").toBool();
if (hide) {
ui->hideNotGroupedCheckBox->setCheckState(Qt::Checked);
}
_protein_table_model_p->hideNotGrouped(settings.value("proteinview/hidenotgrouped", "false").toBool());
#if QT_VERSION >= 0x050000
// Qt5 code
/*
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad);
connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile);
*/
#else
// Qt4 code
connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &)));
connect(ui->proteinSearchEdit, SIGNAL(textChanged(QString)), _protein_table_model_p, SLOT(onProteinSearchEdit(QString)));
connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) );
connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
//connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar()));
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::doubleclickOnproteinMatch(ProteinMatch * p_protein_match) {
void ProteinListWindow::doFocusReceived(bool has_focus) {
if (has_focus ) {
qDebug() << "ProteinListWindow::doFocusReceived begin";
_project_window->setDefaultProteinListWindow(this);
qDebug() << "ProteinListWindow::doFocusReceived end";
void ProteinListWindow::showContextMenu(const QPoint & pos) {
QMenu contextMenu(tr("Context menu"), this);
QAction accession_action("accession", this);
accession_action.setCheckable(true);
accession_action.setChecked(_display_evalue);
connect(&accession_action, SIGNAL(toggled(bool)), this, SLOT(showAccessionColumn(bool)));
contextMenu.addAction(&accession_action);
QAction evalue_action("Evalue", this);
evalue_action.setCheckable(true);
evalue_action.setChecked(_display_evalue);
connect(&evalue_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
contextMenu.addAction(&evalue_action);
contextMenu.exec(mapToGlobal(pos));
}
ProteinListWindow::~ProteinListWindow()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
delete ui;
void ProteinListWindow::edited() {
qDebug() << "ProteinListWindow::edited begin";
//emit dataChanged(index, index);
emit identificationGroupEdited(_p_identification_group);
updateStatusBar();
qDebug() << "ProteinListWindow::edited end";
}
void ProteinListWindow::doNotValidHide(bool hide) {
qDebug() << "ProteinListWindow::doNotValidHide begin";
_protein_table_model_p->hideNotValid(hide);
QSettings settings;
settings.setValue("proteinview/hidenotvalid", QString("%1").arg(hide));
qDebug() << "ProteinListWindow::doNotValidHide end";
}
void ProteinListWindow::doNotCheckedHide(bool hide) {
qDebug() << "ProteinListWindow::doNotCheckedHide begin";
_protein_table_model_p->hideNotChecked(hide);
QSettings settings;
settings.setValue("proteinview/hidenotchecked", QString("%1").arg(hide));
qDebug() << "ProteinListWindow::doNotCheckedHide end";
}
void ProteinListWindow::doNotGroupedHide(bool hide) {
qDebug() << "ProteinListWindow::doNotGroupedHide begin";
_protein_table_model_p->hideNotGrouped(hide);
QSettings settings;
settings.setValue("proteinview/hidenotgrouped", QString("%1").arg(hide));
qDebug() << "ProteinListWindow::doNotGroupedHide end";
}
void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) {
qDebug() << "ProteinListWindow::doIdentificationGroupGrouped begin";
if (_p_identification_group == p_identification_group) {
_p_proxy_model->setSourceModel(_protein_table_model_p);
updateStatusBar();
}
qDebug() << "ProteinListWindow::doIdentificationGroupGrouped end";
}
void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) {
if (_p_identification_group != p_identification_group) {
_p_identification_group = p_identification_group;
_protein_table_model_p->setIdentificationGroup(p_identification_group);
_p_proxy_model->setSourceModel(_protein_table_model_p);
updateStatusBar();
}
}
void ProteinListWindow::updateStatusBar() {
ui->statusbar->showMessage(tr("proteins %1 valid, %2 checked, %3 displayed").arg(_p_identification_group->countValid()).arg(_p_identification_group->countValidAndChecked()).arg(_p_proxy_model->rowCount()));