0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module 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 QSIDEBAR_H
|
|
43 |
#define QSIDEBAR_H
|
|
44 |
|
|
45 |
//
|
|
46 |
// W A R N I N G
|
|
47 |
// -------------
|
|
48 |
//
|
|
49 |
// This file is not part of the Qt API. It exists purely as an
|
|
50 |
// implementation detail. This header file may change from version to
|
|
51 |
// version without notice, or even be removed.
|
|
52 |
//
|
|
53 |
// We mean it.
|
|
54 |
//
|
|
55 |
|
|
56 |
#include <qlistwidget.h>
|
|
57 |
#include <qstandarditemmodel.h>
|
|
58 |
#include <qstyleditemdelegate.h>
|
|
59 |
#include <qurl.h>
|
|
60 |
|
|
61 |
#ifndef QT_NO_FILEDIALOG
|
|
62 |
|
|
63 |
QT_BEGIN_NAMESPACE
|
|
64 |
|
|
65 |
class QFileSystemModel;
|
|
66 |
|
|
67 |
class QSideBarDelegate : public QStyledItemDelegate
|
|
68 |
{
|
|
69 |
public:
|
|
70 |
QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
|
|
71 |
void initStyleOption(QStyleOptionViewItem *option,
|
|
72 |
const QModelIndex &index) const;
|
|
73 |
};
|
|
74 |
|
|
75 |
class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
|
|
76 |
{
|
|
77 |
Q_OBJECT
|
|
78 |
|
|
79 |
public:
|
|
80 |
enum Roles {
|
|
81 |
UrlRole = Qt::UserRole + 1,
|
|
82 |
EnabledRole = Qt::UserRole + 2
|
|
83 |
};
|
|
84 |
|
|
85 |
QUrlModel(QObject *parent = 0);
|
|
86 |
|
|
87 |
QStringList mimeTypes() const;
|
|
88 |
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
|
89 |
#ifndef QT_NO_DRAGANDDROP
|
|
90 |
bool canDrop(QDragEnterEvent *event);
|
|
91 |
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
|
92 |
#endif
|
|
93 |
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
94 |
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole);
|
|
95 |
|
|
96 |
void setUrls(const QList<QUrl> &list);
|
|
97 |
void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
|
|
98 |
QList<QUrl> urls() const;
|
|
99 |
void setFileSystemModel(QFileSystemModel *model);
|
|
100 |
bool showFullPath;
|
|
101 |
|
|
102 |
private Q_SLOTS:
|
|
103 |
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
|
104 |
void layoutChanged();
|
|
105 |
|
|
106 |
private:
|
|
107 |
void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex);
|
|
108 |
void changed(const QString &path);
|
|
109 |
void addIndexToWatch(const QString &path, const QModelIndex &index);
|
|
110 |
QFileSystemModel *fileSystemModel;
|
|
111 |
QList<QPair<QModelIndex, QString> > watching;
|
|
112 |
QList<QUrl> invalidUrls;
|
|
113 |
};
|
|
114 |
|
|
115 |
class Q_AUTOTEST_EXPORT QSidebar : public QListView
|
|
116 |
{
|
|
117 |
Q_OBJECT
|
|
118 |
|
|
119 |
Q_SIGNALS:
|
|
120 |
void goToUrl(const QUrl &url);
|
|
121 |
|
|
122 |
public:
|
|
123 |
QSidebar(QWidget *parent = 0);
|
|
124 |
void init(QFileSystemModel *model, const QList<QUrl> &newUrls);
|
|
125 |
~QSidebar();
|
|
126 |
|
|
127 |
QSize sizeHint() const;
|
|
128 |
|
|
129 |
void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
|
|
130 |
void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
|
|
131 |
QList<QUrl> urls() const { return urlModel->urls(); }
|
|
132 |
|
|
133 |
void selectUrl(const QUrl &url);
|
|
134 |
|
|
135 |
protected:
|
|
136 |
bool event(QEvent * e);
|
|
137 |
void focusInEvent(QFocusEvent *event);
|
|
138 |
#ifndef QT_NO_DRAGANDDROP
|
|
139 |
void dragEnterEvent(QDragEnterEvent *event);
|
|
140 |
#endif
|
|
141 |
|
|
142 |
private Q_SLOTS:
|
|
143 |
void clicked(const QModelIndex &index);
|
|
144 |
#ifndef QT_NO_MENU
|
|
145 |
void showContextMenu(const QPoint &position);
|
|
146 |
#endif
|
|
147 |
void removeEntry();
|
|
148 |
|
|
149 |
private:
|
|
150 |
QUrlModel *urlModel;
|
|
151 |
};
|
|
152 |
|
|
153 |
QT_END_NAMESPACE
|
|
154 |
|
|
155 |
#endif // QT_NO_FILEDIALOG
|
|
156 |
|
|
157 |
#endif // QSIDEBAR_H
|
|
158 |
|