00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OPENMS_VISUAL_PARAMEDITOR_H
00029 #define OPENMS_VISUAL_PARAMEDITOR_H
00030
00031 #include <OpenMS/CONCEPT/Types.h>
00032
00033 #include <OpenMS/VISUAL/UIC/ParamEditorTemplate.h>
00034
00035
00036 #include <QtGui/QItemDelegate>
00037 #include <QtGui/QTreeWidget>
00038
00039 class QModelIndex;
00040 class QStyleOptionViewItem;
00041 class QAbstractItemModel;
00042 class QStringList;
00043 class QString;
00044
00045 namespace OpenMS
00046 {
00047 class String;
00048 class Param;
00049 class ParamEditor;
00054 namespace Internal
00055 {
00061 class ParamEditorDelegate
00062 : public QItemDelegate
00063 {
00064 Q_OBJECT
00065
00066 public:
00068 ParamEditorDelegate(QObject* parent);
00070 QWidget *createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
00072 void setEditorData(QWidget* editor, const QModelIndex& index) const;
00074 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
00076 void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex &index) const;
00077
00078 signals:
00080 void modified(bool) const;
00081
00082 protected:
00084 bool exists_(QString name, QModelIndex index) const;
00085
00086 private:
00088 ParamEditorDelegate();
00089 };
00090
00092 class ParamTree
00093 : public QTreeWidget
00094 {
00095 Q_OBJECT
00096
00097 public:
00099 ParamTree(QWidget* parent);
00101 bool edit(const QModelIndex& index, EditTrigger trigger, QEvent* event);
00102
00103 signals:
00105 void selected(const QModelIndex& index);
00106
00107 protected slots:
00109 void selectionChanged(const QItemSelection& selected, const QItemSelection&);
00110 };
00111
00112 }
00113
00127 class ParamEditor
00128 : public QWidget,
00129 public Ui::ParamEditorTemplate
00130 {
00131 Q_OBJECT
00132
00133 public:
00135 enum
00136 {
00137 NODE,
00138 NORMAL_ITEM,
00139 ADVANCED_ITEM
00140 };
00141
00143 ParamEditor(QWidget* parent=0);
00145 void load(Param& param);
00147 void store();
00149 bool isModified() const;
00151 void clear();
00152
00153 signals:
00155 void modified(bool);
00156
00157 protected slots:
00160 void setModified(bool is_modified);
00162 void toggleAdvancedMode(bool advanced);
00164 void showDocumentation(const QModelIndex& index);
00165
00166 protected:
00168 void storeRecursive_(QTreeWidgetItem* child, String path, std::map<String,String>& section_descriptions);
00169
00171 Internal::ParamTree* tree_;
00173 Param* param_;
00175 bool modified_;
00177 bool advanced_mode_;
00178 };
00179
00180
00181 }
00182
00183 #endif // OPENMS_VISUAL_PARAMEDITOR_H