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// Qt-Security score:significant reason:default
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists for the convenience
10// of Qt Designer. This header
11// file may change from version to version without notice, or even be removed.
12//
13// We mean it.
14//
15
16#ifndef OBJECTINSPECTORMODEL_H
17#define OBJECTINSPECTORMODEL_H
18
19#include <layoutinfo_p.h>
20
21#include <QtGui/qstandarditemmodel.h>
22#include <QtGui/qicon.h>
23#include <QtCore/qcompare.h>
24#include <QtCore/qstring.h>
25#include <QtCore/qlist.h>
26#include <QtCore/qmap.h>
27#include <QtCore/qpointer.h>
28
30
31class QDesignerFormWindowInterface;
32
33namespace qdesigner_internal {
34
35 // Data structure containing the fixed item type icons
39
41
42 // Data structure representing one item of the object inspector.
43 class ObjectData {
44 public:
45 enum Type {
49 ChildWidget, // A child widget
50 LayoutableContainer, // A container that can be laid out
51 LayoutWidget, // A QLayoutWidget
52 ExtensionContainer // QTabWidget and the like, container extension
53 };
54
56
57 explicit ObjectData(QObject *parent, QObject *object, const ModelRecursionContext &ctx);
59
60 Type type() const { return m_type; }
61 QObject *object() const { return m_object; }
62 QObject *parent() const { return m_parent; }
63 QString objectName() const { return m_objectName; }
64
65 bool equals(const ObjectData & me) const;
66
70
71 unsigned compare(const ObjectData & me) const;
72
73 // Initially set up a row
74 void setItems(const StandardItemList &row, const ObjectInspectorIcons &icons) const;
75 // Update row data according to change mask
76 void setItemsDisplayData(const StandardItemList &row, const ObjectInspectorIcons &icons, unsigned mask) const;
77
78 private:
79 friend bool comparesEqual(const ObjectData &lhs, const ObjectData &rhs) noexcept
80 {
81 return lhs.m_parent == rhs.m_parent && lhs.m_object == rhs.m_object;
82 }
84
86 void initWidget(QWidget *w, const ModelRecursionContext &ctx);
87
88 QObject *m_parent = nullptr;
89 QObject *m_object = nullptr;
90 Type m_type = Object;
91 QString m_className;
92 QString m_objectName;
93 QIcon m_classIcon;
95 };
96
98
99 // QStandardItemModel for ObjectInspector. Uses ObjectData/ObjectModel
100 // internally for its updates.
102 public:
105
106 explicit ObjectInspectorModel(QObject *parent);
107
109 UpdateResult update(QDesignerFormWindowInterface *fw);
110
111 QModelIndexList indexesOf(QObject *o) const { return m_objectIndexMultiMap.values(o); }
112 QObject *objectAt(const QModelIndex &index) const;
113
114 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
115 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
116
117 private:
118 void rebuild(const ObjectModel &newModel);
119 void updateItemContents(ObjectModel &oldModel, const ObjectModel &newModel);
120 void clearItems();
121 StandardItemList rowAt(QModelIndex index) const;
122
123 ObjectInspectorIcons m_icons;
124 QMultiMap<QObject *, QModelIndex> m_objectIndexMultiMap;
125 ObjectModel m_model;
126 QPointer<QDesignerFormWindowInterface> m_formWindow;
127 };
128} // namespace qdesigner_internal
129
130QT_END_NAMESPACE
131
132#endif // OBJECTINSPECTORMODEL_H
friend class QWidget
Definition qpainter.h:432
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.
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
QModelIndexList indexesOf(QObject *o) 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]