Debian Codegraph @

src/Gui/propertyeditor/PropertyItemDelegate.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /***************************************************************************
3 * Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
4 * *
5 * This file is part of the FreeCAD CAx development system. *
6 * *
7 * This library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU Library General Public *
9 * License as published by the Free Software Foundation; either *
10 * version 2 of the License, or (at your option) any later version. *
11 * *
12 * This library is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Library General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Library General Public *
18 * License along with this library; see the file COPYING.LIB. If not, *
19 * write to the Free Software Foundation, Inc., 59 Temple Place, *
20 * Suite 330, Boston, MA 02111-1307, USA *
21 * *
22 ***************************************************************************/
23
24
25 #ifndef PROPERTYITEMDELEGATE_H
26 #define PROPERTYITEMDELEGATE_H
27
28 #include <QItemDelegate>
29 #include <QPointer>
30
31 namespace Gui
32 {
33 namespace PropertyEditor
34 {
35
36 class PropertyEditorWidget;
37
38 class PropertyItemDelegate: public QItemDelegate
39 {
40 Q_OBJECT
41
42 public:
43 explicit PropertyItemDelegate(QObject* parent);
44 ~PropertyItemDelegate() override;
45
46 void paint(QPainter* painter, const QStyleOptionViewItem& opt, const QModelIndex& index) const override;
47 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override;
48 void setEditorData(QWidget* editor, const QModelIndex& index) const override;
49 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
50 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
51 bool editorEvent(
52 QEvent* event,
53 QAbstractItemModel* model,
54 const QStyleOptionViewItem& option,
55 const QModelIndex& index
56 ) override;
57
58 protected:
59 bool eventFilter(QObject*, QEvent*) override;
60
61 void valueChanged();
62
63 private:
64 mutable QPointer<QWidget> propertyEditor;
65 mutable QWidget* expressionEditor;
66 mutable PropertyEditorWidget* userEditor = nullptr;
67 mutable bool pressed;
68 bool changed;
69 };
70
71 } // namespace PropertyEditor
72 } // namespace Gui
73
74 #endif // PROPERTYITEMDELEGATE_H