| Line | Source Code | Coverage | 
|---|
| 1 | /**************************************************************************** | - | 
|   | ** |   | 
|   | ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). |   | 
|   | ** Contact: http://www.qt-project.org/legal |   | 
|   | ** |   | 
|   | ** This file is part of the QtGui module of the Qt Toolkit. |   | 
|   | ** |   | 
|   | ** $QT_BEGIN_LICENSE:LGPL$ |   | 
|   | ** Commercial License Usage |   | 
|   | ** Licensees holding valid commercial Qt licenses may use this file in |   | 
|   | ** accordance with the commercial license agreement provided with the |   | 
|   | ** Software or, alternatively, in accordance with the terms contained in |   | 
|   | ** a written agreement between you and Digia.  For licensing terms and |   | 
|   | ** conditions see http://qt.digia.com/licensing.  For further information |   | 
|   | ** use the contact form at http://qt.digia.com/contact-us. |   | 
|   | ** |   | 
|   | ** GNU Lesser General Public License Usage |   | 
|   | ** Alternatively, this file may be used under the terms of the GNU Lesser |   | 
|   | ** General Public License version 2.1 as published by the Free Software |   | 
|   | ** Foundation and appearing in the file LICENSE.LGPL included in the |   | 
|   | ** packaging of this file.  Please review the following information to |   | 
|   | ** ensure the GNU Lesser General Public License version 2.1 requirements |   | 
|   | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |   | 
|   | ** |   | 
|   | ** In addition, as a special exception, Digia gives you certain additional |   | 
|   | ** rights.  These rights are described in the Digia Qt LGPL Exception |   | 
|   | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |   | 
|   | ** |   | 
|   | ** GNU General Public License Usage |   | 
|   | ** Alternatively, this file may be used under the terms of the GNU |   | 
|   | ** General Public License version 3.0 as published by the Free Software |   | 
|   | ** Foundation and appearing in the file LICENSE.GPL included in the |   | 
|   | ** packaging of this file.  Please review the following information to |   | 
|   | ** ensure the GNU General Public License version 3.0 requirements will be |   | 
|   | ** met: http://www.gnu.org/copyleft/gpl.html. |   | 
|   | ** |   | 
|   | ** |   | 
|   | ** $QT_END_LICENSE$ |   | 
|   | ** |   | 
|   | ****************************************************************************/****************************************************************************  |   | 
| 2 | **  | - | 
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).  | - | 
| 4 | ** Contact: http://www.qt-project.org/legal  | - | 
| 5 | **  | - | 
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.  | - | 
| 7 | **  | - | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$  | - | 
| 9 | ** Commercial License Usage  | - | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in  | - | 
| 11 | ** accordance with the commercial license agreement provided with the  | - | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in  | - | 
| 13 | ** a written agreement between you and Digia.  For licensing terms and  | - | 
| 14 | ** conditions see http://qt.digia.com/licensing.  For further information  | - | 
| 15 | ** use the contact form at http://qt.digia.com/contact-us.  | - | 
| 16 | **  | - | 
| 17 | ** GNU Lesser General Public License Usage  | - | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser  | - | 
| 19 | ** General Public License version 2.1 as published by the Free Software  | - | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the  | - | 
| 21 | ** packaging of this file.  Please review the following information to  | - | 
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements  | - | 
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.  | - | 
| 24 | **  | - | 
| 25 | ** In addition, as a special exception, Digia gives you certain additional  | - | 
| 26 | ** rights.  These rights are described in the Digia Qt LGPL Exception  | - | 
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.  | - | 
| 28 | **  | - | 
| 29 | ** GNU General Public License Usage  | - | 
| 30 | ** Alternatively, this file may be used under the terms of the GNU  | - | 
| 31 | ** General Public License version 3.0 as published by the Free Software  | - | 
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the  | - | 
| 33 | ** packaging of this file.  Please review the following information to  | - | 
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be  | - | 
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html.  | - | 
| 36 | **  | - | 
| 37 | **  | - | 
| 38 | ** $QT_END_LICENSE$  | - | 
| 39 | **  | - | 
| 40 | ****************************************************************************/  | - | 
| 41 |   | - | 
| 42 | #include <qvariant.h>  | - | 
| 43 | #include <private/qwidgetitemdata_p.h>  | - | 
| 44 | #include "qfiledialog.h"  | - | 
| 45 |   | - | 
| 46 | #ifndef QT_NO_FILEDIALOG  | - | 
| 47 | #include "qfiledialog_p.h"  | - | 
| 48 | #include <private/qguiapplication_p.h>  | - | 
| 49 | #include <qfontmetrics.h>  | - | 
| 50 | #include <qaction.h>  | - | 
| 51 | #include <qheaderview.h>  | - | 
| 52 | #include <qshortcut.h>  | - | 
| 53 | #include <qgridlayout.h>  | - | 
| 54 | #include <qmenu.h>  | - | 
| 55 | #include <qmessagebox.h>  | - | 
| 56 | #include <qinputdialog.h>  | - | 
| 57 | #include <stdlib.h>  | - | 
| 58 | #include <qsettings.h>  | - | 
| 59 | #include <qdebug.h>  | - | 
| 60 | #include <qapplication.h>  | - | 
| 61 | #include <qstylepainter.h>  | - | 
| 62 | #if !defined(Q_OS_WINCE)  | - | 
| 63 | #include "ui_qfiledialog.h"  | - | 
| 64 | #else  | - | 
| 65 | #define Q_EMBEDDED_SMALLSCREEN  | - | 
| 66 | #include "ui_qfiledialog_embedded.h"  | - | 
| 67 | #if defined(Q_OS_WINCE)  | - | 
| 68 | extern bool qt_priv_ptr_valid;  | - | 
| 69 | #endif  | - | 
| 70 | #endif  | - | 
| 71 | #if defined(Q_OS_UNIX)  | - | 
| 72 | #include <pwd.h>  | - | 
| 73 | #elif defined(Q_OS_WIN)  | - | 
| 74 | #  include <QtCore/qt_windows.h>  | - | 
| 75 | #endif  | - | 
| 76 |   | - | 
| 77 | QT_BEGIN_NAMESPACE  | - | 
| 78 |   | - | 
| 79 | Q_GLOBAL_STATIC(QString, lastVisitedDir)  | - | 
| 80 |   | - | 
| 81 | /*  | - | 
| 82 |     \internal  | - | 
| 83 |   | - | 
| 84 |     Exported hooks that can be used to customize the static functions.  | - | 
| 85 |  */  | - | 
| 86 | typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);  | - | 
| 87 | Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook = 0;  | - | 
| 88 |   | - | 
| 89 | typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);  | - | 
| 90 | Q_WIDGETS_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook = 0;  | - | 
| 91 |   | - | 
| 92 | typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);  | - | 
| 93 | Q_WIDGETS_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook = 0;  | - | 
| 94 |   | - | 
| 95 | typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);  | - | 
| 96 | Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook = 0;  | - | 
| 97 |   | - | 
| 98 | /*!  | - | 
| 99 |   \class QFileDialog  | - | 
| 100 |   \brief The QFileDialog class provides a dialog that allow users to select files or directories.  | - | 
| 101 |   \ingroup standard-dialogs  | - | 
| 102 |   \inmodule QtWidgets  | - | 
| 103 |   | - | 
| 104 |   The QFileDialog class enables a user to traverse the file system in  | - | 
| 105 |   order to select one or many files or a directory.  | - | 
| 106 |   | - | 
| 107 |   The easiest way to create a QFileDialog is to use the static  | - | 
| 108 |   functions. On Windows, Mac OS X, KDE and GNOME, these static functions will  | - | 
| 109 |   call the native file dialog when possible.  | - | 
| 110 |   | - | 
| 111 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 0  | - | 
| 112 |   | - | 
| 113 |   In the above example, a modal QFileDialog is created using a static  | - | 
| 114 |   function. The dialog initially displays the contents of the "/home/jana"  | - | 
| 115 |   directory, and displays files matching the patterns given in the  | - | 
| 116 |   string "Image Files (*.png *.jpg *.bmp)". The parent of the file dialog  | - | 
| 117 |   is set to \e this, and the window title is set to "Open Image".  | - | 
| 118 |   | - | 
| 119 |   If you want to use multiple filters, separate each one with  | - | 
| 120 |   \e two semicolons. For example:  | - | 
| 121 |   | - | 
| 122 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 1  | - | 
| 123 |   | - | 
| 124 |   You can create your own QFileDialog without using the static  | - | 
| 125 |   functions. By calling setFileMode(), you can specify what the user must  | - | 
| 126 |   select in the dialog:  | - | 
| 127 |   | - | 
| 128 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 2  | - | 
| 129 |   | - | 
| 130 |   In the above example, the mode of the file dialog is set to  | - | 
| 131 |   AnyFile, meaning that the user can select any file, or even specify a  | - | 
| 132 |   file that doesn't exist. This mode is useful for creating a  | - | 
| 133 |   "Save As" file dialog. Use ExistingFile if the user must select an  | - | 
| 134 |   existing file, or \l Directory if only a directory may be selected.  | - | 
| 135 |   See the \l QFileDialog::FileMode enum for the complete list of modes.  | - | 
| 136 |   | - | 
| 137 |   The fileMode property contains the mode of operation for the dialog;  | - | 
| 138 |   this indicates what types of objects the user is expected to select.  | - | 
| 139 |   Use setNameFilter() to set the dialog's file filter. For example:  | - | 
| 140 |   | - | 
| 141 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 3  | - | 
| 142 |   | - | 
| 143 |   In the above example, the filter is set to \c{"Images (*.png *.xpm *.jpg)"},  | - | 
| 144 |   this means that only files with the extension \c png, \c xpm,  | - | 
| 145 |   or \c jpg will be shown in the QFileDialog. You can apply  | - | 
| 146 |   several filters by using setNameFilters(). Use selectNameFilter() to select  | - | 
| 147 |   one of the filters you've given as the file dialog's default filter.  | - | 
| 148 |   | - | 
| 149 |   The file dialog has two view modes: \l{QFileDialog::}{List} and  | - | 
| 150 |   \l{QFileDialog::}{Detail}.  | - | 
| 151 |   \l{QFileDialog::}{List} presents the contents of the current directory  | - | 
| 152 |   as a list of file and directory names. \l{QFileDialog::}{Detail} also  | - | 
| 153 |   displays a list of file and directory names, but provides additional  | - | 
| 154 |   information alongside each name, such as the file size and modification  | - | 
| 155 |   date. Set the mode with setViewMode():  | - | 
| 156 |   | - | 
| 157 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 4  | - | 
| 158 |   | - | 
| 159 |   The last important function you will need to use when creating your  | - | 
| 160 |   own file dialog is selectedFiles().  | - | 
| 161 |   | - | 
| 162 |   \snippet code/src_gui_dialogs_qfiledialog.cpp 5  | - | 
| 163 |   | - | 
| 164 |   In the above example, a modal file dialog is created and shown. If  | - | 
| 165 |   the user clicked OK, the file they selected is put in \c fileName.  | - | 
| 166 |   | - | 
| 167 |   The dialog's working directory can be set with setDirectory().  | - | 
| 168 |   Each file in the current directory can be selected using  | - | 
| 169 |   the selectFile() function.  | - | 
| 170 |   | - | 
| 171 |   The \l{dialogs/standarddialogs}{Standard Dialogs} example shows  | - | 
| 172 |   how to use QFileDialog as well as other built-in Qt dialogs.  | - | 
| 173 |   | - | 
| 174 |   \sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example},  | - | 
| 175 |       {Application Example}  | - | 
| 176 | */  | - | 
| 177 |   | - | 
| 178 | /*!  | - | 
| 179 |     \enum QFileDialog::AcceptMode  | - | 
| 180 |   | - | 
| 181 |     \value AcceptOpen  | - | 
| 182 |     \value AcceptSave  | - | 
| 183 | */  | - | 
| 184 |   | - | 
| 185 | /*!  | - | 
| 186 |     \enum QFileDialog::ViewMode  | - | 
| 187 |   | - | 
| 188 |     This enum describes the view mode of the file dialog; i.e. what  | - | 
| 189 |     information about each file will be displayed.  | - | 
| 190 |   | - | 
| 191 |     \value Detail Displays an icon, a name, and details for each item in  | - | 
| 192 |                   the directory.  | - | 
| 193 |     \value List   Displays only an icon and a name for each item in the  | - | 
| 194 |                   directory.  | - | 
| 195 |   | - | 
| 196 |     \sa setViewMode()  | - | 
| 197 | */  | - | 
| 198 |   | - | 
| 199 | /*!  | - | 
| 200 |     \enum QFileDialog::FileMode  | - | 
| 201 |   | - | 
| 202 |     This enum is used to indicate what the user may select in the file  | - | 
| 203 |     dialog; i.e. what the dialog will return if the user clicks OK.  | - | 
| 204 |   | - | 
| 205 |     \value AnyFile        The name of a file, whether it exists or not.  | - | 
| 206 |     \value ExistingFile   The name of a single existing file.  | - | 
| 207 |     \value Directory      The name of a directory. Both files and  | - | 
| 208 |                           directories are displayed.  | - | 
| 209 |     \value ExistingFiles  The names of zero or more existing files.  | - | 
| 210 |   | - | 
| 211 |     This value is obsolete since Qt 4.5:  | - | 
| 212 |   | - | 
| 213 |     \value DirectoryOnly  Use \c Directory and setOption(ShowDirsOnly, true) instead.  | - | 
| 214 |   | - | 
| 215 |     \sa setFileMode()  | - | 
| 216 | */  | - | 
| 217 |   | - | 
| 218 | /*!  | - | 
| 219 |     \enum QFileDialog::Option  | - | 
| 220 |   | - | 
| 221 |     \value ShowDirsOnly Only show directories in the file dialog. By  | - | 
| 222 |     default both files and directories are shown. (Valid only in the  | - | 
| 223 |     \l Directory file mode.)  | - | 
| 224 |   | - | 
| 225 |     \value DontResolveSymlinks Don't resolve symlinks in the file  | - | 
| 226 |     dialog. By default symlinks are resolved.  | - | 
| 227 |   | - | 
| 228 |     \value DontConfirmOverwrite Don't ask for confirmation if an  | - | 
| 229 |     existing file is selected.  By default confirmation is requested.  | - | 
| 230 |   | - | 
| 231 |     \value DontUseNativeDialog Don't use the native file dialog. By  | - | 
| 232 |     default, the native file dialog is used unless you use a subclass  | - | 
| 233 |     of QFileDialog that contains the Q_OBJECT macro.  | - | 
| 234 |   | - | 
| 235 |     \value ReadOnly Indicates that the model is readonly.  | - | 
| 236 |   | - | 
| 237 |     \value HideNameFilterDetails Indicates if the file name filter details are  | - | 
| 238 |     hidden or not.  | - | 
| 239 |   | - | 
| 240 |     \value DontUseSheet In previous versions of Qt, the static  | - | 
| 241 |     functions would create a sheet by default if the static function  | - | 
| 242 |     was given a parent. This is no longer supported and does nothing in Qt 4.5, The  | - | 
| 243 |     static functions will always be an application modal dialog. If  | - | 
| 244 |     you want to use sheets, use QFileDialog::open() instead.  | - | 
| 245 |   | - | 
| 246 | */  | - | 
| 247 |   | - | 
| 248 | /*!  | - | 
| 249 |   \enum QFileDialog::DialogLabel  | - | 
| 250 |   | - | 
| 251 |   \value LookIn  | - | 
| 252 |   \value FileName  | - | 
| 253 |   \value FileType  | - | 
| 254 |   \value Accept  | - | 
| 255 |   \value Reject  | - | 
| 256 | */  | - | 
| 257 |   | - | 
| 258 | /*!  | - | 
| 259 |     \fn void QFileDialog::filesSelected(const QStringList &selected)  | - | 
| 260 |   | - | 
| 261 |     When the selection changes and the dialog is accepted, this signal is  | - | 
| 262 |     emitted with the (possibly empty) list of \a selected files.  | - | 
| 263 |   | - | 
| 264 |     \sa currentChanged(), QDialog::Accepted  | - | 
| 265 | */  | - | 
| 266 |   | - | 
| 267 |   | - | 
| 268 | /*!  | - | 
| 269 |     \fn void QFileDialog::fileSelected(const QString &file)  | - | 
| 270 |   | - | 
| 271 |     When the selection changes and the dialog is accepted, this signal is  | - | 
| 272 |     emitted with the (possibly empty) selected \a file.  | - | 
| 273 |   | - | 
| 274 |     \sa currentChanged(), QDialog::Accepted  | - | 
| 275 | */  | - | 
| 276 |   | - | 
| 277 |   | - | 
| 278 | /*!  | - | 
| 279 |     \fn void QFileDialog::currentChanged(const QString &path)  | - | 
| 280 |   | - | 
| 281 |     When the current file changes, this signal is emitted with the  | - | 
| 282 |     new file name as the \a path parameter.  | - | 
| 283 |   | - | 
| 284 |     \sa filesSelected()  | - | 
| 285 | */  | - | 
| 286 |   | - | 
| 287 | /*!  | - | 
| 288 |   \fn void QFileDialog::directoryEntered(const QString &directory)  | - | 
| 289 |   \since 4.3  | - | 
| 290 |   | - | 
| 291 |   This signal is emitted when the user enters a \a directory.  | - | 
| 292 | */  | - | 
| 293 |   | - | 
| 294 | /*!  | - | 
| 295 |   \fn void QFileDialog::filterSelected(const QString &filter)  | - | 
| 296 |   \since 4.3  | - | 
| 297 |   | - | 
| 298 |   This signal is emitted when the user selects a \a filter.  | - | 
| 299 | */  | - | 
| 300 |   | - | 
| 301 | //#if defined(Q_WS_WIN) || defined(Q_WS_MAC)  | - | 
| 302 | //bool Q_WIDGETS_EXPORT qt_use_native_dialogs = true; // for the benefit of testing tools, until we have a proper API  | - | 
| 303 | //#endif  | - | 
| 304 |   | - | 
| 305 | QT_BEGIN_INCLUDE_NAMESPACE  | - | 
| 306 | #ifdef Q_WS_WIN  | - | 
| 307 | #include <qwindowsstyle_p.h>  | - | 
| 308 | #endif  | - | 
| 309 | #include <qshortcut.h>  | - | 
| 310 | #ifdef Q_WS_MAC  | - | 
| 311 | #include <qmacstyle_mac_p.h>  | - | 
| 312 | #endif  | - | 
| 313 | QT_END_INCLUDE_NAMESPACE  | - | 
| 314 |   | - | 
| 315 | /*!  | - | 
| 316 |     \fn QFileDialog::QFileDialog(QWidget *parent, Qt::WindowFlags flags)  | - | 
| 317 |   | - | 
| 318 |     Constructs a file dialog with the given \a parent and widget \a flags.  | - | 
| 319 | */  | - | 
| 320 | QFileDialog::QFileDialog(QWidget *parent, Qt::WindowFlags f)  | - | 
| 321 |     : QDialog(*new QFileDialogPrivate, parent, f)  | - | 
| 322 | {  | - | 
| 323 |     Q_D(QFileDialog);  | - | 
| 324 |     d->init();  | - | 
| 325 |     d->lineEdit()->selectAll();  | - | 
| 326 | }  | - | 
| 327 |   | - | 
| 328 | /*!  | - | 
| 329 |     Constructs a file dialog with the given \a parent and \a caption that  | - | 
| 330 |     initially displays the contents of the specified \a directory.  | - | 
| 331 |     The contents of the directory are filtered before being shown in the  | - | 
| 332 |     dialog, using a semicolon-separated list of filters specified by  | - | 
| 333 |     \a filter.  | - | 
| 334 | */  | - | 
| 335 | QFileDialog::QFileDialog(QWidget *parent,  | - | 
| 336 |                      const QString &caption,  | - | 
| 337 |                      const QString &directory,  | - | 
| 338 |                      const QString &filter)  | - | 
| 339 |     : QDialog(*new QFileDialogPrivate, parent, 0)  | - | 
| 340 | {  | - | 
| 341 |     Q_D(QFileDialog);  | - | 
| 342 |     d->init(directory, filter, caption);  | - | 
| 343 |     d->lineEdit()->selectAll();  | - | 
| 344 | }  | - | 
| 345 |   | - | 
| 346 | /*!  | - | 
| 347 |     \internal  | - | 
| 348 | */  | - | 
| 349 | QFileDialog::QFileDialog(const QFileDialogArgs &args)  | - | 
| 350 |     : QDialog(*new QFileDialogPrivate, args.parent, 0)  | - | 
| 351 | {  | - | 
| 352 |     Q_D(QFileDialog);  | - | 
| 353 |     d->init(args.directory, args.filter, args.caption);  | - | 
| 354 |     setFileMode(args.mode);  | - | 
| 355 |     setOptions(args.options);  | - | 
| 356 |     selectFile(args.selection);  | - | 
| 357 |     d->lineEdit()->selectAll();  | - | 
| 358 | }  | - | 
| 359 |   | - | 
| 360 | /*!  | - | 
| 361 |     Destroys the file dialog.  | - | 
| 362 | */  | - | 
| 363 | QFileDialog::~QFileDialog()  | - | 
| 364 | {  | - | 
| 365 | #ifndef QT_NO_SETTINGS  | - | 
| 366 |     QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));  | - | 
| 367 |     settings.beginGroup(QLatin1String("Qt"));  | - | 
| 368 |     settings.setValue(QLatin1String("filedialog"), saveState());  | - | 
| 369 | #endif  | - | 
| 370 | }  | - | 
| 371 |   | - | 
| 372 | /*!  | - | 
| 373 |     \since 4.3  | - | 
| 374 |     Sets the \a urls that are located in the sidebar.  | - | 
| 375 |   | - | 
| 376 |     For instance:  | - | 
| 377 |   | - | 
| 378 |     \snippet filedialogurls.cpp 0  | - | 
| 379 |   | - | 
| 380 |     The file dialog will then look like this:  | - | 
| 381 |   | - | 
| 382 |     \image filedialogurls.png  | - | 
| 383 |   | - | 
| 384 |     \sa sidebarUrls()  | - | 
| 385 | */  | - | 
| 386 | void QFileDialog::setSidebarUrls(const QList<QUrl> &urls)  | - | 
| 387 | {  | - | 
| 388 |     Q_D(QFileDialog);  | - | 
| 389 |     d->qFileDialogUi->sidebar->setUrls(urls);  | - | 
| 390 | }  | - | 
| 391 |   | - | 
| 392 | /*!  | - | 
| 393 |     \since 4.3  | - | 
| 394 |     Returns a list of urls that are currently in the sidebar  | - | 
| 395 | */  | - | 
| 396 | QList<QUrl> QFileDialog::sidebarUrls() const  | - | 
| 397 | {  | - | 
| 398 |     Q_D(const QFileDialog);  | - | 
| 399 |     return d->qFileDialogUi->sidebar->urls();  | - | 
| 400 | }  | - | 
| 401 |   | - | 
| 402 | static const qint32 QFileDialogMagic = 0xbe;  | - | 
| 403 |   | - | 
| 404 | /*!  | - | 
| 405 |     \since 4.3  | - | 
| 406 |     Saves the state of the dialog's layout, history and current directory.  | - | 
| 407 |   | - | 
| 408 |     Typically this is used in conjunction with QSettings to remember the size  | - | 
| 409 |     for a future session. A version number is stored as part of the data.  | - | 
| 410 | */  | - | 
| 411 | QByteArray QFileDialog::saveState() const  | - | 
| 412 | {  | - | 
| 413 |     Q_D(const QFileDialog);  | - | 
| 414 |     int version = 3;  | - | 
| 415 |     QByteArray data;  | - | 
| 416 |     QDataStream stream(&data, QIODevice::WriteOnly);  | - | 
| 417 |   | - | 
| 418 |     stream << qint32(QFileDialogMagic);  | - | 
| 419 |     stream << qint32(version);  | - | 
| 420 |     stream << d->qFileDialogUi->splitter->saveState();  | - | 
| 421 |     stream << d->qFileDialogUi->sidebar->urls();  | - | 
| 422 |     stream << history();  | - | 
| 423 |     stream << *lastVisitedDir();  | - | 
| 424 |     stream << d->qFileDialogUi->treeView->header()->saveState();  | - | 
| 425 |     stream << qint32(viewMode());  | - | 
| 426 |     return data;  | - | 
| 427 | }  | - | 
| 428 |   | - | 
| 429 | /*!  | - | 
| 430 |     \since 4.3  | - | 
| 431 |     Restores the dialogs's layout, history and current directory to the \a state specified.  | - | 
| 432 |   | - | 
| 433 |     Typically this is used in conjunction with QSettings to restore the size  | - | 
| 434 |     from a past session.  | - | 
| 435 |   | - | 
| 436 |     Returns false if there are errors  | - | 
| 437 | */  | - | 
| 438 | bool QFileDialog::restoreState(const QByteArray &state)  | - | 
| 439 | {  | - | 
| 440 |     Q_D(QFileDialog);  | - | 
| 441 |     int version = 3;  | - | 
| 442 |     QByteArray sd = state;  | - | 
| 443 |     QDataStream stream(&sd, QIODevice::ReadOnly);  | - | 
| 444 |     if (stream.atEnd())  | - | 
| 445 |         return false;  | - | 
| 446 |     QByteArray splitterState;  | - | 
| 447 |     QByteArray headerData;  | - | 
| 448 |     QList<QUrl> bookmarks;  | - | 
| 449 |     QStringList history;  | - | 
| 450 |     QString currentDirectory;  | - | 
| 451 |     qint32 marker;  | - | 
| 452 |     qint32 v;  | - | 
| 453 |     qint32 viewMode;  | - | 
| 454 |     stream >> marker;  | - | 
| 455 |     stream >> v;  | - | 
| 456 |     if (marker != QFileDialogMagic || v != version)  | - | 
| 457 |         return false;  | - | 
| 458 |   | - | 
| 459 |     stream >> splitterState  | - | 
| 460 |            >> bookmarks  | - | 
| 461 |            >> history  | - | 
| 462 |            >> currentDirectory  | - | 
| 463 |            >> headerData  | - | 
| 464 |            >> viewMode;  | - | 
| 465 |   | - | 
| 466 |     if (!d->qFileDialogUi->splitter->restoreState(splitterState))  | - | 
| 467 |         return false;  | - | 
| 468 |     QList<int> list = d->qFileDialogUi->splitter->sizes();  | - | 
| 469 |     if (list.count() >= 2 && list.at(0) == 0 && list.at(1) == 0) {  | - | 
| 470 |         for (int i = 0; i < list.count(); ++i)  | - | 
| 471 |             list[i] = d->qFileDialogUi->splitter->widget(i)->sizeHint().width();  | - | 
| 472 |         d->qFileDialogUi->splitter->setSizes(list);  | - | 
| 473 |     }  | - | 
| 474 |   | - | 
| 475 |     d->qFileDialogUi->sidebar->setUrls(bookmarks);  | - | 
| 476 |     while (history.count() > 5)  | - | 
| 477 |         history.pop_front();  | - | 
| 478 |     setHistory(history);  | - | 
| 479 |     setDirectory(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir());  | - | 
| 480 |     QHeaderView *headerView = d->qFileDialogUi->treeView->header();  | - | 
| 481 |     if (!headerView->restoreState(headerData))  | - | 
| 482 |         return false;  | - | 
| 483 |   | - | 
| 484 |     QList<QAction*> actions = headerView->actions();  | - | 
| 485 |     QAbstractItemModel *abstractModel = d->model;  | - | 
| 486 | #ifndef QT_NO_PROXYMODEL  | - | 
| 487 |     if (d->proxyModel)  | - | 
| 488 |         abstractModel = d->proxyModel;  | - | 
| 489 | #endif  | - | 
| 490 |     int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1);  | - | 
| 491 |     for (int i = 1; i < total; ++i)  | - | 
| 492 |         actions.at(i - 1)->setChecked(!headerView->isSectionHidden(i));  | - | 
| 493 |   | - | 
| 494 |     setViewMode(ViewMode(viewMode));  | - | 
| 495 |     return true;  | - | 
| 496 | }  | - | 
| 497 |   | - | 
| 498 | /*!  | - | 
| 499 |     \reimp  | - | 
| 500 | */  | - | 
| 501 | void QFileDialog::changeEvent(QEvent *e)  | - | 
| 502 | {  | - | 
| 503 |     Q_D(QFileDialog);  | - | 
| 504 |     if (e->type() == QEvent::LanguageChange) {  | - | 
| 505 |         d->retranslateWindowTitle();  | - | 
| 506 |         d->retranslateStrings();  | - | 
| 507 |     }  | - | 
| 508 |     QDialog::changeEvent(e);  | - | 
| 509 | }  | - | 
| 510 |   | - | 
| 511 | QFileDialogPrivate::QFileDialogPrivate()  | - | 
| 512 |     :  | - | 
| 513 | #ifndef QT_NO_PROXYMODEL  | - | 
| 514 |         proxyModel(0),  | - | 
| 515 | #endif  | - | 
| 516 |         model(0),  | - | 
| 517 |         currentHistoryLocation(-1),  | - | 
| 518 |         renameAction(0),  | - | 
| 519 |         deleteAction(0),  | - | 
| 520 |         showHiddenAction(0),  | - | 
| 521 |         useDefaultCaption(true),  | - | 
| 522 |         defaultFileTypes(true),  | - | 
| 523 |         qFileDialogUi(0),  | - | 
| 524 |         options(new QFileDialogOptions)  | - | 
| 525 | {  | - | 
| 526 | }  | - | 
| 527 |   | - | 
| 528 | QFileDialogPrivate::~QFileDialogPrivate()  | - | 
| 529 | {  | - | 
| 530 | }  | - | 
| 531 |   | - | 
| 532 | void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h)  | - | 
| 533 | {  | - | 
| 534 |     QFileDialog *d = q_func(); never executed (the execution status of this line is deduced):  QFileDialog *d = q_func();  | - | 
| 535 |     QObject::connect(h, SIGNAL(fileSelected(QString)), d, SIGNAL(fileSelected(QString))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""fileSelected(QString)", d, "2""fileSelected(QString)");  | - | 
| 536 |     QObject::connect(h, SIGNAL(filesSelected(QStringList)), d, SIGNAL(filesSelected(QStringList))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""filesSelected(QStringList)", d, "2""filesSelected(QStringList)");  | - | 
| 537 |     QObject::connect(h, SIGNAL(currentChanged(QString)), d, SIGNAL(currentChanged(QString))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""currentChanged(QString)", d, "2""currentChanged(QString)");  | - | 
| 538 |     QObject::connect(h, SIGNAL(directoryEntered(QString)), d, SIGNAL(directoryEntered(QString))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""directoryEntered(QString)", d, "2""directoryEntered(QString)");  | - | 
| 539 |     QObject::connect(h, SIGNAL(directoryEntered(QString)), d, SLOT(_q_nativeEnterDirectory(QString))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""directoryEntered(QString)", d, "1""_q_nativeEnterDirectory(QString)");  | - | 
| 540 |     QObject::connect(h, SIGNAL(filterSelected(QString)), d, SIGNAL(filterSelected(QString))); never executed (the execution status of this line is deduced):  QObject::connect(h, "2""filterSelected(QString)", d, "2""filterSelected(QString)");  | - | 
| 541 |     static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); never executed (the execution status of this line is deduced):  static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options);  | - | 
| 542 | }  | 0 | 
| 543 |   | - | 
| 544 | void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)  | - | 
| 545 | {  | - | 
| 546 |     Q_Q(QFileDialog);  | - | 
| 547 |     options->setWindowTitle(q->windowTitle());  | - | 
| 548 |     options->setViewMode(static_cast<QFileDialogOptions::ViewMode>(q->viewMode()));  | - | 
| 549 |     options->setHistory(q->history());  | - | 
| 550 |     options->setSidebarUrls(qFileDialogUi->sidebar->urls());  | - | 
| 551 |     const QDir directory = q->directory();  | - | 
| 552 |     options->setInitialDirectory(directory.exists() ?  | - | 
| 553 |                                  directory.absolutePath() :  | - | 
| 554 |                                  QString());  | - | 
| 555 |     options->setInitiallySelectedNameFilter(q->selectedNameFilter());  | - | 
| 556 |     options->setInitiallySelectedFiles(userSelectedFiles());  | - | 
| 557 | }  | - | 
| 558 |   | - | 
| 559 | void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *)  | - | 
| 560 | {  | - | 
| 561 |     if (code == QDialog::Accepted) {  | - | 
| 562 |         Q_Q(QFileDialog);  | - | 
| 563 |         q->setViewMode(static_cast<QFileDialog::ViewMode>(options->viewMode()));  | - | 
| 564 |         q->setSidebarUrls(options->sidebarUrls());  | - | 
| 565 |         q->setHistory(options->history());  | - | 
| 566 |     }  | - | 
| 567 | }  | - | 
| 568 |   | - | 
| 569 | void QFileDialogPrivate::retranslateWindowTitle()  | - | 
| 570 | {  | - | 
| 571 |     Q_Q(QFileDialog);  | - | 
| 572 |     if (!useDefaultCaption || setWindowTitle != q->windowTitle())  | - | 
| 573 |         return;  | - | 
| 574 |     if (q->acceptMode() == QFileDialog::AcceptOpen) {  | - | 
| 575 |         const QFileDialog::FileMode fileMode = q->fileMode();  | - | 
| 576 |         if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory)  | - | 
| 577 |             q->setWindowTitle(QFileDialog::tr("Find Directory"));  | - | 
| 578 |         else  | - | 
| 579 |             q->setWindowTitle(QFileDialog::tr("Open"));  | - | 
| 580 |     } else  | - | 
| 581 |         q->setWindowTitle(QFileDialog::tr("Save As"));  | - | 
| 582 |   | - | 
| 583 |     setWindowTitle = q->windowTitle();  | - | 
| 584 | }  | - | 
| 585 |   | - | 
| 586 | void QFileDialogPrivate::setLastVisitedDirectory(const QString &dir)  | - | 
| 587 | {  | - | 
| 588 |     *lastVisitedDir() = dir;  | - | 
| 589 | }  | - | 
| 590 |   | - | 
| 591 | void QFileDialogPrivate::updateFileNameLabel()  | - | 
| 592 | {  | - | 
| 593 |     if (!options->isLabelExplicitlySet(QFileDialogOptions::FileName)) {  | - | 
| 594 |         switch (q_func()->fileMode()) {  | - | 
| 595 |         case QFileDialog::DirectoryOnly:  | - | 
| 596 |         case QFileDialog::Directory:  | - | 
| 597 |             setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:"));  | - | 
| 598 |             break;  | - | 
| 599 |         default:  | - | 
| 600 |             setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("File &name:"));  | - | 
| 601 |             break;  | - | 
| 602 |         }  | - | 
| 603 |     }  | - | 
| 604 | }  | - | 
| 605 |   | - | 
| 606 | void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder)  | - | 
| 607 | {  | - | 
| 608 |     Q_Q(QFileDialog);  | - | 
| 609 |     // 'Save as' at a folder: Temporarily change to "Open".  | - | 
| 610 |     if (saveAsOnFolder) {  | - | 
| 611 |         setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Open"));  | - | 
| 612 |     } else if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) {  | - | 
| 613 |         setLabelTextControl(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept));  | - | 
| 614 |         return;  | - | 
| 615 |     } else {  | - | 
| 616 |         switch (q->fileMode()) {  | - | 
| 617 |         case QFileDialog::DirectoryOnly:  | - | 
| 618 |         case QFileDialog::Directory:  | - | 
| 619 |             setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose"));  | - | 
| 620 |             break;  | - | 
| 621 |         default:  | - | 
| 622 |             setLabelTextControl(QFileDialog::Accept,  | - | 
| 623 |                                 q->acceptMode() == QFileDialog::AcceptOpen ?  | - | 
| 624 |                                     QFileDialog::tr("&Open")  :  | - | 
| 625 |                                     QFileDialog::tr("&Save"));  | - | 
| 626 |             break;  | - | 
| 627 |         }  | - | 
| 628 |     }  | - | 
| 629 | }  | - | 
| 630 |   | - | 
| 631 | void QFileDialogPrivate::retranslateStrings()  | - | 
| 632 | {  | - | 
| 633 |     Q_Q(QFileDialog);  | - | 
| 634 |     /* WIDGETS */  | - | 
| 635 |     if (defaultFileTypes)  | - | 
| 636 |         q->setNameFilter(QFileDialog::tr("All Files (*)"));  | - | 
| 637 |   | - | 
| 638 |     QList<QAction*> actions = qFileDialogUi->treeView->header()->actions();  | - | 
| 639 |     QAbstractItemModel *abstractModel = model;  | - | 
| 640 | #ifndef QT_NO_PROXYMODEL  | - | 
| 641 |     if (proxyModel)  | - | 
| 642 |         abstractModel = proxyModel;  | - | 
| 643 | #endif  | - | 
| 644 |     int total = qMin(abstractModel->columnCount(QModelIndex()), actions.count() + 1);  | - | 
| 645 |     for (int i = 1; i < total; ++i) {  | - | 
| 646 |         actions.at(i - 1)->setText(QFileDialog::tr("Show ") + abstractModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());  | - | 
| 647 |     }  | - | 
| 648 |   | - | 
| 649 |     /* MENU ACTIONS */  | - | 
| 650 |     renameAction->setText(QFileDialog::tr("&Rename"));  | - | 
| 651 |     deleteAction->setText(QFileDialog::tr("&Delete"));  | - | 
| 652 |     showHiddenAction->setText(QFileDialog::tr("Show &hidden files"));  | - | 
| 653 |     newFolderAction->setText(QFileDialog::tr("&New Folder"));  | - | 
| 654 |     qFileDialogUi->retranslateUi(q);  | - | 
| 655 |     updateFileNameLabel();  | - | 
| 656 | }  | - | 
| 657 |   | - | 
| 658 | void QFileDialogPrivate::emitFilesSelected(const QStringList &files)  | - | 
| 659 | {  | - | 
| 660 |     Q_Q(QFileDialog);  | - | 
| 661 |     emit q->filesSelected(files);  | - | 
| 662 |     if (files.count() == 1)  | - | 
| 663 |         emit q->fileSelected(files.first());  | - | 
| 664 | }  | - | 
| 665 |   | - | 
| 666 | bool QFileDialogPrivate::canBeNativeDialog()  | - | 
| 667 | {  | - | 
| 668 |     Q_Q(QFileDialog);  | - | 
| 669 |     if (nativeDialogInUse)  | - | 
| 670 |         return true;  | - | 
| 671 |     if (q->testAttribute(Qt::WA_DontShowOnScreen))  | - | 
| 672 |         return false;  | - | 
| 673 |     if (q->options() & QFileDialog::DontUseNativeDialog)  | - | 
| 674 |         return false;  | - | 
| 675 |   | - | 
| 676 |     QLatin1String staticName(QFileDialog::staticMetaObject.className());  | - | 
| 677 |     QLatin1String dynamicName(q->metaObject()->className());  | - | 
| 678 |     return (staticName == dynamicName);  | - | 
| 679 | }  | - | 
| 680 |   | - | 
| 681 | /*!  | - | 
| 682 |     \since 4.5  | - | 
| 683 |     Sets the given \a option to be enabled if \a on is true; otherwise,  | - | 
| 684 |     clears the given \a option.  | - | 
| 685 |   | - | 
| 686 |     \sa options, testOption()  | - | 
| 687 | */  | - | 
| 688 | void QFileDialog::setOption(Option option, bool on)  | - | 
| 689 | {  | - | 
| 690 |     const QFileDialog::Options previousOptions = options();  | - | 
| 691 |     if (!(previousOptions & option) != !on)  | - | 
| 692 |         setOptions(previousOptions ^ option);  | - | 
| 693 | }  | - | 
| 694 |   | - | 
| 695 | /*!  | - | 
| 696 |     \since 4.5  | - | 
| 697 |   | - | 
| 698 |     Returns true if the given \a option is enabled; otherwise, returns  | - | 
| 699 |     false.  | - | 
| 700 |   | - | 
| 701 |     \sa options, setOption()  | - | 
| 702 | */  | - | 
| 703 | bool QFileDialog::testOption(Option option) const  | - | 
| 704 | {  | - | 
| 705 |     Q_D(const QFileDialog);  | - | 
| 706 |     return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option));  | - | 
| 707 | }  | - | 
| 708 |   | - | 
| 709 | /*!  | - | 
| 710 |     \property QFileDialog::options  | - | 
| 711 |     \brief the various options that affect the look and feel of the dialog  | - | 
| 712 |     \since 4.5  | - | 
| 713 |   | - | 
| 714 |     By default, all options are disabled.  | - | 
| 715 |   | - | 
| 716 |     Options should be set before showing the dialog. Setting them while the  | - | 
| 717 |     dialog is visible is not guaranteed to have an immediate effect on the  | - | 
| 718 |     dialog (depending on the option and on the platform).  | - | 
| 719 |   | - | 
| 720 |     \sa setOption(), testOption()  | - | 
| 721 | */  | - | 
| 722 | void QFileDialog::setOptions(Options options)  | - | 
| 723 | {  | - | 
| 724 |     Q_D(QFileDialog);  | - | 
| 725 |   | - | 
| 726 |     Options changed = (options ^ QFileDialog::options());  | - | 
| 727 |     if (!changed)  | - | 
| 728 |         return;  | - | 
| 729 |   | - | 
| 730 |     d->options->setOptions(QFileDialogOptions::FileDialogOptions(int(options)));  | - | 
| 731 |     if (changed & DontResolveSymlinks)  | - | 
| 732 |         d->model->setResolveSymlinks(!(options & DontResolveSymlinks));  | - | 
| 733 |     if (changed & ReadOnly) {  | - | 
| 734 |         bool ro = (options & ReadOnly);  | - | 
| 735 |         d->model->setReadOnly(ro);  | - | 
| 736 |         d->qFileDialogUi->newFolderButton->setEnabled(!ro);  | - | 
| 737 |         d->renameAction->setEnabled(!ro);  | - | 
| 738 |         d->deleteAction->setEnabled(!ro);  | - | 
| 739 |     }  | - | 
| 740 |     if (changed & HideNameFilterDetails)  | - | 
| 741 |         setNameFilters(d->options->nameFilters());  | - | 
| 742 |   | - | 
| 743 |     if (changed & ShowDirsOnly)  | - | 
| 744 |         setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files);  | - | 
| 745 | }  | - | 
| 746 |   | - | 
| 747 | QFileDialog::Options QFileDialog::options() const  | - | 
| 748 | {  | - | 
| 749 |     Q_D(const QFileDialog);  | - | 
| 750 |     return QFileDialog::Options(int(d->options->options()));  | - | 
| 751 | }  | - | 
| 752 |   | - | 
| 753 | /*!  | - | 
| 754 |     \overload  | - | 
| 755 |   | - | 
| 756 |     \since 4.5  | - | 
| 757 |   | - | 
| 758 |     This function connects one of its signals to the slot specified by \a receiver  | - | 
| 759 |     and \a member. The specific signal depends is filesSelected() if fileMode is  | - | 
| 760 |     ExistingFiles and fileSelected() if fileMode is anything else.  | - | 
| 761 |   | - | 
| 762 |     The signal will be disconnected from the slot when the dialog is closed.  | - | 
| 763 | */  | - | 
| 764 | void QFileDialog::open(QObject *receiver, const char *member)  | - | 
| 765 | {  | - | 
| 766 |     Q_D(QFileDialog);  | - | 
| 767 |     const char *signal = (fileMode() == ExistingFiles) ? SIGNAL(filesSelected(QStringList))  | - | 
| 768 |                                                        : SIGNAL(fileSelected(QString));  | - | 
| 769 |     connect(this, signal, receiver, member);  | - | 
| 770 |     d->signalToDisconnectOnClose = signal;  | - | 
| 771 |     d->receiverToDisconnectOnClose = receiver;  | - | 
| 772 |     d->memberToDisconnectOnClose = member;  | - | 
| 773 |   | - | 
| 774 |     QDialog::open();  | - | 
| 775 | }  | - | 
| 776 |   | - | 
| 777 |   | - | 
| 778 | /*!  | - | 
| 779 |     \reimp  | - | 
| 780 | */  | - | 
| 781 | void QFileDialog::setVisible(bool visible)  | - | 
| 782 | {  | - | 
| 783 |     Q_D(QFileDialog);  | - | 
| 784 |     if (visible){  | - | 
| 785 |         if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))  | - | 
| 786 |             return;  | - | 
| 787 |     } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))  | - | 
| 788 |         return;  | - | 
| 789 |   | - | 
| 790 |     if (d->canBeNativeDialog()){  | - | 
| 791 |         if (d->setNativeDialogVisible(visible)){  | - | 
| 792 |             // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below  | - | 
| 793 |             // updates the state correctly, but skips showing the non-native version:  | - | 
| 794 |             setAttribute(Qt::WA_DontShowOnScreen);  | - | 
| 795 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 796 |             //So the completer don't try to complete and therefore to show a popup  | - | 
| 797 |             d->completer->setModel(0);  | - | 
| 798 | #endif  | - | 
| 799 |         } else {  | - | 
| 800 |             setAttribute(Qt::WA_DontShowOnScreen, false);  | - | 
| 801 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 802 |             if (d->proxyModel != 0)  | - | 
| 803 |                 d->completer->setModel(d->proxyModel);  | - | 
| 804 |             else  | - | 
| 805 |                 d->completer->setModel(d->model);  | - | 
| 806 | #endif  | - | 
| 807 |         }  | - | 
| 808 |     }  | - | 
| 809 |   | - | 
| 810 |     if (!d->nativeDialogInUse)  | - | 
| 811 |         d->qFileDialogUi->fileNameEdit->setFocus();  | - | 
| 812 |   | - | 
| 813 |     QDialog::setVisible(visible);  | - | 
| 814 | }  | - | 
| 815 |   | - | 
| 816 | /*!  | - | 
| 817 |     \internal  | - | 
| 818 |     set the directory to url  | - | 
| 819 | */  | - | 
| 820 | void QFileDialogPrivate::_q_goToUrl(const QUrl &url)  | - | 
| 821 | {  | - | 
| 822 |     //The shortcut in the side bar may have a parent that is not fetched yet (e.g. an hidden file)  | - | 
| 823 |     //so we force the fetching  | - | 
| 824 |     QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true);  | - | 
| 825 |     QModelIndex idx =  model->d_func()->index(node);  | - | 
| 826 |     _q_enterDirectory(idx);  | - | 
| 827 | }  | - | 
| 828 |   | - | 
| 829 | /*!  | - | 
| 830 |     \fn void QFileDialog::setDirectory(const QDir &directory)  | - | 
| 831 |   | - | 
| 832 |     \overload  | - | 
| 833 | */  | - | 
| 834 |   | - | 
| 835 | /*!  | - | 
| 836 |     Sets the file dialog's current \a directory.  | - | 
| 837 | */  | - | 
| 838 | void QFileDialog::setDirectory(const QString &directory)  | - | 
| 839 | {  | - | 
| 840 |     Q_D(QFileDialog);  | - | 
| 841 |     QString newDirectory = directory;  | - | 
| 842 |     QFileInfo info(directory);  | - | 
| 843 |     //we remove .. and . from the given path if exist  | - | 
| 844 |     if (!directory.isEmpty())  | - | 
| 845 |         newDirectory = QDir::cleanPath(directory);  | - | 
| 846 |   | - | 
| 847 |     if (!directory.isEmpty() && newDirectory.isEmpty())  | - | 
| 848 |         return;  | - | 
| 849 |   | - | 
| 850 |     d->setLastVisitedDirectory(newDirectory);  | - | 
| 851 |   | - | 
| 852 |     if (d->nativeDialogInUse){  | - | 
| 853 |         d->setDirectory_sys(newDirectory);  | - | 
| 854 |         return;  | - | 
| 855 |     }  | - | 
| 856 |     if (d->rootPath() == newDirectory)  | - | 
| 857 |         return;  | - | 
| 858 |     QModelIndex root = d->model->setRootPath(newDirectory);  | - | 
| 859 |     d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled);  | - | 
| 860 |     if (root != d->rootIndex()) {  | - | 
| 861 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 862 |     if (directory.endsWith(QLatin1Char('/')))  | - | 
| 863 |         d->completer->setCompletionPrefix(newDirectory);  | - | 
| 864 |     else  | - | 
| 865 |         d->completer->setCompletionPrefix(newDirectory + QLatin1Char('/'));  | - | 
| 866 | #endif  | - | 
| 867 |         d->setRootIndex(root);  | - | 
| 868 |     }  | - | 
| 869 |     d->qFileDialogUi->listView->selectionModel()->clear();  | - | 
| 870 | }  | - | 
| 871 |   | - | 
| 872 | /*!  | - | 
| 873 |     Returns the directory currently being displayed in the dialog.  | - | 
| 874 | */  | - | 
| 875 | QDir QFileDialog::directory() const  | - | 
| 876 | {  | - | 
| 877 |     Q_D(const QFileDialog);  | - | 
| 878 |     return QDir(d->nativeDialogInUse ? d->directory_sys() : d->rootPath());  | - | 
| 879 | }  | - | 
| 880 |   | - | 
| 881 | /*!  | - | 
| 882 |     Selects the given \a filename in the file dialog.  | - | 
| 883 |   | - | 
| 884 |     \sa selectedFiles()  | - | 
| 885 | */  | - | 
| 886 | void QFileDialog::selectFile(const QString &filename)  | - | 
| 887 | {  | - | 
| 888 |     Q_D(QFileDialog);  | - | 
| 889 |     if (filename.isEmpty())  | - | 
| 890 |         return;  | - | 
| 891 |   | - | 
| 892 |     if (d->nativeDialogInUse){  | - | 
| 893 |         d->selectFile_sys(filename);  | - | 
| 894 |         return;  | - | 
| 895 |     }  | - | 
| 896 |   | - | 
| 897 |     if (!QDir::isRelativePath(filename)) {  | - | 
| 898 |         QFileInfo info(filename);  | - | 
| 899 |         QString filenamePath = info.absoluteDir().path();  | - | 
| 900 |   | - | 
| 901 |         if (d->model->rootPath() != filenamePath)  | - | 
| 902 |             setDirectory(filenamePath);  | - | 
| 903 |     }  | - | 
| 904 |   | - | 
| 905 |     QModelIndex index = d->model->index(filename);  | - | 
| 906 |     QString file;  | - | 
| 907 |     if (!index.isValid()) {  | - | 
| 908 |         // save as dialog where we want to input a default value  | - | 
| 909 |         QString text = filename;  | - | 
| 910 |         if (QFileInfo(filename).isAbsolute()) {  | - | 
| 911 |             QString current = d->rootPath();  | - | 
| 912 |             text.remove(current);  | - | 
| 913 |             if (text.at(0) == QDir::separator()  | - | 
| 914 | #ifdef Q_OS_WIN  | - | 
| 915 |                 //On Windows both cases can happen  | - | 
| 916 |                 || text.at(0) == QLatin1Char('/')  | - | 
| 917 | #endif  | - | 
| 918 |                 )  | - | 
| 919 |                 text = text.remove(0,1);  | - | 
| 920 |         }  | - | 
| 921 |         file = text;  | - | 
| 922 |     } else {  | - | 
| 923 |         file = index.data().toString();  | - | 
| 924 |     }  | - | 
| 925 |     d->qFileDialogUi->listView->selectionModel()->clear();  | - | 
| 926 |     if (!isVisible() || !d->lineEdit()->hasFocus())  | - | 
| 927 |         d->lineEdit()->setText(file);  | - | 
| 928 | }  | - | 
| 929 |   | - | 
| 930 | #ifdef Q_OS_UNIX  | - | 
| 931 | Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path, bool *expanded = 0)  | - | 
| 932 | {  | - | 
| 933 |     if (expanded != 0)  | - | 
| 934 |         *expanded = false;  | - | 
| 935 |     if (!path.startsWith(QLatin1Char('~')))  | - | 
| 936 |         return path;  | - | 
| 937 |     QString ret = path;  | - | 
| 938 |     QStringList tokens = ret.split(QDir::separator());  | - | 
| 939 |     if (tokens.first() == QLatin1String("~")) {  | - | 
| 940 |         ret.replace(0, 1, QDir::homePath());  | - | 
| 941 |     } else {  | - | 
| 942 |         QString userName = tokens.first();  | - | 
| 943 |         userName.remove(0, 1);  | - | 
| 944 | #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)  | - | 
| 945 |         passwd pw;  | - | 
| 946 |         passwd *tmpPw;  | - | 
| 947 |         char buf[200];  | - | 
| 948 |         const int bufSize = sizeof(buf);  | - | 
| 949 |         int err = 0;  | - | 
| 950 | #if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L)  | - | 
| 951 |         tmpPw = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize);  | - | 
| 952 | #else  | - | 
| 953 |         err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw);  | - | 
| 954 | #endif  | - | 
| 955 |         if (err || !tmpPw)  | - | 
| 956 |             return ret;  | - | 
| 957 |         const QString homePath = QString::fromLocal8Bit(pw.pw_dir);  | - | 
| 958 | #else  | - | 
| 959 |         passwd *pw = getpwnam(userName.toLocal8Bit().constData());  | - | 
| 960 |         if (!pw)  | - | 
| 961 |             return ret;  | - | 
| 962 |         const QString homePath = QString::fromLocal8Bit(pw->pw_dir);  | - | 
| 963 | #endif  | - | 
| 964 |         ret.replace(0, tokens.first().length(), homePath);  | - | 
| 965 |     }  | - | 
| 966 |     if (expanded != 0)  | - | 
| 967 |         *expanded = true;  | - | 
| 968 |     return ret;  | - | 
| 969 | }  | - | 
| 970 | #endif  | - | 
| 971 |   | - | 
| 972 | /**  | - | 
| 973 |     Returns the text in the line edit which can be one or more file names  | - | 
| 974 |   */  | - | 
| 975 | QStringList QFileDialogPrivate::typedFiles() const  | - | 
| 976 | {  | - | 
| 977 |     Q_Q(const QFileDialog);  | - | 
| 978 |     QStringList files;  | - | 
| 979 |     QString editText = lineEdit()->text();  | - | 
| 980 |     if (!editText.contains(QLatin1Char('"'))) {  | - | 
| 981 | #ifdef Q_OS_UNIX  | - | 
| 982 |         const QString prefix = q->directory().absolutePath() + QDir::separator();  | - | 
| 983 |         if (QFile::exists(prefix + editText))  | - | 
| 984 |             files << editText;  | - | 
| 985 |         else  | - | 
| 986 |             files << qt_tildeExpansion(editText);  | - | 
| 987 | #else  | - | 
| 988 |         files << editText;  | - | 
| 989 |         Q_UNUSED(q)  | - | 
| 990 | #endif  | - | 
| 991 |     } else {  | - | 
| 992 |         // " is used to separate files like so: "file1" "file2" "file3" ...  | - | 
| 993 |         // ### need escape character for filenames with quotes (")  | - | 
| 994 |         QStringList tokens = editText.split(QLatin1Char('\"'));  | - | 
| 995 |         for (int i=0; i<tokens.size(); ++i) {  | - | 
| 996 |             if ((i % 2) == 0)  | - | 
| 997 |                 continue; // Every even token is a separator  | - | 
| 998 | #ifdef Q_OS_UNIX  | - | 
| 999 |             const QString token = tokens.at(i);  | - | 
| 1000 |             const QString prefix = q->directory().absolutePath() + QDir::separator();  | - | 
| 1001 |             if (QFile::exists(prefix + token))  | - | 
| 1002 |                 files << token;  | - | 
| 1003 |             else  | - | 
| 1004 |                 files << qt_tildeExpansion(token);  | - | 
| 1005 | #else  | - | 
| 1006 |             files << toInternal(tokens.at(i));  | - | 
| 1007 | #endif  | - | 
| 1008 |         }  | - | 
| 1009 |     }  | - | 
| 1010 |     return addDefaultSuffixToFiles(files);  | - | 
| 1011 | }  | - | 
| 1012 |   | - | 
| 1013 | // Return selected files without defaulting to the root of the file system model  | - | 
| 1014 | // used for initializing QFileDialogOptions for native dialogs. The default is  | - | 
| 1015 | // not suitable for native dialogs since it mostly equals directory().  | - | 
| 1016 | QStringList QFileDialogPrivate::userSelectedFiles() const  | - | 
| 1017 | {  | - | 
| 1018 |     if (nativeDialogInUse)  | - | 
| 1019 |         return addDefaultSuffixToFiles(selectedFiles_sys());  | - | 
| 1020 |   | - | 
| 1021 |     QStringList files;  | - | 
| 1022 |     foreach (const QModelIndex &index, qFileDialogUi->listView->selectionModel()->selectedRows())  | - | 
| 1023 |         files.append(index.data(QFileSystemModel::FilePathRole).toString());  | - | 
| 1024 |   | - | 
| 1025 |     if (files.isEmpty() && !lineEdit()->text().isEmpty())  | - | 
| 1026 |         files = typedFiles();  | - | 
| 1027 |   | - | 
| 1028 |     return files;  | - | 
| 1029 | }  | - | 
| 1030 |   | - | 
| 1031 | QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList filesToFix) const  | - | 
| 1032 | {  | - | 
| 1033 |     QStringList files;  | - | 
| 1034 |     for (int i=0; i<filesToFix.size(); ++i) {  | - | 
| 1035 |         QString name = toInternal(filesToFix.at(i));  | - | 
| 1036 |         QFileInfo info(name);  | - | 
| 1037 |         // if the filename has no suffix, add the default suffix  | - | 
| 1038 |         const QString defaultSuffix = options->defaultSuffix();  | - | 
| 1039 |         if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1)  | - | 
| 1040 |             name += QLatin1Char('.') + defaultSuffix;  | - | 
| 1041 |         if (info.isAbsolute()) {  | - | 
| 1042 |             files.append(name);  | - | 
| 1043 |         } else {  | - | 
| 1044 |             // at this point the path should only have Qt path separators.  | - | 
| 1045 |             // This check is needed since we might be at the root directory  | - | 
| 1046 |             // and on Windows it already ends with slash.  | - | 
| 1047 |             QString path = rootPath();  | - | 
| 1048 |             if (!path.endsWith(QLatin1Char('/')))  | - | 
| 1049 |                 path += QLatin1Char('/');  | - | 
| 1050 |             path += name;  | - | 
| 1051 |             files.append(path);  | - | 
| 1052 |         }  | - | 
| 1053 |     }  | - | 
| 1054 |     return files;  | - | 
| 1055 | }  | - | 
| 1056 |   | - | 
| 1057 |   | - | 
| 1058 | /*!  | - | 
| 1059 |     Returns a list of strings containing the absolute paths of the  | - | 
| 1060 |     selected files in the dialog. If no files are selected, or  | - | 
| 1061 |     the mode is not ExistingFiles or ExistingFile, selectedFiles() contains the current path in the viewport.  | - | 
| 1062 |   | - | 
| 1063 |     \sa selectedNameFilter(), selectFile()  | - | 
| 1064 | */  | - | 
| 1065 | QStringList QFileDialog::selectedFiles() const  | - | 
| 1066 | {  | - | 
| 1067 |     Q_D(const QFileDialog);  | - | 
| 1068 |   | - | 
| 1069 |     QStringList files = d->userSelectedFiles();  | - | 
| 1070 |     if (files.isEmpty()) {  | - | 
| 1071 |         const FileMode fm = fileMode();  | - | 
| 1072 |         if (fm != ExistingFile && fm != ExistingFiles)  | - | 
| 1073 |             files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString());  | - | 
| 1074 |     }  | - | 
| 1075 |     return files;  | - | 
| 1076 | }  | - | 
| 1077 |   | - | 
| 1078 | /*  | - | 
| 1079 |     Makes a list of filters from ;;-separated text.  | - | 
| 1080 |     Used by the mac and windows implementations  | - | 
| 1081 | */  | - | 
| 1082 | QStringList qt_make_filter_list(const QString &filter)  | - | 
| 1083 | {  | - | 
| 1084 |     QString f(filter);  | - | 
| 1085 |   | - | 
| 1086 |     if (f.isEmpty())  | - | 
| 1087 |         return QStringList();  | - | 
| 1088 |   | - | 
| 1089 |     QString sep(QLatin1String(";;"));  | - | 
| 1090 |     int i = f.indexOf(sep, 0);  | - | 
| 1091 |     if (i == -1) {  | - | 
| 1092 |         if (f.indexOf(QLatin1Char('\n'), 0) != -1) {  | - | 
| 1093 |             sep = QLatin1Char('\n');  | - | 
| 1094 |             i = f.indexOf(sep, 0);  | - | 
| 1095 |         }  | - | 
| 1096 |     }  | - | 
| 1097 |   | - | 
| 1098 |     return f.split(sep);  | - | 
| 1099 | }  | - | 
| 1100 |   | - | 
| 1101 | /*!  | - | 
| 1102 |     \since 4.4  | - | 
| 1103 |   | - | 
| 1104 |     Sets the filter used in the file dialog to the given \a filter.  | - | 
| 1105 |   | - | 
| 1106 |     If \a filter contains a pair of parentheses containing one or more  | - | 
| 1107 |     of \b{anything*something}, separated by spaces, then only the  | - | 
| 1108 |     text contained in the parentheses is used as the filter. This means  | - | 
| 1109 |     that these calls are all equivalent:  | - | 
| 1110 |   | - | 
| 1111 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 6  | - | 
| 1112 |   | - | 
| 1113 |     \sa setNameFilters()  | - | 
| 1114 | */  | - | 
| 1115 | void QFileDialog::setNameFilter(const QString &filter)  | - | 
| 1116 | {  | - | 
| 1117 |     setNameFilters(qt_make_filter_list(filter));  | - | 
| 1118 | }  | - | 
| 1119 |   | - | 
| 1120 |   | - | 
| 1121 | /*!  | - | 
| 1122 |     \property QFileDialog::nameFilterDetailsVisible  | - | 
| 1123 |     \obsolete  | - | 
| 1124 |     \brief This property holds whether the filter details is shown or not.  | - | 
| 1125 |     \since 4.4  | - | 
| 1126 |   | - | 
| 1127 |     When this property is true (the default), the filter details are shown  | - | 
| 1128 |     in the combo box.  When the property is set to false, these are hidden.  | - | 
| 1129 |   | - | 
| 1130 |     Use setOption(HideNameFilterDetails, !\e enabled) or  | - | 
| 1131 |     !testOption(HideNameFilterDetails).  | - | 
| 1132 | */  | - | 
| 1133 | void QFileDialog::setNameFilterDetailsVisible(bool enabled)  | - | 
| 1134 | {  | - | 
| 1135 |     setOption(HideNameFilterDetails, !enabled);  | - | 
| 1136 | }  | - | 
| 1137 |   | - | 
| 1138 | bool QFileDialog::isNameFilterDetailsVisible() const  | - | 
| 1139 | {  | - | 
| 1140 |     return !testOption(HideNameFilterDetails);  | - | 
| 1141 | }  | - | 
| 1142 |   | - | 
| 1143 |   | - | 
| 1144 | /*  | - | 
| 1145 |     Strip the filters by removing the details, e.g. (*.*).  | - | 
| 1146 | */  | - | 
| 1147 | QStringList qt_strip_filters(const QStringList &filters)  | - | 
| 1148 | {  | - | 
| 1149 |     QStringList strippedFilters;  | - | 
| 1150 |     QRegExp r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));  | - | 
| 1151 |     for (int i = 0; i < filters.count(); ++i) {  | - | 
| 1152 |         QString filterName;  | - | 
| 1153 |         int index = r.indexIn(filters[i]);  | - | 
| 1154 |         if (index >= 0)  | - | 
| 1155 |             filterName = r.cap(1);  | - | 
| 1156 |         strippedFilters.append(filterName.simplified());  | - | 
| 1157 |     }  | - | 
| 1158 |     return strippedFilters;  | - | 
| 1159 | }  | - | 
| 1160 |   | - | 
| 1161 |   | - | 
| 1162 | /*!  | - | 
| 1163 |     \since 4.4  | - | 
| 1164 |   | - | 
| 1165 |     Sets the \a filters used in the file dialog.  | - | 
| 1166 |   | - | 
| 1167 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 7  | - | 
| 1168 | */  | - | 
| 1169 | void QFileDialog::setNameFilters(const QStringList &filters)  | - | 
| 1170 | {  | - | 
| 1171 |     Q_D(QFileDialog);  | - | 
| 1172 |     d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));  | - | 
| 1173 |     QStringList cleanedFilters;  | - | 
| 1174 |     for (int i = 0; i < filters.count(); ++i) {  | - | 
| 1175 |         cleanedFilters << filters[i].simplified();  | - | 
| 1176 |     }  | - | 
| 1177 |     d->options->setNameFilters(cleanedFilters);  | - | 
| 1178 |   | - | 
| 1179 |     d->qFileDialogUi->fileTypeCombo->clear();  | - | 
| 1180 |     if (cleanedFilters.isEmpty())  | - | 
| 1181 |         return;  | - | 
| 1182 |   | - | 
| 1183 |     if (testOption(HideNameFilterDetails))  | - | 
| 1184 |         d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters));  | - | 
| 1185 |     else  | - | 
| 1186 |         d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);  | - | 
| 1187 |   | - | 
| 1188 |     d->_q_useNameFilter(0);  | - | 
| 1189 | }  | - | 
| 1190 |   | - | 
| 1191 | /*!  | - | 
| 1192 |     \since 4.4  | - | 
| 1193 |   | - | 
| 1194 |     Returns the file type filters that are in operation on this file  | - | 
| 1195 |     dialog.  | - | 
| 1196 | */  | - | 
| 1197 | QStringList QFileDialog::nameFilters() const  | - | 
| 1198 | {  | - | 
| 1199 |     return d_func()->options->nameFilters();  | - | 
| 1200 | }  | - | 
| 1201 |   | - | 
| 1202 | /*!  | - | 
| 1203 |     \since 4.4  | - | 
| 1204 |   | - | 
| 1205 |     Sets the current file type \a filter. Multiple filters can be  | - | 
| 1206 |     passed in \a filter by separating them with semicolons or spaces.  | - | 
| 1207 |   | - | 
| 1208 |     \sa setNameFilter(), setNameFilters(), selectedNameFilter()  | - | 
| 1209 | */  | - | 
| 1210 | void QFileDialog::selectNameFilter(const QString &filter)  | - | 
| 1211 | {  | - | 
| 1212 |     Q_D(QFileDialog);  | - | 
| 1213 |     if (d->nativeDialogInUse) {  | - | 
| 1214 |         d->selectNameFilter_sys(filter);  | - | 
| 1215 |         return;  | - | 
| 1216 |     }  | - | 
| 1217 |     int i = -1;  | - | 
| 1218 |     if (testOption(HideNameFilterDetails)) {  | - | 
| 1219 |         const QStringList filters = qt_strip_filters(qt_make_filter_list(filter));  | - | 
| 1220 |         if (!filters.isEmpty())  | - | 
| 1221 |             i = d->qFileDialogUi->fileTypeCombo->findText(filters.first());  | - | 
| 1222 |     } else {  | - | 
| 1223 |         i = d->qFileDialogUi->fileTypeCombo->findText(filter);  | - | 
| 1224 |     }  | - | 
| 1225 |     if (i >= 0) {  | - | 
| 1226 |         d->qFileDialogUi->fileTypeCombo->setCurrentIndex(i);  | - | 
| 1227 |         d->_q_useNameFilter(d->qFileDialogUi->fileTypeCombo->currentIndex());  | - | 
| 1228 |     }  | - | 
| 1229 | }  | - | 
| 1230 |   | - | 
| 1231 | /*!  | - | 
| 1232 |     \since 4.4  | - | 
| 1233 |   | - | 
| 1234 |     Returns the filter that the user selected in the file dialog.  | - | 
| 1235 |   | - | 
| 1236 |     \sa selectedFiles()  | - | 
| 1237 | */  | - | 
| 1238 | QString QFileDialog::selectedNameFilter() const  | - | 
| 1239 | {  | - | 
| 1240 |     Q_D(const QFileDialog);  | - | 
| 1241 |     if (d->nativeDialogInUse)  | - | 
| 1242 |         return d->selectedNameFilter_sys();  | - | 
| 1243 |   | - | 
| 1244 |     return d->qFileDialogUi->fileTypeCombo->currentText();  | - | 
| 1245 | }  | - | 
| 1246 |   | - | 
| 1247 | /*!  | - | 
| 1248 |     \since 4.4  | - | 
| 1249 |   | - | 
| 1250 |     Returns the filter that is used when displaying files.  | - | 
| 1251 |   | - | 
| 1252 |     \sa setFilter()  | - | 
| 1253 | */  | - | 
| 1254 | QDir::Filters QFileDialog::filter() const  | - | 
| 1255 | {  | - | 
| 1256 |     Q_D(const QFileDialog);  | - | 
| 1257 |     return d->model->filter();  | - | 
| 1258 | }  | - | 
| 1259 |   | - | 
| 1260 | /*!  | - | 
| 1261 |     \since 4.4  | - | 
| 1262 |   | - | 
| 1263 |     Sets the filter used by the model to \a filters. The filter is used  | - | 
| 1264 |     to specify the kind of files that should be shown.  | - | 
| 1265 |   | - | 
| 1266 |     \sa filter()  | - | 
| 1267 | */  | - | 
| 1268 |   | - | 
| 1269 | void QFileDialog::setFilter(QDir::Filters filters)  | - | 
| 1270 | {  | - | 
| 1271 |     Q_D(QFileDialog);  | - | 
| 1272 |     d->model->setFilter(filters);  | - | 
| 1273 |     d->options->setFilter(filters);  | - | 
| 1274 |     if (d->nativeDialogInUse){  | - | 
| 1275 |         d->setFilter_sys();  | - | 
| 1276 |         return;  | - | 
| 1277 |     }  | - | 
| 1278 |   | - | 
| 1279 |     d->showHiddenAction->setChecked((filters & QDir::Hidden));  | - | 
| 1280 | }  | - | 
| 1281 |   | - | 
| 1282 | /*!  | - | 
| 1283 |     \property QFileDialog::viewMode  | - | 
| 1284 |     \brief the way files and directories are displayed in the dialog  | - | 
| 1285 |   | - | 
| 1286 |     By default, the \c Detail mode is used to display information about  | - | 
| 1287 |     files and directories.  | - | 
| 1288 |   | - | 
| 1289 |     \sa ViewMode  | - | 
| 1290 | */  | - | 
| 1291 | void QFileDialog::setViewMode(QFileDialog::ViewMode mode)  | - | 
| 1292 | {  | - | 
| 1293 |     Q_D(QFileDialog);  | - | 
| 1294 |     if (mode == Detail)  | - | 
| 1295 |         d->_q_showDetailsView();  | - | 
| 1296 |     else  | - | 
| 1297 |         d->_q_showListView();  | - | 
| 1298 | }  | - | 
| 1299 |   | - | 
| 1300 | QFileDialog::ViewMode QFileDialog::viewMode() const  | - | 
| 1301 | {  | - | 
| 1302 |     Q_D(const QFileDialog);  | - | 
| 1303 |     return (d->qFileDialogUi->stackedWidget->currentWidget() == d->qFileDialogUi->listView->parent() ? QFileDialog::List : QFileDialog::Detail);  | - | 
| 1304 | }  | - | 
| 1305 |   | - | 
| 1306 | /*!  | - | 
| 1307 |     \property QFileDialog::fileMode  | - | 
| 1308 |     \brief the file mode of the dialog  | - | 
| 1309 |   | - | 
| 1310 |     The file mode defines the number and type of items that the user is  | - | 
| 1311 |     expected to select in the dialog.  | - | 
| 1312 |   | - | 
| 1313 |     By default, this property is set to AnyFile.  | - | 
| 1314 |   | - | 
| 1315 |     This function will set the labels for the FileName and  | - | 
| 1316 |     \l{QFileDialog::}{Accept} \l{DialogLabel}s. It is possible to set  | - | 
| 1317 |     custom text after the call to setFileMode().  | - | 
| 1318 |   | - | 
| 1319 |     \sa FileMode  | - | 
| 1320 | */  | - | 
| 1321 | void QFileDialog::setFileMode(QFileDialog::FileMode mode)  | - | 
| 1322 | {  | - | 
| 1323 |     Q_D(QFileDialog);  | - | 
| 1324 |     d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode));  | - | 
| 1325 |     d->retranslateWindowTitle();  | - | 
| 1326 |   | - | 
| 1327 |     // keep ShowDirsOnly option in sync with fileMode (BTW, DirectoryOnly is obsolete)  | - | 
| 1328 |     setOption(ShowDirsOnly, mode == DirectoryOnly);  | - | 
| 1329 |   | - | 
| 1330 |     // set selection mode and behavior  | - | 
| 1331 |     QAbstractItemView::SelectionMode selectionMode;  | - | 
| 1332 |     if (mode == QFileDialog::ExistingFiles)  | - | 
| 1333 |         selectionMode = QAbstractItemView::ExtendedSelection;  | - | 
| 1334 |     else  | - | 
| 1335 |         selectionMode = QAbstractItemView::SingleSelection;  | - | 
| 1336 |     d->qFileDialogUi->listView->setSelectionMode(selectionMode);  | - | 
| 1337 |     d->qFileDialogUi->treeView->setSelectionMode(selectionMode);  | - | 
| 1338 |     // set filter  | - | 
| 1339 |     d->model->setFilter(d->filterForMode(filter()));  | - | 
| 1340 |     // setup file type for directory  | - | 
| 1341 |     if (mode == DirectoryOnly || mode == Directory) {  | - | 
| 1342 |         d->qFileDialogUi->fileTypeCombo->clear();  | - | 
| 1343 |         d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories"));  | - | 
| 1344 |         d->qFileDialogUi->fileTypeCombo->setEnabled(false);  | - | 
| 1345 |     }  | - | 
| 1346 |     d->updateFileNameLabel();  | - | 
| 1347 |     d->updateOkButtonText();  | - | 
| 1348 |     if (d->nativeDialogInUse){  | - | 
| 1349 |         d->setFilter_sys();  | - | 
| 1350 |         return;  | - | 
| 1351 |     }  | - | 
| 1352 |   | - | 
| 1353 |     d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly));  | - | 
| 1354 |     d->_q_updateOkButton();  | - | 
| 1355 | }  | - | 
| 1356 |   | - | 
| 1357 | QFileDialog::FileMode QFileDialog::fileMode() const  | - | 
| 1358 | {  | - | 
| 1359 |     Q_D(const QFileDialog);  | - | 
| 1360 |     return static_cast<FileMode>(d->options->fileMode());  | - | 
| 1361 | }  | - | 
| 1362 |   | - | 
| 1363 | /*!  | - | 
| 1364 |     \property QFileDialog::acceptMode  | - | 
| 1365 |     \brief the accept mode of the dialog  | - | 
| 1366 |   | - | 
| 1367 |     The action mode defines whether the dialog is for opening or saving files.  | - | 
| 1368 |   | - | 
| 1369 |     By default, this property is set to \l{AcceptOpen}.  | - | 
| 1370 |   | - | 
| 1371 |     \sa AcceptMode  | - | 
| 1372 | */  | - | 
| 1373 | void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode)  | - | 
| 1374 | {  | - | 
| 1375 |     Q_D(QFileDialog);  | - | 
| 1376 |     d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode));  | - | 
| 1377 |     QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save);  | - | 
| 1378 |     d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel);  | - | 
| 1379 |     d->qFileDialogUi->buttonBox->button(button)->setEnabled(false);  | - | 
| 1380 |     d->_q_updateOkButton();  | - | 
| 1381 |     if (mode == AcceptSave) {  | - | 
| 1382 |         d->qFileDialogUi->lookInCombo->setEditable(false);  | - | 
| 1383 |     }  | - | 
| 1384 |     d->retranslateWindowTitle();  | - | 
| 1385 |     // we need to recreate the native dialog when changing the AcceptMode  | - | 
| 1386 |     d->deletePlatformHelper();  | - | 
| 1387 |     // clear WA_DontShowOnScreen so that d->canBeNativeDialog() doesn't return false incorrectly  | - | 
| 1388 |     setAttribute(Qt::WA_DontShowOnScreen, false);  | - | 
| 1389 | }  | - | 
| 1390 |   | - | 
| 1391 | /*  | - | 
| 1392 |     Returns the file system model index that is the root index in the  | - | 
| 1393 |     views  | - | 
| 1394 | */  | - | 
| 1395 | QModelIndex QFileDialogPrivate::rootIndex() const {  | - | 
| 1396 |     return mapToSource(qFileDialogUi->listView->rootIndex());  | - | 
| 1397 | }  | - | 
| 1398 |   | - | 
| 1399 | QAbstractItemView *QFileDialogPrivate::currentView() const {  | - | 
| 1400 |     if (!qFileDialogUi->stackedWidget)  | - | 
| 1401 |         return 0;  | - | 
| 1402 |     if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent())  | - | 
| 1403 |         return qFileDialogUi->listView;  | - | 
| 1404 |     return qFileDialogUi->treeView;  | - | 
| 1405 | }  | - | 
| 1406 |   | - | 
| 1407 | QLineEdit *QFileDialogPrivate::lineEdit() const {  | - | 
| 1408 |     return (QLineEdit*)qFileDialogUi->fileNameEdit;  | - | 
| 1409 | }  | - | 
| 1410 |   | - | 
| 1411 | int QFileDialogPrivate::maxNameLength(const QString &path)  | - | 
| 1412 | {  | - | 
| 1413 | #if defined(Q_OS_UNIX)  | - | 
| 1414 |     return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);  | - | 
| 1415 | #elif defined(Q_OS_WINCE)  | - | 
| 1416 |     Q_UNUSED(path);  | - | 
| 1417 |     return MAX_PATH;  | - | 
| 1418 | #elif defined(Q_OS_WIN)  | - | 
| 1419 |     DWORD maxLength;  | - | 
| 1420 |     const QString drive = path.left(3);  | - | 
| 1421 |     if (::GetVolumeInformation(reinterpret_cast<const wchar_t *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0) == false)  | - | 
| 1422 |         return -1;  | - | 
| 1423 |     return maxLength;  | - | 
| 1424 | #else  | - | 
| 1425 |     Q_UNUSED(path);  | - | 
| 1426 | #endif  | - | 
| 1427 |     return -1;  | - | 
| 1428 | }  | - | 
| 1429 |   | - | 
| 1430 | /*  | - | 
| 1431 |     Sets the view root index to be the file system model index  | - | 
| 1432 | */  | - | 
| 1433 | void QFileDialogPrivate::setRootIndex(const QModelIndex &index) const {  | - | 
| 1434 |     Q_ASSERT(index.isValid() ? index.model() == model : true);  | - | 
| 1435 |     QModelIndex idx = mapFromSource(index);  | - | 
| 1436 |     qFileDialogUi->treeView->setRootIndex(idx);  | - | 
| 1437 |     qFileDialogUi->listView->setRootIndex(idx);  | - | 
| 1438 | }  | - | 
| 1439 | /*  | - | 
| 1440 |     Select a file system model index  | - | 
| 1441 |     returns the index that was selected (or not depending upon sortfilterproxymodel)  | - | 
| 1442 | */  | - | 
| 1443 | QModelIndex QFileDialogPrivate::select(const QModelIndex &index) const {  | - | 
| 1444 |     Q_ASSERT(index.isValid() ? index.model() == model : true);  | - | 
| 1445 |   | - | 
| 1446 |     QModelIndex idx = mapFromSource(index);  | - | 
| 1447 |     if (idx.isValid() && !qFileDialogUi->listView->selectionModel()->isSelected(idx))  | - | 
| 1448 |         qFileDialogUi->listView->selectionModel()->select(idx,  | - | 
| 1449 |             QItemSelectionModel::Select | QItemSelectionModel::Rows);  | - | 
| 1450 |     return idx;  | - | 
| 1451 | }  | - | 
| 1452 |   | - | 
| 1453 | QFileDialog::AcceptMode QFileDialog::acceptMode() const  | - | 
| 1454 | {  | - | 
| 1455 |     Q_D(const QFileDialog);  | - | 
| 1456 |     return static_cast<AcceptMode>(d->options->acceptMode());  | - | 
| 1457 | }  | - | 
| 1458 |   | - | 
| 1459 | /*!  | - | 
| 1460 |     \property QFileDialog::readOnly  | - | 
| 1461 |     \obsolete  | - | 
| 1462 |     \brief Whether the filedialog is read-only  | - | 
| 1463 |   | - | 
| 1464 |     If this property is set to false, the file dialog will allow renaming,  | - | 
| 1465 |     and deleting of files and directories and creating directories.  | - | 
| 1466 |   | - | 
| 1467 |     Use setOption(ReadOnly, \e enabled) or testOption(ReadOnly) instead.  | - | 
| 1468 | */  | - | 
| 1469 | void QFileDialog::setReadOnly(bool enabled)  | - | 
| 1470 | {  | - | 
| 1471 |     setOption(ReadOnly, enabled);  | - | 
| 1472 | }  | - | 
| 1473 |   | - | 
| 1474 | bool QFileDialog::isReadOnly() const  | - | 
| 1475 | {  | - | 
| 1476 |     return testOption(ReadOnly);  | - | 
| 1477 | }  | - | 
| 1478 |   | - | 
| 1479 | /*!  | - | 
| 1480 |     \property QFileDialog::resolveSymlinks  | - | 
| 1481 |     \obsolete  | - | 
| 1482 |     \brief whether the filedialog should resolve shortcuts  | - | 
| 1483 |   | - | 
| 1484 |     If this property is set to true, the file dialog will resolve  | - | 
| 1485 |     shortcuts or symbolic links.  | - | 
| 1486 |   | - | 
| 1487 |     Use setOption(DontResolveSymlinks, !\a enabled) or  | - | 
| 1488 |     !testOption(DontResolveSymlinks).  | - | 
| 1489 | */  | - | 
| 1490 | void QFileDialog::setResolveSymlinks(bool enabled)  | - | 
| 1491 | {  | - | 
| 1492 |     setOption(DontResolveSymlinks, !enabled);  | - | 
| 1493 | }  | - | 
| 1494 |   | - | 
| 1495 | bool QFileDialog::resolveSymlinks() const  | - | 
| 1496 | {  | - | 
| 1497 |     return !testOption(DontResolveSymlinks);  | - | 
| 1498 | }  | - | 
| 1499 |   | - | 
| 1500 | /*!  | - | 
| 1501 |     \property QFileDialog::confirmOverwrite  | - | 
| 1502 |     \obsolete  | - | 
| 1503 |     \brief whether the filedialog should ask before accepting a selected file,  | - | 
| 1504 |     when the accept mode is AcceptSave  | - | 
| 1505 |   | - | 
| 1506 |     Use setOption(DontConfirmOverwrite, !\e enabled) or  | - | 
| 1507 |     !testOption(DontConfirmOverwrite) instead.  | - | 
| 1508 | */  | - | 
| 1509 | void QFileDialog::setConfirmOverwrite(bool enabled)  | - | 
| 1510 | {  | - | 
| 1511 |     setOption(DontConfirmOverwrite, !enabled);  | - | 
| 1512 | }  | - | 
| 1513 |   | - | 
| 1514 | bool QFileDialog::confirmOverwrite() const  | - | 
| 1515 | {  | - | 
| 1516 |     return !testOption(DontConfirmOverwrite);  | - | 
| 1517 | }  | - | 
| 1518 |   | - | 
| 1519 | /*!  | - | 
| 1520 |     \property QFileDialog::defaultSuffix  | - | 
| 1521 |     \brief suffix added to the filename if no other suffix was specified  | - | 
| 1522 |   | - | 
| 1523 |     This property specifies a string that will be added to the  | - | 
| 1524 |     filename if it has no suffix already. The suffix is typically  | - | 
| 1525 |     used to indicate the file type (e.g. "txt" indicates a text  | - | 
| 1526 |     file).  | - | 
| 1527 | */  | - | 
| 1528 | void QFileDialog::setDefaultSuffix(const QString &suffix)  | - | 
| 1529 | {  | - | 
| 1530 |     Q_D(QFileDialog);  | - | 
| 1531 |     d->options->setDefaultSuffix(suffix);  | - | 
| 1532 | }  | - | 
| 1533 |   | - | 
| 1534 | QString QFileDialog::defaultSuffix() const  | - | 
| 1535 | {  | - | 
| 1536 |     Q_D(const QFileDialog);  | - | 
| 1537 |     return d->options->defaultSuffix();  | - | 
| 1538 | }  | - | 
| 1539 |   | - | 
| 1540 | /*!  | - | 
| 1541 |     Sets the browsing history of the filedialog to contain the given  | - | 
| 1542 |     \a paths.  | - | 
| 1543 | */  | - | 
| 1544 | void QFileDialog::setHistory(const QStringList &paths)  | - | 
| 1545 | {  | - | 
| 1546 |     Q_D(QFileDialog);  | - | 
| 1547 |     d->qFileDialogUi->lookInCombo->setHistory(paths);  | - | 
| 1548 | }  | - | 
| 1549 |   | - | 
| 1550 | void QFileDialogComboBox::setHistory(const QStringList &paths)  | - | 
| 1551 | {  | - | 
| 1552 |     m_history = paths;  | - | 
| 1553 |     // Only populate the first item, showPopup will populate the rest if needed  | - | 
| 1554 |     QList<QUrl> list;  | - | 
| 1555 |     QModelIndex idx = d_ptr->model->index(d_ptr->rootPath());  | - | 
| 1556 |     //On windows the popup display the "C:\", convert to nativeSeparators  | - | 
| 1557 |     QUrl url = QUrl::fromLocalFile(QDir::toNativeSeparators(idx.data(QFileSystemModel::FilePathRole).toString()));  | - | 
| 1558 |     if (url.isValid())  | - | 
| 1559 |         list.append(url);  | - | 
| 1560 |     urlModel->setUrls(list);  | - | 
| 1561 | }  | - | 
| 1562 |   | - | 
| 1563 | /*!  | - | 
| 1564 |     Returns the browsing history of the filedialog as a list of paths.  | - | 
| 1565 | */  | - | 
| 1566 | QStringList QFileDialog::history() const  | - | 
| 1567 | {  | - | 
| 1568 |     Q_D(const QFileDialog);  | - | 
| 1569 |     QStringList currentHistory = d->qFileDialogUi->lookInCombo->history();  | - | 
| 1570 |     //On windows the popup display the "C:\", convert to nativeSeparators  | - | 
| 1571 |     QString newHistory = QDir::toNativeSeparators(d->rootIndex().data(QFileSystemModel::FilePathRole).toString());  | - | 
| 1572 |     if (!currentHistory.contains(newHistory))  | - | 
| 1573 |         currentHistory << newHistory;  | - | 
| 1574 |     return currentHistory;  | - | 
| 1575 | }  | - | 
| 1576 |   | - | 
| 1577 | /*!  | - | 
| 1578 |     Sets the item delegate used to render items in the views in the  | - | 
| 1579 |     file dialog to the given \a delegate.  | - | 
| 1580 |   | - | 
| 1581 |     \warning You should not share the same instance of a delegate between views.  | - | 
| 1582 |     Doing so can cause incorrect or unintuitive editing behavior since each  | - | 
| 1583 |     view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()}  | - | 
| 1584 |     signal, and attempt to access, modify or close an editor that has already been closed.  | - | 
| 1585 |   | - | 
| 1586 |     Note that the model used is QFileSystemModel. It has custom item data roles, which is  | - | 
| 1587 |     described by the \l{QFileSystemModel::}{Roles} enum. You can use a QFileIconProvider if  | - | 
| 1588 |     you only want custom icons.  | - | 
| 1589 |   | - | 
| 1590 |     \sa itemDelegate(), setIconProvider(), QFileSystemModel  | - | 
| 1591 | */  | - | 
| 1592 | void QFileDialog::setItemDelegate(QAbstractItemDelegate *delegate)  | - | 
| 1593 | {  | - | 
| 1594 |     Q_D(QFileDialog);  | - | 
| 1595 |     d->qFileDialogUi->listView->setItemDelegate(delegate);  | - | 
| 1596 |     d->qFileDialogUi->treeView->setItemDelegate(delegate);  | - | 
| 1597 | }  | - | 
| 1598 |   | - | 
| 1599 | /*!  | - | 
| 1600 |   Returns the item delegate used to render the items in the views in the filedialog.  | - | 
| 1601 | */  | - | 
| 1602 | QAbstractItemDelegate *QFileDialog::itemDelegate() const  | - | 
| 1603 | {  | - | 
| 1604 |     Q_D(const QFileDialog);  | - | 
| 1605 |     return d->qFileDialogUi->listView->itemDelegate();  | - | 
| 1606 | }  | - | 
| 1607 |   | - | 
| 1608 | /*!  | - | 
| 1609 |     Sets the icon provider used by the filedialog to the specified \a provider.  | - | 
| 1610 | */  | - | 
| 1611 | void QFileDialog::setIconProvider(QFileIconProvider *provider)  | - | 
| 1612 | {  | - | 
| 1613 |     Q_D(QFileDialog);  | - | 
| 1614 |     d->model->setIconProvider(provider);  | - | 
| 1615 |     //It forces the refresh of all entries in the side bar, then we can get new icons  | - | 
| 1616 |     d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls());  | - | 
| 1617 | }  | - | 
| 1618 |   | - | 
| 1619 | /*!  | - | 
| 1620 |     Returns the icon provider used by the filedialog.  | - | 
| 1621 | */  | - | 
| 1622 | QFileIconProvider *QFileDialog::iconProvider() const  | - | 
| 1623 | {  | - | 
| 1624 |     Q_D(const QFileDialog);  | - | 
| 1625 |     return d->model->iconProvider();  | - | 
| 1626 | }  | - | 
| 1627 |   | - | 
| 1628 | void QFileDialogPrivate::setLabelTextControl(QFileDialog::DialogLabel label, const QString &text)  | - | 
| 1629 | {  | - | 
| 1630 |     switch (label) {  | - | 
| 1631 |     case QFileDialog::LookIn:  | - | 
| 1632 |         qFileDialogUi->lookInLabel->setText(text);  | - | 
| 1633 |         break;  | - | 
| 1634 |     case QFileDialog::FileName:  | - | 
| 1635 |         qFileDialogUi->fileNameLabel->setText(text);  | - | 
| 1636 |         break;  | - | 
| 1637 |     case QFileDialog::FileType:  | - | 
| 1638 |         qFileDialogUi->fileTypeLabel->setText(text);  | - | 
| 1639 |         break;  | - | 
| 1640 |     case QFileDialog::Accept:  | - | 
| 1641 |         if (q_func()->acceptMode() == QFileDialog::AcceptOpen) {  | - | 
| 1642 |             if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open))  | - | 
| 1643 |                 button->setText(text);  | - | 
| 1644 |         } else {  | - | 
| 1645 |             if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save))  | - | 
| 1646 |                 button->setText(text);  | - | 
| 1647 |         }  | - | 
| 1648 |         break;  | - | 
| 1649 |     case QFileDialog::Reject:  | - | 
| 1650 |         if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel))  | - | 
| 1651 |             button->setText(text);  | - | 
| 1652 |         break;  | - | 
| 1653 |     }  | - | 
| 1654 | }  | - | 
| 1655 |   | - | 
| 1656 | /*!  | - | 
| 1657 |     Sets the \a text shown in the filedialog in the specified \a label.  | - | 
| 1658 | */  | - | 
| 1659 |   | - | 
| 1660 | void QFileDialog::setLabelText(DialogLabel label, const QString &text)  | - | 
| 1661 | {  | - | 
| 1662 |     Q_D(QFileDialog);  | - | 
| 1663 |     d->options->setLabelText(static_cast<QFileDialogOptions::DialogLabel>(label), text);  | - | 
| 1664 |     d->setLabelTextControl(label, text);  | - | 
| 1665 | }  | - | 
| 1666 |   | - | 
| 1667 | /*!  | - | 
| 1668 |     Returns the text shown in the filedialog in the specified \a label.  | - | 
| 1669 | */  | - | 
| 1670 | QString QFileDialog::labelText(DialogLabel label) const  | - | 
| 1671 | {  | - | 
| 1672 |     QPushButton *button;  | - | 
| 1673 |     Q_D(const QFileDialog);  | - | 
| 1674 |     switch (label) {  | - | 
| 1675 |     case LookIn:  | - | 
| 1676 |         return d->qFileDialogUi->lookInLabel->text();  | - | 
| 1677 |     case FileName:  | - | 
| 1678 |         return d->qFileDialogUi->fileNameLabel->text();  | - | 
| 1679 |     case FileType:  | - | 
| 1680 |         return d->qFileDialogUi->fileTypeLabel->text();  | - | 
| 1681 |     case Accept:  | - | 
| 1682 |         if (acceptMode() == AcceptOpen)  | - | 
| 1683 |             button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open);  | - | 
| 1684 |         else  | - | 
| 1685 |             button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save);  | - | 
| 1686 |         if (button)  | - | 
| 1687 |             return button->text();  | - | 
| 1688 |     case Reject:  | - | 
| 1689 |         button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel);  | - | 
| 1690 |         if (button)  | - | 
| 1691 |             return button->text();  | - | 
| 1692 |     }  | - | 
| 1693 |     return QString();  | - | 
| 1694 | }  | - | 
| 1695 |   | - | 
| 1696 | /*  | - | 
| 1697 |     For the native file dialogs  | - | 
| 1698 | */  | - | 
| 1699 |   | - | 
| 1700 | #if defined(Q_WS_WIN)  | - | 
| 1701 | extern QString qt_win_get_open_file_name(const QFileDialogArgs &args,  | - | 
| 1702 |                                          QString *initialDirectory,  | - | 
| 1703 |                                          QString *selectedFilter);  | - | 
| 1704 |   | - | 
| 1705 | extern QString qt_win_get_save_file_name(const QFileDialogArgs &args,  | - | 
| 1706 |                                          QString *initialDirectory,  | - | 
| 1707 |                                          QString *selectedFilter);  | - | 
| 1708 |   | - | 
| 1709 | extern QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,  | - | 
| 1710 |                                               QString *initialDirectory,  | - | 
| 1711 |                                               QString *selectedFilter);  | - | 
| 1712 |   | - | 
| 1713 | extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);  | - | 
| 1714 | #endif  | - | 
| 1715 |   | - | 
| 1716 | /*!  | - | 
| 1717 |     This is a convenience static function that returns an existing file  | - | 
| 1718 |     selected by the user. If the user presses Cancel, it returns a null string.  | - | 
| 1719 |   | - | 
| 1720 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 8  | - | 
| 1721 |   | - | 
| 1722 |     The function creates a modal file dialog with the given \a parent widget.  | - | 
| 1723 |     If \a parent is not 0, the dialog will be shown centered over the parent  | - | 
| 1724 |     widget.  | - | 
| 1725 |   | - | 
| 1726 |     The file dialog's working directory will be set to \a dir. If \a dir  | - | 
| 1727 |     includes a file name, the file will be selected. Only files that match the  | - | 
| 1728 |     given \a filter are shown. The filter selected is set to \a selectedFilter.  | - | 
| 1729 |     The parameters \a dir, \a selectedFilter, and \a filter may be empty  | - | 
| 1730 |     strings. If you want multiple filters, separate them with ';;', for  | - | 
| 1731 |     example:  | - | 
| 1732 |   | - | 
| 1733 |     \code  | - | 
| 1734 |     "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"  | - | 
| 1735 |     \endcode  | - | 
| 1736 |   | - | 
| 1737 |     The \a options argument holds various options about how to run the dialog,  | - | 
| 1738 |     see the QFileDialog::Option enum for more information on the flags you can  | - | 
| 1739 |     pass.  | - | 
| 1740 |   | - | 
| 1741 |     The dialog's caption is set to \a caption. If \a caption is not specified  | - | 
| 1742 |     then a default caption will be used.  | - | 
| 1743 |   | - | 
| 1744 |     On Windows, and Mac OS X, this static function will use the  | - | 
| 1745 |     native file dialog and not a QFileDialog.  | - | 
| 1746 |   | - | 
| 1747 |     On Windows the dialog will spin a blocking modal event loop that will not  | - | 
| 1748 |     dispatch any QTimers, and if \a parent is not 0 then it will position the  | - | 
| 1749 |     dialog just below the parent's title bar.  | - | 
| 1750 |   | - | 
| 1751 |     On Unix/X11, the normal behavior of the file dialog is to resolve and  | - | 
| 1752 |     follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},  | - | 
| 1753 |     the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If  | - | 
| 1754 |     \a options includes DontResolveSymlinks, the file dialog will treat  | - | 
| 1755 |     symlinks as regular directories.  | - | 
| 1756 |   | - | 
| 1757 |     \warning Do not delete \a parent during the execution of the dialog. If you  | - | 
| 1758 |     want to do this, you should create the dialog yourself using one of the  | - | 
| 1759 |     QFileDialog constructors.  | - | 
| 1760 |   | - | 
| 1761 |     \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory()  | - | 
| 1762 | */  | - | 
| 1763 | QString QFileDialog::getOpenFileName(QWidget *parent,  | - | 
| 1764 |                                const QString &caption,  | - | 
| 1765 |                                const QString &dir,  | - | 
| 1766 |                                const QString &filter,  | - | 
| 1767 |                                QString *selectedFilter,  | - | 
| 1768 |                                Options options)  | - | 
| 1769 | {  | - | 
| 1770 |     if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))  | - | 
| 1771 |         return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);  | - | 
| 1772 |     QFileDialogArgs args;  | - | 
| 1773 |     args.parent = parent;  | - | 
| 1774 |     args.caption = caption;  | - | 
| 1775 |     args.directory = QFileDialogPrivate::workingDirectory(dir);  | - | 
| 1776 |     args.selection = QFileDialogPrivate::initialSelection(dir);  | - | 
| 1777 |     args.filter = filter;  | - | 
| 1778 |     args.mode = ExistingFile;  | - | 
| 1779 |     args.options = options;  | - | 
| 1780 | #if defined(Q_WS_WIN)  | - | 
| 1781 |     if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {  | - | 
| 1782 |         return qt_win_get_open_file_name(args, &(args.directory), selectedFilter);  | - | 
| 1783 |     }  | - | 
| 1784 | #endif  | - | 
| 1785 |   | - | 
| 1786 |     // create a qt dialog  | - | 
| 1787 |     QFileDialog dialog(args);  | - | 
| 1788 |     if (selectedFilter && !selectedFilter->isEmpty())  | - | 
| 1789 |         dialog.selectNameFilter(*selectedFilter);  | - | 
| 1790 |     if (dialog.exec() == QDialog::Accepted) {  | - | 
| 1791 |         if (selectedFilter)  | - | 
| 1792 |             *selectedFilter = dialog.selectedNameFilter();  | - | 
| 1793 |         return dialog.selectedFiles().value(0);  | - | 
| 1794 |     }  | - | 
| 1795 |     return QString();  | - | 
| 1796 | }  | - | 
| 1797 |   | - | 
| 1798 | /*!  | - | 
| 1799 |     This is a convenience static function that will return one or more existing  | - | 
| 1800 |     files selected by the user.  | - | 
| 1801 |   | - | 
| 1802 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 9  | - | 
| 1803 |   | - | 
| 1804 |     This function creates a modal file dialog with the given \a parent widget.  | - | 
| 1805 |     If \a parent is not 0, the dialog will be shown centered over the parent  | - | 
| 1806 |     widget.  | - | 
| 1807 |   | - | 
| 1808 |     The file dialog's working directory will be set to \a dir. If \a dir  | - | 
| 1809 |     includes a file name, the file will be selected. The filter is set to  | - | 
| 1810 |     \a filter so that only those files which match the filter are shown. The  | - | 
| 1811 |     filter selected is set to \a selectedFilter. The parameters \a dir,  | - | 
| 1812 |     \a selectedFilter and \a filter may be empty strings. If you need multiple  | - | 
| 1813 |     filters, separate them with ';;', for instance:  | - | 
| 1814 |   | - | 
| 1815 |     \code  | - | 
| 1816 |     "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"  | - | 
| 1817 |     \endcode  | - | 
| 1818 |   | - | 
| 1819 |     The dialog's caption is set to \a caption. If \a caption is not specified  | - | 
| 1820 |     then a default caption will be used.  | - | 
| 1821 |   | - | 
| 1822 |     On Windows, and Mac OS X, this static function will use the  | - | 
| 1823 |     native file dialog and not a QFileDialog.  | - | 
| 1824 |   | - | 
| 1825 |     On Windows the dialog will spin a blocking modal event loop that will not  | - | 
| 1826 |     dispatch any QTimers, and if \a parent is not 0 then it will position the  | - | 
| 1827 |     dialog just below the parent's title bar.  | - | 
| 1828 |   | - | 
| 1829 |     On Unix/X11, the normal behavior of the file dialog is to resolve and  | - | 
| 1830 |     follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},  | - | 
| 1831 |     the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}.  | - | 
| 1832 |     The \a options argument holds various options about how to run the dialog,  | - | 
| 1833 |     see the QFileDialog::Option enum for more information on the flags you can  | - | 
| 1834 |     pass.  | - | 
| 1835 |   | - | 
| 1836 |     \note If you want to iterate over the list of files, you should iterate  | - | 
| 1837 |     over a copy. For example:  | - | 
| 1838 |   | - | 
| 1839 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 10  | - | 
| 1840 |   | - | 
| 1841 |     \warning Do not delete \a parent during the execution of the dialog. If you  | - | 
| 1842 |     want to do this, you should create the dialog yourself using one of the  | - | 
| 1843 |     QFileDialog constructors.  | - | 
| 1844 |   | - | 
| 1845 |     \sa getOpenFileName(), getSaveFileName(), getExistingDirectory()  | - | 
| 1846 | */  | - | 
| 1847 | QStringList QFileDialog::getOpenFileNames(QWidget *parent,  | - | 
| 1848 |                                           const QString &caption,  | - | 
| 1849 |                                           const QString &dir,  | - | 
| 1850 |                                           const QString &filter,  | - | 
| 1851 |                                           QString *selectedFilter,  | - | 
| 1852 |                                           Options options)  | - | 
| 1853 | {  | - | 
| 1854 |     if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))  | - | 
| 1855 |         return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);  | - | 
| 1856 |     QFileDialogArgs args;  | - | 
| 1857 |     args.parent = parent;  | - | 
| 1858 |     args.caption = caption;  | - | 
| 1859 |     args.directory = QFileDialogPrivate::workingDirectory(dir);  | - | 
| 1860 |     args.selection = QFileDialogPrivate::initialSelection(dir);  | - | 
| 1861 |     args.filter = filter;  | - | 
| 1862 |     args.mode = ExistingFiles;  | - | 
| 1863 |     args.options = options;  | - | 
| 1864 |   | - | 
| 1865 | #if defined(Q_WS_WIN)  | - | 
| 1866 |     if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {  | - | 
| 1867 |         return qt_win_get_open_file_names(args, &(args.directory), selectedFilter);  | - | 
| 1868 |     }  | - | 
| 1869 | #endif  | - | 
| 1870 |   | - | 
| 1871 |     // create a qt dialog  | - | 
| 1872 |     QFileDialog dialog(args);  | - | 
| 1873 |     if (selectedFilter && !selectedFilter->isEmpty())  | - | 
| 1874 |         dialog.selectNameFilter(*selectedFilter);  | - | 
| 1875 |     if (dialog.exec() == QDialog::Accepted) {  | - | 
| 1876 |         if (selectedFilter)  | - | 
| 1877 |             *selectedFilter = dialog.selectedNameFilter();  | - | 
| 1878 |         return dialog.selectedFiles();  | - | 
| 1879 |     }  | - | 
| 1880 |     return QStringList();  | - | 
| 1881 | }  | - | 
| 1882 |   | - | 
| 1883 | /*!  | - | 
| 1884 |     This is a convenience static function that will return a file name selected  | - | 
| 1885 |     by the user. The file does not have to exist.  | - | 
| 1886 |   | - | 
| 1887 |     It creates a modal file dialog with the given \a parent widget. If  | - | 
| 1888 |     \a parent is not 0, the dialog will be shown centered over the parent  | - | 
| 1889 |     widget.  | - | 
| 1890 |   | - | 
| 1891 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 11  | - | 
| 1892 |   | - | 
| 1893 |     The file dialog's working directory will be set to \a dir. If \a dir  | - | 
| 1894 |     includes a file name, the file will be selected. Only files that match the  | - | 
| 1895 |     \a filter are shown. The filter selected is set to \a selectedFilter. The  | - | 
| 1896 |     parameters \a dir, \a selectedFilter, and \a filter may be empty strings.  | - | 
| 1897 |     Multiple filters are separated with ';;'. For instance:  | - | 
| 1898 |   | - | 
| 1899 |     \code  | - | 
| 1900 |     "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"  | - | 
| 1901 |     \endcode  | - | 
| 1902 |   | - | 
| 1903 |     The \a options argument holds various options about how to run the dialog,  | - | 
| 1904 |     see the QFileDialog::Option enum for more information on the flags you can  | - | 
| 1905 |     pass.  | - | 
| 1906 |   | - | 
| 1907 |     The default filter can be chosen by setting \a selectedFilter to the  | - | 
| 1908 |     desired value.  | - | 
| 1909 |   | - | 
| 1910 |     The dialog's caption is set to \a caption. If \a caption is not specified,  | - | 
| 1911 |     a default caption will be used.  | - | 
| 1912 |   | - | 
| 1913 |     On Windows, and Mac OS X, this static function will use the  | - | 
| 1914 |     native file dialog and not a QFileDialog.  | - | 
| 1915 |   | - | 
| 1916 |     On Windows the dialog will spin a blocking modal event loop that will not  | - | 
| 1917 |     dispatch any QTimers, and if \a parent is not 0 then it will position the  | - | 
| 1918 |     dialog just below the parent's title bar. On Mac OS X, with its native file  | - | 
| 1919 |     dialog, the filter argument is ignored.  | - | 
| 1920 |   | - | 
| 1921 |     On Unix/X11, the normal behavior of the file dialog is to resolve and  | - | 
| 1922 |     follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},  | - | 
| 1923 |     the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If  | - | 
| 1924 |     \a options includes DontResolveSymlinks the file dialog will treat symlinks  | - | 
| 1925 |     as regular directories.  | - | 
| 1926 |   | - | 
| 1927 |     \warning Do not delete \a parent during the execution of the dialog. If you  | - | 
| 1928 |     want to do this, you should create the dialog yourself using one of the  | - | 
| 1929 |     QFileDialog constructors.  | - | 
| 1930 |   | - | 
| 1931 |     \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory()  | - | 
| 1932 | */  | - | 
| 1933 | QString QFileDialog::getSaveFileName(QWidget *parent,  | - | 
| 1934 |                                      const QString &caption,  | - | 
| 1935 |                                      const QString &dir,  | - | 
| 1936 |                                      const QString &filter,  | - | 
| 1937 |                                      QString *selectedFilter,  | - | 
| 1938 |                                      Options options)  | - | 
| 1939 | {  | - | 
| 1940 |     if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))  | - | 
| 1941 |         return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);  | - | 
| 1942 |     QFileDialogArgs args;  | - | 
| 1943 |     args.parent = parent;  | - | 
| 1944 |     args.caption = caption;  | - | 
| 1945 |     args.directory = QFileDialogPrivate::workingDirectory(dir);  | - | 
| 1946 |     args.selection = QFileDialogPrivate::initialSelection(dir);  | - | 
| 1947 |     args.filter = filter;  | - | 
| 1948 |     args.mode = AnyFile;  | - | 
| 1949 |     args.options = options;  | - | 
| 1950 |   | - | 
| 1951 | #if defined(Q_WS_WIN)  | - | 
| 1952 |     if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {  | - | 
| 1953 |         return qt_win_get_save_file_name(args, &(args.directory), selectedFilter);  | - | 
| 1954 |     }  | - | 
| 1955 | #endif  | - | 
| 1956 |   | - | 
| 1957 |     // create a qt dialog  | - | 
| 1958 |     QFileDialog dialog(args);  | - | 
| 1959 |     dialog.setAcceptMode(AcceptSave);  | - | 
| 1960 |     if (selectedFilter && !selectedFilter->isEmpty())  | - | 
| 1961 |         dialog.selectNameFilter(*selectedFilter);  | - | 
| 1962 |     if (dialog.exec() == QDialog::Accepted) {  | - | 
| 1963 |         if (selectedFilter)  | - | 
| 1964 |             *selectedFilter = dialog.selectedNameFilter();  | - | 
| 1965 |         return dialog.selectedFiles().value(0);  | - | 
| 1966 |     }  | - | 
| 1967 |   | - | 
| 1968 |     return QString();  | - | 
| 1969 | }  | - | 
| 1970 |   | - | 
| 1971 | /*!  | - | 
| 1972 |     This is a convenience static function that will return an existing  | - | 
| 1973 |     directory selected by the user.  | - | 
| 1974 |   | - | 
| 1975 |     \snippet code/src_gui_dialogs_qfiledialog.cpp 12  | - | 
| 1976 |   | - | 
| 1977 |     This function creates a modal file dialog with the given \a parent widget.  | - | 
| 1978 |     If \a parent is not 0, the dialog will be shown centered over the parent  | - | 
| 1979 |     widget.  | - | 
| 1980 |   | - | 
| 1981 |     The dialog's working directory is set to \a dir, and the caption is set to  | - | 
| 1982 |     \a caption. Either of these may be an empty string in which case the  | - | 
| 1983 |     current directory and a default caption will be used respectively.  | - | 
| 1984 |   | - | 
| 1985 |     The \a options argument holds various options about how to run the dialog,  | - | 
| 1986 |     see the QFileDialog::Option enum for more information on the flags you can  | - | 
| 1987 |     pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must  | - | 
| 1988 |     be set.  | - | 
| 1989 |   | - | 
| 1990 |     On Windows, and Mac OS X, this static function will use the  | - | 
| 1991 |     native file dialog and not a QFileDialog. On Windows CE, if the device has  | - | 
| 1992 |     no native file dialog, a QFileDialog will be used.  | - | 
| 1993 |   | - | 
| 1994 |     On Unix/X11, the normal behavior of the file dialog is to resolve and  | - | 
| 1995 |     follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},  | - | 
| 1996 |     the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If  | - | 
| 1997 |     \a options includes DontResolveSymlinks, the file dialog will treat  | - | 
| 1998 |     symlinks as regular directories.  | - | 
| 1999 |   | - | 
| 2000 |     On Windows the dialog will spin a blocking modal event loop that will not  | - | 
| 2001 |     dispatch any QTimers, and if \a parent is not 0 then it will position the  | - | 
| 2002 |     dialog just below the parent's title bar.  | - | 
| 2003 |   | - | 
| 2004 |     \warning Do not delete \a parent during the execution of the dialog. If you  | - | 
| 2005 |     want to do this, you should create the dialog yourself using one of the  | - | 
| 2006 |     QFileDialog constructors.  | - | 
| 2007 |   | - | 
| 2008 |     \sa getOpenFileName(), getOpenFileNames(), getSaveFileName()  | - | 
| 2009 | */  | - | 
| 2010 | QString QFileDialog::getExistingDirectory(QWidget *parent,  | - | 
| 2011 |                                           const QString &caption,  | - | 
| 2012 |                                           const QString &dir,  | - | 
| 2013 |                                           Options options)  | - | 
| 2014 | {  | - | 
| 2015 |     if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))  | - | 
| 2016 |         return qt_filedialog_existing_directory_hook(parent, caption, dir, options);  | - | 
| 2017 |     QFileDialogArgs args;  | - | 
| 2018 |     args.parent = parent;  | - | 
| 2019 |     args.caption = caption;  | - | 
| 2020 |     args.directory = QFileDialogPrivate::workingDirectory(dir);  | - | 
| 2021 |     args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);  | - | 
| 2022 |     args.options = options;  | - | 
| 2023 |   | - | 
| 2024 | #if defined(Q_WS_WIN)  | - | 
| 2025 |     if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog) && (options & ShowDirsOnly)  | - | 
| 2026 | #if defined(Q_OS_WINCE)  | - | 
| 2027 |         && qt_priv_ptr_valid  | - | 
| 2028 | #endif  | - | 
| 2029 |         ) {  | - | 
| 2030 |         return qt_win_get_existing_directory(args);  | - | 
| 2031 |     }  | - | 
| 2032 | #endif  | - | 
| 2033 |   | - | 
| 2034 |     // create a qt dialog  | - | 
| 2035 |     QFileDialog dialog(args);  | - | 
| 2036 |     if (dialog.exec() == QDialog::Accepted) {  | - | 
| 2037 |         return dialog.selectedFiles().value(0);  | - | 
| 2038 |     }  | - | 
| 2039 |     return QString();  | - | 
| 2040 | }  | - | 
| 2041 |   | - | 
| 2042 | inline static QString _qt_get_directory(const QString &path)  | - | 
| 2043 | {  | - | 
| 2044 |     QFileInfo info = QFileInfo(QDir::current(), path);  | - | 
| 2045 |     if (info.exists() && info.isDir())  | - | 
| 2046 |         return QDir::cleanPath(info.absoluteFilePath());  | - | 
| 2047 |     info.setFile(info.absolutePath());  | - | 
| 2048 |     if (info.exists() && info.isDir())  | - | 
| 2049 |         return info.absoluteFilePath();  | - | 
| 2050 |     return QString();  | - | 
| 2051 | }  | - | 
| 2052 | /*  | - | 
| 2053 |     Get the initial directory path  | - | 
| 2054 |   | - | 
| 2055 |     \sa initialSelection()  | - | 
| 2056 |  */  | - | 
| 2057 | QString QFileDialogPrivate::workingDirectory(const QString &path)  | - | 
| 2058 | {  | - | 
| 2059 |     if (!path.isEmpty()) {  | - | 
| 2060 |         QString directory = _qt_get_directory(path);  | - | 
| 2061 |         if (!directory.isEmpty())  | - | 
| 2062 |             return directory;  | - | 
| 2063 |     }  | - | 
| 2064 |     QString directory = _qt_get_directory(*lastVisitedDir());  | - | 
| 2065 |     if (!directory.isEmpty())  | - | 
| 2066 |         return directory;  | - | 
| 2067 |     return QDir::currentPath();  | - | 
| 2068 | }  | - | 
| 2069 |   | - | 
| 2070 | /*  | - | 
| 2071 |     Get the initial selection given a path.  The initial directory  | - | 
| 2072 |     can contain both the initial directory and initial selection  | - | 
| 2073 |     /home/user/foo.txt  | - | 
| 2074 |   | - | 
| 2075 |     \sa workingDirectory()  | - | 
| 2076 |  */  | - | 
| 2077 | QString QFileDialogPrivate::initialSelection(const QString &path)  | - | 
| 2078 | {  | - | 
| 2079 |     if (!path.isEmpty()) {  | - | 
| 2080 |         QFileInfo info(path);  | - | 
| 2081 |         if (!info.isDir())  | - | 
| 2082 |             return info.fileName();  | - | 
| 2083 |     }  | - | 
| 2084 |     return QString();  | - | 
| 2085 | }  | - | 
| 2086 |   | - | 
| 2087 | /*!  | - | 
| 2088 |  \reimp  | - | 
| 2089 | */  | - | 
| 2090 | void QFileDialog::done(int result)  | - | 
| 2091 | {  | - | 
| 2092 |     Q_D(QFileDialog);  | - | 
| 2093 |   | - | 
| 2094 |     QDialog::done(result);  | - | 
| 2095 |   | - | 
| 2096 |     if (d->receiverToDisconnectOnClose) {  | - | 
| 2097 |         disconnect(this, d->signalToDisconnectOnClose,  | - | 
| 2098 |                    d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);  | - | 
| 2099 |         d->receiverToDisconnectOnClose = 0;  | - | 
| 2100 |     }  | - | 
| 2101 |     d->memberToDisconnectOnClose.clear();  | - | 
| 2102 |     d->signalToDisconnectOnClose.clear();  | - | 
| 2103 | }  | - | 
| 2104 |   | - | 
| 2105 | /*!  | - | 
| 2106 |  \reimp  | - | 
| 2107 | */  | - | 
| 2108 | void QFileDialog::accept()  | - | 
| 2109 | {  | - | 
| 2110 |     Q_D(QFileDialog);  | - | 
| 2111 |     QStringList files = selectedFiles();  | - | 
| 2112 |     if (files.isEmpty())  | - | 
| 2113 |         return;  | - | 
| 2114 |     if (d->nativeDialogInUse){  | - | 
| 2115 |         d->emitFilesSelected(files);  | - | 
| 2116 |         QDialog::accept();  | - | 
| 2117 |         return;  | - | 
| 2118 |     }  | - | 
| 2119 |   | - | 
| 2120 |     QString lineEditText = d->lineEdit()->text();  | - | 
| 2121 |     // "hidden feature" type .. and then enter, and it will move up a dir  | - | 
| 2122 |     // special case for ".."  | - | 
| 2123 |     if (lineEditText == QLatin1String("..")) {  | - | 
| 2124 |         d->_q_navigateToParent();  | - | 
| 2125 |         bool block = d->qFileDialogUi->fileNameEdit->blockSignals(true);  | - | 
| 2126 |         d->lineEdit()->selectAll();  | - | 
| 2127 |         d->qFileDialogUi->fileNameEdit->blockSignals(block);  | - | 
| 2128 |         return;  | - | 
| 2129 |     }  | - | 
| 2130 |   | - | 
| 2131 |     switch (fileMode()) {  | - | 
| 2132 |     case DirectoryOnly:  | - | 
| 2133 |     case Directory: {  | - | 
| 2134 |         QString fn = files.first();  | - | 
| 2135 |         QFileInfo info(fn);  | - | 
| 2136 |         if (!info.exists())  | - | 
| 2137 |             info = QFileInfo(d->getEnvironmentVariable(fn));  | - | 
| 2138 |         if (!info.exists()) {  | - | 
| 2139 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 2140 |             QString message = tr("%1\nDirectory not found.\nPlease verify the "  | - | 
| 2141 |                                           "correct directory name was given.");  | - | 
| 2142 |             QMessageBox::warning(this, windowTitle(), message.arg(info.fileName()));  | - | 
| 2143 | #endif // QT_NO_MESSAGEBOX  | - | 
| 2144 |             return;  | - | 
| 2145 |         }  | - | 
| 2146 |         if (info.isDir()) {  | - | 
| 2147 |             d->emitFilesSelected(files);  | - | 
| 2148 |             QDialog::accept();  | - | 
| 2149 |         }  | - | 
| 2150 |         return;  | - | 
| 2151 |     }  | - | 
| 2152 |   | - | 
| 2153 |     case AnyFile: {  | - | 
| 2154 |         QString fn = files.first();  | - | 
| 2155 |         QFileInfo info(fn);  | - | 
| 2156 |         if (info.isDir()) {  | - | 
| 2157 |             setDirectory(info.absoluteFilePath());  | - | 
| 2158 |             return;  | - | 
| 2159 |         }  | - | 
| 2160 |   | - | 
| 2161 |         if (!info.exists()) {  | - | 
| 2162 |             int maxNameLength = d->maxNameLength(info.path());  | - | 
| 2163 |             if (maxNameLength >= 0 && info.fileName().length() > maxNameLength)  | - | 
| 2164 |                 return;  | - | 
| 2165 |         }  | - | 
| 2166 |   | - | 
| 2167 |         // check if we have to ask for permission to overwrite the file  | - | 
| 2168 |         if (!info.exists() || !confirmOverwrite() || acceptMode() == AcceptOpen) {  | - | 
| 2169 |             d->emitFilesSelected(QStringList(fn));  | - | 
| 2170 |             QDialog::accept();  | - | 
| 2171 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 2172 |         } else {  | - | 
| 2173 |             if (QMessageBox::warning(this, windowTitle(),  | - | 
| 2174 |                                      tr("%1 already exists.\nDo you want to replace it?")  | - | 
| 2175 |                                      .arg(info.fileName()),  | - | 
| 2176 |                                      QMessageBox::Yes | QMessageBox::No, QMessageBox::No)  | - | 
| 2177 |                     == QMessageBox::Yes) {  | - | 
| 2178 |                 d->emitFilesSelected(QStringList(fn));  | - | 
| 2179 |                 QDialog::accept();  | - | 
| 2180 |             }  | - | 
| 2181 | #endif  | - | 
| 2182 |         }  | - | 
| 2183 |         return;  | - | 
| 2184 |     }  | - | 
| 2185 |   | - | 
| 2186 |     case ExistingFile:  | - | 
| 2187 |     case ExistingFiles:  | - | 
| 2188 |         for (int i = 0; i < files.count(); ++i) {  | - | 
| 2189 |             QFileInfo info(files.at(i));  | - | 
| 2190 |             if (!info.exists())  | - | 
| 2191 |                 info = QFileInfo(d->getEnvironmentVariable(files.at(i)));  | - | 
| 2192 |             if (!info.exists()) {  | - | 
| 2193 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 2194 |                 QString message = tr("%1\nFile not found.\nPlease verify the "  | - | 
| 2195 |                                      "correct file name was given.");  | - | 
| 2196 |                 QMessageBox::warning(this, windowTitle(), message.arg(info.fileName()));  | - | 
| 2197 | #endif // QT_NO_MESSAGEBOX  | - | 
| 2198 |                 return;  | - | 
| 2199 |             }  | - | 
| 2200 |             if (info.isDir()) {  | - | 
| 2201 |                 setDirectory(info.absoluteFilePath());  | - | 
| 2202 |                 d->lineEdit()->clear();  | - | 
| 2203 |                 return;  | - | 
| 2204 |             }  | - | 
| 2205 |         }  | - | 
| 2206 |         d->emitFilesSelected(files);  | - | 
| 2207 |         QDialog::accept();  | - | 
| 2208 |         return;  | - | 
| 2209 |     }  | - | 
| 2210 | }  | - | 
| 2211 |   | - | 
| 2212 | /*!  | - | 
| 2213 |     \internal  | - | 
| 2214 |   | - | 
| 2215 |     Create widgets, layout and set default values  | - | 
| 2216 | */  | - | 
| 2217 | void QFileDialogPrivate::init(const QString &directory, const QString &nameFilter,  | - | 
| 2218 |                               const QString &caption)  | - | 
| 2219 | {  | - | 
| 2220 |     Q_Q(QFileDialog);  | - | 
| 2221 |     if (!caption.isEmpty()) {  | - | 
| 2222 |         useDefaultCaption = false;  | - | 
| 2223 |         setWindowTitle = caption;  | - | 
| 2224 |         q->setWindowTitle(caption);  | - | 
| 2225 |     }  | - | 
| 2226 |   | - | 
| 2227 |     createWidgets();  | - | 
| 2228 |     createMenuActions();  | - | 
| 2229 |     retranslateStrings();  | - | 
| 2230 |     q->setFileMode(QFileDialog::AnyFile);  | - | 
| 2231 |   | - | 
| 2232 | #ifndef QT_NO_SETTINGS  | - | 
| 2233 |     QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));  | - | 
| 2234 |     settings.beginGroup(QLatin1String("Qt"));  | - | 
| 2235 |     if (!directory.isEmpty())  | - | 
| 2236 |         setLastVisitedDirectory(workingDirectory(directory));  | - | 
| 2237 |     q->restoreState(settings.value(QLatin1String("filedialog")).toByteArray());  | - | 
| 2238 | #endif  | - | 
| 2239 |   | - | 
| 2240 | #if defined(Q_EMBEDDED_SMALLSCREEN)  | - | 
| 2241 |     qFileDialogUi->lookInLabel->setVisible(false);  | - | 
| 2242 |     qFileDialogUi->fileNameLabel->setVisible(false);  | - | 
| 2243 |     qFileDialogUi->fileTypeLabel->setVisible(false);  | - | 
| 2244 |     qFileDialogUi->sidebar->hide();  | - | 
| 2245 | #endif  | - | 
| 2246 |     // Default case  | - | 
| 2247 |     if (!nameFilter.isEmpty())  | - | 
| 2248 |         q->setNameFilter(nameFilter);  | - | 
| 2249 |     q->setAcceptMode(QFileDialog::AcceptOpen);  | - | 
| 2250 |     q->setDirectory(workingDirectory(directory));  | - | 
| 2251 |     q->selectFile(initialSelection(directory));  | - | 
| 2252 |   | - | 
| 2253 |     _q_updateOkButton();  | - | 
| 2254 |     q->resize(q->sizeHint());  | - | 
| 2255 | }  | - | 
| 2256 |   | - | 
| 2257 | /*!  | - | 
| 2258 |     \internal  | - | 
| 2259 |   | - | 
| 2260 |     Create the widgets, set properties and connections  | - | 
| 2261 | */  | - | 
| 2262 | void QFileDialogPrivate::createWidgets()  | - | 
| 2263 | {  | - | 
| 2264 |     Q_Q(QFileDialog);  | - | 
| 2265 |     model = new QFileSystemModel(q);  | - | 
| 2266 |     options->setFilter(model->filter());  | - | 
| 2267 |     model->setObjectName(QLatin1String("qt_filesystem_model"));  | - | 
| 2268 |     if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())  | - | 
| 2269 |         model->setNameFilterDisables(helper->defaultNameFilterDisables());  | - | 
| 2270 |     else  | - | 
| 2271 |         model->setNameFilterDisables(false);  | - | 
| 2272 |     model->d_func()->disableRecursiveSort = true;  | - | 
| 2273 |     QFileDialog::connect(model, SIGNAL(fileRenamed(QString,QString,QString)), q, SLOT(_q_fileRenamed(QString,QString,QString)));  | - | 
| 2274 |     QFileDialog::connect(model, SIGNAL(rootPathChanged(QString)),  | - | 
| 2275 |             q, SLOT(_q_pathChanged(QString)));  | - | 
| 2276 |     QFileDialog::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),  | - | 
| 2277 |             q, SLOT(_q_rowsInserted(QModelIndex)));  | - | 
| 2278 |     model->setReadOnly(false);  | - | 
| 2279 |   | - | 
| 2280 |     qFileDialogUi.reset(new Ui_QFileDialog());  | - | 
| 2281 |     qFileDialogUi->setupUi(q);  | - | 
| 2282 |   | - | 
| 2283 |     QList<QUrl> initialBookmarks;  | - | 
| 2284 |     initialBookmarks << QUrl::fromLocalFile(QLatin1String(""))  | - | 
| 2285 |                      << QUrl::fromLocalFile(QDir::homePath());  | - | 
| 2286 |     qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks);  | - | 
| 2287 |     QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)),  | - | 
| 2288 |                          q, SLOT(_q_goToUrl(QUrl)));  | - | 
| 2289 |   | - | 
| 2290 |     QObject::connect(qFileDialogUi->buttonBox, SIGNAL(accepted()), q, SLOT(accept()));  | - | 
| 2291 |     QObject::connect(qFileDialogUi->buttonBox, SIGNAL(rejected()), q, SLOT(reject()));  | - | 
| 2292 |   | - | 
| 2293 |     qFileDialogUi->lookInCombo->setFileDialogPrivate(this);  | - | 
| 2294 |     QObject::connect(qFileDialogUi->lookInCombo, SIGNAL(activated(QString)), q, SLOT(_q_goToDirectory(QString)));  | - | 
| 2295 |   | - | 
| 2296 |     qFileDialogUi->lookInCombo->setInsertPolicy(QComboBox::NoInsert);  | - | 
| 2297 |     qFileDialogUi->lookInCombo->setDuplicatesEnabled(false);  | - | 
| 2298 |   | - | 
| 2299 |     // filename  | - | 
| 2300 |     qFileDialogUi->fileNameEdit->setFileDialogPrivate(this);  | - | 
| 2301 | #ifndef QT_NO_SHORTCUT  | - | 
| 2302 |     qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit);  | - | 
| 2303 | #endif  | - | 
| 2304 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 2305 |     completer = new QFSCompleter(model, q);  | - | 
| 2306 |     qFileDialogUi->fileNameEdit->setCompleter(completer);  | - | 
| 2307 | #endif // QT_NO_FSCOMPLETER  | - | 
| 2308 |     QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),  | - | 
| 2309 |             q, SLOT(_q_autoCompleteFileName(QString)));  | - | 
| 2310 |     QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),  | - | 
| 2311 |                      q, SLOT(_q_updateOkButton()));  | - | 
| 2312 |   | - | 
| 2313 |     QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(returnPressed()), q, SLOT(accept()));  | - | 
| 2314 |   | - | 
| 2315 |     // filetype  | - | 
| 2316 |     qFileDialogUi->fileTypeCombo->setDuplicatesEnabled(false);  | - | 
| 2317 |     qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);  | - | 
| 2318 |     qFileDialogUi->fileTypeCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);  | - | 
| 2319 |     QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(int)),  | - | 
| 2320 |                      q, SLOT(_q_useNameFilter(int)));  | - | 
| 2321 |     QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(QString)),  | - | 
| 2322 |                      q, SIGNAL(filterSelected(QString)));  | - | 
| 2323 |   | - | 
| 2324 |     qFileDialogUi->listView->setFileDialogPrivate(this);  | - | 
| 2325 |     qFileDialogUi->listView->setModel(model);  | - | 
| 2326 |     QObject::connect(qFileDialogUi->listView, SIGNAL(activated(QModelIndex)),  | - | 
| 2327 |                      q, SLOT(_q_enterDirectory(QModelIndex)));  | - | 
| 2328 |     QObject::connect(qFileDialogUi->listView, SIGNAL(customContextMenuRequested(QPoint)),  | - | 
| 2329 |                     q, SLOT(_q_showContextMenu(QPoint)));  | - | 
| 2330 | #ifndef QT_NO_SHORTCUT  | - | 
| 2331 |     QShortcut *shortcut = new QShortcut(qFileDialogUi->listView);  | - | 
| 2332 |     shortcut->setKey(QKeySequence(QLatin1String("Delete")));  | - | 
| 2333 |     QObject::connect(shortcut, SIGNAL(activated()), q, SLOT(_q_deleteCurrent()));  | - | 
| 2334 | #endif  | - | 
| 2335 |   | - | 
| 2336 |     qFileDialogUi->treeView->setFileDialogPrivate(this);  | - | 
| 2337 |     qFileDialogUi->treeView->setModel(model);  | - | 
| 2338 |     QHeaderView *treeHeader = qFileDialogUi->treeView->header();  | - | 
| 2339 |     QFontMetrics fm(q->font());  | - | 
| 2340 |     treeHeader->resizeSection(0, fm.width(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww")));  | - | 
| 2341 |     treeHeader->resizeSection(1, fm.width(QLatin1String("128.88 GB")));  | - | 
| 2342 |     treeHeader->resizeSection(2, fm.width(QLatin1String("mp3Folder")));  | - | 
| 2343 |     treeHeader->resizeSection(3, fm.width(QLatin1String("10/29/81 02:02PM")));  | - | 
| 2344 |     treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu);  | - | 
| 2345 |   | - | 
| 2346 |     QActionGroup *showActionGroup = new QActionGroup(q);  | - | 
| 2347 |     showActionGroup->setExclusive(false);  | - | 
| 2348 |     QObject::connect(showActionGroup, SIGNAL(triggered(QAction*)),  | - | 
| 2349 |                      q, SLOT(_q_showHeader(QAction*)));;  | - | 
| 2350 |   | - | 
| 2351 |     QAbstractItemModel *abstractModel = model;  | - | 
| 2352 | #ifndef QT_NO_PROXYMODEL  | - | 
| 2353 |     if (proxyModel)  | - | 
| 2354 |         abstractModel = proxyModel;  | - | 
| 2355 | #endif  | - | 
| 2356 |     for (int i = 1; i < abstractModel->columnCount(QModelIndex()); ++i) {  | - | 
| 2357 |         QAction *showHeader = new QAction(showActionGroup);  | - | 
| 2358 |         showHeader->setCheckable(true);  | - | 
| 2359 |         showHeader->setChecked(true);  | - | 
| 2360 |         treeHeader->addAction(showHeader);  | - | 
| 2361 |     }  | - | 
| 2362 |   | - | 
| 2363 |     QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel());  | - | 
| 2364 |     qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel());  | - | 
| 2365 |   | - | 
| 2366 |     QObject::connect(qFileDialogUi->treeView, SIGNAL(activated(QModelIndex)),  | - | 
| 2367 |                      q, SLOT(_q_enterDirectory(QModelIndex)));  | - | 
| 2368 |     QObject::connect(qFileDialogUi->treeView, SIGNAL(customContextMenuRequested(QPoint)),  | - | 
| 2369 |                      q, SLOT(_q_showContextMenu(QPoint)));  | - | 
| 2370 | #ifndef QT_NO_SHORTCUT  | - | 
| 2371 |     shortcut = new QShortcut(qFileDialogUi->treeView);  | - | 
| 2372 |     shortcut->setKey(QKeySequence(QLatin1String("Delete")));  | - | 
| 2373 |     QObject::connect(shortcut, SIGNAL(activated()), q, SLOT(_q_deleteCurrent()));  | - | 
| 2374 | #endif  | - | 
| 2375 |   | - | 
| 2376 |     // Selections  | - | 
| 2377 |     QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel();  | - | 
| 2378 |     QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),  | - | 
| 2379 |                      q, SLOT(_q_selectionChanged()));  | - | 
| 2380 |     QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)),  | - | 
| 2381 |                      q, SLOT(_q_currentChanged(QModelIndex)));  | - | 
| 2382 |     qFileDialogUi->splitter->setStretchFactor(qFileDialogUi->splitter->indexOf(qFileDialogUi->splitter->widget(1)), QSizePolicy::Expanding);  | - | 
| 2383 |   | - | 
| 2384 |     createToolButtons();  | - | 
| 2385 | }  | - | 
| 2386 |   | - | 
| 2387 | void QFileDialogPrivate::_q_showHeader(QAction *action)  | - | 
| 2388 | {  | - | 
| 2389 |     Q_Q(QFileDialog);  | - | 
| 2390 |     QActionGroup *actionGroup = qobject_cast<QActionGroup*>(q->sender());  | - | 
| 2391 |     qFileDialogUi->treeView->header()->setSectionHidden(actionGroup->actions().indexOf(action) + 1, !action->isChecked());  | - | 
| 2392 | }  | - | 
| 2393 |   | - | 
| 2394 | #ifndef QT_NO_PROXYMODEL  | - | 
| 2395 | /*!  | - | 
| 2396 |     \since 4.3  | - | 
| 2397 |   | - | 
| 2398 |     Sets the model for the views to the given \a proxyModel.  This is useful if you  | - | 
| 2399 |     want to modify the underlying model; for example, to add columns, filter  | - | 
| 2400 |     data or add drives.  | - | 
| 2401 |   | - | 
| 2402 |     Any existing proxy model will be removed, but not deleted.  The file dialog  | - | 
| 2403 |     will take ownership of the \a proxyModel.  | - | 
| 2404 |   | - | 
| 2405 |     \sa proxyModel()  | - | 
| 2406 | */  | - | 
| 2407 | void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)  | - | 
| 2408 | {  | - | 
| 2409 |     Q_D(QFileDialog);  | - | 
| 2410 |     if ((!proxyModel && !d->proxyModel)  | - | 
| 2411 |         || (proxyModel == d->proxyModel))  | - | 
| 2412 |         return;  | - | 
| 2413 |   | - | 
| 2414 |     QModelIndex idx = d->rootIndex();  | - | 
| 2415 |     if (d->proxyModel) {  | - | 
| 2416 |         disconnect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),  | - | 
| 2417 |             this, SLOT(_q_rowsInserted(QModelIndex)));  | - | 
| 2418 |     } else {  | - | 
| 2419 |         disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),  | - | 
| 2420 |             this, SLOT(_q_rowsInserted(QModelIndex)));  | - | 
| 2421 |     }  | - | 
| 2422 |   | - | 
| 2423 |     if (proxyModel != 0) {  | - | 
| 2424 |         proxyModel->setParent(this);  | - | 
| 2425 |         d->proxyModel = proxyModel;  | - | 
| 2426 |         proxyModel->setSourceModel(d->model);  | - | 
| 2427 |         d->qFileDialogUi->listView->setModel(d->proxyModel);  | - | 
| 2428 |         d->qFileDialogUi->treeView->setModel(d->proxyModel);  | - | 
| 2429 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 2430 |         d->completer->setModel(d->proxyModel);  | - | 
| 2431 |         d->completer->proxyModel = d->proxyModel;  | - | 
| 2432 | #endif  | - | 
| 2433 |         connect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),  | - | 
| 2434 |             this, SLOT(_q_rowsInserted(QModelIndex)));  | - | 
| 2435 |     } else {  | - | 
| 2436 |         d->proxyModel = 0;  | - | 
| 2437 |         d->qFileDialogUi->listView->setModel(d->model);  | - | 
| 2438 |         d->qFileDialogUi->treeView->setModel(d->model);  | - | 
| 2439 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 2440 |         d->completer->setModel(d->model);  | - | 
| 2441 |         d->completer->sourceModel = d->model;  | - | 
| 2442 |         d->completer->proxyModel = 0;  | - | 
| 2443 | #endif  | - | 
| 2444 |         connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),  | - | 
| 2445 |             this, SLOT(_q_rowsInserted(QModelIndex)));  | - | 
| 2446 |     }  | - | 
| 2447 |     QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel());  | - | 
| 2448 |     d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel());  | - | 
| 2449 |   | - | 
| 2450 |     d->setRootIndex(idx);  | - | 
| 2451 |   | - | 
| 2452 |     // reconnect selection  | - | 
| 2453 |     QItemSelectionModel *selections = d->qFileDialogUi->listView->selectionModel();  | - | 
| 2454 |     QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),  | - | 
| 2455 |                      this, SLOT(_q_selectionChanged()));  | - | 
| 2456 |     QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)),  | - | 
| 2457 |                      this, SLOT(_q_currentChanged(QModelIndex)));  | - | 
| 2458 | }  | - | 
| 2459 |   | - | 
| 2460 | /*!  | - | 
| 2461 |     Returns the proxy model used by the file dialog.  By default no proxy is set.  | - | 
| 2462 |   | - | 
| 2463 |     \sa setProxyModel()  | - | 
| 2464 | */  | - | 
| 2465 | QAbstractProxyModel *QFileDialog::proxyModel() const  | - | 
| 2466 | {  | - | 
| 2467 |     Q_D(const QFileDialog);  | - | 
| 2468 |     return d->proxyModel;  | - | 
| 2469 | }  | - | 
| 2470 | #endif // QT_NO_PROXYMODEL  | - | 
| 2471 |   | - | 
| 2472 | /*!  | - | 
| 2473 |     \internal  | - | 
| 2474 |   | - | 
| 2475 |     Create tool buttons, set properties and connections  | - | 
| 2476 | */  | - | 
| 2477 | void QFileDialogPrivate::createToolButtons()  | - | 
| 2478 | {  | - | 
| 2479 |     Q_Q(QFileDialog);  | - | 
| 2480 |     qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, 0, q));  | - | 
| 2481 |     qFileDialogUi->backButton->setAutoRaise(true);  | - | 
| 2482 |     qFileDialogUi->backButton->setEnabled(false);  | - | 
| 2483 |     QObject::connect(qFileDialogUi->backButton, SIGNAL(clicked()), q, SLOT(_q_navigateBackward()));  | - | 
| 2484 |   | - | 
| 2485 |     qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, 0, q));  | - | 
| 2486 |     qFileDialogUi->forwardButton->setAutoRaise(true);  | - | 
| 2487 |     qFileDialogUi->forwardButton->setEnabled(false);  | - | 
| 2488 |     QObject::connect(qFileDialogUi->forwardButton, SIGNAL(clicked()), q, SLOT(_q_navigateForward()));  | - | 
| 2489 |   | - | 
| 2490 |     qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, 0, q));  | - | 
| 2491 |     qFileDialogUi->toParentButton->setAutoRaise(true);  | - | 
| 2492 |     qFileDialogUi->toParentButton->setEnabled(false);  | - | 
| 2493 |     QObject::connect(qFileDialogUi->toParentButton, SIGNAL(clicked()), q, SLOT(_q_navigateToParent()));  | - | 
| 2494 |   | - | 
| 2495 |     qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, 0, q));  | - | 
| 2496 |     qFileDialogUi->listModeButton->setAutoRaise(true);  | - | 
| 2497 |     qFileDialogUi->listModeButton->setDown(true);  | - | 
| 2498 |     QObject::connect(qFileDialogUi->listModeButton, SIGNAL(clicked()), q, SLOT(_q_showListView()));  | - | 
| 2499 |   | - | 
| 2500 |     qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, 0, q));  | - | 
| 2501 |     qFileDialogUi->detailModeButton->setAutoRaise(true);  | - | 
| 2502 |     QObject::connect(qFileDialogUi->detailModeButton, SIGNAL(clicked()), q, SLOT(_q_showDetailsView()));  | - | 
| 2503 |   | - | 
| 2504 |     QSize toolSize(qFileDialogUi->fileNameEdit->sizeHint().height(), qFileDialogUi->fileNameEdit->sizeHint().height());  | - | 
| 2505 |     qFileDialogUi->backButton->setFixedSize(toolSize);  | - | 
| 2506 |     qFileDialogUi->listModeButton->setFixedSize(toolSize);  | - | 
| 2507 |     qFileDialogUi->detailModeButton->setFixedSize(toolSize);  | - | 
| 2508 |     qFileDialogUi->forwardButton->setFixedSize(toolSize);  | - | 
| 2509 |     qFileDialogUi->toParentButton->setFixedSize(toolSize);  | - | 
| 2510 |   | - | 
| 2511 |     qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, 0, q));  | - | 
| 2512 |     qFileDialogUi->newFolderButton->setFixedSize(toolSize);  | - | 
| 2513 |     qFileDialogUi->newFolderButton->setAutoRaise(true);  | - | 
| 2514 |     qFileDialogUi->newFolderButton->setEnabled(false);  | - | 
| 2515 |     QObject::connect(qFileDialogUi->newFolderButton, SIGNAL(clicked()), q, SLOT(_q_createDirectory()));  | - | 
| 2516 | }  | - | 
| 2517 |   | - | 
| 2518 | /*!  | - | 
| 2519 |     \internal  | - | 
| 2520 |   | - | 
| 2521 |     Create actions which will be used in the right click.  | - | 
| 2522 | */  | - | 
| 2523 | void QFileDialogPrivate::createMenuActions()  | - | 
| 2524 | {  | - | 
| 2525 |     Q_Q(QFileDialog);  | - | 
| 2526 |   | - | 
| 2527 |     QAction *goHomeAction =  new QAction(q);  | - | 
| 2528 | #ifndef QT_NO_SHORTCUT  | - | 
| 2529 |     goHomeAction->setShortcut(Qt::CTRL + Qt::Key_H + Qt::SHIFT);  | - | 
| 2530 | #endif  | - | 
| 2531 |     QObject::connect(goHomeAction, SIGNAL(triggered()), q, SLOT(_q_goHome()));  | - | 
| 2532 |     q->addAction(goHomeAction);  | - | 
| 2533 |   | - | 
| 2534 |     // ### TODO add Desktop & Computer actions  | - | 
| 2535 |   | - | 
| 2536 |     QAction *goToParent =  new QAction(q);  | - | 
| 2537 |     goToParent->setObjectName(QLatin1String("qt_goto_parent_action"));  | - | 
| 2538 | #ifndef QT_NO_SHORTCUT  | - | 
| 2539 |     goToParent->setShortcut(Qt::CTRL + Qt::UpArrow);  | - | 
| 2540 | #endif  | - | 
| 2541 |     QObject::connect(goToParent, SIGNAL(triggered()), q, SLOT(_q_navigateToParent()));  | - | 
| 2542 |     q->addAction(goToParent);  | - | 
| 2543 |   | - | 
| 2544 |     renameAction = new QAction(q);  | - | 
| 2545 |     renameAction->setEnabled(false);  | - | 
| 2546 |     renameAction->setObjectName(QLatin1String("qt_rename_action"));  | - | 
| 2547 |     QObject::connect(renameAction, SIGNAL(triggered()), q, SLOT(_q_renameCurrent()));  | - | 
| 2548 |   | - | 
| 2549 |     deleteAction = new QAction(q);  | - | 
| 2550 |     deleteAction->setEnabled(false);  | - | 
| 2551 |     deleteAction->setObjectName(QLatin1String("qt_delete_action"));  | - | 
| 2552 |     QObject::connect(deleteAction, SIGNAL(triggered()), q, SLOT(_q_deleteCurrent()));  | - | 
| 2553 |   | - | 
| 2554 |     showHiddenAction = new QAction(q);  | - | 
| 2555 |     showHiddenAction->setObjectName(QLatin1String("qt_show_hidden_action"));  | - | 
| 2556 |     showHiddenAction->setCheckable(true);  | - | 
| 2557 |     QObject::connect(showHiddenAction, SIGNAL(triggered()), q, SLOT(_q_showHidden()));  | - | 
| 2558 |   | - | 
| 2559 |     newFolderAction = new QAction(q);  | - | 
| 2560 |     newFolderAction->setObjectName(QLatin1String("qt_new_folder_action"));  | - | 
| 2561 |     QObject::connect(newFolderAction, SIGNAL(triggered()), q, SLOT(_q_createDirectory()));  | - | 
| 2562 | }  | - | 
| 2563 |   | - | 
| 2564 | void QFileDialogPrivate::_q_goHome()  | - | 
| 2565 | {  | - | 
| 2566 |     Q_Q(QFileDialog);  | - | 
| 2567 |     q->setDirectory(QDir::homePath());  | - | 
| 2568 | }  | - | 
| 2569 |   | - | 
| 2570 | /*!  | - | 
| 2571 |     \internal  | - | 
| 2572 |   | - | 
| 2573 |     Update history with new path, buttons, and combo  | - | 
| 2574 | */  | - | 
| 2575 | void QFileDialogPrivate::_q_pathChanged(const QString &newPath)  | - | 
| 2576 | {  | - | 
| 2577 |     Q_Q(QFileDialog);  | - | 
| 2578 |     QDir dir(model->rootDirectory());  | - | 
| 2579 |     qFileDialogUi->toParentButton->setEnabled(dir.exists());  | - | 
| 2580 |     qFileDialogUi->sidebar->selectUrl(QUrl::fromLocalFile(newPath));  | - | 
| 2581 |     q->setHistory(qFileDialogUi->lookInCombo->history());  | - | 
| 2582 |   | - | 
| 2583 |     if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)) {  | - | 
| 2584 |         while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) {  | - | 
| 2585 |             currentHistory.removeLast();  | - | 
| 2586 |         }  | - | 
| 2587 |         currentHistory.append(QDir::toNativeSeparators(newPath));  | - | 
| 2588 |         ++currentHistoryLocation;  | - | 
| 2589 |     }  | - | 
| 2590 |     qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1);  | - | 
| 2591 |     qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0);  | - | 
| 2592 | }  | - | 
| 2593 |   | - | 
| 2594 | /*!  | - | 
| 2595 |     \internal  | - | 
| 2596 |   | - | 
| 2597 |     Navigates to the last directory viewed in the dialog.  | - | 
| 2598 | */  | - | 
| 2599 | void QFileDialogPrivate::_q_navigateBackward()  | - | 
| 2600 | {  | - | 
| 2601 |     Q_Q(QFileDialog);  | - | 
| 2602 |     if (!currentHistory.isEmpty() && currentHistoryLocation > 0) {  | - | 
| 2603 |         --currentHistoryLocation;  | - | 
| 2604 |         QString previousHistory = currentHistory.at(currentHistoryLocation);  | - | 
| 2605 |         q->setDirectory(previousHistory);  | - | 
| 2606 |     }  | - | 
| 2607 | }  | - | 
| 2608 |   | - | 
| 2609 | /*!  | - | 
| 2610 |     \internal  | - | 
| 2611 |   | - | 
| 2612 |     Navigates to the last directory viewed in the dialog.  | - | 
| 2613 | */  | - | 
| 2614 | void QFileDialogPrivate::_q_navigateForward()  | - | 
| 2615 | {  | - | 
| 2616 |     Q_Q(QFileDialog);  | - | 
| 2617 |     if (!currentHistory.isEmpty() && currentHistoryLocation < currentHistory.size() - 1) {  | - | 
| 2618 |         ++currentHistoryLocation;  | - | 
| 2619 |         QString nextHistory = currentHistory.at(currentHistoryLocation);  | - | 
| 2620 |         q->setDirectory(nextHistory);  | - | 
| 2621 |     }  | - | 
| 2622 | }  | - | 
| 2623 |   | - | 
| 2624 | /*!  | - | 
| 2625 |     \internal  | - | 
| 2626 |   | - | 
| 2627 |     Navigates to the parent directory of the currently displayed directory  | - | 
| 2628 |     in the dialog.  | - | 
| 2629 | */  | - | 
| 2630 | void QFileDialogPrivate::_q_navigateToParent()  | - | 
| 2631 | {  | - | 
| 2632 |     Q_Q(QFileDialog);  | - | 
| 2633 |     QDir dir(model->rootDirectory());  | - | 
| 2634 |     QString newDirectory;  | - | 
| 2635 |     if (dir.isRoot()) {  | - | 
| 2636 |         newDirectory = model->myComputer().toString();  | - | 
| 2637 |     } else {  | - | 
| 2638 |         dir.cdUp();  | - | 
| 2639 |         newDirectory = dir.absolutePath();  | - | 
| 2640 |     }  | - | 
| 2641 |     q->setDirectory(newDirectory);  | - | 
| 2642 |     emit q->directoryEntered(newDirectory);  | - | 
| 2643 | }  | - | 
| 2644 |   | - | 
| 2645 | /*!  | - | 
| 2646 |     \internal  | - | 
| 2647 |   | - | 
| 2648 |     Creates a new directory, first asking the user for a suitable name.  | - | 
| 2649 | */  | - | 
| 2650 | void QFileDialogPrivate::_q_createDirectory()  | - | 
| 2651 | {  | - | 
| 2652 |     Q_Q(QFileDialog);  | - | 
| 2653 |     qFileDialogUi->listView->clearSelection();  | - | 
| 2654 |   | - | 
| 2655 |     QString newFolderString = QFileDialog::tr("New Folder");  | - | 
| 2656 |     QString folderName = newFolderString;  | - | 
| 2657 |     QString prefix = q->directory().absolutePath() + QDir::separator();  | - | 
| 2658 |     if (QFile::exists(prefix + folderName)) {  | - | 
| 2659 |         qlonglong suffix = 2;  | - | 
| 2660 |         while (QFile::exists(prefix + folderName)) {  | - | 
| 2661 |             folderName = newFolderString + QString::number(suffix++);  | - | 
| 2662 |         }  | - | 
| 2663 |     }  | - | 
| 2664 |   | - | 
| 2665 |     QModelIndex parent = rootIndex();  | - | 
| 2666 |     QModelIndex index = model->mkdir(parent, folderName);  | - | 
| 2667 |     if (!index.isValid())  | - | 
| 2668 |         return;  | - | 
| 2669 |   | - | 
| 2670 |     index = select(index);  | - | 
| 2671 |     if (index.isValid()) {  | - | 
| 2672 |         qFileDialogUi->treeView->setCurrentIndex(index);  | - | 
| 2673 |         currentView()->edit(index);  | - | 
| 2674 |     }  | - | 
| 2675 | }  | - | 
| 2676 |   | - | 
| 2677 | void QFileDialogPrivate::_q_showListView()  | - | 
| 2678 | {  | - | 
| 2679 |     qFileDialogUi->listModeButton->setDown(true);  | - | 
| 2680 |     qFileDialogUi->detailModeButton->setDown(false);  | - | 
| 2681 |     qFileDialogUi->treeView->hide();  | - | 
| 2682 |     qFileDialogUi->listView->show();  | - | 
| 2683 |     qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->listView->parentWidget());  | - | 
| 2684 |     qFileDialogUi->listView->doItemsLayout();  | - | 
| 2685 | }  | - | 
| 2686 |   | - | 
| 2687 | void QFileDialogPrivate::_q_showDetailsView()  | - | 
| 2688 | {  | - | 
| 2689 |     qFileDialogUi->listModeButton->setDown(false);  | - | 
| 2690 |     qFileDialogUi->detailModeButton->setDown(true);  | - | 
| 2691 |     qFileDialogUi->listView->hide();  | - | 
| 2692 |     qFileDialogUi->treeView->show();  | - | 
| 2693 |     qFileDialogUi->stackedWidget->setCurrentWidget(qFileDialogUi->treeView->parentWidget());  | - | 
| 2694 |     qFileDialogUi->treeView->doItemsLayout();  | - | 
| 2695 | }  | - | 
| 2696 |   | - | 
| 2697 | /*!  | - | 
| 2698 |     \internal  | - | 
| 2699 |   | - | 
| 2700 |     Show the context menu for the file/dir under position  | - | 
| 2701 | */  | - | 
| 2702 | void QFileDialogPrivate::_q_showContextMenu(const QPoint &position)  | - | 
| 2703 | {  | - | 
| 2704 | #ifdef QT_NO_MENU  | - | 
| 2705 |     Q_UNUSED(position);  | - | 
| 2706 | #else  | - | 
| 2707 |     Q_Q(QFileDialog);  | - | 
| 2708 |     QAbstractItemView *view = 0;  | - | 
| 2709 |     if (q->viewMode() == QFileDialog::Detail)  | - | 
| 2710 |         view = qFileDialogUi->treeView;  | - | 
| 2711 |     else  | - | 
| 2712 |         view = qFileDialogUi->listView;  | - | 
| 2713 |     QModelIndex index = view->indexAt(position);  | - | 
| 2714 |     index = mapToSource(index.sibling(index.row(), 0));  | - | 
| 2715 |   | - | 
| 2716 |     QMenu menu(view);  | - | 
| 2717 |     if (index.isValid()) {  | - | 
| 2718 |         // file context menu  | - | 
| 2719 |         const bool ro = model && model->isReadOnly();  | - | 
| 2720 |         QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt());  | - | 
| 2721 |         renameAction->setEnabled(!ro && p & QFile::WriteUser);  | - | 
| 2722 |         menu.addAction(renameAction);  | - | 
| 2723 |         deleteAction->setEnabled(!ro && p & QFile::WriteUser);  | - | 
| 2724 |         menu.addAction(deleteAction);  | - | 
| 2725 |         menu.addSeparator();  | - | 
| 2726 |     }  | - | 
| 2727 |     menu.addAction(showHiddenAction);  | - | 
| 2728 |     if (qFileDialogUi->newFolderButton->isVisible()) {  | - | 
| 2729 |         newFolderAction->setEnabled(qFileDialogUi->newFolderButton->isEnabled());  | - | 
| 2730 |         menu.addAction(newFolderAction);  | - | 
| 2731 |     }  | - | 
| 2732 |     menu.exec(view->viewport()->mapToGlobal(position));  | - | 
| 2733 | #endif // QT_NO_MENU  | - | 
| 2734 | }  | - | 
| 2735 |   | - | 
| 2736 | /*!  | - | 
| 2737 |     \internal  | - | 
| 2738 | */  | - | 
| 2739 | void QFileDialogPrivate::_q_renameCurrent()  | - | 
| 2740 | {  | - | 
| 2741 |     Q_Q(QFileDialog);  | - | 
| 2742 |     QModelIndex index = qFileDialogUi->listView->currentIndex();  | - | 
| 2743 |     index = index.sibling(index.row(), 0);  | - | 
| 2744 |     if (q->viewMode() == QFileDialog::List)  | - | 
| 2745 |         qFileDialogUi->listView->edit(index);  | - | 
| 2746 |     else  | - | 
| 2747 |         qFileDialogUi->treeView->edit(index);  | - | 
| 2748 | }  | - | 
| 2749 |   | - | 
| 2750 | bool QFileDialogPrivate::removeDirectory(const QString &path)  | - | 
| 2751 | {  | - | 
| 2752 |     QModelIndex modelIndex = model->index(path);  | - | 
| 2753 |     return model->remove(modelIndex);  | - | 
| 2754 | }  | - | 
| 2755 |   | - | 
| 2756 | /*!  | - | 
| 2757 |     \internal  | - | 
| 2758 |   | - | 
| 2759 |     Deletes the currently selected item in the dialog.  | - | 
| 2760 | */  | - | 
| 2761 | void QFileDialogPrivate::_q_deleteCurrent()  | - | 
| 2762 | {  | - | 
| 2763 |     if (model->isReadOnly())  | - | 
| 2764 |         return;  | - | 
| 2765 |   | - | 
| 2766 |     QModelIndexList list = qFileDialogUi->listView->selectionModel()->selectedRows();  | - | 
| 2767 |     for (int i = list.count() - 1; i >= 0; --i) {  | - | 
| 2768 |         QModelIndex index = list.at(i);  | - | 
| 2769 |         if (index == qFileDialogUi->listView->rootIndex())  | - | 
| 2770 |             continue;  | - | 
| 2771 |   | - | 
| 2772 |         index = mapToSource(index.sibling(index.row(), 0));  | - | 
| 2773 |         if (!index.isValid())  | - | 
| 2774 |             continue;  | - | 
| 2775 |   | - | 
| 2776 |     QString fileName = index.data(QFileSystemModel::FileNameRole).toString();  | - | 
| 2777 |     QString filePath = index.data(QFileSystemModel::FilePathRole).toString();  | - | 
| 2778 |     bool isDir = model->isDir(index);  | - | 
| 2779 |   | - | 
| 2780 |     QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt());  | - | 
| 2781 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 2782 |     Q_Q(QFileDialog);  | - | 
| 2783 |     if (!(p & QFile::WriteUser) && (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"),  | - | 
| 2784 |                                 QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?")  | - | 
| 2785 |                                 .arg(fileName),  | - | 
| 2786 |                                  QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No))  | - | 
| 2787 |         return;  | - | 
| 2788 |     else if (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"),  | - | 
| 2789 |                                   QFileDialog::tr("Are you sure you want to delete '%1'?")  | - | 
| 2790 |                                   .arg(fileName),  | - | 
| 2791 |                                   QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)  | - | 
| 2792 |         return;  | - | 
| 2793 |   | - | 
| 2794 | #else  | - | 
| 2795 |     if (!(p & QFile::WriteUser))  | - | 
| 2796 |         return;  | - | 
| 2797 | #endif // QT_NO_MESSAGEBOX  | - | 
| 2798 |   | - | 
| 2799 |         // the event loop has run, we can NOT reuse index because the model might have removed it.  | - | 
| 2800 |         if (isDir) {  | - | 
| 2801 |             if (!removeDirectory(filePath)) {  | - | 
| 2802 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 2803 |             QMessageBox::warning(q, q->windowTitle(),  | - | 
| 2804 |                                 QFileDialog::tr("Could not delete directory."));  | - | 
| 2805 | #endif  | - | 
| 2806 |             }  | - | 
| 2807 |         } else {  | - | 
| 2808 |             model->remove(index);  | - | 
| 2809 |         }  | - | 
| 2810 |     }  | - | 
| 2811 | }  | - | 
| 2812 |   | - | 
| 2813 | void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text)  | - | 
| 2814 | {  | - | 
| 2815 |     if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) {  | - | 
| 2816 |         qFileDialogUi->listView->selectionModel()->clearSelection();  | - | 
| 2817 |         return;  | - | 
| 2818 |     }  | - | 
| 2819 |   | - | 
| 2820 |     QStringList multipleFiles = typedFiles();  | - | 
| 2821 |     if (multipleFiles.count() > 0) {  | - | 
| 2822 |         QModelIndexList oldFiles = qFileDialogUi->listView->selectionModel()->selectedRows();  | - | 
| 2823 |         QModelIndexList newFiles;  | - | 
| 2824 |         for (int i = 0; i < multipleFiles.count(); ++i) {  | - | 
| 2825 |             QModelIndex idx = model->index(multipleFiles.at(i));  | - | 
| 2826 |             if (oldFiles.contains(idx))  | - | 
| 2827 |                 oldFiles.removeAll(idx);  | - | 
| 2828 |             else  | - | 
| 2829 |                 newFiles.append(idx);  | - | 
| 2830 |         }  | - | 
| 2831 |         for (int i = 0; i < newFiles.count(); ++i)  | - | 
| 2832 |             select(newFiles.at(i));  | - | 
| 2833 |         if (lineEdit()->hasFocus())  | - | 
| 2834 |             for (int i = 0; i < oldFiles.count(); ++i)  | - | 
| 2835 |                 qFileDialogUi->listView->selectionModel()->select(oldFiles.at(i),  | - | 
| 2836 |                     QItemSelectionModel::Toggle | QItemSelectionModel::Rows);  | - | 
| 2837 |     }  | - | 
| 2838 | }  | - | 
| 2839 |   | - | 
| 2840 | /*!  | - | 
| 2841 |     \internal  | - | 
| 2842 | */  | - | 
| 2843 | void QFileDialogPrivate::_q_updateOkButton()  | - | 
| 2844 | {  | - | 
| 2845 |     Q_Q(QFileDialog);  | - | 
| 2846 |     QPushButton *button =  qFileDialogUi->buttonBox->button((q->acceptMode() == QFileDialog::AcceptOpen)  | - | 
| 2847 |                     ? QDialogButtonBox::Open : QDialogButtonBox::Save);  | - | 
| 2848 |     if (!button)  | - | 
| 2849 |         return;  | - | 
| 2850 |     const QFileDialog::FileMode fileMode = q->fileMode();  | - | 
| 2851 |   | - | 
| 2852 |     bool enableButton = true;  | - | 
| 2853 |     bool isOpenDirectory = false;  | - | 
| 2854 |   | - | 
| 2855 |     QStringList files = q->selectedFiles();  | - | 
| 2856 |     QString lineEditText = lineEdit()->text();  | - | 
| 2857 |   | - | 
| 2858 |     if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) {  | - | 
| 2859 |         button->setEnabled(true);  | - | 
| 2860 |         updateOkButtonText();  | - | 
| 2861 |         return;  | - | 
| 2862 |     }  | - | 
| 2863 |   | - | 
| 2864 |     if (files.isEmpty()) {  | - | 
| 2865 |         enableButton = false;  | - | 
| 2866 |     } else if (lineEditText == QLatin1String("..")) {  | - | 
| 2867 |         isOpenDirectory = true;  | - | 
| 2868 |     } else {  | - | 
| 2869 |         switch (fileMode) {  | - | 
| 2870 |         case QFileDialog::DirectoryOnly:  | - | 
| 2871 |         case QFileDialog::Directory: {  | - | 
| 2872 |             QString fn = files.first();  | - | 
| 2873 |             QModelIndex idx = model->index(fn);  | - | 
| 2874 |             if (!idx.isValid())  | - | 
| 2875 |                 idx = model->index(getEnvironmentVariable(fn));  | - | 
| 2876 |             if (!idx.isValid() || !model->isDir(idx))  | - | 
| 2877 |                 enableButton = false;  | - | 
| 2878 |             break;  | - | 
| 2879 |         }  | - | 
| 2880 |         case QFileDialog::AnyFile: {  | - | 
| 2881 |             QString fn = files.first();  | - | 
| 2882 |             QFileInfo info(fn);  | - | 
| 2883 |             QModelIndex idx = model->index(fn);  | - | 
| 2884 |             QString fileDir;  | - | 
| 2885 |             QString fileName;  | - | 
| 2886 |             if (info.isDir()) {  | - | 
| 2887 |                 fileDir = info.canonicalFilePath();  | - | 
| 2888 |             } else {  | - | 
| 2889 |                 fileDir = fn.mid(0, fn.lastIndexOf(QLatin1Char('/')));  | - | 
| 2890 |                 fileName = fn.mid(fileDir.length() + 1);  | - | 
| 2891 |             }  | - | 
| 2892 |             if (lineEditText.contains(QLatin1String(".."))) {  | - | 
| 2893 |                 fileDir = info.canonicalFilePath();  | - | 
| 2894 |                 fileName = info.fileName();  | - | 
| 2895 |             }  | - | 
| 2896 |   | - | 
| 2897 |             if (fileDir == q->directory().canonicalPath() && fileName.isEmpty()) {  | - | 
| 2898 |                 enableButton = false;  | - | 
| 2899 |                 break;  | - | 
| 2900 |             }  | - | 
| 2901 |             if (idx.isValid() && model->isDir(idx)) {  | - | 
| 2902 |                 isOpenDirectory = true;  | - | 
| 2903 |                 enableButton = true;  | - | 
| 2904 |                 break;  | - | 
| 2905 |             }  | - | 
| 2906 |             if (!idx.isValid()) {  | - | 
| 2907 |                 int maxLength = maxNameLength(fileDir);  | - | 
| 2908 |                 enableButton = maxLength < 0 || fileName.length() <= maxLength;  | - | 
| 2909 |             }  | - | 
| 2910 |             break;  | - | 
| 2911 |         }  | - | 
| 2912 |         case QFileDialog::ExistingFile:  | - | 
| 2913 |         case QFileDialog::ExistingFiles:  | - | 
| 2914 |             for (int i = 0; i < files.count(); ++i) {  | - | 
| 2915 |                 QModelIndex idx = model->index(files.at(i));  | - | 
| 2916 |                 if (!idx.isValid())  | - | 
| 2917 |                     idx = model->index(getEnvironmentVariable(files.at(i)));  | - | 
| 2918 |                 if (!idx.isValid()) {  | - | 
| 2919 |                     enableButton = false;  | - | 
| 2920 |                     break;  | - | 
| 2921 |                 }  | - | 
| 2922 |                 if (idx.isValid() && model->isDir(idx)) {  | - | 
| 2923 |                     isOpenDirectory = true;  | - | 
| 2924 |                     break;  | - | 
| 2925 |                 }  | - | 
| 2926 |             }  | - | 
| 2927 |             break;  | - | 
| 2928 |         default:  | - | 
| 2929 |             break;  | - | 
| 2930 |         }  | - | 
| 2931 |     }  | - | 
| 2932 |   | - | 
| 2933 |     button->setEnabled(enableButton);  | - | 
| 2934 |     updateOkButtonText(isOpenDirectory);  | - | 
| 2935 | }  | - | 
| 2936 |   | - | 
| 2937 | /*!  | - | 
| 2938 |     \internal  | - | 
| 2939 | */  | - | 
| 2940 | void QFileDialogPrivate::_q_currentChanged(const QModelIndex &index)  | - | 
| 2941 | {  | - | 
| 2942 |     _q_updateOkButton();  | - | 
| 2943 |     emit q_func()->currentChanged(index.data(QFileSystemModel::FilePathRole).toString());  | - | 
| 2944 | }  | - | 
| 2945 |   | - | 
| 2946 | /*!  | - | 
| 2947 |     \internal  | - | 
| 2948 |   | - | 
| 2949 |     This is called when the user double clicks on a file with the corresponding  | - | 
| 2950 |     model item \a index.  | - | 
| 2951 | */  | - | 
| 2952 | void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)  | - | 
| 2953 | {  | - | 
| 2954 |     Q_Q(QFileDialog); executed (the execution status of this line is deduced):  QFileDialog * const q = q_func();  | - | 
| 2955 |     // My Computer or a directory  | - | 
| 2956 |     QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index; partially evaluated:  index.model() == proxyModel| no Evaluation Count:0  | yes Evaluation Count:5  |  
   | 0-5 | 
| 2957 |     QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); executed (the execution status of this line is deduced):  QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString();  | - | 
| 2958 |     if (path.isEmpty() || model->isDir(sourceIndex)) { partially evaluated:  path.isEmpty()| no Evaluation Count:0  | yes Evaluation Count:5  |  
  partially evaluated:  model->isDir(sourceIndex)| yes Evaluation Count:5  | no Evaluation Count:0  |  
   | 0-5 | 
| 2959 |         const QFileDialog::FileMode fileMode = q->fileMode(); executed (the execution status of this line is deduced):  const QFileDialog::FileMode fileMode = q->fileMode();  | - | 
| 2960 |         q->setDirectory(path); executed (the execution status of this line is deduced):  q->setDirectory(path);  | - | 
| 2961 |         emit q->directoryEntered(path); executed (the execution status of this line is deduced):  q->directoryEntered(path);  | - | 
| 2962 |         if (fileMode == QFileDialog::Directory evaluated:  fileMode == QFileDialog::Directory| yes Evaluation Count:2  | yes Evaluation Count:3  |  
   | 2-3 | 
| 2963 |                 || fileMode == QFileDialog::DirectoryOnly) { partially evaluated:  fileMode == QFileDialog::DirectoryOnly| no Evaluation Count:0  | yes Evaluation Count:3  |  
   | 0-3 | 
| 2964 |             // ### find out why you have to do both of these.  | - | 
| 2965 |             lineEdit()->setText(QString()); executed (the execution status of this line is deduced):  lineEdit()->setText(QString());  | - | 
| 2966 |             lineEdit()->clear(); executed (the execution status of this line is deduced):  lineEdit()->clear();  | - | 
| 2967 |         } executed:  }Execution Count:2   | 2 | 
| 2968 |     } else { executed:  }Execution Count:5   | 5 | 
| 2969 |         // Do not accept when shift-clicking to multi-select a file in environments with single-click-activation (KDE)  | - | 
| 2970 |         if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) never evaluated: !q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)  | 0 | 
| 2971 |             || q->fileMode() != QFileDialog::ExistingFiles || !(QGuiApplication::keyboardModifiers() & Qt::CTRL)) { never evaluated: q->fileMode() != QFileDialog::ExistingFiles never evaluated: !(QGuiApplication::keyboardModifiers() & Qt::CTRL)  | 0 | 
| 2972 |             q->accept(); never executed (the execution status of this line is deduced):  q->accept();  | - | 
| 2973 |         }  | 0 | 
| 2974 |     }  | 0 | 
| 2975 | }  | - | 
| 2976 |   | - | 
| 2977 | /*!  | - | 
| 2978 |     \internal  | - | 
| 2979 |   | - | 
| 2980 |     Changes the file dialog's current directory to the one specified  | - | 
| 2981 |     by \a path.  | - | 
| 2982 | */  | - | 
| 2983 | void QFileDialogPrivate::_q_goToDirectory(const QString &path)  | - | 
| 2984 | {  | - | 
| 2985 |  #ifndef QT_NO_MESSAGEBOX  | - | 
| 2986 |     Q_Q(QFileDialog);  | - | 
| 2987 | #endif  | - | 
| 2988 |     QModelIndex index = qFileDialogUi->lookInCombo->model()->index(qFileDialogUi->lookInCombo->currentIndex(),  | - | 
| 2989 |                                                     qFileDialogUi->lookInCombo->modelColumn(),  | - | 
| 2990 |                                                     qFileDialogUi->lookInCombo->rootModelIndex());  | - | 
| 2991 |     QString path2 = path;  | - | 
| 2992 |     if (!index.isValid())  | - | 
| 2993 |         index = mapFromSource(model->index(getEnvironmentVariable(path)));  | - | 
| 2994 |     else {  | - | 
| 2995 |         path2 = index.data(UrlRole).toUrl().toLocalFile();  | - | 
| 2996 |         index = mapFromSource(model->index(path2));  | - | 
| 2997 |     }  | - | 
| 2998 |     QDir dir(path2);  | - | 
| 2999 |     if (!dir.exists())  | - | 
| 3000 |         dir = getEnvironmentVariable(path2);  | - | 
| 3001 |   | - | 
| 3002 |     if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) {  | - | 
| 3003 |         _q_enterDirectory(index);  | - | 
| 3004 | #ifndef QT_NO_MESSAGEBOX  | - | 
| 3005 |     } else {  | - | 
| 3006 |         QString message = QFileDialog::tr("%1\nDirectory not found.\nPlease verify the "  | - | 
| 3007 |                                           "correct directory name was given.");  | - | 
| 3008 |         QMessageBox::warning(q, q->windowTitle(), message.arg(path2));  | - | 
| 3009 | #endif // QT_NO_MESSAGEBOX  | - | 
| 3010 |     }  | - | 
| 3011 | }  | - | 
| 3012 |   | - | 
| 3013 | /*!  | - | 
| 3014 |     \internal  | - | 
| 3015 |   | - | 
| 3016 |     Sets the current name filter to be nameFilter and  | - | 
| 3017 |     update the qFileDialogUi->fileNameEdit when in AcceptSave mode with the new extension.  | - | 
| 3018 | */  | - | 
| 3019 | void QFileDialogPrivate::_q_useNameFilter(int index)  | - | 
| 3020 | {  | - | 
| 3021 |     QStringList nameFilters = options->nameFilters();  | - | 
| 3022 |     if (index == nameFilters.size()) {  | - | 
| 3023 |         QAbstractItemModel *comboModel = qFileDialogUi->fileTypeCombo->model();  | - | 
| 3024 |         nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString());  | - | 
| 3025 |         options->setNameFilters(nameFilters);  | - | 
| 3026 |     }  | - | 
| 3027 |   | - | 
| 3028 |     QString nameFilter = nameFilters.at(index);  | - | 
| 3029 |     QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter);  | - | 
| 3030 |     if (q_func()->acceptMode() == QFileDialog::AcceptSave) {  | - | 
| 3031 |         QString newNameFilterExtension;  | - | 
| 3032 |         if (newNameFilters.count() > 0)  | - | 
| 3033 |             newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix();  | - | 
| 3034 |   | - | 
| 3035 |         QString fileName = lineEdit()->text();  | - | 
| 3036 |         const QString fileNameExtension = QFileInfo(fileName).suffix();  | - | 
| 3037 |         if (!fileNameExtension.isEmpty() && !newNameFilterExtension.isEmpty()) {  | - | 
| 3038 |             const int fileNameExtensionLength = fileNameExtension.count();  | - | 
| 3039 |             fileName.replace(fileName.count() - fileNameExtensionLength,  | - | 
| 3040 |                              fileNameExtensionLength, newNameFilterExtension);  | - | 
| 3041 |             qFileDialogUi->listView->clearSelection();  | - | 
| 3042 |             lineEdit()->setText(fileName);  | - | 
| 3043 |         }  | - | 
| 3044 |     }  | - | 
| 3045 |   | - | 
| 3046 |     model->setNameFilters(newNameFilters);  | - | 
| 3047 | }  | - | 
| 3048 |   | - | 
| 3049 | /*!  | - | 
| 3050 |     \internal  | - | 
| 3051 |   | - | 
| 3052 |     This is called when the model index corresponding to the current file is changed  | - | 
| 3053 |     from \a index to \a current.  | - | 
| 3054 | */  | - | 
| 3055 | void QFileDialogPrivate::_q_selectionChanged()  | - | 
| 3056 | {  | - | 
| 3057 |     const QFileDialog::FileMode fileMode = q_func()->fileMode();  | - | 
| 3058 |     QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows();  | - | 
| 3059 |     bool stripDirs = (fileMode != QFileDialog::DirectoryOnly && fileMode != QFileDialog::Directory);  | - | 
| 3060 |   | - | 
| 3061 |     QStringList allFiles;  | - | 
| 3062 |     for (int i = 0; i < indexes.count(); ++i) {  | - | 
| 3063 |         if (stripDirs && model->isDir(mapToSource(indexes.at(i))))  | - | 
| 3064 |             continue;  | - | 
| 3065 |         allFiles.append(indexes.at(i).data().toString());  | - | 
| 3066 |     }  | - | 
| 3067 |     if (allFiles.count() > 1)  | - | 
| 3068 |         for (int i = 0; i < allFiles.count(); ++i) {  | - | 
| 3069 |             allFiles.replace(i, QString(QLatin1Char('"') + allFiles.at(i) + QLatin1Char('"')));  | - | 
| 3070 |     }  | - | 
| 3071 |   | - | 
| 3072 |     QString finalFiles = allFiles.join(QLatin1Char(' '));  | - | 
| 3073 |     if (!finalFiles.isEmpty() && !lineEdit()->hasFocus() && lineEdit()->isVisible())  | - | 
| 3074 |         lineEdit()->setText(finalFiles);  | - | 
| 3075 |     else  | - | 
| 3076 |         _q_updateOkButton();  | - | 
| 3077 | }  | - | 
| 3078 |   | - | 
| 3079 | /*!  | - | 
| 3080 |     \internal  | - | 
| 3081 |   | - | 
| 3082 |     Includes hidden files and directories in the items displayed in the dialog.  | - | 
| 3083 | */  | - | 
| 3084 | void QFileDialogPrivate::_q_showHidden()  | - | 
| 3085 | {  | - | 
| 3086 |     Q_Q(QFileDialog);  | - | 
| 3087 |     QDir::Filters dirFilters = q->filter();  | - | 
| 3088 |     if (showHiddenAction->isChecked())  | - | 
| 3089 |         dirFilters |= QDir::Hidden;  | - | 
| 3090 |     else  | - | 
| 3091 |         dirFilters &= ~QDir::Hidden;  | - | 
| 3092 |     q->setFilter(dirFilters);  | - | 
| 3093 | }  | - | 
| 3094 |   | - | 
| 3095 | /*!  | - | 
| 3096 |     \internal  | - | 
| 3097 |   | - | 
| 3098 |     When parent is root and rows have been inserted when none was there before  | - | 
| 3099 |     then select the first one.  | - | 
| 3100 | */  | - | 
| 3101 | void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent)  | - | 
| 3102 | {  | - | 
| 3103 |     if (!qFileDialogUi->treeView  | - | 
| 3104 |         || parent != qFileDialogUi->treeView->rootIndex()  | - | 
| 3105 |         || !qFileDialogUi->treeView->selectionModel()  | - | 
| 3106 |         || qFileDialogUi->treeView->selectionModel()->hasSelection()  | - | 
| 3107 |         || qFileDialogUi->treeView->model()->rowCount(parent) == 0)  | - | 
| 3108 |         return;  | - | 
| 3109 | }  | - | 
| 3110 |   | - | 
| 3111 | void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString oldName, const QString newName)  | - | 
| 3112 | {  | - | 
| 3113 |     const QFileDialog::FileMode fileMode = q_func()->fileMode();  | - | 
| 3114 |     if (fileMode == QFileDialog::Directory || fileMode == QFileDialog::DirectoryOnly) {  | - | 
| 3115 |         if (path == rootPath() && lineEdit()->text() == oldName)  | - | 
| 3116 |             lineEdit()->setText(newName);  | - | 
| 3117 |     }  | - | 
| 3118 | }  | - | 
| 3119 |   | - | 
| 3120 | void QFileDialogPrivate::_q_nativeEnterDirectory(const QString &directory)  | - | 
| 3121 | {  | - | 
| 3122 |     if (!directory.isEmpty()) // Windows native dialogs occasionally emit signals with empty strings. never evaluated: !directory.isEmpty()  | 0 | 
| 3123 |         *lastVisitedDir() = directory; never executed: *lastVisitedDir() = directory;  | 0 | 
| 3124 | }  | 0 | 
| 3125 |   | - | 
| 3126 | /*!  | - | 
| 3127 |     \internal  | - | 
| 3128 |   | - | 
| 3129 |     For the list and tree view watch keys to goto parent and back in the history  | - | 
| 3130 |   | - | 
| 3131 |     returns true if handled  | - | 
| 3132 | */  | - | 
| 3133 | bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {  | - | 
| 3134 |   | - | 
| 3135 |     Q_Q(QFileDialog);  | - | 
| 3136 |     switch (event->key()) {  | - | 
| 3137 |     case Qt::Key_Backspace:  | - | 
| 3138 |         _q_navigateToParent();  | - | 
| 3139 |         return true;  | - | 
| 3140 |     case Qt::Key_Back:  | - | 
| 3141 | #ifdef QT_KEYPAD_NAVIGATION  | - | 
| 3142 |         if (QApplication::keypadNavigationEnabled())  | - | 
| 3143 |             return false;  | - | 
| 3144 | #endif  | - | 
| 3145 |     case Qt::Key_Left:  | - | 
| 3146 |         if (event->key() == Qt::Key_Back || event->modifiers() == Qt::AltModifier) {  | - | 
| 3147 |             _q_navigateBackward();  | - | 
| 3148 |             return true;  | - | 
| 3149 |         }  | - | 
| 3150 |         break;  | - | 
| 3151 |     case Qt::Key_Escape:  | - | 
| 3152 |         q->hide();  | - | 
| 3153 |         return true;  | - | 
| 3154 |     default:  | - | 
| 3155 |         break;  | - | 
| 3156 |     }  | - | 
| 3157 |     return false;  | - | 
| 3158 | }  | - | 
| 3159 |   | - | 
| 3160 | QString QFileDialogPrivate::getEnvironmentVariable(const QString &string)  | - | 
| 3161 | {  | - | 
| 3162 | #ifdef Q_OS_UNIX  | - | 
| 3163 |     if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) {  | - | 
| 3164 |         return QString::fromLocal8Bit(getenv(string.mid(1).toLatin1().constData()));  | - | 
| 3165 |     }  | - | 
| 3166 | #else  | - | 
| 3167 |     if (string.size() > 2 && string.startsWith(QLatin1Char('%')) && string.endsWith(QLatin1Char('%'))) {  | - | 
| 3168 |         return QString::fromLocal8Bit(qgetenv(string.mid(1, string.size() - 2).toLatin1().constData()));  | - | 
| 3169 |     }  | - | 
| 3170 | #endif  | - | 
| 3171 |     return string;  | - | 
| 3172 | }  | - | 
| 3173 |   | - | 
| 3174 | void QFileDialogComboBox::setFileDialogPrivate(QFileDialogPrivate *d_pointer) {  | - | 
| 3175 |     d_ptr = d_pointer;  | - | 
| 3176 |     urlModel = new QUrlModel(this);  | - | 
| 3177 |     urlModel->showFullPath = true;  | - | 
| 3178 |     urlModel->setFileSystemModel(d_ptr->model);  | - | 
| 3179 |     setModel(urlModel);  | - | 
| 3180 | }  | - | 
| 3181 |   | - | 
| 3182 | void QFileDialogComboBox::showPopup()  | - | 
| 3183 | {  | - | 
| 3184 |     if (model()->rowCount() > 1)  | - | 
| 3185 |         QComboBox::showPopup();  | - | 
| 3186 |   | - | 
| 3187 |     urlModel->setUrls(QList<QUrl>());  | - | 
| 3188 |     QList<QUrl> list;  | - | 
| 3189 |     QModelIndex idx = d_ptr->model->index(d_ptr->rootPath());  | - | 
| 3190 |     while (idx.isValid()) {  | - | 
| 3191 |         QUrl url = QUrl::fromLocalFile(idx.data(QFileSystemModel::FilePathRole).toString());  | - | 
| 3192 |         if (url.isValid())  | - | 
| 3193 |             list.append(url);  | - | 
| 3194 |         idx = idx.parent();  | - | 
| 3195 |     }  | - | 
| 3196 |     // add "my computer"  | - | 
| 3197 |     list.append(QUrl::fromLocalFile(QLatin1String("")));  | - | 
| 3198 |     urlModel->addUrls(list, 0);  | - | 
| 3199 |     idx = model()->index(model()->rowCount() - 1, 0);  | - | 
| 3200 |   | - | 
| 3201 |     // append history  | - | 
| 3202 |     QList<QUrl> urls;  | - | 
| 3203 |     for (int i = 0; i < m_history.count(); ++i) {  | - | 
| 3204 |         QUrl path = QUrl::fromLocalFile(m_history.at(i));  | - | 
| 3205 |         if (!urls.contains(path))  | - | 
| 3206 |             urls.prepend(path);  | - | 
| 3207 |     }  | - | 
| 3208 |     if (urls.count() > 0) {  | - | 
| 3209 |         model()->insertRow(model()->rowCount());  | - | 
| 3210 |         idx = model()->index(model()->rowCount()-1, 0);  | - | 
| 3211 |         // ### TODO maybe add a horizontal line before this  | - | 
| 3212 |         model()->setData(idx, QFileDialog::tr("Recent Places"));  | - | 
| 3213 |         QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model());  | - | 
| 3214 |         if (m) {  | - | 
| 3215 |             Qt::ItemFlags flags = m->flags(idx);  | - | 
| 3216 |             flags &= ~Qt::ItemIsEnabled;  | - | 
| 3217 |             m->item(idx.row(), idx.column())->setFlags(flags);  | - | 
| 3218 |         }  | - | 
| 3219 |         urlModel->addUrls(urls, -1, false);  | - | 
| 3220 |     }  | - | 
| 3221 |     setCurrentIndex(0);  | - | 
| 3222 |   | - | 
| 3223 |     QComboBox::showPopup();  | - | 
| 3224 | }  | - | 
| 3225 |   | - | 
| 3226 | // Exact same as QComboBox::paintEvent(), except we elide the text.  | - | 
| 3227 | void QFileDialogComboBox::paintEvent(QPaintEvent *)  | - | 
| 3228 | {  | - | 
| 3229 |     QStylePainter painter(this);  | - | 
| 3230 |     painter.setPen(palette().color(QPalette::Text));  | - | 
| 3231 |   | - | 
| 3232 |     // draw the combobox frame, focusrect and selected etc.  | - | 
| 3233 |     QStyleOptionComboBox opt;  | - | 
| 3234 |     initStyleOption(&opt);  | - | 
| 3235 |   | - | 
| 3236 |     QRect editRect = style()->subControlRect(QStyle::CC_ComboBox, &opt,  | - | 
| 3237 |                                                 QStyle::SC_ComboBoxEditField, this);  | - | 
| 3238 |     int size = editRect.width() - opt.iconSize.width() - 4;  | - | 
| 3239 |     opt.currentText = opt.fontMetrics.elidedText(opt.currentText, Qt::ElideMiddle, size);  | - | 
| 3240 |     painter.drawComplexControl(QStyle::CC_ComboBox, opt);  | - | 
| 3241 |   | - | 
| 3242 |     // draw the icon and text  | - | 
| 3243 |     painter.drawControl(QStyle::CE_ComboBoxLabel, opt);  | - | 
| 3244 | }  | - | 
| 3245 |   | - | 
| 3246 | QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent)  | - | 
| 3247 | {  | - | 
| 3248 | }  | - | 
| 3249 |   | - | 
| 3250 | void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)  | - | 
| 3251 | {  | - | 
| 3252 |     d_ptr = d_pointer;  | - | 
| 3253 |     setSelectionBehavior(QAbstractItemView::SelectRows);  | - | 
| 3254 |     setWrapping(true);  | - | 
| 3255 |     setResizeMode(QListView::Adjust);  | - | 
| 3256 |     setEditTriggers(QAbstractItemView::EditKeyPressed);  | - | 
| 3257 |     setContextMenuPolicy(Qt::CustomContextMenu);  | - | 
| 3258 | #ifndef QT_NO_DRAGANDDROP  | - | 
| 3259 |     setDragDropMode(QAbstractItemView::InternalMove);  | - | 
| 3260 | #endif  | - | 
| 3261 | }  | - | 
| 3262 |   | - | 
| 3263 | QSize QFileDialogListView::sizeHint() const  | - | 
| 3264 | {  | - | 
| 3265 |     int height = qMax(10, sizeHintForRow(0));  | - | 
| 3266 |     return QSize(QListView::sizeHint().width() * 2, height * 30);  | - | 
| 3267 | }  | - | 
| 3268 |   | - | 
| 3269 | void QFileDialogListView::keyPressEvent(QKeyEvent *e)  | - | 
| 3270 | {  | - | 
| 3271 | #ifdef QT_KEYPAD_NAVIGATION  | - | 
| 3272 |     if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {  | - | 
| 3273 |         QListView::keyPressEvent(e);  | - | 
| 3274 |         return;  | - | 
| 3275 |     }  | - | 
| 3276 | #endif // QT_KEYPAD_NAVIGATION  | - | 
| 3277 |   | - | 
| 3278 |     if (!d_ptr->itemViewKeyboardEvent(e))  | - | 
| 3279 |         QListView::keyPressEvent(e);  | - | 
| 3280 |     e->accept();  | - | 
| 3281 | }  | - | 
| 3282 |   | - | 
| 3283 | QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent)  | - | 
| 3284 | {  | - | 
| 3285 | }  | - | 
| 3286 |   | - | 
| 3287 | void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)  | - | 
| 3288 | {  | - | 
| 3289 |     d_ptr = d_pointer;  | - | 
| 3290 |     setSelectionBehavior(QAbstractItemView::SelectRows);  | - | 
| 3291 |     setRootIsDecorated(false);  | - | 
| 3292 |     setItemsExpandable(false);  | - | 
| 3293 |     setSortingEnabled(true);  | - | 
| 3294 |     header()->setSortIndicator(0, Qt::AscendingOrder);  | - | 
| 3295 |     header()->setStretchLastSection(false);  | - | 
| 3296 |     setTextElideMode(Qt::ElideMiddle);  | - | 
| 3297 |     setEditTriggers(QAbstractItemView::EditKeyPressed);  | - | 
| 3298 |     setContextMenuPolicy(Qt::CustomContextMenu);  | - | 
| 3299 | #ifndef QT_NO_DRAGANDDROP  | - | 
| 3300 |     setDragDropMode(QAbstractItemView::InternalMove);  | - | 
| 3301 | #endif  | - | 
| 3302 | }  | - | 
| 3303 |   | - | 
| 3304 | void QFileDialogTreeView::keyPressEvent(QKeyEvent *e)  | - | 
| 3305 | {  | - | 
| 3306 | #ifdef QT_KEYPAD_NAVIGATION  | - | 
| 3307 |     if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {  | - | 
| 3308 |         QTreeView::keyPressEvent(e);  | - | 
| 3309 |         return;  | - | 
| 3310 |     }  | - | 
| 3311 | #endif // QT_KEYPAD_NAVIGATION  | - | 
| 3312 |   | - | 
| 3313 |     if (!d_ptr->itemViewKeyboardEvent(e))  | - | 
| 3314 |         QTreeView::keyPressEvent(e);  | - | 
| 3315 |     e->accept();  | - | 
| 3316 | }  | - | 
| 3317 |   | - | 
| 3318 | QSize QFileDialogTreeView::sizeHint() const  | - | 
| 3319 | {  | - | 
| 3320 |     int height = qMax(10, sizeHintForRow(0));  | - | 
| 3321 |     QSize sizeHint = header()->sizeHint();  | - | 
| 3322 |     return QSize(sizeHint.width() * 4, height * 30);  | - | 
| 3323 | }  | - | 
| 3324 |   | - | 
| 3325 | /*!  | - | 
| 3326 |     // FIXME: this is a hack to avoid propagating key press events  | - | 
| 3327 |     // to the dialog and from there to the "Ok" button  | - | 
| 3328 | */  | - | 
| 3329 | void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)  | - | 
| 3330 | {  | - | 
| 3331 | #ifdef QT_KEYPAD_NAVIGATION  | - | 
| 3332 |     if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {  | - | 
| 3333 |         QLineEdit::keyPressEvent(e);  | - | 
| 3334 |         return;  | - | 
| 3335 |     }  | - | 
| 3336 | #endif // QT_KEYPAD_NAVIGATION  | - | 
| 3337 |   | - | 
| 3338 |     int key = e->key();  | - | 
| 3339 |     QLineEdit::keyPressEvent(e);  | - | 
| 3340 |     if (key != Qt::Key_Escape)  | - | 
| 3341 |         e->accept();  | - | 
| 3342 |     if (hideOnEsc && (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter)) {  | - | 
| 3343 |         e->accept();  | - | 
| 3344 |         hide();  | - | 
| 3345 |         d_ptr->currentView()->setFocus(Qt::ShortcutFocusReason);  | - | 
| 3346 |     }  | - | 
| 3347 | }  | - | 
| 3348 |   | - | 
| 3349 | #ifndef QT_NO_FSCOMPLETER  | - | 
| 3350 |   | - | 
| 3351 | QString QFSCompleter::pathFromIndex(const QModelIndex &index) const  | - | 
| 3352 | {  | - | 
| 3353 |     const QFileSystemModel *dirModel;  | - | 
| 3354 |     if (proxyModel)  | - | 
| 3355 |         dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());  | - | 
| 3356 |     else  | - | 
| 3357 |         dirModel = sourceModel;  | - | 
| 3358 |     QString currentLocation = dirModel->rootPath();  | - | 
| 3359 |     QString path = index.data(QFileSystemModel::FilePathRole).toString();  | - | 
| 3360 |     if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {  | - | 
| 3361 | #if defined(Q_OS_UNIX) || defined(Q_OS_WINCE)  | - | 
| 3362 |         if (currentLocation == QDir::separator())  | - | 
| 3363 |             return path.mid(currentLocation.length());  | - | 
| 3364 | #endif  | - | 
| 3365 |         if (currentLocation.endsWith(QLatin1Char('/')))  | - | 
| 3366 |             return path.mid(currentLocation.length());  | - | 
| 3367 |         else  | - | 
| 3368 |             return path.mid(currentLocation.length()+1);  | - | 
| 3369 |     }  | - | 
| 3370 |     return index.data(QFileSystemModel::FilePathRole).toString();  | - | 
| 3371 | }  | - | 
| 3372 |   | - | 
| 3373 | QStringList QFSCompleter::splitPath(const QString &path) const  | - | 
| 3374 | {  | - | 
| 3375 |     if (path.isEmpty())  | - | 
| 3376 |         return QStringList(completionPrefix());  | - | 
| 3377 |   | - | 
| 3378 |     QString pathCopy = QDir::toNativeSeparators(path);  | - | 
| 3379 |     QString sep = QDir::separator();  | - | 
| 3380 | #if defined(Q_OS_WIN)  | - | 
| 3381 |     if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))  | - | 
| 3382 |         return QStringList(pathCopy);  | - | 
| 3383 |     QString doubleSlash(QLatin1String("\\\\"));  | - | 
| 3384 |     if (pathCopy.startsWith(doubleSlash))  | - | 
| 3385 |         pathCopy = pathCopy.mid(2);  | - | 
| 3386 |     else  | - | 
| 3387 |         doubleSlash.clear();  | - | 
| 3388 | #elif defined(Q_OS_UNIX)  | - | 
| 3389 |     bool expanded;  | - | 
| 3390 |     pathCopy = qt_tildeExpansion(pathCopy, &expanded);  | - | 
| 3391 |     if (expanded) {  | - | 
| 3392 |         QFileSystemModel *dirModel;  | - | 
| 3393 |         if (proxyModel)  | - | 
| 3394 |             dirModel = qobject_cast<QFileSystemModel *>(proxyModel->sourceModel());  | - | 
| 3395 |         else  | - | 
| 3396 |             dirModel = sourceModel;  | - | 
| 3397 |         dirModel->fetchMore(dirModel->index(pathCopy));  | - | 
| 3398 |     }  | - | 
| 3399 | #endif  | - | 
| 3400 |   | - | 
| 3401 |     QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));  | - | 
| 3402 |   | - | 
| 3403 | #if defined(Q_OS_WIN)  | - | 
| 3404 |     QStringList parts = pathCopy.split(re, QString::SkipEmptyParts);  | - | 
| 3405 |     if (!doubleSlash.isEmpty() && !parts.isEmpty())  | - | 
| 3406 |         parts[0].prepend(doubleSlash);  | - | 
| 3407 |     if (pathCopy.endsWith(sep))  | - | 
| 3408 |         parts.append(QString());  | - | 
| 3409 | #else  | - | 
| 3410 |     QStringList parts = pathCopy.split(re);  | - | 
| 3411 |     if (pathCopy[0] == sep[0]) // read the "/" at the beginning as the split removed it  | - | 
| 3412 |         parts[0] = sep[0];  | - | 
| 3413 | #endif  | - | 
| 3414 |   | - | 
| 3415 | #if defined(Q_OS_WIN)  | - | 
| 3416 |     bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':'));  | - | 
| 3417 | #else  | - | 
| 3418 |     bool startsFromRoot = pathCopy[0] == sep[0];  | - | 
| 3419 | #endif  | - | 
| 3420 |     if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {  | - | 
| 3421 |         const QFileSystemModel *dirModel;  | - | 
| 3422 |         if (proxyModel)  | - | 
| 3423 |             dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());  | - | 
| 3424 |         else  | - | 
| 3425 |             dirModel = sourceModel;  | - | 
| 3426 |         QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath());  | - | 
| 3427 | #if defined(Q_OS_WIN)  | - | 
| 3428 |         if (currentLocation.endsWith(QLatin1Char(':')))  | - | 
| 3429 |             currentLocation.append(sep);  | - | 
| 3430 | #endif  | - | 
| 3431 |         if (currentLocation.contains(sep) && path != currentLocation) {  | - | 
| 3432 |             QStringList currentLocationList = splitPath(currentLocation);  | - | 
| 3433 |             while (!currentLocationList.isEmpty()  | - | 
| 3434 |                    && parts.count() > 0  | - | 
| 3435 |                    && parts.at(0) == QLatin1String("..")) {  | - | 
| 3436 |                 parts.removeFirst();  | - | 
| 3437 |                 currentLocationList.removeLast();  | - | 
| 3438 |             }  | - | 
| 3439 |             if (!currentLocationList.isEmpty() && currentLocationList.last().isEmpty())  | - | 
| 3440 |                 currentLocationList.removeLast();  | - | 
| 3441 |             return currentLocationList + parts;  | - | 
| 3442 |         }  | - | 
| 3443 |     }  | - | 
| 3444 |     return parts;  | - | 
| 3445 | }  | - | 
| 3446 |   | - | 
| 3447 | #endif // QT_NO_COMPLETER  | - | 
| 3448 |   | - | 
| 3449 |   | - | 
| 3450 | QT_END_NAMESPACE  | - | 
| 3451 |   | - | 
| 3452 | #include "moc_qfiledialog.cpp"  | - | 
| 3453 |   | - | 
| 3454 | #endif // QT_NO_FILEDIALOG  | - | 
| 3455 |   | - | 
 |  |  |