Qt 4.8
qsidebar_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
64 
65 class QFileSystemModel;
66 
68 {
69  public:
72  const QModelIndex &index) const;
73 };
74 
76 {
77  Q_OBJECT
78 
79 public:
80  enum Roles {
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);
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);
113 };
114 
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:
151 };
152 
154 
155 #endif // QT_NO_FILEDIALOG
156 
157 #endif // QSIDEBAR_H
158 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QFileSystemModel class provides a data model for the local filesystem.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QList< QUrl > urls() const
Definition: qsidebar_p.h:131
bool showFullPath
Definition: qsidebar_p.h:100
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStandardItemModel class provides a generic model for storing custom data.
#define Q_SLOTS
Definition: qobjectdefs.h:71
QFileSystemModel * fileSystemModel
Definition: qsidebar_p.h:110
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_SIGNALS
Definition: qobjectdefs.h:72
The QStyledItemDelegate class provides display and editing facilities for data items from a model...
QUrlModel * urlModel
Definition: qsidebar_p.h:150
void addUrls(const QList< QUrl > &list, int row)
Definition: qsidebar_p.h:130
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
Initialize option with the values using the index index.
Definition: qsidebar.cpp:58
QList< QUrl > invalidUrls
Definition: qsidebar_p.h:112
static bool init
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Definition: qmime_win.cpp:141
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const char * data(const QByteArray &arr)
DropAction
Definition: qnamespace.h:1597
QList< QPair< QModelIndex, QString > > watching
Definition: qsidebar_p.h:111
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
QSideBarDelegate(QWidget *parent=0)
Definition: qsidebar_p.h:70
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
quint16 index
void setUrls(const QList< QUrl > &list)
Definition: qsidebar_p.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define UrlRole
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the size needed by the delegate to display the item specified by index, taking into account t...
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275