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