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
widgetboxtreewidget.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#ifndef WIDGETBOXTREEWIDGET_H
6#define WIDGETBOXTREEWIDGET_H
7
8#include <qdesigner_widgetbox_p.h>
9
10#include <QtWidgets/qtreewidget.h>
11#include <QtGui/qicon.h>
12#include <QtCore/qlist.h>
13#include <QtCore/qhash.h>
14#include <QtCore/qxmlstream.h>
15
17
18class QDesignerFormEditorInterface;
19class QDesignerDnDItemInterface;
20
21class QTimer;
22
23namespace qdesigner_internal {
24
26
27// WidgetBoxTreeWidget: A tree of categories
28
30{
32
33public:
37
38 explicit WidgetBoxTreeWidget(QDesignerFormEditorInterface *core, QWidget *parent = nullptr);
40
41 int categoryCount() const;
42 Category category(int cat_idx) const;
43 void addCategory(const Category &cat);
44 void removeCategory(int cat_idx);
45
46 int widgetCount(int cat_idx) const;
47 Widget widget(int cat_idx, int wgt_idx) const;
48 void addWidget(int cat_idx, const Widget &wgt);
49 void removeWidget(int cat_idx, int wgt_idx);
50
51 void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list);
52
53 void setFileName(const QString &file_name);
54 QString fileName() const;
55 bool load(QDesignerWidgetBox::LoadMode loadMode);
56 bool loadContents(const QString &contents);
57 bool save();
58 QIcon iconForWidget(const QString &iconName) const;
59
63
64public slots:
65 void filter(const QString &);
66
67protected:
68 void contextMenuEvent(QContextMenuEvent *e) override;
69 void resizeEvent(QResizeEvent *e) override;
70
71private slots:
72 void slotSave();
73 void slotScratchPadItemDeleted();
74 void slotLastScratchPadItemDeleted();
75
76 void handleMousePress(QTreeWidgetItem *item);
77 void deleteScratchpad();
78 void slotListMode();
79 void slotIconMode();
80
81private:
82 WidgetBoxCategoryListView *addCategoryView(QTreeWidgetItem *parent, bool iconMode);
83 WidgetBoxCategoryListView *categoryViewAt(int idx) const;
84 void adjustSubListSize(QTreeWidgetItem *cat_item);
85
86 static bool readCategories(const QString &fileName, const QString &xml, CategoryList *cats, QString *errorMessage);
87 static bool readWidget(Widget *w, const QString &xml, QXmlStreamReader &r);
88
89 CategoryList loadCustomCategoryList() const;
90 void writeCategories(QXmlStreamWriter &writer, const CategoryList &cat_list) const;
91
92 int indexOfCategory(const QString &name) const;
93 int indexOfScratchpad() const;
94 int ensureScratchpad();
95 void addCustomCategories(bool replace);
96
97 void saveExpandedState() const;
98 void restoreExpandedState();
99 void updateViewMode();
100
101 QDesignerFormEditorInterface *m_core;
102 QString m_file_name;
103 mutable QHash<QString, QIcon> m_pluginIcons;
104 bool m_iconMode;
105 QTimer *m_scratchPadDeleteTimer;
106};
107
108} // namespace qdesigner_internal
109
110QT_END_NAMESPACE
111
112#endif // WIDGETBOXTREEWIDGET_H
void mousePressEvent(QMouseEvent *event) override
\reimp
Definition widgetbox.cpp:45
void focusInEvent(QFocusEvent *e) override
\reimp
Definition widgetbox.cpp:52
WidgetBoxFilterLineEdit(QWidget *parent=nullptr)
Definition widgetbox.cpp:34
Widget widget(int cat_idx, int wgt_idx) const
void setFileName(const QString &file_name)
void contextMenuEvent(QContextMenuEvent *e) override
void resizeEvent(QResizeEvent *e) override
QIcon iconForWidget(const QString &iconName) const
WidgetBoxTreeWidget(QDesignerFormEditorInterface *core, QWidget *parent=nullptr)
void addWidget(int cat_idx, const Widget &wgt)
bool load(QDesignerWidgetBox::LoadMode loadMode)
void removeWidget(int cat_idx, int wgt_idx)
void dropWidgets(const QList< QDesignerDnDItemInterface * > &item_list)
QString fileName() const override
Returns the name of the XML file \QD is currently using to populate its widget box.
Widget widget(int cat_idx, int wgt_idx) const override
Category category(int cat_idx) const override
bool load() override
Populates \QD's widget box by loading (or reloading) the currently specified XML file.
void dragEnterEvent(QDragEnterEvent *event) override
void dropWidgets(const QList< QDesignerDnDItemInterface * > &item_list, const QPoint &global_mouse_pos) override
void removeCategory(int cat_idx) override
void dragMoveEvent(QDragMoveEvent *event) override
void addWidget(int cat_idx, const Widget &wgt) override
int categoryCount() const override
bool save() override
Saves the contents of \QD's widget box in the file specified by the fileName() function.
void addCategory(const Category &cat) override
QDesignerFormEditorInterface * core() const
Definition widgetbox.cpp:98
int widgetCount(int cat_idx) const override
void removeWidget(int cat_idx, int wgt_idx) override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static const QDesignerMimeData * checkDragEvent(QDropEvent *event, bool acceptEventsFromWidgetBox)