diff options
Diffstat (limited to 'src/widgets/dialogs/qfiledialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 8a51c7d186..69496dbd29 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -223,6 +223,9 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir) of QFileDialog that contains the Q_OBJECT macro, or the platform does not have a native dialog of the type that you require. + \note This option must be set before changing dialog properties + or showing the dialog. + \value ReadOnly Indicates that the model is readonly. \value HideNameFilterDetails Indicates if the file name filter details are @@ -521,7 +524,7 @@ void QFileDialog::changeEvent(QEvent *e) QFileDialogPrivate::QFileDialogPrivate() : -#ifndef QT_NO_PROXYMODEL +#if QT_CONFIG(proxymodel) proxyModel(0), #endif model(0), @@ -667,7 +670,7 @@ void QFileDialogPrivate::retranslateStrings() QList<QAction*> actions = qFileDialogUi->treeView->header()->actions(); QAbstractItemModel *abstractModel = model; -#ifndef QT_NO_PROXYMODEL +#if QT_CONFIG(proxymodel) if (proxyModel) abstractModel = proxyModel; #endif @@ -724,6 +727,16 @@ bool QFileDialogPrivate::usingWidgets() const Sets the given \a option to be enabled if \a on is true; otherwise, clears the given \a option. + Options (particularly the DontUseNativeDialogs option) should be set + before changing dialog properties or showing the dialog. + + Setting options while the dialog is visible is not guaranteed to have + an immediate effect on the dialog (depending on the option and on the + platform). + + Setting options after changing other properties may cause these + values to have no effect. + \sa options, testOption() */ void QFileDialog::setOption(Option option, bool on) @@ -754,9 +767,15 @@ bool QFileDialog::testOption(Option option) const By default, all options are disabled. - Options should be set before showing the dialog. Setting them while the - dialog is visible is not guaranteed to have an immediate effect on the - dialog (depending on the option and on the platform). + Options (particularly the DontUseNativeDialogs option) should be set + before changing dialog properties or showing the dialog. + + Setting options while the dialog is visible is not guaranteed to have + an immediate effect on the dialog (depending on the option and on the + platform). + + Setting options after changing other properties may cause these + values to have no effect. \sa setOption(), testOption() */ @@ -806,8 +825,6 @@ QFileDialog::Options QFileDialog::options() const } /*! - \overload - \since 4.5 This function connects one of its signals to the slot specified by \a receiver @@ -1051,10 +1068,15 @@ void QFileDialog::selectFile(const QString &filename) return; if (!d->usingWidgets()) { - QUrl url = QUrl::fromLocalFile(filename); + QUrl url; if (QFileInfo(filename).isRelative()) { - QDir dir(d->options->initialDirectory().toLocalFile()); - url = QUrl::fromLocalFile(dir.absoluteFilePath(filename)); + url = d->options->initialDirectory(); + QString path = url.path(); + if (!path.endsWith(QLatin1Char('/'))) + path += QLatin1Char('/'); + url.setPath(path + filename); + } else { + url = QUrl::fromLocalFile(filename); } d->selectFile_sys(url); d->options->setInitiallySelectedFiles(QList<QUrl>() << url); @@ -1112,7 +1134,7 @@ Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path) const QString homePath = QDir::homePath(); #else const QByteArray userName = path.midRef(1, separatorPosition - 1).toLocal8Bit(); -# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) +# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_WASM) passwd pw; passwd *tmpPw; char buf[200]; @@ -2110,9 +2132,7 @@ QString QFileDialog::labelText(DialogLabel label) const strings. If you want multiple filters, separate them with ';;', for example: - \code - "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \snippet code/src_gui_dialogs_qfiledialog.cpp 14 The \a options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can @@ -2225,9 +2245,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent, \a selectedFilter and \a filter may be empty strings. If you need multiple filters, separate them with ';;', for instance: - \code - "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \snippet code/src_gui_dialogs_qfiledialog.cpp 14 The dialog's caption is set to \a caption. If \a caption is not specified then a default caption will be used. @@ -2341,9 +2359,7 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent, parameters \a dir, \a selectedFilter, and \a filter may be empty strings. Multiple filters are separated with ';;'. For instance: - \code - "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \snippet code/src_gui_dialogs_qfiledialog.cpp 14 The \a options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can @@ -2817,7 +2833,7 @@ bool QFileDialogPrivate::restoreWidgetState(QStringList &history, int splitterPo QList<QAction*> actions = headerView->actions(); QAbstractItemModel *abstractModel = model; -#ifndef QT_NO_PROXYMODEL +#if QT_CONFIG(proxymodel) if (proxyModel) abstractModel = proxyModel; #endif @@ -2986,7 +3002,7 @@ void QFileDialogPrivate::createWidgets() q, SLOT(_q_showHeader(QAction*)));; QAbstractItemModel *abstractModel = model; -#ifndef QT_NO_PROXYMODEL +#if QT_CONFIG(proxymodel) if (proxyModel) abstractModel = proxyModel; #endif @@ -3067,7 +3083,7 @@ void QFileDialogPrivate::_q_showHeader(QAction *action) qFileDialogUi->treeView->header()->setSectionHidden(actionGroup->actions().indexOf(action) + 1, !action->isChecked()); } -#ifndef QT_NO_PROXYMODEL +#if QT_CONFIG(proxymodel) /*! \since 4.3 @@ -3145,7 +3161,7 @@ QAbstractProxyModel *QFileDialog::proxyModel() const Q_D(const QFileDialog); return d->proxyModel; } -#endif // QT_NO_PROXYMODEL +#endif // QT_CONFIG(proxymodel) /*! \internal |