Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30724/src/gui

Modified Files:
        wxFolderView.cpp 
Log Message:
unified code handling events from kbd and menu/toolbar; the only user visible change 
is that toolbar delete button now moves focus to the next message just as 'D' does

Index: wxFolderView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxFolderView.cpp,v
retrieving revision 1.660
retrieving revision 1.661
diff -b -u -2 -r1.660 -r1.661
--- wxFolderView.cpp    8 Apr 2004 15:03:53 -0000       1.660
+++ wxFolderView.cpp    8 Apr 2004 17:28:49 -0000       1.661
@@ -4255,4 +4255,48 @@
 }
 
+void
+wxFolderView::UpdateFocusAfterCommand(int cmd)
+{
+   switch ( cmd )
+   {
+      case WXMENU_MSG_SAVE_TO_FOLDER:
+      case WXMENU_MSG_SAVE_TO_FILE:
+      case WXMENU_MSG_UNDELETE:
+      case WXMENU_MSG_FLAG:
+      case WXMENU_MSG_MARK_READ:
+      case WXMENU_MSG_MARK_UNREAD:
+      case WXMENU_MSG_OPEN:
+      case WXMENU_MSG_PRINT:
+         // go to the next message unconditionally for these commands
+         break;
+
+      case WXMENU_MSG_DELETE:
+      case WXMENU_MSG_MOVE_TO_FOLDER:
+         // if we're using trash, the message we deleted/moved is not there
+         // any more so we shouldn't change the focus as it is already on the
+         // next message -- but if we don't use trash, do move to the next
+         // message
+         if ( !m_settings.usingTrash )
+            break;
+         //else: fall through
+
+      default:
+         // nothing to do, don't change the focus
+         return;
+   }
+
+   // get the focused item
+   long focused = m_FolderCtrl->GetFocusedItem();
+
+   // find the next item
+   long newFocus = focused;
+   if ( newFocus == -1 )
+      newFocus = 0;
+   else if ( focused < m_FolderCtrl->GetItemCount() - 1 )
+      newFocus++;
+
+   (void)m_FolderCtrl->GoToItem(newFocus);
+}
+
 bool
 wxFolderView::HandleFolderViewCharEvent(wxKeyEvent& event)
@@ -4350,112 +4394,62 @@
    // ----------
 
-   // we can operate either on all selected items
-   const UIdArray& selections = GetSelections();
-
-   // get the focused item
-   long focused = m_FolderCtrl->GetFocusedItem();
-
-   // find the next item
-   long newFocus = focused;
-   if ( newFocus == -1 )
-      newFocus = 0;
-   else if ( focused < m_FolderCtrl->GetItemCount() - 1 )
-      newFocus++;
-
+   int cmd = 0;
    switch ( key )
    {
       case 'D': // delete
-         if ( event.ControlDown() )
-         {
-            m_msgCmdProc->ProcessCommand(WXMENU_MSG_DELETE_EXPUNGE, selections);
-
-            // don't move focus: either the messages were not expunged at all
-            // or they were but then we shouldn't move to the next message as
-            // the indices have been invalidated
-            newFocus = -1;
-         }
-         else // normal delete
-         {
-            m_msgCmdProc->ProcessCommand(WXMENU_MSG_DELETE, selections);
-
-            // only move on if we mark as deleted, for trash usage, selection
-            // remains the same:
-            if ( m_settings.usingTrash )
-            {
-               // don't move focus
-               newFocus = -1;
-            }
-         }
+         cmd = event.ControlDown() ? WXMENU_MSG_DELETE_EXPUNGE
+                                   : WXMENU_MSG_DELETE;
          break;
 
       case 'U': // undelete
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_UNDELETE, selections);
+         cmd = WXMENU_MSG_UNDELETE;
          break;
 
       case 'X': // expunge
-         ExpungeMessages();
-         newFocus = -1;
+         cmd = WXMENU_MSG_EXPUNGE;
          break;
 
       case 'C': // copy (to folder)
-         if ( !m_msgCmdProc->ProcessCommand(WXMENU_MSG_SAVE_TO_FOLDER, selections) )
-         {
-            // don't move focus if user cancelled copying
-            newFocus = -1;
-         }
+         cmd = WXMENU_MSG_SAVE_TO_FOLDER;
          break;
 
       case 'M': // move
