dialogs/qfiledialog.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7static QString *lastVisitedDir() { static QGlobalStatic<QString > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QString *x = new QString; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QString > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:960
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:958
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-960
8 -
9 -
10 -
11 -
12 -
13 -
14typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options); -
15__attribute__((visibility("default"))) _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook = 0; -
16 -
17typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); -
18__attribute__((visibility("default"))) _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook = 0; -
19 -
20typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); -
21__attribute__((visibility("default"))) _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook = 0; -
22 -
23typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); -
24__attribute__((visibility("default"))) _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook = 0; -
25 -
26 -
27 -
28 -
29 -
30 -
31 -
32 -
33 -
34 -
35 -
36 -
37 -
38 -
39QFileDialog::QFileDialog(QWidget *parent, Qt::WindowFlags f) -
40 : QDialog(*new QFileDialogPrivate, parent, f) -
41{ -
42 QFileDialogPrivate * const d = d_func(); -
43 d->init(); -
44 d->lineEdit()->selectAll(); -
45}
never executed: }
0
46QFileDialog::QFileDialog(QWidget *parent, -
47 const QString &caption, -
48 const QString &directory, -
49 const QString &filter) -
50 : QDialog(*new QFileDialogPrivate, parent, 0) -
51{ -
52 QFileDialogPrivate * const d = d_func(); -
53 d->init(directory, filter, caption); -
54 d->lineEdit()->selectAll(); -
55}
executed: }
Execution Count:189
189
56 -
57 -
58 -
59 -
60QFileDialog::QFileDialog(const QFileDialogArgs &args) -
61 : QDialog(*new QFileDialogPrivate, args.parent, 0) -
62{ -
63 QFileDialogPrivate * const d = d_func(); -
64 d->init(args.directory, args.filter, args.caption); -
65 setFileMode(args.mode); -
66 setOptions(args.options); -
67 selectFile(args.selection); -
68 d->lineEdit()->selectAll(); -
69}
never executed: }
0
70 -
71 -
72 -
73 -
74QFileDialog::~QFileDialog() -
75{ -
76 -
77 QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); -
78 settings.beginGroup(QLatin1String("Qt")); -
79 settings.setValue(QLatin1String("filedialog"), saveState()); -
80 -
81}
executed: }
Execution Count:189
189
82void QFileDialog::setSidebarUrls(const QList<QUrl> &urls) -
83{ -
84 QFileDialogPrivate * const d = d_func(); -
85 d->qFileDialogUi->sidebar->setUrls(urls); -
86}
never executed: }
0
87 -
88 -
89 -
90 -
91 -
92QList<QUrl> QFileDialog::sidebarUrls() const -
93{ -
94 const QFileDialogPrivate * const d = d_func(); -
95 return d->qFileDialogUi->sidebar->urls();
never executed: return d->qFileDialogUi->sidebar->urls();
0
96} -
97 -
98static const qint32 QFileDialogMagic = 0xbe; -
99QByteArray QFileDialog::saveState() const -
100{ -
101 const QFileDialogPrivate * const d = d_func(); -
102 int version = 3; -
103 QByteArray data; -
104 QDataStream stream(&data, QIODevice::WriteOnly); -
105 -
106 stream << qint32(QFileDialogMagic); -
107 stream << qint32(version); -
108 stream << d->qFileDialogUi->splitter->saveState(); -
109 stream << d->qFileDialogUi->sidebar->urls(); -
110 stream << history(); -
111 stream << *lastVisitedDir(); -
112 stream << d->qFileDialogUi->treeView->header()->saveState(); -
113 stream << qint32(viewMode()); -
114 return data;
executed: return data;
Execution Count:191
191
115} -
116bool QFileDialog::restoreState(const QByteArray &state) -
117{ -
118 QFileDialogPrivate * const d = d_func(); -
119 int version = 3; -
120 QByteArray sd = state; -
121 QDataStream stream(&sd, QIODevice::ReadOnly); -
122 if (stream.atEnd())
evaluated: stream.atEnd()
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:107
84-107
123 return false;
executed: return false;
Execution Count:84
84
124 QByteArray splitterState; -
125 QByteArray headerData; -
126 QList<QUrl> bookmarks; -
127 QStringList history; -
128 QString currentDirectory; -
129 qint32 marker; -
130 qint32 v; -
131 qint32 viewMode; -
132 stream >> marker; -
133 stream >> v; -
134 if (marker != QFileDialogMagic || v != version)
partially evaluated: marker != QFileDialogMagic
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
partially evaluated: v != version
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
135 return false;
never executed: return false;
0
136 -
137 stream >> splitterState -
138 >> bookmarks -
139 >> history -
140 >> currentDirectory -
141 >> headerData -
142 >> viewMode; -
143 -
144 if (!d->qFileDialogUi->splitter->restoreState(splitterState))
partially evaluated: !d->qFileDialogUi->splitter->restoreState(splitterState)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
145 return false;
never executed: return false;
0
146 QList<int> list = d->qFileDialogUi->splitter->sizes(); -
147 if (list.count() >= 2 && list.at(0) == 0 && list.at(1) == 0) {
partially evaluated: list.count() >= 2
TRUEFALSE
yes
Evaluation Count:107
no
Evaluation Count:0
partially evaluated: list.at(0) == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
never evaluated: list.at(1) == 0
0-107
148 for (int i = 0; i < list.count(); ++i)
never evaluated: i < list.count()
0
149 list[i] = d->qFileDialogUi->splitter->widget(i)->sizeHint().width();
never executed: list[i] = d->qFileDialogUi->splitter->widget(i)->sizeHint().width();
0
150 d->qFileDialogUi->splitter->setSizes(list); -
151 }
never executed: }
0
152 -
153 d->qFileDialogUi->sidebar->setUrls(bookmarks); -
154 while (history.count() > 5)
partially evaluated: history.count() > 5
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
155 history.pop_front();
never executed: history.pop_front();
0
156 setHistory(history); -
157 setDirectory(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir()); -
158 QHeaderView *headerView = d->qFileDialogUi->treeView->header(); -
159 if (!headerView->restoreState(headerData))
partially evaluated: !headerView->restoreState(headerData)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
160 return false;
never executed: return false;
0
161 -
162 QList<QAction*> actions = headerView->actions(); -
163 QAbstractItemModel *abstractModel = d->model; -
164 -
165 if (d->proxyModel)
partially evaluated: d->proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
166 abstractModel = d->proxyModel;
never executed: abstractModel = d->proxyModel;
0
167 -
168 int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); -
169 for (int i = 1; i < total; ++i)
evaluated: i < total
TRUEFALSE
yes
Evaluation Count:321
yes
Evaluation Count:107
107-321
170 actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
executed: actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));
Execution Count:321
321
171 -
172 setViewMode(ViewMode(viewMode)); -
173 return true;
executed: return true;
Execution Count:107
107
174} -
175 -
176 -
177 -
178 -
179void QFileDialog::changeEvent(QEvent *e) -
180{ -
181 QFileDialogPrivate * const d = d_func(); -
182 if (e->type() == QEvent::LanguageChange) {
partially evaluated: e->type() == QEvent::LanguageChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:256
0-256
183 d->retranslateWindowTitle(); -
184 d->retranslateStrings(); -
185 }
never executed: }
0
186 QDialog::changeEvent(e); -
187}
executed: }
Execution Count:256
256
188 -
189QFileDialogPrivate::QFileDialogPrivate() -
190 : -
191 -
192 proxyModel(0), -
193 -
194 model(0), -
195 currentHistoryLocation(-1), -
196 renameAction(0), -
197 deleteAction(0), -
198 showHiddenAction(0), -
199 useDefaultCaption(true), -
200 defaultFileTypes(true), -
201 qFileDialogUi(0), -
202 options(new QFileDialogOptions) -
203{ -
204}
executed: }
Execution Count:189
189
205 -
206QFileDialogPrivate::~QFileDialogPrivate() -
207{ -
208} -
209 -
210void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h) -
211{ -
212 QFileDialog *d = q_func(); -
213 QObject::connect(h, "2""fileSelected(QString)", d, "2""fileSelected(QString)"); -
214 QObject::connect(h, "2""filesSelected(QStringList)", d, "2""filesSelected(QStringList)"); -
215 QObject::connect(h, "2""currentChanged(QString)", d, "2""currentChanged(QString)"); -
216 QObject::connect(h, "2""directoryEntered(QString)", d, "2""directoryEntered(QString)"); -
217 QObject::connect(h, "2""directoryEntered(QString)", d, "1""_q_nativeEnterDirectory(QString)"); -
218 QObject::connect(h, "2""filterSelected(QString)", d, "2""filterSelected(QString)"); -
219 static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); -
220}
never executed: }
0
221 -
222void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) -
223{ -
224 QFileDialog * const q = q_func(); -
225 options->setWindowTitle(q->windowTitle()); -
226 options->setViewMode(static_cast<QFileDialogOptions::ViewMode>(q->viewMode())); -
227 options->setHistory(q->history()); -
228 options->setSidebarUrls(qFileDialogUi->sidebar->urls()); -
229 const QDir directory = q->directory(); -
230 options->setInitialDirectory(directory.exists() ? -
231 directory.absolutePath() : -
232 QString()); -
233 options->setInitiallySelectedNameFilter(q->selectedNameFilter()); -
234 options->setInitiallySelectedFiles(userSelectedFiles()); -
235}
never executed: }
0
236 -
237void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) -
238{ -
239 if (code == QDialog::Accepted) {
never evaluated: code == QDialog::Accepted
0
240 QFileDialog * const q = q_func(); -
241 q->setViewMode(static_cast<QFileDialog::ViewMode>(options->viewMode())); -
242 q->setSidebarUrls(options->sidebarUrls()); -
243 q->setHistory(options->history()); -
244 }
never executed: }
0
245}
never executed: }
0
246 -
247void QFileDialogPrivate::retranslateWindowTitle() -
248{ -
249 QFileDialog * const q = q_func(); -
250 if (!useDefaultCaption || setWindowTitle != q->windowTitle())
evaluated: !useDefaultCaption
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:348
evaluated: setWindowTitle != q->windowTitle()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:347
1-348
251 return;
executed: return;
Execution Count:81
81
252 if (q->acceptMode() == QFileDialog::AcceptOpen) {
evaluated: q->acceptMode() == QFileDialog::AcceptOpen
TRUEFALSE
yes
Evaluation Count:336
yes
Evaluation Count:11
11-336
253 const QFileDialog::FileMode fileMode = q->fileMode(); -
254 if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory)
evaluated: fileMode == QFileDialog::DirectoryOnly
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:334
evaluated: fileMode == QFileDialog::Directory
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:329
2-334
255 q->setWindowTitle(QFileDialog::tr("Find Directory"));
executed: q->setWindowTitle(QFileDialog::tr("Find Directory"));
Execution Count:7
7
256 else -
257 q->setWindowTitle(QFileDialog::tr("Open"));
executed: q->setWindowTitle(QFileDialog::tr("Open"));
Execution Count:329
329
258 } else -
259 q->setWindowTitle(QFileDialog::tr("Save As"));
executed: q->setWindowTitle(QFileDialog::tr("Save As"));
Execution Count:11
11
260 -
261 setWindowTitle = q->windowTitle(); -
262}
executed: }
Execution Count:347
347
263 -
264void QFileDialogPrivate::setLastVisitedDirectory(const QString &dir) -
265{ -
266 *lastVisitedDir() = dir; -
267}
executed: }
Execution Count:395
395
268 -
269void QFileDialogPrivate::updateFileNameLabel() -
270{ -
271 if (!options->isLabelExplicitlySet(QFileDialogOptions::FileName)) {
partially evaluated: !options->isLabelExplicitlySet(QFileDialogOptions::FileName)
TRUEFALSE
yes
Evaluation Count:400
no
Evaluation Count:0
0-400
272 switch (q_func()->fileMode()) { -
273 case QFileDialog::DirectoryOnly: -
274 case QFileDialog::Directory: -
275 setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:")); -
276 break;
executed: break;
Execution Count:11
11
277 default: -
278 setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("File &name:")); -
279 break;
executed: break;
Execution Count:389
389
280 } -
281 }
executed: }
Execution Count:400
400
282}
executed: }
Execution Count:400
400
283 -
284void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder) -
285{ -
286 QFileDialog * const q = q_func(); -
287 -
288 if (saveAsOnFolder) {
evaluated: saveAsOnFolder
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:762
26-762
289 setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Open")); -
290 } else if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) {
executed: }
Execution Count:26
evaluated: options->isLabelExplicitlySet(QFileDialogOptions::Accept)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:761
1-761
291 setLabelTextControl(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept)); -
292 return;
executed: return;
Execution Count:1
1
293 } else { -
294 switch (q->fileMode()) { -
295 case QFileDialog::DirectoryOnly: -
296 case QFileDialog::Directory: -
297 setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose")); -
298 break;
executed: break;
Execution Count:38
38
299 default: -
300 setLabelTextControl(QFileDialog::Accept, -
301 q->acceptMode() == QFileDialog::AcceptOpen ? -
302 QFileDialog::tr("&Open") : -
303 QFileDialog::tr("&Save")); -
304 break;
executed: break;
Execution Count:723
723
305 } -
306 }
executed: }
Execution Count:761
761
307} -
308 -
309void QFileDialogPrivate::retranslateStrings() -
310{ -
311 QFileDialog * const q = q_func(); -
312 -
313 if (defaultFileTypes)
partially evaluated: defaultFileTypes
TRUEFALSE
yes
Evaluation Count:189
no
Evaluation Count:0
0-189
314 q->setNameFilter(QFileDialog::tr("All Files (*)"));
executed: q->setNameFilter(QFileDialog::tr("All Files (*)"));
Execution Count:189
189
315 -
316 QList<QAction*> actions = qFileDialogUi->treeView->header()->actions(); -
317 QAbstractItemModel *abstractModel = model; -
318 -
319 if (proxyModel)
partially evaluated: proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:189
0-189
320 abstractModel = proxyModel;
never executed: abstractModel = proxyModel;
0
321 -
322 int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); -
323 for (int i = 1; i < total; ++i) {
evaluated: i < total
TRUEFALSE
yes
Evaluation Count:567
yes
Evaluation Count:189
189-567
324 actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); -
325 }
executed: }
Execution Count:567
567
326 -
327 -
328 renameAction->setText(QFileDialog::tr("&Rename")); -
329 deleteAction->setText(QFileDialog::tr("&Delete")); -
330 showHiddenAction->setText(QFileDialog::tr("Show &hidden files")); -
331 newFolderAction->setText(QFileDialog::tr("&New Folder")); -
332 qFileDialogUi->retranslateUi(q); -
333 updateFileNameLabel(); -
334}
executed: }
Execution Count:189
189
335 -
336void QFileDialogPrivate::emitFilesSelected(const QStringList &files) -
337{ -
338 QFileDialog * const q = q_func(); -
339 q->filesSelected(files); -
340 if (files.count() == 1)
partially evaluated: files.count() == 1
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
341 q->fileSelected(files.first());
executed: q->fileSelected(files.first());
Execution Count:6
6
342}
executed: }
Execution Count:6
6
343 -
344bool QFileDialogPrivate::canBeNativeDialog() -
345{ -
346 QFileDialog * const q = q_func(); -
347 if (nativeDialogInUse)
partially evaluated: nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51
0-51
348 return true;
never executed: return true;
0
349 if (q->testAttribute(Qt::WA_DontShowOnScreen))
partially evaluated: q->testAttribute(Qt::WA_DontShowOnScreen)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51
0-51
350 return false;
never executed: return false;
0
351 if (q->options() & QFileDialog::DontUseNativeDialog)
partially evaluated: q->options() & QFileDialog::DontUseNativeDialog
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
352 return false;
executed: return false;
Execution Count:51
51
353 -
354 QLatin1String staticName(QFileDialog::staticMetaObject.className()); -
355 QLatin1String dynamicName(q->metaObject()->className()); -
356 return (staticName == dynamicName);
never executed: return (staticName == dynamicName);
0
357} -
358void QFileDialog::setOption(Option option, bool on) -
359{ -
360 const QFileDialog::Options previousOptions = options(); -
361 if (!(previousOptions & option) != !on)
evaluated: !(previousOptions & option) != !on
TRUEFALSE
yes
Evaluation Count:212
yes
Evaluation Count:213
212-213
362 setOptions(previousOptions ^ option);
executed: setOptions(previousOptions ^ option);
Execution Count:212
212
363}
executed: }
Execution Count:425
425
364bool QFileDialog::testOption(Option option) const -
365{ -
366 const QFileDialogPrivate * const d = d_func(); -
367 return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option));
executed: return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option));
Execution Count:459
459
368} -
369void QFileDialog::setOptions(Options options) -
370{ -
371 QFileDialogPrivate * const d = d_func(); -
372 -
373 Options changed = (options ^ QFileDialog::options()); -
374 if (!changed)
evaluated: !changed
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:212
15-212
375 return;
executed: return;
Execution Count:15
15
376 -
377 d->options->setOptions(QFileDialogOptions::FileDialogOptions(int(options))); -
378 if (changed & DontResolveSymlinks)
evaluated: changed & DontResolveSymlinks
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:210
2-210
379 d->model->setResolveSymlinks(!(options & DontResolveSymlinks));
executed: d->model->setResolveSymlinks(!(options & DontResolveSymlinks));
Execution Count:2
2
380 if (changed & ReadOnly) {
evaluated: changed & ReadOnly
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:209
3-209
381 bool ro = (options & ReadOnly); -
382 d->model->setReadOnly(ro); -
383 d->qFileDialogUi->newFolderButton->setEnabled(!ro); -
384 d->renameAction->setEnabled(!ro); -
385 d->deleteAction->setEnabled(!ro); -
386 }
executed: }
Execution Count:3
3
387 if (changed & HideNameFilterDetails)
evaluated: changed & HideNameFilterDetails
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:203
9-203
388 setNameFilters(d->options->nameFilters());
executed: setNameFilters(d->options->nameFilters());
Execution Count:9
9
389 -
390 if (changed & ShowDirsOnly)
evaluated: changed & ShowDirsOnly
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:205
7-205
391 setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files);
executed: setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files);
Execution Count:7
7
392}
executed: }
Execution Count:212
212
393 -
394QFileDialog::Options QFileDialog::options() const -
395{ -
396 const QFileDialogPrivate * const d = d_func(); -
397 return QFileDialog::Options(int(d->options->options()));
executed: return QFileDialog::Options(int(d->options->options()));
Execution Count:709
709
398} -
399void QFileDialog::open(QObject *receiver, const char *member) -
400{ -
401 QFileDialogPrivate * const d = d_func(); -
402 const char *signal = (fileMode() == ExistingFiles) ? "2""filesSelected(QStringList)"
never evaluated: (fileMode() == ExistingFiles)
0
403 : "2""fileSelected(QString)"; -
404 connect(this, signal, receiver, member); -
405 d->signalToDisconnectOnClose = signal; -
406 d->receiverToDisconnectOnClose = receiver; -
407 d->memberToDisconnectOnClose = member; -
408 -
409 QDialog::open(); -
410}
never executed: }
0
411 -
412 -
413 -
414 -
415 -
416void QFileDialog::setVisible(bool visible) -
417{ -
418 QFileDialogPrivate * const d = d_func(); -
419 if (visible){
evaluated: visible
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:9
9-42
420 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
partially evaluated: testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
never evaluated: !testAttribute(Qt::WA_WState_Hidden)
0-42
421 return;
never executed: return;
0
422 } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
partially evaluated: testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: testAttribute(Qt::WA_WState_Hidden)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
executed: }
Execution Count:42
0-42
423 return;
never executed: return;
0
424 -
425 if (d->canBeNativeDialog()){
partially evaluated: d->canBeNativeDialog()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51
0-51
426 if (d->setNativeDialogVisible(visible)){
never evaluated: d->setNativeDialogVisible(visible)
0
427 -
428 -
429 setAttribute(Qt::WA_DontShowOnScreen); -
430 -
431 -
432 d->completer->setModel(0); -
433 -
434 } else {
never executed: }
0
435 setAttribute(Qt::WA_DontShowOnScreen, false); -
436 -
437 if (d->proxyModel != 0)
never evaluated: d->proxyModel != 0
0
438 d->completer->setModel(d->proxyModel);
never executed: d->completer->setModel(d->proxyModel);
0
439 else -
440 d->completer->setModel(d->model);
never executed: d->completer->setModel(d->model);
0
441 -
442 } -
443 } -
444 -
445 if (!d->nativeDialogInUse)
partially evaluated: !d->nativeDialogInUse
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
446 d->qFileDialogUi->fileNameEdit->setFocus();
executed: d->qFileDialogUi->fileNameEdit->setFocus();
Execution Count:51
51
447 -
448 QDialog::setVisible(visible); -
449}
executed: }
Execution Count:51
51
450 -
451 -
452 -
453 -
454 -
455void QFileDialogPrivate::_q_goToUrl(const QUrl &url) -
456{ -
457 -
458 -
459 QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true); -
460 QModelIndex idx = model->d_func()->index(node); -
461 _q_enterDirectory(idx); -
462}
never executed: }
0
463void QFileDialog::setDirectory(const QString &directory) -
464{ -
465 QFileDialogPrivate * const d = d_func(); -
466 QString newDirectory = directory; -
467 QFileInfo info(directory); -
468 -
469 if (!directory.isEmpty())
evaluated: !directory.isEmpty()
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:1
1-363
470 newDirectory = QDir::cleanPath(directory);
executed: newDirectory = QDir::cleanPath(directory);
Execution Count:363
363
471 -
472 if (!directory.isEmpty() && newDirectory.isEmpty())
evaluated: !directory.isEmpty()
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:1
partially evaluated: newDirectory.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:363
0-363
473 return;
never executed: return;
0
474 -
475 d->setLastVisitedDirectory(newDirectory); -
476 -
477 if (d->nativeDialogInUse){
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:364
0-364
478 d->setDirectory_sys(newDirectory); -
479 return;
never executed: return;
0
480 } -
481 if (d->rootPath() == newDirectory)
evaluated: d->rootPath() == newDirectory
TRUEFALSE
yes
Evaluation Count:128
yes
Evaluation Count:236
128-236
482 return;
executed: return;
Execution Count:128
128
483 QModelIndex root = d->model->setRootPath(newDirectory); -
484 d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); -
485 if (root != d->rootIndex()) {
partially evaluated: root != d->rootIndex()
TRUEFALSE
yes
Evaluation Count:236
no
Evaluation Count:0
0-236
486 -
487 if (directory.endsWith(QLatin1Char('/')))
evaluated: directory.endsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:223
13-223
488 d->completer->setCompletionPrefix(newDirectory);
executed: d->completer->setCompletionPrefix(newDirectory);
Execution Count:13
13
489 else -
490 d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/'));
executed: d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/'));
Execution Count:223
223
491 -
492 d->setRootIndex(root); -
493 }
executed: }
Execution Count:236
236
494 d->qFileDialogUi->listView->selectionModel()->clear(); -
495}
executed: }
Execution Count:236
236
496 -
497 -
498 -
499 -
500QDir QFileDialog::directory() const -
501{ -
502 const QFileDialogPrivate * const d = d_func(); -
503 return QDir(d->nativeDialogInUse ? d->directory_sys() : d->rootPath());
executed: return QDir(d->nativeDialogInUse ? d->directory_sys() : d->rootPath());
Execution Count:748
748
504} -
505 -
506 -
507 -
508 -
509 -
510 -
511void QFileDialog::selectFile(const QString &filename) -
512{ -
513 QFileDialogPrivate * const d = d_func(); -
514 if (filename.isEmpty())
evaluated: filename.isEmpty()
TRUEFALSE
yes
Evaluation Count:182
yes
Evaluation Count:24
24-182
515 return;
executed: return;
Execution Count:182
182
516 -
517 if (d->nativeDialogInUse){
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
518 d->selectFile_sys(filename); -
519 return;
never executed: return;
0
520 } -
521 -
522 if (!QDir::isRelativePath(filename)) {
evaluated: !QDir::isRelativePath(filename)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:14
10-14
523 QFileInfo info(filename); -
524 QString filenamePath = info.absoluteDir().path(); -
525 -
526 if (d->model->rootPath() != filenamePath)
evaluated: d->model->rootPath() != filenamePath
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
527 setDirectory(filenamePath);
executed: setDirectory(filenamePath);
Execution Count:5
5
528 }
executed: }
Execution Count:10
10
529 -
530 QModelIndex index = d->model->index(filename); -
531 QString file; -
532 if (!index.isValid()) {
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:9
9-15
533 -
534 QString text = filename; -
535 if (QFileInfo(filename).isAbsolute()) {
evaluated: QFileInfo(filename).isAbsolute()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
1-14
536 QString current = d->rootPath(); -
537 text.remove(current); -
538 if (text.at(0) == QDir::separator()
partially evaluated: text.at(0) == QDir::separator()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
539 -
540 -
541 -
542 -
543 ) -
544 text = text.remove(0,1);
executed: text = text.remove(0,1);
Execution Count:1
1
545 }
executed: }
Execution Count:1
1
546 file = text; -
547 } else {
executed: }
Execution Count:15
15
548 file = index.data().toString(); -
549 }
executed: }
Execution Count:9
9
550 d->qFileDialogUi->listView->selectionModel()->clear(); -
551 if (!isVisible() || !d->lineEdit()->hasFocus())
evaluated: !isVisible()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:6
partially evaluated: !d->lineEdit()->hasFocus()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-18
552 d->lineEdit()->setText(file);
executed: d->lineEdit()->setText(file);
Execution Count:24
24
553}
executed: }
Execution Count:24
24
554 -
555 -
556 QString qt_tildeExpansion(const QString &path, bool *expanded = 0) -
557{ -
558 if (expanded != 0)
evaluated: expanded != 0
TRUEFALSE
yes
Evaluation Count:368
yes
Evaluation Count:77
77-368
559 *expanded = false;
executed: *expanded = false;
Execution Count:368
368
560 if (!path.startsWith(QLatin1Char('~')))
partially evaluated: !path.startsWith(QLatin1Char('~'))
TRUEFALSE
yes
Evaluation Count:445
no
Evaluation Count:0
0-445
561 return path;
executed: return path;
Execution Count:445
445
562 QString ret = path; -
563 QStringList tokens = ret.split(QDir::separator()); -
564 if (tokens.first() == QLatin1String("~")) {
never evaluated: tokens.first() == QLatin1String("~")
0
565 ret.replace(0, 1, QDir::homePath()); -
566 } else {
never executed: }
0
567 QString userName = tokens.first(); -
568 userName.remove(0, 1); -
569 -
570 passwd pw; -
571 passwd *tmpPw; -
572 char buf[200]; -
573 const int bufSize = sizeof(buf); -
574 int err = 0; -
575 -
576 -
577 -
578 err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); -
579 -
580 if (err || !tmpPw)
never evaluated: err
never evaluated: !tmpPw
0
581 return ret;
never executed: return ret;
0
582 const QString homePath = QString::fromLocal8Bit(pw.pw_dir); -
583 -
584 -
585 -
586 -
587 -
588 -
589 ret.replace(0, tokens.first().length(), homePath); -
590 }
never executed: }
0
591 if (expanded != 0)
never evaluated: expanded != 0
0
592 *expanded = true;
never executed: *expanded = true;
0
593 return ret;
never executed: return ret;
0
594} -
595 -
596 -
597 -
598 -
599 -
600QStringList QFileDialogPrivate::typedFiles() const -
601{ -
602 const QFileDialog * const q = q_func(); -
603 QStringList files; -
604 QString editText = lineEdit()->text(); -
605 if (!editText.contains(QLatin1Char('"'))) {
evaluated: !editText.contains(QLatin1Char('"'))
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:7
7-170
606 -
607 const QString prefix = q->directory().absolutePath() + QDir::separator(); -
608 if (QFile::exists(prefix + editText))
evaluated: QFile::exists(prefix + editText)
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:68
68-102
609 files << editText;
executed: files << editText;
Execution Count:102
102
610 else -
611 files << qt_tildeExpansion(editText);
executed: files << qt_tildeExpansion(editText);
Execution Count:68
68
612 -
613 -
614 -
615 -
616 } else { -
617 -
618 -
619 QStringList tokens = editText.split(QLatin1Char('\"')); -
620 for (int i=0; i<tokens.size(); ++i) {
evaluated: i<tokens.size()
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:7
7-53
621 if ((i % 2) == 0)
evaluated: (i % 2) == 0
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:23
23-30
622 continue;
executed: continue;
Execution Count:30
30
623 -
624 const QString token = tokens.at(i); -
625 const QString prefix = q->directory().absolutePath() + QDir::separator(); -
626 if (QFile::exists(prefix + token))
evaluated: QFile::exists(prefix + token)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:9
9-14
627 files << token;
executed: files << token;
Execution Count:14
14
628 else -
629 files << qt_tildeExpansion(token);
executed: files << qt_tildeExpansion(token);
Execution Count:9
9
630 -
631 -
632 -
633 } -
634 }
executed: }
Execution Count:7
7
635 return addDefaultSuffixToFiles(files);
executed: return addDefaultSuffixToFiles(files);
Execution Count:177
177
636} -
637 -
638 -
639 -
640 -
641QStringList QFileDialogPrivate::userSelectedFiles() const -
642{ -
643 if (nativeDialogInUse)
partially evaluated: nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:599
0-599
644 return addDefaultSuffixToFiles(selectedFiles_sys());
never executed: return addDefaultSuffixToFiles(selectedFiles_sys());
0
645 -
646 QStringList files; -
647 for (QForeachContainer<__typeof__(qFileDialogUi->listView->selectionModel()->selectedRows())> _container_(qFileDialogUi->listView->selectionModel()->selectedRows()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QModelIndex &index = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
648 files.append(index.data(QFileSystemModel::FilePathRole).toString());
executed: files.append(index.data(QFileSystemModel::FilePathRole).toString());
Execution Count:104
104
649 -
650 if (files.isEmpty() && !lineEdit()->text().isEmpty())
evaluated: files.isEmpty()
TRUEFALSE
yes
Evaluation Count:516
yes
Evaluation Count:83
evaluated: !lineEdit()->text().isEmpty()
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:423
83-516
651 files = typedFiles();
executed: files = typedFiles();
Execution Count:93
93
652 -
653 return files;
executed: return files;
Execution Count:599
599
654} -
655 -
656QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList filesToFix) const -
657{ -
658 QStringList files; -
659 for (int i=0; i<filesToFix.size(); ++i) {
evaluated: i<filesToFix.size()
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:177
177-193
660 QString name = toInternal(filesToFix.at(i)); -
661 QFileInfo info(name); -
662 -
663 const QString defaultSuffix = options->defaultSuffix(); -
664 if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1)
partially evaluated: !defaultSuffix.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:193
never evaluated: !info.isDir()
never evaluated: name.lastIndexOf(QLatin1Char('.')) == -1
0-193
665 name += QLatin1Char('.') + defaultSuffix;
never executed: name += QLatin1Char('.') + defaultSuffix;
0
666 if (info.isAbsolute()) {
evaluated: info.isAbsolute()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:192
1-192
667 files.append(name); -
668 } else {
executed: }
Execution Count:1
1
669 -
670 -
671 -
672 QString path = rootPath(); -
673 if (!path.endsWith(QLatin1Char('/')))
evaluated: !path.endsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:9
9-183
674 path += QLatin1Char('/');
executed: path += QLatin1Char('/');
Execution Count:183
183
675 path += name; -
676 files.append(path); -
677 }
executed: }
Execution Count:192
192
678 } -
679 return files;
executed: return files;
Execution Count:177
177
680} -
681QStringList QFileDialog::selectedFiles() const -
682{ -
683 const QFileDialogPrivate * const d = d_func(); -
684 -
685 QStringList files = d->userSelectedFiles(); -
686 if (files.isEmpty()) {
evaluated: files.isEmpty()
TRUEFALSE
yes
Evaluation Count:423
yes
Evaluation Count:176
176-423
687 const FileMode fm = fileMode(); -
688 if (fm != ExistingFile && fm != ExistingFiles)
evaluated: fm != ExistingFile
TRUEFALSE
yes
Evaluation Count:421
yes
Evaluation Count:2
evaluated: fm != ExistingFiles
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:3
2-421
689 files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString());
executed: files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString());
Execution Count:418
418
690 }
executed: }
Execution Count:423
423
691 return files;
executed: return files;
Execution Count:599
599
692} -
693 -
694 -
695 -
696 -
697 -
698QStringList qt_make_filter_list(const QString &filter) -
699{ -
700 QString f(filter); -
701 -
702 if (f.isEmpty())
evaluated: f.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:202
2-202
703 return QStringList();
executed: return QStringList();
Execution Count:2
2
704 -
705 QString sep(QLatin1String(";;")); -
706 int i = f.indexOf(sep, 0); -
707 if (i == -1) {
evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:194
yes
Evaluation Count:8
8-194
708 if (f.indexOf(QLatin1Char('\n'), 0) != -1) {
partially evaluated: f.indexOf(QLatin1Char('\n'), 0) != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:194
0-194
709 sep = QLatin1Char('\n'); -
710 i = f.indexOf(sep, 0); -
711 }
never executed: }
0
712 }
executed: }
Execution Count:194
194
713 -
714 return f.split(sep);
executed: return f.split(sep);
Execution Count:202
202
715} -
716void QFileDialog::setNameFilter(const QString &filter) -
717{ -
718 setNameFilters(qt_make_filter_list(filter)); -
719}
executed: }
Execution Count:200
200
720void QFileDialog::setNameFilterDetailsVisible(bool enabled) -
721{ -
722 setOption(HideNameFilterDetails, !enabled); -
723}
executed: }
Execution Count:8
8
724 -
725bool QFileDialog::isNameFilterDetailsVisible() const -
726{ -
727 return !testOption(HideNameFilterDetails);
executed: return !testOption(HideNameFilterDetails);
Execution Count:1
1
728} -
729 -
730 -
731 -
732 -
733 -
734QStringList qt_strip_filters(const QStringList &filters) -
735{ -
736 QStringList strippedFilters; -
737 QRegExp r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp)); -
738 for (int i = 0; i < filters.count(); ++i) {
evaluated: i < filters.count()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:11
11-20
739 QString filterName; -
740 int index = r.indexIn(filters[i]); -
741 if (index >= 0)
evaluated: index >= 0
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1
1-19
742 filterName = r.cap(1);
executed: filterName = r.cap(1);
Execution Count:19
19
743 strippedFilters.append(filterName.simplified()); -
744 }
executed: }
Execution Count:20
20
745 return strippedFilters;
executed: return strippedFilters;
Execution Count:11
11
746} -
747void QFileDialog::setNameFilters(const QStringList &filters) -
748{ -
749 QFileDialogPrivate * const d = d_func(); -
750 d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)"))); -
751 QStringList cleanedFilters; -
752 for (int i = 0; i < filters.count(); ++i) {
evaluated: i < filters.count()
TRUEFALSE
yes
Evaluation Count:257
yes
Evaluation Count:222
222-257
753 cleanedFilters << filters[i].simplified(); -
754 }
executed: }
Execution Count:257
257
755 d->options->setNameFilters(cleanedFilters); -
756 -
757 d->qFileDialogUi->fileTypeCombo->clear(); -
758 if (cleanedFilters.isEmpty())
evaluated: cleanedFilters.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:217
5-217
759 return;
executed: return;
Execution Count:5
5
760 -
761 if (testOption(HideNameFilterDetails))
evaluated: testOption(HideNameFilterDetails)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:210
7-210
762 d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters));
executed: d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters));
Execution Count:7
7
763 else -
764 d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
executed: d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
Execution Count:210
210
765 -
766 d->_q_useNameFilter(0); -
767}
executed: }
Execution Count:217
217
768 -
769 -
770 -
771 -
772 -
773 -
774 -
775QStringList QFileDialog::nameFilters() const -
776{ -
777 return d_func()->options->nameFilters();
executed: return d_func()->options->nameFilters();
Execution Count:10
10
778} -
779void QFileDialog::selectNameFilter(const QString &filter) -
780{ -
781 QFileDialogPrivate * const d = d_func(); -
782 if (d->nativeDialogInUse) {
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
783 d->selectNameFilter_sys(filter); -
784 return;
never executed: return;
0
785 } -
786 int i = -1; -
787 if (testOption(HideNameFilterDetails)) {
evaluated: testOption(HideNameFilterDetails)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
788 const QStringList filters = qt_strip_filters(qt_make_filter_list(filter)); -
789 if (!filters.isEmpty())
evaluated: !filters.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
790 i = d->qFileDialogUi->fileTypeCombo->findText(filters.first());
executed: i = d->qFileDialogUi->fileTypeCombo->findText(filters.first());
Execution Count:3
3
791 } else {
executed: }
Execution Count:4
4
792 i = d->qFileDialogUi->fileTypeCombo->findText(filter); -
793 }
executed: }
Execution Count:8
8
794 if (i >= 0) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
795 d->qFileDialogUi->fileTypeCombo->setCurrentIndex(i); -
796 d->_q_useNameFilter(d->qFileDialogUi->fileTypeCombo->currentIndex()); -
797 }
executed: }
Execution Count:6
6
798}
executed: }
Execution Count:12
12
799QString QFileDialog::selectedNameFilter() const -
800{ -
801 const QFileDialogPrivate * const d = d_func(); -
802 if (d->nativeDialogInUse)
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
803 return d->selectedNameFilter_sys();
never executed: return d->selectedNameFilter_sys();
0
804 -
805 return d->qFileDialogUi->fileTypeCombo->currentText();
executed: return d->qFileDialogUi->fileTypeCombo->currentText();
Execution Count:12
12
806} -
807QDir::Filters QFileDialog::filter() const -
808{ -
809 const QFileDialogPrivate * const d = d_func(); -
810 return d->model->filter();
executed: return d->model->filter();
Execution Count:219
219
811} -
812void QFileDialog::setFilter(QDir::Filters filters) -
813{ -
814 QFileDialogPrivate * const d = d_func(); -
815 d->model->setFilter(filters); -
816 d->options->setFilter(filters); -
817 if (d->nativeDialogInUse){
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
818 d->setFilter_sys(); -
819 return;
never executed: return;
0
820 } -
821 -
822 d->showHiddenAction->setChecked((filters & QDir::Hidden)); -
823}
executed: }
Execution Count:9
9
824void QFileDialog::setViewMode(QFileDialog::ViewMode mode) -
825{ -
826 QFileDialogPrivate * const d = d_func(); -
827 if (mode == Detail)
evaluated: mode == Detail
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:125
4-125
828 d->_q_showDetailsView();
executed: d->_q_showDetailsView();
Execution Count:4
4
829 else -
830 d->_q_showListView();
executed: d->_q_showListView();
Execution Count:125
125
831} -
832 -
833QFileDialog::ViewMode QFileDialog::viewMode() const -
834{ -
835 const QFileDialogPrivate * const d = d_func(); -
836 return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail);
executed: return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail);
Execution Count:197
197
837} -
838void QFileDialog::setFileMode(QFileDialog::FileMode mode) -
839{ -
840 QFileDialogPrivate * const d = d_func(); -
841 d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode)); -
842 d->retranslateWindowTitle(); -
843 -
844 -
845 setOption(ShowDirsOnly, mode == DirectoryOnly); -
846 -
847 -
848 QAbstractItemView::SelectionMode selectionMode; -
849 if (mode == QFileDialog::ExistingFiles)
evaluated: mode == QFileDialog::ExistingFiles
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:208
3-208
850 selectionMode = QAbstractItemView::ExtendedSelection;
executed: selectionMode = QAbstractItemView::ExtendedSelection;
Execution Count:3
3
851 else -
852 selectionMode = QAbstractItemView::SingleSelection;
executed: selectionMode = QAbstractItemView::SingleSelection;
Execution Count:208
208
853 d->qFileDialogUi->listView->setSelectionMode(selectionMode); -
854 d->qFileDialogUi->treeView->setSelectionMode(selectionMode); -
855 -
856 d->model->setFilter(d->filterForMode(filter())); -
857 -
858 if (mode == DirectoryOnly || mode == Directory) {
evaluated: mode == DirectoryOnly
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:208
evaluated: mode == Directory
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:200
3-208
859 d->qFileDialogUi->fileTypeCombo->clear(); -
860 d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories")); -
861 d->qFileDialogUi->fileTypeCombo->setEnabled(false); -
862 }
executed: }
Execution Count:11
11
863 d->updateFileNameLabel(); -
864 d->updateOkButtonText(); -
865 if (d->nativeDialogInUse){
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:211
0-211
866 d->setFilter_sys(); -
867 return;
never executed: return;
0
868 } -
869 -
870 d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly)); -
871 d->_q_updateOkButton(); -
872}
executed: }
Execution Count:211
211
873 -
874QFileDialog::FileMode QFileDialog::fileMode() const -
875{ -
876 const QFileDialogPrivate * const d = d_func(); -
877 return static_cast<FileMode>(d->options->fileMode());
executed: return static_cast<FileMode>(d->options->fileMode());
Execution Count:2778
2778
878} -
879void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) -
880{ -
881 QFileDialogPrivate * const d = d_func(); -
882 d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode)); -
883 QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save);
evaluated: mode == AcceptOpen
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:27
27-190
884 d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel); -
885 d->qFileDialogUi->buttonBox->button(button)->setEnabled(false); -
886 d->_q_updateOkButton(); -
887 if (mode == AcceptSave) {
evaluated: mode == AcceptSave
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:190
27-190
888 d->qFileDialogUi->lookInCombo->setEditable(false); -
889 }
executed: }
Execution Count:27
27
890 d->retranslateWindowTitle(); -
891 -
892 d->deletePlatformHelper(); -
893 -
894 setAttribute(Qt::WA_DontShowOnScreen, false); -
895}
executed: }
Execution Count:217
217
896 -
897 -
898 -
899 -
900 -
901QModelIndex QFileDialogPrivate::rootIndex() const { -
902 return mapToSource(qFileDialogUi->listView->rootIndex());
executed: return mapToSource(qFileDialogUi->listView->rootIndex());
Execution Count:852
852
903} -
904 -
905QAbstractItemView *QFileDialogPrivate::currentView() const { -
906 if (!qFileDialogUi->stackedWidget)
never evaluated: !qFileDialogUi->stackedWidget
0
907 return 0;
never executed: return 0;
0
908 if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent())
never evaluated: qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent()
0
909 return qFileDialogUi->listView;
never executed: return qFileDialogUi->listView;
0
910 return qFileDialogUi->treeView;
never executed: return qFileDialogUi->treeView;
0
911} -
912 -
913QLineEdit *QFileDialogPrivate::lineEdit() const { -
914 return (QLineEdit*)qFileDialogUi->fileNameEdit;
executed: return (QLineEdit*)qFileDialogUi->fileNameEdit;
Execution Count:1654
1654
915} -
916 -
917int QFileDialogPrivate::maxNameLength(const QString &path) -
918{ -
919 -
920 return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
executed: return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
Execution Count:158
158
921 return -1;
dead code: return -1;
-
922} -
923 -
924 -
925 -
926 -
927void QFileDialogPrivate::setRootIndex(const QModelIndex &index) const { -
928 qt_noop(); -
929 QModelIndex idx = mapFromSource(index); -
930 qFileDialogUi->treeView->setRootIndex(idx); -
931 qFileDialogUi->listView->setRootIndex(idx); -
932}
executed: }
Execution Count:238
238
933 -
934 -
935 -
936 -
937QModelIndex QFileDialogPrivate::select(const QModelIndex &index) const { -
938 qt_noop(); -
939 -
940 QModelIndex idx = mapFromSource(index); -
941 if (idx.isValid() && !qFileDialogUi->listView->selectionModel()->isSelected(idx))
evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:55
partially evaluated: !qFileDialogUi->listView->selectionModel()->isSelected(idx)
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-55
942 qFileDialogUi->listView->selectionModel()->select(idx, 18
943 QItemSelectionModel::Select | QItemSelectionModel::Rows);
executed: qFileDialogUi->listView->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
Execution Count:18
18
944 return idx;
executed: return idx;
Execution Count:73
73
945} -
946 -
947QFileDialog::AcceptMode QFileDialog::acceptMode() const -
948{ -
949 const QFileDialogPrivate * const d = d_func(); -
950 return static_cast<AcceptMode>(d->options->acceptMode());
executed: return static_cast<AcceptMode>(d->options->acceptMode());
Execution Count:2858
2858
951} -
952void QFileDialog::setReadOnly(bool enabled) -
953{ -
954 setOption(ReadOnly, enabled); -
955}
executed: }
Execution Count:3
3
956 -
957bool QFileDialog::isReadOnly() const -
958{ -
959 return testOption(ReadOnly);
executed: return testOption(ReadOnly);
Execution Count:10
10
960} -
961void QFileDialog::setResolveSymlinks(bool enabled) -
962{ -
963 setOption(DontResolveSymlinks, !enabled); -
964}
executed: }
Execution Count:2
2
965 -
966bool QFileDialog::resolveSymlinks() const -
967{ -
968 return !testOption(DontResolveSymlinks);
executed: return !testOption(DontResolveSymlinks);
Execution Count:3
3
969} -
970void QFileDialog::setConfirmOverwrite(bool enabled) -
971{ -
972 setOption(DontConfirmOverwrite, !enabled); -
973}
executed: }
Execution Count:3
3
974 -
975bool QFileDialog::confirmOverwrite() const -
976{ -
977 return !testOption(DontConfirmOverwrite);
executed: return !testOption(DontConfirmOverwrite);
Execution Count:5
5
978} -
979void QFileDialog::setDefaultSuffix(const QString &suffix) -
980{ -
981 QFileDialogPrivate * const d = d_func(); -
982 d->options->setDefaultSuffix(suffix); -
983}
executed: }
Execution Count:2
2
984 -
985QString QFileDialog::defaultSuffix() const -
986{ -
987 const QFileDialogPrivate * const d = d_func(); -
988 return d->options->defaultSuffix();
executed: return d->options->defaultSuffix();
Execution Count:3
3
989} -
990 -
991 -
992 -
993 -
994 -
995void QFileDialog::setHistory(const QStringList &paths) -
996{ -
997 QFileDialogPrivate * const d = d_func(); -
998 d->qFileDialogUi->lookInCombo->setHistory(paths); -
999}
executed: }
Execution Count:346
346
1000 -
1001void QFileDialogComboBox::setHistory(const QStringList &paths) -
1002{ -
1003 m_history = paths; -
1004 -
1005 QList<QUrl> list; -
1006 QModelIndex idx = d_ptr->model->index(d_ptr->rootPath()); -
1007 -
1008 QUrl url = QUrl::fromLocalFile(QDir::toNativeSeparators(idx.data(QFileSystemModel::FilePathRole).toString())); -
1009 if (url.isValid())
partially evaluated: url.isValid()
TRUEFALSE
yes
Evaluation Count:346
no
Evaluation Count:0
0-346
1010 list.append(url);
executed: list.append(url);
Execution Count:346
346
1011 urlModel->setUrls(list); -
1012}
executed: }
Execution Count:346
346
1013 -
1014 -
1015 -
1016 -
1017QStringList QFileDialog::history() const -
1018{ -
1019 const QFileDialogPrivate * const d = d_func(); -
1020 QStringList currentHistory = d->qFileDialogUi->lookInCombo->history(); -
1021 -
1022 QString newHistory = QDir::toNativeSeparators(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); -
1023 if (!currentHistory.contains(newHistory))
evaluated: !currentHistory.contains(newHistory)
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:75
75-121
1024 currentHistory << newHistory;
executed: currentHistory << newHistory;
Execution Count:121
121
1025 return currentHistory;
executed: return currentHistory;
Execution Count:196
196
1026} -
1027void QFileDialog::setItemDelegate(QAbstractItemDelegate *delegate) -
1028{ -
1029 QFileDialogPrivate * const d = d_func(); -
1030 d->qFileDialogUi->listView->setItemDelegate(delegate); -
1031 d->qFileDialogUi->treeView->setItemDelegate(delegate); -
1032}
executed: }
Execution Count:1
1
1033 -
1034 -
1035 -
1036 -
1037QAbstractItemDelegate *QFileDialog::itemDelegate() const -
1038{ -
1039 const QFileDialogPrivate * const d = d_func(); -
1040 return d->qFileDialogUi->listView->itemDelegate();
executed: return d->qFileDialogUi->listView->itemDelegate();
Execution Count:2
2
1041} -
1042 -
1043 -
1044 -
1045 -
1046void QFileDialog::setIconProvider(QFileIconProvider *provider) -
1047{ -
1048 QFileDialogPrivate * const d = d_func(); -
1049 d->model->setIconProvider(provider); -
1050 -
1051 d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls()); -
1052}
executed: }
Execution Count:1
1
1053 -
1054 -
1055 -
1056 -
1057QFileIconProvider *QFileDialog::iconProvider() const -
1058{ -
1059 const QFileDialogPrivate * const d = d_func(); -
1060 return d->model->iconProvider();
executed: return d->model->iconProvider();
Execution Count:2
2
1061} -
1062 -
1063void QFileDialogPrivate::setLabelTextControl(QFileDialog::DialogLabel label, const QString &text) -
1064{ -
1065 switch (label) { -
1066 case QFileDialog::LookIn: -
1067 qFileDialogUi->lookInLabel->setText(text); -
1068 break;
executed: break;
Execution Count:1
1
1069 case QFileDialog::FileName: -
1070 qFileDialogUi->fileNameLabel->setText(text); -
1071 break;
executed: break;
Execution Count:401
401
1072 case QFileDialog::FileType: -
1073 qFileDialogUi->fileTypeLabel->setText(text); -
1074 break;
executed: break;
Execution Count:1
1
1075 case QFileDialog::Accept: -
1076 if (q_func()->acceptMode() == QFileDialog::AcceptOpen) {
evaluated: q_func()->acceptMode() == QFileDialog::AcceptOpen
TRUEFALSE
yes
Evaluation Count:740
yes
Evaluation Count:51
51-740
1077 if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open))
evaluated: QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open)
TRUEFALSE
yes
Evaluation Count:551
yes
Evaluation Count:189
189-551
1078 button->setText(text);
executed: button->setText(text);
Execution Count:551
551
1079 } else {
executed: }
Execution Count:740
740
1080 if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save))
partially evaluated: QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save)
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
1081 button->setText(text);
executed: button->setText(text);
Execution Count:51
51
1082 }
executed: }
Execution Count:51
51
1083 break;
executed: break;
Execution Count:791
791
1084 case QFileDialog::Reject: -
1085 if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel))
partially evaluated: QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1086 button->setText(text);
executed: button->setText(text);
Execution Count:1
1
1087 break;
executed: break;
Execution Count:1
1
1088 } -
1089}
executed: }
Execution Count:1195
1195
1090 -
1091 -
1092 -
1093 -
1094 -
1095void QFileDialog::setLabelText(DialogLabel label, const QString &text) -
1096{ -
1097 QFileDialogPrivate * const d = d_func(); -
1098 d->options->setLabelText(static_cast<QFileDialogOptions::DialogLabel>(label), text); -
1099 d->setLabelTextControl(label, text); -
1100}
executed: }
Execution Count:7
7
1101 -
1102 -
1103 -
1104 -
1105QString QFileDialog::labelText(DialogLabel label) const -
1106{ -
1107 QPushButton *button; -
1108 const QFileDialogPrivate * const d = d_func(); -
1109 switch (label) { -
1110 case LookIn: -
1111 return d->qFileDialogUi->lookInLabel->text();
executed: return d->qFileDialogUi->lookInLabel->text();
Execution Count:2
2
1112 case FileName: -
1113 return d->qFileDialogUi->fileNameLabel->text();
executed: return d->qFileDialogUi->fileNameLabel->text();
Execution Count:2
2
1114 case FileType: -
1115 return d->qFileDialogUi->fileTypeLabel->text();
executed: return d->qFileDialogUi->fileTypeLabel->text();
Execution Count:2
2
1116 case Accept: -
1117 if (acceptMode() == AcceptOpen)
partially evaluated: acceptMode() == AcceptOpen
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1118 button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open);
executed: button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open);
Execution Count:2
2
1119 else -
1120 button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save);
never executed: button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save);
0
1121 if (button)
partially evaluated: button
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1122 return button->text();
executed: return button->text();
Execution Count:2
2
1123 case Reject:
code before this statement never executed: case Reject:
0
1124 button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel); -
1125 if (button)
partially evaluated: button
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1126 return button->text();
executed: return button->text();
Execution Count:2
2
1127 }
never executed: }
0
1128 return QString();
never executed: return QString();
0
1129} -
1130QString QFileDialog::getOpenFileName(QWidget *parent, -
1131 const QString &caption, -
1132 const QString &dir, -
1133 const QString &filter, -
1134 QString *selectedFilter, -
1135 Options options) -
1136{ -
1137 if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))
partially evaluated: qt_filedialog_open_filename_hook
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !(options & DontUseNativeDialog)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1138 return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
executed: return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
Execution Count:1
1
1139 QFileDialogArgs args; -
1140 args.parent = parent; -
1141 args.caption = caption; -
1142 args.directory = QFileDialogPrivate::workingDirectory(dir); -
1143 args.selection = QFileDialogPrivate::initialSelection(dir); -
1144 args.filter = filter; -
1145 args.mode = ExistingFile; -
1146 args.options = options; -
1147 -
1148 -
1149 -
1150 -
1151 -
1152 -
1153 -
1154 QFileDialog dialog(args); -
1155 if (selectedFilter && !selectedFilter->isEmpty())
never evaluated: selectedFilter
never evaluated: !selectedFilter->isEmpty()
0
1156 dialog.selectNameFilter(*selectedFilter);
never executed: dialog.selectNameFilter(*selectedFilter);
0
1157 if (dialog.exec() == QDialog::Accepted) {
never evaluated: dialog.exec() == QDialog::Accepted
0
1158 if (selectedFilter)
never evaluated: selectedFilter
0
1159 *selectedFilter = dialog.selectedNameFilter();
never executed: *selectedFilter = dialog.selectedNameFilter();
0
1160 return dialog.selectedFiles().value(0);
never executed: return dialog.selectedFiles().value(0);
0
1161 } -
1162 return QString();
never executed: return QString();
0
1163} -
1164QStringList QFileDialog::getOpenFileNames(QWidget *parent, -
1165 const QString &caption, -
1166 const QString &dir, -
1167 const QString &filter, -
1168 QString *selectedFilter, -
1169 Options options) -
1170{ -
1171 if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
partially evaluated: qt_filedialog_open_filenames_hook
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !(options & DontUseNativeDialog)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1172 return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
executed: return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
Execution Count:1
1
1173 QFileDialogArgs args; -
1174 args.parent = parent; -
1175 args.caption = caption; -
1176 args.directory = QFileDialogPrivate::workingDirectory(dir); -
1177 args.selection = QFileDialogPrivate::initialSelection(dir); -
1178 args.filter = filter; -
1179 args.mode = ExistingFiles; -
1180 args.options = options; -
1181 QFileDialog dialog(args); -
1182 if (selectedFilter && !selectedFilter->isEmpty())
never evaluated: selectedFilter
never evaluated: !selectedFilter->isEmpty()
0
1183 dialog.selectNameFilter(*selectedFilter);
never executed: dialog.selectNameFilter(*selectedFilter);
0
1184 if (dialog.exec() == QDialog::Accepted) {
never evaluated: dialog.exec() == QDialog::Accepted
0
1185 if (selectedFilter)
never evaluated: selectedFilter
0
1186 *selectedFilter = dialog.selectedNameFilter();
never executed: *selectedFilter = dialog.selectedNameFilter();
0
1187 return dialog.selectedFiles();
never executed: return dialog.selectedFiles();
0
1188 } -
1189 return QStringList();
never executed: return QStringList();
0
1190} -
1191QString QFileDialog::getSaveFileName(QWidget *parent, -
1192 const QString &caption, -
1193 const QString &dir, -
1194 const QString &filter, -
1195 QString *selectedFilter, -
1196 Options options) -
1197{ -
1198 if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
partially evaluated: qt_filedialog_save_filename_hook
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !(options & DontUseNativeDialog)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1199 return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
executed: return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
Execution Count:1
1
1200 QFileDialogArgs args; -
1201 args.parent = parent; -
1202 args.caption = caption; -
1203 args.directory = QFileDialogPrivate::workingDirectory(dir); -
1204 args.selection = QFileDialogPrivate::initialSelection(dir); -
1205 args.filter = filter; -
1206 args.mode = AnyFile; -
1207 args.options = options; -
1208 QFileDialog dialog(args); -
1209 dialog.setAcceptMode(AcceptSave); -
1210 if (selectedFilter && !selectedFilter->isEmpty())
never evaluated: selectedFilter
never evaluated: !selectedFilter->isEmpty()
0
1211 dialog.selectNameFilter(*selectedFilter);
never executed: dialog.selectNameFilter(*selectedFilter);
0
1212 if (dialog.exec() == QDialog::Accepted) {
never evaluated: dialog.exec() == QDialog::Accepted
0
1213 if (selectedFilter)
never evaluated: selectedFilter
0
1214 *selectedFilter = dialog.selectedNameFilter();
never executed: *selectedFilter = dialog.selectedNameFilter();
0
1215 return dialog.selectedFiles().value(0);
never executed: return dialog.selectedFiles().value(0);
0
1216 } -
1217 -
1218 return QString();
never executed: return QString();
0
1219} -
1220QString QFileDialog::getExistingDirectory(QWidget *parent, -
1221 const QString &caption, -
1222 const QString &dir, -
1223 Options options) -
1224{ -
1225 if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
partially evaluated: qt_filedialog_existing_directory_hook
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !(options & DontUseNativeDialog)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1226 return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
executed: return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
Execution Count:1
1
1227 QFileDialogArgs args; -
1228 args.parent = parent; -
1229 args.caption = caption; -
1230 args.directory = QFileDialogPrivate::workingDirectory(dir); -
1231 args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);
never evaluated: options & ShowDirsOnly
0
1232 args.options = options; -
1233 QFileDialog dialog(args); -
1234 if (dialog.exec() == QDialog::Accepted) {
never evaluated: dialog.exec() == QDialog::Accepted
0
1235 return dialog.selectedFiles().value(0);
never executed: return dialog.selectedFiles().value(0);
0
1236 } -
1237 return QString();
never executed: return QString();
0
1238} -
1239 -
1240inline static QString _qt_get_directory(const QString &path) -
1241{ -
1242 QFileInfo info = QFileInfo(QDir::current(), path); -
1243 if (info.exists() && info.isDir())
evaluated: info.exists()
TRUEFALSE
yes
Evaluation Count:203
yes
Evaluation Count:19
evaluated: info.isDir()
TRUEFALSE
yes
Evaluation Count:199
yes
Evaluation Count:4
4-203
1244 return QDir::cleanPath(info.absoluteFilePath());
executed: return QDir::cleanPath(info.absoluteFilePath());
Execution Count:199
199
1245 info.setFile(info.absolutePath()); -
1246 if (info.exists() && info.isDir())
evaluated: info.exists()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2
partially evaluated: info.isDir()
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
1247 return info.absoluteFilePath();
executed: return info.absoluteFilePath();
Execution Count:21
21
1248 return QString();
executed: return QString();
Execution Count:2
2
1249} -
1250 -
1251 -
1252 -
1253 -
1254 -
1255QString QFileDialogPrivate::workingDirectory(const QString &path) -
1256{ -
1257 if (!path.isEmpty()) {
evaluated: !path.isEmpty()
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:158
62-158
1258 QString directory = _qt_get_directory(path); -
1259 if (!directory.isEmpty())
evaluated: !directory.isEmpty()
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:2
2-60
1260 return directory;
executed: return directory;
Execution Count:60
60
1261 }
executed: }
Execution Count:2
2
1262 QString directory = _qt_get_directory(*lastVisitedDir()); -
1263 if (!directory.isEmpty())
partially evaluated: !directory.isEmpty()
TRUEFALSE
yes
Evaluation Count:160
no
Evaluation Count:0
0-160
1264 return directory;
executed: return directory;
Execution Count:160
160
1265 return QDir::currentPath();
never executed: return QDir::currentPath();
0
1266} -
1267QString QFileDialogPrivate::initialSelection(const QString &path) -
1268{ -
1269 if (!path.isEmpty()) {
evaluated: !path.isEmpty()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:158
31-158
1270 QFileInfo info(path); -
1271 if (!info.isDir())
evaluated: !info.isDir()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:22
9-22
1272 return info.fileName();
executed: return info.fileName();
Execution Count:9
9
1273 }
executed: }
Execution Count:22
22
1274 return QString();
executed: return QString();
Execution Count:180
180
1275} -
1276 -
1277 -
1278 -
1279 -
1280void QFileDialog::done(int result) -
1281{ -
1282 QFileDialogPrivate * const d = d_func(); -
1283 -
1284 QDialog::done(result); -
1285 -
1286 if (d->receiverToDisconnectOnClose) {
partially evaluated: d->receiverToDisconnectOnClose
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1287 disconnect(this, d->signalToDisconnectOnClose, -
1288 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); -
1289 d->receiverToDisconnectOnClose = 0; -
1290 }
never executed: }
0
1291 d->memberToDisconnectOnClose.clear(); -
1292 d->signalToDisconnectOnClose.clear(); -
1293}
executed: }
Execution Count:8
8
1294 -
1295 -
1296 -
1297 -
1298void QFileDialog::accept() -
1299{ -
1300 QFileDialogPrivate * const d = d_func(); -
1301 QStringList files = selectedFiles(); -
1302 if (files.isEmpty())
partially evaluated: files.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1303 return;
never executed: return;
0
1304 if (d->nativeDialogInUse){
partially evaluated: d->nativeDialogInUse
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1305 d->emitFilesSelected(files); -
1306 QDialog::accept(); -
1307 return;
never executed: return;
0
1308 } -
1309 -
1310 QString lineEditText = d->lineEdit()->text(); -
1311 -
1312 -
1313 if (lineEditText == QLatin1String("..")) {
partially evaluated: lineEditText == QLatin1String("..")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1314 d->_q_navigateToParent(); -
1315 bool block = d->qFileDialogUi->fileNameEdit->blockSignals(true); -
1316 d->lineEdit()->selectAll(); -
1317 d->qFileDialogUi->fileNameEdit->blockSignals(block); -
1318 return;
never executed: return;
0
1319 } -
1320 -
1321 switch (fileMode()) { -
1322 case DirectoryOnly: -
1323 case Directory: { -
1324 QString fn = files.first(); -
1325 QFileInfo info(fn); -
1326 if (!info.exists())
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1327 info = QFileInfo(d->getEnvironmentVariable(fn));
never executed: info = QFileInfo(d->getEnvironmentVariable(fn));
0
1328 if (!info.exists()) {
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1329 -
1330 QString message = tr("%1\nDirectory not found.\nPlease verify the " -
1331 "correct directory name was given."); -
1332 QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -
1333 -
1334 return;
never executed: return;
0
1335 } -
1336 if (info.isDir()) {
partially evaluated: info.isDir()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1337 d->emitFilesSelected(files); -
1338 QDialog::accept(); -
1339 }
executed: }
Execution Count:3
3
1340 return;
executed: return;
Execution Count:3
3
1341 } -
1342 -
1343 case AnyFile: { -
1344 QString fn = files.first(); -
1345 QFileInfo info(fn); -
1346 if (info.isDir()) {
partially evaluated: info.isDir()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1347 setDirectory(info.absoluteFilePath()); -
1348 return;
never executed: return;
0
1349 } -
1350 -
1351 if (!info.exists()) {
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1352 int maxNameLength = d->maxNameLength(info.path()); -
1353 if (maxNameLength >= 0 && info.fileName().length() > maxNameLength)
never evaluated: maxNameLength >= 0
never evaluated: info.fileName().length() > maxNameLength
0
1354 return;
never executed: return;
0
1355 }
never executed: }
0
1356 -
1357 -
1358 if (!info.exists() || !confirmOverwrite() || acceptMode() == AcceptOpen) {
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !confirmOverwrite()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: acceptMode() == AcceptOpen
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1359 d->emitFilesSelected(QStringList(fn)); -
1360 QDialog::accept(); -
1361 -
1362 } else {
executed: }
Execution Count:1
1
1363 if (QMessageBox::warning(this, windowTitle(), 0
1364 tr("%1 already exists.\nDo you want to replace it?") 0
1365 .arg(info.fileName()), 0
1366 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) 0
1367 == QMessageBox::Yes) {
never evaluated: QMessageBox::warning(this, windowTitle(), tr("%1 already exists.\nDo you want to replace it?") .arg(info.fileName()), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes
0
1368 d->emitFilesSelected(QStringList(fn)); -
1369 QDialog::accept(); -
1370 }
never executed: }
0
1371 -
1372 }
never executed: }
0
1373 return;
executed: return;
Execution Count:1
1
1374 } -
1375 -
1376 case ExistingFile: -
1377 case ExistingFiles: -
1378 for (int i = 0; i < files.count(); ++i) {
evaluated: i < files.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1379 QFileInfo info(files.at(i)); -
1380 if (!info.exists())
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1381 info = QFileInfo(d->getEnvironmentVariable(files.at(i)));
never executed: info = QFileInfo(d->getEnvironmentVariable(files.at(i)));
0
1382 if (!info.exists()) {
partially evaluated: !info.exists()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1383 -
1384 QString message = tr("%1\nFile not found.\nPlease verify the " -
1385 "correct file name was given."); -
1386 QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -
1387 -
1388 return;
never executed: return;
0
1389 } -
1390 if (info.isDir()) {
partially evaluated: info.isDir()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1391 setDirectory(info.absoluteFilePath()); -
1392 d->lineEdit()->clear(); -
1393 return;
never executed: return;
0
1394 } -
1395 }
executed: }
Execution Count:2
2
1396 d->emitFilesSelected(files); -
1397 QDialog::accept(); -
1398 return;
executed: return;
Execution Count:2
2
1399 } -
1400}
never executed: }
0
1401 -
1402 -
1403 -
1404 -
1405 -
1406 -
1407void QFileDialogPrivate::init(const QString &directory, const QString &nameFilter, -
1408 const QString &caption) -
1409{ -
1410 QFileDialog * const q = q_func(); -
1411 if (!caption.isEmpty()) {
evaluated: !caption.isEmpty()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:161
28-161
1412 useDefaultCaption = false; -
1413 setWindowTitle = caption; -
1414 q->setWindowTitle(caption); -
1415 }
executed: }
Execution Count:28
28
1416 -
1417 createWidgets(); -
1418 createMenuActions(); -
1419 retranslateStrings(); -
1420 q->setFileMode(QFileDialog::AnyFile); -
1421 -
1422 -
1423 QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); -
1424 settings.beginGroup(QLatin1String("Qt")); -
1425 if (!directory.isEmpty())
evaluated: !directory.isEmpty()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:158
31-158
1426 setLastVisitedDirectory(workingDirectory(directory));
executed: setLastVisitedDirectory(workingDirectory(directory));
Execution Count:31
31
1427 q->restoreState(settings.value(QLatin1String("filedialog")).toByteArray()); -
1428 if (!nameFilter.isEmpty())
evaluated: !nameFilter.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:188
1-188
1429 q->setNameFilter(nameFilter);
executed: q->setNameFilter(nameFilter);
Execution Count:1
1
1430 q->setAcceptMode(QFileDialog::AcceptOpen); -
1431 q->setDirectory(workingDirectory(directory)); -
1432 q->selectFile(initialSelection(directory)); -
1433 -
1434 _q_updateOkButton(); -
1435 q->resize(q->sizeHint()); -
1436}
executed: }
Execution Count:189
189
1437 -
1438 -
1439 -
1440 -
1441 -
1442 -
1443void QFileDialogPrivate::createWidgets() -
1444{ -
1445 QFileDialog * const q = q_func(); -
1446 model = new QFileSystemModel(q); -
1447 options->setFilter(model->filter()); -
1448 model->setObjectName(QLatin1String("qt_filesystem_model")); -
1449 if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
partially evaluated: QPlatformFileDialogHelper *helper = platformFileDialogHelper()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:189
0-189
1450 model->setNameFilterDisables(helper->defaultNameFilterDisables());
never executed: model->setNameFilterDisables(helper->defaultNameFilterDisables());
0
1451 else -
1452 model->setNameFilterDisables(false);
executed: model->setNameFilterDisables(false);
Execution Count:189
189
1453 model->d_func()->disableRecursiveSort = true; -
1454 QFileDialog::connect(model, "2""fileRenamed(QString,QString,QString)", q, "1""_q_fileRenamed(QString,QString,QString)"); -
1455 QFileDialog::connect(model, "2""rootPathChanged(QString)", -
1456 q, "1""_q_pathChanged(QString)"); -
1457 QFileDialog::connect(model, "2""rowsInserted(QModelIndex,int,int)", -
1458 q, "1""_q_rowsInserted(QModelIndex)"); -
1459 model->setReadOnly(false); -
1460 -
1461 qFileDialogUi.reset(new Ui_QFileDialog()); -
1462 qFileDialogUi->setupUi(q); -
1463 -
1464 QList<QUrl> initialBookmarks; -
1465 initialBookmarks << QUrl::fromLocalFile(QLatin1String("")) -
1466 << QUrl::fromLocalFile(QDir::homePath()); -
1467 qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks); -
1468 QFileDialog::connect(qFileDialogUi->sidebar, "2""goToUrl(QUrl)", -
1469 q, "1""_q_goToUrl(QUrl)"); -
1470 -
1471 QObject::connect(qFileDialogUi->buttonBox, "2""accepted()", q, "1""accept()"); -
1472 QObject::connect(qFileDialogUi->buttonBox, "2""rejected()", q, "1""reject()"); -
1473 -
1474 qFileDialogUi->lookInCombo->setFileDialogPrivate(this); -
1475 QObject::connect(qFileDialogUi->lookInCombo, "2""activated(QString)", q, "1""_q_goToDirectory(QString)"); -
1476 -
1477 qFileDialogUi->lookInCombo->setInsertPolicy(QComboBox::NoInsert); -
1478 qFileDialogUi->lookInCombo->setDuplicatesEnabled(false); -
1479 -
1480 -
1481 qFileDialogUi->fileNameEdit->setFileDialogPrivate(this); -
1482 -
1483 qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); -
1484 -
1485 -
1486 completer = new QFSCompleter(model, q); -
1487 qFileDialogUi->fileNameEdit->setCompleter(completer); -
1488 -
1489 QObject::connect(qFileDialogUi->fileNameEdit, "2""textChanged(QString)", -
1490 q, "1""_q_autoCompleteFileName(QString)"); -
1491 QObject::connect(qFileDialogUi->fileNameEdit, "2""textChanged(QString)", -
1492 q, "1""_q_updateOkButton()"); -
1493 -
1494 QObject::connect(qFileDialogUi->fileNameEdit, "2""returnPressed()", q, "1""accept()"); -
1495 -
1496 -
1497 qFileDialogUi->fileTypeCombo->setDuplicatesEnabled(false); -
1498 qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); -
1499 qFileDialogUi->fileTypeCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); -
1500 QObject::connect(qFileDialogUi->fileTypeCombo, "2""activated(int)", -
1501 q, "1""_q_useNameFilter(int)"); -
1502 QObject::connect(qFileDialogUi->fileTypeCombo, "2""activated(QString)", -
1503 q, "2""filterSelected(QString)"); -
1504 -
1505 qFileDialogUi->listView->setFileDialogPrivate(this); -
1506 qFileDialogUi->listView->setModel(model); -
1507 QObject::connect(qFileDialogUi->listView, "2""activated(QModelIndex)", -
1508 q, "1""_q_enterDirectory(QModelIndex)"); -
1509 QObject::connect(qFileDialogUi->listView, "2""customContextMenuRequested(QPoint)", -
1510 q, "1""_q_showContextMenu(QPoint)"); -
1511 -
1512 QShortcut *shortcut = new QShortcut(qFileDialogUi->listView); -
1513 shortcut->setKey(QKeySequence(QLatin1String("Delete"))); -
1514 QObject::connect(shortcut, "2""activated()", q, "1""_q_deleteCurrent()"); -
1515 -
1516 -
1517 qFileDialogUi->treeView->setFileDialogPrivate(this); -
1518 qFileDialogUi->treeView->setModel(model); -
1519 QHeaderView *treeHeader = qFileDialogUi->treeView->header(); -
1520 QFontMetrics fm(q->font()); -
1521 treeHeader->resizeSection(0, fm.width(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww"))); -
1522 treeHeader->resizeSection(1, fm.width(QLatin1String("128.88 GB"))); -
1523 treeHeader->resizeSection(2, fm.width(QLatin1String("mp3Folder"))); -
1524 treeHeader->resizeSection(3, fm.width(QLatin1String("10/29/81 02:02PM"))); -
1525 treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu); -
1526 -
1527 QActionGroup *showActionGroup = new QActionGroup(q); -
1528 showActionGroup->setExclusive(false); -
1529 QObject::connect(showActionGroup, "2""triggered(QAction*)", -
1530 q, "1""_q_showHeader(QAction*)");; -
1531 -
1532 QAbstractItemModel *abstractModel = model; -
1533 -
1534 if (proxyModel)
partially evaluated: proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:189
0-189
1535 abstractModel = proxyModel;
never executed: abstractModel = proxyModel;
0
1536 -
1537 for (int i = 1; i < abstractModel->columnCount(QModelIndex()); ++i) {
evaluated: i < abstractModel->columnCount(QModelIndex())
TRUEFALSE
yes
Evaluation Count:567
yes
Evaluation Count:189
189-567
1538 QAction *showHeader = new QAction(showActionGroup); -
1539 showHeader->setCheckable(true); -
1540 showHeader->setChecked(true); -
1541 treeHeader->addAction(showHeader); -
1542 }
executed: }
Execution Count:567
567
1543 -
1544 QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel()); -
1545 qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel()); -
1546 -
1547 QObject::connect(qFileDialogUi->treeView, "2""activated(QModelIndex)", -
1548 q, "1""_q_enterDirectory(QModelIndex)"); -
1549 QObject::connect(qFileDialogUi->treeView, "2""customContextMenuRequested(QPoint)", -
1550 q, "1""_q_showContextMenu(QPoint)"); -
1551 -
1552 shortcut = new QShortcut(qFileDialogUi->treeView); -
1553 shortcut->setKey(QKeySequence(QLatin1String("Delete"))); -
1554 QObject::connect(shortcut, "2""activated()", q, "1""_q_deleteCurrent()"); -
1555 -
1556 -
1557 -
1558 QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel(); -
1559 QObject::connect(selections, "2""selectionChanged(QItemSelection,QItemSelection)", -
1560 q, "1""_q_selectionChanged()"); -
1561 QObject::connect(selections, "2""currentChanged(QModelIndex,QModelIndex)", -
1562 q, "1""_q_currentChanged(QModelIndex)"); -
1563 qFileDialogUi->splitter->setStretchFactor(qFileDialogUi->splitter->indexOf(qFileDialogUi->splitter->widget(1)), QSizePolicy::Expanding); -
1564 -
1565 createToolButtons(); -
1566}
executed: }
Execution Count:189
189
1567 -
1568void QFileDialogPrivate::_q_showHeader(QAction *action) -
1569{ -
1570 QFileDialog * const q = q_func(); -
1571 QActionGroup *actionGroup = qobject_cast<QActionGroup*>(q->sender()); -
1572 qFileDialogUi->treeView->header()->setSectionHidden(actionGroup->actions().indexOf(action) + 1, !action->isChecked()); -
1573}
never executed: }
0
1574void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) -
1575{ -
1576 QFileDialogPrivate * const d = d_func(); -
1577 if ((!proxyModel && !d->proxyModel)
evaluated: !proxyModel
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
evaluated: !d->proxyModel
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-2
1578 || (proxyModel == d->proxyModel))
partially evaluated: (proxyModel == d->proxyModel)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1579 return;
executed: return;
Execution Count:1
1
1580 -
1581 QModelIndex idx = d->rootIndex(); -
1582 if (d->proxyModel) {
evaluated: d->proxyModel
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1583 disconnect(d->proxyModel, "2""rowsInserted(QModelIndex,int,int)", -
1584 this, "1""_q_rowsInserted(QModelIndex)"); -
1585 } else {
executed: }
Execution Count:1
1
1586 disconnect(d->model, "2""rowsInserted(QModelIndex,int,int)", -
1587 this, "1""_q_rowsInserted(QModelIndex)"); -
1588 }
executed: }
Execution Count:1
1
1589 -
1590 if (proxyModel != 0) {
evaluated: proxyModel != 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1591 proxyModel->setParent(this); -
1592 d->proxyModel = proxyModel; -
1593 proxyModel->setSourceModel(d->model); -
1594 d->qFileDialogUi->listView->setModel(d->proxyModel); -
1595 d->qFileDialogUi->treeView->setModel(d->proxyModel); -
1596 -
1597 d->completer->setModel(d->proxyModel); -
1598 d->completer->proxyModel = d->proxyModel; -
1599 -
1600 connect(d->proxyModel, "2""rowsInserted(QModelIndex,int,int)", -
1601 this, "1""_q_rowsInserted(QModelIndex)"); -
1602 } else {
executed: }
Execution Count:1
1
1603 d->proxyModel = 0; -
1604 d->qFileDialogUi->listView->setModel(d->model); -
1605 d->qFileDialogUi->treeView->setModel(d->model); -
1606 -
1607 d->completer->setModel(d->model); -
1608 d->completer->sourceModel = d->model; -
1609 d->completer->proxyModel = 0; -
1610 -
1611 connect(d->model, "2""rowsInserted(QModelIndex,int,int)", -
1612 this, "1""_q_rowsInserted(QModelIndex)"); -
1613 }
executed: }
Execution Count:1
1
1614 QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel()); -
1615 d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel()); -
1616 -
1617 d->setRootIndex(idx); -
1618 -
1619 -
1620 QItemSelectionModel *selections = d->qFileDialogUi->listView->selectionModel(); -
1621 QObject::connect(selections, "2""selectionChanged(QItemSelection,QItemSelection)", -
1622 this, "1""_q_selectionChanged()"); -
1623 QObject::connect(selections, "2""currentChanged(QModelIndex,QModelIndex)", -
1624 this, "1""_q_currentChanged(QModelIndex)"); -
1625}
executed: }
Execution Count:2
2
1626 -
1627 -
1628 -
1629 -
1630 -
1631 -
1632QAbstractProxyModel *QFileDialog::proxyModel() const -
1633{ -
1634 const QFileDialogPrivate * const d = d_func(); -
1635 return d->proxyModel;
executed: return d->proxyModel;
Execution Count:4
4
1636} -
1637 -
1638 -
1639 -
1640 -
1641 -
1642 -
1643 -
1644void QFileDialogPrivate::createToolButtons() -
1645{ -
1646 QFileDialog * const q = q_func(); -
1647 qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, 0, q)); -
1648 qFileDialogUi->backButton->setAutoRaise(true); -
1649 qFileDialogUi->backButton->setEnabled(false); -
1650 QObject::connect(qFileDialogUi->backButton, "2""clicked()", q, "1""_q_navigateBackward()"); -
1651 -
1652 qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, 0, q)); -
1653 qFileDialogUi->forwardButton->setAutoRaise(true); -
1654 qFileDialogUi->forwardButton->setEnabled(false); -
1655 QObject::connect(qFileDialogUi->forwardButton, "2""clicked()", q, "1""_q_navigateForward()"); -
1656 -
1657 qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, 0, q)); -
1658 qFileDialogUi->toParentButton->setAutoRaise(true); -
1659 qFileDialogUi->toParentButton->setEnabled(false); -
1660 QObject::connect(qFileDialogUi->toParentButton, "2""clicked()", q, "1""_q_navigateToParent()"); -
1661 -
1662 qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, 0, q)); -
1663 qFileDialogUi->listModeButton->setAutoRaise(true); -
1664 qFileDialogUi->listModeButton->setDown(true); -
1665 QObject::connect(qFileDialogUi->listModeButton, "2""clicked()", q, "1""_q_showListView()"); -
1666 -
1667 qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, 0, q)); -
1668 qFileDialogUi->detailModeButton->setAutoRaise(true); -
1669 QObject::connect(qFileDialogUi->detailModeButton, "2""clicked()", q, "1""_q_showDetailsView()"); -
1670 -
1671 QSize toolSize(qFileDialogUi->fileNameEdit->sizeHint().height(), qFileDialogUi->fileNameEdit->sizeHint().height()); -
1672 qFileDialogUi->backButton->setFixedSize(toolSize); -
1673 qFileDialogUi->listModeButton->setFixedSize(toolSize); -
1674 qFileDialogUi->detailModeButton->setFixedSize(toolSize); -
1675 qFileDialogUi->forwardButton->setFixedSize(toolSize); -
1676 qFileDialogUi->toParentButton->setFixedSize(toolSize); -
1677 -
1678 qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, 0, q)); -
1679 qFileDialogUi->newFolderButton->setFixedSize(toolSize); -
1680 qFileDialogUi->newFolderButton->setAutoRaise(true); -
1681 qFileDialogUi->newFolderButton->setEnabled(false); -
1682 QObject::connect(qFileDialogUi->newFolderButton, "2""clicked()", q, "1""_q_createDirectory()"); -
1683}
executed: }
Execution Count:189
189
1684 -
1685 -
1686 -
1687 -
1688 -
1689 -
1690void QFileDialogPrivate::createMenuActions() -
1691{ -
1692 QFileDialog * const q = q_func(); -
1693 -
1694 QAction *goHomeAction = new QAction(q); -
1695 -
1696 goHomeAction->setShortcut(Qt::CTRL + Qt::Key_H + Qt::SHIFT); -
1697 -
1698 QObject::connect(goHomeAction, "2""triggered()", q, "1""_q_goHome()"); -
1699 q->addAction(goHomeAction); -
1700 -
1701 -
1702 -
1703 QAction *goToParent = new QAction(q); -
1704 goToParent->setObjectName(QLatin1String("qt_goto_parent_action")); -
1705 -
1706 goToParent->setShortcut(Qt::CTRL + Qt::UpArrow); -
1707 -
1708 QObject::connect(goToParent, "2""triggered()", q, "1""_q_navigateToParent()"); -
1709 q->addAction(goToParent); -
1710 -
1711 renameAction = new QAction(q); -
1712 renameAction->setEnabled(false); -
1713 renameAction->setObjectName(QLatin1String("qt_rename_action")); -
1714 QObject::connect(renameAction, "2""triggered()", q, "1""_q_renameCurrent()"); -
1715 -
1716 deleteAction = new QAction(q); -
1717 deleteAction->setEnabled(false); -
1718 deleteAction->setObjectName(QLatin1String("qt_delete_action")); -
1719 QObject::connect(deleteAction, "2""triggered()", q, "1""_q_deleteCurrent()"); -
1720 -
1721 showHiddenAction = new QAction(q); -
1722 showHiddenAction->setObjectName(QLatin1String("qt_show_hidden_action")); -
1723 showHiddenAction->setCheckable(true); -
1724 QObject::connect(showHiddenAction, "2""triggered()", q, "1""_q_showHidden()"); -
1725 -
1726 newFolderAction = new QAction(q); -
1727 newFolderAction->setObjectName(QLatin1String("qt_new_folder_action")); -
1728 QObject::connect(newFolderAction, "2""triggered()", q, "1""_q_createDirectory()"); -
1729}
executed: }
Execution Count:189
189
1730 -
1731void QFileDialogPrivate::_q_goHome() -
1732{ -
1733 QFileDialog * const q = q_func(); -
1734 q->setDirectory(QDir::homePath()); -
1735}
never executed: }
0
1736 -
1737 -
1738 -
1739 -
1740 -
1741 -
1742void QFileDialogPrivate::_q_pathChanged(const QString &newPath) -
1743{ -
1744 QFileDialog * const q = q_func(); -
1745 QDir dir(model->rootDirectory()); -
1746 qFileDialogUi->toParentButton->setEnabled(dir.exists()); -
1747 qFileDialogUi->sidebar->selectUrl(QUrl::fromLocalFile(newPath)); -
1748 q->setHistory(qFileDialogUi->lookInCombo->history()); -
1749 -
1750 if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)) {
evaluated: currentHistoryLocation < 0
TRUEFALSE
yes
Evaluation Count:189
yes
Evaluation Count:47
evaluated: currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:12
12-189
1751 while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) {
evaluated: currentHistoryLocation >= 0
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:189
evaluated: currentHistoryLocation + 1 < currentHistory.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:35
2-189
1752 currentHistory.removeLast(); -
1753 }
executed: }
Execution Count:2
2
1754 currentHistory.append(QDir::toNativeSeparators(newPath)); -
1755 ++currentHistoryLocation; -
1756 }
executed: }
Execution Count:224
224
1757 qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1); -
1758 qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0); -
1759}
executed: }
Execution Count:236
236
1760 -
1761 -
1762 -
1763 -
1764 -
1765 -
1766void QFileDialogPrivate::_q_navigateBackward() -
1767{ -
1768 QFileDialog * const q = q_func(); -
1769 if (!currentHistory.isEmpty() && currentHistoryLocation > 0) {
partially evaluated: !currentHistory.isEmpty()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: currentHistoryLocation > 0
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1770 --currentHistoryLocation; -
1771 QString previousHistory = currentHistory.at(currentHistoryLocation); -
1772 q->setDirectory(previousHistory); -
1773 }
executed: }
Execution Count:8
8
1774}
executed: }
Execution Count:8
8
1775 -
1776 -
1777 -
1778 -
1779 -
1780 -
1781void QFileDialogPrivate::_q_navigateForward() -
1782{ -
1783 QFileDialog * const q = q_func(); -
1784 if (!currentHistory.isEmpty() && currentHistoryLocation < currentHistory.size() - 1) {
partially evaluated: !currentHistory.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: currentHistoryLocation < currentHistory.size() - 1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1785 ++currentHistoryLocation; -
1786 QString nextHistory = currentHistory.at(currentHistoryLocation); -
1787 q->setDirectory(nextHistory); -
1788 }
executed: }
Execution Count:4
4
1789}
executed: }
Execution Count:4
4
1790 -
1791 -
1792 -
1793 -
1794 -
1795 -
1796 -
1797void QFileDialogPrivate::_q_navigateToParent() -
1798{ -
1799 QFileDialog * const q = q_func(); -
1800 QDir dir(model->rootDirectory()); -
1801 QString newDirectory; -
1802 if (dir.isRoot()) {
partially evaluated: dir.isRoot()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1803 newDirectory = model->myComputer().toString(); -
1804 } else {
never executed: }
0
1805 dir.cdUp(); -
1806 newDirectory = dir.absolutePath(); -
1807 }
executed: }
Execution Count:1
1
1808 q->setDirectory(newDirectory); -
1809 q->directoryEntered(newDirectory); -
1810}
executed: }
Execution Count:1
1
1811 -
1812 -
1813 -
1814 -
1815 -
1816 -
1817void QFileDialogPrivate::_q_createDirectory() -
1818{ -
1819 QFileDialog * const q = q_func(); -
1820 qFileDialogUi->listView->clearSelection(); -
1821 -
1822 QString newFolderString = QFileDialog::tr("New Folder"); -
1823 QString folderName = newFolderString; -
1824 QString prefix = q->directory().absolutePath() + QDir::separator(); -
1825 if (QFile::exists(prefix + folderName)) {
never evaluated: QFile::exists(prefix + folderName)
0
1826 qlonglong suffix = 2; -
1827 while (QFile::exists(prefix + folderName)) {
never evaluated: QFile::exists(prefix + folderName)
0
1828 folderName = newFolderString + QString::number(suffix++); -
1829 }
never executed: }
0
1830 }
never executed: }
0
1831 -
1832 QModelIndex parent = rootIndex(); -
1833 QModelIndex index = model->mkdir(parent, folderName); -
1834 if (!index.isValid())
never evaluated: !index.isValid()
0
1835 return;
never executed: return;
0
1836 -
1837 index = select(index); -
1838 if (index.isValid()) {
never evaluated: index.isValid()
0
1839 qFileDialogUi->treeView->setCurrentIndex(index); -
1840 currentView()->edit(index); -
1841 }
never executed: }
0
1842}
never executed: }
0
1843 -
1844void QFileDialogPrivate::_q_showListView() -
1845{ -
1846 qFileDialogUi->listModeButton->setDown(true); -
1847 qFileDialogUi->detailModeButton->setDown(false); -
1848 qFileDialogUi->treeView->hide(); -
1849 qFileDialogUi->listView->show(); -
1850 qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->listView->parentWidget()); -
1851 qFileDialogUi->listView->doItemsLayout(); -
1852}
executed: }
Execution Count:125
125
1853 -
1854void QFileDialogPrivate::_q_showDetailsView() -
1855{ -
1856 qFileDialogUi->listModeButton->setDown(false); -
1857 qFileDialogUi->detailModeButton->setDown(true); -
1858 qFileDialogUi->listView->hide(); -
1859 qFileDialogUi->treeView->show(); -
1860 qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->treeView->parentWidget()); -
1861 qFileDialogUi->treeView->doItemsLayout(); -
1862}
executed: }
Execution Count:4
4
1863 -
1864 -
1865 -
1866 -
1867 -
1868 -
1869void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) -
1870{ -
1871 -
1872 -
1873 -
1874 QFileDialog * const q = q_func(); -
1875 QAbstractItemView *view = 0; -
1876 if (q->viewMode() == QFileDialog::Detail)
partially evaluated: q->viewMode() == QFileDialog::Detail
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1877 view = qFileDialogUi->treeView;
never executed: view = qFileDialogUi->treeView;
0
1878 else -
1879 view = qFileDialogUi->listView;
executed: view = qFileDialogUi->listView;
Execution Count:3
3
1880 QModelIndex index = view->indexAt(position); -
1881 index = mapToSource(index.sibling(index.row(), 0)); -
1882 -
1883 QMenu menu(view); -
1884 if (index.isValid()) {
partially evaluated: index.isValid()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1885 -
1886 const bool ro = model && model->isReadOnly();
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: model->isReadOnly()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
1887 QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); -
1888 renameAction->setEnabled(!ro && p & QFile::WriteUser); -
1889 menu.addAction(renameAction); -
1890 deleteAction->setEnabled(!ro && p & QFile::WriteUser); -
1891 menu.addAction(deleteAction); -
1892 menu.addSeparator(); -
1893 }
executed: }
Execution Count:3
3
1894 menu.addAction(showHiddenAction); -
1895 if (qFileDialogUi->newFolderButton->isVisible()) {
partially evaluated: qFileDialogUi->newFolderButton->isVisible()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1896 newFolderAction->setEnabled(qFileDialogUi->newFolderButton->isEnabled()); -
1897 menu.addAction(newFolderAction); -
1898 }
executed: }
Execution Count:3
3
1899 menu.exec(view->viewport()->mapToGlobal(position)); -
1900 -
1901}
executed: }
Execution Count:3
3
1902 -
1903 -
1904 -
1905 -
1906void QFileDialogPrivate::_q_renameCurrent() -
1907{ -
1908 QFileDialog * const q = q_func(); -
1909 QModelIndex index = qFileDialogUi->listView->currentIndex(); -
1910 index = index.sibling(index.row(), 0); -
1911 if (q->viewMode() == QFileDialog::List)
never evaluated: q->viewMode() == QFileDialog::List
0
1912 qFileDialogUi->listView->edit(index);
never executed: qFileDialogUi->listView->edit(index);
0
1913 else -
1914 qFileDialogUi->treeView->edit(index);
never executed: qFileDialogUi->treeView->edit(index);
0
1915} -
1916 -
1917bool QFileDialogPrivate::removeDirectory(const QString &path) -
1918{ -
1919 QModelIndex modelIndex = model->index(path); -
1920 return model->remove(modelIndex);
never executed: return model->remove(modelIndex);
0
1921} -
1922 -
1923 -
1924 -
1925 -
1926 -
1927 -
1928void QFileDialogPrivate::_q_deleteCurrent() -
1929{ -
1930 if (model->isReadOnly())
never evaluated: model->isReadOnly()
0
1931 return;
never executed: return;
0
1932 -
1933 QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); -
1934 for (int i = list.count() - 1; i >= 0; --i) {
never evaluated: i >= 0
0
1935 QModelIndex index = list.at(i); -
1936 if (index == qFileDialogUi->listView->rootIndex())
never evaluated: index == qFileDialogUi->listView->rootIndex()
0
1937 continue;
never executed: continue;
0
1938 -
1939 index = mapToSource(index.sibling(index.row(), 0)); -
1940 if (!index.isValid())
never evaluated: !index.isValid()
0
1941 continue;
never executed: continue;
0
1942 -
1943 QString fileName = index.data(QFileSystemModel::FileNameRole).toString(); -
1944 QString filePath = index.data(QFileSystemModel::FilePathRole).toString(); -
1945 bool isDir = model->isDir(index); -
1946 -
1947 QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); -
1948 -
1949 QFileDialog * const q = q_func(); -
1950 if (!(p & QFile::WriteUser) && (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"),
never evaluated: !(p & QFile::WriteUser)
0
1951 QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?") 0
1952 .arg(fileName), 0
1953 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No))
never evaluated: (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?") .arg(fileName), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
0
1954 return;
never executed: return;
0
1955 else if (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), 0
1956 QFileDialog::tr("Are you sure you want to delete '%1'?") 0
1957 .arg(fileName), 0
1958 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
never evaluated: QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), QFileDialog::tr("Are you sure you want to delete '%1'?") .arg(fileName), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No
0
1959 return;
never executed: return;
0
1960 -
1961 -
1962 -
1963 -
1964 -
1965 -
1966 -
1967 if (isDir) {
never evaluated: isDir
0
1968 if (!removeDirectory(filePath)) {
never evaluated: !removeDirectory(filePath)
0
1969 -
1970 QMessageBox::warning(q, q->windowTitle(), -
1971 QFileDialog::tr("Could not delete directory.")); -
1972 -
1973 }
never executed: }
0
1974 } else {
never executed: }
0
1975 model->remove(index); -
1976 }
never executed: }
0
1977 } -
1978}
never executed: }
0
1979 -
1980void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) -
1981{ -
1982 if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) {
partially evaluated: text.startsWith(QLatin1String("//"))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:87
evaluated: text.startsWith(QLatin1Char('\\'))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:84
0-87
1983 qFileDialogUi->listView->selectionModel()->clearSelection(); -
1984 return;
executed: return;
Execution Count:3
3
1985 } -
1986 -
1987 QStringList multipleFiles = typedFiles(); -
1988 if (multipleFiles.count() > 0) {
partially evaluated: multipleFiles.count() > 0
TRUEFALSE
yes
Evaluation Count:84
no
Evaluation Count:0
0-84
1989 QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows(); -
1990 QModelIndexList newFiles; -
1991 for (int i = 0; i < multipleFiles.count(); ++i) {
evaluated: i < multipleFiles.count()
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:84
84-100
1992 QModelIndex idx = model->index(multipleFiles.at(i)); -
1993 if (oldFiles.contains(idx))
evaluated: oldFiles.contains(idx)
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:73
27-73
1994 oldFiles.removeAll(idx);
executed: oldFiles.removeAll(idx);
Execution Count:27
27
1995 else -
1996 newFiles.append(idx);
executed: newFiles.append(idx);
Execution Count:73
73
1997 } -
1998 for (int i = 0; i < newFiles.count(); ++i)
evaluated: i < newFiles.count()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:84
73-84
1999 select(newFiles.at(i));
executed: select(newFiles.at(i));
Execution Count:73
73
2000 if (lineEdit()->hasFocus())
evaluated: lineEdit()->hasFocus()
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:37
37-47
2001 for (int i = 0; i < oldFiles.count(); ++i)
evaluated: i < oldFiles.count()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:47
2-47
2002 qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), 2
2003 QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
executed: qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), QItemSelectionModel::Toggle | QItemSelectionModel::Rows);
Execution Count:2
2
2004 }
executed: }
Execution Count:84
84
2005}
executed: }
Execution Count:84
84
2006 -
2007 -
2008 -
2009 -
2010void QFileDialogPrivate::_q_updateOkButton() -
2011{ -
2012 QFileDialog * const q = q_func(); -
2013 QPushButton *button = qFileDialogUi->buttonBox->button((q->acceptMode() == QFileDialog::AcceptOpen) -
2014 ? QDialogButtonBox::Open : QDialogButtonBox::Save); -
2015 if (!button)
evaluated: !button
TRUEFALSE
yes
Evaluation Count:189
yes
Evaluation Count:577
189-577
2016 return;
executed: return;
Execution Count:189
189
2017 const QFileDialog::FileMode fileMode = q->fileMode(); -
2018 -
2019 bool enableButton = true; -
2020 bool isOpenDirectory = false; -
2021 -
2022 QStringList files = q->selectedFiles(); -
2023 QString lineEditText = lineEdit()->text(); -
2024 -
2025 if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) {
partially evaluated: lineEditText.startsWith(QLatin1String("//"))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:577
evaluated: lineEditText.startsWith(QLatin1Char('\\'))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:574
0-577
2026 button->setEnabled(true); -
2027 updateOkButtonText(); -
2028 return;
executed: return;
Execution Count:3
3
2029 } -
2030 -
2031 if (files.isEmpty()) {
evaluated: files.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:569
5-569
2032 enableButton = false; -
2033 } else if (lineEditText == QLatin1String("..")) {
executed: }
Execution Count:5
evaluated: lineEditText == QLatin1String("..")
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:564
5-564
2034 isOpenDirectory = true; -
2035 } else {
executed: }
Execution Count:5
5
2036 switch (fileMode) { -
2037 case QFileDialog::DirectoryOnly: -
2038 case QFileDialog::Directory: { -
2039 QString fn = files.first(); -
2040 QModelIndex idx = model->index(fn); -
2041 if (!idx.isValid())
evaluated: !idx.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
3-24
2042 idx = model->index(getEnvironmentVariable(fn));
executed: idx = model->index(getEnvironmentVariable(fn));
Execution Count:3
3
2043 if (!idx.isValid() || !model->isDir(idx))
evaluated: !idx.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
evaluated: !model->isDir(idx)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:22
2-24
2044 enableButton = false;
executed: enableButton = false;
Execution Count:5
5
2045 break;
executed: break;
Execution Count:27
27
2046 } -
2047 case QFileDialog::AnyFile: { -
2048 QString fn = files.first(); -
2049 QFileInfo info(fn); -
2050 QModelIndex idx = model->index(fn); -
2051 QString fileDir; -
2052 QString fileName; -
2053 if (info.isDir()) {
evaluated: info.isDir()
TRUEFALSE
yes
Evaluation Count:374
yes
Evaluation Count:139
139-374
2054 fileDir = info.canonicalFilePath(); -
2055 } else {
executed: }
Execution Count:374
374
2056 fileDir = fn.mid(0, fn.lastIndexOf(QLatin1Char('/'))); -
2057 fileName = fn.mid(fileDir.length() + 1); -
2058 }
executed: }
Execution Count:139
139
2059 if (lineEditText.contains(QLatin1String(".."))) {
evaluated: lineEditText.contains(QLatin1String(".."))
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:476
37-476
2060 fileDir = info.canonicalFilePath(); -
2061 fileName = info.fileName(); -
2062 }
executed: }
Execution Count:37
37
2063 -
2064 if (fileDir == q->directory().canonicalPath() && fileName.isEmpty()) {
evaluated: fileDir == q->directory().canonicalPath()
TRUEFALSE
yes
Evaluation Count:369
yes
Evaluation Count:144
evaluated: fileName.isEmpty()
TRUEFALSE
yes
Evaluation Count:317
yes
Evaluation Count:52
52-369
2065 enableButton = false; -
2066 break;
executed: break;
Execution Count:317
317
2067 } -
2068 if (idx.isValid() && model->isDir(idx)) {
evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:158
evaluated: model->isDir(idx)
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:17
17-158
2069 isOpenDirectory = true; -
2070 enableButton = true; -
2071 break;
executed: break;
Execution Count:21
21
2072 } -
2073 if (!idx.isValid()) {
evaluated: !idx.isValid()
TRUEFALSE
yes
Evaluation Count:158
yes
Evaluation Count:17
17-158
2074 int maxLength = maxNameLength(fileDir); -
2075 enableButton = maxLength < 0 || fileName.length() <= maxLength;
evaluated: maxLength < 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:71
evaluated: fileName.length() <= maxLength
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:3
3-87
2076 }
executed: }
Execution Count:158
158
2077 break;
executed: break;
Execution Count:175
175
2078 } -
2079 case QFileDialog::ExistingFile: -
2080 case QFileDialog::ExistingFiles: -
2081 for (int i = 0; i < files.count(); ++i) {
evaluated: i < files.count()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:24
24-40
2082 QModelIndex idx = model->index(files.at(i)); -
2083 if (!idx.isValid())
partially evaluated: !idx.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2084 idx = model->index(getEnvironmentVariable(files.at(i)));
never executed: idx = model->index(getEnvironmentVariable(files.at(i)));
0
2085 if (!idx.isValid()) {
partially evaluated: !idx.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2086 enableButton = false; -
2087 break;
never executed: break;
0
2088 } -
2089 if (idx.isValid() && model->isDir(idx)) {
partially evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:40
no
Evaluation Count:0
partially evaluated: model->isDir(idx)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2090 isOpenDirectory = true; -
2091 break;
never executed: break;
0
2092 } -
2093 }
executed: }
Execution Count:40
40
2094 break;
executed: break;
Execution Count:24
24
2095 default: -
2096 break;
never executed: break;
0
2097 } -
2098 }
executed: }
Execution Count:564
564
2099 -
2100 button->setEnabled(enableButton); -
2101 updateOkButtonText(isOpenDirectory); -
2102}
executed: }
Execution Count:574
574
2103 -
2104 -
2105 -
2106 -
2107void QFileDialogPrivate::_q_currentChanged(const QModelIndex &index) -
2108{ -
2109 _q_updateOkButton(); -
2110 q_func()->currentChanged(index.data(QFileSystemModel::FilePathRole).toString()); -
2111}
executed: }
Execution Count:24
24
2112 -
2113 -
2114 -
2115 -
2116 -
2117 -
2118 -
2119void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) -
2120{ -
2121 QFileDialog * const q = q_func(); -
2122 -
2123 QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index;
partially evaluated: index.model() == proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
2124 QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); -
2125 if (path.isEmpty() || model->isDir(sourceIndex)) {
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: model->isDir(sourceIndex)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
2126 const QFileDialog::FileMode fileMode = q->fileMode(); -
2127 q->setDirectory(path); -
2128 q->directoryEntered(path); -
2129 if (fileMode == QFileDialog::Directory
evaluated: fileMode == QFileDialog::Directory
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
2130 || fileMode == QFileDialog::DirectoryOnly) {
partially evaluated: fileMode == QFileDialog::DirectoryOnly
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2131 -
2132 lineEdit()->setText(QString()); -
2133 lineEdit()->clear(); -
2134 }
executed: }
Execution Count:2
2
2135 } else {
executed: }
Execution Count:5
5
2136 -
2137 if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)
never evaluated: !q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)
0
2138 || q->fileMode() != QFileDialog::ExistingFiles || !(QGuiApplication::keyboardModifiers() & Qt::CTRL)) {
never evaluated: q->fileMode() != QFileDialog::ExistingFiles
never evaluated: !(QGuiApplication::keyboardModifiers() & Qt::CTRL)
0
2139 q->accept(); -
2140 }
never executed: }
0
2141 }
never executed: }
0
2142} -
2143 -
2144 -
2145 -
2146 -
2147 -
2148 -
2149 -
2150void QFileDialogPrivate::_q_goToDirectory(const QString &path) -
2151{ -
2152 -
2153 QFileDialog * const q = q_func(); -
2154 -
2155 QModelIndex index = qFileDialogUi->lookInCombo->model()->index(qFileDialogUi->lookInCombo->currentIndex(), -
2156 qFileDialogUi->lookInCombo->modelColumn(), -
2157 qFileDialogUi->lookInCombo->rootModelIndex()); -
2158 QString path2 = path; -
2159 if (!index.isValid())
never evaluated: !index.isValid()
0
2160 index = mapFromSource(model->index(getEnvironmentVariable(path)));
never executed: index = mapFromSource(model->index(getEnvironmentVariable(path)));
0
2161 else { -
2162 path2 = index.data((Qt::UserRole + 1)).toUrl().toLocalFile(); -
2163 index = mapFromSource(model->index(path2)); -
2164 }
never executed: }
0
2165 QDir dir(path2); -
2166 if (!dir.exists())
never evaluated: !dir.exists()
0
2167 dir = getEnvironmentVariable(path2);
never executed: dir = getEnvironmentVariable(path2);
0
2168 -
2169 if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) {
never evaluated: dir.exists()
never evaluated: path2.isEmpty()
never evaluated: path2 == model->myComputer().toString()
0
2170 _q_enterDirectory(index); -
2171 -
2172 } else {
never executed: }
0
2173 QString message = QFileDialog::tr("%1\nDirectory not found.\nPlease verify the " -
2174 "correct directory name was given."); -
2175 QMessageBox::warning(q, q->windowTitle(), message.arg(path2)); -
2176 -
2177 }
never executed: }
0
2178} -
2179 -
2180 -
2181 -
2182 -
2183 -
2184 -
2185 -
2186void QFileDialogPrivate::_q_useNameFilter(int index) -
2187{ -
2188 QStringList nameFilters = options->nameFilters(); -
2189 if (index == nameFilters.size()) {
evaluated: index == nameFilters.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:224
1-224
2190 QAbstractItemModel *comboModel = qFileDialogUi->fileTypeCombo->model(); -
2191 nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString()); -
2192 options->setNameFilters(nameFilters); -
2193 }
executed: }
Execution Count:1
1
2194 -
2195 QString nameFilter = nameFilters.at(index); -
2196 QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter); -
2197 if (q_func()->acceptMode() == QFileDialog::AcceptSave) {
evaluated: q_func()->acceptMode() == QFileDialog::AcceptSave
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:217
8-217
2198 QString newNameFilterExtension; -
2199 if (newNameFilters.count() > 0)
partially evaluated: newNameFilters.count() > 0
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
2200 newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix();
executed: newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix();
Execution Count:8
8
2201 -
2202 QString fileName = lineEdit()->text(); -
2203 const QString fileNameExtension = QFileInfo(fileName).suffix(); -
2204 if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {
partially evaluated: !fileNameExtension.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
never evaluated: !newNameFilterExtension.isEmpty()
0-8
2205 const int fileNameExtensionLength = fileNameExtension.count(); -
2206 fileName.replace(fileName.count() - fileNameExtensionLength, -
2207 fileNameExtensionLength, newNameFilterExtension); -
2208 qFileDialogUi->listView->clearSelection(); -
2209 lineEdit()->setText(fileName); -
2210 }
never executed: }
0
2211 }
executed: }
Execution Count:8
8
2212 -
2213 model->setNameFilters(newNameFilters); -
2214}
executed: }
Execution Count:225
225
2215 -
2216 -
2217 -
2218 -
2219 -
2220 -
2221 -
2222void QFileDialogPrivate::_q_selectionChanged() -
2223{ -
2224 const QFileDialog::FileMode fileMode = q_func()->fileMode(); -
2225 QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows(); -
2226 bool stripDirs = (fileMode != QFileDialog::DirectoryOnly && fileMode != QFileDialog::Directory);
evaluated: fileMode != QFileDialog::DirectoryOnly
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:1
evaluated: fileMode != QFileDialog::Directory
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:5
1-53
2227 -
2228 QStringList allFiles; -
2229 for (int i = 0; i < indexes.count(); ++i) {
evaluated: i < indexes.count()
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:54
54-58
2230 if (stripDirs && model->isDir(mapToSource(indexes.at(i))))
evaluated: stripDirs
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:5
evaluated: model->isDir(mapToSource(indexes.at(i)))
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:38
5-53
2231 continue;
executed: continue;
Execution Count:15
15
2232 allFiles.append(indexes.at(i).data().toString()); -
2233 }
executed: }
Execution Count:43
43
2234 if (allFiles.count() > 1)
evaluated: allFiles.count() > 1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:47
7-47
2235 for (int i = 0; i < allFiles.count(); ++i) {
evaluated: i < allFiles.count()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:7
7-23
2236 allFiles.replace(i, QString(QLatin1Char('"') + allFiles.at(i) + QLatin1Char('"'))); -
2237 }
executed: }
Execution Count:23
23
2238 -
2239 QString finalFiles = allFiles.join(QLatin1Char(' ')); -
2240 if (!finalFiles.isEmpty() && !lineEdit()->hasFocus() && lineEdit()->isVisible())
evaluated: !finalFiles.isEmpty()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:27
evaluated: !lineEdit()->hasFocus()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:7
evaluated: lineEdit()->isVisible()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-27
2241 lineEdit()->setText(finalFiles);
executed: lineEdit()->setText(finalFiles);
Execution Count:16
16
2242 else -
2243 _q_updateOkButton();
executed: _q_updateOkButton();
Execution Count:38
38
2244} -
2245 -
2246 -
2247 -
2248 -
2249 -
2250 -
2251void QFileDialogPrivate::_q_showHidden() -
2252{ -
2253 QFileDialog * const q = q_func(); -
2254 QDir::Filters dirFilters = q->filter(); -
2255 if (showHiddenAction->isChecked())
never evaluated: showHiddenAction->isChecked()
0
2256 dirFilters |= QDir::Hidden;
never executed: dirFilters |= QDir::Hidden;
0
2257 else -
2258 dirFilters &= ~QDir::Hidden;
never executed: dirFilters &= ~QDir::Hidden;
0
2259 q->setFilter(dirFilters); -
2260}
never executed: }
0
2261 -
2262 -
2263 -
2264 -
2265 -
2266 -
2267 -
2268void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent) -
2269{ -
2270 if (!qFileDialogUi->treeView
partially evaluated: !qFileDialogUi->treeView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2263
0-2263
2271 || parent != qFileDialogUi->treeView->rootIndex()
evaluated: parent != qFileDialogUi->treeView->rootIndex()
TRUEFALSE
yes
Evaluation Count:2021
yes
Evaluation Count:242
242-2021
2272 || !qFileDialogUi->treeView->selectionModel()
evaluated: !qFileDialogUi->treeView->selectionModel()
TRUEFALSE
yes
Evaluation Count:189
yes
Evaluation Count:53
53-189
2273 || qFileDialogUi->treeView->selectionModel()->hasSelection()
evaluated: qFileDialogUi->treeView->selectionModel()->hasSelection()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:48
5-48
2274 || qFileDialogUi->treeView->model()->rowCount(parent) == 0)
partially evaluated: qFileDialogUi->treeView->model()->rowCount(parent) == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
0-48
2275 return;
executed: return;
Execution Count:2215
2215
2276}
executed: }
Execution Count:48
48
2277 -
2278void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString oldName, const QString newName) -
2279{ -
2280 const QFileDialog::FileMode fileMode = q_func()->fileMode(); -
2281 if (fileMode == QFileDialog::Directory || fileMode == QFileDialog::DirectoryOnly) {
never evaluated: fileMode == QFileDialog::Directory
never evaluated: fileMode == QFileDialog::DirectoryOnly
0
2282 if (path == rootPath() && lineEdit()->text() == oldName)
never evaluated: path == rootPath()
never evaluated: lineEdit()->text() == oldName
0
2283 lineEdit()->setText(newName);
never executed: lineEdit()->setText(newName);
0
2284 }
never executed: }
0
2285}
never executed: }
0
2286 -
2287void QFileDialogPrivate::_q_nativeEnterDirectory(const QString &directory) -
2288{ -
2289 if (!directory.isEmpty())
never evaluated: !directory.isEmpty()
0
2290 *lastVisitedDir() = directory;
never executed: *lastVisitedDir() = directory;
0
2291}
never executed: }
0
2292bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { -
2293 -
2294 QFileDialog * const q = q_func(); -
2295 switch (event->key()) { -
2296 case Qt::Key_Backspace: -
2297 _q_navigateToParent(); -
2298 return true;
executed: return true;
Execution Count:1
1
2299 case Qt::Key_Back: -
2300 -
2301 -
2302 -
2303 -
2304 case Qt::Key_Left: -
2305 if (event->key() == Qt::Key_Back || event->modifiers() == Qt::AltModifier) {
never evaluated: event->key() == Qt::Key_Back
never evaluated: event->modifiers() == Qt::AltModifier
0
2306 _q_navigateBackward(); -
2307 return true;
never executed: return true;
0
2308 } -
2309 break;
never executed: break;
0
2310 case Qt::Key_Escape: -
2311 q->hide(); -
2312 return true;
executed: return true;
Execution Count:1
1
2313 default: -
2314 break;
executed: break;
Execution Count:12
12
2315 } -
2316 return false;
executed: return false;
Execution Count:12
12
2317} -
2318 -
2319QString QFileDialogPrivate::getEnvironmentVariable(const QString &string) -
2320{ -
2321 -
2322 if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) {
partially evaluated: string.size() > 1
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: string.startsWith(QLatin1Char('$'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2323 return QString::fromLocal8Bit(getenv(string.mid(1).toLatin1().constData()));
never executed: return QString::fromLocal8Bit(getenv(string.mid(1).toLatin1().constData()));
0
2324 } -
2325 -
2326 -
2327 -
2328 -
2329 -
2330 return string;
executed: return string;
Execution Count:3
3
2331} -
2332 -
2333void QFileDialogComboBox::setFileDialogPrivate(QFileDialogPrivate *d_pointer) { -
2334 d_ptr = d_pointer; -
2335 urlModel = new QUrlModel(this); -
2336 urlModel->showFullPath = true; -
2337 urlModel->setFileSystemModel(d_ptr->model); -
2338 setModel(urlModel); -
2339}
executed: }
Execution Count:189
189
2340 -
2341void QFileDialogComboBox::showPopup() -
2342{ -
2343 if (model()->rowCount() > 1)
never evaluated: model()->rowCount() > 1
0
2344 QComboBox::showPopup();
never executed: QComboBox::showPopup();
0
2345 -
2346 urlModel->setUrls(QList<QUrl>()); -
2347 QList<QUrl> list; -
2348 QModelIndex idx = d_ptr->model->index(d_ptr->rootPath()); -
2349 while (idx.isValid()) {
never evaluated: idx.isValid()
0
2350 QUrl url = QUrl::fromLocalFile(idx.data(QFileSystemModel::FilePathRole).toString()); -
2351 if (url.isValid())
never evaluated: url.isValid()
0
2352 list.append(url);
never executed: list.append(url);
0
2353 idx = idx.parent(); -
2354 }
never executed: }
0
2355 -
2356 list.append(QUrl::fromLocalFile(QLatin1String(""))); -
2357 urlModel->addUrls(list, 0); -
2358 idx = model()->index(model()->rowCount() - 1, 0); -
2359 -
2360 -
2361 QList<QUrl> urls; -
2362 for (int i = 0; i < m_history.count(); ++i) {
never evaluated: i < m_history.count()
0
2363 QUrl path = QUrl::fromLocalFile(m_history.at(i)); -
2364 if (!urls.contains(path))
never evaluated: !urls.contains(path)
0
2365 urls.prepend(path);
never executed: urls.prepend(path);
0
2366 }
never executed: }
0
2367 if (urls.count() > 0) {
never evaluated: urls.count() > 0
0
2368 model()->insertRow(model()->rowCount()); -
2369 idx = model()->index(model()->rowCount()-1, 0); -
2370 -
2371 model()->setData(idx, QFileDialog::tr("Recent Places")); -
2372 QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model()); -
2373 if (m) {
never evaluated: m
0
2374 Qt::ItemFlags flags = m->flags(idx); -
2375 flags &= ~Qt::ItemIsEnabled; -
2376 m->item(idx.row(), idx.column())->setFlags(flags); -
2377 }
never executed: }
0
2378 urlModel->addUrls(urls, -1, false); -
2379 }
never executed: }
0
2380 setCurrentIndex(0); -
2381 -
2382 QComboBox::showPopup(); -
2383}
never executed: }
0
2384 -
2385 -
2386void QFileDialogComboBox::paintEvent(QPaintEvent *) -
2387{ -
2388 QStylePainter painter(this); -
2389 painter.setPen(palette().color(QPalette::Text)); -
2390 -
2391 -
2392 QStyleOptionComboBox opt; -
2393 initStyleOption(&opt); -
2394 -
2395 QRect editRect = style()->subControlRect(QStyle::CC_ComboBox, &opt, -
2396 QStyle::SC_ComboBoxEditField, this); -
2397 int size = editRect.width() - opt.iconSize.width() - 4; -
2398 opt.currentText = opt.fontMetrics.elidedText(opt.currentText, Qt::ElideMiddle, size); -
2399 painter.drawComplexControl(QStyle::CC_ComboBox, opt); -
2400 -
2401 -
2402 painter.drawControl(QStyle::CE_ComboBoxLabel, opt); -
2403}
executed: }
Execution Count:58
58
2404 -
2405QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent) -
2406{ -
2407}
executed: }
Execution Count:189
189
2408 -
2409void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) -
2410{ -
2411 d_ptr = d_pointer; -
2412 setSelectionBehavior(QAbstractItemView::SelectRows); -
2413 setWrapping(true); -
2414 setResizeMode(QListView::Adjust); -
2415 setEditTriggers(QAbstractItemView::EditKeyPressed); -
2416 setContextMenuPolicy(Qt::CustomContextMenu); -
2417 -
2418 setDragDropMode(QAbstractItemView::InternalMove); -
2419 -
2420}
executed: }
Execution Count:189
189
2421 -
2422QSize QFileDialogListView::sizeHint() const -
2423{ -
2424 int height = qMax(10, sizeHintForRow(0)); -
2425 return QSize(QListView::sizeHint().width() * 2, height * 30);
executed: return QSize(QListView::sizeHint().width() * 2, height * 30);
Execution Count:190
190
2426} -
2427 -
2428void QFileDialogListView::keyPressEvent(QKeyEvent *e) -
2429{ -
2430 -
2431 -
2432 -
2433 -
2434 -
2435 -
2436 -
2437 if (!d_ptr->itemViewKeyboardEvent(e))
evaluated: !d_ptr->itemViewKeyboardEvent(e)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
2438 QListView::keyPressEvent(e);
executed: QListView::keyPressEvent(e);
Execution Count:12
12
2439 e->accept(); -
2440}
executed: }
Execution Count:14
14
2441 -
2442QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) -
2443{ -
2444}
executed: }
Execution Count:189
189
2445 -
2446void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) -
2447{ -
2448 d_ptr = d_pointer; -
2449 setSelectionBehavior(QAbstractItemView::SelectRows); -
2450 setRootIsDecorated(false); -
2451 setItemsExpandable(false); -
2452 setSortingEnabled(true); -
2453 header()->setSortIndicator(0, Qt::AscendingOrder); -
2454 header()->setStretchLastSection(false); -
2455 setTextElideMode(Qt::ElideMiddle); -
2456 setEditTriggers(QAbstractItemView::EditKeyPressed); -
2457 setContextMenuPolicy(Qt::CustomContextMenu); -
2458 -
2459 setDragDropMode(QAbstractItemView::InternalMove); -
2460 -
2461}
executed: }
Execution Count:189
189
2462 -
2463void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) -
2464{ -
2465 -
2466 -
2467 -
2468 -
2469 -
2470 -
2471 -
2472 if (!d_ptr->itemViewKeyboardEvent(e))
never evaluated: !d_ptr->itemViewKeyboardEvent(e)
0
2473 QTreeView::keyPressEvent(e);
never executed: QTreeView::keyPressEvent(e);
0
2474 e->accept(); -
2475}
never executed: }
0
2476 -
2477QSize QFileDialogTreeView::sizeHint() const -
2478{ -
2479 int height = qMax(10, sizeHintForRow(0)); -
2480 QSize sizeHint = header()->sizeHint(); -
2481 return QSize(sizeHint.width() * 4, height * 30);
executed: return QSize(sizeHint.width() * 4, height * 30);
Execution Count:193
193
2482} -
2483 -
2484 -
2485 -
2486 -
2487 -
2488void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) -
2489{ -
2490 -
2491 -
2492 -
2493 -
2494 -
2495 -
2496 -
2497 int key = e->key(); -
2498 QLineEdit::keyPressEvent(e); -
2499 if (key != Qt::Key_Escape)
evaluated: key != Qt::Key_Escape
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-16
2500 e->accept();
executed: e->accept();
Execution Count:16
16
2501 if (hideOnEsc && (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter)) {
partially evaluated: hideOnEsc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
never evaluated: key == Qt::Key_Escape
never evaluated: key == Qt::Key_Return
never evaluated: key == Qt::Key_Enter
0-17
2502 e->accept(); -
2503 hide(); -
2504 d_ptr->currentView()->setFocus(Qt::ShortcutFocusReason); -
2505 }
never executed: }
0
2506}
executed: }
Execution Count:17
17
2507 -
2508 -
2509 -
2510QString QFSCompleter::pathFromIndex(const QModelIndex &index) const -
2511{ -
2512 const QFileSystemModel *dirModel; -
2513 if (proxyModel)
partially evaluated: proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2514 dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
never executed: dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
0
2515 else -
2516 dirModel = sourceModel;
executed: dirModel = sourceModel;
Execution Count:1
1
2517 QString currentLocation = dirModel->rootPath(); -
2518 QString path = index.data(QFileSystemModel::FilePathRole).toString(); -
2519 if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
partially evaluated: !currentLocation.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: path.startsWith(currentLocation)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2520 -
2521 if (currentLocation == QDir::separator())
partially evaluated: currentLocation == QDir::separator()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2522 return path.mid(currentLocation.length());
executed: return path.mid(currentLocation.length());
Execution Count:1
1
2523 -
2524 if (currentLocation.endsWith(QLatin1Char('/')))
never evaluated: currentLocation.endsWith(QLatin1Char('/'))
0
2525 return path.mid(currentLocation.length());
never executed: return path.mid(currentLocation.length());
0
2526 else -
2527 return path.mid(currentLocation.length()+1);
never executed: return path.mid(currentLocation.length()+1);
0
2528 } -
2529 return index.data(QFileSystemModel::FilePathRole).toString();
never executed: return index.data(QFileSystemModel::FilePathRole).toString();
0
2530} -
2531 -
2532QStringList QFSCompleter::splitPath(const QString &path) const -
2533{ -
2534 if (path.isEmpty())
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:368
0-368
2535 return QStringList(completionPrefix());
never executed: return QStringList(completionPrefix());
0
2536 -
2537 QString pathCopy = QDir::toNativeSeparators(path); -
2538 QString sep = QDir::separator(); -
2539 bool expanded; -
2540 pathCopy = qt_tildeExpansion(pathCopy, &expanded); -
2541 if (expanded) {
partially evaluated: expanded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:368
0-368
2542 QFileSystemModel *dirModel; -
2543 if (proxyModel)
never evaluated: proxyModel
0
2544 dirModel = qobject_cast<QFileSystemModel *>(proxyModel->sourceModel());
never executed: dirModel = qobject_cast<QFileSystemModel *>(proxyModel->sourceModel());
0
2545 else -
2546 dirModel = sourceModel;
never executed: dirModel = sourceModel;
0
2547 dirModel->fetchMore(dirModel->index(pathCopy)); -
2548 }
never executed: }
0
2549 -
2550 -
2551 QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); -
2552 QStringList parts = pathCopy.split(re); -
2553 if (pathCopy[0] == sep[0])
evaluated: pathCopy[0] == sep[0]
TRUEFALSE
yes
Evaluation Count:303
yes
Evaluation Count:65
65-303
2554 parts[0] = sep[0];
executed: parts[0] = sep[0];
Execution Count:303
303
2555 -
2556 -
2557 -
2558 -
2559 -
2560 bool startsFromRoot = pathCopy[0] == sep[0]; -
2561 -
2562 if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {
evaluated: parts.count() == 1
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:342
partially evaluated: parts.count() > 1
TRUEFALSE
yes
Evaluation Count:342
no
Evaluation Count:0
evaluated: !startsFromRoot
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:303
0-342
2563 const QFileSystemModel *dirModel; -
2564 if (proxyModel)
partially evaluated: proxyModel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-65
2565 dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
never executed: dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
0
2566 else -
2567 dirModel = sourceModel;
executed: dirModel = sourceModel;
Execution Count:65
65
2568 QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath()); -
2569 -
2570 -
2571 -
2572 -
2573 if (currentLocation.contains(sep) && path != currentLocation) {
partially evaluated: currentLocation.contains(sep)
TRUEFALSE
yes
Evaluation Count:65
no
Evaluation Count:0
partially evaluated: path != currentLocation
TRUEFALSE
yes
Evaluation Count:65
no
Evaluation Count:0
0-65
2574 QStringList currentLocationList = splitPath(currentLocation); -
2575 while (!currentLocationList.isEmpty()
evaluated: !currentLocationList.isEmpty()
TRUEFALSE
yes
Evaluation Count:108
yes
Evaluation Count:34
34-108
2576 && parts.count() > 0
evaluated: parts.count() > 0
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:4
4-104
2577 && parts.at(0) == QLatin1String("..")) {
evaluated: parts.at(0) == QLatin1String("..")
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:27
27-77
2578 parts.removeFirst(); -
2579 currentLocationList.removeLast(); -
2580 }
executed: }
Execution Count:77
77
2581 if (!currentLocationList.isEmpty() && currentLocationList.last().isEmpty())
evaluated: !currentLocationList.isEmpty()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:34
evaluated: currentLocationList.last().isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:25
6-34
2582 currentLocationList.removeLast();
executed: currentLocationList.removeLast();
Execution Count:6
6
2583 return currentLocationList + parts;
executed: return currentLocationList + parts;
Execution Count:65
65
2584 } -
2585 }
never executed: }
0
2586 return parts;
executed: return parts;
Execution Count:303
303
2587} -
2588 -
2589 -
2590 -
2591 -
2592 -
2593 -
2594 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial