only include Applications by default on OS X
[ambit.git] / src / qsidebar.h
blob87309527daa992e4f85d2b1733efa3a47824e4fe
1 /****************************************************************************
2 **
3 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
4 **
5 ** This file is part of the QtGui module of the Qt Toolkit.
6 **
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 ****************************************************************************/
25 #ifndef QSIDEBAR_H
26 #define QSIDEBAR_H
28 #include <qlistwidget.h>
29 #include <qstandarditemmodel.h>
30 #include <qurl.h>
32 #ifndef QT_NO_FILEDIALOG
34 class QFileSystemModel;
35 class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
37 Q_OBJECT
39 public:
40 enum Roles {
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; }
58 private Q_SLOTS:
59 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
60 void layoutChanged();
62 private:
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
73 Q_OBJECT
75 Q_SIGNALS:
76 void goToUrl(const QUrl &url);
77 void goTo(const QModelIndex &index);
79 public:
80 QSidebar(QFileSystemModel *model, const QList<QUrl> &newUrls, QWidget *parent = 0);
81 ~QSidebar();
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);
91 public slots:
92 void selectIndex(const QModelIndex &index);
94 protected:
95 void focusInEvent(QFocusEvent *event);
96 void dragEnterEvent(QDragEnterEvent *event);
98 private Q_SLOTS:
99 void clicked(const QModelIndex &index);
100 void showContextMenu(const QPoint &position);
101 void removeEntry();
103 private:
104 QUrlModel *urlModel;
107 #endif
109 #endif