filemanager/src/filemanager/src/fmviewmanager.cpp
changeset 48 1bebd60c0f00
parent 44 22e202702210
equal deleted inserted replaced
44:22e202702210 48:1bebd60c0f00
    28 #include "fmoperationservice.h"
    28 #include "fmoperationservice.h"
    29 #include "fmoperationbase.h"
    29 #include "fmoperationbase.h"
    30 #include "fmdrivewatcher.h"
    30 #include "fmdrivewatcher.h"
    31 #include "fmdialog.h"
    31 #include "fmdialog.h"
    32 #include "fmdlgutils.h"
    32 #include "fmdlgutils.h"
       
    33 #include "fmserviceutils.h"
    33 
    34 
    34 #include <hbview.h>
    35 #include <hbview.h>
    35 #include <hbmainwindow.h>
    36 #include <hbmainwindow.h>
    36 #include <hbapplication.h>
    37 #include <hbapplication.h>
    37 #include <hbactivitymanager.h>
    38 #include <hbactivitymanager.h>
    38 #include <QFileSystemWatcher>
    39 #include <QFileSystemWatcher>
    39 #include <QFileInfo>
    40 #include <QFileInfo>
    40 #include <QPixmap>
    41 #include <QPixmap>
    41 
    42 
    42 #include <shareui.h>
       
    43 
       
    44 FmViewManager *FmViewManager::mViewManager = 0;
    43 FmViewManager *FmViewManager::mViewManager = 0;
    45 
    44 
    46 
    45 
    47 FmDlgCloseUnit::FmDlgCloseUnit( FmDialog *dialog ) : mDialog( dialog )
    46 FmDlgCloseUnit::FmDlgCloseUnit( FmDialog *dialog ) : mDialog( dialog )
    48 {
    47 {
    73 FmDialog *FmDlgCloseUnit::dialog()
    72 FmDialog *FmDlgCloseUnit::dialog()
    74 {
    73 {
    75 	return mDialog;
    74 	return mDialog;
    76 }
    75 }
    77 
    76 
    78 FmViewManager::FmViewManager( FmMainWindow* mainWindow ) : mOperationService( 0 ), mShareUi( 0 )
    77 FmViewManager::FmViewManager( FmMainWindow* mainWindow ) 
       
    78     : mOperationService( 0 ), mServiceUtils( 0 )
    79 {
    79 {
    80     mMainWindow = mainWindow;
    80     mMainWindow = mainWindow;
    81     mDriveWatcher = new FmDriveWatcher( this );
    81     mDriveWatcher = new FmDriveWatcher( this );
    82     mDriveWatcher->setObjectName( "driveWatcher" );
    82     mDriveWatcher->setObjectName( "driveWatcher" );
    83     mDriveWatcher->startWatch();
    83     mDriveWatcher->startWatch();
    99 
    99 
   100     mDriveWatcher->cancelWatch();
   100     mDriveWatcher->cancelWatch();
   101     delete mDriveWatcher;
   101     delete mDriveWatcher;
   102     mDriveWatcher = 0;
   102     mDriveWatcher = 0;
   103     
   103     
   104     delete mShareUi;
   104     delete mServiceUtils;
   105     mShareUi = 0;
   105     mServiceUtils = 0;
   106 
   106 
   107 }
   107 }
   108 
   108 
   109 FmViewManager *FmViewManager::CreateViewManager( FmMainWindow* mainWindow )
   109 FmViewManager *FmViewManager::CreateViewManager( FmMainWindow* mainWindow )
   110 {
   110 {
   128 FmOperationService *FmViewManager::operationService()
   128 FmOperationService *FmViewManager::operationService()
   129 {
   129 {
   130     if ( !mOperationService ) {
   130     if ( !mOperationService ) {
   131         mOperationService = new FmOperationService( this );
   131         mOperationService = new FmOperationService( this );
   132         mOperationService->setObjectName( "operationService" );
   132         mOperationService->setObjectName( "operationService" );
       
   133         QMetaObject::connectSlotsByName( this );
   133     }    
   134     }    
   134     return mOperationService;
   135     return mOperationService;
   135 }
   136 }
   136 
   137 
   137 /*
   138 /*
   138    return \a shareUi which is used to send files. 
   139    return \a FmServiceUtils. 
   139  */
   140  */
   140 ShareUi *FmViewManager::shareUi()
   141 FmServiceUtils *FmViewManager::serviceUtils()
   141 {
   142 {
   142     if( !mShareUi ) {
   143     if( !mServiceUtils ) {
   143         mShareUi = new ShareUi;
   144         mServiceUtils = new FmServiceUtils;
   144     }
   145     }
   145     return mShareUi;
   146     return mServiceUtils;
   146 }
   147 }
   147 
   148 
   148 void FmViewManager::popViewAndShow()
   149 void FmViewManager::popViewAndShow()
   149 {
   150 {
   150     FmViewBase *view = static_cast<FmViewBase *>( mMainWindow->currentView() );
   151     FmViewBase *view = static_cast<FmViewBase *>( mMainWindow->currentView() );
   203 
   204 
   204     mMainWindow->addView( driverView );
   205     mMainWindow->addView( driverView );
   205     mMainWindow->setCurrentView( driverView );
   206     mMainWindow->setCurrentView( driverView );
   206     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();        
   207     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();        
   207     bool ok = activityManager->removeActivity("FMMemoryStoragesList");
   208     bool ok = activityManager->removeActivity("FMMemoryStoragesList");
       
   209     Q_UNUSED( ok );
   208 
   210 
   209     connect( this, SIGNAL( driveSpaceChanged() ), 
   211     connect( this, SIGNAL( driveSpaceChanged() ), 
   210         driverView, SLOT( refreshDrive() ) );
   212         driverView, SLOT( refreshDrive() ) );
   211     // Refresh drive view when gaining foreground
   213     // Refresh drive view when gaining foreground
   212     // ( switch back to filemanager from home screen or any other applications )
   214     // ( switch back to filemanager from home screen or any other applications )
   234             checkedPath.clear();
   236             checkedPath.clear();
   235         }
   237         }
   236     }
   238     }
   237    
   239    
   238     if( checkedPath.isEmpty() ) {
   240     if( checkedPath.isEmpty() ) {
   239         FmDlgUtils::information( QString( hbTrId("Path: %1 is unavailable!").arg( path )) );
   241         FmDlgUtils::warning( QString( hbTrId("Path: %1 is unavailable!").arg( path )) );
   240         return;
   242         return;
   241     }
   243     }
   242 
   244 
   243     FmFileView *fileView= new FmFileView();
   245     FmFileView *fileView= new FmFileView();
   244     fileView->setRootPath( checkedPath );
   246     fileView->setRootPath( checkedPath );
   351     metadata.insert("screenshot", mScreenShot);
   353     metadata.insert("screenshot", mScreenShot);
   352     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();     
   354     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();     
   353     // add the activity to the activity manager
   355     // add the activity to the activity manager
   354     bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata);
   356     bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata);
   355     // do not need check return value
   357     // do not need check return value
   356 
   358     Q_UNUSED( ok );
   357 }
   359 }
   358 
   360 
   359 void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView)
   361 void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView)
   360 {
   362 {
   361     Q_UNUSED(newView);
   363     Q_UNUSED(newView);