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

Select column showed MsIdentification List

parent 9e56b195
......@@ -30,6 +30,52 @@
#include <odsstream/odsdocwriter.h>
#include <odsstream/qtablewriter.h>
MsIdentificationListQActionColumn::MsIdentificationListQActionColumn(
MsIdentificationListWindow *parent, msIdentificationListColumn column)
: QAction(parent)
{
this->setText(MsIdentificationTableModel::getTitle(column));
this->setCheckable(true);
this->setChecked(parent->getMsIdentificationListColumnDisplay(column));
// evalue_action.setChecked(_display_evalue);
// connect(p_action, SIGNAL(toggled(bool)), this,
// SLOT(showEvalueColumn(bool)));
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()
{
// if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
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)
{
......@@ -59,6 +105,10 @@ MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
&MsIdentificationTableModel::layoutChanged,
this,
&MsIdentificationListWindow::updateStatusBar);
connect(ui->centralwidget,
&QWidget::customContextMenuRequested,
this,
&MsIdentificationListWindow::showContextMenu);
connect(ui->tableView,
&QTableView::clicked,
m_proxy_model,
......@@ -90,8 +140,36 @@ MsIdentificationListWindow::onMsIdentificationSearchEdit(
emit MsIdentificationDataChanged();
}
void
MsIdentificationListWindow::showContextMenu(const QPoint &pos)
{
if(m_context_menu == nullptr)
{
m_context_menu = new QMenu(tr("Context menu"), this);
MsIdentificationListQActionColumn *p_action;
for(unsigned int i = 0; i < m_msid_table_model_p->columnCount(); i++)
{
p_action = new MsIdentificationListQActionColumn(
this, MsIdentificationTableModel::getMsIdentificationListColumn(i));
m_context_menu->addAction(p_action);
}
m_context_menu->exec(mapToGlobal(pos));
}
m_context_menu->move(mapToGlobal(pos));
m_context_menu->show();
}
MsIdentificationListWindow::~MsIdentificationListWindow()
{
delete ui;
if(m_context_menu != nullptr)
{
delete m_context_menu;
}
}
void
......@@ -145,6 +223,20 @@ MsIdentificationListWindow::doExportAsOdsFile()
}
}
void
MsIdentificationListWindow::setMsIdentificationListColumnDisplay(
msIdentificationListColumn column, bool toggled)
{
m_proxy_model->setMsIdentificationListColumnDisplay(column, toggled);
}
bool
MsIdentificationListWindow::getMsIdentificationListColumnDisplay(
msIdentificationListColumn column) const
{
return m_proxy_model->getMsIdentificationListColumnDisplay(column);
}
void
MsIdentificationListWindow::askEngineDetailView(
IdentificationDataSourceSp *identificationEngine)
......
......@@ -39,6 +39,25 @@ 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;
......@@ -51,6 +70,10 @@ class MsIdentificationListWindow : public QMainWindow
~MsIdentificationListWindow();
void setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp> &identificationDataSourceSpList);
void setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
bool toggled);
bool
getMsIdentificationListColumnDisplay(msIdentificationListColumn column) const;
void resizeColumnsToContents();
......@@ -64,6 +87,7 @@ class MsIdentificationListWindow : public QMainWindow
void doSearchOn(QString search_on);
void updateStatusBar();
void onMsIdentificationSearchEdit(QString protein_search_string);
void showContextMenu(const QPoint &);
protected:
void askEngineDetailView(IdentificationDataSourceSp *identificationEngine);
......@@ -73,7 +97,7 @@ class MsIdentificationListWindow : public QMainWindow
MsIdentificationTableModel *m_msid_table_model_p = nullptr;
MsIdentificationTableProxyModel *m_proxy_model = nullptr;
ProjectWindow *m_project_window;
QMenu *_p_context_menu = nullptr;
QMenu *m_context_menu = nullptr;
bool _display_evalue = true;
bool _display_accession = true;
};
......@@ -205,20 +205,41 @@ MsIdentificationTableProxyModel::onTableClicked(const QModelIndex &index)
qDebug() << "end " << index.row();
}
void
MsIdentificationTableProxyModel::setMsIdentificationListColumnDisplay(
msIdentificationListColumn column, bool toggled)
{
qDebug() << "begin " << toggled;
beginResetModel();
QSettings settings;
settings.setValue(QString("ms_identification_list_columns/%1")
.arg(m_msid_table_model_p->getTitle(column)),
toggled);
m_column_display[(std::int8_t)column] = toggled;
endResetModel();
resteItemDelegates();
}
bool
MsIdentificationTableProxyModel::getMsIdentificationListColumnDisplay(
msIdentificationListColumn column) const
{
return m_column_display[(std::int8_t)column];
}
void
MsIdentificationTableProxyModel::resteItemDelegates() const
{
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,7 +54,10 @@ 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);
bool
getMsIdentificationListColumnDisplay(msIdentificationListColumn column) const;
void resteItemDelegates() const;
public slots:
......
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