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

peptide list window added

parent db21c6ef
No related branches found
No related tags found
No related merge requests found
Showing
with 551 additions and 38 deletions
......@@ -74,18 +74,23 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} )
SET(XTPCPP_SRCS
./gui/mainwindow.cpp
./gui/peptide_list_view/peptidelistwindow.cpp
./gui/peptide_list_view/peptidetablemodel.cpp
./gui/protein_list_view/proteinlistwindow.cpp
./gui/protein_list_view/proteintablemodel.cpp
)
SET (GUI_UIS
./gui/main.ui
./gui/peptide_list_view/peptide_view.ui
./gui/protein_list_view/protein_view.ui
)
SET(XTPCPP_MOC_HDRS
./gui/mainwindow.h
./gui/peptide_list_view/peptidelistwindow.h
./gui/peptide_list_view/peptidetablemodel.h
./gui/protein_list_view/proteinlistwindow.h
./gui/protein_list_view/proteintablemodel.h
)
......
......@@ -52,6 +52,27 @@ void PeptideMatch::setPeptideSp (pappso::PeptideSp peptide) {
void PeptideMatch::setChecked(bool arg1) {
_checked = arg1;
}
bool PeptideMatch::isChecked() const {
return _checked;
}
void PeptideMatch::setIdentificationDataSource(IdentificationDataSource* identification_source) {
_p_identification_source = identification_source;
}
IdentificationDataSource* PeptideMatch::getIdentificationDataSource () const {
return _p_identification_source;
}
unsigned int PeptideMatch::getScan() const {
return _scan;
}
pappso::pappso_double PeptideMatch::getRetentionTime() const {
return _rt;
}
unsigned int PeptideMatch::getCharge() const {
return _charge;
}
pappso::PeptideSp PeptideMatch::getPeptideSp() const {
return _peptide_sp;
}
......@@ -41,7 +41,13 @@ public :
void setPeptideSp (pappso::PeptideSp peptide);
void setIdentificationDataSource(IdentificationDataSource* identification_source);
void setChecked(bool arg1);
bool isChecked() const;
IdentificationDataSource* getIdentificationDataSource () const;
unsigned int getScan() const;
pappso::pappso_double getRetentionTime() const;
unsigned int getCharge() const;
pappso::PeptideSp getPeptideSp() const;
private :
pappso::MsRunIdSp _msrunid_sp;
......@@ -53,11 +59,11 @@ private :
unsigned int _start;
unsigned int _charge;
IdentificationDataSource* _p_identification_source = nullptr;
/** @brief manually checked by user (true by default)
*/
bool _checked = true;
/** @brief automatic filter result (false by default)
*/
bool _proxy_valid = false;
......
......@@ -22,6 +22,7 @@
******************************************************************************/
#include "project.h"
#include "../input/xpipsaxhandler.h"
#include "peptidematch.h"
Project::Project()
{
......@@ -80,3 +81,7 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) {
IdentificationGroup* Project::getCurrentIdentificationGroupP() const {
return _p_current_identification_group;
}
bool Project::isValid(PeptideMatch* p_peptide_match) const {
return true;
}
......@@ -29,6 +29,8 @@
class Project;
typedef std::shared_ptr<Project> ProjectSp;
class PeptideMatch;
class Project
{
public:
......@@ -39,6 +41,10 @@ public:
void readXpipFile(QFileInfo xpip_source);
IdentificationGroup* newIdentificationGroup();
IdentificationGroup* getCurrentIdentificationGroupP() const;
/** @brief is it valid regarding threshold and project rules
*/
bool isValid(PeptideMatch* p_peptide_match) const;
private :
std::vector<IdentificationGroup *> _identification_goup_list;
IdentificationGroup* _p_current_identification_group = nullptr;
......
......@@ -28,8 +28,14 @@
#include "ui_main.h"
#include "files/xpipfile.h"
#include "gui/peptide_list_view/peptidelistwindow.h"
void PwizLoaderThread::doMsDataFileLoad(const QString & parameter) {
pwiz::msdata::MSDataFile* p_ms_data_file = getPwizMSDataFile(parameter);
/* ... here is the expensive or blocking operation ... */
emit msDataReady(p_ms_data_file);
}
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent),
ui(new Ui::Main)
......@@ -38,6 +44,17 @@ MainWindow::MainWindow(QWidget *parent):
PwizLoaderThread *worker = new PwizLoaderThread;
worker->moveToThread(&workerThread);
/*
*/
workerThread.start();
QDockWidget *dock = new QDockWidget(tr("Protein List"), this);
_protein_list_window = new ProteinListWindow(this);
//_protein_list_window->show();
dock->setWidget(_protein_list_window);
addDockWidget(Qt::RightDockWidgetArea, dock);
#if QT_VERSION >= 0x050000
// Qt5 code
/*
......@@ -47,21 +64,13 @@ MainWindow::MainWindow(QWidget *parent):
*/
#else
// Qt4 code
connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this ,SLOT(doProteinMatchClicked(ProteinMatch *)));
/*
connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString)));
connect(worker, SIGNAL(msDataReady(pwiz::msdata::MSDataFile *)), this, SLOT(handleMsDataFile(pwiz::msdata::MSDataFile *)));
*/
#endif
/*
*/
workerThread.start();
QDockWidget *dock = new QDockWidget(tr("Protein List"), this);
_protein_list_window = new ProteinListWindow(this);
//_protein_list_window->show();
dock->setWidget(_protein_list_window);
addDockWidget(Qt::RightDockWidgetArea, dock);
}
MainWindow::~MainWindow()
......@@ -74,6 +83,12 @@ MainWindow::~MainWindow()
}
void MainWindow::doProteinMatchClicked(ProteinMatch * protein_match) {
PeptideListWindow * peptide_window = new PeptideListWindow(this);
peptide_window->setProteinMatch(_project_sp.get(), protein_match);
peptide_window->show();
}
void MainWindow::selectXpipFile() {
QSettings settings;
......@@ -88,10 +103,10 @@ void MainWindow::selectXpipFile() {
}
QFileInfo new_xpip_file;
new_xpip_file.setFile(filename);
XpipFile xpip_file(new_xpip_file);
_project_sp = xpip_file.getProjectSp();
_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
}
......@@ -49,11 +49,7 @@ class PwizLoaderThread : public QObject
public:
public slots:
void doMsDataFileLoad(const QString & parameter) {
pwiz::msdata::MSDataFile* p_ms_data_file = getPwizMSDataFile(parameter);
/* ... here is the expensive or blocking operation ... */
emit msDataReady(p_ms_data_file);
}
void doMsDataFileLoad(const QString & parameter);
signals:
void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file);
......@@ -70,6 +66,7 @@ public:
public slots:
void selectXpipFile();
void doProteinMatchClicked(ProteinMatch * protein_match);
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PeptideView</class>
<widget class="QMainWindow" name="PeptideView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<height>404</height>
</rect>
</property>
<property name="windowTitle">
<string>Protein list</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="tableView"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>826</width>
<height>19</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
/*******************************************************************************
* 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 "peptidelistwindow.h"
#include "ui_peptide_view.h"
PeptideListWindow::PeptideListWindow(QWidget *parent):
QMainWindow(parent),
ui(new Ui::PeptideView)
{
ui->setupUi(this);
#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(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString)));
connect(worker, SIGNAL(msDataReady(pwiz::msdata::MSDataFile *)), this, SLOT(handleMsDataFile(pwiz::msdata::MSDataFile *)));
*/
#endif
/*
*/
_peptide_table_model_p = new PeptideTableModel(0);
_p_proxy_model = new PeptideTableProxyModel(this, _peptide_table_model_p);
_p_proxy_model->setSourceModel(_peptide_table_model_p);
_p_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel( _p_proxy_model );
ui->tableView->setSortingEnabled(true);
connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
}
PeptideListWindow::~PeptideListWindow()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
delete ui;
}
void PeptideListWindow::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) {
_peptide_table_model_p->setProteinMatch(p_project, p_protein_match);
_p_proxy_model->setSourceModel(_peptide_table_model_p);
}
/*******************************************************************************
* 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 PEPTIDELISTWINDOW_H
#define PEPTIDELISTWINDOW_H
#include <QMainWindow>
#include "peptidetablemodel.h"
#include "../../core/proteinmatch.h"
#include "../../core/project.h"
//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html
namespace Ui {
class PeptideView;
}
class PeptideListWindow: public QMainWindow {
Q_OBJECT
public:
explicit PeptideListWindow(QWidget * parent = 0);
~PeptideListWindow();
void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match);
public slots:
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
signals:
//void peptideChanged(pappso::PeptideSp peptide);
private:
Ui::PeptideView *ui;
PeptideTableModel * _peptide_table_model_p = nullptr;
PeptideTableProxyModel * _p_proxy_model = nullptr;
};
#endif // PEPTIDELISTWINDOW_H
/*******************************************************************************
* 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 "peptidetablemodel.h"
#include <QDebug>
PeptideTableProxyModel::PeptideTableProxyModel(QObject *parent,PeptideTableModel* peptide_table_model_p): QSortFilterProxyModel(parent)
{
_peptide_table_model_p = peptide_table_model_p;
}
bool PeptideTableProxyModel::filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const {
return _peptide_table_model_p->acceptRow(source_row);
//return true;
}
void PeptideTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row();
qDebug() << "PeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row();
_peptide_table_model_p->onTableClicked(this->mapToSource(index));
}
bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const {
QVariant leftData = sourceModel()->data(left);
QVariant rightData = sourceModel()->data(right);
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::UInt) {
return leftData.toUInt() < rightData.toUInt();
}
if (leftData.type() == QVariant::Double) {
return leftData.toDouble() < rightData.toDouble();
}
return leftData.toString() < rightData.toString();
}
QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation,
int role) const {
return sourceModel()->headerData(section, orientation,
role);
}
PeptideTableModel::PeptideTableModel(QObject *parent)
:QAbstractTableModel(parent)
{
//ui->tableView->show();
// QModelIndex topLeft = createIndex(0,0);
//emit a signal to make the view reread identified data
//emit dataChanged(topLeft, topLeft);
}
void PeptideTableModel::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) {
qDebug() << "PeptideTableModel::setProteinMatch begin " ;
_p_project = p_project;
_p_protein_match = p_protein_match;
QModelIndex topLeft = createIndex(0,0);
QModelIndex bottomRight = createIndex(rowCount(),columnCount());
emit dataChanged(topLeft, bottomRight);
emit headerDataChanged(Qt::Horizontal, 0,3);
}
int PeptideTableModel::rowCount(const QModelIndex &parent ) const {
if (_p_protein_match != nullptr) {
qDebug() << "PeptideTableModel::rowCount(const QModelIndex &parent ) " << _p_protein_match->getPeptideMatchList().size();
return _p_protein_match->getPeptideMatchList().size();
}
return 0;
}
int PeptideTableModel::columnCount(const QModelIndex &parent ) const {
return 6;
}
QVariant PeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole)
{
if (orientation == Qt::Horizontal) {
switch (section)
{
case 0:
return QString("checked");
case 1:
return QString("sample");
case 2:
return QString("scan");
case 3:
return QString("RT");
case 4:
return QString("charge");
case 5:
return QString("sequence");
}
}
}
return QVariant();
}
QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
// generate a log message when this method gets called
int row = index.row();
int col = index.column();
qDebug() << QString("row %1, col%2, role %3")
.arg(row).arg(col).arg(role);
switch(role) {
case Qt::CheckStateRole:
if (col == 0) //add a checkbox to cell(1,0)
{
if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) {
return Qt::Checked;
}
else {
return Qt::Unchecked;
}
}
break;
case Qt::DisplayRole:
if (_p_protein_match == nullptr) {
}
else {
if (col == 0) {
return QVariant();
}
if (col == 1) {
return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getResourceName();
}
if (col == 2) {
return QVariant ((quint16) _p_protein_match->getPeptideMatchList().at(row)->getScan());
}
if (col == 3) {
return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getRetentionTime());
}
if (col == 4) {
return QVariant ((quint8) _p_protein_match->getPeptideMatchList().at(row)->getCharge());
}
if (col == 5) {
return _p_protein_match->getPeptideMatchList().at(row)->getPeptideSp().get()->getSequence();
}
}
return QString("Row%1, Column%2")
.arg(index.row() + 1)
.arg(index.column() +1);
}
return QVariant();
}
void PeptideTableModel::onTableClicked(const QModelIndex &index)
{
int row = index.row();
int col = index.column();
if (col == 0) //add a checkbox to cell(1,0)
{
if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) {
_p_protein_match->getPeptideMatchList().at(row)->setChecked(false);
}
else {
_p_protein_match->getPeptideMatchList().at(row)->setChecked(true);
}
//emit dataChanged(index, index);
}
else {
emit peptideMatchClicked(_p_protein_match->getPeptideMatchList().at(row));
}
}
bool PeptideTableModel::acceptRow(int source_row) {
if (_p_project->isValid(_p_protein_match->getPeptideMatchList().at(source_row))) {
return true;
}
return false;
}
/*******************************************************************************
* 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 PEPTIDETABLEMODEL_H
#define PEPTIDETABLEMODEL_H
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "../../core/project.h"
class PeptideTableModel;
class PeptideTableProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
PeptideTableProxyModel(QObject* parent,PeptideTableModel* peptide_table_model_p);
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role) const override;
bool lessThan(const QModelIndex & left, const QModelIndex & right) const override;
public slots:
void onTableClicked(const QModelIndex &index);
private:
PeptideTableModel* _peptide_table_model_p;
};
class PeptideTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
PeptideTableModel(QObject *parent=0);
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;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match);
bool acceptRow(int source_row);
signals:
void peptideMatchClicked(PeptideMatch * p_peptide_match);
public slots:
void onTableClicked(const QModelIndex &index);
private :
Project * _p_project;
ProteinMatch * _p_protein_match= nullptr;
};
#endif // PEPTIDETABLEMODEL_H
......@@ -50,7 +50,7 @@ ProteinListWindow::ProteinListWindow(QWidget *parent):
/*
*/
_protein_table_model_p = new ProteinTableModel(0);
_protein_table_model_p = new ProteinTableModel(this, this);
_p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p);
......@@ -58,10 +58,14 @@ ProteinListWindow::ProteinListWindow(QWidget *parent):
_p_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel( _p_proxy_model );
ui->tableView->setSortingEnabled(true);
connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
}
void ProteinListWindow::clickOnproteinMatch(ProteinMatch * p_protein_match) {
emit proteinMatchClicked(p_protein_match);
}
ProteinListWindow::~ProteinListWindow()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
......
......@@ -41,14 +41,14 @@ public:
explicit ProteinListWindow(QWidget * parent = 0);
~ProteinListWindow();
void setIdentificationGroup(IdentificationGroup * p_identification_group);
void clickOnproteinMatch(ProteinMatch * p_protein_match);
public slots:
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
signals:
//void peptideChanged(pappso::PeptideSp peptide);
void proteinMatchClicked(ProteinMatch * p_protein_match);
private:
Ui::ProteinView *ui;
ProteinTableModel * _protein_table_model_p = nullptr;
......
......@@ -22,6 +22,7 @@
******************************************************************************/
#include "proteintablemodel.h"
#include "proteinlistwindow.h"
#include <QDebug>
......@@ -40,8 +41,8 @@ bool ProteinTableProxyModel::filterAcceptsRow(int source_row,
void ProteinTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row();
qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row();
qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row();
qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row();
_protein_table_model_p->onTableClicked(this->mapToSource(index));
}
......@@ -82,10 +83,10 @@ QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orienta
role);
}
ProteinTableModel::ProteinTableModel(QObject *parent)
ProteinTableModel::ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window)
:QAbstractTableModel(parent)
{
_p_protein_list_window = p_protein_list_window;
//ui->tableView->show();
// QModelIndex topLeft = createIndex(0,0);
//emit a signal to make the view reread identified data
......@@ -170,7 +171,7 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const {
if (col == 3) {
if (_p_identification_group != nullptr) {
return _p_identification_group->getProteinMatchList().at(row)->getEvalue();
return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getEvalue());
}
}
......@@ -190,18 +191,22 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const {
void ProteinTableModel::onTableClicked(const QModelIndex &index)
{
int row = index.row();
int row = index.row();
int col = index.column();
if (col == 0) //add a checkbox to cell(1,0)
{
if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) {
_p_identification_group->getProteinMatchList().at(row)->setChecked(false);
}
else {
_p_identification_group->getProteinMatchList().at(row)->setChecked(true);
}
//emit dataChanged(index, index);
{
if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) {
_p_identification_group->getProteinMatchList().at(row)->setChecked(false);
}
else {
_p_identification_group->getProteinMatchList().at(row)->setChecked(true);
}
//emit dataChanged(index, index);
}
else {
_p_protein_list_window->clickOnproteinMatch(_p_identification_group->getProteinMatchList().at(row));
}
}
bool ProteinTableModel::acceptRow(int source_row) {
......
......@@ -28,6 +28,8 @@
#include <QSortFilterProxyModel>
#include "../../core/project.h"
class ProteinListWindow;
class ProteinTableModel;
class ProteinTableProxyModel : public QSortFilterProxyModel
{
......@@ -52,7 +54,7 @@ class ProteinTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
ProteinTableModel(QObject *parent=0);
ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window);
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;
......@@ -61,10 +63,12 @@ public:
void setIdentificationGroup(IdentificationGroup * p_identification_group);
bool acceptRow(int source_row);
public slots:
void onTableClicked(const QModelIndex &index);
private :
IdentificationGroup * _p_identification_group = nullptr;
ProteinListWindow * _p_protein_list_window;
};
#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