diff --git a/src/gui/peptide_list_view/peptide_view.ui b/src/gui/peptide_list_view/peptide_view.ui index dc6ee5687e517e4f85d5534853cae34bd8413ae1..1f9453a3bb2e892e5ca3c6f10e26781436cb8a0b 100644 --- a/src/gui/peptide_list_view/peptide_view.ui +++ b/src/gui/peptide_list_view/peptide_view.ui @@ -35,31 +35,6 @@ </property> </widget> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayoutcb"> - <item> - <widget class="QCheckBox" name="hideNotValidCheckBox"> - <property name="text"> - <string>show only valid peptides</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="hideNotCheckedCheckBox"> - <property name="text"> - <string>show only checked peptides</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="hideNotGroupedCheckBox"> - <property name="text"> - <string>show only grouped peptides</string> - </property> - </widget> - </item> - </layout> - </item> <item> <widget class="QTableView" name="tableView"/> </item> @@ -125,8 +100,53 @@ <height>25</height> </rect> </property> + <widget class="QMenu" name="menuExport"> + <property name="title"> + <string>e&xport</string> + </property> + <addaction name="actionAs_ODS_file"/> + </widget> + <widget class="QMenu" name="menuShow_only"> + <property name="title"> + <string>s&how only</string> + </property> + <addaction name="actionValid_peptides"/> + <addaction name="actionChecked_peptides"/> + <addaction name="actionGrouped_peptides"/> + </widget> + <addaction name="menuExport"/> + <addaction name="menuShow_only"/> </widget> <widget class="QStatusBar" name="statusbar"/> + <action name="actionAs_ODS_file"> + <property name="text"> + <string>&as ODS file</string> + </property> + </action> + <action name="actionValid_peptides"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>&valid peptides</string> + </property> + </action> + <action name="actionChecked_peptides"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>&checked peptides</string> + </property> + </action> + <action name="actionGrouped_peptides"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>&grouped peptides</string> + </property> + </action> </widget> <resources/> <connections> @@ -211,50 +231,66 @@ </hints> </connection> <connection> - <sender>hideNotGroupedCheckBox</sender> + <sender>actionAs_ODS_file</sender> + <signal>triggered()</signal> + <receiver>PeptideView</receiver> + <slot>doExportAsOdsFile()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>412</x> + <y>201</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionValid_peptides</sender> <signal>toggled(bool)</signal> <receiver>PeptideView</receiver> - <slot>doNotGroupedHide(bool)</slot> + <slot>doNotValidHide(bool)</slot> <hints> <hint type="sourcelabel"> - <x>815</x> - <y>112</y> + <x>-1</x> + <y>-1</y> </hint> <hint type="destinationlabel"> - <x>1079</x> - <y>360</y> + <x>412</x> + <y>201</y> </hint> </hints> </connection> <connection> - <sender>hideNotCheckedCheckBox</sender> + <sender>actionChecked_peptides</sender> <signal>toggled(bool)</signal> <receiver>PeptideView</receiver> <slot>doNotCheckedHide(bool)</slot> <hints> <hint type="sourcelabel"> - <x>612</x> - <y>112</y> + <x>-1</x> + <y>-1</y> </hint> <hint type="destinationlabel"> - <x>920</x> - <y>269</y> + <x>412</x> + <y>201</y> </hint> </hints> </connection> <connection> - <sender>hideNotValidCheckBox</sender> + <sender>actionGrouped_peptides</sender> <signal>toggled(bool)</signal> <receiver>PeptideView</receiver> - <slot>doNotValidHide(bool)</slot> + <slot>doNotGroupedHide(bool)</slot> <hints> <hint type="sourcelabel"> - <x>409</x> - <y>112</y> + <x>-1</x> + <y>-1</y> </hint> <hint type="destinationlabel"> - <x>839</x> - <y>171</y> + <x>412</x> + <y>201</y> </hint> </hints> </connection> @@ -268,5 +304,6 @@ <slot>doMsrunFileSearch(QString)</slot> <slot>doScanNumberSearch(int)</slot> <slot>doModificationSearch(QString)</slot> + <slot>doExportAsOdsFile()</slot> </slots> </ui> diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp index 533afa4a0925949a48bb0450421cf06ef6c31a62..ab5fbd27ec9a801f29ce156e1e8bfb386d0d4118 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.cpp +++ b/src/gui/peptide_list_view/peptidelistwindow.cpp @@ -23,6 +23,8 @@ ******************************************************************************/ #include <QSettings> +#include <odsstream/odsdocwriter.h> +#include <odsstream/qtablewriter.h> #include "peptidelistwindow.h" #include "../project_view/projectwindow.h" @@ -47,7 +49,9 @@ PeptideListQactionColumn::PeptideListQactionColumn(PeptideListWindow *parent, #if QT_VERSION >= 0x050000 // Qt5 code - connect(this, &PeptideListQactionColumn::toggled, this, + connect(this, + &PeptideListQactionColumn::toggled, + this, &PeptideListQactionColumn::doToggled); #else // Qt4 code @@ -96,19 +100,19 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent) bool hide = settings.value("peptideview/hidenotvalid", "true").toBool(); if(hide) { - ui->hideNotValidCheckBox->setCheckState(Qt::Checked); + ui->actionValid_peptides->setChecked(Qt::Checked); } _p_proxy_model->hideNotValid(hide); hide = settings.value("peptideview/hidenotchecked", "false").toBool(); if(hide) { - ui->hideNotCheckedCheckBox->setCheckState(Qt::Checked); + ui->actionChecked_peptides->setChecked(Qt::Checked); } _p_proxy_model->hideNotChecked(hide); hide = settings.value("peptideview/hidenotgrouped", "false").toBool(); if(hide) { - ui->hideNotGroupedCheckBox->setCheckState(Qt::Checked); + ui->actionGrouped_peptides->setChecked(Qt::Checked); } _p_proxy_model->hideNotGrouped(hide); @@ -119,30 +123,47 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent) #if QT_VERSION >= 0x050000 // Qt5 code - connect(_project_window, &ProjectWindow::identificationGroupGrouped, this, + connect(_project_window, + &ProjectWindow::identificationGroupGrouped, + this, &PeptideListWindow::doIdentificationGroupGrouped); - connect(this, &PeptideListWindow::peptideDataChanged, _peptide_table_model_p, + connect(this, + &PeptideListWindow::peptideDataChanged, + _peptide_table_model_p, &PeptideTableModel::onPeptideDataChanged); - connect(ui->tableView, &QTableView::clicked, _p_proxy_model, + connect(ui->tableView, + &QTableView::clicked, + _p_proxy_model, &PeptideTableProxyModel::onTableClicked); - connect(_peptide_table_model_p, &PeptideTableModel::layoutChanged, this, + connect(_peptide_table_model_p, + &PeptideTableModel::layoutChanged, + this, &PeptideListWindow::updateStatusBar); - connect(ui->centralwidget, &QWidget::customContextMenuRequested, this, + connect(ui->centralwidget, + &QWidget::customContextMenuRequested, + this, &PeptideListWindow::showContextMenu); #else // Qt4 code connect(_project_window, - SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this, + SIGNAL(identificationGroupGrouped(IdentificationGroup *)), + this, SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect(this, SIGNAL(peptideDataChanged()), _peptide_table_model_p, + connect(this, + SIGNAL(peptideDataChanged()), + _peptide_table_model_p, SLOT(onPeptideDataChanged())); - connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, + connect(ui->tableView, + SIGNAL(clicked(const QModelIndex &)), + _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); - connect(_peptide_table_model_p, SIGNAL(layoutChanged()), this, + connect(_peptide_table_model_p, + SIGNAL(layoutChanged()), + this, SLOT(updateStatusBar())); /* @@ -417,3 +438,32 @@ PeptideListWindow::getPeptideListColumnDisplay(PeptideListColumn column) const { return _p_proxy_model->getPeptideListColumnDisplay(column); } + +void +PeptideListWindow::doExportAsOdsFile() +{ + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + 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)")); + + + CalcWriterInterface *p_writer = new OdsDocWriter(filename); + const QAbstractProxyModel *p_table_model = _p_proxy_model; + + QtableWriter table_writer(p_writer, p_table_model); + + // table_writer.setFormatPercentForColumn( + // _peptide_table_model_p->index(0, (int)ProteinListColumn::coverage)); + + table_writer.writeSheet("protein list"); + + p_writer->close(); + delete p_writer; +} diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h index 3aecc924345bfec4835131df1c3699bc8b8041c7..a0ce122fb48f7ab3d58b8e3e35a3ae571305dd22 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.h +++ b/src/gui/peptide_list_view/peptidelistwindow.h @@ -84,6 +84,7 @@ class PeptideListWindow : public QMainWindow protected slots: void showContextMenu(const QPoint &pos); + void doExportAsOdsFile(); signals: void identificationGroupEdited(IdentificationGroup *p_identification_group);