itom  4.1.0
paramInputDialog.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 *********************************************************************** */
27 
28 #ifndef STRINGLISTDIALOG_H
29 #define STRINGLISTDIALOG_H
30 
31 #include "ui_paramInputDialog.h"
32 
33 #include "common/paramMeta.h"
34 
35 #include <qdialog.h>
36 #include <qstyleditemdelegate.h>
37 
38 //-------------------------------------------------------------------------------------
39 class QListWidgetItem;
40 
41 namespace ito {
42 
43 enum tParamType
44 {
45  none = 0x0,
46  intArray = 0x1,
47  doubleArray = 0x2,
48  charArray = 0x4
49 };
50 
51 //-------------------------------------------------------------------------------------
52 class LineEditDelegate : public QStyledItemDelegate
53 {
54  Q_OBJECT
55 
56 public:
57  explicit LineEditDelegate(const double minVal, const double maxVal, const tParamType paramType, QObject *parent = 0);
58 
59  QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
60 
61  void setEditorData(QWidget *editor, const QModelIndex &index) const;
62  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
63  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
64 
65 private:
66  ito::ParamMeta m_meta;
67  double m_minVal;
68  double m_maxVal;
69  tParamType m_paramType;
70 };
71 
72 //-------------------------------------------------------------------------------------
73 class ParamInputDialog: public QDialog
74 {
75  Q_OBJECT
76 
77 public:
78  explicit ParamInputDialog(const QStringList &stringList, const ito::ParamMeta *meta, const tParamType paramType, QWidget *parent);
80 
81  QListWidget *listWidget() const { return ui.listWidget; }
82  void setNewItemText(const QString &tpl) { m_newItemText = tpl; }
83  QString newItemText() const { return m_newItemText; }
84  void setCurrentIndex(int idx);
85  QStringList getStringList();
86  QRegExp m_RegExp;
87  LineEditDelegate *m_lineEditDel;
88 
89 private slots:
90  void on_newListItemButton_clicked();
91  void on_deleteListItemButton_clicked();
92  void on_moveListItemUpButton_clicked();
93  void on_moveListItemDownButton_clicked();
94  void on_listWidget_currentRowChanged();
95  void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
96  void on_buttonBox_clicked(QAbstractButton* btn);
97 
98 protected:
99  virtual void setItemData(int role, const QVariant &v);
100  virtual QVariant getItemData(int role) const;
101 
102 private:
103  void updateEditor();
104  Ui::paramInputDialog ui;
105  bool m_updating;
106  QString m_newItemText;
107  size_t m_minSize;
108  size_t m_maxSize;
109  size_t m_stepSize;
110  double m_minVal;
111  double m_maxVal;
112 };
113 
114 } //end namespace ito
115 
116 #endif // STRINGLISTDIALOG_H
Definition: apiFunctionsGraph.cpp:39
Definition: paramInputDialog.h:52
Definition: paramInputDialog.h:73
Base class for all meta-information classes.
Definition: paramMeta.h:59