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-2013.
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 #include <OpenMS/CONCEPT/Types.h>
39 
40 #include <OpenMS/VISUAL/UIC/ui_ParamEditor.h>
41 #include <QtGui/QLineEdit>
42 
43 #include <QtGui/QItemDelegate>
44 #include <QtGui/QTreeWidget>
45 
46 class QModelIndex;
47 class QStyleOptionViewItem;
48 class QAbstractItemModel;
49 class QStringList;
50 class QString;
51 
52 namespace OpenMS
53 {
54  class String;
55  class Param;
56  class ParamEditor;
61  namespace Internal
62  {
63 
68  class OPENMS_GUI_DLLAPI OpenMSLineEdit
69  : public QLineEdit
70  {
71  Q_OBJECT
72  public:
74  :QLineEdit(w)
75  {}
76 
77 signals:
79  void lostFocus();
80 
81 
82  protected:
83  virtual void focusOutEvent ( QFocusEvent * e );
84  virtual void focusInEvent ( QFocusEvent * e );
85  };
91  class OPENMS_GUI_DLLAPI ParamEditorDelegate :
92  public QItemDelegate
93  {
94  Q_OBJECT
95 
96 public:
98  ParamEditorDelegate(QObject * parent);
100  QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
102  void setEditorData(QWidget * editor, const QModelIndex & index) const;
104  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
106  void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
107 
109  bool hasUncommittedData() const;
110 signals:
112  void modified(bool) const;
113 
114 protected:
116  bool exists_(QString name, QModelIndex index) const;
117 
118 private slots:
120  void commitAndCloseListEditor_();
122  void commitAndCloseComboBox_();
124  void closeListEditor_();
126  void commitAndCloseLineEdit_();
127 private:
131  mutable QString fileName_;
133  mutable bool has_uncommited_data_;
134  };
135 
137  class OPENMS_GUI_DLLAPI ParamTree :
138  public QTreeWidget
139  {
140  Q_OBJECT
141 
142 public:
144  ParamTree(QWidget * parent);
146  bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event);
147 
148 signals:
150  void selected(const QModelIndex & index);
151 
152 protected slots:
154  void selectionChanged(const QItemSelection & selected, const QItemSelection &);
155  };
156 
157  }
158 
170  class OPENMS_GUI_DLLAPI ParamEditor :
171  public QWidget,
172  public Ui::ParamEditorTemplate
173  {
174  Q_OBJECT
175 
176 public:
178  enum
179  {
182  ADVANCED_ITEM
183  };
184 
186  ParamEditor(QWidget * parent = 0);
188  void load(Param & param);
190  void store();
192  bool isModified() const;
194  void clear();
195 
196 public slots:
199  void setModified(bool is_modified);
200 
201 signals:
203  void modified(bool);
204 
205 protected slots:
207  void toggleAdvancedMode(bool advanced);
209  void showDocumentation(const QModelIndex & index);
210 
211 protected:
213  void storeRecursive_(QTreeWidgetItem * child, String path, std::map<String, String> & section_descriptions);
214 
220  bool modified_;
223  };
224 
225 
226 } // namespace OpenMS
227 
228 #endif // OPENMS_VISUAL_PARAMEDITOR_H
bool modified_
Indicates that the data was modified since last store/load operation.
Definition: ParamEditor.h:220
A more convenient string class.
Definition: String.h:56
QString fileName_
used to modify value of output and input files( not for output and input lists)
Definition: ParamEditor.h:131
Custom QLineEdit which emits a signal when losing focus (such that we can commit its data) ...
Definition: ParamEditor.h:68
Param * param_
The data to edit.
Definition: ParamEditor.h:218
Item that is always shown.
Definition: ParamEditor.h:181
bool advanced_mode_
Indicates if normal mode or advanced mode is activated.
Definition: ParamEditor.h:222
QTreeWidget that emits a signal whenever a new row is selected.
Definition: ParamEditor.h:137
OpenMSLineEdit(QWidget *w)
Definition: ParamEditor.h:73
A GUI for editing or viewing a Param object.
Definition: ParamEditor.h:170
Management and storage of parameters / INI files.
Definition: Param.h:69
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:133
Internal::ParamTree * tree_
Pointer to the tree widget.
Definition: ParamEditor.h:216
Internal delegate class for QTreeWidget.
Definition: ParamEditor.h:91
Section.
Definition: ParamEditor.h:180

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:19 using doxygen 1.8.5