-         if ( !m_msgCmdProc->ProcessCommand(WXMENU_MSG_MOVE_TO_FOLDER, selections) )
-         {
-            // don't delete the messages if we couldn't save them!
-            newFocus = -1;
-         }
+         cmd = WXMENU_MSG_MOVE_TO_FOLDER;
          break;
 
       case 'S': // save (to file)
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_SAVE_TO_FILE, selections);
+         cmd = WXMENU_MSG_SAVE_TO_FILE;
          break;
 
       case 'R': // reply
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_REPLY, selections);
-         newFocus = -1;
+         cmd = WXMENU_MSG_REPLY;
          break;
 
       case 'G': // group reply
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_REPLY_ALL, selections);
-         newFocus = -1;
+         cmd = WXMENU_MSG_REPLY_ALL;
          break;
 
       case 'L': // list reply
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_REPLY_LIST, selections);
-         newFocus = -1;
+         cmd = WXMENU_MSG_REPLY_LIST;
          break;
 
       case 'F': // forward
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_FORWARD, selections);
-         newFocus = -1;
+         cmd = WXMENU_MSG_FORWARD;
          break;
 
       case 'O': // open
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_OPEN, selections);
+         cmd = WXMENU_MSG_OPEN;
          break;
 
       case 'P': // print
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_PRINT, selections);
+         cmd = WXMENU_MSG_PRINT;
          break;
 
       case 'H': // headers
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_TOGGLEHEADERS, selections);
-
-         // don't move focus
-         newFocus = -1;
+         cmd = WXMENU_MSG_TOGGLEHEADERS;
          break;
 
       case '*':
-         m_msgCmdProc->ProcessCommand(WXMENU_MSG_FLAG, selections);
-
-         // don't move focus
-         newFocus = -1;
+         cmd = WXMENU_MSG_FLAG;
          break;
 
@@ -4464,7 +4458,4 @@
       case '?':   // start search backwards
          {
-            // don't move focus below
-            newFocus = -1;
-
             m_searchData.uids.Clear();
 
@@ -4495,7 +4486,4 @@
       case 'N':   // find previous match
          MoveToNextSearchMatch(key == 'n');
-
-         // don't move focus below
-         newFocus = -1;
          break;
 
@@ -4503,5 +4491,5 @@
       case WXK_NEXT:
          // scroll down the preview window
-         if ( m_FolderCtrl->IsPreviewed(focused) )
+         if ( m_FolderCtrl->IsPreviewed(m_FolderCtrl->GetFocusedItem()) )
          {
             if ( !m_MessagePreview->PageDown() )
@@ -4516,7 +4504,4 @@
             event.Skip();
          }
-
-         // don't move focus
-         newFocus = -1;
          break;
 
@@ -4524,5 +4509,5 @@
       case WXK_BACK:
          // scroll up within the message viewer:
-         if ( m_FolderCtrl->IsPreviewed(focused) )
+         if ( m_FolderCtrl->IsPreviewed(m_FolderCtrl->GetFocusedItem()) )
          {
             if ( key == WXK_BACK )
@@ -4536,7 +4521,4 @@
             event.Skip();
          }
-
-         // don't move focus
-         newFocus = -1;
          break;
 
@@ -4558,11 +4540,10 @@
          // current selection, so prevent this from happening by *not* calling
          // event.Skip() here
-         newFocus = -1;
+         ;
    }
 
-   if ( newFocus != -1 )
+   if ( cmd )
    {
-      // move focus, possibly selecting the new item as well
-      (void)m_FolderCtrl->GoToItem(newFocus);
+      DoCommandEvent(cmd);
    }
 
@@ -4590,4 +4571,10 @@
    }
 
+   DoCommandEvent(cmd);
+}
+
+void
+wxFolderView::DoCommandEvent(int cmd)
+{
    const UIdArray& selections = GetSelections();
    if ( selections.IsEmpty() )
@@ -4602,6 +4589,13 @@
    {
       if ( m_msgCmdProc->ProcessCommand(cmd, selections) )
+      {
+         // after some commands (such as copying the message to another
+         // folder, tagging, ...) we want to move focus to the next message
+         // because usually you want to operate on the next message now
+         UpdateFocusAfterCommand(cmd);
+
          return;
    }
+   }
 
    switch ( cmd )



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to