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
actionrepository_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 ACTIONREPOSITORY_H
16#define ACTIONREPOSITORY_H
17
19#include <QtCore/qmimedata.h>
20#include <QtGui/qstandarditemmodel.h>
21#include <QtWidgets/qtreeview.h>
22#include <QtWidgets/qlistview.h>
23#include <QtWidgets/qstackedwidget.h>
24#include <QtGui/qicon.h>
25
27
28class QPixmap;
29
30class QDesignerFormEditorInterface;
32
33namespace qdesigner_internal {
34
35class PropertySheetKeySequenceValue;
36
37// Shared model of actions, to be used for several views (detailed/icon view).
39{
41public:
43 enum { ActionRole = Qt::UserRole + 1000 };
44
45 explicit ActionModel(QWidget *parent = nullptr);
47
48 void clearActions();
50 // remove row
51 void remove(int row);
52 // update the row from the underlying action
53 void update(int row);
54
55 // return row of action or -1.
56 int findAction(QAction *) const;
57
58 QString actionName(int row) const;
59 QAction *actionAt(const QModelIndex &index) const;
61
65
66 // Find the associated menus and toolbars, ignore toolbuttons
68
69 // Retrieve shortcut via property sheet as it is a fake property
72
75
76private:
78
79 void initializeHeaders();
81 const QIcon &defaultIcon,
83
84 const QIcon m_emptyIcon;
85
87};
88
89// Internal class that provides the detailed view of actions.
91{
93public:
94 explicit ActionTreeView(ActionModel *model, QWidget *parent = nullptr);
95 QAction *currentAction() const;
96
97public slots:
98 void filter(const QString &text);
99
100signals:
102 void currentActionChanged(QAction *action);
103 void actionActivated(QAction *action, int column);
104
105protected slots:
107
108protected:
109 void dragEnterEvent(QDragEnterEvent *event) override;
110 void dragMoveEvent(QDragMoveEvent *event) override;
111 void dropEvent(QDropEvent *event) override;
112 void focusInEvent(QFocusEvent *event) override;
113 void contextMenuEvent(QContextMenuEvent *event) override;
114 void startDrag(Qt::DropActions supportedActions) override;
115
116private slots:
117 void slotActivated(const QModelIndex &);
118
119private:
120 ActionModel *m_model;
121};
122
123// Internal class that provides the icon view of actions.
125{
127public:
128 explicit ActionListView(ActionModel *model, QWidget *parent = nullptr);
129 QAction *currentAction() const;
130
131public slots:
132 void filter(const QString &text);
133
134signals:
136 void currentActionChanged(QAction *action);
137 void actionActivated(QAction *action);
138
139protected slots:
141
142protected:
143 void dragEnterEvent(QDragEnterEvent *event) override;
144 void dragMoveEvent(QDragMoveEvent *event) override;
145 void dropEvent(QDropEvent *event) override;
146 void focusInEvent(QFocusEvent *event) override;
147 void contextMenuEvent(QContextMenuEvent *event) override;
148 void startDrag(Qt::DropActions supportedActions) override;
149
150private slots:
151 void slotActivated(const QModelIndex &);
152
153private:
154 ActionModel *m_model;
155};
156
157// Action View that can be switched between detailed and icon view
158// using a QStackedWidget of ActionListView / ActionTreeView
159// that share the item model and the selection model.
160
163public:
164 // Separate initialize() function takes core argument to make this
165 // thing usable as promoted widget.
166 explicit ActionView(QWidget *parent = nullptr);
167 void initialize(QDesignerFormEditorInterface *core) { m_model->initialize(core); }
168
169 // View mode
171 int viewMode() const;
172 void setViewMode(int lm);
173
174 void setSelectionMode(QAbstractItemView::SelectionMode sm);
176
177 ActionModel *model() const { return m_model; }
178
179 QAction *currentAction() const;
180 void setCurrentIndex(const QModelIndex &index);
181
184 QItemSelection selection() const;
185
186public slots:
187 void filter(const QString &text);
188 void selectAll();
189 void clearSelection();
190 void selectAction(QAction *a);
191
192signals:
194 void currentChanged(QAction *action);
195 void activated(QAction *action, int column);
196 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
197 void resourceImageDropped(const QString &data, QAction *action);
198
199private slots:
201
202private:
203 ActionModel *m_model;
204 ActionTreeView *m_actionTreeView;
205 ActionListView *m_actionListView;
206};
207
209{
211public:
213
216
217 const ActionList &actionList() const { return m_actionList; }
219
220 static QPixmap actionDragPixmap(const QAction *action);
221
222 // Utility to accept with right action
223 void accept(QDragMoveEvent *event) const;
224private:
227};
228
229} // namespace qdesigner_internal
230
231QT_END_NAMESPACE
232
233#endif // ACTIONREPOSITORY_H
static constexpr auto toolTipPropertyC
static constexpr auto iconPropertyC
static constexpr auto textPropertyC
static constexpr auto shortcutPropertyC
static constexpr auto menuRolePropertyC
static constexpr auto actionEditorViewModeKey
static constexpr auto objectNamePropertyC
static constexpr auto checkablePropertyC
friend class QPainter
void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const override
Renders the region within the rectangle specified by rect, indicating that it has the focus,...
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
void dragEnterEvent(QDragEnterEvent *event) override
void dropEvent(QDropEvent *event) override
void focusInEvent(QFocusEvent *event) override
void contextMenuEvent(QContextMenuEvent *event) override
void startDrag(Qt::DropActions supportedActions) override
void currentActionChanged(QAction *action)
void dragMoveEvent(QDragMoveEvent *event) override
void actionActivated(QAction *action)
void dropEvent(QDropEvent *event) override
void dragMoveEvent(QDragMoveEvent *event) override
void actionActivated(QAction *action, int column)
void focusInEvent(QFocusEvent *event) override
void startDrag(Qt::DropActions supportedActions) override
void contextMenuEvent(QContextMenuEvent *event) override
void currentActionChanged(QAction *action)
void dragEnterEvent(QDragEnterEvent *event) override
void setSelectionMode(QAbstractItemView::SelectionMode sm)
QAbstractItemView::SelectionMode selectionMode() const
void currentChanged(QAction *action)
void resourceImageDropped(const QString &data, QAction *action)
void setCurrentIndex(const QModelIndex &index)
void initialize(QDesignerFormEditorInterface *core)
void activated(QAction *action, int column)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QDesignerFormWindowCommand * setKeySequencePropertyCommand(const PropertySheetKeySequenceValue &ks, QAction *action, QDesignerFormWindowInterface *fw)
static CharacterCategory category(QChar c)
static QDesignerFormWindowCommand * setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
static void setInitialProperty(QDesignerPropertySheetExtension *sheet, const QString &name, const QVariant &value)
static void refreshIconPropertyChanged(const QAction *action, QDesignerPropertySheetExtension *sheet)
static QString underscore(QString text)
static QString textPropertyValue(const QDesignerPropertySheetExtension *sheet, const QString &name)
static QString camelCase(const QString &text)
QDesignerFormWindowCommand * setPropertyCommand(const QString &name, T value, T defaultValue, QObject *o, QDesignerFormWindowInterface *fw)
#define QDESIGNER_SHARED_EXPORT