Qt 4.8
qsidebar.cpp
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 #include "qsidebar_p.h"
43 #include "qfilesystemmodel.h"
44 
45 #ifndef QT_NO_FILEDIALOG
46 
47 #include <qaction.h>
48 #include <qurl.h>
49 #include <qmenu.h>
50 #include <qmimedata.h>
51 #include <qevent.h>
52 #include <qdebug.h>
53 #include <qfileiconprovider.h>
54 #include <qfiledialog.h>
55 
57 
59  const QModelIndex &index) const
60 {
62  QVariant value = index.data(QUrlModel::EnabledRole);
63  if (value.isValid()) {
64  //If the bookmark/entry is not enabled then we paint it in gray
65  if (!qvariant_cast<bool>(value))
66  option->state &= ~QStyle::State_Enabled;
67  }
68 }
69 
76 QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(0)
77 {
78 }
79 
84 {
85  return QStringList(QLatin1String("text/uri-list"));
86 }
87 
91 Qt::ItemFlags QUrlModel::flags(const QModelIndex &index) const
92 {
93  Qt::ItemFlags flags = QStandardItemModel::flags(index);
94  if (index.isValid()) {
95  flags &= ~Qt::ItemIsEditable;
96  // ### some future version could support "moving" urls onto a folder
97  flags &= ~Qt::ItemIsDropEnabled;
98  }
99 
100  if (index.data(Qt::DecorationRole).isNull())
101  flags &= ~Qt::ItemIsEnabled;
102 
103  return flags;
104 }
105 
110 {
111  QList<QUrl> list;
112  for (int i = 0; i < indexes.count(); ++i) {
113  if (indexes.at(i).column() == 0)
114  list.append(indexes.at(i).data(UrlRole).toUrl());
115  }
116  QMimeData *data = new QMimeData();
117  data->setUrls(list);
118  return data;
119 }
120 
121 #ifndef QT_NO_DRAGANDDROP
122 
129 {
130  if (!event->mimeData()->formats().contains(mimeTypes().first()))
131  return false;
132 
133  const QList<QUrl> list = event->mimeData()->urls();
134  for (int i = 0; i < list.count(); ++i) {
135  QModelIndex idx = fileSystemModel->index(list.at(0).toLocalFile());
136  if (!fileSystemModel->isDir(idx))
137  return false;
138  }
139  return true;
140 }
141 
146  int row, int column, const QModelIndex &parent)
147 {
148  if (!data->formats().contains(mimeTypes().first()))
149  return false;
150  Q_UNUSED(action);
151  Q_UNUSED(column);
152  Q_UNUSED(parent);
153  addUrls(data->urls(), row);
154  return true;
155 }
156 
157 #endif // QT_NO_DRAGANDDROP
158 
164 bool QUrlModel::setData(const QModelIndex &index, const QVariant &value, int role)
165 {
166  if (value.type() == QVariant::Url) {
167  QUrl url = value.toUrl();
168  QModelIndex dirIndex = fileSystemModel->index(url.toLocalFile());
169  //On windows the popup display the "C:\", convert to nativeSeparators
170  if (showFullPath)
172  else {
175  }
179  return true;
180  }
181  return QStandardItemModel::setData(index, value, role);
182 }
183 
184 void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex)
185 {
186  setData(index, url, UrlRole);
187  if (url.path().isEmpty()) {
190  } else {
191  QString newName;
192  if (showFullPath) {
193  //On windows the popup display the "C:\", convert to nativeSeparators
195  } else {
196  newName = dirIndex.data().toString();
197  }
198 
199  QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole));
200  if (!dirIndex.isValid()) {
202  newName = QFileInfo(url.toLocalFile()).fileName();
203  if (!invalidUrls.contains(url))
204  invalidUrls.append(url);
205  //The bookmark is invalid then we set to false the EnabledRole
206  setData(index, false, EnabledRole);
207  } else {
208  //The bookmark is valid then we set to true the EnabledRole
209  setData(index, true, EnabledRole);
210  }
211 
212  // Make sure that we have at least 32x32 images
213  const QSize size = newIcon.actualSize(QSize(32,32));
214  if (size.width() < 32) {
215  QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32));
216  newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation));
217  }
218 
219  if (index.data().toString() != newName)
220  setData(index, newName);
221  QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
222  if (oldIcon.cacheKey() != newIcon.cacheKey())
223  setData(index, newIcon, Qt::DecorationRole);
224  }
225 }
226 
228 {
229  removeRows(0, rowCount());
230  invalidUrls.clear();
231  watching.clear();
232  addUrls(list, 0);
233 }
234 
241 void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
242 {
243  if (row == -1)
244  row = rowCount();
245  row = qMin(row, rowCount());
246  for (int i = list.count() - 1; i >= 0; --i) {
247  QUrl url = list.at(i);
248  if (!url.isValid() || url.scheme() != QLatin1String("file"))
249  continue;
250  //this makes sure the url is clean
251  const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
252  url = QUrl::fromLocalFile(cleanUrl);
253 
254  for (int j = 0; move && j < rowCount(); ++j) {
255  QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
256 #if defined(Q_OS_WIN)
257  if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == cleanUrl.toLower()) {
258 #else
259  if (index(j, 0).data(UrlRole).toUrl().toLocalFile() == cleanUrl) {
260 #endif
261  removeRow(j);
262  if (j <= row)
263  row--;
264  break;
265  }
266  }
267  row = qMax(row, 0);
268  QModelIndex idx = fileSystemModel->index(cleanUrl);
269  if (!fileSystemModel->isDir(idx))
270  continue;
271  insertRows(row, 1);
272  setUrl(index(row, 0), url, idx);
273  watching.append(qMakePair(idx, cleanUrl));
274  }
275 }
276 
281 {
282  QList<QUrl> list;
283  for (int i = 0; i < rowCount(); ++i)
284  list.append(data(index(i, 0), UrlRole).toUrl());
285  return list;
286 }
287 
292 {
293  if (model == fileSystemModel)
294  return;
295  if (fileSystemModel != 0) {
298  disconnect(model, SIGNAL(layoutChanged()),
299  this, SLOT(layoutChanged()));
300  disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
301  this, SLOT(layoutChanged()));
302  }
303  fileSystemModel = model;
304  if (fileSystemModel != 0) {
307  connect(model, SIGNAL(layoutChanged()),
308  this, SLOT(layoutChanged()));
309  connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
310  this, SLOT(layoutChanged()));
311  }
312  clear();
313  insertColumns(0, 1);
314 }
315 
316 /*
317  If one of the index's we are watching has changed update our internal data
318 */
319 void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
320 {
321  QModelIndex parent = topLeft.parent();
322  for (int i = 0; i < watching.count(); ++i) {
323  QModelIndex index = watching.at(i).first;
324  if (index.model() && topLeft.model()) {
325  Q_ASSERT(index.model() == topLeft.model());
326  }
327  if ( index.row() >= topLeft.row()
328  && index.row() <= bottomRight.row()
329  && index.column() >= topLeft.column()
330  && index.column() <= bottomRight.column()
331  && index.parent() == parent) {
332  changed(watching.at(i).second);
333  }
334  }
335 }
336 
341 {
342  QStringList paths;
343  for (int i = 0; i < watching.count(); ++i)
344  paths.append(watching.at(i).second);
345  watching.clear();
346  for (int i = 0; i < paths.count(); ++i) {
347  QString path = paths.at(i);
348  QModelIndex newIndex = fileSystemModel->index(path);
350  if (newIndex.isValid())
351  changed(path);
352  }
353 }
354 
360 void QUrlModel::changed(const QString &path)
361 {
362  for (int i = 0; i < rowCount(); ++i) {
363  QModelIndex idx = index(i, 0);
364  if (idx.data(UrlRole).toUrl().toLocalFile() == path) {
365  setData(idx, idx.data(UrlRole).toUrl());
366  }
367  }
368 }
369 
371 {
372 }
373 
375 {
376  // ### TODO make icon size dynamic
377  setIconSize(QSize(24,24));
378  setUniformItemSizes(true);
379  urlModel = new QUrlModel(this);
383 
385  this, SLOT(clicked(QModelIndex)));
386 #ifndef QT_NO_DRAGANDDROP
388 #endif
391  this, SLOT(showContextMenu(QPoint)));
392  urlModel->setUrls(newUrls);
393  setCurrentIndex(this->model()->index(0,0));
394 }
395 
397 {
398 }
399 
400 #ifndef QT_NO_DRAGANDDROP
402 {
403  if (urlModel->canDrop(event))
405 }
406 #endif // QT_NO_DRAGANDDROP
407 
409 {
410  if (model())
411  return QListView::sizeHintForIndex(model()->index(0, 0)) + QSize(2 * frameWidth(), 2 * frameWidth());
412  return QListView::sizeHint();
413 }
414 
415 void QSidebar::selectUrl(const QUrl &url)
416 {
418  this, SLOT(clicked(QModelIndex)));
419 
420  selectionModel()->clear();
421  for (int i = 0; i < model()->rowCount(); ++i) {
422  if (model()->index(i, 0).data(QUrlModel::UrlRole).toUrl() == url) {
424  break;
425  }
426  }
427 
429  this, SLOT(clicked(QModelIndex)));
430 }
431 
432 #ifndef QT_NO_MENU
433 
439 {
441  if (indexAt(position).isValid()) {
442  QAction *action = new QAction(QFileDialog::tr("Remove"), this);
443  if (indexAt(position).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
444  action->setEnabled(false);
445  connect(action, SIGNAL(triggered()), this, SLOT(removeEntry()));
446  actions.append(action);
447  }
448  if (actions.count() > 0)
449  QMenu::exec(actions, mapToGlobal(position));
450 }
451 #endif // QT_NO_MENU
452 
459 {
462  for (int i = 0; i < idxs.count(); i++)
463  indexes.append(idxs.at(i));
464 
465  for (int i = 0; i < indexes.count(); ++i)
466  if (!indexes.at(i).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
467  model()->removeRow(indexes.at(i).row());
468 }
469 
476 {
477  QUrl url = model()->index(index.row(), 0).data(QUrlModel::UrlRole).toUrl();
478  emit goToUrl(url);
479  selectUrl(url);
480 }
481 
487 {
489  viewport()->update();
490 }
491 
496 {
497  if (event->type() == QEvent::KeyRelease) {
498  QKeyEvent* ke = (QKeyEvent*) event;
499  if (ke->key() == Qt::Key_Delete) {
500  removeEntry();
501  return true;
502  }
503  }
504  return QListView::event(event);
505 }
506 
508 
509 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QSize sizeHintForIndex(const QModelIndex &index) const
Returns the size hint for the item with the specified index or an invalid size for invalid indexes...
void removeEntry()
Definition: qsidebar.cpp:458
int row() const
Returns the row this persistent model index refers to.
QMimeData * mimeData(const QModelIndexList &indexes) const
Reimplemented Function
Definition: qsidebar.cpp:109
The QKeyEvent class describes a key event.
Definition: qevent.h:224
The QFileSystemModel class provides a data model for the local filesystem.
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
virtual void clear()
Clears the selection model.
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
Removes the given row from the child items of the parent specified.
QList< QUrl > urls() const
Return the complete list of urls in a QList.
Definition: qsidebar.cpp:280
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QStringList formats() const
Returns a list of formats supported by the object.
Definition: qmimedata.cpp:579
QPixmap scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
Definition: qpixmap.cpp:1642
bool event(QEvent *e)
Reimplemented Function
Definition: qsidebar.cpp:495
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
bool showFullPath
Definition: qsidebar_p.h:100
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
QModelIndexList selectedIndexes() const
Returns a list of all selected model item indexes.
void setIconSize(const QSize &size)
#define SLOT(a)
Definition: qobjectdefs.h:226
bool canDrop(QDragEnterEvent *event)
Decide based upon the data if it should be accepted or not.
Definition: qsidebar.cpp:128
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented Function
Definition: qsidebar.cpp:91
virtual QIcon icon(IconType type) const
Returns an icon set for the given type.
void changed(const QString &path)
The following path changed data update our copy of that data.
Definition: qsidebar.cpp:360
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QStandardItemModel class provides a generic model for storing custom data.
int frameWidth() const
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
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Reimplemented Function
Definition: qsidebar.cpp:164
void customContextMenuRequested(const QPoint &pos)
This signal is emitted when the widget&#39;s contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget.
QFileIconProvider * iconProvider() const
Returns the file icon provider for this directory model.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
Definition: qwidget.cpp:7596
void goToUrl(const QUrl &url)
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
void setUniformItemSizes(bool enable)
Definition: qlistview.cpp:1615
QModelIndex indexAt(const QPoint &p) const
Reimplemented Function
Definition: qlistview.cpp:1112
void setEnabled(bool)
Definition: qaction.cpp:1192
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
QUrlModel * urlModel
Definition: qsidebar_p.h:150
bool event(QEvent *e)
Reimplemented Function
Definition: qlistview.cpp:1693
void currentChanged(const QModelIndex &current, const QModelIndex &previous)
Reimplemented Function
Definition: qlistview.cpp:3242
QStringList mimeTypes() const
Reimplemented Function
Definition: qsidebar.cpp:83
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QWidget * viewport() const
Returns the viewport widget.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int width() const
Returns the width.
Definition: qsize.h:126
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: qsidebar.cpp:319
void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex)
Definition: qsidebar.cpp:184
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
static bool isEmpty(const char *str)
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
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
void showContextMenu(const QPoint &position)
Definition: qsidebar.cpp:438
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Reimplemented Function
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QItemSelectionModel * selectionModel() const
Returns the current selection model.
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented Function
int row() const
Returns the row this model index refers to.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
Definition: qsidebar.cpp:145
void setUrls(const QList< QUrl > &list)
Definition: qsidebar.cpp:227
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
bool isDir(const QModelIndex &index) const
Returns true if the model item index represents a directory; otherwise returns false.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QWidgetData * data
Definition: qwidget.h:815
QSidebar(QWidget *parent=0)
Definition: qsidebar.cpp:370
QUrlModel(QObject *parent=0)
QUrlModel lets you have indexes from a QFileSystemModel to a list.
Definition: qsidebar.cpp:76
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void setUrls(const QList< QUrl > &urls)
Sets the URLs stored in the MIME data object to those specified by urls.
Definition: qmimedata.cpp:334
int rowCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void setDragDropMode(DragDropMode behavior)
void dragEnterEvent(QDragEnterEvent *event)
This event handler is called when a drag is in progress and the mouse enters this widget...
Definition: qsidebar.cpp:401
QVariant myComputer(int role=Qt::DisplayRole) const
Returns the data stored under the given role for the item "My Computer".
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
Definition: qmimedata.cpp:310
DropAction
Definition: qnamespace.h:1597
void clear()
Removes all items from the list.
Definition: qlist.h:764
static QString cleanPath(const QString &path)
Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path...
Definition: qdir.cpp:2082
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
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
Definition: qvariant.cpp:2528
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
void selectUrl(const QUrl &url)
Definition: qsidebar.cpp:415
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition: qicon.cpp:679
void layoutChanged()
Re-get all of our data, anything could have changed!
Definition: qsidebar.cpp:340
void dragEnterEvent(QDragEnterEvent *event)
This function is called with the given event when a drag and drop operation enters the widget...
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void addUrls(const QList< QUrl > &urls, int row=-1, bool move=true)
Add urls list into the list at row.
Definition: qsidebar.cpp:241
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
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
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
The QModelIndex class is used to locate data in a data model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407
void init(QFileSystemModel *model, const QList< QUrl > &newUrls)
Definition: qsidebar.cpp:374
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Reimplemented Function
Definition: qnamespace.h:54
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
void focusInEvent(QFocusEvent *event)
Reimplemented Function Don&#39;t automatically select something
Definition: qsidebar.cpp:486
quint16 index
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
Initialize option with the values using the index index.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for this view and its model to delegate.
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
QAbstractItemModel * model() const
Returns the model that this view is presenting.
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the &#39;/&#39; separators converted to separators that are appropriate for the underly...
Definition: qdir.cpp:812
void clear()
Removes all items (including header items) from the model and sets the number of rows and columns to ...
QSize sizeHint() const
Definition: qsidebar.cpp:408
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok=0)
void rowsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been removed from the model.
QSize sizeHint() const
Reimplemented Function
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QString fileName(const QString &fileUrl)
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
void clicked(const QModelIndex &index)
Definition: qsidebar.cpp:475
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
void setFileSystemModel(QFileSystemModel *model)
QFileSystemModel to get index&#39;s from, clears existing rows.
Definition: qsidebar.cpp:291
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
int column() const
Returns the column this model index refers to.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Reimplemented Function
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60