-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathCBaseProperty.h
60 lines (45 loc) · 1.66 KB
/
CBaseProperty.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
#ifndef CBASEPROPERTY_H
#define CBASEPROPERTY_H
#include <QtWidgets/QTreeWidgetItem>
class CBaseProperty: public QTreeWidgetItem
{
public:
CBaseProperty(const QByteArray& id, const QString &name);
CBaseProperty(CBaseProperty* top, const QByteArray& id, const QString &name);
const QByteArray& getId() const { return m_id; }
const QString& getName() const { return m_name; }
void setMarked(bool on = true);
bool isMarked() const;
bool isMarkable() const;
bool checkMarked();
void setBackground(const QBrush& bg);
void setTextColor(const QColor& color);
// handlers to reimplement
virtual void onAdded() {}
virtual void onEnter() {}
virtual void onLeave() { finishEdit(); }
virtual void onShowEditor(QWidget* /*editWidget*/) {}
virtual void onHideEditor(QWidget* /*editWidget*/) {}
virtual bool onKeyPressed(QKeyEvent* /*event*/, QWidget* /*editWidget*/) { return false; }
// actions to reimplement
virtual QVariant getVariantValue() const = 0;
virtual void setValue();
virtual void validateValue() {}
virtual void displayValue() {}
virtual QWidget* createEditor() const { return NULL; }
virtual void valueToEditor() {}
virtual void valueFromEditor() {}
virtual void startEdit();
virtual void finishEdit(bool cancel = false);
virtual bool isEditorWindow(QWidget* editor, QWidget* window) const { return editor == window; }
protected:
friend class CPropertyEditor;
QWidget* getActiveEditor();
void setEditorPrivate();
void emitValueChanged();
QByteArray m_id;
QString m_name;
bool m_isMarkable;
bool m_editorIsPrivate;
};
#endif // CBASEPROPERTY_H