source: trunk/src/gui/dialogs/qsidebar_p.h@ 508

Last change on this file since 508 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 4.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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 <qurl.h>
59
60#ifndef QT_NO_FILEDIALOG
61
62QT_BEGIN_NAMESPACE
63
64class QFileSystemModel;
65class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
66{
67 Q_OBJECT
68
69public:
70 enum Roles {
71 UrlRole = Qt::UserRole + 1
72 };
73
74 QUrlModel(QObject *parent = 0);
75
76 QStringList mimeTypes() const;
77 QMimeData *mimeData(const QModelIndexList &indexes) const;
78#ifndef QT_NO_DRAGANDDROP
79 bool canDrop(QDragEnterEvent *event);
80 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
81#endif
82 Qt::ItemFlags flags(const QModelIndex &index) const;
83 bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole);
84
85 void setUrls(const QList<QUrl> &list);
86 void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
87 QList<QUrl> urls() const;
88 void setFileSystemModel(QFileSystemModel *model);
89 bool showFullPath;
90
91private Q_SLOTS:
92 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
93 void layoutChanged();
94
95private:
96 void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex);
97 void changed(const QString &path);
98 void addIndexToWatch(const QString &path, const QModelIndex &index);
99 QFileSystemModel *fileSystemModel;
100 QList<QPair<QModelIndex, QString> > watching;
101 QList<QUrl> invalidUrls;
102};
103
104class Q_AUTOTEST_EXPORT QSidebar : public QListView
105{
106 Q_OBJECT
107
108Q_SIGNALS:
109 void goToUrl(const QUrl &url);
110
111public:
112 QSidebar(QWidget *parent = 0);
113 void init(QFileSystemModel *model, const QList<QUrl> &newUrls);
114 ~QSidebar();
115
116 QSize sizeHint() const;
117
118 void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
119 void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
120 QList<QUrl> urls() const { return urlModel->urls(); }
121
122 void selectUrl(const QUrl &url);
123
124protected:
125 bool event(QEvent * e);
126 void focusInEvent(QFocusEvent *event);
127#ifndef QT_NO_DRAGANDDROP
128 void dragEnterEvent(QDragEnterEvent *event);
129#endif
130
131private Q_SLOTS:
132 void clicked(const QModelIndex &index);
133#ifndef QT_NO_MENU
134 void showContextMenu(const QPoint &position);
135#endif
136 void removeEntry();
137
138private:
139 QUrlModel *urlModel;
140};
141
142QT_END_NAMESPACE
143
144#endif // QT_NO_FILEDIALOG
145
146#endif // QSIDEBAR_H
147
Note: See TracBrowser for help on using the repository browser.