msidentificationlistwindow.cpp 4.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

/*******************************************************************************
 * 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 "ui_ms_identification_run_view.h"
#include "msidentificationlistwindow.h"

#include "../../mainwindow.h"
#include <QSettings>
#include <odsstream/odsdocwriter.h>
#include <odsstream/qtablewriter.h>

MsIdentificationListQactionColumn::MsIdentificationListQactionColumn(MsIdentificationListWindow *parent,
                                                   msIdentificationListColumn column)
  : QAction(parent)
{

  this->setText(MsIdentificationTableModel::getTitle(column));
  this->setCheckable(true);


  // 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)
{
  m_project_window = parent;
  ui->setupUi(this);
  setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg"));

  m_msid_table_model_p = new MsIdentificationTableModel(this);


  m_proxy_model = new MsIdentificationTableProxyModel(this, m_msid_table_model_p);
  m_proxy_model->setSourceModel(m_msid_table_model_p);
  m_proxy_model->setDynamicSortFilter(true);

  ui->tableView->setModel(m_proxy_model);
  ui->tableView->setSortingEnabled(true);
  ui->tableView->setAlternatingRowColors(true);
  
     connect(ui->centralwidget,
          &QWidget::customContextMenuRequested,
          this,
          &MsIdentificationListWindow::showContextMenu);
}

void
MsIdentificationListWindow::showContextMenu(const QPoint &pos)
{
  if(_p_context_menu == nullptr)
    {
      _p_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));
          _p_context_menu->addAction(p_action);
        }

      _p_context_menu->exec(mapToGlobal(pos));
    }
  _p_context_menu->move(mapToGlobal(pos));
  _p_context_menu->show();
}

void
MsIdentificationListWindow::resizeColumnsToContents()
{
  ui->tableView->resizeColumnsToContents();
}

MsIdentificationListWindow::~MsIdentificationListWindow()
{
  // if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
  //   delete ui;
  //   if(_p_context_menu != nullptr)
  //     {
  //       delete _p_context_menu;
  //     }
}

void
MsIdentificationListWindow::setIdentificationDataSourceSpList(std::vector<IdentificationDataSourceSp>& identificationDataSourceSpList)
{
  qDebug() << "MsIdentificationListWindow::setIdentificationGroup begin ";

  m_msid_table_model_p->setIdentificationDataSourceSpList(identificationDataSourceSpList);

  qDebug() << "MsIdentificationListWindow::setIdentificationGroup end";
}


void
MsIdentificationListWindow::setMsIdentificationListColumnDisplay(msIdentificationListColumn column,
                                             bool toggled)
{
  m_proxy_model->setMsIdentificationListColumnDisplay(column, toggled);
}