Commit e265ea84 authored by Renne Thomas's avatar Renne Thomas
Browse files

Add columns and export menu in ms id list

parent 63a0b97a
......@@ -72,16 +72,31 @@
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuCompare">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>&amp;Compare</string>
</property>
<addaction name="actionAlignement"/>
</widget>
<widget class="QMenu" name="menuExport">
<property name="title">
<string>e&amp;xport</string>
</property>
<addaction name="actionAs_ODS_file"/>
<addaction name="action_as_ODS_file"/>
</widget>
<addaction name="menuExport"/>
<addaction name="menuCompare"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionAs_ODS_file">
<action name="actionAlignement">
<property name="text">
<string>&amp;Alignement</string>
</property>
</action>
<action name="action_as_ODS_file">
<property name="text">
<string>&amp;as ODS file</string>
</property>
......@@ -90,7 +105,7 @@
<resources/>
<connections>
<connection>
<sender>actionAs_ODS_file</sender>
<sender>action_as_ODS_file</sender>
<signal>triggered()</signal>
<receiver>MsIdentificationView</receiver>
<slot>doExportAsOdsFile()</slot>
......
......@@ -30,46 +30,6 @@
#include <odsstream/odsdocwriter.h>
#include <odsstream/qtablewriter.h>
MsIdentificationListQactionColumn::MsIdentificationListQactionColumn(
MsIdentificationListWindow *parent, msIdentificationListColumn column)
: QAction(parent)
{
this->setText(MsIdentificationTableModel::getTitle(column));
// this->setCheckable(true);
m_column = column;
m_msid_list_window = parent;
#if QT_VERSION >= 0x050000
// Qt5 code
connect(this,
&MsIdentificationListQactionColumn::toggled,
this,
&MsIdentificationListQactionColumn::doToggled);
#else
// Qt4 code
connect(this, SIGNAL(toggled(bool)), this, SLOT(doToggled(bool)));
#endif
}
MsIdentificationListQactionColumn::~MsIdentificationListQactionColumn()
{
qDebug() << "MsIdentificationListQactionColumn::~"
"MsIdentificationListQactionColumn begin ";
}
void
MsIdentificationListQactionColumn::doToggled(bool toggled)
{
qDebug() << "MsIdentificationListQactionColumn::doToggled begin " << toggled;
setChecked(toggled);
m_msid_list_window->setMsIdentificationListColumnDisplay(m_column, toggled);
qDebug() << "MsIdentificationListQactionColumn::doToggled end";
}
MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
: QMainWindow(parent), ui(new Ui::MsIdentificationView)
{
......@@ -89,6 +49,8 @@ MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
ui->tableView->setSortingEnabled(true);
ui->tableView->setAlternatingRowColors(true);
m_proxy_model->resteItemDelegates();
connect(this,
&MsIdentificationListWindow::MsIdentificationDataChanged,
m_msid_table_model_p,
......@@ -97,6 +59,10 @@ MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
&MsIdentificationTableModel::layoutChanged,
this,
&MsIdentificationListWindow::updateStatusBar);
connect(ui->tableView,
&QTableView::clicked,
m_proxy_model,
&MsIdentificationTableProxyModel::onTableClicked);
}
void
......@@ -149,10 +115,32 @@ MsIdentificationListWindow::setIdentificationDataSourceSpList(
qDebug() << "MsIdentificationListWindow::setIdentificationGroup end";
}
void
MsIdentificationListWindow::setMsIdentificationListColumnDisplay(
msIdentificationListColumn column, bool toggled)
MsIdentificationListWindow::doExportAsOdsFile()
{
m_proxy_model->setMsIdentificationListColumnDisplay(column, toggled);
QSettings settings;
QString default_location = settings.value("path/export_ods", "").toString();
QString filename;
filename = QFileDialog::getSaveFileName(
this,
tr("Save ODS file"),
QString("%1/untitled.ods").arg(default_location),
tr("Open Document Spreadsheet (*.ods)"));
if(!filename.isEmpty())
{
CalcWriterInterface *p_writer = new OdsDocWriter(filename);
const QAbstractProxyModel *p_table_model = m_proxy_model;
QtableWriter table_writer(p_writer, p_table_model);
table_writer.setFormatPercentForColumn(m_msid_table_model_p->index(
0, (int)msIdentificationListColumn::percent_assign));
table_writer.writeSheet("Ms Identification list");
p_writer->close();
delete p_writer;
}
}
......@@ -39,23 +39,6 @@ namespace Ui
class MsIdentificationView;
}
class MsIdentificationListWindow;
class MsIdentificationListQactionColumn : public QAction
{
Q_OBJECT
public:
explicit MsIdentificationListQactionColumn(MsIdentificationListWindow *parent,
msIdentificationListColumn column);
~MsIdentificationListQactionColumn();
public slots:
void doToggled(bool toggled);
private:
MsIdentificationListWindow *m_msid_list_window;
msIdentificationListColumn m_column;
};
class MsIdentificationListWindow : public QMainWindow
{
friend class MsIdentificationTableModel;
......@@ -68,10 +51,12 @@ class MsIdentificationListWindow : public QMainWindow
~MsIdentificationListWindow();
void setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp> &identificationDataSourceSpList);
void setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
bool toggled);
void resizeColumnsToContents();
public slots:
void doExportAsOdsFile();
signals:
void MsIdentificationDataChanged();
......
......@@ -97,13 +97,30 @@ MsIdentificationTableModel::getTitle(std::int8_t column)
case(std::int8_t)msIdentificationListColumn::run_id:
return "Identification RunID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "Identification File";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "Peak-list file";
break;
case(std::int8_t)msIdentificationListColumn::engine_name:
return "Engine Name";
break;
case(std::int8_t)msIdentificationListColumn::nbr_spectrum:
return "Number of Spectrum";
break;
case(std::int8_t)msIdentificationListColumn::nbr_peptide:
return "Number of peptide";
break;
case(std::int8_t)msIdentificationListColumn::nbr_unique:
return "Number of unique";
break;
case(std::int8_t)msIdentificationListColumn::percent_assign:
return "% Assignation";
break;
case(std::int8_t)msIdentificationListColumn::id_msrun_id:
return "MsRunID";
break;
}
return "";
}
......@@ -119,13 +136,30 @@ MsIdentificationTableModel::getDescription(std::int8_t column)
case(std::int8_t)msIdentificationListColumn::run_id:
return "Identification of RunID";
break;
case(std::int8_t)msIdentificationListColumn::id_file:
return "Identification File pathway";
break;
case(std::int8_t)msIdentificationListColumn::mzML:
return "peak-list data file pathway";
break;
case(std::int8_t)msIdentificationListColumn::engine_name:
return "Engine Name";
break;
case(std::int8_t)msIdentificationListColumn::nbr_spectrum:
return "Number of Spectrum";
break;
case(std::int8_t)msIdentificationListColumn::nbr_peptide:
return "Number of peptide identified";
break;
case(std::int8_t)msIdentificationListColumn::nbr_unique:
return "Number of unique peptide";
break;
case(std::int8_t)msIdentificationListColumn::percent_assign:
return "Percentage of Assignation";
break;
case(std::int8_t)msIdentificationListColumn::id_msrun_id:
return "Identification of MsRunID";
break;
}
return "";
}
......@@ -158,20 +192,28 @@ MsIdentificationTableModel::headerData(int section,
int
MsIdentificationTableModel::getColumnWidth(int column)
{
qDebug() << "Test " << column;
switch(column)
{
case(int)msIdentificationListColumn::run_id:
return 200;
break;
case(int)msIdentificationListColumn::id_file:
return 500;
return 400;
break;
case(int)msIdentificationListColumn::mzML:
return 500;
return 400;
break;
case(int)msIdentificationListColumn::nbr_spectrum:
return 160;
break;
case(int)msIdentificationListColumn::nbr_peptide:
return 160;
break;
case(int)msIdentificationListColumn::nbr_unique:
return 160;
break;
}
return 300;
return 120;
}
msIdentificationListColumn
......@@ -200,6 +242,66 @@ MsIdentificationTableModel::data(const QModelIndex &index, int role) const
return QVariant(
m_identificationDataSourceSpList.at(row)->getXmlId());
}
if(col == (std::int8_t)msIdentificationListColumn::id_file)
{
QFileInfo fi(
m_identificationDataSourceSpList.at(row)->getResourceName());
return QVariant(fi.fileName());
}
if(col == (std::int8_t)msIdentificationListColumn::mzML)
{
QFileInfo fi(m_identificationDataSourceSpList.at(row)
->getMsRunSp()
.get()
->getFileName());
return QVariant(fi.fileName());
}
if(col == (std::int8_t)msIdentificationListColumn::engine_name)
{
return QVariant(m_identificationDataSourceSpList.at(row)
->getIdentificationEngineName());
}
if(col == (std::int8_t)msIdentificationListColumn::id_msrun_id)
{
return QVariant(m_identificationDataSourceSpList.at(row)
->getMsRunSp()
->getXmlId());
}
if(col == (std::int8_t)msIdentificationListColumn::nbr_peptide)
{
return QVariant(
m_identificationDataSourceSpList.at(row)
->getIdentificationEngineStatistics(
IdentificationEngineStatistics::total_spectra_assigned));
}
if(col == (std::int8_t)msIdentificationListColumn::nbr_unique)
{
return QVariant(
m_identificationDataSourceSpList.at(row)
->getIdentificationEngineStatistics(
IdentificationEngineStatistics::total_unique_assigned));
}
if(col == (std::int8_t)msIdentificationListColumn::nbr_spectrum)
{
return QVariant(
m_identificationDataSourceSpList.at(row)
->getIdentificationEngineStatistics(
IdentificationEngineStatistics::total_spectra_used));
}
if(col == (std::int8_t)msIdentificationListColumn::percent_assign)
{
return QVariant(
m_identificationDataSourceSpList.at(row)
->getIdentificationEngineStatistics(
IdentificationEngineStatistics::total_spectra_assigned)
.toDouble() /
m_identificationDataSourceSpList.at(row)
->getIdentificationEngineStatistics(
IdentificationEngineStatistics::total_spectra_used)
.toDouble());
}
case Qt::ToolTipRole:
if(col == (std::int8_t)msIdentificationListColumn::id_file)
{
return QVariant(
......
......@@ -35,10 +35,16 @@
enum class msIdentificationListColumn : std::int8_t
{
run_id = 0, ///< msRun ID
id_file = 1, ///< file ID
mzML = 2, ///< accession
last = 3, ///< get list size
run_id = 0, ///< msRun ID
id_file = 1, ///< file ID
mzML = 2, ///< accession
engine_name = 3, ///< engine name
nbr_spectrum = 4, ///< number of spectrum
nbr_peptide = 5, ///< number of peptide identified
nbr_unique = 6, ///< number of unique spectra
percent_assign = 7, ///< percent of assignation
id_msrun_id = 8, ///< identification of MsRunId
last = 9, ///< get list size
};
class MsIdentificationListWindow;
......
......@@ -184,18 +184,42 @@ MsIdentificationTableProxyModel::headerData(int section,
return sourceModel()->headerData(col, orientation, role);
}
void
MsIdentificationTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "MsIdentificationTableProxyModel::onTableClicked begin "
<< index.row();
qDebug() << "MsIdentificationTableProxyModel::onTableClicked begin "
<< this->mapToSource(index).row();
QModelIndex source_index(this->mapToSource(index));
int row = source_index.row();
msIdentificationListColumn col =
(msIdentificationListColumn)source_index.column();
if(col == msIdentificationListColumn::engine_name)
{
// m_msid_list_window->askProteinDetailView();
}
qDebug() << "MsIdentificationTableProxyModel::onTableClicked end "
<< index.row();
}
void
MsIdentificationTableProxyModel::setMsIdentificationListColumnDisplay(
msIdentificationListColumn column, bool toggled)
MsIdentificationTableProxyModel::resteItemDelegates() const
{
qDebug() << toggled;
beginResetModel();
QSettings settings;
settings.setValue(QString("protein_list_columns/%1")
.arg(m_msid_table_model_p->getTitle(column)),
toggled);
m_column_display[(std::int8_t)column] = toggled;
endResetModel();
for(int i = 0; i < columnCount(); ++i)
{
qDebug() << i;
qDebug() << (std::int8_t)msIdentificationListColumn::percent_assign;
qDebug() << mapToSource(index(0, i)).column();
// m_msid_list_window->ui->tableView->setItemDelegateForColumn(
// i, m_msid_list_window->ui->tableView->itemDelegate());
if(i == (std::int8_t)msIdentificationListColumn::percent_assign)
{
qDebug() << "AAAAAAAAAAAAAAAAAAAAA";
m_msid_list_window->ui->tableView->setItemDelegateForColumn(
i, m_percent_delegate);
}
}
}
......@@ -54,9 +54,11 @@ class MsIdentificationTableProxyModel : public QSortFilterProxyModel
const QModelIndex &right) const override;
void setSearchOn(QString search_on);
void setMsIdentificationSearchString(QString ms_id_search_string);
void setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
bool toggled);
void resteItemDelegates() const;
public slots:
void onTableClicked(const QModelIndex &index);
private:
std::vector<IdentificationDataSourceSp> m_identificationDataSourceSpList;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment