1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef WIDGETBOX_H
30#define WIDGETBOX_H
31
32#include "widgetbox_global.h"
33#include <qdesigner_widgetbox_p.h>
34
35QT_BEGIN_NAMESPACE
36
37class QDesignerFormEditorInterface;
38class QDesignerFormWindowInterface;
39
40namespace qdesigner_internal {
41
42class WidgetBoxTreeWidget;
43
44class QT_WIDGETBOX_EXPORT WidgetBox : public QDesignerWidgetBox
45{
46 Q_OBJECT
47public:
48 explicit WidgetBox(QDesignerFormEditorInterface *core, QWidget *parent = nullptr,
49 Qt::WindowFlags flags = {});
50 ~WidgetBox() override;
51
52 QDesignerFormEditorInterface *core() const;
53
54 int categoryCount() const override;
55 Category category(int cat_idx) const override;
56 void addCategory(const Category &cat) override;
57 void removeCategory(int cat_idx) override;
58
59 int widgetCount(int cat_idx) const override;
60 Widget widget(int cat_idx, int wgt_idx) const override;
61 void addWidget(int cat_idx, const Widget &wgt) override;
62 void removeWidget(int cat_idx, int wgt_idx) override;
63
64 void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, const QPoint &global_mouse_pos) override;
65
66 void setFileName(const QString &file_name) override;
67 QString fileName() const override;
68 bool load() override;
69 bool save() override;
70
71 bool loadContents(const QString &contents) override;
72 QIcon iconForWidget(const QString &className, const QString &category = QString()) const override;
73
74protected:
75 void dragEnterEvent (QDragEnterEvent * event) override;
76 void dragMoveEvent(QDragMoveEvent * event) override;
77 void dropEvent (QDropEvent * event) override;
78
79private slots:
80 void handleMousePress(const QString &name, const QString &xml, const QPoint &global_mouse_pos);
81
82private:
83 QDesignerFormEditorInterface *m_core;
84 WidgetBoxTreeWidget *m_view;
85};
86
87} // namespace qdesigner_internal
88
89QT_END_NAMESPACE
90
91#endif // WIDGETBOX_H
92