OpenMS
Loading...
Searching...
No Matches
ParamEditor.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm, Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11// OpenMS_GUI config
12#include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13
15
16#include <QtWidgets/QLineEdit>
17#include <QtWidgets/QItemDelegate>
18#include <QtWidgets/QTreeWidget>
19
20class QModelIndex;
21class QStyleOptionViewItem;
22class QAbstractItemModel;
23#include <QtCore/qcontainerfwd.h> // for QStringList
24class QString;
25
26namespace Ui
27{
28 class ParamEditorTemplate;
29}
30
31namespace OpenMS
32{
33 class Param;
34 class ParamEditor;
39 namespace Internal
40 {
41
46 class OPENMS_GUI_DLLAPI OpenMSLineEdit
47 : public QLineEdit
48 {
49 Q_OBJECT
50 public:
52 :QLineEdit(w)
53 {}
54
55signals:
57 void lostFocus();
58
59
60 protected:
61 void focusOutEvent ( QFocusEvent * e ) override;
62 void focusInEvent ( QFocusEvent * e ) override;
63 };
69 class OPENMS_GUI_DLLAPI ParamEditorDelegate :
70 public QItemDelegate
71 {
72 Q_OBJECT
73
74public:
78 QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
80 void setEditorData(QWidget * editor, const QModelIndex & index) const override;
82 void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const override;
84 void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
85
87 bool hasUncommittedData() const;
88signals:
90 void modified(bool) const;
91
92protected:
94 bool eventFilter(QObject* editor, QEvent* event) override;
95
96private slots:
103
104private:
108 mutable QString fileName_;
110 mutable QString dirName_;
113 };
114
116 class OPENMS_GUI_DLLAPI ParamTree :
117 public QTreeWidget
118 {
119 Q_OBJECT
120
121public:
125 bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event) override;
126
127signals:
129 void selected(const QModelIndex & index);
130
131protected slots:
133 void selectionChanged(const QItemSelection & selected, const QItemSelection &) override;
134 };
135
136 }
137
138
150 class OPENMS_GUI_DLLAPI ParamEditor :
151 public QWidget
152 {
153 Q_OBJECT
154
155public:
157 enum
158 {
161 ADVANCED_ITEM
162 };
163
165 ParamEditor(QWidget* parent = nullptr);
167 ~ParamEditor() override;
168
170 void load(Param& param);
172 void store();
174 bool isModified() const;
176 void clear();
177
178public slots:
181 void setModified(bool is_modified);
182
183signals:
185 void modified(bool);
186
187protected slots:
189 void toggleAdvancedMode(bool advanced);
191 void showDocumentation(const QModelIndex & index);
192
193protected:
195 void storeRecursive_(QTreeWidgetItem * child, std::string path, std::map<std::string, std::string> & section_descriptions);
196
205
206private:
207 Ui::ParamEditorTemplate* ui_;
208 };
209
210
211} // namespace OpenMS
212
Custom QLineEdit which emits a signal when losing focus (such that we can commit its data)
Definition ParamEditor.h:48
void focusInEvent(QFocusEvent *e) override
void lostFocus()
emitted on focusOutEvent
void focusOutEvent(QFocusEvent *e) override
OpenMSLineEdit(QWidget *w)
Definition ParamEditor.h:51
Internal delegate class for QTreeWidget.
Definition ParamEditor.h:71
ParamEditorDelegate(QObject *parent)
Constructor.
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 closeEditor_()
if cancel in any editor is clicked, the Dialog is closed and changes are rejected
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....
bool hasUncommittedData() const
true if the underlying tree has an open QLineEdit which has uncommitted data
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:112
void commitAndCloseEditor_()
For closing any editor and updating ParamEditor.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the widget(combobox or QLineEdit) used to edit the item specified by index for editing....
QString dirName_
holds a directory name (for output directories)
Definition ParamEditor.h:110
QString fileName_
used to modify value of output and input files( not for output and input lists)
Definition ParamEditor.h:108
void commitAndCloseLineEdit_()
... a bit special, because reset uncommited data
void modified(bool) const
signal for showing ParamEditor if the Model data changed
bool eventFilter(QObject *editor, QEvent *event) override
a shortcut to calling commit(), which calls setModelData(); useful for embedded editors,...
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.
QTreeWidget that emits a signal whenever a new row is selected.
Definition ParamEditor.h:118
void selected(const QModelIndex &index)
Signal that is emitted when a new item is selected.
ParamTree(QWidget *parent)
Constructor.
bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override
Overloaded edit method to activate F2 use.
void selectionChanged(const QItemSelection &selected, const QItemSelection &) override
Reimplemented virtual slot.
A GUI for editing or viewing a Param object.
Definition ParamEditor.h:152
Internal::ParamTree * tree_
Pointer to the tree widget.
Definition ParamEditor.h:198
bool advanced_mode_
Indicates if normal mode or advanced mode is activated.
Definition ParamEditor.h:204
void showDocumentation(const QModelIndex &index)
Shows the documentation of an item in doc_.
void load(Param &param)
load method for Param object
bool isModified() const
Indicates if the data changed since last save.
bool modified_
Indicates that the data was modified since last store/load operation.
Definition ParamEditor.h:202
Ui::ParamEditorTemplate * ui_
Definition ParamEditor.h:207
void setModified(bool is_modified)
void toggleAdvancedMode(bool advanced)
Switches between normal and advanced mode.
void modified(bool)
item was edited
Param * param_
The data to edit.
Definition ParamEditor.h:200
ParamEditor(QWidget *parent=nullptr)
constructor
@ NODE
Section.
Definition ParamEditor.h:159
@ NORMAL_ITEM
Item that is always shown.
Definition ParamEditor.h:160
void storeRecursive_(QTreeWidgetItem *child, std::string path, std::map< std::string, std::string > &section_descriptions)
recursive helper method for method storeRecursive()
void clear()
Clears all parameters.
~ParamEditor() override
destructor
void store()
store edited data in Param object
Management and storage of parameters / INI files.
Definition Param.h:46
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition DataFilterDialog.h:20