| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qfiledialog.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | namespace { namespace Q_QGS_lastVisitedDir { typedef QUrl Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QUrl, Q_QGS_lastVisitedDir::innerFunction, Q_QGS_lastVisitedDir::guard> lastVisitedDir;return &holder.value; | 0 | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | QFileDialog::QFileDialog(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||
| 17 | : QDialog(*new QFileDialogPrivate, parent, f) | - | ||||||||||||||||||
| 18 | { | - | ||||||||||||||||||
| 19 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 20 | d->init(); | - | ||||||||||||||||||
| 21 | } never executed: end of block | 0 | ||||||||||||||||||
| 22 | QFileDialog::QFileDialog(QWidget *parent, | - | ||||||||||||||||||
| 23 | const QString &caption, | - | ||||||||||||||||||
| 24 | const QString &directory, | - | ||||||||||||||||||
| 25 | const QString &filter) | - | ||||||||||||||||||
| 26 | : QDialog(*new QFileDialogPrivate, parent, 0) | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 29 | d->init(QUrl::fromLocalFile(directory), filter, caption); | - | ||||||||||||||||||
| 30 | } never executed: end of block | 0 | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | QFileDialog::QFileDialog(const QFileDialogArgs &args) | - | ||||||||||||||||||
| 36 | : QDialog(*new QFileDialogPrivate, args.parent, 0) | - | ||||||||||||||||||
| 37 | { | - | ||||||||||||||||||
| 38 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 39 | d->init(args.directory, args.filter, args.caption); | - | ||||||||||||||||||
| 40 | setFileMode(args.mode); | - | ||||||||||||||||||
| 41 | setOptions(args.options); | - | ||||||||||||||||||
| 42 | selectFile(args.selection); | - | ||||||||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | QFileDialog::~QFileDialog() | - | ||||||||||||||||||
| 49 | { | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 52 | d->saveSettings(); | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||
| 55 | void QFileDialog::setSidebarUrls(const QList<QUrl> &urls) | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 58 | if (!d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 59 | d->qFileDialogUi->sidebar->setUrls(urls); never executed: d->qFileDialogUi->sidebar->setUrls(urls); | 0 | ||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | QList<QUrl> QFileDialog::sidebarUrls() const | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 69 | return never executed: (d->nativeDialogInUsereturn (d->nativeDialogInUse ? QList<QUrl>() : d->qFileDialogUi->sidebar->urls());
never executed: return (d->nativeDialogInUse ? QList<QUrl>() : d->qFileDialogUi->sidebar->urls()); | 0 | ||||||||||||||||||
| 70 | } | - | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | static const qint32 QFileDialogMagic = 0xbe; | - | ||||||||||||||||||
| 73 | QByteArray QFileDialog::saveState() const | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 76 | int version = 4; | - | ||||||||||||||||||
| 77 | QByteArray data; | - | ||||||||||||||||||
| 78 | QDataStream stream(&data, QIODevice::WriteOnly); | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | stream << qint32(QFileDialogMagic); | - | ||||||||||||||||||
| 81 | stream << qint32(version); | - | ||||||||||||||||||
| 82 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 83 | stream << d->qFileDialogUi->splitter->saveState(); | - | ||||||||||||||||||
| 84 | stream << d->qFileDialogUi->sidebar->urls(); | - | ||||||||||||||||||
| 85 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 86 | stream << d->splitterState; | - | ||||||||||||||||||
| 87 | stream << d->sidebarUrls; | - | ||||||||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||||||||
| 89 | stream << history(); | - | ||||||||||||||||||
| 90 | stream << *lastVisitedDir(); | - | ||||||||||||||||||
| 91 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 92 | stream << d->qFileDialogUi->treeView->header()->saveState(); never executed: stream << d->qFileDialogUi->treeView->header()->saveState(); | 0 | ||||||||||||||||||
| 93 | else | - | ||||||||||||||||||
| 94 | stream << d->headerData; never executed: stream << d->headerData; | 0 | ||||||||||||||||||
| 95 | stream << qint32(viewMode()); | - | ||||||||||||||||||
| 96 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||||||||
| 97 | } | - | ||||||||||||||||||
| 98 | bool QFileDialog::restoreState(const QByteArray &state) | - | ||||||||||||||||||
| 99 | { | - | ||||||||||||||||||
| 100 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 101 | QByteArray sd = state; | - | ||||||||||||||||||
| 102 | QDataStream stream(&sd, QIODevice::ReadOnly); | - | ||||||||||||||||||
| 103 | if (stream.atEnd()
| 0 | ||||||||||||||||||
| 104 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 105 | QStringList history; | - | ||||||||||||||||||
| 106 | QUrl currentDirectory; | - | ||||||||||||||||||
| 107 | qint32 marker; | - | ||||||||||||||||||
| 108 | qint32 v; | - | ||||||||||||||||||
| 109 | qint32 viewMode; | - | ||||||||||||||||||
| 110 | stream >> marker; | - | ||||||||||||||||||
| 111 | stream >> v; | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | if (marker != QFileDialogMagic
| 0 | ||||||||||||||||||
| 114 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | stream >> d->splitterState | - | ||||||||||||||||||
| 117 | >> d->sidebarUrls | - | ||||||||||||||||||
| 118 | >> history; | - | ||||||||||||||||||
| 119 | if (v == 3
| 0 | ||||||||||||||||||
| 120 | QString currentDirectoryString; | - | ||||||||||||||||||
| 121 | stream >> currentDirectoryString; | - | ||||||||||||||||||
| 122 | currentDirectory = QUrl::fromLocalFile(currentDirectoryString); | - | ||||||||||||||||||
| 123 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 124 | stream >> currentDirectory; | - | ||||||||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||||||||
| 126 | stream >> d->headerData | - | ||||||||||||||||||
| 127 | >> viewMode; | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | setDirectoryUrl(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir()); | - | ||||||||||||||||||
| 130 | setViewMode(static_cast<QFileDialog::ViewMode>(viewMode)); | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 133 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | return never executed: d->restoreWidgetState(history, -1);return d->restoreWidgetState(history, -1);never executed: return d->restoreWidgetState(history, -1); | 0 | ||||||||||||||||||
| 136 | } | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | void QFileDialog::changeEvent(QEvent *e) | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 144 | if (e->type() == QEvent::LanguageChange
| 0 | ||||||||||||||||||
| 145 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 146 | d->retranslateStrings(); | - | ||||||||||||||||||
| 147 | } never executed: end of block | 0 | ||||||||||||||||||
| 148 | QDialog::changeEvent(e); | - | ||||||||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | QFileDialogPrivate::QFileDialogPrivate() | - | ||||||||||||||||||
| 152 | : | - | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | proxyModel(0), | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | model(0), | - | ||||||||||||||||||
| 157 | currentHistoryLocation(-1), | - | ||||||||||||||||||
| 158 | renameAction(0), | - | ||||||||||||||||||
| 159 | deleteAction(0), | - | ||||||||||||||||||
| 160 | showHiddenAction(0), | - | ||||||||||||||||||
| 161 | useDefaultCaption(true), | - | ||||||||||||||||||
| 162 | defaultFileTypes(true), | - | ||||||||||||||||||
| 163 | qFileDialogUi(0), | - | ||||||||||||||||||
| 164 | options(new QFileDialogOptions) | - | ||||||||||||||||||
| 165 | { | - | ||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | QFileDialogPrivate::~QFileDialogPrivate() | - | ||||||||||||||||||
| 169 | { | - | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h) | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | QFileDialog *d = q_func(); | - | ||||||||||||||||||
| 175 | QObject::connect(h, qFlagLocation("2""fileSelected(QUrl)" "\0" __FILE__ ":" "542"), d, qFlagLocation("1""_q_emitUrlSelected(QUrl)" "\0" __FILE__ ":" "542")); | - | ||||||||||||||||||
| 176 | QObject::connect(h, qFlagLocation("2""filesSelected(QList<QUrl>)" "\0" __FILE__ ":" "543"), d, qFlagLocation("1""_q_emitUrlsSelected(QList<QUrl>)" "\0" __FILE__ ":" "543")); | - | ||||||||||||||||||
| 177 | QObject::connect(h, qFlagLocation("2""currentChanged(QUrl)" "\0" __FILE__ ":" "544"), d, qFlagLocation("1""_q_nativeCurrentChanged(QUrl)" "\0" __FILE__ ":" "544")); | - | ||||||||||||||||||
| 178 | QObject::connect(h, qFlagLocation("2""directoryEntered(QUrl)" "\0" __FILE__ ":" "545"), d, qFlagLocation("1""_q_nativeEnterDirectory(QUrl)" "\0" __FILE__ ":" "545")); | - | ||||||||||||||||||
| 179 | QObject::connect(h, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "546"), d, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "546")); | - | ||||||||||||||||||
| 180 | static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); | - | ||||||||||||||||||
| 181 | nativeDialogInUse = true; | - | ||||||||||||||||||
| 182 | } never executed: end of block | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 187 | options->setWindowTitle(q->windowTitle()); | - | ||||||||||||||||||
| 188 | options->setHistory(q->history()); | - | ||||||||||||||||||
| 189 | if (usingWidgets()
| 0 | ||||||||||||||||||
| 190 | options->setSidebarUrls(qFileDialogUi->sidebar->urls()); never executed: options->setSidebarUrls(qFileDialogUi->sidebar->urls()); | 0 | ||||||||||||||||||
| 191 | if (options->initiallySelectedNameFilter().isEmpty()
| 0 | ||||||||||||||||||
| 192 | options->setInitiallySelectedNameFilter(q->selectedNameFilter()); never executed: options->setInitiallySelectedNameFilter(q->selectedNameFilter()); | 0 | ||||||||||||||||||
| 193 | if (options->initiallySelectedFiles().isEmpty()
| 0 | ||||||||||||||||||
| 194 | options->setInitiallySelectedFiles(userSelectedFiles()); never executed: options->setInitiallySelectedFiles(userSelectedFiles()); | 0 | ||||||||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) | - | ||||||||||||||||||
| 198 | { | - | ||||||||||||||||||
| 199 | if (code == QDialog::Accepted
| 0 | ||||||||||||||||||
| 200 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 201 | q->setViewMode(static_cast<QFileDialog::ViewMode>(options->viewMode())); | - | ||||||||||||||||||
| 202 | q->setSidebarUrls(options->sidebarUrls()); | - | ||||||||||||||||||
| 203 | q->setHistory(options->history()); | - | ||||||||||||||||||
| 204 | } never executed: end of block | 0 | ||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | void QFileDialogPrivate::retranslateWindowTitle() | - | ||||||||||||||||||
| 208 | { | - | ||||||||||||||||||
| 209 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 210 | if (!useDefaultCaption
| 0 | ||||||||||||||||||
| 211 | return; never executed: return; | 0 | ||||||||||||||||||
| 212 | if (q->acceptMode() == QFileDialog::AcceptOpen
| 0 | ||||||||||||||||||
| 213 | const QFileDialog::FileMode fileMode = q->fileMode(); | - | ||||||||||||||||||
| 214 | if (fileMode == QFileDialog::DirectoryOnly
| 0 | ||||||||||||||||||
| 215 | q->setWindowTitle(QFileDialog::tr("Find Directory")); never executed: q->setWindowTitle(QFileDialog::tr("Find Directory")); | 0 | ||||||||||||||||||
| 216 | else | - | ||||||||||||||||||
| 217 | q->setWindowTitle(QFileDialog::tr("Open")); never executed: q->setWindowTitle(QFileDialog::tr("Open")); | 0 | ||||||||||||||||||
| 218 | } else | - | ||||||||||||||||||
| 219 | q->setWindowTitle(QFileDialog::tr("Save As")); never executed: q->setWindowTitle(QFileDialog::tr("Save As")); | 0 | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | setWindowTitle = q->windowTitle(); | - | ||||||||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | void QFileDialogPrivate::setLastVisitedDirectory(const QUrl &dir) | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | *lastVisitedDir() = dir; | - | ||||||||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | void QFileDialogPrivate::updateLookInLabel() | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | if (options->isLabelExplicitlySet(QFileDialogOptions::LookIn)
| 0 | ||||||||||||||||||
| 232 | setLabelTextControl(QFileDialog::LookIn, options->labelText(QFileDialogOptions::LookIn)); never executed: setLabelTextControl(QFileDialog::LookIn, options->labelText(QFileDialogOptions::LookIn)); | 0 | ||||||||||||||||||
| 233 | } never executed: end of block | 0 | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | void QFileDialogPrivate::updateFileNameLabel() | - | ||||||||||||||||||
| 236 | { | - | ||||||||||||||||||
| 237 | if (options->isLabelExplicitlySet(QFileDialogOptions::FileName)
| 0 | ||||||||||||||||||
| 238 | setLabelTextControl(QFileDialog::FileName, options->labelText(QFileDialogOptions::FileName)); | - | ||||||||||||||||||
| 239 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 240 | switch (q_func()->fileMode()) { | - | ||||||||||||||||||
| 241 | case never executed: QFileDialog::DirectoryOnly:case QFileDialog::DirectoryOnly:never executed: case QFileDialog::DirectoryOnly: | 0 | ||||||||||||||||||
| 242 | case never executed: QFileDialog::Directory:case QFileDialog::Directory:never executed: case QFileDialog::Directory: | 0 | ||||||||||||||||||
| 243 | setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:")); | - | ||||||||||||||||||
| 244 | break; never executed: break; | 0 | ||||||||||||||||||
| 245 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 246 | setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("File &name:")); | - | ||||||||||||||||||
| 247 | break; never executed: break; | 0 | ||||||||||||||||||
| 248 | } | - | ||||||||||||||||||
| 249 | } | - | ||||||||||||||||||
| 250 | } | - | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | void QFileDialogPrivate::updateFileTypeLabel() | - | ||||||||||||||||||
| 253 | { | - | ||||||||||||||||||
| 254 | if (options->isLabelExplicitlySet(QFileDialogOptions::FileType)
| 0 | ||||||||||||||||||
| 255 | setLabelTextControl(QFileDialog::FileType, options->labelText(QFileDialogOptions::FileType)); never executed: setLabelTextControl(QFileDialog::FileType, options->labelText(QFileDialogOptions::FileType)); | 0 | ||||||||||||||||||
| 256 | } never executed: end of block | 0 | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder) | - | ||||||||||||||||||
| 259 | { | - | ||||||||||||||||||
| 260 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | if (saveAsOnFolder
| 0 | ||||||||||||||||||
| 263 | setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Open")); | - | ||||||||||||||||||
| 264 | } never executed: else if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)end of block
| 0 | ||||||||||||||||||
| 265 | setLabelTextControl(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept)); | - | ||||||||||||||||||
| 266 | return; never executed: return; | 0 | ||||||||||||||||||
| 267 | } else { | - | ||||||||||||||||||
| 268 | switch (q->fileMode()) { | - | ||||||||||||||||||
| 269 | case never executed: QFileDialog::DirectoryOnly:case QFileDialog::DirectoryOnly:never executed: case QFileDialog::DirectoryOnly: | 0 | ||||||||||||||||||
| 270 | case never executed: QFileDialog::Directory:case QFileDialog::Directory:never executed: case QFileDialog::Directory: | 0 | ||||||||||||||||||
| 271 | setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose")); | - | ||||||||||||||||||
| 272 | break; never executed: break; | 0 | ||||||||||||||||||
| 273 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 274 | setLabelTextControl(QFileDialog::Accept, | - | ||||||||||||||||||
| 275 | q->acceptMode() == QFileDialog::AcceptOpen ? | - | ||||||||||||||||||
| 276 | QFileDialog::tr("&Open") : | - | ||||||||||||||||||
| 277 | QFileDialog::tr("&Save")); | - | ||||||||||||||||||
| 278 | break; never executed: break; | 0 | ||||||||||||||||||
| 279 | } | - | ||||||||||||||||||
| 280 | } | - | ||||||||||||||||||
| 281 | } | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | void QFileDialogPrivate::updateCancelButtonText() | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | if (options->isLabelExplicitlySet(QFileDialogOptions::Reject)
| 0 | ||||||||||||||||||
| 286 | setLabelTextControl(QFileDialog::Reject, options->labelText(QFileDialogOptions::Reject)); never executed: setLabelTextControl(QFileDialog::Reject, options->labelText(QFileDialogOptions::Reject)); | 0 | ||||||||||||||||||
| 287 | } never executed: end of block | 0 | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | void QFileDialogPrivate::retranslateStrings() | - | ||||||||||||||||||
| 290 | { | - | ||||||||||||||||||
| 291 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | if (defaultFileTypes
| 0 | ||||||||||||||||||
| 294 | q->setNameFilter(QFileDialog::tr("All Files (*)")); never executed: q->setNameFilter(QFileDialog::tr("All Files (*)")); | 0 | ||||||||||||||||||
| 295 | if (!usingWidgets()
| 0 | ||||||||||||||||||
| 296 | return; never executed: return; | 0 | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | QList<QAction*> actions = qFileDialogUi->treeView->header()->actions(); | - | ||||||||||||||||||
| 299 | QAbstractItemModel *abstractModel = model; | - | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | if (proxyModel
| 0 | ||||||||||||||||||
| 302 | abstractModel = proxyModel; never executed: abstractModel = proxyModel; | 0 | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); | - | ||||||||||||||||||
| 305 | for (int i = 1; i < total
| 0 | ||||||||||||||||||
| 306 | actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); | - | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | renameAction->setText(QFileDialog::tr("&Rename")); | - | ||||||||||||||||||
| 311 | deleteAction->setText(QFileDialog::tr("&Delete")); | - | ||||||||||||||||||
| 312 | showHiddenAction->setText(QFileDialog::tr("Show &hidden files")); | - | ||||||||||||||||||
| 313 | newFolderAction->setText(QFileDialog::tr("&New Folder")); | - | ||||||||||||||||||
| 314 | qFileDialogUi->retranslateUi(q); | - | ||||||||||||||||||
| 315 | updateLookInLabel(); | - | ||||||||||||||||||
| 316 | updateFileNameLabel(); | - | ||||||||||||||||||
| 317 | updateFileTypeLabel(); | - | ||||||||||||||||||
| 318 | updateCancelButtonText(); | - | ||||||||||||||||||
| 319 | } never executed: end of block | 0 | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | void QFileDialogPrivate::emitFilesSelected(const QStringList &files) | - | ||||||||||||||||||
| 322 | { | - | ||||||||||||||||||
| 323 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 324 | q->filesSelected(files); | - | ||||||||||||||||||
| 325 | if (files.count() == 1
| 0 | ||||||||||||||||||
| 326 | q->fileSelected(files.first()); never executed: q->fileSelected(files.first()); | 0 | ||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | bool QFileDialogPrivate::canBeNativeDialog() const | - | ||||||||||||||||||
| 330 | { | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | const QDialog * const q = static_cast<const QDialog*>(q_ptr); | - | ||||||||||||||||||
| 334 | if (nativeDialogInUse
| 0 | ||||||||||||||||||
| 335 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 336 | if (q->testAttribute(Qt::WA_DontShowOnScreen)
| 0 | ||||||||||||||||||
| 337 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 338 | if (options->options() & QFileDialog::DontUseNativeDialog
| 0 | ||||||||||||||||||
| 339 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | QLatin1String staticName(QFileDialog::staticMetaObject.className()); | - | ||||||||||||||||||
| 342 | QLatin1String dynamicName(q->metaObject()->className()); | - | ||||||||||||||||||
| 343 | return never executed: (staticName == dynamicName);return (staticName == dynamicName);never executed: return (staticName == dynamicName); | 0 | ||||||||||||||||||
| 344 | } | - | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | bool QFileDialogPrivate::usingWidgets() const | - | ||||||||||||||||||
| 347 | { | - | ||||||||||||||||||
| 348 | return never executed: !nativeDialogInUsereturn !nativeDialogInUse && qFileDialogUi;
never executed: return !nativeDialogInUse && qFileDialogUi; | 0 | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | void QFileDialog::setOption(Option option, bool on) | - | ||||||||||||||||||
| 351 | { | - | ||||||||||||||||||
| 352 | const QFileDialog::Options previousOptions = options(); | - | ||||||||||||||||||
| 353 | if (!(previousOptions & option) != !on
| 0 | ||||||||||||||||||
| 354 | setOptions(previousOptions ^ option); never executed: setOptions(previousOptions ^ option); | 0 | ||||||||||||||||||
| 355 | } never executed: end of block | 0 | ||||||||||||||||||
| 356 | bool QFileDialog::testOption(Option option) const | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 359 | return never executed: d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option));return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option));never executed: return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option)); | 0 | ||||||||||||||||||
| 360 | } | - | ||||||||||||||||||
| 361 | void QFileDialog::setOptions(Options options) | - | ||||||||||||||||||
| 362 | { | - | ||||||||||||||||||
| 363 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | Options changed = (options ^ QFileDialog::options()); | - | ||||||||||||||||||
| 366 | if (!changed
| 0 | ||||||||||||||||||
| 367 | return; never executed: return; | 0 | ||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | d->options->setOptions(QFileDialogOptions::FileDialogOptions(int(options))); | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | if ((
| 0 | ||||||||||||||||||
| 372 | d->createWidgets(); never executed: d->createWidgets(); | 0 | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 375 | if (changed & DontResolveSymlinks
| 0 | ||||||||||||||||||
| 376 | d->model->setResolveSymlinks(!(options & DontResolveSymlinks)); never executed: d->model->setResolveSymlinks(!(options & DontResolveSymlinks)); | 0 | ||||||||||||||||||
| 377 | if (changed & ReadOnly
| 0 | ||||||||||||||||||
| 378 | bool ro = (options & ReadOnly); | - | ||||||||||||||||||
| 379 | d->model->setReadOnly(ro); | - | ||||||||||||||||||
| 380 | d->qFileDialogUi->newFolderButton->setEnabled(!ro); | - | ||||||||||||||||||
| 381 | d->renameAction->setEnabled(!ro); | - | ||||||||||||||||||
| 382 | d->deleteAction->setEnabled(!ro); | - | ||||||||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | if (changed & DontUseCustomDirectoryIcons
| 0 | ||||||||||||||||||
| 386 | QFileIconProvider::Options providerOptions = iconProvider()->options(); | - | ||||||||||||||||||
| 387 | if (options & DontUseCustomDirectoryIcons
| 0 | ||||||||||||||||||
| 388 | providerOptions |= QFileIconProvider::DontUseCustomDirectoryIcons; never executed: providerOptions |= QFileIconProvider::DontUseCustomDirectoryIcons; | 0 | ||||||||||||||||||
| 389 | else | - | ||||||||||||||||||
| 390 | providerOptions &= ~QFileIconProvider::DontUseCustomDirectoryIcons; never executed: providerOptions &= ~QFileIconProvider::DontUseCustomDirectoryIcons; | 0 | ||||||||||||||||||
| 391 | iconProvider()->setOptions(providerOptions); | - | ||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | if (changed & HideNameFilterDetails
| 0 | ||||||||||||||||||
| 396 | setNameFilters(d->options->nameFilters()); never executed: setNameFilters(d->options->nameFilters()); | 0 | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | if (changed & ShowDirsOnly
| 0 | ||||||||||||||||||
| 399 | setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files); never executed: setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files); | 0 | ||||||||||||||||||
| 400 | } never executed: end of block | 0 | ||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | QFileDialog::Options QFileDialog::options() const | - | ||||||||||||||||||
| 403 | { | - | ||||||||||||||||||
| 404 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 405 | return never executed: QFileDialog::Options(int(d->options->options()));return QFileDialog::Options(int(d->options->options()));never executed: return QFileDialog::Options(int(d->options->options())); | 0 | ||||||||||||||||||
| 406 | } | - | ||||||||||||||||||
| 407 | void QFileDialog::open(QObject *receiver, const char *member) | - | ||||||||||||||||||
| 408 | { | - | ||||||||||||||||||
| 409 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 410 | const char *signal = (
| 0 | ||||||||||||||||||
| 411 | : qFlagLocation("2""fileSelected(QString)" "\0" __FILE__ ":" "821"); | - | ||||||||||||||||||
| 412 | connect(this, signal, receiver, member); | - | ||||||||||||||||||
| 413 | d->signalToDisconnectOnClose = signal; | - | ||||||||||||||||||
| 414 | d->receiverToDisconnectOnClose = receiver; | - | ||||||||||||||||||
| 415 | d->memberToDisconnectOnClose = member; | - | ||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | QDialog::open(); | - | ||||||||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | void QFileDialog::setVisible(bool visible) | - | ||||||||||||||||||
| 425 | { | - | ||||||||||||||||||
| 426 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 427 | if (visible
| 0 | ||||||||||||||||||
| 428 | if (testAttribute(Qt::WA_WState_ExplicitShowHide)
| 0 | ||||||||||||||||||
| 429 | return; never executed: return; | 0 | ||||||||||||||||||
| 430 | } never executed: else if (testAttribute(Qt::WA_WState_ExplicitShowHide)end of block
| 0 | ||||||||||||||||||
| 431 | return; never executed: return; | 0 | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | if (d->canBeNativeDialog()
| 0 | ||||||||||||||||||
| 434 | if (d->setNativeDialogVisible(visible)
| 0 | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | setAttribute(Qt::WA_DontShowOnScreen); | - | ||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | if (!d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 441 | d->completer->setModel(0); never executed: d->completer->setModel(0); | 0 | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 444 | d->createWidgets(); | - | ||||||||||||||||||
| 445 | setAttribute(Qt::WA_DontShowOnScreen, false); | - | ||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | if (!d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 448 | if (d->proxyModel != 0
| 0 | ||||||||||||||||||
| 449 | d->completer->setModel(d->proxyModel); never executed: d->completer->setModel(d->proxyModel); | 0 | ||||||||||||||||||
| 450 | else | - | ||||||||||||||||||
| 451 | d->completer->setModel(d->model); never executed: d->completer->setModel(d->model); | 0 | ||||||||||||||||||
| 452 | } | - | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | } never executed: end of block | 0 | ||||||||||||||||||
| 455 | } | - | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 458 | d->qFileDialogUi->fileNameEdit->setFocus(); never executed: d->qFileDialogUi->fileNameEdit->setFocus(); | 0 | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | QDialog::setVisible(visible); | - | ||||||||||||||||||
| 461 | } never executed: end of block | 0 | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | void QFileDialogPrivate::_q_goToUrl(const QUrl &url) | - | ||||||||||||||||||
| 468 | { | - | ||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true); | - | ||||||||||||||||||
| 472 | QModelIndex idx = model->d_func()->index(node); | - | ||||||||||||||||||
| 473 | _q_enterDirectory(idx); | - | ||||||||||||||||||
| 474 | } never executed: end of block | 0 | ||||||||||||||||||
| 475 | void QFileDialog::setDirectory(const QString &directory) | - | ||||||||||||||||||
| 476 | { | - | ||||||||||||||||||
| 477 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 478 | QString newDirectory = directory; | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | if (!directory.isEmpty()
| 0 | ||||||||||||||||||
| 481 | newDirectory = QDir::cleanPath(directory); never executed: newDirectory = QDir::cleanPath(directory); | 0 | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | if (!directory.isEmpty()
| 0 | ||||||||||||||||||
| 484 | return; never executed: return; | 0 | ||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | QUrl newDirUrl = QUrl::fromLocalFile(newDirectory); | - | ||||||||||||||||||
| 487 | QFileDialogPrivate::setLastVisitedDirectory(newDirUrl); | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | d->options->setInitialDirectory(QUrl::fromLocalFile(directory)); | - | ||||||||||||||||||
| 490 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 491 | d->setDirectory_sys(newDirUrl); | - | ||||||||||||||||||
| 492 | return; never executed: return; | 0 | ||||||||||||||||||
| 493 | } | - | ||||||||||||||||||
| 494 | if (d->rootPath() == newDirectory
| 0 | ||||||||||||||||||
| 495 | return; never executed: return; | 0 | ||||||||||||||||||
| 496 | QModelIndex root = d->model->setRootPath(newDirectory); | - | ||||||||||||||||||
| 497 | if (!d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 498 | d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); | - | ||||||||||||||||||
| 499 | if (root != d->rootIndex()
| 0 | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | if (directory.endsWith(QLatin1Char('/'))
| 0 | ||||||||||||||||||
| 502 | d->completer->setCompletionPrefix(newDirectory); never executed: d->completer->setCompletionPrefix(newDirectory); | 0 | ||||||||||||||||||
| 503 | else | - | ||||||||||||||||||
| 504 | d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/')); never executed: d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/')); | 0 | ||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | d->setRootIndex(root); | - | ||||||||||||||||||
| 507 | } never executed: end of block | 0 | ||||||||||||||||||
| 508 | d->qFileDialogUi->listView->selectionModel()->clear(); | - | ||||||||||||||||||
| 509 | } never executed: end of block | 0 | ||||||||||||||||||
| 510 | } never executed: end of block | 0 | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | - | |||||||||||||||||||
| 515 | QDir QFileDialog::directory() const | - | ||||||||||||||||||
| 516 | { | - | ||||||||||||||||||
| 517 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 518 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 519 | QString dir = d->directory_sys().toLocalFile(); | - | ||||||||||||||||||
| 520 | return never executed: QDir(dir.isEmpty() ? d->options->initialDirectory().toLocalFile() : dir);return QDir(dir.isEmpty() ? d->options->initialDirectory().toLocalFile() : dir);never executed: return QDir(dir.isEmpty() ? d->options->initialDirectory().toLocalFile() : dir); | 0 | ||||||||||||||||||
| 521 | } | - | ||||||||||||||||||
| 522 | return never executed: d->rootPath();return d->rootPath();never executed: return d->rootPath(); | 0 | ||||||||||||||||||
| 523 | } | - | ||||||||||||||||||
| 524 | void QFileDialog::setDirectoryUrl(const QUrl &directory) | - | ||||||||||||||||||
| 525 | { | - | ||||||||||||||||||
| 526 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 527 | if (!directory.isValid()
| 0 | ||||||||||||||||||
| 528 | return; never executed: return; | 0 | ||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 | QFileDialogPrivate::setLastVisitedDirectory(directory); | - | ||||||||||||||||||
| 531 | d->options->setInitialDirectory(directory); | - | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 534 | d->setDirectory_sys(directory); never executed: d->setDirectory_sys(directory); | 0 | ||||||||||||||||||
| 535 | else if (directory.isLocalFile()
| 0 | ||||||||||||||||||
| 536 | setDirectory(directory.toLocalFile()); never executed: setDirectory(directory.toLocalFile()); | 0 | ||||||||||||||||||
| 537 | else if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 538 | QMessageLogger(__FILE__, 985, __PRETTY_FUNCTION__).warning("Non-native QFileDialog supports only local files"); never executed: QMessageLogger(__FILE__, 985, __PRETTY_FUNCTION__).warning("Non-native QFileDialog supports only local files"); | 0 | ||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | - | |||||||||||||||||||
| 545 | - | |||||||||||||||||||
| 546 | QUrl QFileDialog::directoryUrl() const | - | ||||||||||||||||||
| 547 | { | - | ||||||||||||||||||
| 548 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 549 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 550 | return never executed: d->directory_sys();return d->directory_sys();never executed: return d->directory_sys(); | 0 | ||||||||||||||||||
| 551 | else | - | ||||||||||||||||||
| 552 | return never executed: QUrl::fromLocalFile(directory().absolutePath());return QUrl::fromLocalFile(directory().absolutePath());never executed: return QUrl::fromLocalFile(directory().absolutePath()); | 0 | ||||||||||||||||||
| 553 | } | - | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | static inline bool isCaseSensitiveFileSystem(const QString &path) | - | ||||||||||||||||||
| 557 | { | - | ||||||||||||||||||
| 558 | (void)path; | - | ||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | } | - | ||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | - | |||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | static inline QString fileFromPath(const QString &rootPath, QString path) | - | ||||||||||||||||||
| 573 | { | - | ||||||||||||||||||
| 574 | if (!QFileInfo(path).isAbsolute()
| 0 | ||||||||||||||||||
| 575 | return never executed: path;return path;never executed: return path; | 0 | ||||||||||||||||||
| 576 | if (path.startsWith(rootPath, isCaseSensitiveFileSystem(rootPath) ? Qt::CaseSensitive : Qt::CaseInsensitive)
| 0 | ||||||||||||||||||
| 577 | path.remove(0, rootPath.size()); never executed: path.remove(0, rootPath.size()); | 0 | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | if (path.isEmpty()
| 0 | ||||||||||||||||||
| 580 | return never executed: path;return path;never executed: return path; | 0 | ||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | if (path.at(0) == QDir::separator()
| 0 | ||||||||||||||||||
| 583 | - | |||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | ) { | - | ||||||||||||||||||
| 588 | path.remove(0, 1); | - | ||||||||||||||||||
| 589 | } never executed: end of block | 0 | ||||||||||||||||||
| 590 | return never executed: path;return path;never executed: return path; | 0 | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | - | |||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | void QFileDialog::selectFile(const QString &filename) | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 601 | if (filename.isEmpty()
| 0 | ||||||||||||||||||
| 602 | return; never executed: return; | 0 | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 605 | QUrl url = QUrl::fromLocalFile(filename); | - | ||||||||||||||||||
| 606 | if (QFileInfo(filename).isRelative()
| 0 | ||||||||||||||||||
| 607 | QDir dir(d->options->initialDirectory().toLocalFile()); | - | ||||||||||||||||||
| 608 | url = QUrl::fromLocalFile(dir.absoluteFilePath(filename)); | - | ||||||||||||||||||
| 609 | } never executed: end of block | 0 | ||||||||||||||||||
| 610 | d->selectFile_sys(url); | - | ||||||||||||||||||
| 611 | d->options->setInitiallySelectedFiles(QList<QUrl>() << url); | - | ||||||||||||||||||
| 612 | return; never executed: return; | 0 | ||||||||||||||||||
| 613 | } | - | ||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | if (!QDir::isRelativePath(filename)
| 0 | ||||||||||||||||||
| 616 | QFileInfo info(filename); | - | ||||||||||||||||||
| 617 | QString filenamePath = info.absoluteDir().path(); | - | ||||||||||||||||||
| 618 | - | |||||||||||||||||||
| 619 | if (d->model->rootPath() != filenamePath
| 0 | ||||||||||||||||||
| 620 | setDirectory(filenamePath); never executed: setDirectory(filenamePath); | 0 | ||||||||||||||||||
| 621 | } never executed: end of block | 0 | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | QModelIndex index = d->model->index(filename); | - | ||||||||||||||||||
| 624 | d->qFileDialogUi->listView->selectionModel()->clear(); | - | ||||||||||||||||||
| 625 | if (!isVisible()
| 0 | ||||||||||||||||||
| 626 | d->lineEdit()->setText(index.isValid() ? index.data().toString() : fileFromPath(d->rootPath(), filename)); never executed: d->lineEdit()->setText(index.isValid() ? index.data().toString() : fileFromPath(d->rootPath(), filename)); | 0 | ||||||||||||||||||
| 627 | } never executed: end of block | 0 | ||||||||||||||||||
| 628 | void QFileDialog::selectUrl(const QUrl &url) | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 631 | if (!url.isValid()
| 0 | ||||||||||||||||||
| 632 | return; never executed: return; | 0 | ||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 635 | d->selectFile_sys(url); never executed: d->selectFile_sys(url); | 0 | ||||||||||||||||||
| 636 | else if (url.isLocalFile()
| 0 | ||||||||||||||||||
| 637 | selectFile(url.toLocalFile()); never executed: selectFile(url.toLocalFile()); | 0 | ||||||||||||||||||
| 638 | else | - | ||||||||||||||||||
| 639 | QMessageLogger(__FILE__, 1095, __PRETTY_FUNCTION__).warning("Non-native QFileDialog supports only local files"); never executed: QMessageLogger(__FILE__, 1095, __PRETTY_FUNCTION__).warning("Non-native QFileDialog supports only local files"); | 0 | ||||||||||||||||||
| 640 | } | - | ||||||||||||||||||
| 641 | - | |||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | __attribute__((visibility("default"))) QString qt_tildeExpansion(const QString &path, bool *expanded = 0) | - | ||||||||||||||||||
| 644 | { | - | ||||||||||||||||||
| 645 | if (expanded != 0
| 0 | ||||||||||||||||||
| 646 | * never executed: expanded = false;*expanded = false;never executed: *expanded = false; | 0 | ||||||||||||||||||
| 647 | if (!path.startsWith(QLatin1Char('~'))
| 0 | ||||||||||||||||||
| 648 | return never executed: path;return path;never executed: return path; | 0 | ||||||||||||||||||
| 649 | QString ret = path; | - | ||||||||||||||||||
| 650 | QStringList tokens = ret.split(QDir::separator()); | - | ||||||||||||||||||
| 651 | if (tokens.first() == QLatin1String("~")
| 0 | ||||||||||||||||||
| 652 | ret.replace(0, 1, QDir::homePath()); | - | ||||||||||||||||||
| 653 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 654 | QString userName = tokens.first(); | - | ||||||||||||||||||
| 655 | userName.remove(0, 1); | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | - | |||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | passwd pw; | - | ||||||||||||||||||
| 660 | passwd *tmpPw; | - | ||||||||||||||||||
| 661 | char buf[200]; | - | ||||||||||||||||||
| 662 | const int bufSize = sizeof(buf); | - | ||||||||||||||||||
| 663 | int err = 0; | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | - | |||||||||||||||||||
| 667 | err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); | - | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | if (err
| 0 | ||||||||||||||||||
| 670 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 671 | const QString homePath = QString::fromLocal8Bit(pw.pw_dir); | - | ||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | - | |||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | ret.replace(0, tokens.first().length(), homePath); | - | ||||||||||||||||||
| 679 | } never executed: end of block | 0 | ||||||||||||||||||
| 680 | if (expanded != 0
| 0 | ||||||||||||||||||
| 681 | * never executed: expanded = true;*expanded = true;never executed: *expanded = true; | 0 | ||||||||||||||||||
| 682 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 683 | } | - | ||||||||||||||||||
| 684 | - | |||||||||||||||||||
| 685 | - | |||||||||||||||||||
| 686 | - | |||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | QStringList QFileDialogPrivate::typedFiles() const | - | ||||||||||||||||||
| 690 | { | - | ||||||||||||||||||
| 691 | const QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 692 | QStringList files; | - | ||||||||||||||||||
| 693 | QString editText = lineEdit()->text(); | - | ||||||||||||||||||
| 694 | if (!editText.contains(QLatin1Char('"'))
| 0 | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | const QString prefix = q->directory().absolutePath() + QDir::separator(); | - | ||||||||||||||||||
| 697 | if (QFile::exists(prefix + editText)
| 0 | ||||||||||||||||||
| 698 | files << editText; never executed: files << editText; | 0 | ||||||||||||||||||
| 699 | else | - | ||||||||||||||||||
| 700 | files << qt_tildeExpansion(editText); never executed: files << qt_tildeExpansion(editText); | 0 | ||||||||||||||||||
| 701 | - | |||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | - | |||||||||||||||||||
| 704 | - | |||||||||||||||||||
| 705 | } else { | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | - | |||||||||||||||||||
| 708 | QStringList tokens = editText.split(QLatin1Char('\"')); | - | ||||||||||||||||||
| 709 | for (int i=0; i<tokens.size()
| 0 | ||||||||||||||||||
| 710 | if ((
| 0 | ||||||||||||||||||
| 711 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | const QString token = tokens.at(i); | - | ||||||||||||||||||
| 714 | const QString prefix = q->directory().absolutePath() + QDir::separator(); | - | ||||||||||||||||||
| 715 | if (QFile::exists(prefix + token)
| 0 | ||||||||||||||||||
| 716 | files << token; never executed: files << token; | 0 | ||||||||||||||||||
| 717 | else | - | ||||||||||||||||||
| 718 | files << qt_tildeExpansion(token); never executed: files << qt_tildeExpansion(token); | 0 | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | - | |||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | } | - | ||||||||||||||||||
| 723 | } never executed: end of block | 0 | ||||||||||||||||||
| 724 | return never executed: addDefaultSuffixToFiles(files);return addDefaultSuffixToFiles(files);never executed: return addDefaultSuffixToFiles(files); | 0 | ||||||||||||||||||
| 725 | } | - | ||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | - | |||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | QList<QUrl> QFileDialogPrivate::userSelectedFiles() const | - | ||||||||||||||||||
| 731 | { | - | ||||||||||||||||||
| 732 | QList<QUrl> files; | - | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | if (!usingWidgets()
| 0 | ||||||||||||||||||
| 735 | return never executed: addDefaultSuffixToUrls(selectedFiles_sys());return addDefaultSuffixToUrls(selectedFiles_sys());never executed: return addDefaultSuffixToUrls(selectedFiles_sys()); | 0 | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | const QModelIndexList selectedRows = qFileDialogUi->listView->selectionModel()->selectedRows(); | - | ||||||||||||||||||
| 738 | files.reserve(selectedRows.size()); | - | ||||||||||||||||||
| 739 | 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 = 0) | - | ||||||||||||||||||
| 740 | files.append(QUrl::fromLocalFile(index.data(QFileSystemModel::FilePathRole).toString())); never executed: files.append(QUrl::fromLocalFile(index.data(QFileSystemModel::FilePathRole).toString())); | 0 | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | if (files.isEmpty()
| 0 | ||||||||||||||||||
| 743 | const QStringList typedFilesList = typedFiles(); | - | ||||||||||||||||||
| 744 | files.reserve(typedFilesList.size()); | - | ||||||||||||||||||
| 745 | 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 = 0) | - | ||||||||||||||||||
| 746 | files.append(QUrl::fromLocalFile(path)); never executed: files.append(QUrl::fromLocalFile(path)); | 0 | ||||||||||||||||||
| 747 | } never executed: end of block | 0 | ||||||||||||||||||
| 748 | - | |||||||||||||||||||
| 749 | return never executed: files;return files;never executed: return files; | 0 | ||||||||||||||||||
| 750 | } | - | ||||||||||||||||||
| 751 | - | |||||||||||||||||||
| 752 | QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &filesToFix) const | - | ||||||||||||||||||
| 753 | { | - | ||||||||||||||||||
| 754 | QStringList files; | - | ||||||||||||||||||
| 755 | for (int i=0; i<filesToFix.size()
| 0 | ||||||||||||||||||
| 756 | QString name = toInternal(filesToFix.at(i)); | - | ||||||||||||||||||
| 757 | QFileInfo info(name); | - | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | const QString defaultSuffix = options->defaultSuffix(); | - | ||||||||||||||||||
| 760 | if (!defaultSuffix.isEmpty()
| 0 | ||||||||||||||||||
| 761 | name += QLatin1Char('.') + defaultSuffix; never executed: name += QLatin1Char('.') + defaultSuffix; | 0 | ||||||||||||||||||
| 762 | if (info.isAbsolute()
| 0 | ||||||||||||||||||
| 763 | files.append(name); | - | ||||||||||||||||||
| 764 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 765 | - | |||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | - | |||||||||||||||||||
| 768 | QString path = rootPath(); | - | ||||||||||||||||||
| 769 | if (!path.endsWith(QLatin1Char('/'))
| 0 | ||||||||||||||||||
| 770 | path += QLatin1Char('/'); never executed: path += QLatin1Char('/'); | 0 | ||||||||||||||||||
| 771 | path += name; | - | ||||||||||||||||||
| 772 | files.append(path); | - | ||||||||||||||||||
| 773 | } never executed: end of block | 0 | ||||||||||||||||||
| 774 | } | - | ||||||||||||||||||
| 775 | return never executed: files;return files;never executed: return files; | 0 | ||||||||||||||||||
| 776 | } | - | ||||||||||||||||||
| 777 | - | |||||||||||||||||||
| 778 | QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsToFix) const | - | ||||||||||||||||||
| 779 | { | - | ||||||||||||||||||
| 780 | QList<QUrl> urls; | - | ||||||||||||||||||
| 781 | const int numUrlsToFix = urlsToFix.size(); | - | ||||||||||||||||||
| 782 | urls.reserve(numUrlsToFix); | - | ||||||||||||||||||
| 783 | for (int i = 0; i < numUrlsToFix
| 0 | ||||||||||||||||||
| 784 | QUrl url = urlsToFix.at(i); | - | ||||||||||||||||||
| 785 | - | |||||||||||||||||||
| 786 | const QString defaultSuffix = options->defaultSuffix(); | - | ||||||||||||||||||
| 787 | if (!defaultSuffix.isEmpty()
| 0 | ||||||||||||||||||
| 788 | url.setPath(url.path() + QLatin1Char('.') + defaultSuffix); never executed: url.setPath(url.path() + QLatin1Char('.') + defaultSuffix); | 0 | ||||||||||||||||||
| 789 | urls.append(url); | - | ||||||||||||||||||
| 790 | } never executed: end of block | 0 | ||||||||||||||||||
| 791 | return never executed: urls;return urls;never executed: return urls; | 0 | ||||||||||||||||||
| 792 | } | - | ||||||||||||||||||
| 793 | QStringList QFileDialog::selectedFiles() const | - | ||||||||||||||||||
| 794 | { | - | ||||||||||||||||||
| 795 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 796 | - | |||||||||||||||||||
| 797 | QStringList files; | - | ||||||||||||||||||
| 798 | const QList<QUrl> userSelectedFiles = d->userSelectedFiles(); | - | ||||||||||||||||||
| 799 | files.reserve(userSelectedFiles.size()); | - | ||||||||||||||||||
| 800 | 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 = 0) | - | ||||||||||||||||||
| 801 | files.append(file.toLocalFile()); never executed: files.append(file.toLocalFile()); | 0 | ||||||||||||||||||
| 802 | if (files.isEmpty()
| 0 | ||||||||||||||||||
| 803 | const FileMode fm = fileMode(); | - | ||||||||||||||||||
| 804 | if (fm != ExistingFile
| 0 | ||||||||||||||||||
| 805 | files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); never executed: files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); | 0 | ||||||||||||||||||
| 806 | } never executed: end of block | 0 | ||||||||||||||||||
| 807 | return never executed: files;return files;never executed: return files; | 0 | ||||||||||||||||||
| 808 | } | - | ||||||||||||||||||
| 809 | QList<QUrl> QFileDialog::selectedUrls() const | - | ||||||||||||||||||
| 810 | { | - | ||||||||||||||||||
| 811 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 812 | if (d->nativeDialogInUse
| 0 | ||||||||||||||||||
| 813 | return never executed: d->userSelectedFiles();return d->userSelectedFiles();never executed: return d->userSelectedFiles(); | 0 | ||||||||||||||||||
| 814 | } else { | - | ||||||||||||||||||
| 815 | QList<QUrl> urls; | - | ||||||||||||||||||
| 816 | const QStringList selectedFileList = selectedFiles(); | - | ||||||||||||||||||
| 817 | urls.reserve(selectedFileList.size()); | - | ||||||||||||||||||
| 818 | 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 = 0) | - | ||||||||||||||||||
| 819 | urls.append(QUrl::fromLocalFile(file)); never executed: urls.append(QUrl::fromLocalFile(file)); | 0 | ||||||||||||||||||
| 820 | return never executed: urls;return urls;never executed: return urls; | 0 | ||||||||||||||||||
| 821 | } | - | ||||||||||||||||||
| 822 | } | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | - | |||||||||||||||||||
| 825 | - | |||||||||||||||||||
| 826 | - | |||||||||||||||||||
| 827 | - | |||||||||||||||||||
| 828 | QStringList qt_make_filter_list(const QString &filter) | - | ||||||||||||||||||
| 829 | { | - | ||||||||||||||||||
| 830 | QString f(filter); | - | ||||||||||||||||||
| 831 | - | |||||||||||||||||||
| 832 | if (f.isEmpty()
| 0 | ||||||||||||||||||
| 833 | return never executed: QStringList();return QStringList();never executed: return QStringList(); | 0 | ||||||||||||||||||
| 834 | - | |||||||||||||||||||
| 835 | QString sep(QLatin1String(";;")); | - | ||||||||||||||||||
| 836 | int i = f.indexOf(sep, 0); | - | ||||||||||||||||||
| 837 | if (i == -1
| 0 | ||||||||||||||||||
| 838 | if (f.indexOf(QLatin1Char('\n'), 0) != -1
| 0 | ||||||||||||||||||
| 839 | sep = QLatin1Char('\n'); | - | ||||||||||||||||||
| 840 | i = f.indexOf(sep, 0); | - | ||||||||||||||||||
| 841 | } never executed: end of block | 0 | ||||||||||||||||||
| 842 | } never executed: end of block | 0 | ||||||||||||||||||
| 843 | - | |||||||||||||||||||
| 844 | return never executed: f.split(sep);return f.split(sep);never executed: return f.split(sep); | 0 | ||||||||||||||||||
| 845 | } | - | ||||||||||||||||||
| 846 | void QFileDialog::setNameFilter(const QString &filter) | - | ||||||||||||||||||
| 847 | { | - | ||||||||||||||||||
| 848 | setNameFilters(qt_make_filter_list(filter)); | - | ||||||||||||||||||
| 849 | } never executed: end of block | 0 | ||||||||||||||||||
| 850 | void QFileDialog::setNameFilterDetailsVisible(bool enabled) | - | ||||||||||||||||||
| 851 | { | - | ||||||||||||||||||
| 852 | setOption(HideNameFilterDetails, !enabled); | - | ||||||||||||||||||
| 853 | } never executed: end of block | 0 | ||||||||||||||||||
| 854 | - | |||||||||||||||||||
| 855 | bool QFileDialog::isNameFilterDetailsVisible() const | - | ||||||||||||||||||
| 856 | { | - | ||||||||||||||||||
| 857 | return never executed: !testOption(HideNameFilterDetails);return !testOption(HideNameFilterDetails);never executed: return !testOption(HideNameFilterDetails); | 0 | ||||||||||||||||||
| 858 | } | - | ||||||||||||||||||
| 859 | - | |||||||||||||||||||
| 860 | - | |||||||||||||||||||
| 861 | - | |||||||||||||||||||
| 862 | - | |||||||||||||||||||
| 863 | - | |||||||||||||||||||
| 864 | QStringList qt_strip_filters(const QStringList &filters) | - | ||||||||||||||||||
| 865 | { | - | ||||||||||||||||||
| 866 | QStringList strippedFilters; | - | ||||||||||||||||||
| 867 | QRegExp r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp)); | - | ||||||||||||||||||
| 868 | const int numFilters = filters.count(); | - | ||||||||||||||||||
| 869 | strippedFilters.reserve(numFilters); | - | ||||||||||||||||||
| 870 | for (int i = 0; i < numFilters
| 0 | ||||||||||||||||||
| 871 | QString filterName; | - | ||||||||||||||||||
| 872 | int index = r.indexIn(filters[i]); | - | ||||||||||||||||||
| 873 | if (index >= 0
| 0 | ||||||||||||||||||
| 874 | filterName = r.cap(1); never executed: filterName = r.cap(1); | 0 | ||||||||||||||||||
| 875 | strippedFilters.append(filterName.simplified()); | - | ||||||||||||||||||
| 876 | } never executed: end of block | 0 | ||||||||||||||||||
| 877 | return never executed: strippedFilters;return strippedFilters;never executed: return strippedFilters; | 0 | ||||||||||||||||||
| 878 | } | - | ||||||||||||||||||
| 879 | void QFileDialog::setNameFilters(const QStringList &filters) | - | ||||||||||||||||||
| 880 | { | - | ||||||||||||||||||
| 881 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 882 | d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)"))); | - | ||||||||||||||||||
| 883 | QStringList cleanedFilters; | - | ||||||||||||||||||
| 884 | const int numFilters = filters.count(); | - | ||||||||||||||||||
| 885 | cleanedFilters.reserve(numFilters); | - | ||||||||||||||||||
| 886 | for (int i = 0; i < numFilters
| 0 | ||||||||||||||||||
| 887 | cleanedFilters << filters[i].simplified(); | - | ||||||||||||||||||
| 888 | } never executed: end of block | 0 | ||||||||||||||||||
| 889 | d->options->setNameFilters(cleanedFilters); | - | ||||||||||||||||||
| 890 | - | |||||||||||||||||||
| 891 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 892 | return; never executed: return; | 0 | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | d->qFileDialogUi->fileTypeCombo->clear(); | - | ||||||||||||||||||
| 895 | if (cleanedFilters.isEmpty()
| 0 | ||||||||||||||||||
| 896 | return; never executed: return; | 0 | ||||||||||||||||||
| 897 | - | |||||||||||||||||||
| 898 | if (testOption(HideNameFilterDetails)
| 0 | ||||||||||||||||||
| 899 | d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters)); never executed: d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters)); | 0 | ||||||||||||||||||
| 900 | else | - | ||||||||||||||||||
| 901 | d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters); never executed: d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters); | 0 | ||||||||||||||||||
| 902 | - | |||||||||||||||||||
| 903 | d->_q_useNameFilter(0); | - | ||||||||||||||||||
| 904 | } never executed: end of block | 0 | ||||||||||||||||||
| 905 | - | |||||||||||||||||||
| 906 | - | |||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | - | |||||||||||||||||||
| 910 | - | |||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | QStringList QFileDialog::nameFilters() const | - | ||||||||||||||||||
| 913 | { | - | ||||||||||||||||||
| 914 | return never executed: d_func()->options->nameFilters();return d_func()->options->nameFilters();never executed: return d_func()->options->nameFilters(); | 0 | ||||||||||||||||||
| 915 | } | - | ||||||||||||||||||
| 916 | void QFileDialog::selectNameFilter(const QString &filter) | - | ||||||||||||||||||
| 917 | { | - | ||||||||||||||||||
| 918 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 919 | d->options->setInitiallySelectedNameFilter(filter); | - | ||||||||||||||||||
| 920 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 921 | d->selectNameFilter_sys(filter); | - | ||||||||||||||||||
| 922 | return; never executed: return; | 0 | ||||||||||||||||||
| 923 | } | - | ||||||||||||||||||
| 924 | int i = -1; | - | ||||||||||||||||||
| 925 | if (testOption(HideNameFilterDetails)
| 0 | ||||||||||||||||||
| 926 | const QStringList filters = qt_strip_filters(qt_make_filter_list(filter)); | - | ||||||||||||||||||
| 927 | if (!filters.isEmpty()
| 0 | ||||||||||||||||||
| 928 | i = d->qFileDialogUi->fileTypeCombo->findText(filters.first()); never executed: i = d->qFileDialogUi->fileTypeCombo->findText(filters.first()); | 0 | ||||||||||||||||||
| 929 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 930 | i = d->qFileDialogUi->fileTypeCombo->findText(filter); | - | ||||||||||||||||||
| 931 | } never executed: end of block | 0 | ||||||||||||||||||
| 932 | if (i >= 0
| 0 | ||||||||||||||||||
| 933 | d->qFileDialogUi->fileTypeCombo->setCurrentIndex(i); | - | ||||||||||||||||||
| 934 | d->_q_useNameFilter(d->qFileDialogUi->fileTypeCombo->currentIndex()); | - | ||||||||||||||||||
| 935 | } never executed: end of block | 0 | ||||||||||||||||||
| 936 | } never executed: end of block | 0 | ||||||||||||||||||
| 937 | QString QFileDialog::selectedNameFilter() const | - | ||||||||||||||||||
| 938 | { | - | ||||||||||||||||||
| 939 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 940 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 941 | return never executed: d->selectedNameFilter_sys();return d->selectedNameFilter_sys();never executed: return d->selectedNameFilter_sys(); | 0 | ||||||||||||||||||
| 942 | - | |||||||||||||||||||
| 943 | return never executed: d->qFileDialogUi->fileTypeCombo->currentText();return d->qFileDialogUi->fileTypeCombo->currentText();never executed: return d->qFileDialogUi->fileTypeCombo->currentText(); | 0 | ||||||||||||||||||
| 944 | } | - | ||||||||||||||||||
| 945 | QDir::Filters QFileDialog::filter() const | - | ||||||||||||||||||
| 946 | { | - | ||||||||||||||||||
| 947 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 948 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 949 | return never executed: d->model->filter();return d->model->filter();never executed: return d->model->filter(); | 0 | ||||||||||||||||||
| 950 | return never executed: d->options->filter();return d->options->filter();never executed: return d->options->filter(); | 0 | ||||||||||||||||||
| 951 | } | - | ||||||||||||||||||
| 952 | void QFileDialog::setFilter(QDir::Filters filters) | - | ||||||||||||||||||
| 953 | { | - | ||||||||||||||||||
| 954 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 955 | d->options->setFilter(filters); | - | ||||||||||||||||||
| 956 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 957 | d->setFilter_sys(); | - | ||||||||||||||||||
| 958 | return; never executed: return; | 0 | ||||||||||||||||||
| 959 | } | - | ||||||||||||||||||
| 960 | - | |||||||||||||||||||
| 961 | d->model->setFilter(filters); | - | ||||||||||||||||||
| 962 | d->showHiddenAction->setChecked((filters & QDir::Hidden)); | - | ||||||||||||||||||
| 963 | } never executed: end of block | 0 | ||||||||||||||||||
| 964 | - | |||||||||||||||||||
| 965 | - | |||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 | static QString nameFilterForMime(const QString &mimeType) | - | ||||||||||||||||||
| 968 | { | - | ||||||||||||||||||
| 969 | QMimeDatabase db; | - | ||||||||||||||||||
| 970 | QMimeType mime(db.mimeTypeForName(mimeType)); | - | ||||||||||||||||||
| 971 | if (mime.isValid()
| 0 | ||||||||||||||||||
| 972 | if (mime.isDefault()
| 0 | ||||||||||||||||||
| 973 | return never executed: QFileDialog::tr("All files (*)");return QFileDialog::tr("All files (*)");never executed: return QFileDialog::tr("All files (*)"); | 0 | ||||||||||||||||||
| 974 | } else { | - | ||||||||||||||||||
| 975 | const QString patterns = mime.globPatterns().join(QLatin1Char(' ')); | - | ||||||||||||||||||
| 976 | return never executed: mime.comment() + ([]() -> QString { enum { Size = sizeof(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); returnreturn mime.comment() + ([]() -> QString { enum { Size = sizeof(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(')');never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()) + patterns + QLatin1Char(')');return qstring_literal_temp;never executed: return mime.comment() + ([]() -> QString { enum { Size = sizeof(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(')'); | 0 | ||||||||||||||||||
| 977 | } | - | ||||||||||||||||||
| 978 | } | - | ||||||||||||||||||
| 979 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 980 | } | - | ||||||||||||||||||
| 981 | void QFileDialog::setMimeTypeFilters(const QStringList &filters) | - | ||||||||||||||||||
| 982 | { | - | ||||||||||||||||||
| 983 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 984 | QStringList nameFilters; | - | ||||||||||||||||||
| 985 | 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 = 0) { | - | ||||||||||||||||||
| 986 | const QString text = nameFilterForMime(mimeType); | - | ||||||||||||||||||
| 987 | if (!text.isEmpty()
| 0 | ||||||||||||||||||
| 988 | nameFilters.append(text); never executed: nameFilters.append(text); | 0 | ||||||||||||||||||
| 989 | } never executed: end of block | 0 | ||||||||||||||||||
| 990 | setNameFilters(nameFilters); | - | ||||||||||||||||||
| 991 | d->options->setMimeTypeFilters(filters); | - | ||||||||||||||||||
| 992 | } never executed: end of block | 0 | ||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | - | |||||||||||||||||||
| 995 | - | |||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | - | |||||||||||||||||||
| 998 | - | |||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | QStringList QFileDialog::mimeTypeFilters() const | - | ||||||||||||||||||
| 1001 | { | - | ||||||||||||||||||
| 1002 | return never executed: d_func()->options->mimeTypeFilters();return d_func()->options->mimeTypeFilters();never executed: return d_func()->options->mimeTypeFilters(); | 0 | ||||||||||||||||||
| 1003 | } | - | ||||||||||||||||||
| 1004 | - | |||||||||||||||||||
| 1005 | - | |||||||||||||||||||
| 1006 | - | |||||||||||||||||||
| 1007 | - | |||||||||||||||||||
| 1008 | - | |||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | - | |||||||||||||||||||
| 1011 | void QFileDialog::selectMimeTypeFilter(const QString &filter) | - | ||||||||||||||||||
| 1012 | { | - | ||||||||||||||||||
| 1013 | const QString text = nameFilterForMime(filter); | - | ||||||||||||||||||
| 1014 | if (!text.isEmpty()
| 0 | ||||||||||||||||||
| 1015 | selectNameFilter(text); never executed: selectNameFilter(text); | 0 | ||||||||||||||||||
| 1016 | } never executed: end of block | 0 | ||||||||||||||||||
| 1017 | void QFileDialog::setViewMode(QFileDialog::ViewMode mode) | - | ||||||||||||||||||
| 1018 | { | - | ||||||||||||||||||
| 1019 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1020 | d->options->setViewMode(static_cast<QFileDialogOptions::ViewMode>(mode)); | - | ||||||||||||||||||
| 1021 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1022 | return; never executed: return; | 0 | ||||||||||||||||||
| 1023 | if (mode == Detail
| 0 | ||||||||||||||||||
| 1024 | d->_q_showDetailsView(); never executed: d->_q_showDetailsView(); | 0 | ||||||||||||||||||
| 1025 | else | - | ||||||||||||||||||
| 1026 | d->_q_showListView(); never executed: d->_q_showListView(); | 0 | ||||||||||||||||||
| 1027 | } | - | ||||||||||||||||||
| 1028 | - | |||||||||||||||||||
| 1029 | QFileDialog::ViewMode QFileDialog::viewMode() const | - | ||||||||||||||||||
| 1030 | { | - | ||||||||||||||||||
| 1031 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1032 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1033 | return never executed: static_cast<QFileDialog::ViewMode>(d->options->viewMode());return static_cast<QFileDialog::ViewMode>(d->options->viewMode());never executed: return static_cast<QFileDialog::ViewMode>(d->options->viewMode()); | 0 | ||||||||||||||||||
| 1034 | return never executed: (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent()return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail);
never executed: return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail); | 0 | ||||||||||||||||||
| 1035 | } | - | ||||||||||||||||||
| 1036 | void QFileDialog::setFileMode(QFileDialog::FileMode mode) | - | ||||||||||||||||||
| 1037 | { | - | ||||||||||||||||||
| 1038 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1039 | d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode)); | - | ||||||||||||||||||
| 1040 | - | |||||||||||||||||||
| 1041 | - | |||||||||||||||||||
| 1042 | setOption(ShowDirsOnly, mode == DirectoryOnly); | - | ||||||||||||||||||
| 1043 | - | |||||||||||||||||||
| 1044 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1045 | return; never executed: return; | 0 | ||||||||||||||||||
| 1046 | - | |||||||||||||||||||
| 1047 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | - | |||||||||||||||||||
| 1050 | QAbstractItemView::SelectionMode selectionMode; | - | ||||||||||||||||||
| 1051 | if (mode == QFileDialog::ExistingFiles
| 0 | ||||||||||||||||||
| 1052 | selectionMode = QAbstractItemView::ExtendedSelection; never executed: selectionMode = QAbstractItemView::ExtendedSelection; | 0 | ||||||||||||||||||
| 1053 | else | - | ||||||||||||||||||
| 1054 | selectionMode = QAbstractItemView::SingleSelection; never executed: selectionMode = QAbstractItemView::SingleSelection; | 0 | ||||||||||||||||||
| 1055 | d->qFileDialogUi->listView->setSelectionMode(selectionMode); | - | ||||||||||||||||||
| 1056 | d->qFileDialogUi->treeView->setSelectionMode(selectionMode); | - | ||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | d->model->setFilter(d->filterForMode(filter())); | - | ||||||||||||||||||
| 1059 | - | |||||||||||||||||||
| 1060 | if (mode == DirectoryOnly
| 0 | ||||||||||||||||||
| 1061 | d->qFileDialogUi->fileTypeCombo->clear(); | - | ||||||||||||||||||
| 1062 | d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories")); | - | ||||||||||||||||||
| 1063 | d->qFileDialogUi->fileTypeCombo->setEnabled(false); | - | ||||||||||||||||||
| 1064 | } never executed: end of block | 0 | ||||||||||||||||||
| 1065 | d->updateFileNameLabel(); | - | ||||||||||||||||||
| 1066 | d->updateOkButtonText(); | - | ||||||||||||||||||
| 1067 | d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly)); | - | ||||||||||||||||||
| 1068 | d->_q_updateOkButton(); | - | ||||||||||||||||||
| 1069 | } never executed: end of block | 0 | ||||||||||||||||||
| 1070 | - | |||||||||||||||||||
| 1071 | QFileDialog::FileMode QFileDialog::fileMode() const | - | ||||||||||||||||||
| 1072 | { | - | ||||||||||||||||||
| 1073 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1074 | return never executed: static_cast<FileMode>(d->options->fileMode());return static_cast<FileMode>(d->options->fileMode());never executed: return static_cast<FileMode>(d->options->fileMode()); | 0 | ||||||||||||||||||
| 1075 | } | - | ||||||||||||||||||
| 1076 | void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) | - | ||||||||||||||||||
| 1077 | { | - | ||||||||||||||||||
| 1078 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1079 | d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode)); | - | ||||||||||||||||||
| 1080 | - | |||||||||||||||||||
| 1081 | setAttribute(Qt::WA_DontShowOnScreen, false); | - | ||||||||||||||||||
| 1082 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1083 | return; never executed: return; | 0 | ||||||||||||||||||
| 1084 | QDialogButtonBox::StandardButton button = (mode == AcceptOpen
| 0 | ||||||||||||||||||
| 1085 | d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel); | - | ||||||||||||||||||
| 1086 | d->qFileDialogUi->buttonBox->button(button)->setEnabled(false); | - | ||||||||||||||||||
| 1087 | d->_q_updateOkButton(); | - | ||||||||||||||||||
| 1088 | if (mode == AcceptSave
| 0 | ||||||||||||||||||
| 1089 | d->qFileDialogUi->lookInCombo->setEditable(false); | - | ||||||||||||||||||
| 1090 | } never executed: end of block | 0 | ||||||||||||||||||
| 1091 | d->retranslateWindowTitle(); | - | ||||||||||||||||||
| 1092 | } never executed: end of block | 0 | ||||||||||||||||||
| 1093 | void QFileDialog::setSupportedSchemes(const QStringList &schemes) | - | ||||||||||||||||||
| 1094 | { | - | ||||||||||||||||||
| 1095 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1096 | d->options->setSupportedSchemes(schemes); | - | ||||||||||||||||||
| 1097 | } never executed: end of block | 0 | ||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | QStringList QFileDialog::supportedSchemes() const | - | ||||||||||||||||||
| 1100 | { | - | ||||||||||||||||||
| 1101 | return never executed: d_func()->options->supportedSchemes();return d_func()->options->supportedSchemes();never executed: return d_func()->options->supportedSchemes(); | 0 | ||||||||||||||||||
| 1102 | } | - | ||||||||||||||||||
| 1103 | - | |||||||||||||||||||
| 1104 | - | |||||||||||||||||||
| 1105 | - | |||||||||||||||||||
| 1106 | - | |||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | QModelIndex QFileDialogPrivate::rootIndex() const { | - | ||||||||||||||||||
| 1109 | return never executed: mapToSource(qFileDialogUi->listView->rootIndex());return mapToSource(qFileDialogUi->listView->rootIndex());never executed: return mapToSource(qFileDialogUi->listView->rootIndex()); | 0 | ||||||||||||||||||
| 1110 | } | - | ||||||||||||||||||
| 1111 | - | |||||||||||||||||||
| 1112 | QAbstractItemView *QFileDialogPrivate::currentView() const { | - | ||||||||||||||||||
| 1113 | if (!qFileDialogUi->stackedWidget
| 0 | ||||||||||||||||||
| 1114 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 1115 | if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent()
| 0 | ||||||||||||||||||
| 1116 | return never executed: qFileDialogUi->listView;return qFileDialogUi->listView;never executed: return qFileDialogUi->listView; | 0 | ||||||||||||||||||
| 1117 | return never executed: qFileDialogUi->treeView;return qFileDialogUi->treeView;never executed: return qFileDialogUi->treeView; | 0 | ||||||||||||||||||
| 1118 | } | - | ||||||||||||||||||
| 1119 | - | |||||||||||||||||||
| 1120 | QLineEdit *QFileDialogPrivate::lineEdit() const { | - | ||||||||||||||||||
| 1121 | return never executed: (QLineEdit*)qFileDialogUi->fileNameEdit;return (QLineEdit*)qFileDialogUi->fileNameEdit;never executed: return (QLineEdit*)qFileDialogUi->fileNameEdit; | 0 | ||||||||||||||||||
| 1122 | } | - | ||||||||||||||||||
| 1123 | - | |||||||||||||||||||
| 1124 | int QFileDialogPrivate::maxNameLength(const QString &path) | - | ||||||||||||||||||
| 1125 | { | - | ||||||||||||||||||
| 1126 | - | |||||||||||||||||||
| 1127 | return never executed: ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);never executed: return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX); | 0 | ||||||||||||||||||
| 1128 | return dead code: -1;return -1;dead code: return -1; | - | ||||||||||||||||||
| 1129 | } | - | ||||||||||||||||||
| 1130 | - | |||||||||||||||||||
| 1131 | - | |||||||||||||||||||
| 1132 | - | |||||||||||||||||||
| 1133 | - | |||||||||||||||||||
| 1134 | void QFileDialogPrivate::setRootIndex(const QModelIndex &index) const { | - | ||||||||||||||||||
| 1135 | ((!(index.isValid() ? index.model() == model : true)) ? qt_assert("index.isValid() ? index.model() == model : true",__FILE__,1777) : qt_noop()); | - | ||||||||||||||||||
| 1136 | QModelIndex idx = mapFromSource(index); | - | ||||||||||||||||||
| 1137 | qFileDialogUi->treeView->setRootIndex(idx); | - | ||||||||||||||||||
| 1138 | qFileDialogUi->listView->setRootIndex(idx); | - | ||||||||||||||||||
| 1139 | } never executed: end of block | 0 | ||||||||||||||||||
| 1140 | - | |||||||||||||||||||
| 1141 | - | |||||||||||||||||||
| 1142 | - | |||||||||||||||||||
| 1143 | - | |||||||||||||||||||
| 1144 | QModelIndex QFileDialogPrivate::select(const QModelIndex &index) const { | - | ||||||||||||||||||
| 1145 | ((!(index.isValid() ? index.model() == model : true)) ? qt_assert("index.isValid() ? index.model() == model : true",__FILE__,1787) : qt_noop()); | - | ||||||||||||||||||
| 1146 | - | |||||||||||||||||||
| 1147 | QModelIndex idx = mapFromSource(index); | - | ||||||||||||||||||
| 1148 | if (idx.isValid()
| 0 | ||||||||||||||||||
| 1149 | qFileDialogUi->listView->selectionModel()->select(idx, never executed: qFileDialogUi->listView->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); | 0 | ||||||||||||||||||
| 1150 | QItemSelectionModel::Select | QItemSelectionModel::Rows); never executed: qFileDialogUi->listView->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); | 0 | ||||||||||||||||||
| 1151 | return never executed: idx;return idx;never executed: return idx; | 0 | ||||||||||||||||||
| 1152 | } | - | ||||||||||||||||||
| 1153 | - | |||||||||||||||||||
| 1154 | QFileDialog::AcceptMode QFileDialog::acceptMode() const | - | ||||||||||||||||||
| 1155 | { | - | ||||||||||||||||||
| 1156 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1157 | return never executed: static_cast<AcceptMode>(d->options->acceptMode());return static_cast<AcceptMode>(d->options->acceptMode());never executed: return static_cast<AcceptMode>(d->options->acceptMode()); | 0 | ||||||||||||||||||
| 1158 | } | - | ||||||||||||||||||
| 1159 | void QFileDialog::setReadOnly(bool enabled) | - | ||||||||||||||||||
| 1160 | { | - | ||||||||||||||||||
| 1161 | setOption(ReadOnly, enabled); | - | ||||||||||||||||||
| 1162 | } never executed: end of block | 0 | ||||||||||||||||||
| 1163 | - | |||||||||||||||||||
| 1164 | bool QFileDialog::isReadOnly() const | - | ||||||||||||||||||
| 1165 | { | - | ||||||||||||||||||
| 1166 | return never executed: testOption(ReadOnly);return testOption(ReadOnly);never executed: return testOption(ReadOnly); | 0 | ||||||||||||||||||
| 1167 | } | - | ||||||||||||||||||
| 1168 | void QFileDialog::setResolveSymlinks(bool enabled) | - | ||||||||||||||||||
| 1169 | { | - | ||||||||||||||||||
| 1170 | setOption(DontResolveSymlinks, !enabled); | - | ||||||||||||||||||
| 1171 | } never executed: end of block | 0 | ||||||||||||||||||
| 1172 | - | |||||||||||||||||||
| 1173 | bool QFileDialog::resolveSymlinks() const | - | ||||||||||||||||||
| 1174 | { | - | ||||||||||||||||||
| 1175 | return never executed: !testOption(DontResolveSymlinks);return !testOption(DontResolveSymlinks);never executed: return !testOption(DontResolveSymlinks); | 0 | ||||||||||||||||||
| 1176 | } | - | ||||||||||||||||||
| 1177 | void QFileDialog::setConfirmOverwrite(bool enabled) | - | ||||||||||||||||||
| 1178 | { | - | ||||||||||||||||||
| 1179 | setOption(DontConfirmOverwrite, !enabled); | - | ||||||||||||||||||
| 1180 | } never executed: end of block | 0 | ||||||||||||||||||
| 1181 | - | |||||||||||||||||||
| 1182 | bool QFileDialog::confirmOverwrite() const | - | ||||||||||||||||||
| 1183 | { | - | ||||||||||||||||||
| 1184 | return never executed: !testOption(DontConfirmOverwrite);return !testOption(DontConfirmOverwrite);never executed: return !testOption(DontConfirmOverwrite); | 0 | ||||||||||||||||||
| 1185 | } | - | ||||||||||||||||||
| 1186 | void QFileDialog::setDefaultSuffix(const QString &suffix) | - | ||||||||||||||||||
| 1187 | { | - | ||||||||||||||||||
| 1188 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1189 | d->options->setDefaultSuffix(suffix); | - | ||||||||||||||||||
| 1190 | } never executed: end of block | 0 | ||||||||||||||||||
| 1191 | - | |||||||||||||||||||
| 1192 | QString QFileDialog::defaultSuffix() const | - | ||||||||||||||||||
| 1193 | { | - | ||||||||||||||||||
| 1194 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1195 | return never executed: d->options->defaultSuffix();return d->options->defaultSuffix();never executed: return d->options->defaultSuffix(); | 0 | ||||||||||||||||||
| 1196 | } | - | ||||||||||||||||||
| 1197 | - | |||||||||||||||||||
| 1198 | - | |||||||||||||||||||
| 1199 | - | |||||||||||||||||||
| 1200 | - | |||||||||||||||||||
| 1201 | - | |||||||||||||||||||
| 1202 | void QFileDialog::setHistory(const QStringList &paths) | - | ||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||
| 1204 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1205 | if (d->usingWidgets()
| 0 | ||||||||||||||||||
| 1206 | d->qFileDialogUi->lookInCombo->setHistory(paths); never executed: d->qFileDialogUi->lookInCombo->setHistory(paths); | 0 | ||||||||||||||||||
| 1207 | } never executed: end of block | 0 | ||||||||||||||||||
| 1208 | - | |||||||||||||||||||
| 1209 | void QFileDialogComboBox::setHistory(const QStringList &paths) | - | ||||||||||||||||||
| 1210 | { | - | ||||||||||||||||||
| 1211 | m_history = paths; | - | ||||||||||||||||||
| 1212 | - | |||||||||||||||||||
| 1213 | QList<QUrl> list; | - | ||||||||||||||||||
| 1214 | QModelIndex idx = d_ptr->model->index(d_ptr->rootPath()); | - | ||||||||||||||||||
| 1215 | - | |||||||||||||||||||
| 1216 | QUrl url = QUrl::fromLocalFile(QDir::toNativeSeparators(idx.data(QFileSystemModel::FilePathRole).toString())); | - | ||||||||||||||||||
| 1217 | if (url.isValid()
| 0 | ||||||||||||||||||
| 1218 | list.append(url); never executed: list.append(url); | 0 | ||||||||||||||||||
| 1219 | urlModel->setUrls(list); | - | ||||||||||||||||||
| 1220 | } never executed: end of block | 0 | ||||||||||||||||||
| 1221 | - | |||||||||||||||||||
| 1222 | - | |||||||||||||||||||
| 1223 | - | |||||||||||||||||||
| 1224 | - | |||||||||||||||||||
| 1225 | QStringList QFileDialog::history() const | - | ||||||||||||||||||
| 1226 | { | - | ||||||||||||||||||
| 1227 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1228 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1229 | return never executed: QStringList();return QStringList();never executed: return QStringList(); | 0 | ||||||||||||||||||
| 1230 | QStringList currentHistory = d->qFileDialogUi->lookInCombo->history(); | - | ||||||||||||||||||
| 1231 | - | |||||||||||||||||||
| 1232 | QString newHistory = QDir::toNativeSeparators(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); | - | ||||||||||||||||||
| 1233 | if (!currentHistory.contains(newHistory)
| 0 | ||||||||||||||||||
| 1234 | currentHistory << newHistory; never executed: currentHistory << newHistory; | 0 | ||||||||||||||||||
| 1235 | return never executed: currentHistory;return currentHistory;never executed: return currentHistory; | 0 | ||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||
| 1237 | void QFileDialog::setItemDelegate(QAbstractItemDelegate *delegate) | - | ||||||||||||||||||
| 1238 | { | - | ||||||||||||||||||
| 1239 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1240 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1241 | return; never executed: return; | 0 | ||||||||||||||||||
| 1242 | d->qFileDialogUi->listView->setItemDelegate(delegate); | - | ||||||||||||||||||
| 1243 | d->qFileDialogUi->treeView->setItemDelegate(delegate); | - | ||||||||||||||||||
| 1244 | } never executed: end of block | 0 | ||||||||||||||||||
| 1245 | - | |||||||||||||||||||
| 1246 | - | |||||||||||||||||||
| 1247 | - | |||||||||||||||||||
| 1248 | - | |||||||||||||||||||
| 1249 | QAbstractItemDelegate *QFileDialog::itemDelegate() const | - | ||||||||||||||||||
| 1250 | { | - | ||||||||||||||||||
| 1251 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1252 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1253 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 1254 | return never executed: d->qFileDialogUi->listView->itemDelegate();return d->qFileDialogUi->listView->itemDelegate();never executed: return d->qFileDialogUi->listView->itemDelegate(); | 0 | ||||||||||||||||||
| 1255 | } | - | ||||||||||||||||||
| 1256 | - | |||||||||||||||||||
| 1257 | - | |||||||||||||||||||
| 1258 | - | |||||||||||||||||||
| 1259 | - | |||||||||||||||||||
| 1260 | void QFileDialog::setIconProvider(QFileIconProvider *provider) | - | ||||||||||||||||||
| 1261 | { | - | ||||||||||||||||||
| 1262 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1263 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1264 | return; never executed: return; | 0 | ||||||||||||||||||
| 1265 | d->model->setIconProvider(provider); | - | ||||||||||||||||||
| 1266 | - | |||||||||||||||||||
| 1267 | d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls()); | - | ||||||||||||||||||
| 1268 | } never executed: end of block | 0 | ||||||||||||||||||
| 1269 | - | |||||||||||||||||||
| 1270 | - | |||||||||||||||||||
| 1271 | - | |||||||||||||||||||
| 1272 | - | |||||||||||||||||||
| 1273 | QFileIconProvider *QFileDialog::iconProvider() const | - | ||||||||||||||||||
| 1274 | { | - | ||||||||||||||||||
| 1275 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1276 | if (!d->model
| 0 | ||||||||||||||||||
| 1277 | return never executed: nullptr;return nullptr;never executed: return nullptr; | 0 | ||||||||||||||||||
| 1278 | return never executed: d->model->iconProvider();return d->model->iconProvider();never executed: return d->model->iconProvider(); | 0 | ||||||||||||||||||
| 1279 | } | - | ||||||||||||||||||
| 1280 | - | |||||||||||||||||||
| 1281 | void QFileDialogPrivate::setLabelTextControl(QFileDialog::DialogLabel label, const QString &text) | - | ||||||||||||||||||
| 1282 | { | - | ||||||||||||||||||
| 1283 | if (!qFileDialogUi
| 0 | ||||||||||||||||||
| 1284 | return; never executed: return; | 0 | ||||||||||||||||||
| 1285 | switch (label) { | - | ||||||||||||||||||
| 1286 | case never executed: QFileDialog::LookIn:case QFileDialog::LookIn:never executed: case QFileDialog::LookIn: | 0 | ||||||||||||||||||
| 1287 | qFileDialogUi->lookInLabel->setText(text); | - | ||||||||||||||||||
| 1288 | break; never executed: break; | 0 | ||||||||||||||||||
| 1289 | case never executed: QFileDialog::FileName:case QFileDialog::FileName:never executed: case QFileDialog::FileName: | 0 | ||||||||||||||||||
| 1290 | qFileDialogUi->fileNameLabel->setText(text); | - | ||||||||||||||||||
| 1291 | break; never executed: break; | 0 | ||||||||||||||||||
| 1292 | case never executed: QFileDialog::FileType:case QFileDialog::FileType:never executed: case QFileDialog::FileType: | 0 | ||||||||||||||||||
| 1293 | qFileDialogUi->fileTypeLabel->setText(text); | - | ||||||||||||||||||
| 1294 | break; never executed: break; | 0 | ||||||||||||||||||
| 1295 | case never executed: QFileDialog::Accept:case QFileDialog::Accept:never executed: case QFileDialog::Accept: | 0 | ||||||||||||||||||
| 1296 | if (q_func()->acceptMode() == QFileDialog::AcceptOpen
| 0 | ||||||||||||||||||
| 1297 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open)
| 0 | ||||||||||||||||||
| 1298 | button->setText(text); never executed: button->setText(text); | 0 | ||||||||||||||||||
| 1299 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 1300 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save)
| 0 | ||||||||||||||||||
| 1301 | button->setText(text); never executed: button->setText(text); | 0 | ||||||||||||||||||
| 1302 | } never executed: end of block | 0 | ||||||||||||||||||
| 1303 | break; never executed: break; | 0 | ||||||||||||||||||
| 1304 | case never executed: QFileDialog::Reject:case QFileDialog::Reject:never executed: case QFileDialog::Reject: | 0 | ||||||||||||||||||
| 1305 | if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel)
| 0 | ||||||||||||||||||
| 1306 | button->setText(text); never executed: button->setText(text); | 0 | ||||||||||||||||||
| 1307 | break; never executed: break; | 0 | ||||||||||||||||||
| 1308 | } | - | ||||||||||||||||||
| 1309 | } never executed: end of block | 0 | ||||||||||||||||||
| 1310 | - | |||||||||||||||||||
| 1311 | - | |||||||||||||||||||
| 1312 | - | |||||||||||||||||||
| 1313 | - | |||||||||||||||||||
| 1314 | - | |||||||||||||||||||
| 1315 | void QFileDialog::setLabelText(DialogLabel label, const QString &text) | - | ||||||||||||||||||
| 1316 | { | - | ||||||||||||||||||
| 1317 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1318 | d->options->setLabelText(static_cast<QFileDialogOptions::DialogLabel>(label), text); | - | ||||||||||||||||||
| 1319 | d->setLabelTextControl(label, text); | - | ||||||||||||||||||
| 1320 | } never executed: end of block | 0 | ||||||||||||||||||
| 1321 | - | |||||||||||||||||||
| 1322 | - | |||||||||||||||||||
| 1323 | - | |||||||||||||||||||
| 1324 | - | |||||||||||||||||||
| 1325 | QString QFileDialog::labelText(DialogLabel label) const | - | ||||||||||||||||||
| 1326 | { | - | ||||||||||||||||||
| 1327 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1328 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1329 | return never executed: d->options->labelText(static_cast<QFileDialogOptions::DialogLabel>(label));return d->options->labelText(static_cast<QFileDialogOptions::DialogLabel>(label));never executed: return d->options->labelText(static_cast<QFileDialogOptions::DialogLabel>(label)); | 0 | ||||||||||||||||||
| 1330 | QPushButton *button; | - | ||||||||||||||||||
| 1331 | switch (label) { | - | ||||||||||||||||||
| 1332 | case never executed: LookIn:case LookIn:never executed: case LookIn: | 0 | ||||||||||||||||||
| 1333 | return never executed: d->qFileDialogUi->lookInLabel->text();return d->qFileDialogUi->lookInLabel->text();never executed: return d->qFileDialogUi->lookInLabel->text(); | 0 | ||||||||||||||||||
| 1334 | case never executed: FileName:case FileName:never executed: case FileName: | 0 | ||||||||||||||||||
| 1335 | return never executed: d->qFileDialogUi->fileNameLabel->text();return d->qFileDialogUi->fileNameLabel->text();never executed: return d->qFileDialogUi->fileNameLabel->text(); | 0 | ||||||||||||||||||
| 1336 | case never executed: FileType:case FileType:never executed: case FileType: | 0 | ||||||||||||||||||
| 1337 | return never executed: d->qFileDialogUi->fileTypeLabel->text();return d->qFileDialogUi->fileTypeLabel->text();never executed: return d->qFileDialogUi->fileTypeLabel->text(); | 0 | ||||||||||||||||||
| 1338 | case never executed: Accept:case Accept:never executed: case Accept: | 0 | ||||||||||||||||||
| 1339 | if (acceptMode() == AcceptOpen
| 0 | ||||||||||||||||||
| 1340 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open); never executed: button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open); | 0 | ||||||||||||||||||
| 1341 | else | - | ||||||||||||||||||
| 1342 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save); never executed: button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save); | 0 | ||||||||||||||||||
| 1343 | if (button
| 0 | ||||||||||||||||||
| 1344 | return never executed: button->text();return button->text();never executed: return button->text(); | 0 | ||||||||||||||||||
| 1345 | break; never executed: break; | 0 | ||||||||||||||||||
| 1346 | case never executed: Reject:case Reject:never executed: case Reject: | 0 | ||||||||||||||||||
| 1347 | button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel); | - | ||||||||||||||||||
| 1348 | if (button
| 0 | ||||||||||||||||||
| 1349 | return never executed: button->text();return button->text();never executed: return button->text(); | 0 | ||||||||||||||||||
| 1350 | break; never executed: break; | 0 | ||||||||||||||||||
| 1351 | } | - | ||||||||||||||||||
| 1352 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 1353 | } | - | ||||||||||||||||||
| 1354 | QString QFileDialog::getOpenFileName(QWidget *parent, | - | ||||||||||||||||||
| 1355 | const QString &caption, | - | ||||||||||||||||||
| 1356 | const QString &dir, | - | ||||||||||||||||||
| 1357 | const QString &filter, | - | ||||||||||||||||||
| 1358 | QString *selectedFilter, | - | ||||||||||||||||||
| 1359 | Options options) | - | ||||||||||||||||||
| 1360 | { | - | ||||||||||||||||||
| 1361 | const QStringList schemes = QStringList(([]() -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1362 | const QUrl selectedUrl = getOpenFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes); | - | ||||||||||||||||||
| 1363 | return never executed: selectedUrl.toLocalFile();return selectedUrl.toLocalFile();never executed: return selectedUrl.toLocalFile(); | 0 | ||||||||||||||||||
| 1364 | } | - | ||||||||||||||||||
| 1365 | QUrl QFileDialog::getOpenFileUrl(QWidget *parent, | - | ||||||||||||||||||
| 1366 | const QString &caption, | - | ||||||||||||||||||
| 1367 | const QUrl &dir, | - | ||||||||||||||||||
| 1368 | const QString &filter, | - | ||||||||||||||||||
| 1369 | QString *selectedFilter, | - | ||||||||||||||||||
| 1370 | Options options, | - | ||||||||||||||||||
| 1371 | const QStringList &supportedSchemes) | - | ||||||||||||||||||
| 1372 | { | - | ||||||||||||||||||
| 1373 | QFileDialogArgs args; | - | ||||||||||||||||||
| 1374 | args.parent = parent; | - | ||||||||||||||||||
| 1375 | args.caption = caption; | - | ||||||||||||||||||
| 1376 | args.directory = QFileDialogPrivate::workingDirectory(dir); | - | ||||||||||||||||||
| 1377 | args.selection = QFileDialogPrivate::initialSelection(dir); | - | ||||||||||||||||||
| 1378 | args.filter = filter; | - | ||||||||||||||||||
| 1379 | args.mode = ExistingFile; | - | ||||||||||||||||||
| 1380 | args.options = options; | - | ||||||||||||||||||
| 1381 | - | |||||||||||||||||||
| 1382 | QFileDialog dialog(args); | - | ||||||||||||||||||
| 1383 | dialog.setSupportedSchemes(supportedSchemes); | - | ||||||||||||||||||
| 1384 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1385 | dialog.selectNameFilter(*selectedFilter); never executed: dialog.selectNameFilter(*selectedFilter); | 0 | ||||||||||||||||||
| 1386 | if (dialog.exec() == QDialog::Accepted
| 0 | ||||||||||||||||||
| 1387 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1388 | * never executed: selectedFilter = dialog.selectedNameFilter();*selectedFilter = dialog.selectedNameFilter();never executed: *selectedFilter = dialog.selectedNameFilter(); | 0 | ||||||||||||||||||
| 1389 | return never executed: dialog.selectedUrls().value(0);return dialog.selectedUrls().value(0);never executed: return dialog.selectedUrls().value(0); | 0 | ||||||||||||||||||
| 1390 | } | - | ||||||||||||||||||
| 1391 | return never executed: QUrl();return QUrl();never executed: return QUrl(); | 0 | ||||||||||||||||||
| 1392 | } | - | ||||||||||||||||||
| 1393 | QStringList QFileDialog::getOpenFileNames(QWidget *parent, | - | ||||||||||||||||||
| 1394 | const QString &caption, | - | ||||||||||||||||||
| 1395 | const QString &dir, | - | ||||||||||||||||||
| 1396 | const QString &filter, | - | ||||||||||||||||||
| 1397 | QString *selectedFilter, | - | ||||||||||||||||||
| 1398 | Options options) | - | ||||||||||||||||||
| 1399 | { | - | ||||||||||||||||||
| 1400 | const QStringList schemes = QStringList(([]() -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1401 | const QList<QUrl> selectedUrls = getOpenFileUrls(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes); | - | ||||||||||||||||||
| 1402 | QStringList fileNames; | - | ||||||||||||||||||
| 1403 | fileNames.reserve(selectedUrls.size()); | - | ||||||||||||||||||
| 1404 | 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 = 0) | - | ||||||||||||||||||
| 1405 | fileNames << url.toLocalFile(); never executed: fileNames << url.toLocalFile(); | 0 | ||||||||||||||||||
| 1406 | return never executed: fileNames;return fileNames;never executed: return fileNames; | 0 | ||||||||||||||||||
| 1407 | } | - | ||||||||||||||||||
| 1408 | QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent, | - | ||||||||||||||||||
| 1409 | const QString &caption, | - | ||||||||||||||||||
| 1410 | const QUrl &dir, | - | ||||||||||||||||||
| 1411 | const QString &filter, | - | ||||||||||||||||||
| 1412 | QString *selectedFilter, | - | ||||||||||||||||||
| 1413 | Options options, | - | ||||||||||||||||||
| 1414 | const QStringList &supportedSchemes) | - | ||||||||||||||||||
| 1415 | { | - | ||||||||||||||||||
| 1416 | QFileDialogArgs args; | - | ||||||||||||||||||
| 1417 | args.parent = parent; | - | ||||||||||||||||||
| 1418 | args.caption = caption; | - | ||||||||||||||||||
| 1419 | args.directory = QFileDialogPrivate::workingDirectory(dir); | - | ||||||||||||||||||
| 1420 | args.selection = QFileDialogPrivate::initialSelection(dir); | - | ||||||||||||||||||
| 1421 | args.filter = filter; | - | ||||||||||||||||||
| 1422 | args.mode = ExistingFiles; | - | ||||||||||||||||||
| 1423 | args.options = options; | - | ||||||||||||||||||
| 1424 | - | |||||||||||||||||||
| 1425 | QFileDialog dialog(args); | - | ||||||||||||||||||
| 1426 | dialog.setSupportedSchemes(supportedSchemes); | - | ||||||||||||||||||
| 1427 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1428 | dialog.selectNameFilter(*selectedFilter); never executed: dialog.selectNameFilter(*selectedFilter); | 0 | ||||||||||||||||||
| 1429 | if (dialog.exec() == QDialog::Accepted
| 0 | ||||||||||||||||||
| 1430 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1431 | * never executed: selectedFilter = dialog.selectedNameFilter();*selectedFilter = dialog.selectedNameFilter();never executed: *selectedFilter = dialog.selectedNameFilter(); | 0 | ||||||||||||||||||
| 1432 | return never executed: dialog.selectedUrls();return dialog.selectedUrls();never executed: return dialog.selectedUrls(); | 0 | ||||||||||||||||||
| 1433 | } | - | ||||||||||||||||||
| 1434 | return never executed: QList<QUrl>();return QList<QUrl>();never executed: return QList<QUrl>(); | 0 | ||||||||||||||||||
| 1435 | } | - | ||||||||||||||||||
| 1436 | QString QFileDialog::getSaveFileName(QWidget *parent, | - | ||||||||||||||||||
| 1437 | const QString &caption, | - | ||||||||||||||||||
| 1438 | const QString &dir, | - | ||||||||||||||||||
| 1439 | const QString &filter, | - | ||||||||||||||||||
| 1440 | QString *selectedFilter, | - | ||||||||||||||||||
| 1441 | Options options) | - | ||||||||||||||||||
| 1442 | { | - | ||||||||||||||||||
| 1443 | const QStringList schemes = QStringList(([]() -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1444 | const QUrl selectedUrl = getSaveFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes); | - | ||||||||||||||||||
| 1445 | return never executed: selectedUrl.toLocalFile();return selectedUrl.toLocalFile();never executed: return selectedUrl.toLocalFile(); | 0 | ||||||||||||||||||
| 1446 | } | - | ||||||||||||||||||
| 1447 | QUrl QFileDialog::getSaveFileUrl(QWidget *parent, | - | ||||||||||||||||||
| 1448 | const QString &caption, | - | ||||||||||||||||||
| 1449 | const QUrl &dir, | - | ||||||||||||||||||
| 1450 | const QString &filter, | - | ||||||||||||||||||
| 1451 | QString *selectedFilter, | - | ||||||||||||||||||
| 1452 | Options options, | - | ||||||||||||||||||
| 1453 | const QStringList &supportedSchemes) | - | ||||||||||||||||||
| 1454 | { | - | ||||||||||||||||||
| 1455 | QFileDialogArgs args; | - | ||||||||||||||||||
| 1456 | args.parent = parent; | - | ||||||||||||||||||
| 1457 | args.caption = caption; | - | ||||||||||||||||||
| 1458 | args.directory = QFileDialogPrivate::workingDirectory(dir); | - | ||||||||||||||||||
| 1459 | args.selection = QFileDialogPrivate::initialSelection(dir); | - | ||||||||||||||||||
| 1460 | args.filter = filter; | - | ||||||||||||||||||
| 1461 | args.mode = AnyFile; | - | ||||||||||||||||||
| 1462 | args.options = options; | - | ||||||||||||||||||
| 1463 | - | |||||||||||||||||||
| 1464 | QFileDialog dialog(args); | - | ||||||||||||||||||
| 1465 | dialog.setSupportedSchemes(supportedSchemes); | - | ||||||||||||||||||
| 1466 | dialog.setAcceptMode(AcceptSave); | - | ||||||||||||||||||
| 1467 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1468 | dialog.selectNameFilter(*selectedFilter); never executed: dialog.selectNameFilter(*selectedFilter); | 0 | ||||||||||||||||||
| 1469 | if (dialog.exec() == QDialog::Accepted
| 0 | ||||||||||||||||||
| 1470 | if (selectedFilter
| 0 | ||||||||||||||||||
| 1471 | * never executed: selectedFilter = dialog.selectedNameFilter();*selectedFilter = dialog.selectedNameFilter();never executed: *selectedFilter = dialog.selectedNameFilter(); | 0 | ||||||||||||||||||
| 1472 | return never executed: dialog.selectedUrls().value(0);return dialog.selectedUrls().value(0);never executed: return dialog.selectedUrls().value(0); | 0 | ||||||||||||||||||
| 1473 | } | - | ||||||||||||||||||
| 1474 | return never executed: QUrl();return QUrl();never executed: return QUrl(); | 0 | ||||||||||||||||||
| 1475 | } | - | ||||||||||||||||||
| 1476 | QString QFileDialog::getExistingDirectory(QWidget *parent, | - | ||||||||||||||||||
| 1477 | const QString &caption, | - | ||||||||||||||||||
| 1478 | const QString &dir, | - | ||||||||||||||||||
| 1479 | Options options) | - | ||||||||||||||||||
| 1480 | { | - | ||||||||||||||||||
| 1481 | const QStringList schemes = QStringList(([]() -> QString { enum { Size = sizeof(u"" "file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1482 | const QUrl selectedUrl = getExistingDirectoryUrl(parent, caption, QUrl::fromLocalFile(dir), options, schemes); | - | ||||||||||||||||||
| 1483 | return never executed: selectedUrl.toLocalFile();return selectedUrl.toLocalFile();never executed: return selectedUrl.toLocalFile(); | 0 | ||||||||||||||||||
| 1484 | } | - | ||||||||||||||||||
| 1485 | QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent, | - | ||||||||||||||||||
| 1486 | const QString &caption, | - | ||||||||||||||||||
| 1487 | const QUrl &dir, | - | ||||||||||||||||||
| 1488 | Options options, | - | ||||||||||||||||||
| 1489 | const QStringList &supportedSchemes) | - | ||||||||||||||||||
| 1490 | { | - | ||||||||||||||||||
| 1491 | QFileDialogArgs args; | - | ||||||||||||||||||
| 1492 | args.parent = parent; | - | ||||||||||||||||||
| 1493 | args.caption = caption; | - | ||||||||||||||||||
| 1494 | args.directory = QFileDialogPrivate::workingDirectory(dir); | - | ||||||||||||||||||
| 1495 | args.mode = (options & ShowDirsOnly
| 0 | ||||||||||||||||||
| 1496 | args.options = options; | - | ||||||||||||||||||
| 1497 | - | |||||||||||||||||||
| 1498 | QFileDialog dialog(args); | - | ||||||||||||||||||
| 1499 | dialog.setSupportedSchemes(supportedSchemes); | - | ||||||||||||||||||
| 1500 | if (dialog.exec() == QDialog::Accepted
| 0 | ||||||||||||||||||
| 1501 | return never executed: dialog.selectedUrls().value(0);return dialog.selectedUrls().value(0);never executed: return dialog.selectedUrls().value(0); | 0 | ||||||||||||||||||
| 1502 | return never executed: QUrl();return QUrl();never executed: return QUrl(); | 0 | ||||||||||||||||||
| 1503 | } | - | ||||||||||||||||||
| 1504 | - | |||||||||||||||||||
| 1505 | inline static QUrl _qt_get_directory(const QUrl &url) | - | ||||||||||||||||||
| 1506 | { | - | ||||||||||||||||||
| 1507 | if (url.isLocalFile()
| 0 | ||||||||||||||||||
| 1508 | QFileInfo info = QFileInfo(QDir::current(), url.toLocalFile()); | - | ||||||||||||||||||
| 1509 | if (info.exists()
| 0 | ||||||||||||||||||
| 1510 | return never executed: QUrl::fromLocalFile(QDir::cleanPath(info.absoluteFilePath()));return QUrl::fromLocalFile(QDir::cleanPath(info.absoluteFilePath()));never executed: return QUrl::fromLocalFile(QDir::cleanPath(info.absoluteFilePath())); | 0 | ||||||||||||||||||
| 1511 | info.setFile(info.absolutePath()); | - | ||||||||||||||||||
| 1512 | if (info.exists()
| 0 | ||||||||||||||||||
| 1513 | return never executed: QUrl::fromLocalFile(info.absoluteFilePath());return QUrl::fromLocalFile(info.absoluteFilePath());never executed: return QUrl::fromLocalFile(info.absoluteFilePath()); | 0 | ||||||||||||||||||
| 1514 | return never executed: QUrl();return QUrl();never executed: return QUrl(); | 0 | ||||||||||||||||||
| 1515 | } else { | - | ||||||||||||||||||
| 1516 | return never executed: url;return url;never executed: return url; | 0 | ||||||||||||||||||
| 1517 | } | - | ||||||||||||||||||
| 1518 | } | - | ||||||||||||||||||
| 1519 | - | |||||||||||||||||||
| 1520 | - | |||||||||||||||||||
| 1521 | - | |||||||||||||||||||
| 1522 | - | |||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | QUrl QFileDialogPrivate::workingDirectory(const QUrl &url) | - | ||||||||||||||||||
| 1525 | { | - | ||||||||||||||||||
| 1526 | if (!url.isEmpty()
| 0 | ||||||||||||||||||
| 1527 | QUrl directory = _qt_get_directory(url); | - | ||||||||||||||||||
| 1528 | if (!directory.isEmpty()
| 0 | ||||||||||||||||||
| 1529 | return never executed: directory;return directory;never executed: return directory; | 0 | ||||||||||||||||||
| 1530 | } never executed: end of block | 0 | ||||||||||||||||||
| 1531 | QUrl directory = _qt_get_directory(*lastVisitedDir()); | - | ||||||||||||||||||
| 1532 | if (!directory.isEmpty()
| 0 | ||||||||||||||||||
| 1533 | return never executed: directory;return directory;never executed: return directory; | 0 | ||||||||||||||||||
| 1534 | return never executed: QUrl::fromLocalFile(QDir::currentPath());return QUrl::fromLocalFile(QDir::currentPath());never executed: return QUrl::fromLocalFile(QDir::currentPath()); | 0 | ||||||||||||||||||
| 1535 | } | - | ||||||||||||||||||
| 1536 | QString QFileDialogPrivate::initialSelection(const QUrl &url) | - | ||||||||||||||||||
| 1537 | { | - | ||||||||||||||||||
| 1538 | if (url.isEmpty()
| 0 | ||||||||||||||||||
| 1539 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 1540 | if (url.isLocalFile()
| 0 | ||||||||||||||||||
| 1541 | QFileInfo info(url.toLocalFile()); | - | ||||||||||||||||||
| 1542 | if (!info.isDir()
| 0 | ||||||||||||||||||
| 1543 | return never executed: info.fileName();return info.fileName();never executed: return info.fileName(); | 0 | ||||||||||||||||||
| 1544 | else | - | ||||||||||||||||||
| 1545 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 1546 | } | - | ||||||||||||||||||
| 1547 | - | |||||||||||||||||||
| 1548 | return never executed: url.fileName();return url.fileName();never executed: return url.fileName(); | 0 | ||||||||||||||||||
| 1549 | } | - | ||||||||||||||||||
| 1550 | - | |||||||||||||||||||
| 1551 | - | |||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | - | |||||||||||||||||||
| 1554 | void QFileDialog::done(int result) | - | ||||||||||||||||||
| 1555 | { | - | ||||||||||||||||||
| 1556 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1557 | - | |||||||||||||||||||
| 1558 | QDialog::done(result); | - | ||||||||||||||||||
| 1559 | - | |||||||||||||||||||
| 1560 | if (d->receiverToDisconnectOnClose
| 0 | ||||||||||||||||||
| 1561 | disconnect(this, d->signalToDisconnectOnClose, | - | ||||||||||||||||||
| 1562 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - | ||||||||||||||||||
| 1563 | d->receiverToDisconnectOnClose = 0; | - | ||||||||||||||||||
| 1564 | } never executed: end of block | 0 | ||||||||||||||||||
| 1565 | d->memberToDisconnectOnClose.clear(); | - | ||||||||||||||||||
| 1566 | d->signalToDisconnectOnClose.clear(); | - | ||||||||||||||||||
| 1567 | } never executed: end of block | 0 | ||||||||||||||||||
| 1568 | - | |||||||||||||||||||
| 1569 | - | |||||||||||||||||||
| 1570 | - | |||||||||||||||||||
| 1571 | - | |||||||||||||||||||
| 1572 | void QFileDialog::accept() | - | ||||||||||||||||||
| 1573 | { | - | ||||||||||||||||||
| 1574 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1575 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 1576 | const QList<QUrl> urls = selectedUrls(); | - | ||||||||||||||||||
| 1577 | if (urls.isEmpty()
| 0 | ||||||||||||||||||
| 1578 | return; never executed: return; | 0 | ||||||||||||||||||
| 1579 | d->_q_emitUrlsSelected(urls); | - | ||||||||||||||||||
| 1580 | if (urls.count() == 1
| 0 | ||||||||||||||||||
| 1581 | d->_q_emitUrlSelected(urls.first()); never executed: d->_q_emitUrlSelected(urls.first()); | 0 | ||||||||||||||||||
| 1582 | QDialog::accept(); | - | ||||||||||||||||||
| 1583 | return; never executed: return; | 0 | ||||||||||||||||||
| 1584 | } | - | ||||||||||||||||||
| 1585 | - | |||||||||||||||||||
| 1586 | QStringList files = selectedFiles(); | - | ||||||||||||||||||
| 1587 | if (files.isEmpty()
| 0 | ||||||||||||||||||
| 1588 | return; never executed: return; | 0 | ||||||||||||||||||
| 1589 | QString lineEditText = d->lineEdit()->text(); | - | ||||||||||||||||||
| 1590 | - | |||||||||||||||||||
| 1591 | - | |||||||||||||||||||
| 1592 | if (lineEditText == QLatin1String("..")
| 0 | ||||||||||||||||||
| 1593 | d->_q_navigateToParent(); | - | ||||||||||||||||||
| 1594 | const QSignalBlocker blocker(d->qFileDialogUi->fileNameEdit); | - | ||||||||||||||||||
| 1595 | d->lineEdit()->selectAll(); | - | ||||||||||||||||||
| 1596 | return; never executed: return; | 0 | ||||||||||||||||||
| 1597 | } | - | ||||||||||||||||||
| 1598 | - | |||||||||||||||||||
| 1599 | switch (fileMode()) { | - | ||||||||||||||||||
| 1600 | case never executed: DirectoryOnly:case DirectoryOnly:never executed: case DirectoryOnly: | 0 | ||||||||||||||||||
| 1601 | case never executed: Directory:case Directory:never executed: {case Directory: | 0 | ||||||||||||||||||
| 1602 | QString fn = files.first(); | - | ||||||||||||||||||
| 1603 | QFileInfo info(fn); | - | ||||||||||||||||||
| 1604 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1605 | info = QFileInfo(d->getEnvironmentVariable(fn)); never executed: info = QFileInfo(d->getEnvironmentVariable(fn)); | 0 | ||||||||||||||||||
| 1606 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1607 | - | |||||||||||||||||||
| 1608 | QString message = tr("%1\nDirectory not found.\nPlease verify the " | - | ||||||||||||||||||
| 1609 | "correct directory name was given."); | - | ||||||||||||||||||
| 1610 | QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); | - | ||||||||||||||||||
| 1611 | - | |||||||||||||||||||
| 1612 | return; never executed: return; | 0 | ||||||||||||||||||
| 1613 | } | - | ||||||||||||||||||
| 1614 | if (info.isDir()
| 0 | ||||||||||||||||||
| 1615 | d->emitFilesSelected(files); | - | ||||||||||||||||||
| 1616 | QDialog::accept(); | - | ||||||||||||||||||
| 1617 | } never executed: end of block | 0 | ||||||||||||||||||
| 1618 | return; never executed: return; | 0 | ||||||||||||||||||
| 1619 | } | - | ||||||||||||||||||
| 1620 | - | |||||||||||||||||||
| 1621 | case never executed: AnyFile:case AnyFile:never executed: {case AnyFile: | 0 | ||||||||||||||||||
| 1622 | QString fn = files.first(); | - | ||||||||||||||||||
| 1623 | QFileInfo info(fn); | - | ||||||||||||||||||
| 1624 | if (info.isDir()
| 0 | ||||||||||||||||||
| 1625 | setDirectory(info.absoluteFilePath()); | - | ||||||||||||||||||
| 1626 | return; never executed: return; | 0 | ||||||||||||||||||
| 1627 | } | - | ||||||||||||||||||
| 1628 | - | |||||||||||||||||||
| 1629 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1630 | int maxNameLength = d->maxNameLength(info.path()); | - | ||||||||||||||||||
| 1631 | if (maxNameLength >= 0
| 0 | ||||||||||||||||||
| 1632 | return; never executed: return; | 0 | ||||||||||||||||||
| 1633 | } never executed: end of block | 0 | ||||||||||||||||||
| 1634 | - | |||||||||||||||||||
| 1635 | - | |||||||||||||||||||
| 1636 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1637 | d->emitFilesSelected(QStringList(fn)); | - | ||||||||||||||||||
| 1638 | QDialog::accept(); | - | ||||||||||||||||||
| 1639 | - | |||||||||||||||||||
| 1640 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 1641 | if (QMessageBox::warning(this, windowTitle(),
| 0 | ||||||||||||||||||
| 1642 | tr("%1 already exists.\nDo you want to replace it?")
| 0 | ||||||||||||||||||
| 1643 | .arg(info.fileName()),
| 0 | ||||||||||||||||||
| 1644 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
| 0 | ||||||||||||||||||
| 1645 | == QMessageBox::Yes
| 0 | ||||||||||||||||||
| 1646 | d->emitFilesSelected(QStringList(fn)); | - | ||||||||||||||||||
| 1647 | QDialog::accept(); | - | ||||||||||||||||||
| 1648 | } never executed: end of block | 0 | ||||||||||||||||||
| 1649 | - | |||||||||||||||||||
| 1650 | } never executed: end of block | 0 | ||||||||||||||||||
| 1651 | return; never executed: return; | 0 | ||||||||||||||||||
| 1652 | } | - | ||||||||||||||||||
| 1653 | - | |||||||||||||||||||
| 1654 | case never executed: ExistingFile:case ExistingFile:never executed: case ExistingFile: | 0 | ||||||||||||||||||
| 1655 | case never executed: ExistingFiles:case ExistingFiles:never executed: case ExistingFiles: | 0 | ||||||||||||||||||
| 1656 | for (int i = 0; i < files.count()
| 0 | ||||||||||||||||||
| 1657 | QFileInfo info(files.at(i)); | - | ||||||||||||||||||
| 1658 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1659 | info = QFileInfo(d->getEnvironmentVariable(files.at(i))); never executed: info = QFileInfo(d->getEnvironmentVariable(files.at(i))); | 0 | ||||||||||||||||||
| 1660 | if (!info.exists()
| 0 | ||||||||||||||||||
| 1661 | - | |||||||||||||||||||
| 1662 | QString message = tr("%1\nFile not found.\nPlease verify the " | - | ||||||||||||||||||
| 1663 | "correct file name was given."); | - | ||||||||||||||||||
| 1664 | QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); | - | ||||||||||||||||||
| 1665 | - | |||||||||||||||||||
| 1666 | return; never executed: return; | 0 | ||||||||||||||||||
| 1667 | } | - | ||||||||||||||||||
| 1668 | if (info.isDir()
| 0 | ||||||||||||||||||
| 1669 | setDirectory(info.absoluteFilePath()); | - | ||||||||||||||||||
| 1670 | d->lineEdit()->clear(); | - | ||||||||||||||||||
| 1671 | return; never executed: return; | 0 | ||||||||||||||||||
| 1672 | } | - | ||||||||||||||||||
| 1673 | } never executed: end of block | 0 | ||||||||||||||||||
| 1674 | d->emitFilesSelected(files); | - | ||||||||||||||||||
| 1675 | QDialog::accept(); | - | ||||||||||||||||||
| 1676 | return; never executed: return; | 0 | ||||||||||||||||||
| 1677 | } | - | ||||||||||||||||||
| 1678 | } never executed: end of block | 0 | ||||||||||||||||||
| 1679 | - | |||||||||||||||||||
| 1680 | - | |||||||||||||||||||
| 1681 | void QFileDialogPrivate::saveSettings() | - | ||||||||||||||||||
| 1682 | { | - | ||||||||||||||||||
| 1683 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 1684 | QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); | - | ||||||||||||||||||
| 1685 | settings.beginGroup(QLatin1String("FileDialog")); | - | ||||||||||||||||||
| 1686 | - | |||||||||||||||||||
| 1687 | if (usingWidgets()
| 0 | ||||||||||||||||||
| 1688 | settings.setValue(QLatin1String("sidebarWidth"), qFileDialogUi->splitter->sizes().first()); | - | ||||||||||||||||||
| 1689 | settings.setValue(QLatin1String("shortcuts"), QUrl::toStringList(qFileDialogUi->sidebar->urls())); | - | ||||||||||||||||||
| 1690 | settings.setValue(QLatin1String("treeViewHeader"), qFileDialogUi->treeView->header()->saveState()); | - | ||||||||||||||||||
| 1691 | } never executed: end of block | 0 | ||||||||||||||||||
| 1692 | QStringList historyUrls; | - | ||||||||||||||||||
| 1693 | const QStringList history = q->history(); | - | ||||||||||||||||||
| 1694 | historyUrls.reserve(history.size()); | - | ||||||||||||||||||
| 1695 | 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 = 0) | - | ||||||||||||||||||
| 1696 | historyUrls << QUrl::fromLocalFile(path).toString(); never executed: historyUrls << QUrl::fromLocalFile(path).toString(); | 0 | ||||||||||||||||||
| 1697 | settings.setValue(QLatin1String("history"), historyUrls); | - | ||||||||||||||||||
| 1698 | settings.setValue(QLatin1String("lastVisited"), lastVisitedDir()->toString()); | - | ||||||||||||||||||
| 1699 | const QMetaEnum &viewModeMeta = q->metaObject()->enumerator(q->metaObject()->indexOfEnumerator("ViewMode")); | - | ||||||||||||||||||
| 1700 | settings.setValue(QLatin1String("viewMode"), QLatin1String(viewModeMeta.key(q->viewMode()))); | - | ||||||||||||||||||
| 1701 | settings.setValue(QLatin1String("qtVersion"), QLatin1String("5.6.4")); | - | ||||||||||||||||||
| 1702 | } never executed: end of block | 0 | ||||||||||||||||||
| 1703 | - | |||||||||||||||||||
| 1704 | bool QFileDialogPrivate::restoreFromSettings() | - | ||||||||||||||||||
| 1705 | { | - | ||||||||||||||||||
| 1706 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 1707 | QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); | - | ||||||||||||||||||
| 1708 | if (!settings.childGroups().contains(QLatin1String("FileDialog"))
| 0 | ||||||||||||||||||
| 1709 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 1710 | settings.beginGroup(QLatin1String("FileDialog")); | - | ||||||||||||||||||
| 1711 | - | |||||||||||||||||||
| 1712 | q->setDirectoryUrl(lastVisitedDir()->isEmpty() ? settings.value(QLatin1String("lastVisited")).toUrl() : *lastVisitedDir()); | - | ||||||||||||||||||
| 1713 | - | |||||||||||||||||||
| 1714 | QByteArray viewModeStr = settings.value(QLatin1String("viewMode")).toString().toLatin1(); | - | ||||||||||||||||||
| 1715 | const QMetaEnum &viewModeMeta = q->metaObject()->enumerator(q->metaObject()->indexOfEnumerator("ViewMode")); | - | ||||||||||||||||||
| 1716 | bool ok = false; | - | ||||||||||||||||||
| 1717 | int viewMode = viewModeMeta.keyToValue(viewModeStr.constData(), &ok); | - | ||||||||||||||||||
| 1718 | if (!ok
| 0 | ||||||||||||||||||
| 1719 | viewMode = QFileDialog::List; never executed: viewMode = QFileDialog::List; | 0 | ||||||||||||||||||
| 1720 | q->setViewMode(static_cast<QFileDialog::ViewMode>(viewMode)); | - | ||||||||||||||||||
| 1721 | - | |||||||||||||||||||
| 1722 | sidebarUrls = QUrl::fromStringList(settings.value(QLatin1String("shortcuts")).toStringList()); | - | ||||||||||||||||||
| 1723 | headerData = settings.value(QLatin1String("treeViewHeader")).toByteArray(); | - | ||||||||||||||||||
| 1724 | - | |||||||||||||||||||
| 1725 | if (!usingWidgets()
| 0 | ||||||||||||||||||
| 1726 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 1727 | - | |||||||||||||||||||
| 1728 | QStringList history; | - | ||||||||||||||||||
| 1729 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(settings.value(QLatin1String("history")).toStringList())>::type> _container_((settings.value(QLatin1String("history")).toStringList())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &urlStr = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 1730 | QUrl url(urlStr); | - | ||||||||||||||||||
| 1731 | if (url.isLocalFile()
| 0 | ||||||||||||||||||
| 1732 | history << url.toLocalFile(); never executed: history << url.toLocalFile(); | 0 | ||||||||||||||||||
| 1733 | } never executed: end of block | 0 | ||||||||||||||||||
| 1734 | - | |||||||||||||||||||
| 1735 | 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 | ||||||||||||||||||
| 1736 | } | - | ||||||||||||||||||
| 1737 | - | |||||||||||||||||||
| 1738 | - | |||||||||||||||||||
| 1739 | bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPosition) | - | ||||||||||||||||||
| 1740 | { | - | ||||||||||||||||||
| 1741 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 1742 | if (splitterPosition >= 0
| 0 | ||||||||||||||||||
| 1743 | QList<int> splitterSizes; | - | ||||||||||||||||||
| 1744 | splitterSizes.append(splitterPosition); | - | ||||||||||||||||||
| 1745 | splitterSizes.append(qFileDialogUi->splitter->widget(1)->sizeHint().width()); | - | ||||||||||||||||||
| 1746 | qFileDialogUi->splitter->setSizes(splitterSizes); | - | ||||||||||||||||||
| 1747 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 1748 | if (!qFileDialogUi->splitter->restoreState(splitterState)
| 0 | ||||||||||||||||||
| 1749 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 1750 | QList<int> list = qFileDialogUi->splitter->sizes(); | - | ||||||||||||||||||
| 1751 | if (list.count() >= 2
| 0 | ||||||||||||||||||
| 1752 | for (int i = 0; i < list.count()
| 0 | ||||||||||||||||||
| 1753 | list[i] = qFileDialogUi->splitter->widget(i)->sizeHint().width(); never executed: list[i] = qFileDialogUi->splitter->widget(i)->sizeHint().width(); | 0 | ||||||||||||||||||
| 1754 | qFileDialogUi->splitter->setSizes(list); | - | ||||||||||||||||||
| 1755 | } never executed: end of block | 0 | ||||||||||||||||||
| 1756 | } never executed: end of block | 0 | ||||||||||||||||||
| 1757 | - | |||||||||||||||||||
| 1758 | qFileDialogUi->sidebar->setUrls(sidebarUrls); | - | ||||||||||||||||||
| 1759 | while (history.count() > 5
| 0 | ||||||||||||||||||
| 1760 | history.pop_front(); never executed: history.pop_front(); | 0 | ||||||||||||||||||
| 1761 | q->setHistory(history); | - | ||||||||||||||||||
| 1762 | - | |||||||||||||||||||
| 1763 | QHeaderView *headerView = qFileDialogUi->treeView->header(); | - | ||||||||||||||||||
| 1764 | if (!headerView->restoreState(headerData)
| 0 | ||||||||||||||||||
| 1765 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 1766 | - | |||||||||||||||||||
| 1767 | QList<QAction*> actions = headerView->actions(); | - | ||||||||||||||||||
| 1768 | QAbstractItemModel *abstractModel = model; | - | ||||||||||||||||||
| 1769 | - | |||||||||||||||||||
| 1770 | if (proxyModel
| 0 | ||||||||||||||||||
| 1771 | abstractModel = proxyModel; never executed: abstractModel = proxyModel; | 0 | ||||||||||||||||||
| 1772 | - | |||||||||||||||||||
| 1773 | int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1); | - | ||||||||||||||||||
| 1774 | for (int i = 1; i < total
| 0 | ||||||||||||||||||
| 1775 | actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i)); never executed: actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i)); | 0 | ||||||||||||||||||
| 1776 | - | |||||||||||||||||||
| 1777 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 1778 | } | - | ||||||||||||||||||
| 1779 | - | |||||||||||||||||||
| 1780 | - | |||||||||||||||||||
| 1781 | - | |||||||||||||||||||
| 1782 | - | |||||||||||||||||||
| 1783 | - | |||||||||||||||||||
| 1784 | - | |||||||||||||||||||
| 1785 | void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter, | - | ||||||||||||||||||
| 1786 | const QString &caption) | - | ||||||||||||||||||
| 1787 | { | - | ||||||||||||||||||
| 1788 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 1789 | if (!caption.isEmpty()
| 0 | ||||||||||||||||||
| 1790 | useDefaultCaption = false; | - | ||||||||||||||||||
| 1791 | setWindowTitle = caption; | - | ||||||||||||||||||
| 1792 | q->setWindowTitle(caption); | - | ||||||||||||||||||
| 1793 | } never executed: end of block | 0 | ||||||||||||||||||
| 1794 | - | |||||||||||||||||||
| 1795 | q->setAcceptMode(QFileDialog::AcceptOpen); | - | ||||||||||||||||||
| 1796 | nativeDialogInUse = (canBeNativeDialog()
| 0 | ||||||||||||||||||
| 1797 | if (!nativeDialogInUse
| 0 | ||||||||||||||||||
| 1798 | createWidgets(); never executed: createWidgets(); | 0 | ||||||||||||||||||
| 1799 | q->setFileMode(QFileDialog::AnyFile); | - | ||||||||||||||||||
| 1800 | if (!nameFilter.isEmpty()
| 0 | ||||||||||||||||||
| 1801 | q->setNameFilter(nameFilter); never executed: q->setNameFilter(nameFilter); | 0 | ||||||||||||||||||
| 1802 | q->setDirectoryUrl(workingDirectory(directory)); | - | ||||||||||||||||||
| 1803 | q->selectFile(initialSelection(directory)); | - | ||||||||||||||||||
| 1804 | - | |||||||||||||||||||
| 1805 | - | |||||||||||||||||||
| 1806 | - | |||||||||||||||||||
| 1807 | - | |||||||||||||||||||
| 1808 | if (!restoreFromSettings()
| 0 | ||||||||||||||||||
| 1809 | const QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); | - | ||||||||||||||||||
| 1810 | q->restoreState(settings.value(QLatin1String("Qt/filedialog")).toByteArray()); | - | ||||||||||||||||||
| 1811 | } never executed: end of block | 0 | ||||||||||||||||||
| 1812 | const QSize sizeHint = q->sizeHint(); | - | ||||||||||||||||||
| 1813 | if (sizeHint.isValid()
| 0 | ||||||||||||||||||
| 1814 | q->resize(sizeHint); never executed: q->resize(sizeHint); | 0 | ||||||||||||||||||
| 1815 | } never executed: end of block | 0 | ||||||||||||||||||
| 1816 | - | |||||||||||||||||||
| 1817 | - | |||||||||||||||||||
| 1818 | - | |||||||||||||||||||
| 1819 | - | |||||||||||||||||||
| 1820 | - | |||||||||||||||||||
| 1821 | - | |||||||||||||||||||
| 1822 | void QFileDialogPrivate::createWidgets() | - | ||||||||||||||||||
| 1823 | { | - | ||||||||||||||||||
| 1824 | if (qFileDialogUi
| 0 | ||||||||||||||||||
| 1825 | return; never executed: return; | 0 | ||||||||||||||||||
| 1826 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 1827 | - | |||||||||||||||||||
| 1828 | - | |||||||||||||||||||
| 1829 | - | |||||||||||||||||||
| 1830 | - | |||||||||||||||||||
| 1831 | QSize preSize = q->testAttribute(Qt::WA_Resized)
| 0 | ||||||||||||||||||
| 1832 | Qt::WindowStates preState = q->windowState(); | - | ||||||||||||||||||
| 1833 | - | |||||||||||||||||||
| 1834 | model = new QFileSystemModel(q); | - | ||||||||||||||||||
| 1835 | model->setFilter(options->filter()); | - | ||||||||||||||||||
| 1836 | model->setObjectName(QLatin1String("qt_filesystem_model")); | - | ||||||||||||||||||
| 1837 | if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()
| 0 | ||||||||||||||||||
| 1838 | model->setNameFilterDisables(helper->defaultNameFilterDisables()); never executed: model->setNameFilterDisables(helper->defaultNameFilterDisables()); | 0 | ||||||||||||||||||
| 1839 | else | - | ||||||||||||||||||
| 1840 | model->setNameFilterDisables(false); never executed: model->setNameFilterDisables(false); | 0 | ||||||||||||||||||
| 1841 | if (nativeDialogInUse
| 0 | ||||||||||||||||||
| 1842 | deletePlatformHelper(); never executed: deletePlatformHelper(); | 0 | ||||||||||||||||||
| 1843 | model->d_func()->disableRecursiveSort = true; | - | ||||||||||||||||||
| 1844 | QFileDialog::connect(model, qFlagLocation("2""fileRenamed(QString,QString,QString)" "\0" __FILE__ ":" "2864"), q, qFlagLocation("1""_q_fileRenamed(QString,QString,QString)" "\0" __FILE__ ":" "2864")); | - | ||||||||||||||||||
| 1845 | QFileDialog::connect(model, qFlagLocation("2""rootPathChanged(QString)" "\0" __FILE__ ":" "2865"), | - | ||||||||||||||||||
| 1846 | q, qFlagLocation("1""_q_pathChanged(QString)" "\0" __FILE__ ":" "2866")); | - | ||||||||||||||||||
| 1847 | QFileDialog::connect(model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "2867"), | - | ||||||||||||||||||
| 1848 | q, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "2868")); | - | ||||||||||||||||||
| 1849 | model->setReadOnly(false); | - | ||||||||||||||||||
| 1850 | - | |||||||||||||||||||
| 1851 | qFileDialogUi.reset(new Ui_QFileDialog()); | - | ||||||||||||||||||
| 1852 | qFileDialogUi->setupUi(q); | - | ||||||||||||||||||
| 1853 | - | |||||||||||||||||||
| 1854 | QList<QUrl> initialBookmarks; | - | ||||||||||||||||||
| 1855 | initialBookmarks << QUrl(QLatin1String("file:")) | - | ||||||||||||||||||
| 1856 | << QUrl::fromLocalFile(QDir::homePath()); | - | ||||||||||||||||||
| 1857 | qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks); | - | ||||||||||||||||||
| 1858 | QFileDialog::connect(qFileDialogUi->sidebar, qFlagLocation("2""goToUrl(QUrl)" "\0" __FILE__ ":" "2878"), | - | ||||||||||||||||||
| 1859 | q, qFlagLocation("1""_q_goToUrl(QUrl)" "\0" __FILE__ ":" "2879")); | - | ||||||||||||||||||
| 1860 | - | |||||||||||||||||||
| 1861 | QObject::connect(qFileDialogUi->buttonBox, qFlagLocation("2""accepted()" "\0" __FILE__ ":" "2881"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "2881")); | - | ||||||||||||||||||
| 1862 | QObject::connect(qFileDialogUi->buttonBox, qFlagLocation("2""rejected()" "\0" __FILE__ ":" "2882"), q, qFlagLocation("1""reject()" "\0" __FILE__ ":" "2882")); | - | ||||||||||||||||||
| 1863 | - | |||||||||||||||||||
| 1864 | qFileDialogUi->lookInCombo->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1865 | QObject::connect(qFileDialogUi->lookInCombo, qFlagLocation("2""activated(QString)" "\0" __FILE__ ":" "2885"), q, qFlagLocation("1""_q_goToDirectory(QString)" "\0" __FILE__ ":" "2885")); | - | ||||||||||||||||||
| 1866 | - | |||||||||||||||||||
| 1867 | qFileDialogUi->lookInCombo->setInsertPolicy(QComboBox::NoInsert); | - | ||||||||||||||||||
| 1868 | qFileDialogUi->lookInCombo->setDuplicatesEnabled(false); | - | ||||||||||||||||||
| 1869 | - | |||||||||||||||||||
| 1870 | - | |||||||||||||||||||
| 1871 | qFileDialogUi->fileNameEdit->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1872 | - | |||||||||||||||||||
| 1873 | qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); | - | ||||||||||||||||||
| 1874 | - | |||||||||||||||||||
| 1875 | - | |||||||||||||||||||
| 1876 | completer = new QFSCompleter(model, q); | - | ||||||||||||||||||
| 1877 | qFileDialogUi->fileNameEdit->setCompleter(completer); | - | ||||||||||||||||||
| 1878 | - | |||||||||||||||||||
| 1879 | - | |||||||||||||||||||
| 1880 | qFileDialogUi->fileNameEdit->setInputMethodHints(Qt::ImhNoPredictiveText); | - | ||||||||||||||||||
| 1881 | - | |||||||||||||||||||
| 1882 | QObject::connect(qFileDialogUi->fileNameEdit, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "2902"), | - | ||||||||||||||||||
| 1883 | q, qFlagLocation("1""_q_autoCompleteFileName(QString)" "\0" __FILE__ ":" "2903")); | - | ||||||||||||||||||
| 1884 | QObject::connect(qFileDialogUi->fileNameEdit, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "2904"), | - | ||||||||||||||||||
| 1885 | q, qFlagLocation("1""_q_updateOkButton()" "\0" __FILE__ ":" "2905")); | - | ||||||||||||||||||
| 1886 | - | |||||||||||||||||||
| 1887 | QObject::connect(qFileDialogUi->fileNameEdit, qFlagLocation("2""returnPressed()" "\0" __FILE__ ":" "2907"), q, qFlagLocation("1""accept()" "\0" __FILE__ ":" "2907")); | - | ||||||||||||||||||
| 1888 | - | |||||||||||||||||||
| 1889 | - | |||||||||||||||||||
| 1890 | qFileDialogUi->fileTypeCombo->setDuplicatesEnabled(false); | - | ||||||||||||||||||
| 1891 | qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | - | ||||||||||||||||||
| 1892 | qFileDialogUi->fileTypeCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | - | ||||||||||||||||||
| 1893 | QObject::connect(qFileDialogUi->fileTypeCombo, qFlagLocation("2""activated(int)" "\0" __FILE__ ":" "2913"), | - | ||||||||||||||||||
| 1894 | q, qFlagLocation("1""_q_useNameFilter(int)" "\0" __FILE__ ":" "2914")); | - | ||||||||||||||||||
| 1895 | QObject::connect(qFileDialogUi->fileTypeCombo, qFlagLocation("2""activated(QString)" "\0" __FILE__ ":" "2915"), | - | ||||||||||||||||||
| 1896 | q, qFlagLocation("2""filterSelected(QString)" "\0" __FILE__ ":" "2916")); | - | ||||||||||||||||||
| 1897 | - | |||||||||||||||||||
| 1898 | qFileDialogUi->listView->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1899 | qFileDialogUi->listView->setModel(model); | - | ||||||||||||||||||
| 1900 | QObject::connect(qFileDialogUi->listView, qFlagLocation("2""activated(QModelIndex)" "\0" __FILE__ ":" "2920"), | - | ||||||||||||||||||
| 1901 | q, qFlagLocation("1""_q_enterDirectory(QModelIndex)" "\0" __FILE__ ":" "2921")); | - | ||||||||||||||||||
| 1902 | QObject::connect(qFileDialogUi->listView, qFlagLocation("2""customContextMenuRequested(QPoint)" "\0" __FILE__ ":" "2922"), | - | ||||||||||||||||||
| 1903 | q, qFlagLocation("1""_q_showContextMenu(QPoint)" "\0" __FILE__ ":" "2923")); | - | ||||||||||||||||||
| 1904 | - | |||||||||||||||||||
| 1905 | QShortcut *shortcut = new QShortcut(qFileDialogUi->listView); | - | ||||||||||||||||||
| 1906 | shortcut->setKey(QKeySequence(QLatin1String("Delete"))); | - | ||||||||||||||||||
| 1907 | QObject::connect(shortcut, qFlagLocation("2""activated()" "\0" __FILE__ ":" "2927"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "2927")); | - | ||||||||||||||||||
| 1908 | - | |||||||||||||||||||
| 1909 | - | |||||||||||||||||||
| 1910 | qFileDialogUi->treeView->setFileDialogPrivate(this); | - | ||||||||||||||||||
| 1911 | qFileDialogUi->treeView->setModel(model); | - | ||||||||||||||||||
| 1912 | QHeaderView *treeHeader = qFileDialogUi->treeView->header(); | - | ||||||||||||||||||
| 1913 | QFontMetrics fm(q->font()); | - | ||||||||||||||||||
| 1914 | treeHeader->resizeSection(0, fm.width(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww"))); | - | ||||||||||||||||||
| 1915 | treeHeader->resizeSection(1, fm.width(QLatin1String("128.88 GB"))); | - | ||||||||||||||||||
| 1916 | treeHeader->resizeSection(2, fm.width(QLatin1String("mp3Folder"))); | - | ||||||||||||||||||
| 1917 | treeHeader->resizeSection(3, fm.width(QLatin1String("10/29/81 02:02PM"))); | - | ||||||||||||||||||
| 1918 | treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu); | - | ||||||||||||||||||
| 1919 | - | |||||||||||||||||||
| 1920 | QActionGroup *showActionGroup = new QActionGroup(q); | - | ||||||||||||||||||
| 1921 | showActionGroup->setExclusive(false); | - | ||||||||||||||||||
| 1922 | QObject::connect(showActionGroup, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "2942"), | - | ||||||||||||||||||
| 1923 | q, qFlagLocation("1""_q_showHeader(QAction*)" "\0" __FILE__ ":" "2943"));; | - | ||||||||||||||||||
| 1924 | - | |||||||||||||||||||
| 1925 | QAbstractItemModel *abstractModel = model; | - | ||||||||||||||||||
| 1926 | - | |||||||||||||||||||
| 1927 | if (proxyModel
| 0 | ||||||||||||||||||
| 1928 | abstractModel = proxyModel; never executed: abstractModel = proxyModel; | 0 | ||||||||||||||||||
| 1929 | - | |||||||||||||||||||
| 1930 | for (int i = 1; i < abstractModel->columnCount(QModelIndex())
| 0 | ||||||||||||||||||
| 1931 | QAction *showHeader = new QAction(showActionGroup); | - | ||||||||||||||||||
| 1932 | showHeader->setCheckable(true); | - | ||||||||||||||||||
| 1933 | showHeader->setChecked(true); | - | ||||||||||||||||||
| 1934 | treeHeader->addAction(showHeader); | - | ||||||||||||||||||
| 1935 | } never executed: end of block | 0 | ||||||||||||||||||
| 1936 | - | |||||||||||||||||||
| 1937 | QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel()); | - | ||||||||||||||||||
| 1938 | qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel()); | - | ||||||||||||||||||
| 1939 | - | |||||||||||||||||||
| 1940 | QObject::connect(qFileDialogUi->treeView, qFlagLocation("2""activated(QModelIndex)" "\0" __FILE__ ":" "2960"), | - | ||||||||||||||||||
| 1941 | q, qFlagLocation("1""_q_enterDirectory(QModelIndex)" "\0" __FILE__ ":" "2961")); | - | ||||||||||||||||||
| 1942 | QObject::connect(qFileDialogUi->treeView, qFlagLocation("2""customContextMenuRequested(QPoint)" "\0" __FILE__ ":" "2962"), | - | ||||||||||||||||||
| 1943 | q, qFlagLocation("1""_q_showContextMenu(QPoint)" "\0" __FILE__ ":" "2963")); | - | ||||||||||||||||||
| 1944 | - | |||||||||||||||||||
| 1945 | shortcut = new QShortcut(qFileDialogUi->treeView); | - | ||||||||||||||||||
| 1946 | shortcut->setKey(QKeySequence(QLatin1String("Delete"))); | - | ||||||||||||||||||
| 1947 | QObject::connect(shortcut, qFlagLocation("2""activated()" "\0" __FILE__ ":" "2967"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "2967")); | - | ||||||||||||||||||
| 1948 | - | |||||||||||||||||||
| 1949 | - | |||||||||||||||||||
| 1950 | - | |||||||||||||||||||
| 1951 | QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel(); | - | ||||||||||||||||||
| 1952 | QObject::connect(selections, qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "2972"), | - | ||||||||||||||||||
| 1953 | q, qFlagLocation("1""_q_selectionChanged()" "\0" __FILE__ ":" "2973")); | - | ||||||||||||||||||
| 1954 | QObject::connect(selections, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2974"), | - | ||||||||||||||||||
| 1955 | q, qFlagLocation("1""_q_currentChanged(QModelIndex)" "\0" __FILE__ ":" "2975")); | - | ||||||||||||||||||
| 1956 | qFileDialogUi->splitter->setStretchFactor(qFileDialogUi->splitter->indexOf(qFileDialogUi->splitter->widget(1)), QSizePolicy::Expanding); | - | ||||||||||||||||||
| 1957 | - | |||||||||||||||||||
| 1958 | createToolButtons(); | - | ||||||||||||||||||
| 1959 | createMenuActions(); | - | ||||||||||||||||||
| 1960 | - | |||||||||||||||||||
| 1961 | - | |||||||||||||||||||
| 1962 | - | |||||||||||||||||||
| 1963 | - | |||||||||||||||||||
| 1964 | if (!restoreFromSettings()
| 0 | ||||||||||||||||||
| 1965 | const QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); | - | ||||||||||||||||||
| 1966 | q->restoreState(settings.value(QLatin1String("Qt/filedialog")).toByteArray()); | - | ||||||||||||||||||
| 1967 | } never executed: end of block | 0 | ||||||||||||||||||
| 1968 | - | |||||||||||||||||||
| 1969 | - | |||||||||||||||||||
| 1970 | - | |||||||||||||||||||
| 1971 | q->setFileMode(static_cast<QFileDialog::FileMode>(options->fileMode())); | - | ||||||||||||||||||
| 1972 | q->setAcceptMode(static_cast<QFileDialog::AcceptMode>(options->acceptMode())); | - | ||||||||||||||||||
| 1973 | q->setViewMode(static_cast<QFileDialog::ViewMode>(options->viewMode())); | - | ||||||||||||||||||
| 1974 | q->setOptions(static_cast<QFileDialog::Options>(static_cast<int>(options->options()))); | - | ||||||||||||||||||
| 1975 | if (!options->sidebarUrls().isEmpty()
| 0 | ||||||||||||||||||
| 1976 | q->setSidebarUrls(options->sidebarUrls()); never executed: q->setSidebarUrls(options->sidebarUrls()); | 0 | ||||||||||||||||||
| 1977 | q->setDirectoryUrl(options->initialDirectory()); | - | ||||||||||||||||||
| 1978 | - | |||||||||||||||||||
| 1979 | if (!options->mimeTypeFilters().isEmpty()
| 0 | ||||||||||||||||||
| 1980 | q->setMimeTypeFilters(options->mimeTypeFilters()); never executed: q->setMimeTypeFilters(options->mimeTypeFilters()); | 0 | ||||||||||||||||||
| 1981 | else | - | ||||||||||||||||||
| 1982 | - | |||||||||||||||||||
| 1983 | if (!options->nameFilters().isEmpty()
| 0 | ||||||||||||||||||
| 1984 | q->setNameFilters(options->nameFilters()); never executed: q->setNameFilters(options->nameFilters()); | 0 | ||||||||||||||||||
| 1985 | q->selectNameFilter(options->initiallySelectedNameFilter()); | - | ||||||||||||||||||
| 1986 | q->setDefaultSuffix(options->defaultSuffix()); | - | ||||||||||||||||||
| 1987 | q->setHistory(options->history()); | - | ||||||||||||||||||
| 1988 | if (options->initiallySelectedFiles().count() == 1
| 0 | ||||||||||||||||||
| 1989 | q->selectFile(options->initiallySelectedFiles().first().fileName()); never executed: q->selectFile(options->initiallySelectedFiles().first().fileName()); | 0 | ||||||||||||||||||
| 1990 | 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 = 0) | - | ||||||||||||||||||
| 1991 | q->selectUrl(url); never executed: q->selectUrl(url); | 0 | ||||||||||||||||||
| 1992 | lineEdit()->selectAll(); | - | ||||||||||||||||||
| 1993 | _q_updateOkButton(); | - | ||||||||||||||||||
| 1994 | retranslateStrings(); | - | ||||||||||||||||||
| 1995 | q->resize(preSize.isValid() ? preSize : q->sizeHint()); | - | ||||||||||||||||||
| 1996 | q->setWindowState(preState); | - | ||||||||||||||||||
| 1997 | } never executed: end of block | 0 | ||||||||||||||||||
| 1998 | - | |||||||||||||||||||
| 1999 | void QFileDialogPrivate::_q_showHeader(QAction *action) | - | ||||||||||||||||||
| 2000 | { | - | ||||||||||||||||||
| 2001 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2002 | QActionGroup *actionGroup = qobject_cast<QActionGroup*>(q->sender()); | - | ||||||||||||||||||
| 2003 | qFileDialogUi->treeView->header()->setSectionHidden(actionGroup->actions().indexOf(action) + 1, !action->isChecked()); | - | ||||||||||||||||||
| 2004 | } never executed: end of block | 0 | ||||||||||||||||||
| 2005 | void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) | - | ||||||||||||||||||
| 2006 | { | - | ||||||||||||||||||
| 2007 | QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2008 | if (!d->usingWidgets()
| 0 | ||||||||||||||||||
| 2009 | return; never executed: return; | 0 | ||||||||||||||||||
| 2010 | if ((!proxyModel
| 0 | ||||||||||||||||||
| 2011 | || (
| 0 | ||||||||||||||||||
| 2012 | return; never executed: return; | 0 | ||||||||||||||||||
| 2013 | - | |||||||||||||||||||
| 2014 | QModelIndex idx = d->rootIndex(); | - | ||||||||||||||||||
| 2015 | if (d->proxyModel
| 0 | ||||||||||||||||||
| 2016 | disconnect(d->proxyModel, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3050"), | - | ||||||||||||||||||
| 2017 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3051")); | - | ||||||||||||||||||
| 2018 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2019 | disconnect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3053"), | - | ||||||||||||||||||
| 2020 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3054")); | - | ||||||||||||||||||
| 2021 | } never executed: end of block | 0 | ||||||||||||||||||
| 2022 | - | |||||||||||||||||||
| 2023 | if (proxyModel != 0
| 0 | ||||||||||||||||||
| 2024 | proxyModel->setParent(this); | - | ||||||||||||||||||
| 2025 | d->proxyModel = proxyModel; | - | ||||||||||||||||||
| 2026 | proxyModel->setSourceModel(d->model); | - | ||||||||||||||||||
| 2027 | d->qFileDialogUi->listView->setModel(d->proxyModel); | - | ||||||||||||||||||
| 2028 | d->qFileDialogUi->treeView->setModel(d->proxyModel); | - | ||||||||||||||||||
| 2029 | - | |||||||||||||||||||
| 2030 | d->completer->setModel(d->proxyModel); | - | ||||||||||||||||||
| 2031 | d->completer->proxyModel = d->proxyModel; | - | ||||||||||||||||||
| 2032 | - | |||||||||||||||||||
| 2033 | connect(d->proxyModel, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3067"), | - | ||||||||||||||||||
| 2034 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3068")); | - | ||||||||||||||||||
| 2035 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2036 | d->proxyModel = 0; | - | ||||||||||||||||||
| 2037 | d->qFileDialogUi->listView->setModel(d->model); | - | ||||||||||||||||||
| 2038 | d->qFileDialogUi->treeView->setModel(d->model); | - | ||||||||||||||||||
| 2039 | - | |||||||||||||||||||
| 2040 | d->completer->setModel(d->model); | - | ||||||||||||||||||
| 2041 | d->completer->sourceModel = d->model; | - | ||||||||||||||||||
| 2042 | d->completer->proxyModel = 0; | - | ||||||||||||||||||
| 2043 | - | |||||||||||||||||||
| 2044 | connect(d->model, qFlagLocation("2""rowsInserted(QModelIndex,int,int)" "\0" __FILE__ ":" "3078"), | - | ||||||||||||||||||
| 2045 | this, qFlagLocation("1""_q_rowsInserted(QModelIndex)" "\0" __FILE__ ":" "3079")); | - | ||||||||||||||||||
| 2046 | } never executed: end of block | 0 | ||||||||||||||||||
| 2047 | QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel()); | - | ||||||||||||||||||
| 2048 | d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel()); | - | ||||||||||||||||||
| 2049 | - | |||||||||||||||||||
| 2050 | d->setRootIndex(idx); | - | ||||||||||||||||||
| 2051 | - | |||||||||||||||||||
| 2052 | - | |||||||||||||||||||
| 2053 | QItemSelectionModel *selections = d->qFileDialogUi->listView->selectionModel(); | - | ||||||||||||||||||
| 2054 | QObject::connect(selections, qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "3088"), | - | ||||||||||||||||||
| 2055 | this, qFlagLocation("1""_q_selectionChanged()" "\0" __FILE__ ":" "3089")); | - | ||||||||||||||||||
| 2056 | QObject::connect(selections, qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "3090"), | - | ||||||||||||||||||
| 2057 | this, qFlagLocation("1""_q_currentChanged(QModelIndex)" "\0" __FILE__ ":" "3091")); | - | ||||||||||||||||||
| 2058 | } never executed: end of block | 0 | ||||||||||||||||||
| 2059 | - | |||||||||||||||||||
| 2060 | - | |||||||||||||||||||
| 2061 | - | |||||||||||||||||||
| 2062 | - | |||||||||||||||||||
| 2063 | - | |||||||||||||||||||
| 2064 | - | |||||||||||||||||||
| 2065 | QAbstractProxyModel *QFileDialog::proxyModel() const | - | ||||||||||||||||||
| 2066 | { | - | ||||||||||||||||||
| 2067 | const QFileDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 2068 | return never executed: d->proxyModel;return d->proxyModel;never executed: return d->proxyModel; | 0 | ||||||||||||||||||
| 2069 | } | - | ||||||||||||||||||
| 2070 | - | |||||||||||||||||||
| 2071 | - | |||||||||||||||||||
| 2072 | - | |||||||||||||||||||
| 2073 | - | |||||||||||||||||||
| 2074 | - | |||||||||||||||||||
| 2075 | - | |||||||||||||||||||
| 2076 | - | |||||||||||||||||||
| 2077 | void QFileDialogPrivate::createToolButtons() | - | ||||||||||||||||||
| 2078 | { | - | ||||||||||||||||||
| 2079 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2080 | qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, 0, q)); | - | ||||||||||||||||||
| 2081 | qFileDialogUi->backButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2082 | qFileDialogUi->backButton->setEnabled(false); | - | ||||||||||||||||||
| 2083 | QObject::connect(qFileDialogUi->backButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3117"), q, qFlagLocation("1""_q_navigateBackward()" "\0" __FILE__ ":" "3117")); | - | ||||||||||||||||||
| 2084 | - | |||||||||||||||||||
| 2085 | qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, 0, q)); | - | ||||||||||||||||||
| 2086 | qFileDialogUi->forwardButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2087 | qFileDialogUi->forwardButton->setEnabled(false); | - | ||||||||||||||||||
| 2088 | QObject::connect(qFileDialogUi->forwardButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3122"), q, qFlagLocation("1""_q_navigateForward()" "\0" __FILE__ ":" "3122")); | - | ||||||||||||||||||
| 2089 | - | |||||||||||||||||||
| 2090 | qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, 0, q)); | - | ||||||||||||||||||
| 2091 | qFileDialogUi->toParentButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2092 | qFileDialogUi->toParentButton->setEnabled(false); | - | ||||||||||||||||||
| 2093 | QObject::connect(qFileDialogUi->toParentButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3127"), q, qFlagLocation("1""_q_navigateToParent()" "\0" __FILE__ ":" "3127")); | - | ||||||||||||||||||
| 2094 | - | |||||||||||||||||||
| 2095 | qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, 0, q)); | - | ||||||||||||||||||
| 2096 | qFileDialogUi->listModeButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2097 | qFileDialogUi->listModeButton->setDown(true); | - | ||||||||||||||||||
| 2098 | QObject::connect(qFileDialogUi->listModeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3132"), q, qFlagLocation("1""_q_showListView()" "\0" __FILE__ ":" "3132")); | - | ||||||||||||||||||
| 2099 | - | |||||||||||||||||||
| 2100 | qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, 0, q)); | - | ||||||||||||||||||
| 2101 | qFileDialogUi->detailModeButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2102 | QObject::connect(qFileDialogUi->detailModeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3136"), q, qFlagLocation("1""_q_showDetailsView()" "\0" __FILE__ ":" "3136")); | - | ||||||||||||||||||
| 2103 | - | |||||||||||||||||||
| 2104 | QSize toolSize(qFileDialogUi->fileNameEdit->sizeHint().height(), qFileDialogUi->fileNameEdit->sizeHint().height()); | - | ||||||||||||||||||
| 2105 | qFileDialogUi->backButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2106 | qFileDialogUi->listModeButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2107 | qFileDialogUi->detailModeButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2108 | qFileDialogUi->forwardButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2109 | qFileDialogUi->toParentButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2110 | - | |||||||||||||||||||
| 2111 | qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, 0, q)); | - | ||||||||||||||||||
| 2112 | qFileDialogUi->newFolderButton->setFixedSize(toolSize); | - | ||||||||||||||||||
| 2113 | qFileDialogUi->newFolderButton->setAutoRaise(true); | - | ||||||||||||||||||
| 2114 | qFileDialogUi->newFolderButton->setEnabled(false); | - | ||||||||||||||||||
| 2115 | QObject::connect(qFileDialogUi->newFolderButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "3149"), q, qFlagLocation("1""_q_createDirectory()" "\0" __FILE__ ":" "3149")); | - | ||||||||||||||||||
| 2116 | } never executed: end of block | 0 | ||||||||||||||||||
| 2117 | - | |||||||||||||||||||
| 2118 | - | |||||||||||||||||||
| 2119 | - | |||||||||||||||||||
| 2120 | - | |||||||||||||||||||
| 2121 | - | |||||||||||||||||||
| 2122 | - | |||||||||||||||||||
| 2123 | void QFileDialogPrivate::createMenuActions() | - | ||||||||||||||||||
| 2124 | { | - | ||||||||||||||||||
| 2125 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2126 | - | |||||||||||||||||||
| 2127 | QAction *goHomeAction = new QAction(q); | - | ||||||||||||||||||
| 2128 | - | |||||||||||||||||||
| 2129 | goHomeAction->setShortcut(Qt::CTRL + Qt::Key_H + Qt::SHIFT); | - | ||||||||||||||||||
| 2130 | - | |||||||||||||||||||
| 2131 | QObject::connect(goHomeAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3165"), q, qFlagLocation("1""_q_goHome()" "\0" __FILE__ ":" "3165")); | - | ||||||||||||||||||
| 2132 | q->addAction(goHomeAction); | - | ||||||||||||||||||
| 2133 | - | |||||||||||||||||||
| 2134 | - | |||||||||||||||||||
| 2135 | - | |||||||||||||||||||
| 2136 | QAction *goToParent = new QAction(q); | - | ||||||||||||||||||
| 2137 | goToParent->setObjectName(QLatin1String("qt_goto_parent_action")); | - | ||||||||||||||||||
| 2138 | - | |||||||||||||||||||
| 2139 | goToParent->setShortcut(Qt::CTRL + Qt::UpArrow); | - | ||||||||||||||||||
| 2140 | - | |||||||||||||||||||
| 2141 | QObject::connect(goToParent, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3175"), q, qFlagLocation("1""_q_navigateToParent()" "\0" __FILE__ ":" "3175")); | - | ||||||||||||||||||
| 2142 | q->addAction(goToParent); | - | ||||||||||||||||||
| 2143 | - | |||||||||||||||||||
| 2144 | renameAction = new QAction(q); | - | ||||||||||||||||||
| 2145 | renameAction->setEnabled(false); | - | ||||||||||||||||||
| 2146 | renameAction->setObjectName(QLatin1String("qt_rename_action")); | - | ||||||||||||||||||
| 2147 | QObject::connect(renameAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3181"), q, qFlagLocation("1""_q_renameCurrent()" "\0" __FILE__ ":" "3181")); | - | ||||||||||||||||||
| 2148 | - | |||||||||||||||||||
| 2149 | deleteAction = new QAction(q); | - | ||||||||||||||||||
| 2150 | deleteAction->setEnabled(false); | - | ||||||||||||||||||
| 2151 | deleteAction->setObjectName(QLatin1String("qt_delete_action")); | - | ||||||||||||||||||
| 2152 | QObject::connect(deleteAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3186"), q, qFlagLocation("1""_q_deleteCurrent()" "\0" __FILE__ ":" "3186")); | - | ||||||||||||||||||
| 2153 | - | |||||||||||||||||||
| 2154 | showHiddenAction = new QAction(q); | - | ||||||||||||||||||
| 2155 | showHiddenAction->setObjectName(QLatin1String("qt_show_hidden_action")); | - | ||||||||||||||||||
| 2156 | showHiddenAction->setCheckable(true); | - | ||||||||||||||||||
| 2157 | QObject::connect(showHiddenAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3191"), q, qFlagLocation("1""_q_showHidden()" "\0" __FILE__ ":" "3191")); | - | ||||||||||||||||||
| 2158 | - | |||||||||||||||||||
| 2159 | newFolderAction = new QAction(q); | - | ||||||||||||||||||
| 2160 | newFolderAction->setObjectName(QLatin1String("qt_new_folder_action")); | - | ||||||||||||||||||
| 2161 | QObject::connect(newFolderAction, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "3195"), q, qFlagLocation("1""_q_createDirectory()" "\0" __FILE__ ":" "3195")); | - | ||||||||||||||||||
| 2162 | } never executed: end of block | 0 | ||||||||||||||||||
| 2163 | - | |||||||||||||||||||
| 2164 | void QFileDialogPrivate::_q_goHome() | - | ||||||||||||||||||
| 2165 | { | - | ||||||||||||||||||
| 2166 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2167 | q->setDirectory(QDir::homePath()); | - | ||||||||||||||||||
| 2168 | } never executed: end of block | 0 | ||||||||||||||||||
| 2169 | - | |||||||||||||||||||
| 2170 | - | |||||||||||||||||||
| 2171 | - | |||||||||||||||||||
| 2172 | - | |||||||||||||||||||
| 2173 | - | |||||||||||||||||||
| 2174 | - | |||||||||||||||||||
| 2175 | void QFileDialogPrivate::_q_pathChanged(const QString &newPath) | - | ||||||||||||||||||
| 2176 | { | - | ||||||||||||||||||
| 2177 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2178 | QDir dir(model->rootDirectory()); | - | ||||||||||||||||||
| 2179 | qFileDialogUi->toParentButton->setEnabled(dir.exists()); | - | ||||||||||||||||||
| 2180 | qFileDialogUi->sidebar->selectUrl(QUrl::fromLocalFile(newPath)); | - | ||||||||||||||||||
| 2181 | q->setHistory(qFileDialogUi->lookInCombo->history()); | - | ||||||||||||||||||
| 2182 | - | |||||||||||||||||||
| 2183 | if (currentHistoryLocation < 0
| 0 | ||||||||||||||||||
| 2184 | while (currentHistoryLocation >= 0
| 0 | ||||||||||||||||||
| 2185 | currentHistory.removeLast(); | - | ||||||||||||||||||
| 2186 | } never executed: end of block | 0 | ||||||||||||||||||
| 2187 | currentHistory.append(QDir::toNativeSeparators(newPath)); | - | ||||||||||||||||||
| 2188 | ++currentHistoryLocation; | - | ||||||||||||||||||
| 2189 | } never executed: end of block | 0 | ||||||||||||||||||
| 2190 | qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1); | - | ||||||||||||||||||
| 2191 | qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0); | - | ||||||||||||||||||
| 2192 | } never executed: end of block | 0 | ||||||||||||||||||
| 2193 | - | |||||||||||||||||||
| 2194 | - | |||||||||||||||||||
| 2195 | - | |||||||||||||||||||
| 2196 | - | |||||||||||||||||||
| 2197 | - | |||||||||||||||||||
| 2198 | - | |||||||||||||||||||
| 2199 | void QFileDialogPrivate::_q_navigateBackward() | - | ||||||||||||||||||
| 2200 | { | - | ||||||||||||||||||
| 2201 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2202 | if (!currentHistory.isEmpty()
| 0 | ||||||||||||||||||
| 2203 | --currentHistoryLocation; | - | ||||||||||||||||||
| 2204 | QString previousHistory = currentHistory.at(currentHistoryLocation); | - | ||||||||||||||||||
| 2205 | q->setDirectory(previousHistory); | - | ||||||||||||||||||
| 2206 | } never executed: end of block | 0 | ||||||||||||||||||
| 2207 | } never executed: end of block | 0 | ||||||||||||||||||
| 2208 | - | |||||||||||||||||||
| 2209 | - | |||||||||||||||||||
| 2210 | - | |||||||||||||||||||
| 2211 | - | |||||||||||||||||||
| 2212 | - | |||||||||||||||||||
| 2213 | - | |||||||||||||||||||
| 2214 | void QFileDialogPrivate::_q_navigateForward() | - | ||||||||||||||||||
| 2215 | { | - | ||||||||||||||||||
| 2216 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2217 | if (!currentHistory.isEmpty()
| 0 | ||||||||||||||||||
| 2218 | ++currentHistoryLocation; | - | ||||||||||||||||||
| 2219 | QString nextHistory = currentHistory.at(currentHistoryLocation); | - | ||||||||||||||||||
| 2220 | q->setDirectory(nextHistory); | - | ||||||||||||||||||
| 2221 | } never executed: end of block | 0 | ||||||||||||||||||
| 2222 | } never executed: end of block | 0 | ||||||||||||||||||
| 2223 | - | |||||||||||||||||||
| 2224 | - | |||||||||||||||||||
| 2225 | - | |||||||||||||||||||
| 2226 | - | |||||||||||||||||||
| 2227 | - | |||||||||||||||||||
| 2228 | - | |||||||||||||||||||
| 2229 | - | |||||||||||||||||||
| 2230 | void QFileDialogPrivate::_q_navigateToParent() | - | ||||||||||||||||||
| 2231 | { | - | ||||||||||||||||||
| 2232 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2233 | QDir dir(model->rootDirectory()); | - | ||||||||||||||||||
| 2234 | QString newDirectory; | - | ||||||||||||||||||
| 2235 | if (dir.isRoot()
| 0 | ||||||||||||||||||
| 2236 | newDirectory = model->myComputer().toString(); | - | ||||||||||||||||||
| 2237 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2238 | dir.cdUp(); | - | ||||||||||||||||||
| 2239 | newDirectory = dir.absolutePath(); | - | ||||||||||||||||||
| 2240 | } never executed: end of block | 0 | ||||||||||||||||||
| 2241 | q->setDirectory(newDirectory); | - | ||||||||||||||||||
| 2242 | q->directoryEntered(newDirectory); | - | ||||||||||||||||||
| 2243 | } never executed: end of block | 0 | ||||||||||||||||||
| 2244 | - | |||||||||||||||||||
| 2245 | - | |||||||||||||||||||
| 2246 | - | |||||||||||||||||||
| 2247 | - | |||||||||||||||||||
| 2248 | - | |||||||||||||||||||
| 2249 | - | |||||||||||||||||||
| 2250 | void QFileDialogPrivate::_q_createDirectory() | - | ||||||||||||||||||
| 2251 | { | - | ||||||||||||||||||
| 2252 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2253 | qFileDialogUi->listView->clearSelection(); | - | ||||||||||||||||||
| 2254 | - | |||||||||||||||||||
| 2255 | QString newFolderString = QFileDialog::tr("New Folder"); | - | ||||||||||||||||||
| 2256 | QString folderName = newFolderString; | - | ||||||||||||||||||
| 2257 | QString prefix = q->directory().absolutePath() + QDir::separator(); | - | ||||||||||||||||||
| 2258 | if (QFile::exists(prefix + folderName)
| 0 | ||||||||||||||||||
| 2259 | qlonglong suffix = 2; | - | ||||||||||||||||||
| 2260 | while (QFile::exists(prefix + folderName)
| 0 | ||||||||||||||||||
| 2261 | folderName = newFolderString + QString::number(suffix++); | - | ||||||||||||||||||
| 2262 | } never executed: end of block | 0 | ||||||||||||||||||
| 2263 | } never executed: end of block | 0 | ||||||||||||||||||
| 2264 | - | |||||||||||||||||||
| 2265 | QModelIndex parent = rootIndex(); | - | ||||||||||||||||||
| 2266 | QModelIndex index = model->mkdir(parent, folderName); | - | ||||||||||||||||||
| 2267 | if (!index.isValid()
| 0 | ||||||||||||||||||
| 2268 | return; never executed: return; | 0 | ||||||||||||||||||
| 2269 | - | |||||||||||||||||||
| 2270 | index = select(index); | - | ||||||||||||||||||
| 2271 | if (index.isValid()
| 0 | ||||||||||||||||||
| 2272 | qFileDialogUi->treeView->setCurrentIndex(index); | - | ||||||||||||||||||
| 2273 | currentView()->edit(index); | - | ||||||||||||||||||
| 2274 | } never executed: end of block | 0 | ||||||||||||||||||
| 2275 | } never executed: end of block | 0 | ||||||||||||||||||
| 2276 | - | |||||||||||||||||||
| 2277 | void QFileDialogPrivate::_q_showListView() | - | ||||||||||||||||||
| 2278 | { | - | ||||||||||||||||||
| 2279 | qFileDialogUi->listModeButton->setDown(true); | - | ||||||||||||||||||
| 2280 | qFileDialogUi->detailModeButton->setDown(false); | - | ||||||||||||||||||
| 2281 | qFileDialogUi->treeView->hide(); | - | ||||||||||||||||||
| 2282 | qFileDialogUi->listView->show(); | - | ||||||||||||||||||
| 2283 | qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->listView->parentWidget()); | - | ||||||||||||||||||
| 2284 | qFileDialogUi->listView->doItemsLayout(); | - | ||||||||||||||||||
| 2285 | } never executed: end of block | 0 | ||||||||||||||||||
| 2286 | - | |||||||||||||||||||
| 2287 | void QFileDialogPrivate::_q_showDetailsView() | - | ||||||||||||||||||
| 2288 | { | - | ||||||||||||||||||
| 2289 | qFileDialogUi->listModeButton->setDown(false); | - | ||||||||||||||||||
| 2290 | qFileDialogUi->detailModeButton->setDown(true); | - | ||||||||||||||||||
| 2291 | qFileDialogUi->listView->hide(); | - | ||||||||||||||||||
| 2292 | qFileDialogUi->treeView->show(); | - | ||||||||||||||||||
| 2293 | qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->treeView->parentWidget()); | - | ||||||||||||||||||
| 2294 | qFileDialogUi->treeView->doItemsLayout(); | - | ||||||||||||||||||
| 2295 | } never executed: end of block | 0 | ||||||||||||||||||
| 2296 | - | |||||||||||||||||||
| 2297 | - | |||||||||||||||||||
| 2298 | - | |||||||||||||||||||
| 2299 | - | |||||||||||||||||||
| 2300 | - | |||||||||||||||||||
| 2301 | - | |||||||||||||||||||
| 2302 | void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) | - | ||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||
| 2304 | - | |||||||||||||||||||
| 2305 | - | |||||||||||||||||||
| 2306 | - | |||||||||||||||||||
| 2307 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2308 | QAbstractItemView *view = 0; | - | ||||||||||||||||||
| 2309 | if (q->viewMode() == QFileDialog::Detail
| 0 | ||||||||||||||||||
| 2310 | view = qFileDialogUi->treeView; never executed: view = qFileDialogUi->treeView; | 0 | ||||||||||||||||||
| 2311 | else | - | ||||||||||||||||||
| 2312 | view = qFileDialogUi->listView; never executed: view = qFileDialogUi->listView; | 0 | ||||||||||||||||||
| 2313 | QModelIndex index = view->indexAt(position); | - | ||||||||||||||||||
| 2314 | index = mapToSource(index.sibling(index.row(), 0)); | - | ||||||||||||||||||
| 2315 | - | |||||||||||||||||||
| 2316 | QMenu menu(view); | - | ||||||||||||||||||
| 2317 | if (index.isValid()
| 0 | ||||||||||||||||||
| 2318 | - | |||||||||||||||||||
| 2319 | const bool ro = model
| 0 | ||||||||||||||||||
| 2320 | QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); | - | ||||||||||||||||||
| 2321 | renameAction->setEnabled(!ro && p & QFile::WriteUser); | - | ||||||||||||||||||
| 2322 | menu.addAction(renameAction); | - | ||||||||||||||||||
| 2323 | deleteAction->setEnabled(!ro && p & QFile::WriteUser); | - | ||||||||||||||||||
| 2324 | menu.addAction(deleteAction); | - | ||||||||||||||||||
| 2325 | menu.addSeparator(); | - | ||||||||||||||||||
| 2326 | } never executed: end of block | 0 | ||||||||||||||||||
| 2327 | menu.addAction(showHiddenAction); | - | ||||||||||||||||||
| 2328 | if (qFileDialogUi->newFolderButton->isVisible()
| 0 | ||||||||||||||||||
| 2329 | newFolderAction->setEnabled(qFileDialogUi->newFolderButton->isEnabled()); | - | ||||||||||||||||||
| 2330 | menu.addAction(newFolderAction); | - | ||||||||||||||||||
| 2331 | } never executed: end of block | 0 | ||||||||||||||||||
| 2332 | menu.exec(view->viewport()->mapToGlobal(position)); | - | ||||||||||||||||||
| 2333 | - | |||||||||||||||||||
| 2334 | } never executed: end of block | 0 | ||||||||||||||||||
| 2335 | - | |||||||||||||||||||
| 2336 | - | |||||||||||||||||||
| 2337 | - | |||||||||||||||||||
| 2338 | - | |||||||||||||||||||
| 2339 | void QFileDialogPrivate::_q_renameCurrent() | - | ||||||||||||||||||
| 2340 | { | - | ||||||||||||||||||
| 2341 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2342 | QModelIndex index = qFileDialogUi->listView->currentIndex(); | - | ||||||||||||||||||
| 2343 | index = index.sibling(index.row(), 0); | - | ||||||||||||||||||
| 2344 | if (q->viewMode() == QFileDialog::List
| 0 | ||||||||||||||||||
| 2345 | qFileDialogUi->listView->edit(index); never executed: qFileDialogUi->listView->edit(index); | 0 | ||||||||||||||||||
| 2346 | else | - | ||||||||||||||||||
| 2347 | qFileDialogUi->treeView->edit(index); never executed: qFileDialogUi->treeView->edit(index); | 0 | ||||||||||||||||||
| 2348 | } | - | ||||||||||||||||||
| 2349 | - | |||||||||||||||||||
| 2350 | bool QFileDialogPrivate::removeDirectory(const QString &path) | - | ||||||||||||||||||
| 2351 | { | - | ||||||||||||||||||
| 2352 | QModelIndex modelIndex = model->index(path); | - | ||||||||||||||||||
| 2353 | return never executed: model->remove(modelIndex);return model->remove(modelIndex);never executed: return model->remove(modelIndex); | 0 | ||||||||||||||||||
| 2354 | } | - | ||||||||||||||||||
| 2355 | - | |||||||||||||||||||
| 2356 | - | |||||||||||||||||||
| 2357 | - | |||||||||||||||||||
| 2358 | - | |||||||||||||||||||
| 2359 | - | |||||||||||||||||||
| 2360 | - | |||||||||||||||||||
| 2361 | void QFileDialogPrivate::_q_deleteCurrent() | - | ||||||||||||||||||
| 2362 | { | - | ||||||||||||||||||
| 2363 | if (model->isReadOnly()
| 0 | ||||||||||||||||||
| 2364 | return; never executed: return; | 0 | ||||||||||||||||||
| 2365 | - | |||||||||||||||||||
| 2366 | QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows(); | - | ||||||||||||||||||
| 2367 | for (int i = list.count() - 1; i >= 0
| 0 | ||||||||||||||||||
| 2368 | QModelIndex index = list.at(i); | - | ||||||||||||||||||
| 2369 | if (index == qFileDialogUi->listView->rootIndex()
| 0 | ||||||||||||||||||
| 2370 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2371 | - | |||||||||||||||||||
| 2372 | index = mapToSource(index.sibling(index.row(), 0)); | - | ||||||||||||||||||
| 2373 | if (!index.isValid()
| 0 | ||||||||||||||||||
| 2374 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2375 | - | |||||||||||||||||||
| 2376 | QString fileName = index.data(QFileSystemModel::FileNameRole).toString(); | - | ||||||||||||||||||
| 2377 | QString filePath = index.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 2378 | bool isDir = model->isDir(index); | - | ||||||||||||||||||
| 2379 | - | |||||||||||||||||||
| 2380 | QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); | - | ||||||||||||||||||
| 2381 | - | |||||||||||||||||||
| 2382 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2383 | if (!(p & QFile::WriteUser)
| 0 | ||||||||||||||||||
| 2384 | QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?")
| 0 | ||||||||||||||||||
| 2385 | .arg(fileName),
| 0 | ||||||||||||||||||
| 2386 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
| 0 | ||||||||||||||||||
| 2387 | return; never executed: return; | 0 | ||||||||||||||||||
| 2388 | else if (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"),
| 0 | ||||||||||||||||||
| 2389 | QFileDialog::tr("Are you sure you want to delete '%1'?")
| 0 | ||||||||||||||||||
| 2390 | .arg(fileName),
| 0 | ||||||||||||||||||
| 2391 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No
| 0 | ||||||||||||||||||
| 2392 | return; never executed: return; | 0 | ||||||||||||||||||
| 2393 | - | |||||||||||||||||||
| 2394 | - | |||||||||||||||||||
| 2395 | - | |||||||||||||||||||
| 2396 | - | |||||||||||||||||||
| 2397 | - | |||||||||||||||||||
| 2398 | - | |||||||||||||||||||
| 2399 | - | |||||||||||||||||||
| 2400 | if (isDir
| 0 | ||||||||||||||||||
| 2401 | if (!removeDirectory(filePath)
| 0 | ||||||||||||||||||
| 2402 | - | |||||||||||||||||||
| 2403 | QMessageBox::warning(q, q->windowTitle(), | - | ||||||||||||||||||
| 2404 | QFileDialog::tr("Could not delete directory.")); | - | ||||||||||||||||||
| 2405 | - | |||||||||||||||||||
| 2406 | } never executed: end of block | 0 | ||||||||||||||||||
| 2407 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2408 | model->remove(index); | - | ||||||||||||||||||
| 2409 | } never executed: end of block | 0 | ||||||||||||||||||
| 2410 | } | - | ||||||||||||||||||
| 2411 | } never executed: end of block | 0 | ||||||||||||||||||
| 2412 | - | |||||||||||||||||||
| 2413 | void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) | - | ||||||||||||||||||
| 2414 | { | - | ||||||||||||||||||
| 2415 | if (text.startsWith(QLatin1String("//"))
| 0 | ||||||||||||||||||
| 2416 | qFileDialogUi->listView->selectionModel()->clearSelection(); | - | ||||||||||||||||||
| 2417 | return; never executed: return; | 0 | ||||||||||||||||||
| 2418 | } | - | ||||||||||||||||||
| 2419 | - | |||||||||||||||||||
| 2420 | QStringList multipleFiles = typedFiles(); | - | ||||||||||||||||||
| 2421 | if (multipleFiles.count() > 0
| 0 | ||||||||||||||||||
| 2422 | QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows(); | - | ||||||||||||||||||
| 2423 | QModelIndexList newFiles; | - | ||||||||||||||||||
| 2424 | for (int i = 0; i < multipleFiles.count()
| 0 | ||||||||||||||||||
| 2425 | QModelIndex idx = model->index(multipleFiles.at(i)); | - | ||||||||||||||||||
| 2426 | if (oldFiles.contains(idx)
| 0 | ||||||||||||||||||
| 2427 | oldFiles.removeAll(idx); never executed: oldFiles.removeAll(idx); | 0 | ||||||||||||||||||
| 2428 | else | - | ||||||||||||||||||
| 2429 | newFiles.append(idx); never executed: newFiles.append(idx); | 0 | ||||||||||||||||||
| 2430 | } | - | ||||||||||||||||||
| 2431 | for (int i = 0; i < newFiles.count()
| 0 | ||||||||||||||||||
| 2432 | select(newFiles.at(i)); never executed: select(newFiles.at(i)); | 0 | ||||||||||||||||||
| 2433 | if (lineEdit()->hasFocus()
| 0 | ||||||||||||||||||
| 2434 | for (int i = 0; i < oldFiles.count()
| 0 | ||||||||||||||||||
| 2435 | qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), never executed: qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), QItemSelectionModel::Toggle | QItemSelectionModel::Rows); | 0 | ||||||||||||||||||
| 2436 | QItemSelectionModel::Toggle | QItemSelectionModel::Rows); never executed: qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i), QItemSelectionModel::Toggle | QItemSelectionModel::Rows); | 0 | ||||||||||||||||||
| 2437 | } never executed: end of block | 0 | ||||||||||||||||||
| 2438 | } never executed: end of block | 0 | ||||||||||||||||||
| 2439 | - | |||||||||||||||||||
| 2440 | - | |||||||||||||||||||
| 2441 | - | |||||||||||||||||||
| 2442 | - | |||||||||||||||||||
| 2443 | void QFileDialogPrivate::_q_updateOkButton() | - | ||||||||||||||||||
| 2444 | { | - | ||||||||||||||||||
| 2445 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2446 | QPushButton *button = qFileDialogUi->buttonBox->button((q->acceptMode() == QFileDialog::AcceptOpen) | - | ||||||||||||||||||
| 2447 | ? QDialogButtonBox::Open : QDialogButtonBox::Save); | - | ||||||||||||||||||
| 2448 | if (!button
| 0 | ||||||||||||||||||
| 2449 | return; never executed: return; | 0 | ||||||||||||||||||
| 2450 | const QFileDialog::FileMode fileMode = q->fileMode(); | - | ||||||||||||||||||
| 2451 | - | |||||||||||||||||||
| 2452 | bool enableButton = true; | - | ||||||||||||||||||
| 2453 | bool isOpenDirectory = false; | - | ||||||||||||||||||
| 2454 | - | |||||||||||||||||||
| 2455 | QStringList files = q->selectedFiles(); | - | ||||||||||||||||||
| 2456 | QString lineEditText = lineEdit()->text(); | - | ||||||||||||||||||
| 2457 | - | |||||||||||||||||||
| 2458 | if (lineEditText.startsWith(QLatin1String("//"))
| 0 | ||||||||||||||||||
| 2459 | button->setEnabled(true); | - | ||||||||||||||||||
| 2460 | updateOkButtonText(); | - | ||||||||||||||||||
| 2461 | return; never executed: return; | 0 | ||||||||||||||||||
| 2462 | } | - | ||||||||||||||||||
| 2463 | - | |||||||||||||||||||
| 2464 | if (files.isEmpty()
| 0 | ||||||||||||||||||
| 2465 | enableButton = false; | - | ||||||||||||||||||
| 2466 | } never executed: else if (lineEditText == QLatin1String("..")end of block
| 0 | ||||||||||||||||||
| 2467 | isOpenDirectory = true; | - | ||||||||||||||||||
| 2468 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2469 | switch (fileMode) { | - | ||||||||||||||||||
| 2470 | case never executed: QFileDialog::DirectoryOnly:case QFileDialog::DirectoryOnly:never executed: case QFileDialog::DirectoryOnly: | 0 | ||||||||||||||||||
| 2471 | case never executed: QFileDialog::Directory:case QFileDialog::Directory:never executed: {case QFileDialog::Directory: | 0 | ||||||||||||||||||
| 2472 | QString fn = files.first(); | - | ||||||||||||||||||
| 2473 | QModelIndex idx = model->index(fn); | - | ||||||||||||||||||
| 2474 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2475 | idx = model->index(getEnvironmentVariable(fn)); never executed: idx = model->index(getEnvironmentVariable(fn)); | 0 | ||||||||||||||||||
| 2476 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2477 | enableButton = false; never executed: enableButton = false; | 0 | ||||||||||||||||||
| 2478 | break; never executed: break; | 0 | ||||||||||||||||||
| 2479 | } | - | ||||||||||||||||||
| 2480 | case never executed: QFileDialog::AnyFile:case QFileDialog::AnyFile:never executed: {case QFileDialog::AnyFile: | 0 | ||||||||||||||||||
| 2481 | QString fn = files.first(); | - | ||||||||||||||||||
| 2482 | QFileInfo info(fn); | - | ||||||||||||||||||
| 2483 | QModelIndex idx = model->index(fn); | - | ||||||||||||||||||
| 2484 | QString fileDir; | - | ||||||||||||||||||
| 2485 | QString fileName; | - | ||||||||||||||||||
| 2486 | if (info.isDir()
| 0 | ||||||||||||||||||
| 2487 | fileDir = info.canonicalFilePath(); | - | ||||||||||||||||||
| 2488 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2489 | fileDir = fn.mid(0, fn.lastIndexOf(QLatin1Char('/'))); | - | ||||||||||||||||||
| 2490 | fileName = fn.mid(fileDir.length() + 1); | - | ||||||||||||||||||
| 2491 | } never executed: end of block | 0 | ||||||||||||||||||
| 2492 | if (lineEditText.contains(QLatin1String(".."))
| 0 | ||||||||||||||||||
| 2493 | fileDir = info.canonicalFilePath(); | - | ||||||||||||||||||
| 2494 | fileName = info.fileName(); | - | ||||||||||||||||||
| 2495 | } never executed: end of block | 0 | ||||||||||||||||||
| 2496 | - | |||||||||||||||||||
| 2497 | if (fileDir == q->directory().canonicalPath()
| 0 | ||||||||||||||||||
| 2498 | enableButton = false; | - | ||||||||||||||||||
| 2499 | break; never executed: break; | 0 | ||||||||||||||||||
| 2500 | } | - | ||||||||||||||||||
| 2501 | if (idx.isValid()
| 0 | ||||||||||||||||||
| 2502 | isOpenDirectory = true; | - | ||||||||||||||||||
| 2503 | enableButton = true; | - | ||||||||||||||||||
| 2504 | break; never executed: break; | 0 | ||||||||||||||||||
| 2505 | } | - | ||||||||||||||||||
| 2506 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2507 | int maxLength = maxNameLength(fileDir); | - | ||||||||||||||||||
| 2508 | enableButton = maxLength < 0
| 0 | ||||||||||||||||||
| 2509 | } never executed: end of block | 0 | ||||||||||||||||||
| 2510 | break; never executed: break; | 0 | ||||||||||||||||||
| 2511 | } | - | ||||||||||||||||||
| 2512 | case never executed: QFileDialog::ExistingFile:case QFileDialog::ExistingFile:never executed: case QFileDialog::ExistingFile: | 0 | ||||||||||||||||||
| 2513 | case never executed: QFileDialog::ExistingFiles:case QFileDialog::ExistingFiles:never executed: case QFileDialog::ExistingFiles: | 0 | ||||||||||||||||||
| 2514 | for (int i = 0; i < files.count()
| 0 | ||||||||||||||||||
| 2515 | QModelIndex idx = model->index(files.at(i)); | - | ||||||||||||||||||
| 2516 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2517 | idx = model->index(getEnvironmentVariable(files.at(i))); never executed: idx = model->index(getEnvironmentVariable(files.at(i))); | 0 | ||||||||||||||||||
| 2518 | if (!idx.isValid()
| 0 | ||||||||||||||||||
| 2519 | enableButton = false; | - | ||||||||||||||||||
| 2520 | break; never executed: break; | 0 | ||||||||||||||||||
| 2521 | } | - | ||||||||||||||||||
| 2522 | if (idx.isValid()
| 0 | ||||||||||||||||||
| 2523 | isOpenDirectory = true; | - | ||||||||||||||||||
| 2524 | break; never executed: break; | 0 | ||||||||||||||||||
| 2525 | } | - | ||||||||||||||||||
| 2526 | } never executed: end of block | 0 | ||||||||||||||||||
| 2527 | break; never executed: break; | 0 | ||||||||||||||||||
| 2528 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 2529 | break; never executed: break; | 0 | ||||||||||||||||||
| 2530 | } | - | ||||||||||||||||||
| 2531 | } | - | ||||||||||||||||||
| 2532 | - | |||||||||||||||||||
| 2533 | button->setEnabled(enableButton); | - | ||||||||||||||||||
| 2534 | updateOkButtonText(isOpenDirectory); | - | ||||||||||||||||||
| 2535 | } never executed: end of block | 0 | ||||||||||||||||||
| 2536 | - | |||||||||||||||||||
| 2537 | - | |||||||||||||||||||
| 2538 | - | |||||||||||||||||||
| 2539 | - | |||||||||||||||||||
| 2540 | void QFileDialogPrivate::_q_currentChanged(const QModelIndex &index) | - | ||||||||||||||||||
| 2541 | { | - | ||||||||||||||||||
| 2542 | _q_updateOkButton(); | - | ||||||||||||||||||
| 2543 | q_func()->currentChanged(index.data(QFileSystemModel::FilePathRole).toString()); | - | ||||||||||||||||||
| 2544 | } never executed: end of block | 0 | ||||||||||||||||||
| 2545 | - | |||||||||||||||||||
| 2546 | - | |||||||||||||||||||
| 2547 | - | |||||||||||||||||||
| 2548 | - | |||||||||||||||||||
| 2549 | - | |||||||||||||||||||
| 2550 | - | |||||||||||||||||||
| 2551 | - | |||||||||||||||||||
| 2552 | void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) | - | ||||||||||||||||||
| 2553 | { | - | ||||||||||||||||||
| 2554 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2555 | - | |||||||||||||||||||
| 2556 | QModelIndex sourceIndex = index.model() == proxyModel
| 0 | ||||||||||||||||||
| 2557 | QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 2558 | if (path.isEmpty()
| 0 | ||||||||||||||||||
| 2559 | const QFileDialog::FileMode fileMode = q->fileMode(); | - | ||||||||||||||||||
| 2560 | q->setDirectory(path); | - | ||||||||||||||||||
| 2561 | q->directoryEntered(path); | - | ||||||||||||||||||
| 2562 | if (fileMode == QFileDialog::Directory
| 0 | ||||||||||||||||||
| 2563 | || fileMode == QFileDialog::DirectoryOnly
| 0 | ||||||||||||||||||
| 2564 | - | |||||||||||||||||||
| 2565 | lineEdit()->setText(QString()); | - | ||||||||||||||||||
| 2566 | lineEdit()->clear(); | - | ||||||||||||||||||
| 2567 | } never executed: end of block | 0 | ||||||||||||||||||
| 2568 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2569 | - | |||||||||||||||||||
| 2570 | if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, qFileDialogUi->treeView)
| 0 | ||||||||||||||||||
| 2571 | || q->fileMode() != QFileDialog::ExistingFiles
| 0 | ||||||||||||||||||
| 2572 | q->accept(); | - | ||||||||||||||||||
| 2573 | } never executed: end of block | 0 | ||||||||||||||||||
| 2574 | } never executed: end of block | 0 | ||||||||||||||||||
| 2575 | } | - | ||||||||||||||||||
| 2576 | - | |||||||||||||||||||
| 2577 | - | |||||||||||||||||||
| 2578 | - | |||||||||||||||||||
| 2579 | - | |||||||||||||||||||
| 2580 | - | |||||||||||||||||||
| 2581 | - | |||||||||||||||||||
| 2582 | - | |||||||||||||||||||
| 2583 | void QFileDialogPrivate::_q_goToDirectory(const QString &path) | - | ||||||||||||||||||
| 2584 | { | - | ||||||||||||||||||
| 2585 | - | |||||||||||||||||||
| 2586 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2587 | - | |||||||||||||||||||
| 2588 | QModelIndex index = qFileDialogUi->lookInCombo->model()->index(qFileDialogUi->lookInCombo->currentIndex(), | - | ||||||||||||||||||
| 2589 | qFileDialogUi->lookInCombo->modelColumn(), | - | ||||||||||||||||||
| 2590 | qFileDialogUi->lookInCombo->rootModelIndex()); | - | ||||||||||||||||||
| 2591 | QString path2 = path; | - | ||||||||||||||||||
| 2592 | if (!index.isValid()
| 0 | ||||||||||||||||||
| 2593 | index = mapFromSource(model->index(getEnvironmentVariable(path))); never executed: index = mapFromSource(model->index(getEnvironmentVariable(path))); | 0 | ||||||||||||||||||
| 2594 | else { | - | ||||||||||||||||||
| 2595 | path2 = index.data((Qt::UserRole + 1)).toUrl().toLocalFile(); | - | ||||||||||||||||||
| 2596 | index = mapFromSource(model->index(path2)); | - | ||||||||||||||||||
| 2597 | } never executed: end of block | 0 | ||||||||||||||||||
| 2598 | QDir dir(path2); | - | ||||||||||||||||||
| 2599 | if (!dir.exists()
| 0 | ||||||||||||||||||
| 2600 | dir = getEnvironmentVariable(path2); never executed: dir = getEnvironmentVariable(path2); | 0 | ||||||||||||||||||
| 2601 | - | |||||||||||||||||||
| 2602 | if (dir.exists()
| 0 | ||||||||||||||||||
| 2603 | _q_enterDirectory(index); | - | ||||||||||||||||||
| 2604 | - | |||||||||||||||||||
| 2605 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 2606 | QString message = QFileDialog::tr("%1\nDirectory not found.\nPlease verify the " | - | ||||||||||||||||||
| 2607 | "correct directory name was given."); | - | ||||||||||||||||||
| 2608 | QMessageBox::warning(q, q->windowTitle(), message.arg(path2)); | - | ||||||||||||||||||
| 2609 | - | |||||||||||||||||||
| 2610 | } never executed: end of block | 0 | ||||||||||||||||||
| 2611 | } | - | ||||||||||||||||||
| 2612 | - | |||||||||||||||||||
| 2613 | - | |||||||||||||||||||
| 2614 | - | |||||||||||||||||||
| 2615 | - | |||||||||||||||||||
| 2616 | - | |||||||||||||||||||
| 2617 | - | |||||||||||||||||||
| 2618 | - | |||||||||||||||||||
| 2619 | void QFileDialogPrivate::_q_useNameFilter(int index) | - | ||||||||||||||||||
| 2620 | { | - | ||||||||||||||||||
| 2621 | QStringList nameFilters = options->nameFilters(); | - | ||||||||||||||||||
| 2622 | if (index == nameFilters.size()
| 0 | ||||||||||||||||||
| 2623 | QAbstractItemModel *comboModel = qFileDialogUi->fileTypeCombo->model(); | - | ||||||||||||||||||
| 2624 | nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString()); | - | ||||||||||||||||||
| 2625 | options->setNameFilters(nameFilters); | - | ||||||||||||||||||
| 2626 | } never executed: end of block | 0 | ||||||||||||||||||
| 2627 | - | |||||||||||||||||||
| 2628 | QString nameFilter = nameFilters.at(index); | - | ||||||||||||||||||
| 2629 | QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter); | - | ||||||||||||||||||
| 2630 | if (q_func()->acceptMode() == QFileDialog::AcceptSave
| 0 | ||||||||||||||||||
| 2631 | QString newNameFilterExtension; | - | ||||||||||||||||||
| 2632 | if (newNameFilters.count() > 0
| 0 | ||||||||||||||||||
| 2633 | newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); never executed: newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); | 0 | ||||||||||||||||||
| 2634 | - | |||||||||||||||||||
| 2635 | QString fileName = lineEdit()->text(); | - | ||||||||||||||||||
| 2636 | const QString fileNameExtension = QFileInfo(fileName).suffix(); | - | ||||||||||||||||||
| 2637 | if (!fileNameExtension.isEmpty()
| 0 | ||||||||||||||||||
| 2638 | const int fileNameExtensionLength = fileNameExtension.count(); | - | ||||||||||||||||||
| 2639 | fileName.replace(fileName.count() - fileNameExtensionLength, | - | ||||||||||||||||||
| 2640 | fileNameExtensionLength, newNameFilterExtension); | - | ||||||||||||||||||
| 2641 | qFileDialogUi->listView->clearSelection(); | - | ||||||||||||||||||
| 2642 | lineEdit()->setText(fileName); | - | ||||||||||||||||||
| 2643 | } never executed: end of block | 0 | ||||||||||||||||||
| 2644 | } never executed: end of block | 0 | ||||||||||||||||||
| 2645 | - | |||||||||||||||||||
| 2646 | model->setNameFilters(newNameFilters); | - | ||||||||||||||||||
| 2647 | } never executed: end of block | 0 | ||||||||||||||||||
| 2648 | - | |||||||||||||||||||
| 2649 | - | |||||||||||||||||||
| 2650 | - | |||||||||||||||||||
| 2651 | - | |||||||||||||||||||
| 2652 | - | |||||||||||||||||||
| 2653 | - | |||||||||||||||||||
| 2654 | - | |||||||||||||||||||
| 2655 | void QFileDialogPrivate::_q_selectionChanged() | - | ||||||||||||||||||
| 2656 | { | - | ||||||||||||||||||
| 2657 | const QFileDialog::FileMode fileMode = q_func()->fileMode(); | - | ||||||||||||||||||
| 2658 | QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows(); | - | ||||||||||||||||||
| 2659 | bool stripDirs = (fileMode != QFileDialog::DirectoryOnly
| 0 | ||||||||||||||||||
| 2660 | - | |||||||||||||||||||
| 2661 | QStringList allFiles; | - | ||||||||||||||||||
| 2662 | for (int i = 0; i < indexes.count()
| 0 | ||||||||||||||||||
| 2663 | if (stripDirs
| 0 | ||||||||||||||||||
| 2664 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2665 | allFiles.append(indexes.at(i).data().toString()); | - | ||||||||||||||||||
| 2666 | } never executed: end of block | 0 | ||||||||||||||||||
| 2667 | if (allFiles.count() > 1
| 0 | ||||||||||||||||||
| 2668 | for (int i = 0; i < allFiles.count()
| 0 | ||||||||||||||||||
| 2669 | allFiles.replace(i, QString(QLatin1Char('"') + allFiles.at(i) + QLatin1Char('"'))); | - | ||||||||||||||||||
| 2670 | } never executed: end of block | 0 | ||||||||||||||||||
| 2671 | - | |||||||||||||||||||
| 2672 | QString finalFiles = allFiles.join(QLatin1Char(' ')); | - | ||||||||||||||||||
| 2673 | if (!finalFiles.isEmpty()
| 0 | ||||||||||||||||||
| 2674 | lineEdit()->setText(finalFiles); never executed: lineEdit()->setText(finalFiles); | 0 | ||||||||||||||||||
| 2675 | else | - | ||||||||||||||||||
| 2676 | _q_updateOkButton(); never executed: _q_updateOkButton(); | 0 | ||||||||||||||||||
| 2677 | } | - | ||||||||||||||||||
| 2678 | - | |||||||||||||||||||
| 2679 | - | |||||||||||||||||||
| 2680 | - | |||||||||||||||||||
| 2681 | - | |||||||||||||||||||
| 2682 | - | |||||||||||||||||||
| 2683 | - | |||||||||||||||||||
| 2684 | void QFileDialogPrivate::_q_showHidden() | - | ||||||||||||||||||
| 2685 | { | - | ||||||||||||||||||
| 2686 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2687 | QDir::Filters dirFilters = q->filter(); | - | ||||||||||||||||||
| 2688 | if (showHiddenAction->isChecked()
| 0 | ||||||||||||||||||
| 2689 | dirFilters |= QDir::Hidden; never executed: dirFilters |= QDir::Hidden; | 0 | ||||||||||||||||||
| 2690 | else | - | ||||||||||||||||||
| 2691 | dirFilters &= ~QDir::Hidden; never executed: dirFilters &= ~QDir::Hidden; | 0 | ||||||||||||||||||
| 2692 | q->setFilter(dirFilters); | - | ||||||||||||||||||
| 2693 | } never executed: end of block | 0 | ||||||||||||||||||
| 2694 | - | |||||||||||||||||||
| 2695 | - | |||||||||||||||||||
| 2696 | - | |||||||||||||||||||
| 2697 | - | |||||||||||||||||||
| 2698 | - | |||||||||||||||||||
| 2699 | - | |||||||||||||||||||
| 2700 | - | |||||||||||||||||||
| 2701 | void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent) | - | ||||||||||||||||||
| 2702 | { | - | ||||||||||||||||||
| 2703 | if (!qFileDialogUi->treeView
| 0 | ||||||||||||||||||
| 2704 | || parent != qFileDialogUi->treeView->rootIndex()
| 0 | ||||||||||||||||||
| 2705 | || !qFileDialogUi->treeView->selectionModel()
| 0 | ||||||||||||||||||
| 2706 | || qFileDialogUi->treeView->selectionModel()->hasSelection()
| 0 | ||||||||||||||||||
| 2707 | || qFileDialogUi->treeView->model()->rowCount(parent) == 0
| 0 | ||||||||||||||||||
| 2708 | return; never executed: return; | 0 | ||||||||||||||||||
| 2709 | } never executed: end of block | 0 | ||||||||||||||||||
| 2710 | - | |||||||||||||||||||
| 2711 | void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString &oldName, const QString &newName) | - | ||||||||||||||||||
| 2712 | { | - | ||||||||||||||||||
| 2713 | const QFileDialog::FileMode fileMode = q_func()->fileMode(); | - | ||||||||||||||||||
| 2714 | if (fileMode == QFileDialog::Directory
| 0 | ||||||||||||||||||
| 2715 | if (path == rootPath()
| 0 | ||||||||||||||||||
| 2716 | lineEdit()->setText(newName); never executed: lineEdit()->setText(newName); | 0 | ||||||||||||||||||
| 2717 | } never executed: end of block | 0 | ||||||||||||||||||
| 2718 | } never executed: end of block | 0 | ||||||||||||||||||
| 2719 | - | |||||||||||||||||||
| 2720 | void QFileDialogPrivate::_q_emitUrlSelected(const QUrl &file) | - | ||||||||||||||||||
| 2721 | { | - | ||||||||||||||||||
| 2722 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2723 | q->urlSelected(file); | - | ||||||||||||||||||
| 2724 | if (file.isLocalFile()
| 0 | ||||||||||||||||||
| 2725 | q->fileSelected(file.toLocalFile()); never executed: q->fileSelected(file.toLocalFile()); | 0 | ||||||||||||||||||
| 2726 | } never executed: end of block | 0 | ||||||||||||||||||
| 2727 | - | |||||||||||||||||||
| 2728 | void QFileDialogPrivate::_q_emitUrlsSelected(const QList<QUrl> &files) | - | ||||||||||||||||||
| 2729 | { | - | ||||||||||||||||||
| 2730 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2731 | q->urlsSelected(files); | - | ||||||||||||||||||
| 2732 | QStringList localFiles; | - | ||||||||||||||||||
| 2733 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(files)>::type> _container_((files)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QUrl &file = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||
| 2734 | if (file.isLocalFile()
| 0 | ||||||||||||||||||
| 2735 | localFiles.append(file.toLocalFile()); never executed: localFiles.append(file.toLocalFile()); | 0 | ||||||||||||||||||
| 2736 | if (!localFiles.isEmpty()
| 0 | ||||||||||||||||||
| 2737 | q->filesSelected(localFiles); never executed: q->filesSelected(localFiles); | 0 | ||||||||||||||||||
| 2738 | } never executed: end of block | 0 | ||||||||||||||||||
| 2739 | - | |||||||||||||||||||
| 2740 | void QFileDialogPrivate::_q_nativeCurrentChanged(const QUrl &file) | - | ||||||||||||||||||
| 2741 | { | - | ||||||||||||||||||
| 2742 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2743 | q->currentUrlChanged(file); | - | ||||||||||||||||||
| 2744 | if (file.isLocalFile()
| 0 | ||||||||||||||||||
| 2745 | q->currentChanged(file.toLocalFile()); never executed: q->currentChanged(file.toLocalFile()); | 0 | ||||||||||||||||||
| 2746 | } never executed: end of block | 0 | ||||||||||||||||||
| 2747 | - | |||||||||||||||||||
| 2748 | void QFileDialogPrivate::_q_nativeEnterDirectory(const QUrl &directory) | - | ||||||||||||||||||
| 2749 | { | - | ||||||||||||||||||
| 2750 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2751 | q->directoryUrlEntered(directory); | - | ||||||||||||||||||
| 2752 | if (!directory.isEmpty()
| 0 | ||||||||||||||||||
| 2753 | *lastVisitedDir() = directory; | - | ||||||||||||||||||
| 2754 | if (directory.isLocalFile()
| 0 | ||||||||||||||||||
| 2755 | q->directoryEntered(directory.toLocalFile()); never executed: q->directoryEntered(directory.toLocalFile()); | 0 | ||||||||||||||||||
| 2756 | } never executed: end of block | 0 | ||||||||||||||||||
| 2757 | } never executed: end of block | 0 | ||||||||||||||||||
| 2758 | bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { | - | ||||||||||||||||||
| 2759 | - | |||||||||||||||||||
| 2760 | QFileDialog * const q = q_func(); | - | ||||||||||||||||||
| 2761 | - | |||||||||||||||||||
| 2762 | if (event->matches(QKeySequence::Cancel)
| 0 | ||||||||||||||||||
| 2763 | q->reject(); | - | ||||||||||||||||||
| 2764 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 2765 | } | - | ||||||||||||||||||
| 2766 | - | |||||||||||||||||||
| 2767 | switch (event->key()) { | - | ||||||||||||||||||
| 2768 | case never executed: Qt::Key_Backspace:case Qt::Key_Backspace:never executed: case Qt::Key_Backspace: | 0 | ||||||||||||||||||
| 2769 | _q_navigateToParent(); | - | ||||||||||||||||||
| 2770 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 2771 | case never executed: Qt::Key_Back:case Qt::Key_Back:never executed: case Qt::Key_Back: | 0 | ||||||||||||||||||
| 2772 | - | |||||||||||||||||||
| 2773 | - | |||||||||||||||||||
| 2774 | - | |||||||||||||||||||
| 2775 | - | |||||||||||||||||||
| 2776 | case never executed: Qt::Key_Left:case Qt::Key_Left:never executed: case Qt::Key_Left: | 0 | ||||||||||||||||||
| 2777 | if (event->key() == Qt::Key_Back
| 0 | ||||||||||||||||||
| 2778 | _q_navigateBackward(); | - | ||||||||||||||||||
| 2779 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 2780 | } | - | ||||||||||||||||||
| 2781 | break; never executed: break; | 0 | ||||||||||||||||||
| 2782 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 2783 | break; never executed: break; | 0 | ||||||||||||||||||
| 2784 | } | - | ||||||||||||||||||
| 2785 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 2786 | } | - | ||||||||||||||||||
| 2787 | - | |||||||||||||||||||
| 2788 | QString QFileDialogPrivate::getEnvironmentVariable(const QString &string) | - | ||||||||||||||||||
| 2789 | { | - | ||||||||||||||||||
| 2790 | - | |||||||||||||||||||
| 2791 | if (string.size() > 1
| 0 | ||||||||||||||||||
| 2792 | return never executed: QString::fromLocal8Bit(qgetenv(string.mid(1).toLatin1().constData()));return QString::fromLocal8Bit(qgetenv(string.mid(1).toLatin1().constData()));never executed: return QString::fromLocal8Bit(qgetenv(string.mid(1).toLatin1().constData())); | 0 | ||||||||||||||||||
| 2793 | } | - | ||||||||||||||||||
| 2794 | - | |||||||||||||||||||
| 2795 | - | |||||||||||||||||||
| 2796 | - | |||||||||||||||||||
| 2797 | - | |||||||||||||||||||
| 2798 | - | |||||||||||||||||||
| 2799 | return never executed: string;return string;never executed: return string; | 0 | ||||||||||||||||||
| 2800 | } | - | ||||||||||||||||||
| 2801 | - | |||||||||||||||||||
| 2802 | void QFileDialogComboBox::setFileDialogPrivate(QFileDialogPrivate *d_pointer) { | - | ||||||||||||||||||
| 2803 | d_ptr = d_pointer; | - | ||||||||||||||||||
| 2804 | urlModel = new QUrlModel(this); | - | ||||||||||||||||||
| 2805 | urlModel->showFullPath = true; | - | ||||||||||||||||||
| 2806 | urlModel->setFileSystemModel(d_ptr->model); | - | ||||||||||||||||||
| 2807 | setModel(urlModel); | - | ||||||||||||||||||
| 2808 | } never executed: end of block | 0 | ||||||||||||||||||
| 2809 | - | |||||||||||||||||||
| 2810 | void QFileDialogComboBox::showPopup() | - | ||||||||||||||||||
| 2811 | { | - | ||||||||||||||||||
| 2812 | if (model()->rowCount() > 1
| 0 | ||||||||||||||||||
| 2813 | QComboBox::showPopup(); never executed: QComboBox::showPopup(); | 0 | ||||||||||||||||||
| 2814 | - | |||||||||||||||||||
| 2815 | urlModel->setUrls(QList<QUrl>()); | - | ||||||||||||||||||
| 2816 | QList<QUrl> list; | - | ||||||||||||||||||
| 2817 | QModelIndex idx = d_ptr->model->index(d_ptr->rootPath()); | - | ||||||||||||||||||
| 2818 | while (idx.isValid()
| 0 | ||||||||||||||||||
| 2819 | QUrl url = QUrl::fromLocalFile(idx.data(QFileSystemModel::FilePathRole).toString()); | - | ||||||||||||||||||
| 2820 | if (url.isValid()
| 0 | ||||||||||||||||||
| 2821 | list.append(url); never executed: list.append(url); | 0 | ||||||||||||||||||
| 2822 | idx = idx.parent(); | - | ||||||||||||||||||
| 2823 | } never executed: end of block | 0 | ||||||||||||||||||
| 2824 | - | |||||||||||||||||||
| 2825 | list.append(QUrl(QLatin1String("file:"))); | - | ||||||||||||||||||
| 2826 | urlModel->addUrls(list, 0); | - | ||||||||||||||||||
| 2827 | idx = model()->index(model()->rowCount() - 1, 0); | - | ||||||||||||||||||
| 2828 | - | |||||||||||||||||||
| 2829 | - | |||||||||||||||||||
| 2830 | QList<QUrl> urls; | - | ||||||||||||||||||
| 2831 | for (int i = 0; i < m_history.count()
| 0 | ||||||||||||||||||
| 2832 | QUrl path = QUrl::fromLocalFile(m_history.at(i)); | - | ||||||||||||||||||
| 2833 | if (!urls.contains(path)
| 0 | ||||||||||||||||||
| 2834 | urls.prepend(path); never executed: urls.prepend(path); | 0 | ||||||||||||||||||
| 2835 | } never executed: end of block | 0 | ||||||||||||||||||
| 2836 | if (urls.count() > 0
| 0 | ||||||||||||||||||
| 2837 | model()->insertRow(model()->rowCount()); | - | ||||||||||||||||||
| 2838 | idx = model()->index(model()->rowCount()-1, 0); | - | ||||||||||||||||||
| 2839 | - | |||||||||||||||||||
| 2840 | model()->setData(idx, QFileDialog::tr("Recent Places")); | - | ||||||||||||||||||
| 2841 | QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model()); | - | ||||||||||||||||||
| 2842 | if (m
| 0 | ||||||||||||||||||
| 2843 | Qt::ItemFlags flags = m->flags(idx); | - | ||||||||||||||||||
| 2844 | flags &= ~Qt::ItemIsEnabled; | - | ||||||||||||||||||
| 2845 | m->item(idx.row(), idx.column())->setFlags(flags); | - | ||||||||||||||||||
| 2846 | } never executed: end of block | 0 | ||||||||||||||||||
| 2847 | urlModel->addUrls(urls, -1, false); | - | ||||||||||||||||||
| 2848 | } never executed: end of block | 0 | ||||||||||||||||||
| 2849 | setCurrentIndex(0); | - | ||||||||||||||||||
| 2850 | - | |||||||||||||||||||
| 2851 | QComboBox::showPopup(); | - | ||||||||||||||||||
| 2852 | } never executed: end of block | 0 | ||||||||||||||||||
| 2853 | - | |||||||||||||||||||
| 2854 | - | |||||||||||||||||||
| 2855 | void QFileDialogComboBox::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
| 2856 | { | - | ||||||||||||||||||
| 2857 | QStylePainter painter(this); | - | ||||||||||||||||||
| 2858 | painter.setPen(palette().color(QPalette::Text)); | - | ||||||||||||||||||
| 2859 | - | |||||||||||||||||||
| 2860 | - | |||||||||||||||||||
| 2861 | QStyleOptionComboBox opt; | - | ||||||||||||||||||
| 2862 | initStyleOption(&opt); | - | ||||||||||||||||||
| 2863 | - | |||||||||||||||||||
| 2864 | QRect editRect = style()->subControlRect(QStyle::CC_ComboBox, &opt, | - | ||||||||||||||||||
| 2865 | QStyle::SC_ComboBoxEditField, this); | - | ||||||||||||||||||
| 2866 | int size = editRect.width() - opt.iconSize.width() - 4; | - | ||||||||||||||||||
| 2867 | opt.currentText = opt.fontMetrics.elidedText(opt.currentText, Qt::ElideMiddle, size); | - | ||||||||||||||||||
| 2868 | painter.drawComplexControl(QStyle::CC_ComboBox, opt); | - | ||||||||||||||||||
| 2869 | - | |||||||||||||||||||
| 2870 | - | |||||||||||||||||||
| 2871 | painter.drawControl(QStyle::CE_ComboBoxLabel, opt); | - | ||||||||||||||||||
| 2872 | } never executed: end of block | 0 | ||||||||||||||||||
| 2873 | - | |||||||||||||||||||
| 2874 | QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent) | - | ||||||||||||||||||
| 2875 | { | - | ||||||||||||||||||
| 2876 | } never executed: end of block | 0 | ||||||||||||||||||
| 2877 | - | |||||||||||||||||||
| 2878 | void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) | - | ||||||||||||||||||
| 2879 | { | - | ||||||||||||||||||
| 2880 | d_ptr = d_pointer; | - | ||||||||||||||||||
| 2881 | setSelectionBehavior(QAbstractItemView::SelectRows); | - | ||||||||||||||||||
| 2882 | setWrapping(true); | - | ||||||||||||||||||
| 2883 | setResizeMode(QListView::Adjust); | - | ||||||||||||||||||
| 2884 | setEditTriggers(QAbstractItemView::EditKeyPressed); | - | ||||||||||||||||||
| 2885 | setContextMenuPolicy(Qt::CustomContextMenu); | - | ||||||||||||||||||
| 2886 | - | |||||||||||||||||||
| 2887 | setDragDropMode(QAbstractItemView::InternalMove); | - | ||||||||||||||||||
| 2888 | - | |||||||||||||||||||
| 2889 | } never executed: end of block | 0 | ||||||||||||||||||
| 2890 | - | |||||||||||||||||||
| 2891 | QSize QFileDialogListView::sizeHint() const | - | ||||||||||||||||||
| 2892 | { | - | ||||||||||||||||||
| 2893 | int height = qMax(10, sizeHintForRow(0)); | - | ||||||||||||||||||
| 2894 | return never executed: QSize(QListView::sizeHint().width() * 2, height * 30);return QSize(QListView::sizeHint().width() * 2, height * 30);never executed: return QSize(QListView::sizeHint().width() * 2, height * 30); | 0 | ||||||||||||||||||
| 2895 | } | - | ||||||||||||||||||
| 2896 | - | |||||||||||||||||||
| 2897 | void QFileDialogListView::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 2898 | { | - | ||||||||||||||||||
| 2899 | - | |||||||||||||||||||
| 2900 | - | |||||||||||||||||||
| 2901 | - | |||||||||||||||||||
| 2902 | - | |||||||||||||||||||
| 2903 | - | |||||||||||||||||||
| 2904 | - | |||||||||||||||||||
| 2905 | - | |||||||||||||||||||
| 2906 | if (!d_ptr->itemViewKeyboardEvent(e)
| 0 | ||||||||||||||||||
| 2907 | QListView::keyPressEvent(e); never executed: QListView::keyPressEvent(e); | 0 | ||||||||||||||||||
| 2908 | e->accept(); | - | ||||||||||||||||||
| 2909 | } never executed: end of block | 0 | ||||||||||||||||||
| 2910 | - | |||||||||||||||||||
| 2911 | QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) | - | ||||||||||||||||||
| 2912 | { | - | ||||||||||||||||||
| 2913 | } never executed: end of block | 0 | ||||||||||||||||||
| 2914 | - | |||||||||||||||||||
| 2915 | void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) | - | ||||||||||||||||||
| 2916 | { | - | ||||||||||||||||||
| 2917 | d_ptr = d_pointer; | - | ||||||||||||||||||
| 2918 | setSelectionBehavior(QAbstractItemView::SelectRows); | - | ||||||||||||||||||
| 2919 | setRootIsDecorated(false); | - | ||||||||||||||||||
| 2920 | setItemsExpandable(false); | - | ||||||||||||||||||
| 2921 | setSortingEnabled(true); | - | ||||||||||||||||||
| 2922 | header()->setSortIndicator(0, Qt::AscendingOrder); | - | ||||||||||||||||||
| 2923 | header()->setStretchLastSection(false); | - | ||||||||||||||||||
| 2924 | setTextElideMode(Qt::ElideMiddle); | - | ||||||||||||||||||
| 2925 | setEditTriggers(QAbstractItemView::EditKeyPressed); | - | ||||||||||||||||||
| 2926 | setContextMenuPolicy(Qt::CustomContextMenu); | - | ||||||||||||||||||
| 2927 | - | |||||||||||||||||||
| 2928 | setDragDropMode(QAbstractItemView::InternalMove); | - | ||||||||||||||||||
| 2929 | - | |||||||||||||||||||
| 2930 | } never executed: end of block | 0 | ||||||||||||||||||
| 2931 | - | |||||||||||||||||||
| 2932 | void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 2933 | { | - | ||||||||||||||||||
| 2934 | - | |||||||||||||||||||
| 2935 | - | |||||||||||||||||||
| 2936 | - | |||||||||||||||||||
| 2937 | - | |||||||||||||||||||
| 2938 | - | |||||||||||||||||||
| 2939 | - | |||||||||||||||||||
| 2940 | - | |||||||||||||||||||
| 2941 | if (!d_ptr->itemViewKeyboardEvent(e)
| 0 | ||||||||||||||||||
| 2942 | QTreeView::keyPressEvent(e); never executed: QTreeView::keyPressEvent(e); | 0 | ||||||||||||||||||
| 2943 | e->accept(); | - | ||||||||||||||||||
| 2944 | } never executed: end of block | 0 | ||||||||||||||||||
| 2945 | - | |||||||||||||||||||
| 2946 | QSize QFileDialogTreeView::sizeHint() const | - | ||||||||||||||||||
| 2947 | { | - | ||||||||||||||||||
| 2948 | int height = qMax(10, sizeHintForRow(0)); | - | ||||||||||||||||||
| 2949 | QSize sizeHint = header()->sizeHint(); | - | ||||||||||||||||||
| 2950 | return never executed: QSize(sizeHint.width() * 4, height * 30);return QSize(sizeHint.width() * 4, height * 30);never executed: return QSize(sizeHint.width() * 4, height * 30); | 0 | ||||||||||||||||||
| 2951 | } | - | ||||||||||||||||||
| 2952 | - | |||||||||||||||||||
| 2953 | - | |||||||||||||||||||
| 2954 | - | |||||||||||||||||||
| 2955 | - | |||||||||||||||||||
| 2956 | - | |||||||||||||||||||
| 2957 | void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
| 2958 | { | - | ||||||||||||||||||
| 2959 | - | |||||||||||||||||||
| 2960 | - | |||||||||||||||||||
| 2961 | - | |||||||||||||||||||
| 2962 | - | |||||||||||||||||||
| 2963 | - | |||||||||||||||||||
| 2964 | - | |||||||||||||||||||
| 2965 | - | |||||||||||||||||||
| 2966 | int key = e->key(); | - | ||||||||||||||||||
| 2967 | QLineEdit::keyPressEvent(e); | - | ||||||||||||||||||
| 2968 | if (!e->matches(QKeySequence::Cancel)
| 0 | ||||||||||||||||||
| 2969 | e->accept(); never executed: e->accept(); | 0 | ||||||||||||||||||
| 2970 | } never executed: end of block | 0 | ||||||||||||||||||
| 2971 | - | |||||||||||||||||||
| 2972 | - | |||||||||||||||||||
| 2973 | - | |||||||||||||||||||
| 2974 | QString QFSCompleter::pathFromIndex(const QModelIndex &index) const | - | ||||||||||||||||||
| 2975 | { | - | ||||||||||||||||||
| 2976 | const QFileSystemModel *dirModel; | - | ||||||||||||||||||
| 2977 | if (proxyModel
| 0 | ||||||||||||||||||
| 2978 | dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); never executed: dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); | 0 | ||||||||||||||||||
| 2979 | else | - | ||||||||||||||||||
| 2980 | dirModel = sourceModel; never executed: dirModel = sourceModel; | 0 | ||||||||||||||||||
| 2981 | QString currentLocation = dirModel->rootPath(); | - | ||||||||||||||||||
| 2982 | QString path = index.data(QFileSystemModel::FilePathRole).toString(); | - | ||||||||||||||||||
| 2983 | if (!currentLocation.isEmpty()
| 0 | ||||||||||||||||||
| 2984 | - | |||||||||||||||||||
| 2985 | if (currentLocation == QDir::separator()
| 0 | ||||||||||||||||||
| 2986 | return never executed: path.mid(currentLocation.length());return path.mid(currentLocation.length());never executed: return path.mid(currentLocation.length()); | 0 | ||||||||||||||||||
| 2987 | - | |||||||||||||||||||
| 2988 | if (currentLocation.endsWith(QLatin1Char('/'))
| 0 | ||||||||||||||||||
| 2989 | return never executed: path.mid(currentLocation.length());return path.mid(currentLocation.length());never executed: return path.mid(currentLocation.length()); | 0 | ||||||||||||||||||
| 2990 | else | - | ||||||||||||||||||
| 2991 | return never executed: path.mid(currentLocation.length()+1);return path.mid(currentLocation.length()+1);never executed: return path.mid(currentLocation.length()+1); | 0 | ||||||||||||||||||
| 2992 | } | - | ||||||||||||||||||
| 2993 | return never executed: index.data(QFileSystemModel::FilePathRole).toString();return index.data(QFileSystemModel::FilePathRole).toString();never executed: return index.data(QFileSystemModel::FilePathRole).toString(); | 0 | ||||||||||||||||||
| 2994 | } | - | ||||||||||||||||||
| 2995 | - | |||||||||||||||||||
| 2996 | QStringList QFSCompleter::splitPath(const QString &path) const | - | ||||||||||||||||||
| 2997 | { | - | ||||||||||||||||||
| 2998 | if (path.isEmpty()
| 0 | ||||||||||||||||||
| 2999 | return never executed: QStringList(completionPrefix());return QStringList(completionPrefix());never executed: return QStringList(completionPrefix()); | 0 | ||||||||||||||||||
| 3000 | - | |||||||||||||||||||
| 3001 | QString pathCopy = QDir::toNativeSeparators(path); | - | ||||||||||||||||||
| 3002 | QString sep = QDir::separator(); | - | ||||||||||||||||||
| 3003 | bool expanded; | - | ||||||||||||||||||
| 3004 | pathCopy = qt_tildeExpansion(pathCopy, &expanded); | - | ||||||||||||||||||
| 3005 | if (expanded
| 0 | ||||||||||||||||||
| 3006 | QFileSystemModel *dirModel; | - | ||||||||||||||||||
| 3007 | if (proxyModel
| 0 | ||||||||||||||||||
| 3008 | dirModel = qobject_cast<QFileSystemModel *>(proxyModel->sourceModel()); never executed: dirModel = qobject_cast<QFileSystemModel *>(proxyModel->sourceModel()); | 0 | ||||||||||||||||||
| 3009 | else | - | ||||||||||||||||||
| 3010 | dirModel = sourceModel; never executed: dirModel = sourceModel; | 0 | ||||||||||||||||||
| 3011 | dirModel->fetchMore(dirModel->index(pathCopy)); | - | ||||||||||||||||||
| 3012 | } never executed: end of block | 0 | ||||||||||||||||||
| 3013 | - | |||||||||||||||||||
| 3014 | - | |||||||||||||||||||
| 3015 | QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); | - | ||||||||||||||||||
| 3016 | QStringList parts = pathCopy.split(re); | - | ||||||||||||||||||
| 3017 | if (pathCopy[0] == sep[0]
| 0 | ||||||||||||||||||
| 3018 | parts[0] = sep[0]; never executed: parts[0] = sep[0]; | 0 | ||||||||||||||||||
| 3019 | - | |||||||||||||||||||
| 3020 | - | |||||||||||||||||||
| 3021 | - | |||||||||||||||||||
| 3022 | - | |||||||||||||||||||
| 3023 | - | |||||||||||||||||||
| 3024 | bool startsFromRoot = pathCopy[0] == sep[0]; | - | ||||||||||||||||||
| 3025 | - | |||||||||||||||||||
| 3026 | if (parts.count() == 1
| 0 | ||||||||||||||||||
| 3027 | const QFileSystemModel *dirModel; | - | ||||||||||||||||||
| 3028 | if (proxyModel
| 0 | ||||||||||||||||||
| 3029 | dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); never executed: dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel()); | 0 | ||||||||||||||||||
| 3030 | else | - | ||||||||||||||||||
| 3031 | dirModel = sourceModel; never executed: dirModel = sourceModel; | 0 | ||||||||||||||||||
| 3032 | QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath()); | - | ||||||||||||||||||
| 3033 | - | |||||||||||||||||||
| 3034 | - | |||||||||||||||||||
| 3035 | - | |||||||||||||||||||
| 3036 | - | |||||||||||||||||||
| 3037 | if (currentLocation.contains(sep)
| 0 | ||||||||||||||||||
| 3038 | QStringList currentLocationList = splitPath(currentLocation); | - | ||||||||||||||||||
| 3039 | while (!currentLocationList.isEmpty()
| 0 | ||||||||||||||||||
| 3040 | && parts.count() > 0
| 0 | ||||||||||||||||||
| 3041 | && parts.at(0) == QLatin1String("..")
| 0 | ||||||||||||||||||
| 3042 | parts.removeFirst(); | - | ||||||||||||||||||
| 3043 | currentLocationList.removeLast(); | - | ||||||||||||||||||
| 3044 | } never executed: end of block | 0 | ||||||||||||||||||
| 3045 | if (!currentLocationList.isEmpty()
| 0 | ||||||||||||||||||
| 3046 | currentLocationList.removeLast(); never executed: currentLocationList.removeLast(); | 0 | ||||||||||||||||||
| 3047 | return never executed: currentLocationList + parts;return currentLocationList + parts;never executed: return currentLocationList + parts; | 0 | ||||||||||||||||||
| 3048 | } | - | ||||||||||||||||||
| 3049 | } never executed: end of block | 0 | ||||||||||||||||||
| 3050 | return never executed: parts;return parts;never executed: return parts; | 0 | ||||||||||||||||||
| 3051 | } | - | ||||||||||||||||||
| 3052 | - | |||||||||||||||||||
| 3053 | - | |||||||||||||||||||
| 3054 | - | |||||||||||||||||||
| 3055 | - | |||||||||||||||||||
| 3056 | - | |||||||||||||||||||
| 3057 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |