1 /*
2 	Actiona
3 	Copyright (C) 2005 Jonathan Mercier-Ganady
4 
5 	Actiona is free software: you can redistribute it and/or modify
6 	it under the terms of the GNU General Public License as published by
7 	the Free Software Foundation, either version 3 of the License, or
8 	(at your option) any later version.
9 
10 	Actiona is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 	GNU General Public License for more details.
14 
15 	You should have received a copy of the GNU General Public License
16 	along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 	Contact : jmgr@jmgr.info
19 */
20 
21 #pragma once
22 
23 #include "parametercontainer.h"
24 
25 #include <QDialog>
26 #include <QVector>
27 #include <QList>
28 #include <QSet>
29 
30 namespace Ui
31 {
32 	class ActionDialog;
33 }
34 
35 namespace ActionTools
36 {
37 	class ActionDefinition;
38 	class ActionInstance;
39 	class GroupDefinition;
40 	class ParameterDefinition;
41 	class Script;
42 }
43 
44 class QAbstractItemModel;
45 class QFormLayout;
46 class QGridLayout;
47 class QTabWidget;
48 class QSpinBox;
49 
50 class ActionDialog : public QDialog, public ActionTools::ParameterContainer
51 {
52 	Q_OBJECT
53 
54 public:
55     ActionDialog(QAbstractItemModel *completionModel, ActionTools::Script *script, const ActionTools::ActionDefinition *actionDefinition, const QString &localeName, QWidget *parent = nullptr);
56 	~ActionDialog() override;
57 
58     QMenu *createVariablesMenu(QWidget *parent) const override;
59 
60     using QDialog::exec;
61 public slots:
62 	void accept() override;
63 	int exec(ActionTools::ActionInstance *actionInstance, const QString &field, const QString &subField, int currentLine, int currentColumn);
64 	int exec(ActionTools::ActionInstance *actionInstance, int exception);
65 
66 private slots:
67 	void postInit();
68 	void currentExceptionActionChanged(int index);
69 
70 private:
71 	enum
72 	{
73 		InputParameters,
74 		OutputParameters
75 	};
76 
77 	void addParameter(ActionTools::ParameterDefinition *parameter, int tab);
78 
79 	Ui::ActionDialog *ui;
80 	ActionTools::ActionInstance *mActionInstance;
81 	ActionTools::Script *mScript;
82 	QList<ActionTools::ParameterDefinition *> mParameters;
83 	QString mCurrentField;
84 	QString mCurrentSubField;
85 	int mCurrentLine;
86 	int mCurrentColumn;
87 	int mCurrentException;
88 	QAbstractItemModel *mCompletionModel;
89 	QVector<QFormLayout *> mParameterLayouts[2];
90 	QGridLayout *mExceptionsLayout;
91 	QTabWidget *mTabWidget;
92 	QWidget *mExceptionsTabWidget;
93 	QWidget *mCommonTabWidget;
94 	QList<QWidget *> mParameterTabWidgets;
95 	QSpinBox *mPauseBeforeSpinBox;
96 	QSpinBox *mPauseAfterSpinBox;
97 	QSpinBox *mTimeoutSpinBox;
98     QSet<QString> mOtherActionsVariables;
99 
100 	Q_DISABLE_COPY(ActionDialog)
101 };
102 
103