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-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: David Wojnar $
32 // $Authors: David Wojnar $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_VISUAL_LISTEDITOR_H
36 #define OPENMS_VISUAL_LISTEDITOR_H
37 
38 
40 #include <QtGui/QDialog>
41 #include <QtGui/QListWidget>
42 #include <QtGui/QItemDelegate>
43 
44 class QPushButton;
45 
46 namespace OpenMS
47 {
48  namespace Internal
49  {
50  class ListTable;
51  class ListEditorDelegate;
52  }
53 
57  class OPENMS_GUI_DLLAPI ListEditor :
58  public QDialog
59  {
60  Q_OBJECT
61 
62 public:
63  //types of lists
64  enum Type
65  {
66  INT,
70  INPUT_FILE
71  };
72 
74  ListEditor(QWidget * parent = 0, QString title = "");
76  StringList getList() const;
78  void setList(const StringList & list, ListEditor::Type type);
80  void setListRestrictions(const String & restrictions);
82  void setTypeName(QString name);
83 
84 private:
92  QPushButton * newRowButton_;
94  QPushButton * removeRowButton_;
96  QPushButton * OkButton_;
98  QPushButton * CancelButton_;
99  };
100 
105  namespace Internal
106  {
107  class OPENMS_GUI_DLLAPI ListTable :
108  public QListWidget
109  {
110  Q_OBJECT
111 
112 public:
113 
114  //Default Constructor
115  ListTable(QWidget * parent = 0);
116 
117  //returns a list_
118  StringList getList();
119 
120  //sets new list
121  void setList(const StringList & list, ListEditor::Type type);
122 
123 public slots:
124  void createNewRow();
125  void removeCurrentRow();
126 
127 private:
130  //everything is internally stored as stringlist
132  };
133 
139  class OPENMS_GUI_DLLAPI ListEditorDelegate :
140  public QItemDelegate
141  {
142  Q_OBJECT
143 
144 public:
146  ListEditorDelegate(QObject * parent);
148  QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
150  void setEditorData(QWidget * editor, const QModelIndex & index) const;
152  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
154  void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
155 
156  //sets Type of List
157  void setType(const ListEditor::Type type);
158  //sets restrictions for listelements
159  void setRestrictions(const String & restrictions);
161  void setTypeName(QString name);
163  void setFileName(QString name);
164 
165 private:
173  QString typeName_;
175  mutable QString file_name_;
176 
177 
178  };
179  }
180 
181 
182 
183 
184 
185 } // namespace OpenMS
186 #endif //OPENMS_VISUAL_LISTEDITOR_H
Definition: ListEditor.h:67
String restrictions_
restrictions for list elements
Definition: ListEditor.h:171
Definition: ListEditor.h:107
A more convenient string class.
Definition: String.h:56
QPushButton * OkButton_
button clicked if modifications are accepted
Definition: ListEditor.h:96
QString file_name_
used to set input and output values in setModelData
Definition: ListEditor.h:175
Internal delegate class.
Definition: ListEditor.h:139
Definition: ListEditor.h:69
ListEditor::Type type_
List type.
Definition: ListEditor.h:129
Type
Definition: ListEditor.h:64
StringList list_
Definition: ListEditor.h:131
QPushButton * newRowButton_
buttton for new Row
Definition: ListEditor.h:92
QPushButton * removeRowButton_
button for removing row
Definition: ListEditor.h:94
Definition: ListEditor.h:66
Internal::ListEditorDelegate * listDelegate_
Delegate between view and model.
Definition: ListEditor.h:90
ListEditor::Type type_
List type.
Definition: ListEditor.h:169
Editor for editing int, double and string lists (including output and input file lists) ...
Definition: ListEditor.h:57
String list.
Definition: StringList.h:56
ListEditor::Type type_
List type.
Definition: ListEditor.h:86
QString typeName_
type name. used to distinguish output/input from string lists
Definition: ListEditor.h:173
Definition: ListEditor.h:68
Internal::ListTable * listTable_
displays the list
Definition: ListEditor.h:88
QPushButton * CancelButton_
button clicked if modifications are rejected
Definition: ListEditor.h:98

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