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// 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 ACTIONREPOSITORY_H
17#define ACTIONREPOSITORY_H
18
20#include <QtCore/qmimedata.h>
21#include <QtGui/qstandarditemmodel.h>
22#include <QtWidgets/qtreeview.h>
23#include <QtWidgets/qlistview.h>
24#include <QtWidgets/qstackedwidget.h>
25#include <QtGui/qicon.h>
26
28
29class QPixmap;
30
31class QDesignerFormEditorInterface;
33
34namespace qdesigner_internal {
35
36class PropertySheetKeySequenceValue;
37
38// Shared model of actions, to be used for several views (detailed/icon view).
40{
42public:
44 enum { ActionRole = Qt::UserRole + 1000 };
45
46 explicit ActionModel(QWidget *parent = nullptr);
48
49 void clearActions();
51 // remove row
52 void remove(int row);
53 // update the row from the underlying action
54 void update(int row);
55
56 // return row of action or -1.
57 int findAction(QAction *) const;
58
59 QString actionName(int row) const;
60 QAction *actionAt(const QModelIndex &index) const;
62
66
67 // Find the associated menus and toolbars, ignore toolbuttons
69
70 // Retrieve shortcut via property sheet as it is a fake property
73
76
77private:
79
80 void initializeHeaders();
82 const QIcon &defaultIcon,
84
85 const QIcon m_emptyIcon;
86
88};
89
90// Internal class that provides the detailed view of actions.
92{
94public:
95 explicit ActionTreeView(ActionModel *model, QWidget *parent = nullptr);
96 QAction *currentAction() const;
97
98public slots:
99 void filter(const QString &text);
100
101signals:
103 void currentActionChanged(QAction *action);
104 void actionActivated(QAction *action, int column);
105
106protected slots:
108
109protected:
110 void dragEnterEvent(QDragEnterEvent *event) override;
111 void dragMoveEvent(QDragMoveEvent *event) override;
112 void dropEvent(QDropEvent *event) override;
113 void focusInEvent(QFocusEvent *event) override;
114 void contextMenuEvent(QContextMenuEvent *event) override;
115 void startDrag(Qt::DropActions supportedActions) override;
116
117private slots:
118 void slotActivated(const QModelIndex &);
119
120private:
121 ActionModel *m_model;
122};
123
124// Internal class that provides the icon view of actions.
126{
128public:
129 explicit ActionListView(ActionModel *model, QWidget *parent = nullptr);
130 QAction *currentAction() const;
131
132public slots:
133 void filter(const QString &text);
134
135signals:
137 void currentActionChanged(QAction *action);
138 void actionActivated(QAction *action);
139
140protected slots:
142
143protected:
144 void dragEnterEvent(QDragEnterEvent *event) override;
145 void dragMoveEvent(QDragMoveEvent *event) override;
146 void dropEvent(QDropEvent *event) override;
147 void focusInEvent(QFocusEvent *event) override;
148 void contextMenuEvent(QContextMenuEvent *event) override;
149 void startDrag(Qt::DropActions supportedActions) override;
150
151private slots:
152 void slotActivated(const QModelIndex &);
153
154private:
155 ActionModel *m_model;
156};
157
158// Action View that can be switched between detailed and icon view
159// using a QStackedWidget of ActionListView / ActionTreeView
160// that share the item model and the selection model.
161
164public:
165 // Separate initialize() function takes core argument to make this
166 // thing usable as promoted widget.
167 explicit ActionView(QWidget *parent = nullptr);
168 void initialize(QDesignerFormEditorInterface *core) { m_model->initialize(core); }
169
170 // View mode
172 int viewMode() const;
173 void setViewMode(int lm);
174
175 void setSelectionMode(QAbstractItemView::SelectionMode sm);
177
178 ActionModel *model() const { return m_model; }
179
180 QAction *currentAction() const;
181 void setCurrentIndex(const QModelIndex &index);
182
185 QItemSelection selection() const;
186
187public slots:
188 void filter(const QString &text);
189 void selectAll();
190 void clearSelection();
191 void selectAction(QAction *a);
192
193signals:
195 void currentActionChanged(QAction *action);
196 void activated(QAction *action, int column);
197 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
198 void resourceImageDropped(const QString &data, QAction *action);
199
200private slots:
202
203private:
204 ActionModel *m_model;
205 ActionTreeView *m_actionTreeView;
206 ActionListView *m_actionListView;
207};
208
210{
212public:
214
217
218 const ActionList &actionList() const { return m_actionList; }
220
221 static QPixmap actionDragPixmap(const QAction *action);
222
223 // Utility to accept with right action
224 void accept(QDragMoveEvent *event) const;
225private:
228};
229
230} // namespace qdesigner_internal
231
232QT_END_NAMESPACE
233
234#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)
void currentActionChanged(QAction *action)
QAbstractItemView::SelectionMode selectionMode() const
void resourceImageDropped(const QString &data, QAction *action)
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
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