Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
numeric_value_chooser_delegate.h
Go to the documentation of this file.
1
12#ifndef NUMERIC_VALUE_CHOOSER_DELEGATE_H_
13#define NUMERIC_VALUE_CHOOSER_DELEGATE_H_
14
15
16#include <QStyledItemDelegate>
17
21class NumericValueChooserDelegate : public QStyledItemDelegate
22{
23 Q_OBJECT
24
25public:
32 NumericValueChooserDelegate(int min = 0, int max = 0, QObject *parent = 0);
33
38
44 void setMinMaxRange(int min, int max);
45
51 void setDefaultValue(int defValue, QVariant defaultReturn);
52
53protected:
61 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
62
68 void setEditorData(QWidget *editor, const QModelIndex &index) const;
69
76 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
77
78private:
80 int _min;
81
83 int _max;
84
86 int _default;
87
89 QVariant _defReturn;
90
91private slots:
96 void onValueChanged(int i);
97};
98
99#endif /* NUMERIC_VALUE_CHOOSER_DELEGATE_H_ */
A delegate for choosing numeric values within a specified range in item views.
Definition numeric_value_chooser_delegate.h:22
void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the data to be displayed in the editor widget.
Definition numeric_value_chooser_delegate.cpp:63
void setMinMaxRange(int min, int max)
Sets the minimum and maximum allowed range for the chooser.
Definition numeric_value_chooser_delegate.cpp:30
~NumericValueChooserDelegate()
Destroys the NumericValueChooserDelegate object.
Definition numeric_value_chooser_delegate.cpp:26
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Saves the data from the editor widget back into the model.
Definition numeric_value_chooser_delegate.cpp:79
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Creates the editor widget for the item.
Definition numeric_value_chooser_delegate.cpp:46
void setDefaultValue(int defValue, QVariant defaultReturn)
Sets the default value and the default return variant.
Definition numeric_value_chooser_delegate.cpp:39