filemanager/src/filemanager/src/fmviewmanager.cpp
changeset 44 22e202702210
parent 41 fc4654ce4fcb
child 48 1bebd60c0f00
equal deleted inserted replaced
41:fc4654ce4fcb 44:22e202702210
    37 #include <hbactivitymanager.h>
    37 #include <hbactivitymanager.h>
    38 #include <QFileSystemWatcher>
    38 #include <QFileSystemWatcher>
    39 #include <QFileInfo>
    39 #include <QFileInfo>
    40 #include <QPixmap>
    40 #include <QPixmap>
    41 
    41 
       
    42 #include <shareui.h>
       
    43 
    42 FmViewManager *FmViewManager::mViewManager = 0;
    44 FmViewManager *FmViewManager::mViewManager = 0;
    43 
    45 
    44 
    46 
    45 FmDlgCloseUnit::FmDlgCloseUnit( FmDialog *dialog ) : mDialog( dialog )
    47 FmDlgCloseUnit::FmDlgCloseUnit( FmDialog *dialog ) : mDialog( dialog )
    46 {
    48 {
    71 FmDialog *FmDlgCloseUnit::dialog()
    73 FmDialog *FmDlgCloseUnit::dialog()
    72 {
    74 {
    73 	return mDialog;
    75 	return mDialog;
    74 }
    76 }
    75 
    77 
    76 FmViewManager::FmViewManager( FmMainWindow* mainWindow ) : mOperationService( 0 )
    78 FmViewManager::FmViewManager( FmMainWindow* mainWindow ) : mOperationService( 0 ), mShareUi( 0 )
    77 {
    79 {
    78     mMainWindow = mainWindow;
    80     mMainWindow = mainWindow;
    79     mDriveWatcher = new FmDriveWatcher( this );
    81     mDriveWatcher = new FmDriveWatcher( this );
    80     mDriveWatcher->setObjectName( "driveWatcher" );
    82     mDriveWatcher->setObjectName( "driveWatcher" );
    81     mDriveWatcher->startWatch();
    83     mDriveWatcher->startWatch();
    96     mOperationService = 0;
    98     mOperationService = 0;
    97 
    99 
    98     mDriveWatcher->cancelWatch();
   100     mDriveWatcher->cancelWatch();
    99     delete mDriveWatcher;
   101     delete mDriveWatcher;
   100     mDriveWatcher = 0;
   102     mDriveWatcher = 0;
       
   103     
       
   104     delete mShareUi;
       
   105     mShareUi = 0;
   101 
   106 
   102 }
   107 }
   103 
   108 
   104 FmViewManager *FmViewManager::CreateViewManager( FmMainWindow* mainWindow )
   109 FmViewManager *FmViewManager::CreateViewManager( FmMainWindow* mainWindow )
   105 {
   110 {
   127         mOperationService->setObjectName( "operationService" );
   132         mOperationService->setObjectName( "operationService" );
   128     }    
   133     }    
   129     return mOperationService;
   134     return mOperationService;
   130 }
   135 }
   131 
   136 
       
   137 /*
       
   138    return \a shareUi which is used to send files. 
       
   139  */
       
   140 ShareUi *FmViewManager::shareUi()
       
   141 {
       
   142     if( !mShareUi ) {
       
   143         mShareUi = new ShareUi;
       
   144     }
       
   145     return mShareUi;
       
   146 }
       
   147 
   132 void FmViewManager::popViewAndShow()
   148 void FmViewManager::popViewAndShow()
   133 {
   149 {
   134     FmViewBase *view = static_cast<FmViewBase *>( mMainWindow->currentView() );
   150     FmViewBase *view = static_cast<FmViewBase *>( mMainWindow->currentView() );
   135     view->setNavigationAction( 0 );
   151     view->setNavigationAction( 0 );
   136     // grap the screen when only the drive view is in view stack.
   152     // grap the screen when only the drive view is in view stack.
   137     if( viewCount() == 1 ) {
   153     if( viewCount() == 1 ) {
   138         mScreenShot = QPixmap::grabWidget(mMainWindow, mMainWindow->rect());
   154         mScreenShot = QPixmap::grabWidget(mMainWindow, mMainWindow->rect());
   139     }
   155     }
   140     mMainWindow->removeView( view );   
   156     mMainWindow->removeView( view );  
       
   157 	// If call QEventLoop in destructor of HbView, it will panic
       
   158 	// So add aboutToClose function to do some prepare when view will be closed
       
   159 	// for example, close find view while find is inprogress.
       
   160     // stop find thread in destructor of FmFindView(called by delete container->model...)
       
   161     // and use QEventLoop to wait till thread exit.
       
   162     view->aboutToClose();
   141     delete view;
   163     delete view;
   142 
   164 
   143     if( viewCount() < 1 )
   165     if( viewCount() < 1 )
   144     {
   166     {
   145         mMainWindow->close();
   167         mMainWindow->close();
   234 
   256 
   235     connect( fileView, SIGNAL( popViewAndShow() ),                  //emit when fileView need delete itself and pop&show view from stack.
   257     connect( fileView, SIGNAL( popViewAndShow() ),                  //emit when fileView need delete itself and pop&show view from stack.
   236         this, SLOT( popViewAndShow() ), Qt::QueuedConnection );
   258         this, SLOT( popViewAndShow() ), Qt::QueuedConnection );
   237 }
   259 }
   238 
   260 
   239 void FmViewManager::createFindView( const QString &keyword, const QString &path )
   261 /*
       
   262     Create fild view and search \a keyword in \a pathList
       
   263 */
       
   264 void FmViewManager::createFindView( const QString &keyword, const QStringList &pathList )
   240 {
   265 {
   241     FmFindView *findView= new FmFindView();
   266     FmFindView *findView= new FmFindView();
   242     
   267     
   243     mMainWindow->addView( findView );
   268     mMainWindow->addView( findView );
   244     mMainWindow->setCurrentView( findView );
   269     mMainWindow->setCurrentView( findView );
   245 
   270 
   246     findView->find( keyword, path );
   271     findView->find( keyword, pathList );
   247  }
   272  }
   248 
   273 
   249 void FmViewManager::createSplitView()
   274 void FmViewManager::createSplitView()
   250 {
   275 {
   251     FmSplitView *splitView = new FmSplitView();
   276     FmSplitView *splitView = new FmSplitView();
   325     QVariantHash metadata;
   350     QVariantHash metadata;
   326     metadata.insert("screenshot", mScreenShot);
   351     metadata.insert("screenshot", mScreenShot);
   327     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();     
   352     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();     
   328     // add the activity to the activity manager
   353     // add the activity to the activity manager
   329     bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata);
   354     bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata);
   330     if ( !ok )
   355     // do not need check return value
   331     {
       
   332     qFatal("Add failed" );
       
   333     }
       
   334 
   356 
   335 }
   357 }
   336 
   358 
   337 void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView)
   359 void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView)
   338 {
   360 {