filemanager/src/filemanager/src/components/fmdialog.cpp
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 source file of filemanager base dialog class
       
    17  */
       
    18 
       
    19 #include "fmdialog.h"
       
    20 #include <hbdialog.h>
       
    21 
       
    22 FmDialog::FmDialog( QGraphicsItem *parent) : HbDialog( parent ), mRetAction( 0 )
       
    23 {
       
    24 
       
    25 }
       
    26 
       
    27 HbAction *FmDialog::exec()
       
    28 {
       
    29     HbDialog::open( this, SLOT(dialogClosed(HbAction*)) );
       
    30     mEventLoop.exec();
       
    31     return mRetAction;
       
    32 }
       
    33 
       
    34 void FmDialog::dialogClosed(HbAction *action)
       
    35 {
       
    36     mRetAction = action;
       
    37     mEventLoop.exit();
       
    38 }
       
    39 
       
    40 HbAction *FmDialog::primaryAction() const
       
    41 {
       
    42     QList<QAction *> actionList = QGraphicsWidget::actions();
       
    43     if (actionList.size() > 0) {
       
    44         return (HbAction *)(actionList.at(0));
       
    45     } else {
       
    46         return 0;
       
    47     }
       
    48     
       
    49 }
       
    50 
       
    51 void FmDialog::setPrimaryAction( HbAction *action )
       
    52 {
       
    53     action->setObjectName( "primaryAction" );
       
    54     QList<QAction *> actionList = QGraphicsWidget::actions();
       
    55     if (actionList.size() == 0) {
       
    56         QGraphicsWidget::addAction(action);
       
    57     } else if (actionList.size() ==  1) {
       
    58         actionList.clear();
       
    59         QGraphicsWidget::addAction(action);
       
    60     } else if (actionList.size() == 2) {
       
    61         actionList.removeAt(0);
       
    62         actionList.insert(0, action);
       
    63     }   
       
    64 }
       
    65 
       
    66 HbAction *FmDialog::secondaryAction() const
       
    67 {
       
    68     QList<QAction *> actionList = QGraphicsWidget::actions();
       
    69     if (actionList.size() > 1) {
       
    70         return (HbAction *)(actionList.at(1));
       
    71     } else {
       
    72         return 0;
       
    73     }    
       
    74 }
       
    75 
       
    76 void FmDialog::setSecondaryAction( HbAction *action )
       
    77 {
       
    78     action->setObjectName( "secondaryAction" );
       
    79     QList<QAction *> actionList = QGraphicsWidget::actions();
       
    80     if (actionList.size() == 0) {
       
    81         HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok"));
       
    82         primaryAction->setObjectName( "primaryAction" );
       
    83         QGraphicsWidget::addAction(primaryAction);
       
    84         QGraphicsWidget::addAction(action);          
       
    85     } else if (actionList.size() == 1) {
       
    86         QGraphicsWidget::addAction(action);
       
    87     } else if (actionList.size() == 2) {
       
    88         actionList.removeAt(1);
       
    89         actionList.insert(1, action);
       
    90     } 
       
    91 }