itemlibrarywidget.h 3.94 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29

30
31
#ifndef ITEMLIBRARYWIDGET_H
#define ITEMLIBRARYWIDGET_H
32

33
#include "itemlibraryinfo.h"
34
35
36
37
#include "itemlibrarycomponents.h"

#include <utils/filterlineedit.h>

38
39
#include <QFrame>
#include <QToolButton>
40
41
42
43
44
45
46
#include <QFileIconProvider>
#include <QDeclarativeView>

QT_BEGIN_NAMESPACE
class QFileSystemModel;
class QStackedWidget;
QT_END_NAMESPACE
47
48
49
50

namespace QmlDesigner {

class MetaInfo;
51
class ItemLibraryEntry;
52
class Model;
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
namespace Internal {
    class ItemLibraryModel;
    class ItemLibraryTreeView;
}

class ItemLibraryFileIconProvider : public QFileIconProvider
{
public:
    ItemLibraryFileIconProvider(const QSize &iconSize);

    QIcon icon( const QFileInfo & info ) const;

private:
    QSize m_iconSize;
};


71
class ItemLibraryWidget : public QFrame
72
73
{
    Q_OBJECT
74

75
76
    enum FilterChangeFlag {
      QtBasic = 0x0,
77
      Meego = 0x1
78
79
    };

80
public:
81
    ItemLibraryWidget(QWidget *parent = 0);
82

83
    void setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo);
84
85
86
    QList<QToolButton *> createToolBarWidgets();

    void updateImports();
87

88
89
    void setImportsWidget(QWidget *importsWidget);

90
public slots:
91
    void setSearchFilter(const QString &searchFilter);
92
    void updateModel();
93
    void updateSearch();
94

95
    void setResourcePath(const QString &resourcePath);
96
97
98
99

    void startDragAndDrop(int itemLibId);
    void showItemInfo(int itemLibId);

100
101
    void setModel(Model *model);

102
103
104
105
106
    void setImportFilter(FilterChangeFlag flag);

    void onQtBasicOnlyChecked(bool b);
    void onMeegoChecked(bool b);

107
108
protected:
    void wheelEvent(QWheelEvent *event);
109
110
    void removeImport(const QString &name);
    void addImport(const QString &name, const QString &version);
111
    void emitImportChecked();
112

113
114
signals:
    void itemActivated(const QString& itemName);
115
    void scrollItemsView(QVariant delta);
116
    void resetItemsView();
117
118
    void qtBasicOnlyChecked(bool b);
    void meegoChecked(bool b);
119

120
121
122
private slots:
    void setCurrentIndexOfStackedWidget(int index);

123
private:
124
125
126
127
128
129
130
131
132
133
    ItemLibraryFileIconProvider m_iconProvider;
    QSize m_itemIconSize;
    QSize m_resIconSize;

    QWeakPointer<ItemLibraryInfo> m_itemLibraryInfo;

    QWeakPointer<Internal::ItemLibraryModel> m_itemLibraryModel;
    QWeakPointer<QFileSystemModel> m_resourcesFileSystemModel;

    QWeakPointer<QStackedWidget> m_stackedWidget;
134
    QWeakPointer<Utils::FilterLineEdit> m_filterLineEdit;
135
136
137
138
    QScopedPointer<QDeclarativeView> m_itemsView;
    QScopedPointer<Internal::ItemLibraryTreeView> m_resourcesView;

    QWeakPointer<Model> m_model;
139
    FilterChangeFlag m_filterFlag;
140
141
142
143
};

}

144
#endif // ITEMLIBRARYWIDGET_H
145