filemanager/src/fmfiledialog/src/fmfiledialog.cpp
changeset 25 b7bfdea70ca2
parent 14 1957042d8c7e
child 47 12b82dc0e8db
--- a/filemanager/src/fmfiledialog/src/fmfiledialog.cpp	Mon May 03 12:24:39 2010 +0300
+++ b/filemanager/src/fmfiledialog/src/fmfiledialog.cpp	Fri Jun 25 17:08:34 2010 +0800
@@ -32,6 +32,7 @@
 #include "hblineedit.h"
 
 #include <QGraphicsLinearLayout>
+#include <QEventLoop>
 
 FmFileDialog::FmFileDialog( QGraphicsItem *parent ) : 
     HbDialog( parent ), d_ptr( new FmFileDialogPrivate( this ) )
@@ -67,7 +68,7 @@
     FmFileDialog dialog( parent );
     dialog.d_ptr->init( args );
     if( dialog.exec() ) {
-        ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() );
+        ret = FmUtils::formatPath( dialog.d_ptr->currentPath() );
     }
     return ret;
 }
@@ -96,7 +97,7 @@
     FmFileDialog dialog( parent );
     dialog.d_ptr->init( args );
     if( dialog.exec() ) {
-        ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() )
+        ret = FmUtils::formatPath( dialog.d_ptr->currentPath() )
             + dialog.d_ptr->selectedFile();
     }
     return ret;
@@ -126,7 +127,7 @@
     FmFileDialog dialog( parent );
     dialog.d_ptr->init( args );
     if( dialog.exec() ) {
-        ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() )
+        ret = FmUtils::formatPath( dialog.d_ptr->currentPath() )
             + dialog.d_ptr->selectedFile();
     }
     return ret;
@@ -136,13 +137,70 @@
 
 bool FmFileDialog::exec()
 {
-    if ( d_ptr->isOkAction( HbDialog::exec() ) ) {
+    HbDialog::open( this, SLOT(dialogClosed(HbAction*)) );
+    d_ptr->eventLoop().exec();
+    
+    if ( d_ptr->isOkAction( d_ptr->retAction() ) ) {
         return true;
     } else {
         return false ;
     }
 }
 
+void FmFileDialog::dialogClosed(HbAction *action)
+{
+    d_ptr->setRetAction( action );
+    d_ptr->eventLoop().exit();
+}
 
 
+HbAction *FmFileDialog::primaryAction() const
+{
+    QList<QAction *> actionList = QGraphicsWidget::actions();
+    if (actionList.size() > 0) {
+        return (HbAction *)(actionList.at(0));
+    } else {
+        return 0;
+    }
+    
+}
 
+void FmFileDialog::setPrimaryAction( HbAction *action )
+{
+    QList<QAction *> actionList = QGraphicsWidget::actions();
+    if (actionList.size() == 0) {
+        QGraphicsWidget::addAction(action);
+    } else if (actionList.size() ==  1) {
+        actionList.clear();
+        QGraphicsWidget::addAction(action);
+    } else if (actionList.size() == 2) {
+        actionList.removeAt(0);
+        actionList.insert(0, action);
+    }    
+}
+
+HbAction *FmFileDialog::secondaryAction() const
+{
+    QList<QAction *> actionList = QGraphicsWidget::actions();
+    if (actionList.size() > 1) {
+        return (HbAction *)(actionList.at(1));
+    } else {
+        return 0;
+    }    
+}
+
+void FmFileDialog::setSecondaryAction( HbAction *action )
+{
+    QList<QAction *> actionList = QGraphicsWidget::actions();
+    if (actionList.size() == 0) {
+        QGraphicsWidget::addAction(new HbAction(hbTrId("Ok")));
+        QGraphicsWidget::addAction(action);          
+    } else if (actionList.size() == 1) {
+        QGraphicsWidget::addAction(action);
+    } else if (actionList.size() == 2) {
+        actionList.removeAt(1);
+        actionList.insert(1, action);
+    }
+        
+}
+