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
widgetboxcategorylistview.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 WIDGETBOXCATEGORYLISTVIEW_H
5#define WIDGETBOXCATEGORYLISTVIEW_H
6
7#include <QtDesigner/abstractwidgetbox.h>
8
9#include <QtWidgets/qlistview.h>
10#include <QtCore/qlist.h>
11
12QT_BEGIN_NAMESPACE
13
14class QDesignerFormEditorInterface;
15class QDesignerDnDItemInterface;
16
17class QSortFilterProxyModel;
18
19namespace qdesigner_internal {
20
22
23// List view of a category, switchable between icon and list mode.
24// Provides a filtered view.
26{
28public:
29 // Whether to access the filtered or unfiltered view
31
32 explicit WidgetBoxCategoryListView(QDesignerFormEditorInterface *core, QWidget *parent = nullptr);
33 void setViewMode(ViewMode vm);
34
35 void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list);
36
38
39 // These methods operate on the filtered/unfiltered model according to accessmode
40 int count(AccessMode am) const;
41 QDesignerWidgetBoxInterface::Widget widgetAt(AccessMode am, const QModelIndex &index) const;
42 QDesignerWidgetBoxInterface::Widget widgetAt(AccessMode am, int row) const;
43 void removeRow(AccessMode am, int row);
44 void setCurrentItem(AccessMode am, int row);
45
46 // These methods operate on the unfiltered model and are used for serialization
47 void addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable);
48 bool containsWidget(const QString &name);
51
52 // Helper: Ensure a <ui> tag in the case of empty XML
53 static QString widgetDomXml(const QDesignerWidgetBoxInterface::Widget &widget);
54
57 void widgetBoxPressed(const QString &name, const QString &xml, const QPoint &globalPos);
60
61public slots:
63 void removeCurrentItem();
64 void editCurrentItem();
65
66private slots:
67 void slotPressed(const QModelIndex &index);
68
69private:
70 int mapRowToSource(int filterRow) const;
71 QSortFilterProxyModel *m_proxyModel;
73};
74
75} // namespace qdesigner_internal
76
77QT_END_NAMESPACE
78
79#endif // WIDGETBOXCATEGORYLISTVIEW_H
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the widget used to edit the item specified by index for editing.
void widgetBoxPressed(const QString &name, const QString &xml, const QPoint &globalPos)
QDesignerWidgetBoxInterface::Category category() const
static QString widgetDomXml(const QDesignerWidgetBoxInterface::Widget &widget)
QDesignerWidgetBoxInterface::Widget widgetAt(AccessMode am, const QModelIndex &index) const
WidgetBoxCategoryListView(QDesignerFormEditorInterface *core, QWidget *parent=nullptr)
void dropWidgets(const QList< QDesignerDnDItemInterface * > &item_list)
void addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable)
QDesignerWidgetBoxInterface::Widget widgetAt(AccessMode am, int row) const
void addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable)
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.
QDesignerWidgetBoxInterface::Widget widgetAt(const QModelIndex &index) const
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
QDesignerWidgetBoxInterface::Category category() const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
WidgetBoxCategoryModel(QDesignerFormEditorInterface *core, QObject *parent=nullptr)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the role data for the item at index to value.
QDesignerWidgetBoxInterface::Widget widgetAt(int row) const
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &widget, const QString &filter, const QIcon &icon, bool editable)
static QDomDocument stringToDom(const QString &xml)
static QString domToString(const QDomElement &elt)
static constexpr auto uiClosingTagC
static constexpr auto uiOpeningTagC
static constexpr auto widgetElementC
static constexpr auto nameAttributeC