1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #ifndef _U2_WORKFLOW_INVESTIGATION_WIDGETS_CONTROLLER_H_
23 #define _U2_WORKFLOW_INVESTIGATION_WIDGETS_CONTROLLER_H_
24 
25 #include <QMap>
26 #include <QObject>
27 
28 #include <U2Lang/ActorModel.h>
29 #include <U2Lang/WorkflowInvestigationData.h>
30 
31 class QWidget;
32 class QTableView;
33 
34 namespace U2 {
35 
36 typedef QTableView WorkflowInvestigationWidget;
37 
38 class InvestigationDataModel;
39 
40 class WorkflowInvestigationWidgetsController : public QObject {
41     Q_OBJECT
42     Q_DISABLE_COPY(WorkflowInvestigationWidgetsController)
43 public:
44     explicit WorkflowInvestigationWidgetsController(QWidget *parent = nullptr);
45     ~WorkflowInvestigationWidgetsController();
46 
47     void deleteBusInvestigations();
48     void resetInvestigations();
49     void setInvestigationWidgetsVisible(bool visible);
50     void setCurrentInvestigation(const Workflow::Link *bus);
51     bool eventFilter(QObject *watched, QEvent *event);
52 
53 public slots:
54     void sl_currentInvestigationUpdateResponse(const WorkflowInvestigationData &investigationInfo,
55                                                const Workflow::Link *bus);
56     void sl_countOfMessagesResponse(const Workflow::Link *bus, int countOfMessages);
57 
58 signals:
59     void si_updateCurrentInvestigation(const Workflow::Link *bus);
60     void si_updateCurrentInvestigation(const Workflow::Link *bus, int messageNumber);
61     void si_countOfMessagesRequested(const Workflow::Link *bus);
62     void si_convertionMessages2DocumentsIsRequested(const Workflow::Link *bus,
63                                                     const QString &messageType,
64                                                     int messageNumber);
65 
66 private slots:
67     void sl_contextMenuRequested(const QPoint &cursorPosition);
68     void sl_hotizontalHeaderContextMenuRequested(const QPoint &cursorPosition);
69     void sl_exportInvestigation();
70     void sl_copyToClipboard() const;
71     void sl_hideSelectedColumn();
72     void sl_hideAllColumnsButSelected();
73     void sl_showAllColumns();
74     void sl_columnsVisibilityResponse();
75 
76 private:
77     void createNewInvestigation();
78     void createInvestigationModel();
79     void adjustInvestigationColumnWidth(WorkflowInvestigationWidget *investigator);
80 
81     WorkflowInvestigationWidget *investigationView;
82     InvestigationDataModel *investigationModel;
83     const Workflow::Link *investigatedLink;
84     QString investigatorName;
85     // the variable signals if investigation widget was visible when
86     // debugging finished. If true, then it will become visible when
87     // debugging starts next time
88     bool wasDisplayed;
89     QAction *exportInvestigationAction;
90     QAction *copyToClipboardAction;
91 
92     QAction *hideThisColumnAction;
93     QAction *hideAllColumnsButThisAction;
94     QAction *showAllColumnsAction;
95     int selectedColumn;
96     QMap<const Workflow::Link *, QVector<int>> columnWidths;
97 };
98 
99 }    // namespace U2
100 
101 #endif    // _U2_WORKFLOW_INVESTIGATION_WIDGETS_CONTROLLER_H_
102