qsidebar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qsidebar.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qsidebar_p.h"-
35#include "qfilesystemmodel.h"-
36-
37#ifndef QT_NO_FILEDIALOG-
38-
39#include <qaction.h>-
40#include <qurl.h>-
41#include <qmenu.h>-
42#include <qmimedata.h>-
43#include <qevent.h>-
44#include <qdebug.h>-
45#include <qfileiconprovider.h>-
46#include <qfiledialog.h>-
47-
48QT_BEGIN_NAMESPACE-
49-
50void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option,-
51 const QModelIndex &index) const-
52{-
53 QStyledItemDelegate::initStyleOption(option,index);-
54 QVariant value = index.data(QUrlModel::EnabledRole);-
55 if (value.isValid()) {
value.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
56 //If the bookmark/entry is not enabled then we paint it in gray-
57 if (!qvariant_cast<bool>(value))
!qvariant_cast<bool>(value)Description
TRUEnever evaluated
FALSEnever evaluated
0
58 option->state &= ~QStyle::State_Enabled;
never executed: option->state &= ~QStyle::State_Enabled;
0
59 }
never executed: end of block
0
60}
never executed: end of block
0
61-
62/*!-
63 \internal-
64 \class QUrlModel-
65 QUrlModel lets you have indexes from a QFileSystemModel to a list. When QFileSystemModel-
66 changes them QUrlModel will automatically update.-
67-
68 Example usage: File dialog sidebar and combo box-
69 */-
70QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(0)-
71{-
72}
never executed: end of block
0
73-
74/*!-
75 \reimp-
76*/-
77QStringList QUrlModel::mimeTypes() const-
78{-
79 return QStringList(QLatin1String("text/uri-list"));
never executed: return QStringList(QLatin1String("text/uri-list"));
0
80}-
81-
82/*!-
83 \reimp-
84*/-
85Qt::ItemFlags QUrlModel::flags(const QModelIndex &index) const-
86{-
87 Qt::ItemFlags flags = QStandardItemModel::flags(index);-
88 if (index.isValid()) {
index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
89 flags &= ~Qt::ItemIsEditable;-
90 // ### some future version could support "moving" urls onto a folder-
91 flags &= ~Qt::ItemIsDropEnabled;-
92 }
never executed: end of block
0
93-
94 if (index.data(Qt::DecorationRole).isNull())
index.data(Qt:...Role).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
95 flags &= ~Qt::ItemIsEnabled;
never executed: flags &= ~Qt::ItemIsEnabled;
0
96-
97 return flags;
never executed: return flags;
0
98}-
99-
100/*!-
101 \reimp-
102*/-
103QMimeData *QUrlModel::mimeData(const QModelIndexList &indexes) const-
104{-
105 QList<QUrl> list;-
106 for (int i = 0; i < indexes.count(); ++i) {
i < indexes.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
107 if (indexes.at(i).column() == 0)
indexes.at(i).column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
108 list.append(indexes.at(i).data(UrlRole).toUrl());
never executed: list.append(indexes.at(i).data(UrlRole).toUrl());
0
109 }
never executed: end of block
0
110 QMimeData *data = new QMimeData();-
111 data->setUrls(list);-
112 return data;
never executed: return data;
0
113}-
114-
115#ifndef QT_NO_DRAGANDDROP-
116-
117/*!-
118 Decide based upon the data if it should be accepted or not-
119-
120 We only accept dirs and not files-
121*/-
122bool QUrlModel::canDrop(QDragEnterEvent *event)-
123{-
124 if (!event->mimeData()->formats().contains(mimeTypes().first()))
!event->mimeDa...pes().first())Description
TRUEnever evaluated
FALSEnever evaluated
0
125 return false;
never executed: return false;
0
126-
127 const QList<QUrl> list = event->mimeData()->urls();-
128 for (int i = 0; i < list.count(); ++i) {
i < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
129 QModelIndex idx = fileSystemModel->index(list.at(0).toLocalFile());-
130 if (!fileSystemModel->isDir(idx))
!fileSystemModel->isDir(idx)Description
TRUEnever evaluated
FALSEnever evaluated
0
131 return false;
never executed: return false;
0
132 }
never executed: end of block
0
133 return true;
never executed: return true;
0
134}-
135-
136/*!-
137 \reimp-
138*/-
139bool QUrlModel::dropMimeData(const QMimeData *data, Qt::DropAction action,-
140 int row, int column, const QModelIndex &parent)-
141{-
142 if (!data->formats().contains(mimeTypes().first()))
!data->formats...pes().first())Description
TRUEnever evaluated
FALSEnever evaluated
0
143 return false;
never executed: return false;
0
144 Q_UNUSED(action);-
145 Q_UNUSED(column);-
146 Q_UNUSED(parent);-
147 addUrls(data->urls(), row);-
148 return true;
never executed: return true;
0
149}-
150-
151#endif // QT_NO_DRAGANDDROP-
152-
153/*!-
154 \reimp-
155-
156 If the role is the UrlRole then handle otherwise just pass to QStandardItemModel-
157*/-
158bool QUrlModel::setData(const QModelIndex &index, const QVariant &value, int role)-
159{-
160 if (value.type() == QVariant::Url) {
value.type() == QVariant::UrlDescription
TRUEnever evaluated
FALSEnever evaluated
0
161 QUrl url = value.toUrl();-
162 QModelIndex dirIndex = fileSystemModel->index(url.toLocalFile());-
163 //On windows the popup display the "C:\", convert to nativeSeparators-
164 if (showFullPath)
showFullPathDescription
TRUEnever evaluated
FALSEnever evaluated
0
165 QStandardItemModel::setData(index, QDir::toNativeSeparators(fileSystemModel->data(dirIndex, QFileSystemModel::FilePathRole).toString()));
never executed: QStandardItemModel::setData(index, QDir::toNativeSeparators(fileSystemModel->data(dirIndex, QFileSystemModel::FilePathRole).toString()));
0
166 else {-
167 QStandardItemModel::setData(index, QDir::toNativeSeparators(fileSystemModel->data(dirIndex, QFileSystemModel::FilePathRole).toString()), Qt::ToolTipRole);-
168 QStandardItemModel::setData(index, fileSystemModel->data(dirIndex).toString());-
169 }
never executed: end of block
0
170 QStandardItemModel::setData(index, fileSystemModel->data(dirIndex, Qt::DecorationRole),-
171 Qt::DecorationRole);-
172 QStandardItemModel::setData(index, url, UrlRole);-
173 return true;
never executed: return true;
0
174 }-
175 return QStandardItemModel::setData(index, value, role);
never executed: return QStandardItemModel::setData(index, value, role);
0
176}-
177-
178void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex)-
179{-
180 setData(index, url, UrlRole);-
181 if (url.path().isEmpty()) {
url.path().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
182 setData(index, fileSystemModel->myComputer());-
183 setData(index, fileSystemModel->myComputer(Qt::DecorationRole), Qt::DecorationRole);-
184 } else {
never executed: end of block
0
185 QString newName;-
186 if (showFullPath) {
showFullPathDescription
TRUEnever evaluated
FALSEnever evaluated
0
187 //On windows the popup display the "C:\", convert to nativeSeparators-
188 newName = QDir::toNativeSeparators(dirIndex.data(QFileSystemModel::FilePathRole).toString());-
189 } else {
never executed: end of block
0
190 newName = dirIndex.data().toString();-
191 }
never executed: end of block
0
192-
193 QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole));-
194 if (!dirIndex.isValid()) {
!dirIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
195 const QFileIconProvider *provider = fileSystemModel->iconProvider();-
196 if (provider)
providerDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 newIcon = provider->icon(QFileIconProvider::Folder);
never executed: newIcon = provider->icon(QFileIconProvider::Folder);
0
198 newName = QFileInfo(url.toLocalFile()).fileName();-
199 if (!invalidUrls.contains(url))
!invalidUrls.contains(url)Description
TRUEnever evaluated
FALSEnever evaluated
0
200 invalidUrls.append(url);
never executed: invalidUrls.append(url);
0
201 //The bookmark is invalid then we set to false the EnabledRole-
202 setData(index, false, EnabledRole);-
203 } else {
never executed: end of block
0
204 //The bookmark is valid then we set to true the EnabledRole-
205 setData(index, true, EnabledRole);-
206 }
never executed: end of block
0
207-
208 // Make sure that we have at least 32x32 images-
209 const QSize size = newIcon.actualSize(QSize(32,32));-
210 if (size.width() < 32) {
size.width() < 32Description
TRUEnever evaluated
FALSEnever evaluated
0
211 QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32));-
212 newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation));-
213 }
never executed: end of block
0
214-
215 if (index.data().toString() != newName)
index.data().t...g() != newNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 setData(index, newName);
never executed: setData(index, newName);
0
217 QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));-
218 if (oldIcon.cacheKey() != newIcon.cacheKey())
oldIcon.cacheK...con.cacheKey()Description
TRUEnever evaluated
FALSEnever evaluated
0
219 setData(index, newIcon, Qt::DecorationRole);
never executed: setData(index, newIcon, Qt::DecorationRole);
0
220 }
never executed: end of block
0
221}-
222-
223void QUrlModel::setUrls(const QList<QUrl> &list)-
224{-
225 removeRows(0, rowCount());-
226 invalidUrls.clear();-
227 watching.clear();-
228 addUrls(list, 0);-
229}
never executed: end of block
0
230-
231/*!-
232 Add urls \a list into the list at \a row. If move then movie-
233 existing ones to row.-
234-
235 \sa dropMimeData()-
236*/-
237void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)-
238{-
239 if (row == -1)
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
240 row = rowCount();
never executed: row = rowCount();
0
241 row = qMin(row, rowCount());-
242 for (int i = list.count() - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
243 QUrl url = list.at(i);-
244 if (!url.isValid() || url.scheme() != QLatin1String("file"))
!url.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
url.scheme() !...String("file")Description
TRUEnever evaluated
FALSEnever evaluated
0
245 continue;
never executed: continue;
0
246 //this makes sure the url is clean-
247 const QString cleanUrl = QDir::cleanPath(url.toLocalFile());-
248 if (!cleanUrl.isEmpty())
!cleanUrl.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
249 url = QUrl::fromLocalFile(cleanUrl);
never executed: url = QUrl::fromLocalFile(cleanUrl);
0
250-
251 for (int j = 0; move && j < rowCount(); ++j) {
moveDescription
TRUEnever evaluated
FALSEnever evaluated
j < rowCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
252 QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();-
253#if defined(Q_OS_WIN)-
254 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;-
255#else-
256 const Qt::CaseSensitivity cs = Qt::CaseSensitive;-
257#endif-
258 if (!cleanUrl.compare(local, cs)) {
!cleanUrl.compare(local, cs)Description
TRUEnever evaluated
FALSEnever evaluated
0
259 removeRow(j);-
260 if (j <= row)
j <= rowDescription
TRUEnever evaluated
FALSEnever evaluated
0
261 row--;
never executed: row--;
0
262 break;
never executed: break;
0
263 }-
264 }
never executed: end of block
0
265 row = qMax(row, 0);-
266 QModelIndex idx = fileSystemModel->index(cleanUrl);-
267 if (!fileSystemModel->isDir(idx))
!fileSystemModel->isDir(idx)Description
TRUEnever evaluated
FALSEnever evaluated
0
268 continue;
never executed: continue;
0
269 insertRows(row, 1);-
270 setUrl(index(row, 0), url, idx);-
271 watching.append(qMakePair(idx, cleanUrl));-
272 }
never executed: end of block
0
273}
never executed: end of block
0
274-
275/*!-
276 Return the complete list of urls in a QList.-
277*/-
278QList<QUrl> QUrlModel::urls() const-
279{-
280 QList<QUrl> list;-
281 const int numRows = rowCount();-
282 list.reserve(numRows);-
283 for (int i = 0; i < numRows; ++i)
i < numRowsDescription
TRUEnever evaluated
FALSEnever evaluated
0
284 list.append(data(index(i, 0), UrlRole).toUrl());
never executed: list.append(data(index(i, 0), UrlRole).toUrl());
0
285 return list;
never executed: return list;
0
286}-
287-
288/*!-
289 QFileSystemModel to get index's from, clears existing rows-
290*/-
291void QUrlModel::setFileSystemModel(QFileSystemModel *model)-
292{-
293 if (model == fileSystemModel)
model == fileSystemModelDescription
TRUEnever evaluated
FALSEnever evaluated
0
294 return;
never executed: return;
0
295 if (fileSystemModel != 0) {
fileSystemModel != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
296 disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),-
297 this, SLOT(dataChanged(QModelIndex,QModelIndex)));-
298 disconnect(model, SIGNAL(layoutChanged()),-
299 this, SLOT(layoutChanged()));-
300 disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),-
301 this, SLOT(layoutChanged()));-
302 }
never executed: end of block
0
303 fileSystemModel = model;-
304 if (fileSystemModel != 0) {
fileSystemModel != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
305 connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),-
306 this, SLOT(dataChanged(QModelIndex,QModelIndex)));-
307 connect(model, SIGNAL(layoutChanged()),-
308 this, SLOT(layoutChanged()));-
309 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),-
310 this, SLOT(layoutChanged()));-
311 }
never executed: end of block
0
312 clear();-
313 insertColumns(0, 1);-
314}
never executed: end of block
0
315-
316/*-
317 If one of the index's we are watching has changed update our internal data-
318*/-
319void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)-
320{-
321 QModelIndex parent = topLeft.parent();-
322 for (int i = 0; i < watching.count(); ++i) {
i < watching.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
323 QModelIndex index = watching.at(i).first;-
324 if (index.model() && topLeft.model()) {
index.model()Description
TRUEnever evaluated
FALSEnever evaluated
topLeft.model()Description
TRUEnever evaluated
FALSEnever evaluated
0
325 Q_ASSERT(index.model() == topLeft.model());-
326 }
never executed: end of block
0
327 if ( index.row() >= topLeft.row()
index.row() >= topLeft.row()Description
TRUEnever evaluated
FALSEnever evaluated
0
328 && index.row() <= bottomRight.row()
index.row() <=...tomRight.row()Description
TRUEnever evaluated
FALSEnever evaluated
0
329 && index.column() >= topLeft.column()
index.column()...pLeft.column()Description
TRUEnever evaluated
FALSEnever evaluated
0
330 && index.column() <= bottomRight.column()
index.column()...Right.column()Description
TRUEnever evaluated
FALSEnever evaluated
0
331 && index.parent() == parent) {
index.parent() == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
332 changed(watching.at(i).second);-
333 }
never executed: end of block
0
334 }
never executed: end of block
0
335}
never executed: end of block
0
336-
337/*!-
338 Re-get all of our data, anything could have changed!-
339 */-
340void QUrlModel::layoutChanged()-
341{-
342 QStringList paths;-
343 const int numPaths = watching.count();-
344 paths.reserve(numPaths);-
345 for (int i = 0; i < numPaths; ++i)
i < numPathsDescription
TRUEnever evaluated
FALSEnever evaluated
0
346 paths.append(watching.at(i).second);
never executed: paths.append(watching.at(i).second);
0
347 watching.clear();-
348 for (int i = 0; i < numPaths; ++i) {
i < numPathsDescription
TRUEnever evaluated
FALSEnever evaluated
0
349 QString path = paths.at(i);-
350 QModelIndex newIndex = fileSystemModel->index(path);-
351 watching.append(QPair<QModelIndex, QString>(newIndex, path));-
352 if (newIndex.isValid())
newIndex.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
353 changed(path);
never executed: changed(path);
0
354 }
never executed: end of block
0
355}
never executed: end of block
0
356-
357/*!-
358 The following path changed data update our copy of that data-
359-
360 \sa layoutChanged(), dataChanged()-
361*/-
362void QUrlModel::changed(const QString &path)-
363{-
364 for (int i = 0; i < rowCount(); ++i) {
i < rowCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
365 QModelIndex idx = index(i, 0);-
366 if (idx.data(UrlRole).toUrl().toLocalFile() == path) {
idx.data(UrlRo...File() == pathDescription
TRUEnever evaluated
FALSEnever evaluated
0
367 setData(idx, idx.data(UrlRole).toUrl());-
368 }
never executed: end of block
0
369 }
never executed: end of block
0
370}
never executed: end of block
0
371-
372QSidebar::QSidebar(QWidget *parent) : QListView(parent)-
373{-
374}
never executed: end of block
0
375-
376void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls)-
377{-
378 // ### TODO make icon size dynamic-
379 setIconSize(QSize(24,24));-
380 setUniformItemSizes(true);-
381 urlModel = new QUrlModel(this);-
382 urlModel->setFileSystemModel(model);-
383 setModel(urlModel);-
384 setItemDelegate(new QSideBarDelegate(this));-
385-
386 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),-
387 this, SLOT(clicked(QModelIndex)));-
388#ifndef QT_NO_DRAGANDDROP-
389 setDragDropMode(QAbstractItemView::DragDrop);-
390#endif-
391 setContextMenuPolicy(Qt::CustomContextMenu);-
392 connect(this, SIGNAL(customContextMenuRequested(QPoint)),-
393 this, SLOT(showContextMenu(QPoint)));-
394 urlModel->setUrls(newUrls);-
395 setCurrentIndex(this->model()->index(0,0));-
396}
never executed: end of block
0
397-
398QSidebar::~QSidebar()-
399{-
400}-
401-
402#ifndef QT_NO_DRAGANDDROP-
403void QSidebar::dragEnterEvent(QDragEnterEvent *event)-
404{-
405 if (urlModel->canDrop(event))
urlModel->canDrop(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
406 QListView::dragEnterEvent(event);
never executed: QListView::dragEnterEvent(event);
0
407}
never executed: end of block
0
408#endif // QT_NO_DRAGANDDROP-
409-
410QSize QSidebar::sizeHint() const-
411{-
412 if (model())
model()Description
TRUEnever evaluated
FALSEnever evaluated
0
413 return QListView::sizeHintForIndex(model()->index(0, 0)) + QSize(2 * frameWidth(), 2 * frameWidth());
never executed: return QListView::sizeHintForIndex(model()->index(0, 0)) + QSize(2 * frameWidth(), 2 * frameWidth());
0
414 return QListView::sizeHint();
never executed: return QListView::sizeHint();
0
415}-
416-
417void QSidebar::selectUrl(const QUrl &url)-
418{-
419 disconnect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),-
420 this, SLOT(clicked(QModelIndex)));-
421-
422 selectionModel()->clear();-
423 for (int i = 0; i < model()->rowCount(); ++i) {
i < model()->rowCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
424 if (model()->index(i, 0).data(QUrlModel::UrlRole).toUrl() == url) {
model()->index...toUrl() == urlDescription
TRUEnever evaluated
FALSEnever evaluated
0
425 selectionModel()->select(model()->index(i, 0), QItemSelectionModel::Select);-
426 break;
never executed: break;
0
427 }-
428 }
never executed: end of block
0
429-
430 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),-
431 this, SLOT(clicked(QModelIndex)));-
432}
never executed: end of block
0
433-
434#ifndef QT_NO_MENU-
435/*!-
436 \internal-
437-
438 \sa removeEntry()-
439*/-
440void QSidebar::showContextMenu(const QPoint &position)-
441{-
442 QList<QAction *> actions;-
443 if (indexAt(position).isValid()) {
indexAt(position).isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
444 QAction *action = new QAction(QFileDialog::tr("Remove"), this);-
445 if (indexAt(position).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
indexAt(positi...th().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
446 action->setEnabled(false);
never executed: action->setEnabled(false);
0
447 connect(action, SIGNAL(triggered()), this, SLOT(removeEntry()));-
448 actions.append(action);-
449 }
never executed: end of block
0
450 if (actions.count() > 0)
actions.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
451 QMenu::exec(actions, mapToGlobal(position));
never executed: QMenu::exec(actions, mapToGlobal(position));
0
452}
never executed: end of block
0
453#endif // QT_NO_MENU-
454-
455/*!-
456 \internal-
457-
458 \sa showContextMenu()-
459*/-
460void QSidebar::removeEntry()-
461{-
462 QList<QModelIndex> idxs = selectionModel()->selectedIndexes();-
463 QList<QPersistentModelIndex> indexes;-
464 const int numIndexes = idxs.count();-
465 indexes.reserve(numIndexes);-
466 for (int i = 0; i < numIndexes; i++)
i < numIndexesDescription
TRUEnever evaluated
FALSEnever evaluated
0
467 indexes.append(idxs.at(i));
never executed: indexes.append(idxs.at(i));
0
468-
469 for (int i = 0; i < numIndexes; ++i) {
i < numIndexesDescription
TRUEnever evaluated
FALSEnever evaluated
0
470 if (!indexes.at(i).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
!indexes.at(i)...th().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
471 model()->removeRow(indexes.at(i).row());
never executed: model()->removeRow(indexes.at(i).row());
0
472 }
never executed: end of block
0
473}
never executed: end of block
0
474-
475/*!-
476 \internal-
477-
478 \sa goToUrl()-
479*/-
480void QSidebar::clicked(const QModelIndex &index)-
481{-
482 QUrl url = model()->index(index.row(), 0).data(QUrlModel::UrlRole).toUrl();-
483 emit goToUrl(url);-
484 selectUrl(url);-
485}
never executed: end of block
0
486-
487/*!-
488 \reimp-
489 Don't automatically select something-
490 */-
491void QSidebar::focusInEvent(QFocusEvent *event)-
492{-
493 QAbstractScrollArea::focusInEvent(event);-
494 viewport()->update();-
495}
never executed: end of block
0
496-
497/*!-
498 \reimp-
499 */-
500bool QSidebar::event(QEvent * event)-
501{-
502 if (event->type() == QEvent::KeyRelease) {
event->type() ...nt::KeyReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
503 QKeyEvent* ke = (QKeyEvent*) event;-
504 if (ke->key() == Qt::Key_Delete) {
ke->key() == Qt::Key_DeleteDescription
TRUEnever evaluated
FALSEnever evaluated
0
505 removeEntry();-
506 return true;
never executed: return true;
0
507 }-
508 }
never executed: end of block
0
509 return QListView::event(event);
never executed: return QListView::event(event);
0
510}-
511-
512QT_END_NAMESPACE-
513-
514#include "moc_qsidebar_p.cpp"-
515-
516#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9