itom
Loading...
Searching...
No Matches
paramInputDialog.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#pragma once
24
25#include "ui_paramInputDialog.h"
26
27#include "common/paramMeta.h"
28#include "common/param.h"
29
30#include <qdialog.h>
31#include <qstyleditemdelegate.h>
32#include <qmetatype.h>
33#include <qlist.h>
34#include <qpair.h>
35#include <qregularexpression.h>
36
37Q_DECLARE_METATYPE(ito::complex128)
38
39//-------------------------------------------------------------------------------------
40class QListWidgetItem;
41
42namespace ito {
43
44
46class LineEditDelegate : public QStyledItemDelegate
47{
48 Q_OBJECT
49
50public:
51 explicit LineEditDelegate(const ito::ParamMeta *meta, int paramType, QObject *parent = 0);
52
53 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
54
55 void setEditorData(QWidget *editor, const QModelIndex &index) const;
56 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
57 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
58
59private:
60 QSharedPointer<ito::ParamMeta> m_meta;
61 int m_paramType;
62};
63
64//-------------------------------------------------------------------------------------
65class ParamInputDialog: public QDialog
66{
67 Q_OBJECT
68
69public:
70 explicit ParamInputDialog(const Param& param, QWidget *parent = nullptr);
72
73 Param getItems(RetVal &retValue) const;
74
75private slots:
76 void on_newListItemButton_clicked();
77 void on_deleteListItemButton_clicked();
78 void on_moveListItemUpButton_clicked();
79 void on_moveListItemDownButton_clicked();
80 void on_listWidget_currentRowChanged();
81 void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
82 void on_buttonBox_clicked(QAbstractButton* btn);
83
84protected:
85 virtual void setItemData(int role, const QVariant &v);
86 virtual QVariant getItemData(int role) const;
87 QList<QPair<QString, QVariant>> parseListItems(const ito::Param &param) const;
88 void updateButtonState();
89
90private:
91 void updateEditor();
92 Ui::paramInputDialog ui;
93 bool m_updating;
94 QString m_newItemText;
95 size_t m_minSize;
96 size_t m_maxSize;
97 size_t m_stepSize;
98 Param m_param;
99 QRegularExpression m_RegExp;
100 LineEditDelegate *m_lineEditDel;
101};
102
103} //end namespace ito
declaration of delegate class
Definition paramInputDialog.h:47
class for parameter handling e.g. to pass parameters to plugins
Definition param.h:477
Definition paramInputDialog.h:66
Base class for all meta-information classes.
Definition paramMeta.h:58
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40