author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef WIDGETBOXTREEWIDGET_H |
|
43 |
#define WIDGETBOXTREEWIDGET_H |
|
44 |
||
45 |
#include <qdesigner_widgetbox_p.h> |
|
46 |
||
47 |
#include <QtGui/QTreeWidget> |
|
48 |
#include <QtGui/QIcon> |
|
49 |
#include <QtCore/QList> |
|
50 |
#include <QtCore/QHash> |
|
51 |
#include <QtCore/QXmlStreamReader> // Cannot forward declare them on Mac |
|
52 |
#include <QtCore/QXmlStreamWriter> |
|
53 |
||
54 |
QT_BEGIN_NAMESPACE |
|
55 |
||
56 |
class QDesignerFormEditorInterface; |
|
57 |
class QDesignerDnDItemInterface; |
|
58 |
||
59 |
class QTimer; |
|
60 |
||
61 |
namespace qdesigner_internal { |
|
62 |
||
63 |
class WidgetBoxCategoryListView; |
|
64 |
||
65 |
// WidgetBoxTreeWidget: A tree of categories |
|
66 |
||
67 |
class WidgetBoxTreeWidget : public QTreeWidget |
|
68 |
{ |
|
69 |
Q_OBJECT |
|
70 |
||
71 |
public: |
|
72 |
typedef QDesignerWidgetBoxInterface::Widget Widget; |
|
73 |
typedef QDesignerWidgetBoxInterface::Category Category; |
|
74 |
typedef QDesignerWidgetBoxInterface::CategoryList CategoryList; |
|
75 |
||
76 |
explicit WidgetBoxTreeWidget(QDesignerFormEditorInterface *core, QWidget *parent = 0); |
|
77 |
~WidgetBoxTreeWidget(); |
|
78 |
||
79 |
int categoryCount() const; |
|
80 |
Category category(int cat_idx) const; |
|
81 |
void addCategory(const Category &cat); |
|
82 |
void removeCategory(int cat_idx); |
|
83 |
||
84 |
int widgetCount(int cat_idx) const; |
|
85 |
Widget widget(int cat_idx, int wgt_idx) const; |
|
86 |
void addWidget(int cat_idx, const Widget &wgt); |
|
87 |
void removeWidget(int cat_idx, int wgt_idx); |
|
88 |
||
89 |
void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list); |
|
90 |
||
91 |
void setFileName(const QString &file_name); |
|
92 |
QString fileName() const; |
|
93 |
bool load(QDesignerWidgetBox::LoadMode loadMode); |
|
94 |
bool loadContents(const QString &contents); |
|
95 |
bool save(); |
|
96 |
QIcon iconForWidget(QString iconName) const; |
|
97 |
||
98 |
signals: |
|
99 |
void pressed(const QString name, const QString dom_xml, const QPoint &global_mouse_pos); |
|
100 |
||
101 |
public slots: |
|
102 |
void filter(const QString &); |
|
103 |
||
104 |
protected: |
|
105 |
void contextMenuEvent(QContextMenuEvent *e); |
|
106 |
void resizeEvent(QResizeEvent *e); |
|
107 |
||
108 |
private slots: |
|
109 |
void slotSave(); |
|
110 |
void slotScratchPadItemDeleted(); |
|
111 |
void slotLastScratchPadItemDeleted(); |
|
112 |
||
113 |
void handleMousePress(QTreeWidgetItem *item); |
|
114 |
void deleteScratchpad(); |
|
115 |
void slotListMode(); |
|
116 |
void slotIconMode(); |
|
117 |
||
118 |
private: |
|
119 |
WidgetBoxCategoryListView *addCategoryView(QTreeWidgetItem *parent, bool iconMode); |
|
120 |
WidgetBoxCategoryListView *categoryViewAt(int idx) const; |
|
121 |
void adjustSubListSize(QTreeWidgetItem *cat_item); |
|
122 |
||
123 |
static bool readCategories(const QString &fileName, const QString &xml, CategoryList *cats, QString *errorMessage); |
|
124 |
static bool readWidget(Widget *w, const QString &xml, QXmlStreamReader &r); |
|
125 |
||
126 |
CategoryList loadCustomCategoryList() const; |
|
127 |
void writeCategories(QXmlStreamWriter &writer, const CategoryList &cat_list) const; |
|
128 |
||
129 |
int indexOfCategory(const QString &name) const; |
|
130 |
int indexOfScratchpad() const; |
|
131 |
int ensureScratchpad(); |
|
132 |
void addCustomCategories(bool replace); |
|
133 |
||
134 |
void saveExpandedState() const; |
|
135 |
void restoreExpandedState(); |
|
136 |
void updateViewMode(); |
|
137 |
||
138 |
QDesignerFormEditorInterface *m_core; |
|
139 |
QString m_file_name; |
|
140 |
typedef QHash<QString, QIcon> IconCache; |
|
141 |
mutable IconCache m_pluginIcons; |
|
142 |
bool m_iconMode; |
|
143 |
QTimer *m_scratchPadDeleteTimer; |
|
144 |
}; |
|
145 |
||
146 |
} // namespace qdesigner_internal |
|
147 |
||
148 |
QT_END_NAMESPACE |
|
149 |
||
150 |
#endif // WIDGETBOXTREEWIDGET_H |