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 _PORT_ALIASES_DIALOG_CONTROLLER_H_
23 #define _PORT_ALIASES_DIALOG_CONTROLLER_H_
24 
25 #include <U2Lang/Aliasing.h>
26 #include <U2Lang/Schema.h>
27 
28 #include <ui_PortAliasesConfigurationDialog.h>
29 
30 namespace U2 {
31 namespace Workflow {
32 
33 typedef QPair<QString, QString> PortInfo;    // alias, description
34 struct PortAliasesCfgDlgModel {
35     QMap<Port *, QMap<Descriptor, QString>> aliases;
36     QMap<Port *, PortInfo> ports;
37 };
38 
39 class PortAliasesConfigurationDialog : public QDialog, public Ui_PortAliasesConfigurationDialog {
40     Q_OBJECT
41 public:
42     PortAliasesConfigurationDialog(const Schema &sc, QWidget *p = nullptr);
43 
44     /*
45      * it removes empty aliases from model
46      */
47     PortAliasesCfgDlgModel getModel() const;
48 
49 private:
50     void initializeModel(const Schema &schema);
51     void clearAliasTable();
52 
53 private slots:
54     void sl_portSelected(int row);
55     void sl_onDataChange(int row, int col);
56     void sl_portAliasChanged(const QString &newStr);
57     void sl_portDescriptionChanged(const QString &newStr);
58 
59 private:
60     PortAliasesCfgDlgModel model;
61     QMap<int, Port *> portListMap;    // pairs (row, port)
62     int currentRow;
63 
64     void accept();
65 
66 };    // PortAliasesConfigurationDialog
67 
68 }    // namespace Workflow
69 }    // namespace U2
70 
71 #endif    // _PORT_ALIASES_DIALOG_CONTROLLER_H_
72