Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ListEditor.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: David Wojnar $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_VISUAL_LISTEDITOR_H
36 #define OPENMS_VISUAL_LISTEDITOR_H
37 
38 // OpenMS_GUI config
39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
40 
41 #ifndef Q_MOC_RUN
43 #endif
44 
45 #include <QtGui/QDialog>
46 #include <QtGui/QListWidget>
47 #include <QtGui/QItemDelegate>
48 
49 class QPushButton;
50 
51 namespace OpenMS
52 {
53  namespace Internal
54  {
55  class ListTable;
56  class ListEditorDelegate;
57  }
58 
62  class OPENMS_GUI_DLLAPI ListEditor :
63  public QDialog
64  {
65  Q_OBJECT
66 
67 public:
68  //types of lists
69  enum Type
70  {
71  INT,
75  INPUT_FILE
76  };
77 
79  ListEditor(QWidget * parent = 0, QString title = "");
81  StringList getList() const;
83  void setList(const StringList & list, ListEditor::Type type);
85  void setListRestrictions(const String & restrictions);
87  void setTypeName(QString name);
88 
89 private:
97  QPushButton * newRowButton_;
99  QPushButton * removeRowButton_;
101  QPushButton * OkButton_;
103  QPushButton * CancelButton_;
104  };
105 
110  namespace Internal
111  {
112  class OPENMS_GUI_DLLAPI ListTable :
113  public QListWidget
114  {
115  Q_OBJECT
116 
117 public:
118 
119  //Default Constructor
120  ListTable(QWidget * parent = 0);
121 
122  //returns a list_
123  StringList getList();
124 
125  //sets new list
126  void setList(const StringList & list, ListEditor::Type type);
127 
128 public slots:
129  void createNewRow();
130  void removeCurrentRow();
131 
132 private:
135  //everything is internally stored as stringlist
137  };
138 
144  class OPENMS_GUI_DLLAPI ListEditorDelegate :
145  public QItemDelegate
146  {
147  Q_OBJECT
148 
149 public:
151  ListEditorDelegate(QObject * parent);
153  QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
155  void setEditorData(QWidget * editor, const QModelIndex & index) const;
157  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
159  void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
160 
161  //sets Type of List
162  void setType(const ListEditor::Type type);
163  //sets restrictions for listelements
164  void setRestrictions(const String & restrictions);
166  void setTypeName(QString name);
168  void setFileName(QString name);
169 
170 private:
178  QString typeName_;
180  mutable QString file_name_;
181 
182  };
183  }
184 
185 } // namespace OpenMS
186 #endif //OPENMS_VISUAL_LISTEDITOR_H
Definition: ListEditor.h:72
String restrictions_
restrictions for list elements
Definition: ListEditor.h:176
Definition: ListEditor.h:112
A more convenient string class.
Definition: String.h:57
QPushButton * OkButton_
button clicked if modifications are accepted
Definition: ListEditor.h:101
QString file_name_
used to set input and output values in setModelData
Definition: ListEditor.h:180
Internal delegate class.
Definition: ListEditor.h:144
Definition: ListEditor.h:74
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ListEditor::Type type_
List type.
Definition: ListEditor.h:134
Type
Definition: ListEditor.h:69
StringList list_
Definition: ListEditor.h:136
QPushButton * newRowButton_
button for new Row
Definition: ListEditor.h:97
QPushButton * removeRowButton_
button for removing row
Definition: ListEditor.h:99
Definition: ListEditor.h:71
Internal::ListEditorDelegate * listDelegate_
Delegate between view and model.
Definition: ListEditor.h:95
ListEditor::Type type_
List type.
Definition: ListEditor.h:174
Editor for editing int, double and string lists (including output and input file lists) ...
Definition: ListEditor.h:62
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
ListEditor::Type type_
List type.
Definition: ListEditor.h:91
QString typeName_
type name. used to distinguish output/input from string lists
Definition: ListEditor.h:178
Definition: ListEditor.h:73
Internal::ListTable * listTable_
displays the list
Definition: ListEditor.h:93
QPushButton * CancelButton_
button clicked if modifications are rejected
Definition: ListEditor.h:103

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