summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfiledialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qfiledialog.cpp')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp154
1 files changed, 33 insertions, 121 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 2f49a226e9..db13cfea0f 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1,8 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -35,6 +34,7 @@
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -67,11 +67,12 @@
#if defined(Q_OS_WINCE)
extern bool qt_priv_ptr_valid;
#endif
+#endif
#if defined(Q_OS_UNIX)
#include <pwd.h>
+#elif defined(Q_OS_WIN)
+# include <QtCore/qt_windows.h>
#endif
-#endif
-#include "qplatformdialoghelper_qpa.h"
QT_BEGIN_NAMESPACE
@@ -1097,15 +1098,6 @@ void QFileDialog::setNameFilter(const QString &filter)
setNameFilters(qt_make_filter_list(filter));
}
-/*!
- \obsolete
-
- Use setNameFilter() instead.
-*/
-void QFileDialog::setFilter(const QString &filter)
-{
- setNameFilter(filter);
-}
/*!
\property QFileDialog::nameFilterDetailsVisible
@@ -1178,16 +1170,6 @@ void QFileDialog::setNameFilters(const QStringList &filters)
}
/*!
- \obsolete
-
- Use setNameFilters() instead.
-*/
-void QFileDialog::setFilters(const QStringList &filters)
-{
- setNameFilters(filters);
-}
-
-/*!
\since 4.4
Returns the file type filters that are in operation on this file
@@ -1199,17 +1181,6 @@ QStringList QFileDialog::nameFilters() const
}
/*!
- \obsolete
-
- Use nameFilters() instead.
-*/
-
-QStringList QFileDialog::filters() const
-{
- return nameFilters();
-}
-
-/*!
\since 4.4
Sets the current file type \a filter. Multiple filters can be
@@ -1237,17 +1208,6 @@ void QFileDialog::selectNameFilter(const QString &filter)
}
/*!
- \obsolete
-
- Use selectNameFilter() instead.
-*/
-
-void QFileDialog::selectFilter(const QString &filter)
-{
- selectNameFilter(filter);
-}
-
-/*!
\since 4.4
Returns the filter that the user selected in the file dialog.
@@ -1264,16 +1224,6 @@ QString QFileDialog::selectedNameFilter() const
}
/*!
- \obsolete
-
- Use selectedNameFilter() instead.
-*/
-QString QFileDialog::selectedFilter() const
-{
- return selectedNameFilter();
-}
-
-/*!
\since 4.4
Returns the filter that is used when displaying files.
@@ -1437,6 +1387,25 @@ QLineEdit *QFileDialogPrivate::lineEdit() const {
return (QLineEdit*)qFileDialogUi->fileNameEdit;
}
+int QFileDialogPrivate::maxNameLength(const QString &path)
+{
+#if defined(Q_OS_UNIX)
+ return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
+#elif defined(Q_OS_WINCE)
+ Q_UNUSED(path);
+ return MAX_PATH;
+#elif defined(Q_OS_WIN)
+ DWORD maxLength;
+ const QString drive = path.left(3);
+ if (::GetVolumeInformation(reinterpret_cast<const wchar_t *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0) == FALSE)
+ return -1;
+ return maxLength;
+#else
+ Q_UNUSED(path);
+#endif
+ return -1;
+}
+
/*
Sets the view root index to be the file system model index
*/
@@ -1723,25 +1692,6 @@ extern QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);
#endif
-/*
- For Symbian file dialogs
-*/
-#if defined(Q_WS_S60)
-extern QString qtSymbianGetOpenFileName(const QString &caption,
- const QString &dir,
- const QString &filter);
-
-extern QStringList qtSymbianGetOpenFileNames(const QString &caption,
- const QString &dir,
- const QString &filter);
-
-extern QString qtSymbianGetSaveFileName(const QString &caption,
- const QString &dir);
-
-extern QString qtSymbianGetExistingDirectory(const QString &caption,
- const QString &dir);
-#endif
-
/*!
This is a convenience static function that returns an existing file
selected by the user. If the user presses Cancel, it returns a null string.
@@ -1770,7 +1720,7 @@ extern QString qtSymbianGetExistingDirectory(const QString &caption,
The dialog's caption is set to \a caption. If \a caption is not specified
then a default caption will be used.
- On Windows, Mac OS X and Symbian^3, this static function will use the
+ On Windows, and Mac OS X, this static function will use the
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
@@ -1783,10 +1733,6 @@ extern QString qtSymbianGetExistingDirectory(const QString &caption,
\a options includes DontResolveSymlinks, the file dialog will treat
symlinks as regular directories.
- On Symbian^3 the parameter \a selectedFilter has no meaning and the
- \a options parameter is only used to define if the native file dialog is
- used.
-
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1802,10 +1748,6 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
{
if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
-#if defined(Q_WS_S60)
- if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
- return qtSymbianGetOpenFileName(caption, dir, filter);
-#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -1826,7 +1768,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)
- *selectedFilter = dialog.selectedFilter();
+ *selectedFilter = dialog.selectedNameFilter();
return dialog.selectedFiles().value(0);
}
return QString();
@@ -1856,7 +1798,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
The dialog's caption is set to \a caption. If \a caption is not specified
then a default caption will be used.
- On Windows, Mac OS X and Symbian^3, this static function will use the
+ On Windows, and Mac OS X, this static function will use the
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
@@ -1875,10 +1817,6 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
\snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10
- On Symbian^3 the parameter \a selectedFilter has no meaning and the
- \a options parameter is only used to define if the native file dialog is
- used. On Symbian^3, this function can only return a single filename.
-
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1894,10 +1832,6 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
{
if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
-#if defined(Q_WS_S60)
- if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
- return qtSymbianGetOpenFileNames(caption, dir, filter);
-#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -1919,7 +1853,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)
- *selectedFilter = dialog.selectedFilter();
+ *selectedFilter = dialog.selectedNameFilter();
return dialog.selectedFiles();
}
return QStringList();
@@ -1955,7 +1889,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
The dialog's caption is set to \a caption. If \a caption is not specified,
a default caption will be used.
- On Windows, Mac OS X and Symbian^3, this static function will use the
+ On Windows, and Mac OS X, this static function will use the
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
@@ -1969,10 +1903,6 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
\a options includes DontResolveSymlinks the file dialog will treat symlinks
as regular directories.
- On Symbian^3 the parameters \a filter and \a selectedFilter have no
- meaning. The \a options parameter is only used to define if the native file
- dialog is used.
-
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1988,10 +1918,6 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
{
if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
-#if defined(Q_WS_S60)
- if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
- return qtSymbianGetSaveFileName(caption, dir);
-#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -2014,7 +1940,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
if (selectedFilter)
- *selectedFilter = dialog.selectedFilter();
+ *selectedFilter = dialog.selectedNameFilter();
return dialog.selectedFiles().value(0);
}
@@ -2040,7 +1966,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must
be set.
- On Windows, Mac OS X and Symbian^3, this static function will use the
+ On Windows, and Mac OS X, this static function will use the
native file dialog and not a QFileDialog. On Windows CE, if the device has
no native file dialog, a QFileDialog will be used.
@@ -2054,9 +1980,6 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
dispatch any QTimers, and if \a parent is not 0 then it will position the
dialog just below the parent's title bar.
- On Symbian^3 the \a options parameter is only used to define if the native
- file dialog is used.
-
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -2070,10 +1993,6 @@ QString QFileDialog::getExistingDirectory(QWidget *parent,
{
if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
-#if defined(Q_WS_S60)
- if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
- return qtSymbianGetExistingDirectory(caption, dir);
-#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -3437,10 +3356,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
QString pathCopy = QDir::toNativeSeparators(path);
QString sep = QDir::separator();
-#if defined(Q_OS_SYMBIAN)
- if (pathCopy == QLatin1String("\\"))
- return QStringList(pathCopy);
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
return QStringList(pathCopy);
QString doubleSlash(QLatin1String("\\\\"));
@@ -3463,11 +3379,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
-#if defined(Q_OS_SYMBIAN)
- QStringList parts = pathCopy.split(re, QString::SkipEmptyParts);
- if (pathCopy.endsWith(sep))
- parts.append(QString());
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
QStringList parts = pathCopy.split(re, QString::SkipEmptyParts);
if (!doubleSlash.isEmpty() && !parts.isEmpty())
parts[0].prepend(doubleSlash);