filemanager/filemanager_plat/inc/fmfiledialog.h
branchRCL_3
changeset 39 65326cf895ed
parent 38 491b3ed49290
child 42 f5c50b8af68c
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *     
       
    14 * 
       
    15 * Description:
       
    16 *     The header file of the file dialog
       
    17 *
       
    18 */
       
    19 
       
    20 #ifndef FMFILEDIALOG_H
       
    21 #define FMFILEDIALOG_H
       
    22 
       
    23 #include "fmglobal.h"
       
    24 
       
    25 
       
    26 #include <hbdialog.h>
       
    27 
       
    28 class QString;
       
    29 class QStringList;
       
    30 class FmFileDialogPrivate;
       
    31 
       
    32 class FMFILEDIALOG_EXPORT FmFileDialog : public HbDialog
       
    33 {
       
    34 Q_OBJECT
       
    35 public:
       
    36 
       
    37     enum Option
       
    38     {
       
    39         /* 
       
    40          * Open dir as dialog's working directory and prevent user up to parent directory
       
    41          */
       
    42         PreventDirUp    = 0x00000001,
       
    43         /* 
       
    44          * Ignore filter for dir, list all directory. Set this when need only filter filename.
       
    45          */
       
    46         DisplayAllDirs  = 0x00000002
       
    47     };
       
    48     Q_DECLARE_FLAGS(Options, Option)
       
    49 
       
    50     /**
       
    51      * Static function that will return an existing directory selected by the user
       
    52      * @param parent            Parent widget
       
    53      * @param title             Title for dialog
       
    54      * @param dir               Dialog's working directory is set to dir
       
    55      * @param nameFilters       used for filter folder
       
    56      * @param Options           Options
       
    57      * @return Directory path that user selected. 
       
    58      *         user can select cancel to close dialog and empty string will be returned
       
    59      */
       
    60     static QString getExistingDirectory( HbWidget *parent = 0,
       
    61                                         const QString &title = QString(),
       
    62                                         const QString &dir = QString(),
       
    63                                         const QStringList &nameFilters = QStringList(),
       
    64                                         Options options = 0 );
       
    65 
       
    66     /**
       
    67      * Static function that returns an existing file selected by the use
       
    68      * @param parent            Parent widget
       
    69      * @param title             Title for dialog
       
    70      * @param dir               Dialog's working directory is set to dir
       
    71      * @param nameFilters       used for filter file/folder, such as "*.jpg", "*.txt"
       
    72      *                          Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename.
       
    73      * @param Options           Options
       
    74      * @return File path that user selected. It is an esisting file.
       
    75      *         user can select cancel to close dialog and empty string will be returned
       
    76      */
       
    77     static QString getOpenFileName( HbWidget *parent = 0,
       
    78                                     const QString &title = QString(),
       
    79                                     const QString &dir = QString(),
       
    80                                     const QStringList &nameFilters = QStringList(),
       
    81                                     Options options = 0 );
       
    82     /**
       
    83      * Static function that will return a file name selected by the user. The file does not have to exist.
       
    84      * @param parent            Parent widget
       
    85      * @param title             Title for dialog
       
    86      * @param dir               Dialog's working directory is set to dir
       
    87      * @param nameFilters       used for filter file/folder, such as "*.jpg", "*.txt"
       
    88      *                          Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename.
       
    89      * @param Options           Options
       
    90      * @return File path that user selected or inputted in file name line edit.
       
    91      *         This file does not have to exist.
       
    92      *         user can select cancel to close dialog and empty string will be returned
       
    93      */
       
    94     static QString getSaveFileName( HbWidget *parent = 0,
       
    95                                     const QString &title = QString(),
       
    96                                     const QString &dir = QString(),
       
    97                                     const QStringList &nameFilters = QStringList(),
       
    98                                     Options options = 0 );
       
    99 
       
   100 private slots:
       
   101     void dialogClosed(HbAction *action);
       
   102     
       
   103 private:
       
   104     explicit FmFileDialog( QGraphicsItem *parent );
       
   105     ~FmFileDialog();
       
   106 
       
   107     bool exec();
       
   108     HbAction *primaryAction() const;
       
   109     void setPrimaryAction( HbAction *action );
       
   110 
       
   111     HbAction *secondaryAction() const;
       
   112     void setSecondaryAction( HbAction *action );
       
   113     
       
   114     FmFileDialogPrivate *d_ptr;
       
   115     
       
   116     Q_DISABLE_COPY( FmFileDialog)
       
   117     Q_DECLARE_PRIVATE_D(d_ptr,FmFileDialog)
       
   118     Q_PRIVATE_SLOT(d_func(),void _q_handleUpButton())
       
   119     Q_PRIVATE_SLOT(d_func(),void _q_handleTextChanged(QString))
       
   120     Q_PRIVATE_SLOT(d_func(),void _q_handlePathChanged(QString))
       
   121     Q_PRIVATE_SLOT(d_func(),void _q_handleFileActivated(QString))
       
   122 };
       
   123 
       
   124 Q_DECLARE_OPERATORS_FOR_FLAGS(FmFileDialog::Options)
       
   125 
       
   126 #endif // FMFILEDIALOG_H