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

Generated by Squish Coco Non-Commercial