itom 2.2.1
K:/git-itom/sources/itom/Qitom/ui/paramInputDialog.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut fuer Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 *********************************************************************** */
00027 
00028 #ifndef STRINGLISTDIALOG_H
00029 #define STRINGLISTDIALOG_H
00030 
00031 #include "ui_paramInputDialog.h"
00032 
00033 #include "common/paramMeta.h"
00034 
00035 #include <qdialog.h>
00036 #include <qstyleditemdelegate.h>
00037 
00038 //-------------------------------------------------------------------------------------
00039 class QListWidgetItem;
00040 
00041 namespace ito {
00042 
00043 enum tParamType
00044 {
00045     none        = 0x0,
00046     intArray    = 0x1,
00047     doubleArray = 0x2,
00048     charArray   = 0x4
00049 };
00050 
00051 //-------------------------------------------------------------------------------------
00052 class LineEditDelegate : public QStyledItemDelegate
00053 {
00054     Q_OBJECT
00055 
00056 public:
00057     explicit LineEditDelegate(const double minVal, const double maxVal, const tParamType paramType, QObject *parent = 0);
00058 
00059     QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00060 
00061     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00062     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00063     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00064 
00065 private:
00066     ito::ParamMeta m_meta;
00067     double m_minVal;
00068     double m_maxVal;
00069     tParamType m_paramType;
00070 };
00071 
00072 //-------------------------------------------------------------------------------------
00073 class ParamInputDialog: public QDialog
00074 {
00075     Q_OBJECT
00076 
00077 public:
00078     explicit ParamInputDialog(const QStringList &stringList, const ito::ParamMeta *meta, const tParamType paramType, QWidget *parent);
00079     ~ParamInputDialog();
00080 
00081     QListWidget *listWidget() const { return ui.listWidget; }
00082     void setNewItemText(const QString &tpl) { m_newItemText = tpl; }
00083     QString newItemText() const { return m_newItemText; }
00084     void setCurrentIndex(int idx);
00085     QStringList getStringList();
00086     QRegExp m_RegExp;
00087     LineEditDelegate *m_lineEditDel;
00088 
00089 private slots:
00090     void on_newListItemButton_clicked();
00091     void on_deleteListItemButton_clicked();
00092     void on_moveListItemUpButton_clicked();
00093     void on_moveListItemDownButton_clicked();
00094     void on_listWidget_currentRowChanged();
00095     void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
00096     void on_buttonBox_clicked(QAbstractButton* btn);
00097 
00098 protected:
00099     virtual void setItemData(int role, const QVariant &v);
00100     virtual QVariant getItemData(int role) const;
00101 
00102 private:
00103     void updateEditor();
00104     Ui::paramInputDialog ui;
00105     bool m_updating;
00106     QString m_newItemText;
00107     size_t m_minSize;
00108     size_t m_maxSize;
00109     size_t m_stepSize;
00110     double m_minVal;
00111     double m_maxVal;
00112 };
00113 
00114 } //end namespace ito
00115 
00116 #endif // STRINGLISTDIALOG_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends