ui/viewmanagement/viewmanager/src/glxmenumanager.cpp
changeset 29 2c833fc9e98f
parent 26 c499df2dbb33
child 45 863223ea6961
equal deleted inserted replaced
26:c499df2dbb33 29:2c833fc9e98f
    29 #include "glxlocalisationstrings.h"
    29 #include "glxlocalisationstrings.h"
    30 
    30 
    31 
    31 
    32 
    32 
    33 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow)
    33 GlxMenuManager::GlxMenuManager(HbMainWindow* mainWindow)
    34  : mMainWindow( mainWindow ),
    34     : mModel( 0),
    35    mContextMenu( 0 )
    35       mMainWindow( mainWindow ),
       
    36       mContextMenu( 0 )
    36 {
    37 {
    37 }
    38 }
    38 
    39 
    39 GlxMenuManager::~GlxMenuManager()
    40 GlxMenuManager::~GlxMenuManager()
    40 {
    41 {
   160     action->setData(EGlxCmdSlideshowSettings);
   161     action->setData(EGlxCmdSlideshowSettings);
   161     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   162     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   162     
   163     
   163     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   164     action = menu->addAction(GLX_OPTION_ADD_TO_ALBUM);
   164     action->setData(EGlxCmdAddToAlbum);
   165     action->setData(EGlxCmdAddToAlbum);
   165     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   166 	
       
   167     action = menu->addAction("Rotate");
       
   168     action->setData(EGlxCmdRotate);
       
   169     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   166     connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   170 }
   167 }
   171 
   168 
   172 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
   169 void GlxMenuManager::setAllActionVisibility( QList<QAction*> actionList, bool visible )
   173 {
   170 {
   261 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   258 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   262 	        
   259 	        
   263 	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   260 	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   264 	        action->setData(EGlxCmdSelectSlideshow);
   261 	        action->setData(EGlxCmdSelectSlideshow);
   265 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   262 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   266 		    
   263 
       
   264 	        if ( viewSubState() == ALBUM_ITEM_S ) {        
       
   265 	        action = mContextMenu->addAction(GLX_OPTION_REMOVE_FROM_ALBUM);
       
   266 	        action->setData(EGlxCmdContextRemoveFrom);
       
   267 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   268 	        }
       
   269 	        
   267 	        action = mContextMenu->addAction(GLX_MENU_ADD_TO_ALBUM);
   270 	        action = mContextMenu->addAction(GLX_MENU_ADD_TO_ALBUM);
   268 		    action->setData(EGlxCmdContextAddToAlbum);
   271 		    action->setData(EGlxCmdContextAddToAlbum);
   269 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   272 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   270 		    
   273 		    
   271 		    action = mContextMenu->addAction(GLX_MENU_DELETE);
   274 		    action = mContextMenu->addAction(GLX_MENU_DELETE);
   272 		    action->setData(EGlxCmdContextDelete);
   275 		    action->setData(EGlxCmdContextDelete);
   273 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   276 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   274 			break;
   277 			break;
   275 	    	
   278 	    	
   276 	    case GLX_LISTVIEW_ID :
   279 	    case GLX_LISTVIEW_ID : {
   277 	        action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   280 	        int count = 0;
   278 	        action->setData(EGlxCmdAlbumSlideShow);
   281             QVariant variant = mModel->data( mModel->index(0,0), GlxListItemCount );    
   279 	        connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   282 	        if ( variant.isValid() &&  variant.canConvert<int> () ) {
   280     
   283 	            count = variant.value<int>();  
   281             action = mContextMenu->addAction(GLX_MENU_RENAME);
   284 	        }  
   282             action->setData(EGlxCmdContextRename);
   285 
   283             connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   286 	        if ( count ) {
   284 	                    
   287                 action = mContextMenu->addAction(GLX_MENU_SLIDESHOW);
   285 		    action = mContextMenu->addAction(GLX_MENU_DELETE);
   288                 action->setData(EGlxCmdAlbumSlideShow);
   286 		    action->setData(EGlxCmdContextAlbumDelete);
   289                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   287 		    connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
   290 	        }
       
   291 	        
       
   292 	        variant = mModel->data( mModel->index(0,0), GlxSystemItemRole );    
       
   293             if ( variant.isValid() &&  variant.canConvert<bool> () && ( variant.value<bool>() == false ) ) {           
       
   294                 action = mContextMenu->addAction(GLX_MENU_RENAME);
       
   295                 action->setData(EGlxCmdContextRename);
       
   296                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   297                             
       
   298                 action = mContextMenu->addAction(GLX_MENU_DELETE);
       
   299                 action->setData(EGlxCmdContextAlbumDelete);
       
   300                 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));
       
   301             }
       
   302 	    }
   288 			break;
   303 			break;
   289 			
   304 			
   290 		default:
   305 		default:
   291 		    break;	
   306 		    break;	
   292 		}
   307 		}
   293 
   308 
   294 	connect( mMainWindow, SIGNAL( aboutToChangeOrientation () ), mContextMenu, SLOT( close() ) );
   309     if ( mContextMenu->isEmpty() ) {
   295 	connect( mContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) );
   310         delete mContextMenu ;
   296 	mContextMenu->setPreferredPos( pos );
   311         mContextMenu = NULL ;
   297 	mContextMenu->show();
   312     }
   298     
   313     else {
       
   314         connect( mMainWindow, SIGNAL( aboutToChangeOrientation () ), mContextMenu, SLOT( close() ) );
       
   315         connect( mContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) );
       
   316         mContextMenu->setPreferredPos( pos );
       
   317         mContextMenu->show(); 
       
   318     }    
   299 }
   319 }
   300 
   320 
   301 void GlxMenuManager::closeContextMenu()
   321 void GlxMenuManager::closeContextMenu()
   302 {
   322 {
   303     disconnect( mMainWindow, SIGNAL( aboutToChangeOrientation () ), mContextMenu, SLOT( close() ) );
   323     disconnect( mMainWindow, SIGNAL( aboutToChangeOrientation () ), mContextMenu, SLOT( close() ) );