[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/kmail-soc/kmail
From:       Thomas McGuire <Thomas.McGuire () gmx ! net>
Date:       2008-07-31 14:09:29
Message-ID: 1217513369.538685.28833.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 840156 by tmcguire:

Handle clicks to empty areas correctly.

 M  +11 -1     favoritefolderview.cpp  
 M  +12 -0     favoritefolderview.h  
 M  +46 -41    folderview.cpp  
 M  +5 -0      folderview.h  


--- branches/kdepim/kmail-soc/kmail/favoritefolderview.cpp #840155:840156
@@ -131,14 +131,24 @@
   GlobalSettings::self()->setFavoriteFolderNames( lNames );
 }
 
+void FavoriteFolderView::appendAddFolderActionToMenu( KMenu *menu ) const
+{
+  menu->addAction( KIcon( "bookmark-new" ), i18n( "Add Favorite Folder..." ),
+                   this, SLOT( addFolder() ) );
+}
+
 void FavoriteFolderView::fillContextMenuViewStructureRelatedActions( KMenu *menu, \
FolderViewItem */*item*/, bool multiSelection )  {
   menu->addAction( KIcon( "edit-delete" ), i18n( "Remove From Favorites" ), this, \
SLOT( removeFolders() ) );  if ( !multiSelection )
     menu->addAction( KIcon( "edit-rename" ), i18n( "Rename Favorite..." ), this, \
                SLOT( renameFolder() ) );
-  menu->addAction( KIcon( "bookmark-new" ), i18n( "Add Favorite Folder..." ), this, \
SLOT( addFolder() ) ); +  appendAddFolderActionToMenu( menu );
 }
 
+void FavoriteFolderView::fillContextMenuNoItem( KMenu *mneu )
+{
+  appendAddFolderActionToMenu( mneu );
+}
 
 //=======================================================================================
  // DND Machinery: we allow adding items from outside and maybe sorting stuff by \
                dnd.
--- branches/kdepim/kmail-soc/kmail/favoritefolderview.h #840155:840156
@@ -68,6 +68,11 @@
   virtual void fillContextMenuViewStructureRelatedActions( KMenu *menu, \
FolderViewItem *item, bool multiSelection );  
   /**
+   * Reimplemented to add a "Add Favorite Folder" entry
+   */
+  virtual void fillContextMenuNoItem( KMenu *mneu );
+
+  /**
    * Reimplemented in order to allow for both sorting and moving folders around.
    */
   virtual void handleFoldersDragMoveEvent( QDragMoveEvent *e );
@@ -113,6 +118,13 @@
    * Removes all the currently selected folders from favorites
    */
   void removeFolders();
+
+private:
+
+  /**
+   * Adds the "Add Favorite Folder..." action to a menu
+   */
+  void appendAddFolderActionToMenu( KMenu *menu ) const;
 };
 
 }
--- branches/kdepim/kmail-soc/kmail/folderview.cpp #840155:840156
@@ -1455,6 +1455,11 @@
   }
 }
 
+void FolderView::fillContextMenuNoItem( KMenu *mneu )
+{
+  // this is overridden in derived classes
+}
+
 // A little helper function: Adds a separator to the menu if it has more items
 // than lastActionCount. Returns the number of new items.
 static int insertSeparatorIfNeeded( int lastActionCount, QMenu *menu )
@@ -1472,59 +1477,59 @@
   // This code __attempts__ to favor some sort of logical order in the menu entries.
   //
 
-  FolderViewItem * fvi = static_cast<FolderViewItem *>( currentItem() );
+  FolderViewItem * fvi = static_cast<FolderViewItem *>( itemAt( e->pos() ) );
 
-  if ( !mMainWidget )
-    return; // safe bet
+  KMenu * menu = new KMenu();
+  if ( fvi ) {
+    KMFolder *folder = fvi->folder();
 
-  if ( !fvi )
-    return;
+    // make sure the folder is activated (so actions will get updated)
+    // but keep the selection (so multifolder is possible)
+    Q_ASSERT( mMainWidget );
+    if ( mMainWidget->activeFolder() != folder )
+      activateItem( fvi, true );
 
-  KMFolder *folder = fvi->folder();
+    bool multiSelection = selectedFolders().count() > 1;
 
-  // make sure the folder is activated (so actions will get updated)
-  // but keep the selection (so multifolder is possible)
-  if ( mMainWidget->activeFolder() != folder )
-    activateItem( fvi, true );
+    // First of all, the title
+    if ( multiSelection )
+    {
+      // multiple folders selected: add only actions that can handle all of them
+      menu->addTitle( i18n( "Multiple Folders" ) );
+    } else {
+      // single (or no) folder selected
+      if ( folder )
+        menu->addTitle( folder->label() );
+      else
+        menu->addTitle( fvi->text( LabelColumn ) );
+    }
 
-  KMenu * menu = new KMenu();
+    fillContextMenuAccountRelatedActions( menu, fvi, multiSelection );
 
-  bool multiSelection = selectedFolders().count() > 1;
+    // keep track of the number of actions so we can add separators in the right \
place, if needed +    int lastActionCount = menu->actions().count();
 
-  // First of all, the title
-  if ( multiSelection )
-  {
-    // multiple folders selected: add only actions that can handle all of them
-    menu->addTitle( i18n( "Multiple Folders" ) );
-  } else {
-    // single (or no) folder selected
-    if ( folder )
-      menu->addTitle( folder->label() );
-    else
-      menu->addTitle( fvi->text( LabelColumn ) );
-  }
+    fillContextMenuMessageRelatedActions( menu, fvi, multiSelection );
+    lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
 
-  fillContextMenuAccountRelatedActions( menu, fvi, multiSelection );
+    fillContextMenuTreeStructureRelatedActions( menu, fvi, multiSelection );
+    lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
 
-  // keep track of the number of actions so we can add separators in the right \
                place, if needed
-  int lastActionCount = menu->actions().count();
+    fillContextMenuViewStructureRelatedActions( menu, fvi, multiSelection );
+    lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
 
-  fillContextMenuMessageRelatedActions( menu, fvi, multiSelection );
-  lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
+    fillContextMenuFolderServiceRelatedActions( menu, fvi, multiSelection );
+    lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
+  }
+  else
+    fillContextMenuNoItem( menu );
 
-  fillContextMenuTreeStructureRelatedActions( menu, fvi, multiSelection );
-  lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
+  if ( !menu->isEmpty() ) {
+    kmkernel->setContextMenuShown( true );
+    menu->exec( e->globalPos() , 0 );
+    kmkernel->setContextMenuShown( false );
+  }
 
-  fillContextMenuViewStructureRelatedActions( menu, fvi, multiSelection );
-  lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
-
-  fillContextMenuFolderServiceRelatedActions( menu, fvi, multiSelection );
-  lastActionCount = insertSeparatorIfNeeded( lastActionCount, menu );
-
-  kmkernel->setContextMenuShown( true );
-  menu->exec( e->globalPos() , 0 );
-  kmkernel->setContextMenuShown( false );
-
   delete menu;
 }
 
--- branches/kdepim/kmail-soc/kmail/folderview.h #840155:840156
@@ -665,6 +665,11 @@
   virtual void fillContextMenuFolderServiceRelatedActions( KMenu *menu, \
FolderViewItem *item, bool multiSelection );  
   /**
+   * Adds actions to the context mneu when no item (i.e. whitespace in the listview) \
is clicked +   */
+  virtual void fillContextMenuNoItem( KMenu *mneu );
+
+  /**
    * Intercepts QHelpEvent for tooltip management
    */
   virtual bool event( QEvent *e );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic