filemanager/src/fmfiledialog/src/fmfiledialog.cpp
changeset 14 1957042d8c7e
child 18 edd66bde63a4
child 25 b7bfdea70ca2
child 46 d58987eac7e8
equal deleted inserted replaced
1:d1daf54a55b5 14:1957042d8c7e
       
     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 source file of the file dialog
       
    17 *
       
    18 */
       
    19 
       
    20 #include "fmfiledialog.h"
       
    21 #include "fmfiledialog_p.h"
       
    22 #include "fmfilewidget.h"
       
    23 #include "fmlogger.h"
       
    24 #include "fmutils.h"
       
    25 #include "fmdrivemodel.h"
       
    26 #include "fmcommon.h"
       
    27 
       
    28 #include "hbwidget.h"
       
    29 #include "hblabel.h"
       
    30 #include "hbaction.h"
       
    31 #include "hbpushbutton.h"
       
    32 #include "hblineedit.h"
       
    33 
       
    34 #include <QGraphicsLinearLayout>
       
    35 
       
    36 FmFileDialog::FmFileDialog( QGraphicsItem *parent ) : 
       
    37     HbDialog( parent ), d_ptr( new FmFileDialogPrivate( this ) )
       
    38 {
       
    39 }
       
    40 
       
    41 FmFileDialog::~FmFileDialog()
       
    42 {
       
    43     delete d_ptr;
       
    44 }
       
    45 
       
    46 QString FmFileDialog::getExistingDirectory( HbWidget *parent,
       
    47                                     const QString &title,
       
    48                                     const QString &dir,
       
    49                                     const QStringList &nameFilters,
       
    50                                     Options options )
       
    51 {
       
    52 
       
    53     QString ret;
       
    54 
       
    55     FmFileDialogPrivate::FmFileDialogArgs args;
       
    56     args.mDialogMode = FmFileDialogPrivate::GetDirMode;
       
    57     args.mTitle = title;
       
    58     args.mDirectory = dir;
       
    59     if( options & DisplayAllDirs ) {
       
    60         args.mDirFilters = QDir::AllDirs | QDir::NoDotAndDotDot;
       
    61     } else {
       
    62         args.mDirFilters = QDir::Dirs | QDir::NoDotAndDotDot;
       
    63     }
       
    64     args.mNameFilters = nameFilters;
       
    65     args.mOptions = options;
       
    66 
       
    67     FmFileDialog dialog( parent );
       
    68     dialog.d_ptr->init( args );
       
    69     if( dialog.exec() ) {
       
    70         ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() );
       
    71     }
       
    72     return ret;
       
    73 }
       
    74 
       
    75 QString FmFileDialog::getOpenFileName( HbWidget *parent,
       
    76                                const QString &title,
       
    77                                const QString &dir,
       
    78                                const QStringList &nameFilters,
       
    79                                Options options )
       
    80 {
       
    81 
       
    82     QString ret;
       
    83 
       
    84     FmFileDialogPrivate::FmFileDialogArgs args;
       
    85     args.mDialogMode = FmFileDialogPrivate::GetFileMode;
       
    86     args.mTitle = title;
       
    87     args.mDirectory = dir;
       
    88     if( options & DisplayAllDirs ) {
       
    89         args.mDirFilters = QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Files;
       
    90     } else {
       
    91         args.mDirFilters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files;
       
    92     }
       
    93     args.mNameFilters = nameFilters;
       
    94     args.mOptions = options;
       
    95 
       
    96     FmFileDialog dialog( parent );
       
    97     dialog.d_ptr->init( args );
       
    98     if( dialog.exec() ) {
       
    99         ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() )
       
   100             + dialog.d_ptr->selectedFile();
       
   101     }
       
   102     return ret;
       
   103 }
       
   104 
       
   105 
       
   106 QString FmFileDialog::getSaveFileName( HbWidget * parent,
       
   107                                const QString &title,
       
   108                                const QString &dir,
       
   109                                const QStringList &nameFilters,
       
   110                                Options options )
       
   111 {
       
   112     QString ret;
       
   113 
       
   114     FmFileDialogPrivate::FmFileDialogArgs args;
       
   115     args.mDialogMode = FmFileDialogPrivate::SaveFileMode;
       
   116     args.mTitle = title;
       
   117     args.mDirectory = dir;
       
   118     if( options & DisplayAllDirs ) {
       
   119         args.mDirFilters = QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Files;
       
   120     } else {
       
   121         args.mDirFilters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files;
       
   122     }
       
   123     args.mNameFilters = nameFilters;
       
   124     args.mOptions = options;
       
   125 
       
   126     FmFileDialog dialog( parent );
       
   127     dialog.d_ptr->init( args );
       
   128     if( dialog.exec() ) {
       
   129         ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() )
       
   130             + dialog.d_ptr->selectedFile();
       
   131     }
       
   132     return ret;
       
   133 }
       
   134 
       
   135 
       
   136 
       
   137 bool FmFileDialog::exec()
       
   138 {
       
   139     if ( d_ptr->isOkAction( HbDialog::exec() ) ) {
       
   140         return true;
       
   141     } else {
       
   142         return false ;
       
   143     }
       
   144 }
       
   145 
       
   146 
       
   147 
       
   148