| 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) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QUrl, Q_QGS_lastVisitedDir::innerFunction, Q_QGS_lastVisitedDir::guard> lastVisitedDir; | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | QFileDialog::~QFileDialog() | - | ||||||||||||||||||
| 49 | { | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 52 | d->saveSettings(); | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | } | - | ||||||||||||||||||
| 55 | void QFileDialog::setSidebarUrls(const QList<QUrl> &urls) | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 58 | if (!d->nativeDialogInUse) | - | ||||||||||||||||||
| 59 | d->qFileDialogUi->sidebar->setUrls(urls); | - | ||||||||||||||||||
| 60 | } | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | QList<QUrl> QFileDialog::sidebarUrls() const | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 69 | return (d->nativeDialogInUse ? QList<QUrl>() : d->qFileDialogUi->sidebar->urls()); | - | ||||||||||||||||||
| 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()) { | - | ||||||||||||||||||
| 83 | stream << d->qFileDialogUi->splitter->saveState(); | - | ||||||||||||||||||
| 84 | stream << d->qFileDialogUi->sidebar->urls(); | - | ||||||||||||||||||
| 85 | } else { | - | ||||||||||||||||||
| 86 | stream << d->splitterState; | - | ||||||||||||||||||
| 87 | stream << d->sidebarUrls; | - | ||||||||||||||||||
| 88 | } | - | ||||||||||||||||||
| 89 | stream << history(); | - | ||||||||||||||||||
| 90 | stream << *lastVisitedDir(); | - | ||||||||||||||||||
| 91 | if (d->usingWidgets()) | - | ||||||||||||||||||
| 92 | stream << d->qFileDialogUi->treeView->header()->saveState(); | - | ||||||||||||||||||
| 93 | else | - | ||||||||||||||||||
| 94 | stream << d->headerData; | - | ||||||||||||||||||
| 95 | stream << qint32(viewMode()); | - | ||||||||||||||||||
| 96 | return data; | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 104 | return false; | - | ||||||||||||||||||
| 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 || (v != 3 && v != 4)) | - | ||||||||||||||||||
| 114 | return false; | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | stream >> d->splitterState | - | ||||||||||||||||||
| 117 | >> d->sidebarUrls | - | ||||||||||||||||||
| 118 | >> history; | - | ||||||||||||||||||
| 119 | if (v == 3) { | - | ||||||||||||||||||
| 120 | QString currentDirectoryString; | - | ||||||||||||||||||
| 121 | stream >> currentDirectoryString; | - | ||||||||||||||||||
| 122 | currentDirectory = QUrl::fromLocalFile(currentDirectoryString); | - | ||||||||||||||||||
| 123 | } else { | - | ||||||||||||||||||
| 124 | stream >> currentDirectory; | - | ||||||||||||||||||
| 125 | } | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 133 | return true; | - | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | return d->restoreWidgetState(history, -1); | - | ||||||||||||||||||
| 136 | } | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | void QFileDialog::changeEvent(QEvent *e) | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 144 | if (e->type() == QEvent::LanguageChange) { | - | ||||||||||||||||||
| 145 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 146 | d->retranslateStrings(); | - | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | QDialog::changeEvent(e); | - | ||||||||||||||||||
| 149 | } | - | ||||||||||||||||||
| 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 | defaultFileTypes(true),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__ ":" "542""547"), d, qFlagLocation("1""_q_emitUrlSelected(QUrl)" "\0" __FILE__ ":" "542""547")); | - | ||||||||||||||||||
| 175 | QObject::connect(h, qFlagLocation("2""filesSelected(QList<QUrl>)" "\0" __FILE__ ":" "543""548"), d, qFlagLocation("1""_q_emitUrlsSelected(QList<QUrl>)" "\0" __FILE__ ":" "543""548")); | - | ||||||||||||||||||
| 176 | QObject::connect(h, qFlagLocation("2""currentChanged(QUrl)" "\0" __FILE__ ":" "544""549"), d, qFlagLocation("1""_q_nativeCurrentChanged(QUrl)" "\0" __FILE__ ":" "544""549")); | - | ||||||||||||||||||
| 177 | QObject::connect(h, qFlagLocation("2""directoryEntered(QUrl)" "\0" __FILE__ ":" "545""550"), d, qFlagLocation("1""_q_nativeEnterDirectory(QUrl)" "\0" __FILE__ ":" "545""550")); | - | ||||||||||||||||||
| 178 | QObject::connect(h, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "546""551"), d, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "546""551")); | - | ||||||||||||||||||
| 179 | static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); | - | ||||||||||||||||||
| 180 | nativeDialogInUse = true; | - | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 189 | options->setSidebarUrls(qFileDialogUi->sidebar->urls()); | - | ||||||||||||||||||
| 190 | if (options->initiallySelectedNameFilter().isEmpty()) | - | ||||||||||||||||||
| 191 | options->setInitiallySelectedNameFilter(q->selectedNameFilter()); | - | ||||||||||||||||||
| 192 | if (options->initiallySelectedFiles().isEmpty()) | - | ||||||||||||||||||
| 193 | options->setInitiallySelectedFiles(userSelectedFiles()); | - | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) | - | ||||||||||||||||||
| 197 | { | - | ||||||||||||||||||
| 198 | if (code == QDialog::Accepted) { | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 204 | } | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | void QFileDialogPrivate::retranslateWindowTitle() | - | ||||||||||||||||||
| 207 | { | - | ||||||||||||||||||
| 208 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 209 | if (!useDefaultCaption || setWindowTitle != q->windowTitle()) | - | ||||||||||||||||||
| 210 | return; | - | ||||||||||||||||||
| 211 | if (q->acceptMode() == QFileDialog::AcceptOpen) { | - | ||||||||||||||||||
| 212 | const QFileDialog::FileMode fileMode = q->fileMode(); | - | ||||||||||||||||||
| 213 | if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory) | - | ||||||||||||||||||
| 214 | q->setWindowTitle(QFileDialog::tr("Find Directory")); | - | ||||||||||||||||||
| 215 | else | - | ||||||||||||||||||
| 216 | q->setWindowTitle(QFileDialog::tr("Open")); | - | ||||||||||||||||||
| 217 | } else | - | ||||||||||||||||||
| 218 | q->setWindowTitle(QFileDialog::tr("Save As")); | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | setWindowTitle = q->windowTitle(); | - | ||||||||||||||||||
| 221 | } | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | void QFileDialogPrivate::setLastVisitedDirectory(const QUrl &dir) | - | ||||||||||||||||||
| 224 | { | - | ||||||||||||||||||
| 225 | *lastVisitedDir() = dir; | - | ||||||||||||||||||
| 226 | } | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | void QFileDialogPrivate::updateLookInLabel() | - | ||||||||||||||||||
| 229 | { | - | ||||||||||||||||||
| 230 | if (options->isLabelExplicitlySet(QFileDialogOptions::LookIn)) | - | ||||||||||||||||||
| 231 | setLabelTextControl(QFileDialog::LookIn, options->labelText(QFileDialogOptions::LookIn)); | - | ||||||||||||||||||
| 232 | } | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | void QFileDialogPrivate::updateFileNameLabel() | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | if (options->isLabelExplicitlySet(QFileDialogOptions::FileName)) { | - | ||||||||||||||||||
| 237 | setLabelTextControl(QFileDialog::FileName, options->labelText(QFileDialogOptions::FileName)); | - | ||||||||||||||||||
| 238 | } else { | - | ||||||||||||||||||
| 239 | switch (q_func()->fileMode()) { | - | ||||||||||||||||||
| 240 | case QFileDialog::DirectoryOnly: | - | ||||||||||||||||||
| 241 | case QFileDialog::Directory: | - | ||||||||||||||||||
| 242 | setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:")); | - | ||||||||||||||||||
| 243 | break; | - | ||||||||||||||||||
| 244 | default: | - | ||||||||||||||||||
| 245 | setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("File &name:")); | - | ||||||||||||||||||
| 246 | break; | - | ||||||||||||||||||
| 247 | } | - | ||||||||||||||||||
| 248 | } | - | ||||||||||||||||||
| 249 | } | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | void QFileDialogPrivate::updateFileTypeLabel() | - | ||||||||||||||||||
| 252 | { | - | ||||||||||||||||||
| 253 | if (options->isLabelExplicitlySet(QFileDialogOptions::FileType)) | - | ||||||||||||||||||
| 254 | setLabelTextControl(QFileDialog::FileType, options->labelText(QFileDialogOptions::FileType)); | - | ||||||||||||||||||
| 255 | } | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder) | - | ||||||||||||||||||
| 258 | { | - | ||||||||||||||||||
| 259 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | if (saveAsOnFolder) { | - | ||||||||||||||||||
| 262 | setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Open")); | - | ||||||||||||||||||
| 263 | } else if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) { | - | ||||||||||||||||||
| 264 | setLabelTextControl(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept)); | - | ||||||||||||||||||
| 265 | return; | - | ||||||||||||||||||
| 266 | } else { | - | ||||||||||||||||||
| 267 | switch (q->fileMode()) { | - | ||||||||||||||||||
| 268 | case QFileDialog::DirectoryOnly: | - | ||||||||||||||||||
| 269 | case QFileDialog::Directory: | - | ||||||||||||||||||
| 270 | setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose")); | - | ||||||||||||||||||
| 271 | break; | - | ||||||||||||||||||
| 272 | default: | - | ||||||||||||||||||
| 273 | setLabelTextControl(QFileDialog::Accept, | - | ||||||||||||||||||
| 274 | q->acceptMode() == QFileDialog::AcceptOpen ? | - | ||||||||||||||||||
| 275 | QFileDialog::tr("&Open") : | - | ||||||||||||||||||
| 276 | QFileDialog::tr("&Save")); | - | ||||||||||||||||||
| 277 | break; | - | ||||||||||||||||||
| 278 | } | - | ||||||||||||||||||
| 279 | } | - | ||||||||||||||||||
| 280 | } | - | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | void QFileDialogPrivate::updateCancelButtonText() | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | if (options->isLabelExplicitlySet(QFileDialogOptions::Reject)) | - | ||||||||||||||||||
| 285 | setLabelTextControl(QFileDialog::Reject, options->labelText(QFileDialogOptions::Reject)); | - | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | void QFileDialogPrivate::retranslateStrings() | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | if (defaultFileTypes)options->useDefaultNameFilters()
| 0 | ||||||||||||||||||
| 293 | q->setNameFilter(QFileDialogQFileDialogOptions::tr("All Files (*)"));defaultNameFilterString()); never executed: q->setNameFilter(QFileDialogOptions::defaultNameFilterString()); | 0 | ||||||||||||||||||
| 294 | if (!usingWidgets())(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) | - | ||||||||||||||||||
| 325 | q->fileSelected(files.first()); | - | ||||||||||||||||||
| 326 | } | - | ||||||||||||||||||
| 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
| 0 | ||||||||||||||||||
| 336 | || q->testAttribute(Qt::WA_DontShowOnScreen))
| 0 | ||||||||||||||||||
return false;
| ||||||||||||||||||||
if
| ||||||||||||||||||||
| 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 !nativeDialogInUse && qFileDialogUi; | - | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | void QFileDialog::setOption(Option option, bool on) | - | ||||||||||||||||||
| 351 | { | - | ||||||||||||||||||
| 352 | const QFileDialog::Options previousOptions = options(); | - | ||||||||||||||||||
| 353 | if (!(previousOptions & option) != !on) | - | ||||||||||||||||||
| 354 | setOptions(previousOptions ^ option); | - | ||||||||||||||||||
| 355 | } | - | ||||||||||||||||||
| 356 | bool QFileDialog::testOption(Option option) const | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 359 | return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option)); | - | ||||||||||||||||||
| 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 | if (options & DontUseCustomDirectoryIcons)providerOptions|=.setFlag(QFileIconProvider::DontUseCustomDirectoryIcons; | - | ||||||||||||||||||
| else | ||||||||||||||||||||
| providerOptions, | ||||||||||||||||||||
| 388 | options & = ~QFileIconProvider::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 QFileDialog::Options(int(d->options->options())); | - | ||||||||||||||||||
| 404 | } | - | ||||||||||||||||||
| 405 | void QFileDialog::open(QObject *receiver, const char *member) | - | ||||||||||||||||||
| 406 | { | - | ||||||||||||||||||
| 407 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 408 | const char *signal = (fileMode() == ExistingFiles) ? qFlagLocation("2""filesSelected(QStringList)" "\0" __FILE__ ":" "820""824") | - | ||||||||||||||||||
| 409 | : qFlagLocation("2""fileSelected(QString)" "\0" __FILE__ ":" "821""825"); | - | ||||||||||||||||||
| 410 | connect(this, signal, receiver, member); | - | ||||||||||||||||||
| 411 | d->signalToDisconnectOnClose = signal; | - | ||||||||||||||||||
| 412 | d->receiverToDisconnectOnClose = receiver; | - | ||||||||||||||||||
| 413 | d->memberToDisconnectOnClose = member; | - | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | QDialog::open(); | - | ||||||||||||||||||
| 416 | } | - | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | void QFileDialog::setVisible(bool visible) | - | ||||||||||||||||||
| 423 | { | - | ||||||||||||||||||
| 424 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 425 | if (visible){ | - | ||||||||||||||||||
| 426 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) | - | ||||||||||||||||||
| 427 | return; | - | ||||||||||||||||||
| 428 | } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) | - | ||||||||||||||||||
| 429 | return; | - | ||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | if (d->canBeNativeDialog()){ | - | ||||||||||||||||||
| 432 | if (d->setNativeDialogVisible(visible)){ | - | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | setAttribute(Qt::WA_DontShowOnScreen); | - | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | if (!d->nativeDialogInUse) | - | ||||||||||||||||||
| 439 | d->completer->setModel(0); | - | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | } else { | - | ||||||||||||||||||
| 442 | d->createWidgets(); | - | ||||||||||||||||||
| 443 | setAttribute(Qt::WA_DontShowOnScreen, false); | - | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | if (!d->nativeDialogInUse) { | - | ||||||||||||||||||
| 446 | if (d->proxyModel != 0) | - | ||||||||||||||||||
| 447 | d->completer->setModel(d->proxyModel); | - | ||||||||||||||||||
| 448 | else | - | ||||||||||||||||||
| 449 | d->completer->setModel(d->model); | - | ||||||||||||||||||
| 450 | } | - | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | } | - | ||||||||||||||||||
| 453 | } | - | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | if (d->usingWidgets()) | - | ||||||||||||||||||
| 456 | d->qFileDialogUi->fileNameEdit->setFocus(); | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | QDialog::setVisible(visible); | - | ||||||||||||||||||
| 459 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 473 | void QFileDialog::setDirectory(const QString &directory) | - | ||||||||||||||||||
| 474 | { | - | ||||||||||||||||||
| 475 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 476 | QString newDirectory = directory; | - | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | if (!directory.isEmpty()) | - | ||||||||||||||||||
| 479 | newDirectory = QDir::cleanPath(directory); | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | if (!directory.isEmpty() && newDirectory.isEmpty()) | - | ||||||||||||||||||
| 482 | return; | - | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | QUrl newDirUrl = QUrl::fromLocalFile(newDirectory); | - | ||||||||||||||||||
| 485 | QFileDialogPrivate::setLastVisitedDirectory(newDirUrl); | - | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | d->options->setInitialDirectory(QUrl::fromLocalFile(directory)); | - | ||||||||||||||||||
| 488 | if (!d->usingWidgets()) { | - | ||||||||||||||||||
| 489 | d->setDirectory_sys(newDirUrl); | - | ||||||||||||||||||
| 490 | return; | - | ||||||||||||||||||
| 491 | } | - | ||||||||||||||||||
| 492 | if (d->rootPath() == newDirectory) | - | ||||||||||||||||||
| 493 | return; | - | ||||||||||||||||||
| 494 | QModelIndex root = d->model->setRootPath(newDirectory); | - | ||||||||||||||||||
| 495 | if (!d->nativeDialogInUse) { | - | ||||||||||||||||||
| 496 | d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); | - | ||||||||||||||||||
| 497 | if (root != d->rootIndex()) { | - | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | if (directory.endsWith(QLatin1Char('/'))) | - | ||||||||||||||||||
| 500 | d->completer->setCompletionPrefix(newDirectory); | - | ||||||||||||||||||
| 501 | else | - | ||||||||||||||||||
| 502 | d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/')); | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | d->setRootIndex(root); | - | ||||||||||||||||||
| 505 | } | - | ||||||||||||||||||
| 506 | d->qFileDialogUi->listView->selectionModel()->clear(); | - | ||||||||||||||||||
| 507 | } | - | ||||||||||||||||||
| 508 | } | - | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | QDir QFileDialog::directory() const | - | ||||||||||||||||||
| 514 | { | - | ||||||||||||||||||
| 515 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 516 | if (d->nativeDialogInUse) { | - | ||||||||||||||||||
| 517 | QString dir = d->directory_sys().toLocalFile(); | - | ||||||||||||||||||
| 518 | return QDir(dir.isEmpty() ? d->options->initialDirectory().toLocalFile() : dir); | - | ||||||||||||||||||
| 519 | } | - | ||||||||||||||||||
| 520 | return d->rootPath(); | - | ||||||||||||||||||
| 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(!!(
| 0 | ||||||||||||||||||
| 536 | QMessageLogger(__FILE__, 985989, __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) | - | ||||||||||||||||||
| 548 | return d->directory_sys(); | - | ||||||||||||||||||
| 549 | else | - | ||||||||||||||||||
| 550 | return QUrl::fromLocalFile(directory().absolutePath()); | - | ||||||||||||||||||
| 551 | } | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | static inline bool isCaseSensitiveFileSystem(const QString &path) | - | ||||||||||||||||||
| 555 | { | - | ||||||||||||||||||
| 556 | (void)path; | - | ||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | - | |||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | return true; | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | } | - | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | - | |||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | static inline QString fileFromPath(const QString &rootPath, QString path) | - | ||||||||||||||||||
| 571 | { | - | ||||||||||||||||||
| 572 | if (!QFileInfo(path).isAbsolute()) | - | ||||||||||||||||||
| 573 | return path; | - | ||||||||||||||||||
| 574 | if (path.startsWith(rootPath, isCaseSensitiveFileSystem(rootPath) ? Qt::CaseSensitive : Qt::CaseInsensitive)) | - | ||||||||||||||||||
| 575 | path.remove(0, rootPath.size()); | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | if (path.isEmpty()) | - | ||||||||||||||||||
| 578 | return path; | - | ||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | if (path.at(0) == QDir::separator() | - | ||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | - | |||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | ) { | - | ||||||||||||||||||
| 586 | path.remove(0, 1); | - | ||||||||||||||||||
| 587 | } | - | ||||||||||||||||||
| 588 | return path; | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 600 | return; | - | ||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | if (!d->usingWidgets()) { | - | ||||||||||||||||||
| 603 | QUrl url = QUrl::fromLocalFile(filename); | - | ||||||||||||||||||
| 604 | if (QFileInfo(filename).isRelative()) { | - | ||||||||||||||||||
| 605 | QDir dir(d->options->initialDirectory().toLocalFile()); | - | ||||||||||||||||||
| 606 | url = QUrl::fromLocalFile(dir.absoluteFilePath(filename)); | - | ||||||||||||||||||
| 607 | } | - | ||||||||||||||||||
| 608 | d->selectFile_sys(url); | - | ||||||||||||||||||
| 609 | d->options->setInitiallySelectedFiles(QList<QUrl>() << url); | - | ||||||||||||||||||
| 610 | return; | - | ||||||||||||||||||
| 611 | } | - | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | if (!QDir::isRelativePath(filename)) { | - | ||||||||||||||||||
| 614 | QFileInfo info(filename); | - | ||||||||||||||||||
| 615 | QString filenamePath = info.absoluteDir().path(); | - | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | if (d->model->rootPath() != filenamePath) | - | ||||||||||||||||||
| 618 | setDirectory(filenamePath); | - | ||||||||||||||||||
| 619 | } | - | ||||||||||||||||||
| 620 | - | |||||||||||||||||||
| 621 | QModelIndex index = d->model->index(filename); | - | ||||||||||||||||||
| 622 | d->qFileDialogUi->listView->selectionModel()->clear(); | - | ||||||||||||||||||
| 623 | if (!isVisible() || !d->lineEdit()->hasFocus()) | - | ||||||||||||||||||
| 624 | d->lineEdit()->setText(index.isValid() ? index.data().toString() : fileFromPath(d->rootPath(), filename)); | - | ||||||||||||||||||
| 625 | } | - | ||||||||||||||||||
| 626 | void QFileDialog::selectUrl(const QUrl &url) | - | ||||||||||||||||||
| 627 | { | - | ||||||||||||||||||
| 628 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 629 | if (!url.isValid()) | - | ||||||||||||||||||
| 630 | return; | - | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | if (d->nativeDialogInUse) | - | ||||||||||||||||||
| 633 | d->selectFile_sys(url); | - | ||||||||||||||||||
| 634 | else if (url.isLocalFile()) | - | ||||||||||||||||||
| 635 | selectFile(url.toLocalFile()); | - | ||||||||||||||||||
| 636 | else | - | ||||||||||||||||||
| 637 | QMessageLogger(__FILE__, 10951099, __PRETTY_FUNCTION__).warning("Non-native QFileDialog supports only local files"); | - | ||||||||||||||||||
| 638 | } | - | ||||||||||||||||||
| 639 | - | |||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | __attribute__((visibility("default"))) QString qt_tildeExpansion(const QString &path, bool *expanded = 0) | - | ||||||||||||||||||
| 642 | { | - | ||||||||||||||||||
| 643 | if (expanded != 0) | 0 | ||||||||||||||||||
*expanded = false;if (!path.startsWith(QLatin1Char('~'))
| ||||||||||||||||||||
| 644 | return never executed: path;return path;never executed: return path; | 0 | ||||||||||||||||||
| 645 | QString retint separatorPosition = path; | - | ||||||||||||||||||
| QStringList tokens = ret.splitindexOf(QDir::separator()); | ||||||||||||||||||||
| 646 | if (tokens.first() == QLatin1String("~")) { | 0 | ||||||||||||||||||
retseparatorPosition < 0
| ||||||||||||||||||||
| 647 | separatorPosition = path never executed: separatorPosition = path.size();never executed: .replacesize();separatorPosition = path.size();never executed: separatorPosition = path.size(); | 0 | ||||||||||||||||||
| 648 | if (0,separatorPosition ==
| 0 | ||||||||||||||||||
| 649 | return never executed: return QDir::homePath() + path.midRef(1);never executed: return QDir::homePath() + path.midRef(1);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 | QStringconst QByteArray userName = tokens.first(); | - | ||||||||||||||||||
| userNamepath.removemidRef(01, 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.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); | - | ||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | if (err
| 0 | ||||||||||||||||||
| 667 | return never executed: retpath;return path;never executed: return path; | 0 | ||||||||||||||||||
| 668 | const QString homePath = QString::fromLocal8Bit(pw.pw_dir); | - | ||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | retreturn never executed: return homePath + path.midRef(separatorPosition);never executed: homePath + path.replacemidRef(0, tokens.first().length(), homePathseparatorPosition);return homePath + path.midRef(separatorPosition);never executed: return homePath + path.midRef(separatorPosition); | 0 | ||||||||||||||||||
| 677 | } | - | ||||||||||||||||||
| if (expanded != 0) | ||||||||||||||||||||
| *expanded = true; | ||||||||||||||||||||
| return ret;} | ||||||||||||||||||||
| 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('"'))) { | - | ||||||||||||||||||
| 690 | - | |||||||||||||||||||
| 691 | const QString prefix = q->directory().absolutePath() + QDir::separator(); | - | ||||||||||||||||||
| 692 | if (QFile::exists(prefix + editText)) | - | ||||||||||||||||||
| 693 | files << editText; | - | ||||||||||||||||||
| 694 | else | - | ||||||||||||||||||
| 695 | files << qt_tildeExpansion(editText); | - | ||||||||||||||||||
| 696 | - | |||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 | - | |||||||||||||||||||
| 700 | } else { | - | ||||||||||||||||||
| 701 | - | |||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | QStringList tokens = editText.split(QLatin1Char('\"')); | - | ||||||||||||||||||
| 704 | for (int i=0; i<tokens.size(); ++i) { | - | ||||||||||||||||||
| 705 | if ((i % 2) == 0) | - | ||||||||||||||||||
| 706 | continue; | - | ||||||||||||||||||
| 707 | - | |||||||||||||||||||
| 708 | const QString token = tokens.at(i); | - | ||||||||||||||||||
| 709 | const QString prefix = q->directory().absolutePath() + QDir::separator(); | - | ||||||||||||||||||
| 710 | if (QFile::exists(prefix + token)) | - | ||||||||||||||||||
| 711 | files << token; | - | ||||||||||||||||||
| 712 | else | - | ||||||||||||||||||
| 713 | files << qt_tildeExpansion(token); | - | ||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | } | - | ||||||||||||||||||
| 718 | } | - | ||||||||||||||||||
| 719 | return addDefaultSuffixToFiles(files); | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(selectedRows)>::type> _container_((selectedRows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QModelIndex &index = *_container_.i; _container_.control; _container_.control =: 0selectedRows) | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(typedFilesList)>::type> _container_((typedFilesList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &path = *_container_.i; _container_.control; _container_.control =: 0typedFilesList) | - | ||||||||||||||||||
| 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(); ++i) { | - | ||||||||||||||||||
| 751 | QString name = toInternal(filesToFix.at(i)); | - | ||||||||||||||||||
| 752 | QFileInfo info(name); | - | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | const QString defaultSuffix = options->defaultSuffix(); | - | ||||||||||||||||||
| 755 | if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1) | - | ||||||||||||||||||
| 756 | name += QLatin1Char('.') + defaultSuffix; | - | ||||||||||||||||||
| 757 | if (info.isAbsolute()) { | - | ||||||||||||||||||
| 758 | files.append(name); | - | ||||||||||||||||||
| 759 | } else { | - | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | - | |||||||||||||||||||
| 762 | - | |||||||||||||||||||
| 763 | QString path = rootPath(); | - | ||||||||||||||||||
| 764 | if (!path.endsWith(QLatin1Char('/'))) | - | ||||||||||||||||||
| 765 | path += QLatin1Char('/'); | - | ||||||||||||||||||
| 766 | path += name; | - | ||||||||||||||||||
| 767 | files.append(path); | - | ||||||||||||||||||
| 768 | } | - | ||||||||||||||||||
| 769 | } | - | ||||||||||||||||||
| 770 | return files; | - | ||||||||||||||||||
| 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; ++i) { | - | ||||||||||||||||||
| 779 | QUrl url = urlsToFix.at(i); | - | ||||||||||||||||||
| 780 | - | |||||||||||||||||||
| 781 | const QString defaultSuffix = options->defaultSuffix(); | - | ||||||||||||||||||
| 782 | if (!defaultSuffix.isEmpty() && !url.path().endsWith(QLatin1Char('/')) && url.path().lastIndexOf(QLatin1Char('.')) == -1) | - | ||||||||||||||||||
| 783 | url.setPath(url.path() + QLatin1Char('.') + defaultSuffix); | - | ||||||||||||||||||
| 784 | urls.append(url); | - | ||||||||||||||||||
| 785 | } | - | ||||||||||||||||||
| 786 | return urls; | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(userSelectedFiles)>::type> _container_((userSelectedFiles)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QUrl &file = *_container_.i; _container_.control; _container_.control =: 0userSelectedFiles) | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(selectedFileList)>::type> _container_((selectedFileList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &file = *_container_.i; _container_.control; _container_.control =: 0selectedFileList) | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 828 | return QStringList(); | - | ||||||||||||||||||
| 829 | - | |||||||||||||||||||
| 830 | QString sep(QLatin1String(";;")); | - | ||||||||||||||||||
| 831 | int i = f.indexOf(sep, 0); | - | ||||||||||||||||||
| 832 | if (i == -1) { | - | ||||||||||||||||||
| 833 | if (f.indexOf(QLatin1Char('\n'), 0) != -1) { | - | ||||||||||||||||||
| 834 | sep = QLatin1Char('\n'); | - | ||||||||||||||||||
| 835 | i = f.indexOf(sep, 0); | - | ||||||||||||||||||
| 836 | } | - | ||||||||||||||||||
| 837 | } | - | ||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | return f.split(sep); | - | ||||||||||||||||||
| 840 | } | - | ||||||||||||||||||
| 841 | void QFileDialog::setNameFilter(const QString &filter) | - | ||||||||||||||||||
| 842 | { | - | ||||||||||||||||||
| 843 | setNameFilters(qt_make_filter_list(filter)); | - | ||||||||||||||||||
| 844 | } | - | ||||||||||||||||||
| 845 | void QFileDialog::setNameFilterDetailsVisible(bool enabled) | - | ||||||||||||||||||
| 846 | { | - | ||||||||||||||||||
| 847 | setOption(HideNameFilterDetails, !enabled); | - | ||||||||||||||||||
| 848 | } | - | ||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | bool QFileDialog::isNameFilterDetailsVisible() const | - | ||||||||||||||||||
| 851 | { | - | ||||||||||||||||||
| 852 | return !testOption(HideNameFilterDetails); | - | ||||||||||||||||||
| 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; ++i) { | - | ||||||||||||||||||
| 866 | QString filterName; | - | ||||||||||||||||||
| 867 | int index = r.indexIn(filters[i]); | - | ||||||||||||||||||
| 868 | if (index >= 0) | - | ||||||||||||||||||
| 869 | filterName = r.cap(1); | - | ||||||||||||||||||
| 870 | strippedFilters.append(filterName.simplified()); | - | ||||||||||||||||||
| 871 | } | - | ||||||||||||||||||
| 872 | return strippedFilters; | - | ||||||||||||||||||
| 873 | } | - | ||||||||||||||||||
| 874 | void QFileDialog::setNameFilters(const QStringList &filters) | - | ||||||||||||||||||
| 875 | { | - | ||||||||||||||||||
| 876 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)"))); | ||||||||||||||||||||
| 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 d_func()->options->nameFilters(); | - | ||||||||||||||||||
| 909 | } | - | ||||||||||||||||||
| 910 | void QFileDialog::selectNameFilter(const QString &filter) | - | ||||||||||||||||||
| 911 | { | - | ||||||||||||||||||
| 912 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 913 | d->options->setInitiallySelectedNameFilter(filter); | - | ||||||||||||||||||
| 914 | if (!d->usingWidgets()) { | - | ||||||||||||||||||
| 915 | d->selectNameFilter_sys(filter); | - | ||||||||||||||||||
| 916 | return; | - | ||||||||||||||||||
| 917 | } | - | ||||||||||||||||||
| 918 | int i = -1; | - | ||||||||||||||||||
| 919 | if (testOption(HideNameFilterDetails)) { | - | ||||||||||||||||||
| 920 | const QStringList filters = qt_strip_filters(qt_make_filter_list(filter)); | - | ||||||||||||||||||
| 921 | if (!filters.isEmpty()) | - | ||||||||||||||||||
| 922 | i = d->qFileDialogUi->fileTypeCombo->findText(filters.first()); | - | ||||||||||||||||||
| 923 | } else { | - | ||||||||||||||||||
| 924 | i = d->qFileDialogUi->fileTypeCombo->findText(filter); | - | ||||||||||||||||||
| 925 | } | - | ||||||||||||||||||
| 926 | if (i >= 0) { | - | ||||||||||||||||||
| 927 | d->qFileDialogUi->fileTypeCombo->setCurrentIndex(i); | - | ||||||||||||||||||
| 928 | d->_q_useNameFilter(d->qFileDialogUi->fileTypeCombo->currentIndex()); | - | ||||||||||||||||||
| 929 | } | - | ||||||||||||||||||
| 930 | } | - | ||||||||||||||||||
| 931 | QString QFileDialog::selectedNameFilter() const | - | ||||||||||||||||||
| 932 | { | - | ||||||||||||||||||
| 933 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 934 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 935 | return d->selectedNameFilter_sys(); | - | ||||||||||||||||||
| 936 | - | |||||||||||||||||||
| 937 | return d->qFileDialogUi->fileTypeCombo->currentText(); | - | ||||||||||||||||||
| 938 | } | - | ||||||||||||||||||
| 939 | QDir::Filters QFileDialog::filter() const | - | ||||||||||||||||||
| 940 | { | - | ||||||||||||||||||
| 941 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 942 | if (d->usingWidgets()) | - | ||||||||||||||||||
| 943 | return d->model->filter(); | - | ||||||||||||||||||
| 944 | return d->options->filter(); | - | ||||||||||||||||||
| 945 | } | - | ||||||||||||||||||
| 946 | void QFileDialog::setFilter(QDir::Filters filters) | - | ||||||||||||||||||
| 947 | { | - | ||||||||||||||||||
| 948 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 949 | d->options->setFilter(filters); | - | ||||||||||||||||||
| 950 | if (!d->usingWidgets()) { | - | ||||||||||||||||||
| 951 | d->setFilter_sys(); | - | ||||||||||||||||||
| 952 | return; | - | ||||||||||||||||||
| 953 | } | - | ||||||||||||||||||
| 954 | - | |||||||||||||||||||
| 955 | d->model->setFilter(filters); | - | ||||||||||||||||||
| 956 | d->showHiddenAction->setChecked((filters & QDir::Hidden)); | - | ||||||||||||||||||
| 957 | } | - | ||||||||||||||||||
| 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() + ([]() -> QString { enum { Size = sizeofQLatin1String(u""" (")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" " (" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) + 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(filters)>::type> _container_((filters)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &mimeType = *_container_.i; _container_.control; _container_.control =: 0filters) { | - | ||||||||||||||||||
| 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 d_func()->options->mimeTypeFilters(); | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 1009 | selectNameFilter(text); | - | ||||||||||||||||||
| 1010 | } | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 1016 | return; | - | ||||||||||||||||||
| 1017 | if (mode == Detail) | - | ||||||||||||||||||
| 1018 | d->_q_showDetailsView(); | - | ||||||||||||||||||
| 1019 | else | - | ||||||||||||||||||
| 1020 | d->_q_showListView(); | - | ||||||||||||||||||
| 1021 | } | - | ||||||||||||||||||
| 1022 | - | |||||||||||||||||||
| 1023 | QFileDialog::ViewMode QFileDialog::viewMode() const | - | ||||||||||||||||||
| 1024 | { | - | ||||||||||||||||||
| 1025 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1026 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1027 | return static_cast<QFileDialog::ViewMode>(d->options->viewMode()); | - | ||||||||||||||||||
| 1028 | return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail); | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 1039 | return; | - | ||||||||||||||||||
| 1040 | - | |||||||||||||||||||
| 1041 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 1042 | - | |||||||||||||||||||
| 1043 | - | |||||||||||||||||||
| 1044 | QAbstractItemView::SelectionMode selectionMode; | - | ||||||||||||||||||
| 1045 | if (mode == QFileDialog::ExistingFiles) | - | ||||||||||||||||||
| 1046 | selectionMode = QAbstractItemView::ExtendedSelection; | - | ||||||||||||||||||
| 1047 | else | - | ||||||||||||||||||
| 1048 | selectionMode = QAbstractItemView::SingleSelection; | - | ||||||||||||||||||
| 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 || mode == Directory) { | - | ||||||||||||||||||
| 1055 | d->qFileDialogUi->fileTypeCombo->clear(); | - | ||||||||||||||||||
| 1056 | d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories")); | - | ||||||||||||||||||
| 1057 | d->qFileDialogUi->fileTypeCombo->setEnabled(false); | - | ||||||||||||||||||
| 1058 | } | - | ||||||||||||||||||
| 1059 | d->updateFileNameLabel(); | - | ||||||||||||||||||
| 1060 | d->updateOkButtonText(); | - | ||||||||||||||||||
| 1061 | d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly)); | - | ||||||||||||||||||
| 1062 | d->_q_updateOkButton(); | - | ||||||||||||||||||
| 1063 | } | - | ||||||||||||||||||
| 1064 | - | |||||||||||||||||||
| 1065 | QFileDialog::FileMode QFileDialog::fileMode() const | - | ||||||||||||||||||
| 1066 | { | - | ||||||||||||||||||
| 1067 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1068 | return static_cast<FileMode>(d->options->fileMode()); | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 1077 | return; | - | ||||||||||||||||||
| 1078 | QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save); | - | ||||||||||||||||||
| 1079 | d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel); | - | ||||||||||||||||||
| 1080 | d->qFileDialogUi->buttonBox->button(button)->setEnabled(false); | - | ||||||||||||||||||
| 1081 | d->_q_updateOkButton(); | - | ||||||||||||||||||
| 1082 | if (mode == AcceptSave) { | - | ||||||||||||||||||
| 1083 | d->qFileDialogUi->lookInCombo->setEditable(false); | - | ||||||||||||||||||
| 1084 | } | - | ||||||||||||||||||
| 1085 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 1086 | } | - | ||||||||||||||||||
| 1087 | void QFileDialog::setSupportedSchemes(const QStringList &schemes) | - | ||||||||||||||||||
| 1088 | { | - | ||||||||||||||||||
| 1089 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1090 | d->options->setSupportedSchemes(schemes); | - | ||||||||||||||||||
| 1091 | } | - | ||||||||||||||||||
| 1092 | - | |||||||||||||||||||
| 1093 | QStringList QFileDialog::supportedSchemes() const | - | ||||||||||||||||||
| 1094 | { | - | ||||||||||||||||||
| 1095 | return d_func()->options->supportedSchemes(); | - | ||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||
| 1097 | - | |||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | - | |||||||||||||||||||
| 1101 | - | |||||||||||||||||||
| 1102 | QModelIndex QFileDialogPrivate::rootIndex() const { | - | ||||||||||||||||||
| 1103 | return mapToSource(qFileDialogUi->listView->rootIndex()); | - | ||||||||||||||||||
| 1104 | } | - | ||||||||||||||||||
| 1105 | - | |||||||||||||||||||
| 1106 | QAbstractItemView *QFileDialogPrivate::currentView() const { | - | ||||||||||||||||||
| 1107 | if (!qFileDialogUi->stackedWidget) | - | ||||||||||||||||||
| 1108 | return 0; | - | ||||||||||||||||||
| 1109 | if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent()) | - | ||||||||||||||||||
| 1110 | return qFileDialogUi->listView; | - | ||||||||||||||||||
| 1111 | return qFileDialogUi->treeView; | - | ||||||||||||||||||
| 1112 | } | - | ||||||||||||||||||
| 1113 | - | |||||||||||||||||||
| 1114 | QLineEdit *QFileDialogPrivate::lineEdit() const { | - | ||||||||||||||||||
| 1115 | return (QLineEdit*)qFileDialogUi->fileNameEdit; | - | ||||||||||||||||||
| 1116 | } | - | ||||||||||||||||||
| 1117 | - | |||||||||||||||||||
| 1118 | int QFileDialogPrivate::maxNameLength(const QString &path) | - | ||||||||||||||||||
| 1119 | { | - | ||||||||||||||||||
| 1120 | - | |||||||||||||||||||
| 1121 | return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX); | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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() && !qFileDialogUi->listView->selectionModel()->isSelected(idx)) | - | ||||||||||||||||||
| 1143 | qFileDialogUi->listView->selectionModel()->select(idx, | - | ||||||||||||||||||
| 1144 | QItemSelectionModel::Select | QItemSelectionModel::Rows); | - | ||||||||||||||||||
| 1145 | return idx; | - | ||||||||||||||||||
| 1146 | } | - | ||||||||||||||||||
| 1147 | - | |||||||||||||||||||
| 1148 | QFileDialog::AcceptMode QFileDialog::acceptMode() const | - | ||||||||||||||||||
| 1149 | { | - | ||||||||||||||||||
| 1150 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1151 | return static_cast<AcceptMode>(d->options->acceptMode()); | - | ||||||||||||||||||
| 1152 | } | - | ||||||||||||||||||
| 1153 | void QFileDialog::setReadOnly(bool enabled) | - | ||||||||||||||||||
| 1154 | { | - | ||||||||||||||||||
| 1155 | setOption(ReadOnly, enabled); | - | ||||||||||||||||||
| 1156 | } | - | ||||||||||||||||||
| 1157 | - | |||||||||||||||||||
| 1158 | bool QFileDialog::isReadOnly() const | - | ||||||||||||||||||
| 1159 | { | - | ||||||||||||||||||
| 1160 | return testOption(ReadOnly); | - | ||||||||||||||||||
| 1161 | } | - | ||||||||||||||||||
| 1162 | void QFileDialog::setResolveSymlinks(bool enabled) | - | ||||||||||||||||||
| 1163 | { | - | ||||||||||||||||||
| 1164 | setOption(DontResolveSymlinks, !enabled); | - | ||||||||||||||||||
| 1165 | } | - | ||||||||||||||||||
| 1166 | - | |||||||||||||||||||
| 1167 | bool QFileDialog::resolveSymlinks() const | - | ||||||||||||||||||
| 1168 | { | - | ||||||||||||||||||
| 1169 | return !testOption(DontResolveSymlinks); | - | ||||||||||||||||||
| 1170 | } | - | ||||||||||||||||||
| 1171 | void QFileDialog::setConfirmOverwrite(bool enabled) | - | ||||||||||||||||||
| 1172 | { | - | ||||||||||||||||||
| 1173 | setOption(DontConfirmOverwrite, !enabled); | - | ||||||||||||||||||
| 1174 | } | - | ||||||||||||||||||
| 1175 | - | |||||||||||||||||||
| 1176 | bool QFileDialog::confirmOverwrite() const | - | ||||||||||||||||||
| 1177 | { | - | ||||||||||||||||||
| 1178 | return !testOption(DontConfirmOverwrite); | - | ||||||||||||||||||
| 1179 | } | - | ||||||||||||||||||
| 1180 | void QFileDialog::setDefaultSuffix(const QString &suffix) | - | ||||||||||||||||||
| 1181 | { | - | ||||||||||||||||||
| 1182 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1183 | d->options->setDefaultSuffix(suffix); | - | ||||||||||||||||||
| 1184 | } | - | ||||||||||||||||||
| 1185 | - | |||||||||||||||||||
| 1186 | QString QFileDialog::defaultSuffix() const | - | ||||||||||||||||||
| 1187 | { | - | ||||||||||||||||||
| 1188 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1189 | return d->options->defaultSuffix(); | - | ||||||||||||||||||
| 1190 | } | - | ||||||||||||||||||
| 1191 | - | |||||||||||||||||||
| 1192 | - | |||||||||||||||||||
| 1193 | - | |||||||||||||||||||
| 1194 | - | |||||||||||||||||||
| 1195 | - | |||||||||||||||||||
| 1196 | void QFileDialog::setHistory(const QStringList &paths) | - | ||||||||||||||||||
| 1197 | { | - | ||||||||||||||||||
| 1198 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1199 | if (d->usingWidgets()) | - | ||||||||||||||||||
| 1200 | d->qFileDialogUi->lookInCombo->setHistory(paths); | - | ||||||||||||||||||
| 1201 | } | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 1212 | list.append(url); | - | ||||||||||||||||||
| 1213 | urlModel->setUrls(list); | - | ||||||||||||||||||
| 1214 | } | - | ||||||||||||||||||
| 1215 | - | |||||||||||||||||||
| 1216 | - | |||||||||||||||||||
| 1217 | - | |||||||||||||||||||
| 1218 | - | |||||||||||||||||||
| 1219 | QStringList QFileDialog::history() const | - | ||||||||||||||||||
| 1220 | { | - | ||||||||||||||||||
| 1221 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1222 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1223 | return QStringList(); | - | ||||||||||||||||||
| 1224 | QStringList currentHistory = d->qFileDialogUi->lookInCombo->history(); | - | ||||||||||||||||||
| 1225 | - | |||||||||||||||||||
| 1226 | QString newHistory = QDir::toNativeSeparators(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); | - | ||||||||||||||||||
| 1227 | if (!currentHistory.contains(newHistory)) | - | ||||||||||||||||||
| 1228 | currentHistory << newHistory; | - | ||||||||||||||||||
| 1229 | return currentHistory; | - | ||||||||||||||||||
| 1230 | } | - | ||||||||||||||||||
| 1231 | void QFileDialog::setItemDelegate(QAbstractItemDelegate *delegate) | - | ||||||||||||||||||
| 1232 | { | - | ||||||||||||||||||
| 1233 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1234 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1235 | return; | - | ||||||||||||||||||
| 1236 | d->qFileDialogUi->listView->setItemDelegate(delegate); | - | ||||||||||||||||||
| 1237 | d->qFileDialogUi->treeView->setItemDelegate(delegate); | - | ||||||||||||||||||
| 1238 | } | - | ||||||||||||||||||
| 1239 | - | |||||||||||||||||||
| 1240 | - | |||||||||||||||||||
| 1241 | - | |||||||||||||||||||
| 1242 | - | |||||||||||||||||||
| 1243 | QAbstractItemDelegate *QFileDialog::itemDelegate() const | - | ||||||||||||||||||
| 1244 | { | - | ||||||||||||||||||
| 1245 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1246 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1247 | return 0; | - | ||||||||||||||||||
| 1248 | return d->qFileDialogUi->listView->itemDelegate(); | - | ||||||||||||||||||
| 1249 | } | - | ||||||||||||||||||
| 1250 | - | |||||||||||||||||||
| 1251 | - | |||||||||||||||||||
| 1252 | - | |||||||||||||||||||
| 1253 | - | |||||||||||||||||||
| 1254 | void QFileDialog::setIconProvider(QFileIconProvider *provider) | - | ||||||||||||||||||
| 1255 | { | - | ||||||||||||||||||
| 1256 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1257 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1258 | return; | - | ||||||||||||||||||
| 1259 | d->model->setIconProvider(provider); | - | ||||||||||||||||||
| 1260 | - | |||||||||||||||||||
| 1261 | d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls()); | - | ||||||||||||||||||
| 1262 | } | - | ||||||||||||||||||
| 1263 | - | |||||||||||||||||||
| 1264 | - | |||||||||||||||||||
| 1265 | - | |||||||||||||||||||
| 1266 | - | |||||||||||||||||||
| 1267 | QFileIconProvider *QFileDialog::iconProvider() const | - | ||||||||||||||||||
| 1268 | { | - | ||||||||||||||||||
| 1269 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1270 | if (!d->model) | - | ||||||||||||||||||
| 1271 | return nullptr; | - | ||||||||||||||||||
| 1272 | return d->model->iconProvider(); | - | ||||||||||||||||||
| 1273 | } | - | ||||||||||||||||||
| 1274 | - | |||||||||||||||||||
| 1275 | void QFileDialogPrivate::setLabelTextControl(QFileDialog::DialogLabel label, const QString &text) | - | ||||||||||||||||||
| 1276 | { | - | ||||||||||||||||||
| 1277 | if (!qFileDialogUi) | - | ||||||||||||||||||
| 1278 | return; | - | ||||||||||||||||||
| 1279 | switch (label) { | - | ||||||||||||||||||
| 1280 | case QFileDialog::LookIn: | - | ||||||||||||||||||
| 1281 | qFileDialogUi->lookInLabel->setText(text); | - | ||||||||||||||||||
| 1282 | break; | - | ||||||||||||||||||
| 1283 | case QFileDialog::FileName: | - | ||||||||||||||||||
| 1284 | qFileDialogUi->fileNameLabel->setText(text); | - | ||||||||||||||||||
| 1285 | break; | - | ||||||||||||||||||
| 1286 | case QFileDialog::FileType: | - | ||||||||||||||||||
| 1287 | qFileDialogUi->fileTypeLabel->setText(text); | - | ||||||||||||||||||
| 1288 | break; | - | ||||||||||||||||||
| 1289 | case QFileDialog::Accept: | - | ||||||||||||||||||
| 1290 | if (q_func()->acceptMode() == QFileDialog::AcceptOpen) { | - | ||||||||||||||||||
| 1291 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open)) | - | ||||||||||||||||||
| 1292 | button->setText(text); | - | ||||||||||||||||||
| 1293 | } else { | - | ||||||||||||||||||
| 1294 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save)) | - | ||||||||||||||||||
| 1295 | button->setText(text); | - | ||||||||||||||||||
| 1296 | } | - | ||||||||||||||||||
| 1297 | break; | - | ||||||||||||||||||
| 1298 | case QFileDialog::Reject: | - | ||||||||||||||||||
| 1299 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel)) | - | ||||||||||||||||||
| 1300 | button->setText(text); | - | ||||||||||||||||||
| 1301 | break; | - | ||||||||||||||||||
| 1302 | } | - | ||||||||||||||||||
| 1303 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 1315 | - | |||||||||||||||||||
| 1316 | - | |||||||||||||||||||
| 1317 | - | |||||||||||||||||||
| 1318 | - | |||||||||||||||||||
| 1319 | QString QFileDialog::labelText(DialogLabel label) const | - | ||||||||||||||||||
| 1320 | { | - | ||||||||||||||||||
| 1321 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1322 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 1323 | return d->options->labelText(static_cast<QFileDialogOptions::DialogLabel>(label)); | - | ||||||||||||||||||
| 1324 | QPushButton *button; | - | ||||||||||||||||||
| 1325 | switch (label) { | - | ||||||||||||||||||
| 1326 | case LookIn: | - | ||||||||||||||||||
| 1327 | return d->qFileDialogUi->lookInLabel->text(); | - | ||||||||||||||||||
| 1328 | case FileName: | - | ||||||||||||||||||
| 1329 | return d->qFileDialogUi->fileNameLabel->text(); | - | ||||||||||||||||||
| 1330 | case FileType: | - | ||||||||||||||||||
| 1331 | return d->qFileDialogUi->fileTypeLabel->text(); | - | ||||||||||||||||||
| 1332 | case Accept: | - | ||||||||||||||||||
| 1333 | if (acceptMode() == AcceptOpen) | - | ||||||||||||||||||
| 1334 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open); | - | ||||||||||||||||||
| 1335 | else | - | ||||||||||||||||||
| 1336 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save); | - | ||||||||||||||||||
| 1337 | if (button) | - | ||||||||||||||||||
| 1338 | return button->text(); | - | ||||||||||||||||||
| 1339 | break; | - | ||||||||||||||||||
| 1340 | case Reject: | - | ||||||||||||||||||
| 1341 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel); | - | ||||||||||||||||||
| 1342 | if (button) | - | ||||||||||||||||||
| 1343 | return button->text(); | - | ||||||||||||||||||
| 1344 | break; | - | ||||||||||||||||||
| 1345 | } | - | ||||||||||||||||||
| 1346 | return QString(); | - | ||||||||||||||||||
| 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 qstring_literal_temp; }())); | - | ||||||||||||||||||
| 1356 | const QUrl selectedUrl = getOpenFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes); | - | ||||||||||||||||||
| 1357 | return selectedUrl.toLocalFile(); | - | ||||||||||||||||||
| 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 && !selectedFilter->isEmpty()) | - | ||||||||||||||||||
| 1379 | dialog.selectNameFilter(*selectedFilter); | - | ||||||||||||||||||
| 1380 | if (dialog.exec() == QDialog::Accepted) { | - | ||||||||||||||||||
| 1381 | if (selectedFilter) | - | ||||||||||||||||||
| 1382 | *selectedFilter = dialog.selectedNameFilter(); | - | ||||||||||||||||||
| 1383 | return dialog.selectedUrls().value(0); | - | ||||||||||||||||||
| 1384 | } | - | ||||||||||||||||||
| 1385 | return QUrl(); | - | ||||||||||||||||||
| 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 qstring_literal_temp; }())); | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(selectedUrls)>::type> _container_((selectedUrls)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QUrl &url = *_container_.i; _container_.control; _container_.control =: 0selectedUrls) | - | ||||||||||||||||||
| 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 && !selectedFilter->isEmpty()) | - | ||||||||||||||||||
| 1422 | dialog.selectNameFilter(*selectedFilter); | - | ||||||||||||||||||
| 1423 | if (dialog.exec() == QDialog::Accepted) { | - | ||||||||||||||||||
| 1424 | if (selectedFilter) | - | ||||||||||||||||||
| 1425 | *selectedFilter = dialog.selectedNameFilter(); | - | ||||||||||||||||||
| 1426 | return dialog.selectedUrls(); | - | ||||||||||||||||||
| 1427 | } | - | ||||||||||||||||||
| 1428 | return QList<QUrl>(); | - | ||||||||||||||||||
| 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 qstring_literal_temp; }())); | - | ||||||||||||||||||
| 1438 | const QUrl selectedUrl = getSaveFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes); | - | ||||||||||||||||||
| 1439 | return selectedUrl.toLocalFile(); | - | ||||||||||||||||||
| 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 && !selectedFilter->isEmpty()) | - | ||||||||||||||||||
| 1462 | dialog.selectNameFilter(*selectedFilter); | - | ||||||||||||||||||
| 1463 | if (dialog.exec() == QDialog::Accepted) { | - | ||||||||||||||||||
| 1464 | if (selectedFilter) | - | ||||||||||||||||||
| 1465 | *selectedFilter = dialog.selectedNameFilter(); | - | ||||||||||||||||||
| 1466 | return dialog.selectedUrls().value(0); | - | ||||||||||||||||||
| 1467 | } | - | ||||||||||||||||||
| 1468 | return QUrl(); | - | ||||||||||||||||||
| 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 qstring_literal_temp; }())); | - | ||||||||||||||||||
| 1476 | const QUrl selectedUrl = getExistingDirectoryUrl(parent, caption, QUrl::fromLocalFile(dir), options, schemes); | - | ||||||||||||||||||
| 1477 | return selectedUrl.toLocalFile(); | - | ||||||||||||||||||
| 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 ? DirectoryOnly : Directory); | - | ||||||||||||||||||
| 1490 | args.options = options; | - | ||||||||||||||||||
| 1491 | - | |||||||||||||||||||
| 1492 | QFileDialog dialog(args); | - | ||||||||||||||||||
| 1493 | dialog.setSupportedSchemes(supportedSchemes); | - | ||||||||||||||||||
| 1494 | if (dialog.exec() == QDialog::Accepted) | - | ||||||||||||||||||
| 1495 | return dialog.selectedUrls().value(0); | - | ||||||||||||||||||
| 1496 | return QUrl(); | - | ||||||||||||||||||
| 1497 | } | - | ||||||||||||||||||
| 1498 | - | |||||||||||||||||||
| 1499 | inline static QUrl _qt_get_directory(const QUrl &url) | - | ||||||||||||||||||
| 1500 | { | - | ||||||||||||||||||
| 1501 | if (url.isLocalFile()) { | - | ||||||||||||||||||
| 1502 | QFileInfo info = QFileInfo(QDir::current(), url.toLocalFile()); | - | ||||||||||||||||||
| 1503 | if (info.exists() && info.isDir()) | - | ||||||||||||||||||
| 1504 | return QUrl::fromLocalFile(QDir::cleanPath(info.absoluteFilePath())); | - | ||||||||||||||||||
| 1505 | info.setFile(info.absolutePath()); | - | ||||||||||||||||||
| 1506 | if (info.exists() && info.isDir()) | - | ||||||||||||||||||
| 1507 | return QUrl::fromLocalFile(info.absoluteFilePath()); | - | ||||||||||||||||||
| 1508 | return QUrl(); | - | ||||||||||||||||||
| 1509 | } else { | - | ||||||||||||||||||
| 1510 | return url; | - | ||||||||||||||||||
| 1511 | } | - | ||||||||||||||||||
| 1512 | } | - | ||||||||||||||||||
| 1513 | - | |||||||||||||||||||
| 1514 | - | |||||||||||||||||||
| 1515 | - | |||||||||||||||||||
| 1516 | - | |||||||||||||||||||
| 1517 | - | |||||||||||||||||||
| 1518 | QUrl QFileDialogPrivate::workingDirectory(const QUrl &url) | - | ||||||||||||||||||
| 1519 | { | - | ||||||||||||||||||
| 1520 | if (!url.isEmpty()) { | - | ||||||||||||||||||
| 1521 | QUrl directory = _qt_get_directory(url); | - | ||||||||||||||||||
| 1522 | if (!directory.isEmpty()) | - | ||||||||||||||||||
| 1523 | return directory; | - | ||||||||||||||||||
| 1524 | } | - | ||||||||||||||||||
| 1525 | QUrl directory = _qt_get_directory(*lastVisitedDir()); | - | ||||||||||||||||||
| 1526 | if (!directory.isEmpty()) | - | ||||||||||||||||||
| 1527 | return directory; | - | ||||||||||||||||||
| 1528 | return QUrl::fromLocalFile(QDir::currentPath()); | - | ||||||||||||||||||
| 1529 | } | - | ||||||||||||||||||
| 1530 | QString QFileDialogPrivate::initialSelection(const QUrl &url) | - | ||||||||||||||||||
| 1531 | { | - | ||||||||||||||||||
| 1532 | if (url.isEmpty()) | - | ||||||||||||||||||
| 1533 | return QString(); | - | ||||||||||||||||||
| 1534 | if (url.isLocalFile()) { | - | ||||||||||||||||||
| 1535 | QFileInfo info(url.toLocalFile()); | - | ||||||||||||||||||
| 1536 | if (!info.isDir()) | - | ||||||||||||||||||
| 1537 | return info.fileName(); | - | ||||||||||||||||||
| 1538 | else | - | ||||||||||||||||||
| 1539 | return QString(); | - | ||||||||||||||||||
| 1540 | } | - | ||||||||||||||||||
| 1541 | - | |||||||||||||||||||
| 1542 | return url.fileName(); | - | ||||||||||||||||||
| 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) { | - | ||||||||||||||||||
| 1555 | disconnect(this, d->signalToDisconnectOnClose, | - | ||||||||||||||||||
| 1556 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - | ||||||||||||||||||
| 1557 | d->receiverToDisconnectOnClose = 0; | - | ||||||||||||||||||
| 1558 | } | - | ||||||||||||||||||
| 1559 | d->memberToDisconnectOnClose.clear(); | - | ||||||||||||||||||
| 1560 | d->signalToDisconnectOnClose.clear(); | - | ||||||||||||||||||
| 1561 | } | - | ||||||||||||||||||
| 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 (int i =const 0;auto i&file <: files.count(); ++i) { | - | ||||||||||||||||||
| 1651 | QFileInfo info(files.at(i));file); | - | ||||||||||||||||||
| 1652 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1653 | info = QFileInfo(d->getEnvironmentVariable(files.at(i)));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().firstconstFirst()); | - | ||||||||||||||||||
| 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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(history)>::type> _container_((history)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &path = *_container_.i; _container_.control; _container_.control =: 0history) | - | ||||||||||||||||||
| 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.67.4"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 | forconst (QForeachContainer<typenameauto QtPrivate::remove_reference<decltype(settings.value(QLatin1String("history")).toStringList())>::type>urlStrings _container_((= settings.value(QLatin1String("history")).toStringList())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) (); | - | ||||||||||||||||||
| 1724 | for (const QString &urlStr = *_container_.i; _container_.control; _container_.control =: 0urlStrings) { | - | ||||||||||||||||||
| 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 | whileif (history.countsize() > 5MaxHistorySize
| 0 | ||||||||||||||||||
| 1757 | history.pop_front();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 = (canBeNativeDialog() && 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__ ":" "2864""2866"), q, qFlagLocation("1""_q_fileRenamed(QString,QString,QString)" "\0" __FILE__ ":" "2864""2866")); | - | ||||||||||||||||||
| 1842 | QFileDialog::connect(model, qFlagLocation("2""rootPathChanged(QString)" "\0" __FILE__ ":" "2865""2867"), | - | ||||||||||||||||||
| 1843 | q, qFlagLocation("1""_q_pathChanged(QString)" "\0" __FILE__ ":" "2866""2868")); | - | ||||||||||||||||||
| 1844 | QFileDialog::connect(model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "2867""2869"), | - | ||||||||||||||||||
| 1845 | q, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "2868""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__ ":" "2878""2880"), | - | ||||||||||||||||||
| 1856 | q, qFlagLocation("1""_q_goToUrl(QUrl)" "\0" __FILE__ ":" "2879""2881")); | - | ||||||||||||||||||
| 1857 | - | |||||||||||||||||||
| 1858 | QObject::connect(qFileDialogUi->buttonBox, qFlagLocation("2""accepted()" "\0" __FILE__ ":" "2881""2883"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "2881""2883")); | - | ||||||||||||||||||
| 1859 | QObject::connect(qFileDialogUi->buttonBox, qFlagLocation("2""rejected()" "\0" __FILE__ ":" "2882""2884"), q, qFlagLocation("1""reject()" "\0" __FILE__ ":" "2882""2884")); | - | ||||||||||||||||||
| 1860 | - | |||||||||||||||||||
| 1861 | qFileDialogUi->lookInCombo->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1862 | QObject::connect(qFileDialogUi->lookInCombo, qFlagLocation("2""activated(QString)" "\0" __FILE__ ":" "2885""2887"), q, qFlagLocation("1""_q_goToDirectory(QString)" "\0" __FILE__ ":" "2885""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__ ":" "2902""2904"), | - | ||||||||||||||||||
| 1880 | q, qFlagLocation("1""_q_autoCompleteFileName(QString)" "\0" __FILE__ ":" "2903""2905")); | - | ||||||||||||||||||
| 1881 | QObject::connect(qFileDialogUi->fileNameEdit, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "2904""2906"), | - | ||||||||||||||||||
| 1882 | q, qFlagLocation("1""_q_updateOkButton()" "\0" __FILE__ ":" "2905""2907")); | - | ||||||||||||||||||
| 1883 | - | |||||||||||||||||||
| 1884 | QObject::connect(qFileDialogUi->fileNameEdit, qFlagLocation("2""returnPressed()" "\0" __FILE__ ":" "2907""2909"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "2907""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__ ":" "2913""2915"), | - | ||||||||||||||||||
| 1891 | q, qFlagLocation("1""_q_useNameFilter(int)" "\0" __FILE__ ":" "2914""2916")); | - | ||||||||||||||||||
| 1892 | QObject::connect(qFileDialogUi->fileTypeCombo, qFlagLocation("2""activated(QString)" "\0" __FILE__ ":" "2915""2917"), | - | ||||||||||||||||||
| 1893 | q, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "2916""2918")); | - | ||||||||||||||||||
| 1894 | - | |||||||||||||||||||
| 1895 | qFileDialogUi->listView->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1896 | qFileDialogUi->listView->setModel(model); | - | ||||||||||||||||||
| 1897 | QObject::connect(qFileDialogUi->listView, qFlagLocation("2""activated(QModelIndex)" "\0" __FILE__ ":" "2920""2922"), | - | ||||||||||||||||||
| 1898 | q, qFlagLocation("1""_q_enterDirectory(QModelIndex)" "\0" __FILE__ ":" "2921""2923")); | - | ||||||||||||||||||
| 1899 | QObject::connect(qFileDialogUi->listView, qFlagLocation("2""customContextMenuRequested(QPoint)" "\0" __FILE__ ":" "2922""2924"), | - | ||||||||||||||||||
| 1900 | q, qFlagLocation("1""_q_showContextMenu(QPoint)" "\0" __FILE__ ":" "2923""2925")); | - | ||||||||||||||||||
| 1901 | - | |||||||||||||||||||
| 1902 | QShortcut *shortcut = new QShortcut(qFileDialogUi->listView); | - | ||||||||||||||||||
| 1903 | shortcut->setKey(QKeySequence(QLatin1String("Delete"))); | - | ||||||||||||||||||
| 1904 | QObject::connect(shortcut, qFlagLocation("2""activated()" "\0" __FILE__ ":" "2927""2929"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "2927""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__ ":" "2942""2944"), | - | ||||||||||||||||||
| 1920 | q, qFlagLocation("1""_q_showHeader(QAction*)" "\0" __FILE__ ":" "2943""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__ ":" "2960""2962"), | - | ||||||||||||||||||
| 1938 | q, qFlagLocation("1""_q_enterDirectory(QModelIndex)" "\0" __FILE__ ":" "2961""2963")); | - | ||||||||||||||||||
| 1939 | QObject::connect(qFileDialogUi->treeView, qFlagLocation("2""customContextMenuRequested(QPoint)" "\0" __FILE__ ":" "2962""2964"), | - | ||||||||||||||||||
| 1940 | q, qFlagLocation("1""_q_showContextMenu(QPoint)" "\0" __FILE__ ":" "2963""2965")); | - | ||||||||||||||||||
| 1941 | - | |||||||||||||||||||
| 1942 | shortcut = new QShortcut(qFileDialogUi->treeView); | - | ||||||||||||||||||
| 1943 | shortcut->setKey(QKeySequence(QLatin1String("Delete"))); | - | ||||||||||||||||||
| 1944 | QObject::connect(shortcut, qFlagLocation("2""activated()" "\0" __FILE__ ":" "2967""2969"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "2967""2969")); | - | ||||||||||||||||||
| 1945 | - | |||||||||||||||||||
| 1946 | - | |||||||||||||||||||
| 1947 | - | |||||||||||||||||||
| 1948 | QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel(); | - | ||||||||||||||||||
| 1949 | QObject::connect(selections, qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "2972""2974"), | - | ||||||||||||||||||
| 1950 | q, qFlagLocation("1""_q_selectionChanged()" "\0" __FILE__ ":" "2973""2975")); | - | ||||||||||||||||||
| 1951 | QObject::connect(selections, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2974""2976"), | - | ||||||||||||||||||
| 1952 | q, qFlagLocation("1""_q_currentChanged(QModelIndex)" "\0" __FILE__ ":" "2975""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 | ifconst (auto initiallySelectedFiles = options->initiallySelectedFiles().count(); | - | ||||||||||||||||||
| 1986 | if (initiallySelectedFiles.size
| 0 | ||||||||||||||||||
| 1987 | q->selectFile(options->initiallySelectedFiles()..first().fileName()); never executed: q->selectFile(initiallySelectedFiles.first().fileName()); | 0 | ||||||||||||||||||
| 1988 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(options->initiallySelectedFiles())>::type> _container_((options->initiallySelectedFiles())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QUrl &url = *_container_.i; _container_.control; _container_.control =: 0initiallySelectedFiles) | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 2003 | void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) | - | ||||||||||||||||||
| 2004 | { | - | ||||||||||||||||||
| 2005 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2006 | if (!d->usingWidgets()) | - | ||||||||||||||||||
| 2007 | return; | - | ||||||||||||||||||
| 2008 | if ((!proxyModel && !d->proxyModel) | - | ||||||||||||||||||
| 2009 | || (proxyModel == d->proxyModel)) | - | ||||||||||||||||||
| 2010 | return; | - | ||||||||||||||||||
| 2011 | - | |||||||||||||||||||
| 2012 | QModelIndex idx = d->rootIndex(); | - | ||||||||||||||||||
| 2013 | if (d->proxyModel) { | - | ||||||||||||||||||
| 2014 | disconnect(d->proxyModel, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3050""3053"), | - | ||||||||||||||||||
| 2015 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3051""3054")); | - | ||||||||||||||||||
| 2016 | } else { | - | ||||||||||||||||||
| 2017 | disconnect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3053""3056"), | - | ||||||||||||||||||
| 2018 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3054""3057")); | - | ||||||||||||||||||
| 2019 | } | - | ||||||||||||||||||
| 2020 | - | |||||||||||||||||||
| 2021 | if (proxyModel != 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__ ":" "3067""3070"), | - | ||||||||||||||||||
| 2032 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3068""3071")); | - | ||||||||||||||||||
| 2033 | } else { | - | ||||||||||||||||||
| 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__ ":" "3078""3081"), | - | ||||||||||||||||||
| 2043 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3079""3082")); | - | ||||||||||||||||||
| 2044 | } | - | ||||||||||||||||||
| 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__ ":" "3088""3091"), | - | ||||||||||||||||||
| 2053 | this, qFlagLocation("1""_q_selectionChanged()" "\0" __FILE__ ":" "3089""3092")); | - | ||||||||||||||||||
| 2054 | QObject::connect(selections, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "3090""3093"), | - | ||||||||||||||||||
| 2055 | this, qFlagLocation("1""_q_currentChanged(QModelIndex)" "\0" __FILE__ ":" "3091""3094")); | - | ||||||||||||||||||
| 2056 | } | - | ||||||||||||||||||
| 2057 | - | |||||||||||||||||||
| 2058 | - | |||||||||||||||||||
| 2059 | - | |||||||||||||||||||
| 2060 | - | |||||||||||||||||||
| 2061 | - | |||||||||||||||||||
| 2062 | - | |||||||||||||||||||
| 2063 | QAbstractProxyModel *QFileDialog::proxyModel() const | - | ||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||
| 2065 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2066 | return d->proxyModel; | - | ||||||||||||||||||
| 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__ ":" "3117""3120"), q, qFlagLocation("1""_q_navigateBackward()" "\0" __FILE__ ":" "3117""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__ ":" "3122""3125"), q, qFlagLocation("1""_q_navigateForward()" "\0" __FILE__ ":" "3122""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__ ":" "3127""3130"), q, qFlagLocation("1""_q_navigateToParent()" "\0" __FILE__ ":" "3127""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__ ":" "3132""3135"), q, qFlagLocation("1""_q_showListView()" "\0" __FILE__ ":" "3132""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__ ":" "3136""3139"), q, qFlagLocation("1""_q_showDetailsView()" "\0" __FILE__ ":" "3136""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__ ":" "3149""3152"), q, qFlagLocation("1""_q_createDirectory()" "\0" __FILE__ ":" "3149""3152")); | - | ||||||||||||||||||
| 2114 | } | - | ||||||||||||||||||
| 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__ ":" "3165""3168"), q, qFlagLocation("1""_q_goHome()" "\0" __FILE__ ":" "3165""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__ ":" "3175""3178"), q, qFlagLocation("1""_q_navigateToParent()" "\0" __FILE__ ":" "3175""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__ ":" "3181""3184"), q, qFlagLocation("1""_q_renameCurrent()" "\0" __FILE__ ":" "3181""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__ ":" "3186""3189"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "3186""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__ ":" "3191""3194"), q, qFlagLocation("1""_q_showHidden()" "\0" __FILE__ ":" "3191""3194")); | - | ||||||||||||||||||
| 2156 | - | |||||||||||||||||||
| 2157 | newFolderAction = new QAction(q); | - | ||||||||||||||||||
| 2158 | newFolderAction->setObjectName(QLatin1String("qt_new_folder_action")); | - | ||||||||||||||||||
| 2159 | QObject::connect(newFolderAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3195""3198"), q, qFlagLocation("1""_q_createDirectory()" "\0" __FILE__ ":" "3195""3198")); | - | ||||||||||||||||||
| 2160 | } | - | ||||||||||||||||||
| 2161 | - | |||||||||||||||||||
| 2162 | void QFileDialogPrivate::_q_goHome() | - | ||||||||||||||||||
| 2163 | { | - | ||||||||||||||||||
| 2164 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2165 | q->setDirectory(QDir::homePath()); | - | ||||||||||||||||||
| 2166 | } | - | ||||||||||||||||||
| 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 || currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)) { | - | ||||||||||||||||||
| 2182 | while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) { | - | ||||||||||||||||||
| 2183 | currentHistory.removeLast(); | - | ||||||||||||||||||
| 2184 | } | - | ||||||||||||||||||
| 2185 | currentHistory.append(QDir::toNativeSeparators(newPath)); | - | ||||||||||||||||||
| 2186 | ++currentHistoryLocation; | - | ||||||||||||||||||
| 2187 | } | - | ||||||||||||||||||
| 2188 | qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1); | - | ||||||||||||||||||
| 2189 | qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0); | - | ||||||||||||||||||
| 2190 | } | - | ||||||||||||||||||
| 2191 | - | |||||||||||||||||||
| 2192 | - | |||||||||||||||||||
| 2193 | - | |||||||||||||||||||
| 2194 | - | |||||||||||||||||||
| 2195 | - | |||||||||||||||||||
| 2196 | - | |||||||||||||||||||
| 2197 | void QFileDialogPrivate::_q_navigateBackward() | - | ||||||||||||||||||
| 2198 | { | - | ||||||||||||||||||
| 2199 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2200 | if (!currentHistory.isEmpty() && currentHistoryLocation > 0) { | - | ||||||||||||||||||
| 2201 | --currentHistoryLocation; | - | ||||||||||||||||||
| 2202 | QString previousHistory = currentHistory.at(currentHistoryLocation); | - | ||||||||||||||||||
| 2203 | q->setDirectory(previousHistory); | - | ||||||||||||||||||
| 2204 | } | - | ||||||||||||||||||
| 2205 | } | - | ||||||||||||||||||
| 2206 | - | |||||||||||||||||||
| 2207 | - | |||||||||||||||||||
| 2208 | - | |||||||||||||||||||
| 2209 | - | |||||||||||||||||||
| 2210 | - | |||||||||||||||||||
| 2211 | - | |||||||||||||||||||
| 2212 | void QFileDialogPrivate::_q_navigateForward() | - | ||||||||||||||||||
| 2213 | { | - | ||||||||||||||||||
| 2214 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2215 | if (!currentHistory.isEmpty() && currentHistoryLocation < currentHistory.size() - 1) { | - | ||||||||||||||||||
| 2216 | ++currentHistoryLocation; | - | ||||||||||||||||||
| 2217 | QString nextHistory = currentHistory.at(currentHistoryLocation); | - | ||||||||||||||||||
| 2218 | q->setDirectory(nextHistory); | - | ||||||||||||||||||
| 2219 | } | - | ||||||||||||||||||
| 2220 | } | - | ||||||||||||||||||
| 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()) { | - | ||||||||||||||||||
| 2234 | newDirectory = model->myComputer().toString(); | - | ||||||||||||||||||
| 2235 | } else { | - | ||||||||||||||||||
| 2236 | dir.cdUp(); | - | ||||||||||||||||||
| 2237 | newDirectory = dir.absolutePath(); | - | ||||||||||||||||||
| 2238 | } | - | ||||||||||||||||||
| 2239 | q->setDirectory(newDirectory); | - | ||||||||||||||||||
| 2240 | q->directoryEntered(newDirectory); | - | ||||||||||||||||||
| 2241 | } | - | ||||||||||||||||||
| 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)) { | - | ||||||||||||||||||
| 2257 | qlonglong suffix = 2; | - | ||||||||||||||||||
| 2258 | while (QFile::exists(prefix + folderName)) { | - | ||||||||||||||||||
| 2259 | folderName = newFolderString + QString::number(suffix++); | - | ||||||||||||||||||
| 2260 | } | - | ||||||||||||||||||
| 2261 | } | - | ||||||||||||||||||
| 2262 | - | |||||||||||||||||||
| 2263 | QModelIndex parent = rootIndex(); | - | ||||||||||||||||||
| 2264 | QModelIndex index = model->mkdir(parent, folderName); | - | ||||||||||||||||||
| 2265 | if (!index.isValid()) | - | ||||||||||||||||||
| 2266 | return; | - | ||||||||||||||||||
| 2267 | - | |||||||||||||||||||
| 2268 | index = select(index); | - | ||||||||||||||||||
| 2269 | if (index.isValid()) { | - | ||||||||||||||||||
| 2270 | qFileDialogUi->treeView->setCurrentIndex(index); | - | ||||||||||||||||||
| 2271 | currentView()->edit(index); | - | ||||||||||||||||||
| 2272 | } | - | ||||||||||||||||||
| 2273 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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) | - | ||||||||||||||||||
| 2308 | view = qFileDialogUi->treeView; | - | ||||||||||||||||||
| 2309 | else | - | ||||||||||||||||||
| 2310 | view = qFileDialogUi->listView; | - | ||||||||||||||||||
| 2311 | QModelIndex index = view->indexAt(position); | - | ||||||||||||||||||
| 2312 | index = mapToSource(index.sibling(index.row(), 0)); | - | ||||||||||||||||||
| 2313 | - | |||||||||||||||||||
| 2314 | QMenu menu(view); | - | ||||||||||||||||||
| 2315 | if (index.isValid()) { | - | ||||||||||||||||||
| 2316 | - | |||||||||||||||||||
| 2317 | const bool ro = model && model->isReadOnly(); | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 2325 | menu.addAction(showHiddenAction); | - | ||||||||||||||||||
| 2326 | if (qFileDialogUi->newFolderButton->isVisible()) { | - | ||||||||||||||||||
| 2327 | newFolderAction->setEnabled(qFileDialogUi->newFolderButton->isEnabled()); | - | ||||||||||||||||||
| 2328 | menu.addAction(newFolderAction); | - | ||||||||||||||||||
| 2329 | } | - | ||||||||||||||||||
| 2330 | menu.exec(view->viewport()->mapToGlobal(position)); | - | ||||||||||||||||||
| 2331 | - | |||||||||||||||||||
| 2332 | } | - | ||||||||||||||||||
| 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) | - | ||||||||||||||||||
| 2343 | qFileDialogUi->listView->edit(index); | - | ||||||||||||||||||
| 2344 | else | - | ||||||||||||||||||
| 2345 | qFileDialogUi->treeView->edit(index); | - | ||||||||||||||||||
| 2346 | } | - | ||||||||||||||||||
| 2347 | - | |||||||||||||||||||
| 2348 | bool QFileDialogPrivate::removeDirectory(const QString &path) | - | ||||||||||||||||||
| 2349 | { | - | ||||||||||||||||||
| 2350 | QModelIndex modelIndex = model->index(path); | - | ||||||||||||||||||
| 2351 | return model->remove(modelIndex); | - | ||||||||||||||||||
| 2352 | } | - | ||||||||||||||||||
| 2353 | - | |||||||||||||||||||
| 2354 | - | |||||||||||||||||||
| 2355 | - | |||||||||||||||||||
| 2356 | - | |||||||||||||||||||
| 2357 | - | |||||||||||||||||||
| 2358 | - | |||||||||||||||||||
| 2359 | void QFileDialogPrivate::_q_deleteCurrent() | - | ||||||||||||||||||
| 2360 | { | - | ||||||||||||||||||
| 2361 | if (model->isReadOnly()) | - | ||||||||||||||||||
| 2362 | return; | - | ||||||||||||||||||
| 2363 | - | |||||||||||||||||||
| 2364 | QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); | - | ||||||||||||||||||
| 2365 | for (int i = list.count() - 1; i >= 0; --i) { | - | ||||||||||||||||||
| 2366 | QModelIndex index = list.at(i); | - | ||||||||||||||||||
| 2367 | if (index == qFileDialogUi->listView->rootIndex()) | - | ||||||||||||||||||
| 2368 | continue; | - | ||||||||||||||||||
| 2369 | - | |||||||||||||||||||
| 2370 | index = mapToSource(index.sibling(index.row(), 0)); | - | ||||||||||||||||||
| 2371 | if (!index.isValid()) | - | ||||||||||||||||||
| 2372 | continue; | - | ||||||||||||||||||
| 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) && (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), | - | ||||||||||||||||||
| 2382 | QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?") | - | ||||||||||||||||||
| 2383 | .arg(fileName), | - | ||||||||||||||||||
| 2384 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)) | - | ||||||||||||||||||
| 2385 | return; | - | ||||||||||||||||||
| 2386 | else if (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), | - | ||||||||||||||||||
| 2387 | QFileDialog::tr("Are you sure you want to delete '%1'?") | - | ||||||||||||||||||
| 2388 | .arg(fileName), | - | ||||||||||||||||||
| 2389 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) | - | ||||||||||||||||||
| 2390 | return; | - | ||||||||||||||||||
| 2391 | - | |||||||||||||||||||
| 2392 | - | |||||||||||||||||||
| 2393 | - | |||||||||||||||||||
| 2394 | - | |||||||||||||||||||
| 2395 | - | |||||||||||||||||||
| 2396 | - | |||||||||||||||||||
| 2397 | - | |||||||||||||||||||
| 2398 | if (isDir) { | - | ||||||||||||||||||
| 2399 | if (!removeDirectory(filePath)) { | - | ||||||||||||||||||
| 2400 | - | |||||||||||||||||||
| 2401 | QMessageBox::warning(q, q->windowTitle(), | - | ||||||||||||||||||
| 2402 | QFileDialog::tr("Could not delete directory.")); | - | ||||||||||||||||||
| 2403 | - | |||||||||||||||||||
| 2404 | } | - | ||||||||||||||||||
| 2405 | } else { | - | ||||||||||||||||||
| 2406 | model->remove(index); | - | ||||||||||||||||||
| 2407 | } | - | ||||||||||||||||||
| 2408 | } | - | ||||||||||||||||||
| 2409 | } | - | ||||||||||||||||||
| 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 | QModelIndexListQVector<QModelIndex> newFiles; | - | ||||||||||||||||||
| 2422 | for (int i = 0; i <const auto &file : multipleFiles.count(); ++i) { | - | ||||||||||||||||||
| 2423 | QModelIndex idx = model->index(multipleFiles.at(i));file); | - | ||||||||||||||||||
| 2424 | if (oldFiles.contains(idx))oldFiles.removeAll(idx);
| 0 | ||||||||||||||||||
else
| ||||||||||||||||||||
| 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 (int i = 0; i <const auto &file : files.count(); ++i) { | - | ||||||||||||||||||
| 2511 | QModelIndex idx = model->index(files.at(i));file); | - | ||||||||||||||||||
| 2512 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2513 | idx = model->index(getEnvironmentVariable(files.at(i)));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 | } | - | ||||||||||||||||||
| 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 ? mapToSource(index) : index; | - | ||||||||||||||||||
| 2553 | QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 2554 | if (path.isEmpty() || model->isDir(sourceIndex)) { | - | ||||||||||||||||||
| 2555 | const QFileDialog::FileMode fileMode = q->fileMode(); | - | ||||||||||||||||||
| 2556 | q->setDirectory(path); | - | ||||||||||||||||||
| 2557 | q->directoryEntered(path); | - | ||||||||||||||||||
| 2558 | if (fileMode == QFileDialog::Directory | - | ||||||||||||||||||
| 2559 | || fileMode == QFileDialog::DirectoryOnly) { | - | ||||||||||||||||||
| 2560 | - | |||||||||||||||||||
| 2561 | lineEdit()->setText(QString()); | - | ||||||||||||||||||
| 2562 | lineEdit()->clear(); | - | ||||||||||||||||||
| 2563 | } | - | ||||||||||||||||||
| 2564 | } else { | - | ||||||||||||||||||
| 2565 | - | |||||||||||||||||||
| 2566 | if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, qFileDialogUi->treeView) | - | ||||||||||||||||||
| 2567 | || q->fileMode() != QFileDialog::ExistingFiles || !(QGuiApplication::keyboardModifiers() & Qt::CTRL)) { | - | ||||||||||||||||||
| 2568 | q->accept(); | - | ||||||||||||||||||
| 2569 | } | - | ||||||||||||||||||
| 2570 | } | - | ||||||||||||||||||
| 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()) | - | ||||||||||||||||||
| 2589 | index = mapFromSource(model->index(getEnvironmentVariable(path))); | - | ||||||||||||||||||
| 2590 | else { | - | ||||||||||||||||||
| 2591 | path2 = index.data((Qt::UserRole + 1)).toUrl().toLocalFile(); | - | ||||||||||||||||||
| 2592 | index = mapFromSource(model->index(path2)); | - | ||||||||||||||||||
| 2593 | } | - | ||||||||||||||||||
| 2594 | QDir dir(path2); | - | ||||||||||||||||||
| 2595 | if (!dir.exists()) | - | ||||||||||||||||||
| 2596 | dir = getEnvironmentVariable(path2); | - | ||||||||||||||||||
| 2597 | - | |||||||||||||||||||
| 2598 | if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) { | - | ||||||||||||||||||
| 2599 | _q_enterDirectory(index); | - | ||||||||||||||||||
| 2600 | - | |||||||||||||||||||
| 2601 | } else { | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 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()) { | - | ||||||||||||||||||
| 2619 | QAbstractItemModel *comboModel = qFileDialogUi->fileTypeCombo->model(); | - | ||||||||||||||||||
| 2620 | nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString()); | - | ||||||||||||||||||
| 2621 | options->setNameFilters(nameFilters); | - | ||||||||||||||||||
| 2622 | } | - | ||||||||||||||||||
| 2623 | - | |||||||||||||||||||
| 2624 | QString nameFilter = nameFilters.at(index); | - | ||||||||||||||||||
| 2625 | QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter); | - | ||||||||||||||||||
| 2626 | if (q_func()->acceptMode() == QFileDialog::AcceptSave) { | - | ||||||||||||||||||
| 2627 | QString newNameFilterExtension; | - | ||||||||||||||||||
| 2628 | if (newNameFilters.count() > 0) | - | ||||||||||||||||||
| 2629 | newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); | - | ||||||||||||||||||
| 2630 | - | |||||||||||||||||||
| 2631 | QString fileName = lineEdit()->text(); | - | ||||||||||||||||||
| 2632 | const QString fileNameExtension = QFileInfo(fileName).suffix(); | - | ||||||||||||||||||
| 2633 | if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) { | - | ||||||||||||||||||
| 2634 | const int fileNameExtensionLength = fileNameExtension.count(); | - | ||||||||||||||||||
| 2635 | fileName.replace(fileName.count() - fileNameExtensionLength, | - | ||||||||||||||||||
| 2636 | fileNameExtensionLength, newNameFilterExtension); | - | ||||||||||||||||||
| 2637 | qFileDialogUi->listView->clearSelection(); | - | ||||||||||||||||||
| 2638 | lineEdit()->setText(fileName); | - | ||||||||||||||||||
| 2639 | } | - | ||||||||||||||||||
| 2640 | } | - | ||||||||||||||||||
| 2641 | - | |||||||||||||||||||
| 2642 | model->setNameFilters(newNameFilters); | - | ||||||||||||||||||
| 2643 | } | - | ||||||||||||||||||
| 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 (int i = 0; i <const auto &index : indexes.count(); ++i) { | - | ||||||||||||||||||
| 2659 | if (stripDirs
| 0 | ||||||||||||||||||
| 2660 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2661 | allFiles.append(indexesindex.at(i).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 | if (showHiddenAction->isChecked()) | - | ||||||||||||||||||
| dirFilters |= QDir::Hidden; | ||||||||||||||||||||
| elsedirFilters&= ~.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 | - | ||||||||||||||||||
| 2697 | || parent != qFileDialogUi->treeView->rootIndex() | - | ||||||||||||||||||
| 2698 | || !qFileDialogUi->treeView->selectionModel() | - | ||||||||||||||||||
| 2699 | || qFileDialogUi->treeView->selectionModel()->hasSelection() | - | ||||||||||||||||||
| 2700 | || qFileDialogUi->treeView->model()->rowCount(parent) == 0) | - | ||||||||||||||||||
| 2701 | return; | - | ||||||||||||||||||
| 2702 | } | - | ||||||||||||||||||
| 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 || fileMode == QFileDialog::DirectoryOnly) { | - | ||||||||||||||||||
| 2708 | if (path == rootPath() && lineEdit()->text() == oldName) | - | ||||||||||||||||||
| 2709 | lineEdit()->setText(newName); | - | ||||||||||||||||||
| 2710 | } | - | ||||||||||||||||||
| 2711 | } | - | ||||||||||||||||||
| 2712 | - | |||||||||||||||||||
| 2713 | void QFileDialogPrivate::_q_emitUrlSelected(const QUrl &file) | - | ||||||||||||||||||
| 2714 | { | - | ||||||||||||||||||
| 2715 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2716 | q->urlSelected(file); | - | ||||||||||||||||||
| 2717 | if (file.isLocalFile()) | - | ||||||||||||||||||
| 2718 | q->fileSelected(file.toLocalFile()); | - | ||||||||||||||||||
| 2719 | } | - | ||||||||||||||||||
| 2720 | - | |||||||||||||||||||
| 2721 | void QFileDialogPrivate::_q_emitUrlsSelected(const QList<QUrl> &files) | - | ||||||||||||||||||
| 2722 | { | - | ||||||||||||||||||
| 2723 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2724 | q->urlsSelected(files); | - | ||||||||||||||||||
| 2725 | QStringList localFiles; | - | ||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(files)>::type> _container_((files)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
| 2726 | ++_container_.i, _container_.control ^= 1)for (const QUrl &file = *_container_.i; _container_.control; _container_.control = 0: 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()) | - | ||||||||||||||||||
| 2738 | q->currentChanged(file.toLocalFile()); | - | ||||||||||||||||||
| 2739 | } | - | ||||||||||||||||||
| 2740 | - | |||||||||||||||||||
| 2741 | void QFileDialogPrivate::_q_nativeEnterDirectory(const QUrl &directory) | - | ||||||||||||||||||
| 2742 | { | - | ||||||||||||||||||
| 2743 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2744 | q->directoryUrlEntered(directory); | - | ||||||||||||||||||
| 2745 | if (!directory.isEmpty()) { | - | ||||||||||||||||||
| 2746 | *lastVisitedDir() = directory; | - | ||||||||||||||||||
| 2747 | if (directory.isLocalFile()) | - | ||||||||||||||||||
| 2748 | q->directoryEntered(directory.toLocalFile()); | - | ||||||||||||||||||
| 2749 | } | - | ||||||||||||||||||
| 2750 | } | - | ||||||||||||||||||
| 2751 | bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { | - | ||||||||||||||||||
| 2752 | - | |||||||||||||||||||
| 2753 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2754 | - | |||||||||||||||||||
| 2755 | if (event->matches(QKeySequence::Cancel)) { | - | ||||||||||||||||||
| 2756 | q->reject(); | - | ||||||||||||||||||
| 2757 | return true; | - | ||||||||||||||||||
| 2758 | } | - | ||||||||||||||||||
| 2759 | - | |||||||||||||||||||
| 2760 | switch (event->key()) { | - | ||||||||||||||||||
| 2761 | case Qt::Key_Backspace: | - | ||||||||||||||||||
| 2762 | _q_navigateToParent(); | - | ||||||||||||||||||
| 2763 | return true; | - | ||||||||||||||||||
| 2764 | case Qt::Key_Back: | - | ||||||||||||||||||
| 2765 | - | |||||||||||||||||||
| 2766 | - | |||||||||||||||||||
| 2767 | - | |||||||||||||||||||
| 2768 | - | |||||||||||||||||||
| 2769 | case Qt::Key_Left: | - | ||||||||||||||||||
| 2770 | if (event->key() == Qt::Key_Back || event->modifiers() == Qt::AltModifier) { | - | ||||||||||||||||||
| 2771 | _q_navigateBackward(); | - | ||||||||||||||||||
| 2772 | return true; | - | ||||||||||||||||||
| 2773 | } | - | ||||||||||||||||||
| 2774 | break; | - | ||||||||||||||||||
| 2775 | default: | - | ||||||||||||||||||
| 2776 | break; | - | ||||||||||||||||||
| 2777 | } | - | ||||||||||||||||||
| 2778 | return false; | - | ||||||||||||||||||
| 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.midmidRef(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 | } | - | ||||||||||||||||||
| 2802 | - | |||||||||||||||||||
| 2803 | void QFileDialogComboBox::showPopup() | - | ||||||||||||||||||
| 2804 | { | - | ||||||||||||||||||
| 2805 | if (model()->rowCount() > 1) | - | ||||||||||||||||||
| 2806 | QComboBox::showPopup(); | - | ||||||||||||||||||
| 2807 | - | |||||||||||||||||||
| 2808 | urlModel->setUrls(QList<QUrl>()); | - | ||||||||||||||||||
| 2809 | QList<QUrl> list; | - | ||||||||||||||||||
| 2810 | QModelIndex idx = d_ptr->model->index(d_ptr->rootPath()); | - | ||||||||||||||||||
| 2811 | while (idx.isValid()) { | - | ||||||||||||||||||
| 2812 | QUrl url = QUrl::fromLocalFile(idx.data(QFileSystemModel::FilePathRole).toString()); | - | ||||||||||||||||||
| 2813 | if (url.isValid()) | - | ||||||||||||||||||
| 2814 | list.append(url); | - | ||||||||||||||||||
| 2815 | idx = idx.parent(); | - | ||||||||||||||||||
| 2816 | } | - | ||||||||||||||||||
| 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(); ++i) { | - | ||||||||||||||||||
| 2825 | QUrl path = QUrl::fromLocalFile(m_history.at(i)); | - | ||||||||||||||||||
| 2826 | if (!urls.contains(path)) | - | ||||||||||||||||||
| 2827 | urls.prepend(path); | - | ||||||||||||||||||
| 2828 | } | - | ||||||||||||||||||
| 2829 | if (urls.count() > 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) { | - | ||||||||||||||||||
| 2836 | Qt::ItemFlags flags = m->flags(idx); | - | ||||||||||||||||||
| 2837 | flags &= ~Qt::ItemIsEnabled; | - | ||||||||||||||||||
| 2838 | m->item(idx.row(), idx.column())->setFlags(flags); | - | ||||||||||||||||||
| 2839 | } | - | ||||||||||||||||||
| 2840 | urlModel->addUrls(urls, -1, false); | - | ||||||||||||||||||
| 2841 | } | - | ||||||||||||||||||
| 2842 | setCurrentIndex(0); | - | ||||||||||||||||||
| 2843 | - | |||||||||||||||||||
| 2844 | QComboBox::showPopup(); | - | ||||||||||||||||||
| 2845 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 2866 | - | |||||||||||||||||||
| 2867 | QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent) | - | ||||||||||||||||||
| 2868 | { | - | ||||||||||||||||||
| 2869 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 2883 | - | |||||||||||||||||||
| 2884 | QSize QFileDialogListView::sizeHint() const | - | ||||||||||||||||||
| 2885 | { | - | ||||||||||||||||||
| 2886 | int height = qMax(10, sizeHintForRow(0)); | - | ||||||||||||||||||
| 2887 | return QSize(QListView::sizeHint().width() * 2, height * 30); | - | ||||||||||||||||||
| 2888 | } | - | ||||||||||||||||||
| 2889 | - | |||||||||||||||||||
| 2890 | void QFileDialogListView::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 2891 | { | - | ||||||||||||||||||
| 2892 | - | |||||||||||||||||||
| 2893 | - | |||||||||||||||||||
| 2894 | - | |||||||||||||||||||
| 2895 | - | |||||||||||||||||||
| 2896 | - | |||||||||||||||||||
| 2897 | - | |||||||||||||||||||
| 2898 | - | |||||||||||||||||||
| 2899 | if (!d_ptr->itemViewKeyboardEvent(e)) | - | ||||||||||||||||||
| 2900 | QListView::keyPressEvent(e); | - | ||||||||||||||||||
| 2901 | e->accept(); | - | ||||||||||||||||||
| 2902 | } | - | ||||||||||||||||||
| 2903 | - | |||||||||||||||||||
| 2904 | QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) | - | ||||||||||||||||||
| 2905 | { | - | ||||||||||||||||||
| 2906 | } | - | ||||||||||||||||||
| 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 | } | - | ||||||||||||||||||
| 2924 | - | |||||||||||||||||||
| 2925 | void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 2926 | { | - | ||||||||||||||||||
| 2927 | - | |||||||||||||||||||
| 2928 | - | |||||||||||||||||||
| 2929 | - | |||||||||||||||||||
| 2930 | - | |||||||||||||||||||
| 2931 | - | |||||||||||||||||||
| 2932 | - | |||||||||||||||||||
| 2933 | - | |||||||||||||||||||
| 2934 | if (!d_ptr->itemViewKeyboardEvent(e)) | - | ||||||||||||||||||
| 2935 | QTreeView::keyPressEvent(e); | - | ||||||||||||||||||
| 2936 | e->accept(); | - | ||||||||||||||||||
| 2937 | } | - | ||||||||||||||||||
| 2938 | - | |||||||||||||||||||
| 2939 | QSize QFileDialogTreeView::sizeHint() const | - | ||||||||||||||||||
| 2940 | { | - | ||||||||||||||||||
| 2941 | int height = qMax(10, sizeHintForRow(0)); | - | ||||||||||||||||||
| 2942 | QSize sizeHint = header()->sizeHint(); | - | ||||||||||||||||||
| 2943 | return QSize(sizeHint.width() * 4, height * 30); | - | ||||||||||||||||||
| 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) && key != Qt::Key_Back) | - | ||||||||||||||||||
| 2962 | e->accept(); | - | ||||||||||||||||||
| 2963 | } | - | ||||||||||||||||||
| 2964 | - | |||||||||||||||||||
| 2965 | - | |||||||||||||||||||
| 2966 | - | |||||||||||||||||||
| 2967 | QString QFSCompleter::pathFromIndex(const QModelIndex &index) const | - | ||||||||||||||||||
| 2968 | { | - | ||||||||||||||||||
| 2969 | const QFileSystemModel *dirModel; | - | ||||||||||||||||||
| 2970 | if (proxyModel) | - | ||||||||||||||||||
| 2971 | dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); | - | ||||||||||||||||||
| 2972 | else | - | ||||||||||||||||||
| 2973 | dirModel = sourceModel; | - | ||||||||||||||||||
| 2974 | QString currentLocation = dirModel->rootPath(); | - | ||||||||||||||||||
| 2975 | QString path = index.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 2976 | if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) { | - | ||||||||||||||||||
| 2977 | - | |||||||||||||||||||
| 2978 | if (currentLocation == QDir::separator()) | - | ||||||||||||||||||
| 2979 | return path.mid(currentLocation.length()); | - | ||||||||||||||||||
| 2980 | - | |||||||||||||||||||
| 2981 | if (currentLocation.endsWith(QLatin1Char('/'))) | - | ||||||||||||||||||
| 2982 | return path.mid(currentLocation.length()); | - | ||||||||||||||||||
| 2983 | else | - | ||||||||||||||||||
| 2984 | return path.mid(currentLocation.length()+1); | - | ||||||||||||||||||
| 2985 | } | - | ||||||||||||||||||
| 2986 | return index.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 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 | bool expanded; | - | ||||||||||||||||||
| pathCopy{ | ||||||||||||||||||||
| 2997 | QString tildeExpanded = qt_tildeExpansion(pathCopy, &expanded); | - | ||||||||||||||||||
| 2998 | if (expandedtildeExpanded != 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(pathCopytildeExpanded)); | - | ||||||||||||||||||
| 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 |