filemanager/examples/demo_fmfiledialog/mainwindow.cpp
branchRCL_3
changeset 38 491b3ed49290
child 47 12b82dc0e8db
equal deleted inserted replaced
36:95243422089a 38:491b3ed49290
       
     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 *     
       
    17 *
       
    18 */
       
    19 
       
    20 #include "mainwindow.h"
       
    21 #include "fmfiledialog.h"
       
    22 #include "hbmessagebox.h"
       
    23 
       
    24 #define getDir "getExistingDirectory"
       
    25 #define getFile "getOpenFileName"
       
    26 #define saveFile "getSaveFileName"
       
    27 
       
    28 #define getDir_SetDir "getExistingDirectory_setDir"
       
    29 #define getFile_SetDir "getOpenFileName_setDir"
       
    30 #define saveFile_SetDir "getSaveFileName_setDir"
       
    31 
       
    32 #define getDir_SetFilter "getExistingDirectory_setFilter"
       
    33 #define getDir_SetFilter_AllDirs "getExistingDirectory_setFilter_AllDirs"
       
    34 #define getFile_SetFilter "getOpenFileName_setFilter"
       
    35 #define saveFile_SetFilter "getSaveFileName_setFilter"
       
    36 
       
    37 TestMainWindow::TestMainWindow()
       
    38 {
       
    39 }
       
    40 TestMainWindow::~TestMainWindow()
       
    41 {
       
    42 }
       
    43 
       
    44 void TestMainWindow::init()
       
    45 {
       
    46     HbView *mainView = new HbView;
       
    47     addView( mainView );
       
    48 
       
    49     HbListWidget *listWidget = new HbListWidget( mainView );
       
    50     mainView->setWidget( listWidget );
       
    51 
       
    52     listWidget->addItem( getDir );
       
    53     listWidget->addItem( getFile );
       
    54     listWidget->addItem( saveFile );
       
    55     listWidget->addItem( " " );
       
    56     listWidget->addItem( getDir_SetDir );
       
    57     listWidget->addItem( getFile_SetDir );
       
    58     listWidget->addItem( saveFile_SetDir );
       
    59     listWidget->addItem( " " );
       
    60     listWidget->addItem( getDir_SetFilter );
       
    61     listWidget->addItem( getDir_SetFilter_AllDirs );
       
    62     listWidget->addItem( getFile_SetFilter );
       
    63     listWidget->addItem( saveFile_SetFilter );
       
    64     listWidget->addItem( " " );
       
    65     listWidget->addItem( "placeHolderA" );
       
    66     listWidget->addItem( "placeHolderB" );
       
    67     listWidget->addItem( "placeHolderC" );
       
    68     listWidget->addItem( "placeHolderD" );
       
    69     listWidget->addItem( "placeHolderE" );
       
    70     listWidget->addItem( "placeHolderF" );
       
    71     listWidget->addItem( "placeHolderG" );
       
    72     listWidget->addItem( "placeHolderH" );
       
    73     listWidget->addItem( "placeHolderI" );
       
    74     listWidget->addItem( "placeHolderJ" );
       
    75     listWidget->addItem( "placeHolderK" );
       
    76     listWidget->addItem( "placeHolderL" );
       
    77     listWidget->addItem( "placeHolderM" );
       
    78     listWidget->addItem( "placeHolderN" );
       
    79     listWidget->addItem( "placeHolderO" );
       
    80     listWidget->addItem( "placeHolderP" );
       
    81     listWidget->addItem( "placeHolderQ" );
       
    82     listWidget->addItem( "placeHolderR" );
       
    83     listWidget->addItem( "placeHolderS" );
       
    84     listWidget->addItem( "placeHolderT" );
       
    85     listWidget->addItem( "placeHolderU" );
       
    86     listWidget->addItem( "placeHolderV" );
       
    87     listWidget->addItem( "placeHolderW" );
       
    88     listWidget->addItem( "placeHolderX" );
       
    89     listWidget->addItem( "placeHolderY" );
       
    90     listWidget->addItem( "placeHolderZ" );
       
    91 
       
    92     connect(listWidget, SIGNAL(activated(HbListWidgetItem*)), this,SLOT(activatedListItem(HbListWidgetItem*)) );
       
    93 }
       
    94 
       
    95 void TestMainWindow::activatedListItem(HbListWidgetItem *item)
       
    96 {
       
    97     if( item->text().compare( getDir ) == 0 ) {
       
    98         getExistingDirectory();
       
    99     } else if( item->text().compare( getFile ) == 0 ) {
       
   100         getOpenFileName();
       
   101     } else if( item->text().compare( saveFile ) == 0 ) {
       
   102        getSaveFileName();
       
   103     } else if( item->text().compare( getDir_SetDir ) == 0 ) {
       
   104         getExistingDirectory_SetDir();
       
   105     } else if( item->text().compare( getFile_SetDir ) == 0 ) {
       
   106        getOpenFileName_SetDir();
       
   107     } else if( item->text().compare( saveFile_SetDir ) == 0 ) {
       
   108         getSaveFileName_SetDir();
       
   109     } else if( item->text().compare( getDir_SetFilter ) == 0 ) {
       
   110         getExistingDirectory_SetFilter();
       
   111     } else if( item->text().compare( getDir_SetFilter_AllDirs ) == 0 ) {
       
   112         getExistingDirectory_SetFilter_AllDirs();
       
   113     } else if( item->text().compare( getFile_SetFilter ) == 0 ) {
       
   114         getOpenFileName_SetFilter();
       
   115     } else if( item->text().compare( saveFile_SetFilter ) == 0 ) {
       
   116        getSaveFileName_SetFilter();
       
   117     }
       
   118 }
       
   119 
       
   120 void TestMainWindow::getExistingDirectory()
       
   121 {
       
   122     // getExistingDirectory with default parameter.
       
   123     QString path = FmFileDialog::getExistingDirectory();
       
   124     HbMessageBox::information( path );
       
   125 }
       
   126 void TestMainWindow::getOpenFileName()
       
   127 {
       
   128     // getOpenFileName with default parameter.
       
   129     QString path = FmFileDialog::getOpenFileName();
       
   130     HbMessageBox::information( path );
       
   131 }
       
   132 void TestMainWindow::getSaveFileName()
       
   133 {
       
   134     // getSaveFileName with default parameter.
       
   135     QString path = FmFileDialog::getSaveFileName();
       
   136     HbMessageBox::information( path );
       
   137 }
       
   138 
       
   139 void TestMainWindow::getExistingDirectory_SetDir()
       
   140 {
       
   141     // getExistingDirectory and set header & default Directory
       
   142     QString path = FmFileDialog::getExistingDirectory( 0, "Look in:", "C:/Data/Images" );
       
   143     HbMessageBox::information( path );
       
   144 }
       
   145 void TestMainWindow::getOpenFileName_SetDir()
       
   146 {
       
   147     // getOpenFileName and set header & default Directory
       
   148     QString path = FmFileDialog::getOpenFileName( 0, "Look in:", "C:/Data/Images" );
       
   149     HbMessageBox::information( path );
       
   150 }
       
   151 void TestMainWindow::getSaveFileName_SetDir()
       
   152 {
       
   153     // getSaveFileName and set header & default Directory
       
   154     QString path = FmFileDialog::getSaveFileName( 0, "Look in:", "C:/Data/Images" );
       
   155     HbMessageBox::information( path );
       
   156 }
       
   157 
       
   158 void TestMainWindow::getExistingDirectory_SetFilter()
       
   159 {
       
   160     // getExistingDirectory and set folder&file filter
       
   161     QStringList filterList;
       
   162     filterList<<"*data*"<<"*image*"<<"*sound*";
       
   163     QString path = FmFileDialog::getExistingDirectory( 0, "Look in:", "", filterList );
       
   164     HbMessageBox::information( path );
       
   165 }
       
   166 
       
   167 void TestMainWindow::getExistingDirectory_SetFilter_AllDirs()
       
   168 {
       
   169     // getExistingDirectory and set folder&file filter
       
   170     QStringList filterList;
       
   171     filterList<<"*data*"<<"*image*"<<"*sound*";
       
   172     QString path = FmFileDialog::getExistingDirectory( 0, "Look in:", "", filterList, FmFileDialog::DisplayAllDirs );
       
   173     HbMessageBox::information( path );
       
   174 }
       
   175 
       
   176 void TestMainWindow::getOpenFileName_SetFilter()
       
   177 {
       
   178     // getOpenFileName and set file filter
       
   179     //Set DisplayAllDirs to display all folders, otherwise folders will also be filted.
       
   180     QStringList filterList;
       
   181     filterList<<"*.jpg"<<"*.gif"<<"*.png";
       
   182     QString path = FmFileDialog::getOpenFileName( 0, "Look in:", "", filterList, FmFileDialog::DisplayAllDirs );
       
   183     HbMessageBox::information( path );
       
   184 }
       
   185 void TestMainWindow::getSaveFileName_SetFilter()
       
   186 {
       
   187     // getSaveFileName and set file filter
       
   188     //Set DisplayAllDirs to display all folders, otherwise folders will also be filted.
       
   189     QStringList filterList;
       
   190     filterList<<"*.jpg"<<"*.gif"<<"*.png";
       
   191     QString path = FmFileDialog::getSaveFileName( 0, "Look in:", "", filterList, FmFileDialog::DisplayAllDirs );
       
   192     HbMessageBox::information( path );
       
   193 }