OpenMS
ListEditor.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: David Wojnar $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
14 #ifndef Q_MOC_RUN
16 #endif
17 
18 #include <QDialog>
19 #include <QListWidget>
20 #include <QItemDelegate>
21 
22 class QPushButton;
23 
24 namespace OpenMS
25 {
26  namespace Internal
27  {
28  class ListTable;
29  class ListEditorDelegate;
30  }
31 
35  class OPENMS_GUI_DLLAPI ListEditor :
36  public QDialog
37  {
38  Q_OBJECT
39 
40 public:
41  //types of lists
42  enum Type
43  {
44  INT,
48  INPUT_FILE
49  };
50 
52  ListEditor(QWidget * parent = nullptr, const QString& title = "");
56  void setList(const StringList & list, ListEditor::Type type);
58  void setListRestrictions(const String & restrictions);
60  void setTypeName(QString name);
61 
62 private:
70  QPushButton * newRowButton_;
72  QPushButton * removeRowButton_;
74  QPushButton * OkButton_;
76  QPushButton * CancelButton_;
77  };
78 
83  namespace Internal
84  {
85  class OPENMS_GUI_DLLAPI ListTable :
86  public QListWidget
87  {
88  Q_OBJECT
89 
90 public:
91 
92  //Default Constructor
93  ListTable(QWidget * parent = nullptr);
94 
95  //returns a list_
97 
98  //sets new list
99  void setList(const StringList & list, ListEditor::Type type);
100 
101 public slots:
102  void createNewRow();
104 
105 private:
108  //everything is internally stored as stringlist
110  };
111 
117  class OPENMS_GUI_DLLAPI ListEditorDelegate :
118  public QItemDelegate
119  {
120  Q_OBJECT
121 
122 public:
126  QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
128  void setEditorData(QWidget * editor, const QModelIndex & index) const override;
130  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
132  void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
133 
134  //sets Type of List
135  void setType(const ListEditor::Type type);
136  //sets restrictions for listelements
137  void setRestrictions(const String & restrictions);
139  void setTypeName(QString name);
141  void setFileName(QString name);
142 
143 private:
151  QString typeName_;
153  mutable QString file_name_;
154 
155  };
156  }
157 
158 } // namespace OpenMS
Internal delegate class.
Definition: ListEditor.h:119
void setTypeName(QString name)
set name of type
void setFileName(QString name)
sets the fileName
void setRestrictions(const String &restrictions)
ListEditorDelegate(QObject *parent)
Constructor.
void setType(const ListEditor::Type type)
ListEditor::Type type_
List type.
Definition: ListEditor.h:147
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Updates the editor for the item specified by index according to the style option given.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Sets the data for the specified model and item index from that supplied by the editor....
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
not reimplemented
QString file_name_
used to set input and output values in setModelData
Definition: ListEditor.h:153
String restrictions_
restrictions for list elements
Definition: ListEditor.h:149
QString typeName_
type name. used to distinguish output/input from string lists
Definition: ListEditor.h:151
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the data to be displayed and edited by the editor for the item specified by index.
ListEditorDelegate()
Not implemented => private.
Definition: ListEditor.h:87
void setList(const StringList &list, ListEditor::Type type)
ListEditor::Type type_
List type.
Definition: ListEditor.h:107
ListTable(QWidget *parent=nullptr)
StringList list_
Definition: ListEditor.h:109
Editor for editing int, double and string lists (including output and input file lists)
Definition: ListEditor.h:37
void setTypeName(QString name)
set name of type
QPushButton * CancelButton_
button clicked if modifications are rejected
Definition: ListEditor.h:76
void setList(const StringList &list, ListEditor::Type type)
sets list (and its type)that will be modified by user
Type
Definition: ListEditor.h:43
@ OUTPUT_FILE
Definition: ListEditor.h:47
@ FLOAT
Definition: ListEditor.h:45
@ STRING
Definition: ListEditor.h:46
@ INT
Definition: ListEditor.h:44
ListEditor::Type type_
List type.
Definition: ListEditor.h:64
void setListRestrictions(const String &restrictions)
set restrictions for list elements
QPushButton * removeRowButton_
button for removing row
Definition: ListEditor.h:72
QPushButton * newRowButton_
button for new Row
Definition: ListEditor.h:70
QPushButton * OkButton_
button clicked if modifications are accepted
Definition: ListEditor.h:74
ListEditor(QWidget *parent=nullptr, const QString &title="")
Constructor.
StringList getList() const
returns modified list
Internal::ListTable * listTable_
displays the list
Definition: ListEditor.h:66
Internal::ListEditorDelegate * listDelegate_
Delegate between view and model.
Definition: ListEditor.h:68
A more convenient string class.
Definition: String.h:34
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22