1 /****************************************************************************
3 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
5 ** This file is part of the QtGui module of the Qt Toolkit.
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 ****************************************************************************/
28 #include <qlistwidget.h>
29 #include <qstandarditemmodel.h>
32 #ifndef QT_NO_FILEDIALOG
34 class QFileSystemModel
;
35 class Q_AUTOTEST_EXPORT QUrlModel
: public QStandardItemModel
41 UrlRole
= Qt::UserRole
+ 1,
44 QUrlModel(QObject
*parent
= 0);
46 QStringList
mimeTypes() const;
47 QMimeData
*mimeData(const QModelIndexList
&indexes
) const;
48 bool canDrop(QDragEnterEvent
*event
);
49 bool dropMimeData(const QMimeData
*data
, Qt::DropAction action
, int row
, int column
, const QModelIndex
&parent
);
50 Qt::ItemFlags
flags(const QModelIndex
&index
) const;
51 bool setData(const QModelIndex
&index
, const QVariant
&value
, int role
=Qt::EditRole
);
53 void setUrls(const QList
<QUrl
> &list
);
54 void addUrls(const QList
<QUrl
> &urls
, int row
= -1, bool move
= true);
55 QList
<QUrl
> urls() const;
56 void setFileSystemModel(QFileSystemModel
*model
);
57 QFileSystemModel
*qFileSystemModel() const { return fileSystemModel
; }
59 void dataChanged(const QModelIndex
&topLeft
, const QModelIndex
&bottomRight
);
63 void setUrl(const QModelIndex
&index
, const QUrl
&url
, const QModelIndex
&dirIndex
);
64 void changed(const QString
&path
);
65 void addIndexToWatch(const QString
&path
, const QModelIndex
&index
);
66 QFileSystemModel
*fileSystemModel
;
67 QList
<QPair
<QModelIndex
, QString
> > watching
;
68 QList
<QUrl
> invalidUrls
;
71 class Q_AUTOTEST_EXPORT QSidebar
: public QListView
76 void goToUrl(const QUrl
&url
);
77 void goTo(const QModelIndex
&index
);
80 QSidebar(QFileSystemModel
*model
, const QList
<QUrl
> &newUrls
, QWidget
*parent
= 0);
83 QSize
sizeHint() const;
85 void setUrls(const QList
<QUrl
> &list
) { urlModel
->setUrls(list
); }
86 void addUrls(const QList
<QUrl
> &list
, int row
) { urlModel
->addUrls(list
, row
); }
87 QList
<QUrl
> urls() const { return urlModel
->urls(); }
89 void selectUrl(const QUrl
&url
);
92 void selectIndex(const QModelIndex
&index
);
95 void focusInEvent(QFocusEvent
*event
);
96 void dragEnterEvent(QDragEnterEvent
*event
);
99 void clicked(const QModelIndex
&index
);
100 void showContextMenu(const QPoint
&position
);