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
4#ifndef WIDGETBOXTREEWIDGET_H
5#define WIDGETBOXTREEWIDGET_H
6
7#include <qdesigner_widgetbox_p.h>
8
9#include <QtWidgets/qtreewidget.h>
10#include <QtGui/qicon.h>
11#include <QtCore/qlist.h>
12#include <QtCore/qhash.h>
13#include <QtCore/qxmlstream.h>
14
16
17class QDesignerFormEditorInterface;
18class QDesignerDnDItemInterface;
19
20class QTimer;
21
22namespace qdesigner_internal {
23
25
26// WidgetBoxTreeWidget: A tree of categories
27
29{
31
32public:
36
37 explicit WidgetBoxTreeWidget(QDesignerFormEditorInterface *core, QWidget *parent = nullptr);
39
40 int categoryCount() const;
41 Category category(int cat_idx) const;
42 void addCategory(const Category &cat);
43 void removeCategory(int cat_idx);
44
45 int widgetCount(int cat_idx) const;
46 Widget widget(int cat_idx, int wgt_idx) const;
47 void addWidget(int cat_idx, const Widget &wgt);
48 void removeWidget(int cat_idx, int wgt_idx);
49
50 void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list);
51
52 void setFileName(const QString &file_name);
53 QString fileName() const;
54 bool load(QDesignerWidgetBox::LoadMode loadMode);
55 bool loadContents(const QString &contents);
56 bool save();
57 QIcon iconForWidget(const QString &iconName) const;
58
62
63public slots:
64 void filter(const QString &);
65
66protected:
67 void contextMenuEvent(QContextMenuEvent *e) override;
68 void resizeEvent(QResizeEvent *e) override;
69
70private slots:
71 void slotSave();
72 void slotScratchPadItemDeleted();
73 void slotLastScratchPadItemDeleted();
74
75 void handleMousePress(QTreeWidgetItem *item);
76 void deleteScratchpad();
77 void slotListMode();
78 void slotIconMode();
79
80private:
81 WidgetBoxCategoryListView *addCategoryView(QTreeWidgetItem *parent, bool iconMode);
82 WidgetBoxCategoryListView *categoryViewAt(int idx) const;
83 void adjustSubListSize(QTreeWidgetItem *cat_item);
84
85 static bool readCategories(const QString &fileName, const QString &xml, CategoryList *cats, QString *errorMessage);
86 static bool readWidget(Widget *w, const QString &xml, QXmlStreamReader &r);
87
88 CategoryList loadCustomCategoryList() const;
89 void writeCategories(QXmlStreamWriter &writer, const CategoryList &cat_list) const;
90
91 int indexOfCategory(const QString &name) const;
92 int indexOfScratchpad() const;
93 int ensureScratchpad();
94 void addCustomCategories(bool replace);
95
96 void saveExpandedState() const;
97 void restoreExpandedState();
98 void updateViewMode();
99
100 QDesignerFormEditorInterface *m_core;
101 QString m_file_name;
102 mutable QHash<QString, QIcon> m_pluginIcons;
103 bool m_iconMode;
104 QTimer *m_scratchPadDeleteTimer;
105};
106
107} // namespace qdesigner_internal
108
109QT_END_NAMESPACE
110
111#endif // WIDGETBOXTREEWIDGET_H
void mousePressEvent(QMouseEvent *event) override
\reimp
Definition widgetbox.cpp:44
void focusInEvent(QFocusEvent *e) override
\reimp
Definition widgetbox.cpp:51
WidgetBoxFilterLineEdit(QWidget *parent=nullptr)
Definition widgetbox.cpp:33
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:97
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)