-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathparameter_delegate.h
109 lines (93 loc) · 3.66 KB
/
parameter_delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef PARAMETERDELEGATE_H
#define PARAMETERDELEGATE_H
#include <QItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QLineEdit>
#include <QComboBox>
#include <QFileDialog>
#include "browse_lineedit.h"
namespace dealii
{
/*! @addtogroup ParameterGui
*@{
*/
namespace ParameterGui
{
/**
* The ParameterDelegate class implements special delegates for the QTreeWidget class used in the parameterGUI.
* The QTreeWidget class provides some different standard delegates for editing parameters shown in the
* tree structure. The ParameterDelegate class provides special editors for the different types of parameters defined in
* the ParameterHandler class. For all parameter types based on strings as "Anything", "MultipleSelection" "Map" and
* "List" a simple line editor will be shown up. In the case of integer and double type parameters the editor is a spin box and for
* "Selection" type parameters a combo box will be shown up. For parameters of type "FileName" and "DirectoryName"
* the delegate shows a @ref BrowseLineEdit editor. The column of the tree structure with the parameter values has to be set
* in the constructor.
*
* @note This class is used in the graphical user interface for the @ref ParameterHandler class.
* It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
*
* @ingroup ParameterGui
* @author Martin Steigemann, Wolfgang Bangerth, 2010
*/
class ParameterDelegate : public QItemDelegate
{
Q_OBJECT
public:
/**
* Constructor, @p value_column specifies the column
* of the parameter tree this delegate will be used on.
*/
ParameterDelegate (const int value_column, QObject *parent = 0);
/**
* This function creates the appropriate editor for the parameter
* based on the <tt>index</tt>.
*/
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
/**
* Reimplemented from QItemDelegate.
*/
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* Reimplemented from QItemDelegate.
*/
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
/**
* Reimplemented from QItemDelegate.
*/
void setEditorData(QWidget *editor, const QModelIndex &index) const;
/**
* Reimplemented from QItemDelegate.
*/
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
private slots:
/**
* Reimplemented from QItemDelegate.
*/
void commit_and_close_editor();
private:
/**
* The column this delegate will be used on.
*/
int value_column;
};
}
/**@}*/
}
#endif