| OpenMS 2.5.0

ParamEditor.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm, Chris Bielow $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39
40 #include <OpenMS/CONCEPT/Types.h>
41
42 #include <QtWidgets/QLineEdit>
43 #include <QtWidgets/QItemDelegate>
44 #include <QtWidgets/QTreeWidget>
45
46 class QModelIndex;
47 class QStyleOptionViewItem;
48 class QAbstractItemModel;
49 class QStringList;
50 class QString;
51
52 namespace Ui
53 {
54 class ParamEditorTemplate;
55 }
56
57 namespace OpenMS
58 {
59 class String;
60 class Param;
61 class ParamEditor;
66 namespace Internal
67 {
68
73 class OPENMS_GUI_DLLAPI OpenMSLineEdit
74 : public QLineEdit
75 {
76 Q_OBJECT
77 public:
78 OpenMSLineEdit(QWidget * w)
79 :QLineEdit(w)
80 {}
81
82 signals:
84 void lostFocus();
85
86
87 protected:
88 void focusOutEvent ( QFocusEvent * e ) override;
89 void focusInEvent ( QFocusEvent * e ) override;
90 };
96 class OPENMS_GUI_DLLAPI ParamEditorDelegate :
97 public QItemDelegate
98 {
99 Q_OBJECT
100
101 public:
103 ParamEditorDelegate(QObject * parent);
105 QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
107 void setEditorData(QWidget * editor, const QModelIndex & index) const override;
109 void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
111 void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
112
114 bool hasUncommittedData() const;
115 signals:
117 void modified(bool) const;
118
119 protected:
121 bool exists_(QString name, QModelIndex index) const;
122
123 private slots:
125 void commitAndCloseListEditor_();
127 void commitAndCloseComboBox_();
129 void closeListEditor_();
131 void commitAndCloseLineEdit_();
132 private:
134 ParamEditorDelegate();
136 mutable QString fileName_;
138 mutable bool has_uncommited_data_;
139 };
140
142 class OPENMS_GUI_DLLAPI ParamTree :
143 public QTreeWidget
144 {
145 Q_OBJECT
146
147 public:
149 ParamTree(QWidget * parent);
151 bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event) override;
152
153 signals:
155 void selected(const QModelIndex & index);
156
157 protected slots:
159 void selectionChanged(const QItemSelection & selected, const QItemSelection &) override;
160 };
161
162 }
163
164
176 class OPENMS_GUI_DLLAPI ParamEditor :
177 public QWidget
178 {
179 Q_OBJECT
180
181 public:
183 enum
184 {
185 NODE,
186 NORMAL_ITEM,
187 ADVANCED_ITEM
188 };
189
191 ParamEditor(QWidget * parent = nullptr);
193 virtual ~ParamEditor();
194
196 void load(Param & param);
198 void store();
200 bool isModified() const;
202 void clear();
203
204 public slots:
207 void setModified(bool is_modified);
208
209 signals:
211 void modified(bool);
212
213 protected slots:
215 void toggleAdvancedMode(bool advanced);
217 void showDocumentation(const QModelIndex & index);
218
219 protected:
221 void storeRecursive_(QTreeWidgetItem * child, String path, std::map<String, String> & section_descriptions);
222
224 Internal::ParamTree * tree_;
226 Param * param_;
228 bool modified_;
230 bool advanced_mode_;
231
232 private:
233 Ui::ParamEditorTemplate* ui_;
234 };
235
236
237 } // namespace OpenMS
238
QLineEdit
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::ParamEditor::NODE
Section.
Definition: ParamEditor.h:185
QWidget
QTreeWidget
QItemDelegate
OpenMS::Internal::ParamTree
QTreeWidget that emits a signal whenever a new row is selected.
Definition: ParamEditor.h:142
OpenMS::ParamEditor::advanced_mode_
bool advanced_mode_
Indicates if normal mode or advanced mode is activated.
Definition: ParamEditor.h:230
Types.h
OpenMS::Internal::OpenMSLineEdit::OpenMSLineEdit
OpenMSLineEdit(QWidget *w)
Definition: ParamEditor.h:78
OpenMS::ParamEditor::tree_
Internal::ParamTree * tree_
Pointer to the tree widget.
Definition: ParamEditor.h:224
OpenMS::ParamEditor::modified_
bool modified_
Indicates that the data was modified since last store/load operation.
Definition: ParamEditor.h:228
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::ParamEditorDelegate
Internal delegate class for QTreeWidget.
Definition: ParamEditor.h:96
OpenMS::ParamEditor::NORMAL_ITEM
Item that is always shown.
Definition: ParamEditor.h:186
Ui
Definition: DataFilterDialog.h:45
OpenMS::ParamEditor
A GUI for editing or viewing a Param object.
Definition: ParamEditor.h:176
OpenMS::Internal::OpenMSLineEdit
Custom QLineEdit which emits a signal when losing focus (such that we can commit its data) ...
Definition: ParamEditor.h:73
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::Internal::ParamEditorDelegate::fileName_
QString fileName_
used to modify value of output and input files( not for output and input lists)
Definition: ParamEditor.h:136
OpenMS::ParamEditor::ui_
Ui::ParamEditorTemplate * ui_
Definition: ParamEditor.h:233
OpenMS::ParamEditor::param_
Param * param_
The data to edit.
Definition: ParamEditor.h:226
OpenMS::Internal::ParamEditorDelegate::has_uncommited_data_
bool has_uncommited_data_
true if a QLineEdit is still open and has not committed its data yet (so storing the current param is...
Definition: ParamEditor.h:138
QObject