Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 #ifndef OPENMS_VISUAL_PARAMEDITOR_H
36 #define OPENMS_VISUAL_PARAMEDITOR_H
37 
38 // OpenMS_GUI config
39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
40 
41 #include <OpenMS/CONCEPT/Types.h>
42 
43 #include <OpenMS/VISUAL/UIC/ui_ParamEditor.h>
44 #include <QtGui/QLineEdit>
45 
46 #include <QtGui/QItemDelegate>
47 #include <QtGui/QTreeWidget>
48 
49 class QModelIndex;
50 class QStyleOptionViewItem;
51 class QAbstractItemModel;
52 class QStringList;
53 class QString;
54 
55 namespace OpenMS
56 {
57  class String;
58  class Param;
59  class ParamEditor;
64  namespace Internal
65  {
66 
71  class OPENMS_GUI_DLLAPI OpenMSLineEdit
72  : public QLineEdit
73  {
74  Q_OBJECT
75  public:
77  :QLineEdit(w)
78  {}
79 
80 signals:
82  void lostFocus();
83 
84 
85  protected:
86  virtual void focusOutEvent ( QFocusEvent * e );
87  virtual void focusInEvent ( QFocusEvent * e );
88  };
94  class OPENMS_GUI_DLLAPI ParamEditorDelegate :
95  public QItemDelegate
96  {
97  Q_OBJECT
98 
99 public:
101  ParamEditorDelegate(QObject * parent);
103  QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
105  void setEditorData(QWidget * editor, const QModelIndex & index) const;
107  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
109  void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
110 
112  bool hasUncommittedData() const;
113 signals:
115  void modified(bool) const;
116 
117 protected:
119  bool exists_(QString name, QModelIndex index) const;
120 
121 private slots:
123  void commitAndCloseListEditor_();
125  void commitAndCloseComboBox_();
127  void closeListEditor_();
129  void commitAndCloseLineEdit_();
130 private:
134  mutable QString fileName_;
136  mutable bool has_uncommited_data_;
137  };
138 
140  class OPENMS_GUI_DLLAPI ParamTree :
141  public QTreeWidget
142  {
143  Q_OBJECT
144 
145 public:
147  ParamTree(QWidget * parent);
149  bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event);
150 
151 signals:
153  void selected(const QModelIndex & index);
154 
155 protected slots:
157  void selectionChanged(const QItemSelection & selected, const QItemSelection &);
158  };
159 
160  }
161 
173  class OPENMS_GUI_DLLAPI ParamEditor :
174  public QWidget,
175  public Ui::ParamEditorTemplate
176  {
177  Q_OBJECT
178 
179 public:
181  enum
182  {
185  ADVANCED_ITEM
186  };
187 
189  ParamEditor(QWidget * parent = 0);
191  void load(Param & param);
193  void store();
195  bool isModified() const;
197  void clear();
198 
199 public slots:
202  void setModified(bool is_modified);
203 
204 signals:
206  void modified(bool);
207 
208 protected slots:
210  void toggleAdvancedMode(bool advanced);
212  void showDocumentation(const QModelIndex & index);
213 
214 protected:
216  void storeRecursive_(QTreeWidgetItem * child, String path, std::map<String, String> & section_descriptions);
217 
223  bool modified_;
226  };
227 
228 
229 } // namespace OpenMS
230 
231 #endif // OPENMS_VISUAL_PARAMEDITOR_H
bool modified_
Indicates that the data was modified since last store/load operation.
Definition: ParamEditor.h:223
A more convenient string class.
Definition: String.h:57
QString fileName_
used to modify value of output and input files( not for output and input lists)
Definition: ParamEditor.h:134
Custom QLineEdit which emits a signal when losing focus (such that we can commit its data) ...
Definition: ParamEditor.h:71
Param * param_
The data to edit.
Definition: ParamEditor.h:221
Item that is always shown.
Definition: ParamEditor.h:184
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool advanced_mode_
Indicates if normal mode or advanced mode is activated.
Definition: ParamEditor.h:225
QTreeWidget that emits a signal whenever a new row is selected.
Definition: ParamEditor.h:140
Section.
Definition: ParamEditor.h:183
OpenMSLineEdit(QWidget *w)
Definition: ParamEditor.h:76
A GUI for editing or viewing a Param object.
Definition: ParamEditor.h:173
Management and storage of parameters / INI files.
Definition: Param.h:75
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:136
Internal::ParamTree * tree_
Pointer to the tree widget.
Definition: ParamEditor.h:219
Internal delegate class for QTreeWidget.
Definition: ParamEditor.h:94

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:02 using doxygen 1.8.13