OpenCoverage

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

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