Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
objectinspectormodel_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef OBJECTINSPECTORMODEL_H
16#define OBJECTINSPECTORMODEL_H
17
18#include <layoutinfo_p.h>
19
20#include <QtGui/qstandarditemmodel.h>
21#include <QtGui/qicon.h>
22#include <QtCore/qcompare.h>
23#include <QtCore/qstring.h>
24#include <QtCore/qlist.h>
25#include <QtCore/qmap.h>
26#include <QtCore/qpointer.h>
27
29
30class QDesignerFormWindowInterface;
31
32namespace qdesigner_internal {
33
34 // Data structure containing the fixed item type icons
38
40
41 // Data structure representing one item of the object inspector.
42 class ObjectData {
43 public:
44 enum Type {
48 ChildWidget, // A child widget
49 LayoutableContainer, // A container that can be laid out
50 LayoutWidget, // A QLayoutWidget
51 ExtensionContainer // QTabWidget and the like, container extension
52 };
53
55
56 explicit ObjectData(QObject *parent, QObject *object, const ModelRecursionContext &ctx);
58
59 inline Type type() const { return m_type; }
60 inline QObject *object() const { return m_object; }
61 inline QObject *parent() const { return m_parent; }
62 inline QString objectName() const { return m_objectName; }
63
64 bool equals(const ObjectData & me) const;
65
69
70 unsigned compare(const ObjectData & me) const;
71
72 // Initially set up a row
73 void setItems(const StandardItemList &row, const ObjectInspectorIcons &icons) const;
74 // Update row data according to change mask
75 void setItemsDisplayData(const StandardItemList &row, const ObjectInspectorIcons &icons, unsigned mask) const;
76
77 private:
78 friend bool comparesEqual(const ObjectData &lhs, const ObjectData &rhs) noexcept
79 {
80 return lhs.m_parent == rhs.m_parent && lhs.m_object == rhs.m_object;
81 }
83
85 void initWidget(QWidget *w, const ModelRecursionContext &ctx);
86
87 QObject *m_parent = nullptr;
88 QObject *m_object = nullptr;
89 Type m_type = Object;
90 QString m_className;
91 QString m_objectName;
92 QIcon m_classIcon;
94 };
95
97
98 // QStandardItemModel for ObjectInspector. Uses ObjectData/ObjectModel
99 // internally for its updates.
101 public:
104
105 explicit ObjectInspectorModel(QObject *parent);
106
108 UpdateResult update(QDesignerFormWindowInterface *fw);
109
110 const QModelIndexList indexesOf(QObject *o) const { return m_objectIndexMultiMap.values(o); }
111 QObject *objectAt(const QModelIndex &index) const;
112
113 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
114 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
115
116 private:
117 void rebuild(const ObjectModel &newModel);
118 void updateItemContents(ObjectModel &oldModel, const ObjectModel &newModel);
119 void clearItems();
120 StandardItemList rowAt(QModelIndex index) const;
121
122 ObjectInspectorIcons m_icons;
123 QMultiMap<QObject *, QModelIndex> m_objectIndexMultiMap;
124 ObjectModel m_model;
125 QPointer<QDesignerFormWindowInterface> m_formWindow;
126 };
127} // namespace qdesigner_internal
128
129QT_END_NAMESPACE
130
131#endif // OBJECTINSPECTORMODEL_H
friend class QWidget
Definition qpainter.h:421
ObjectData(QObject *parent, QObject *object, const ModelRecursionContext &ctx)
bool equals(const ObjectData &me) const
void setItemsDisplayData(const StandardItemList &row, const ObjectInspectorIcons &icons, unsigned mask) const
void setItems(const StandardItemList &row, const ObjectInspectorIcons &icons) const
unsigned compare(const ObjectData &me) const
friend bool comparesEqual(const ObjectData &lhs, const ObjectData &rhs) noexcept
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the editor to be used for editing the data item with the given index.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
const QModelIndexList indexesOf(QObject *o) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the role data for the item at index to value.
UpdateResult update(QDesignerFormWindowInterface *fw)
QObject * objectAt(const QModelIndex &index) const
void mouseMoveEvent(QMouseEvent *event) override
void keyPressEvent(QKeyEvent *event) override
QObjectList indexesToObjects(const QModelIndexList &indexes) const
QWidget * managedWidgetAt(const QPoint &global_mouse_pos)
void slotPopupContextMenu(QWidget *parent, const QPoint &pos)
const QPointer< FormWindowBase > & formWindow() const
void handleDragEnterMoveEvent(const QWidget *objectInspectorWidget, QDragMoveEvent *event, bool isDragEnter)
void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static SelectionType selectionType(const QDesignerFormWindowInterface *fw, QObject *o)
static QPoint dropPointOffset(const qdesigner_internal::FormWindowBase *fw, const QWidget *dropTarget)
QIcon layoutIcons[LayoutInfo::UnknownLayout+1]