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

List:       kde-commits
Subject:    branches/work/kdepim-3.5.5+
From:       Volker Krause <vkrause () kde ! org>
Date:       2007-03-01 8:50:33
Message-ID: 1172739033.706930.18653.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 638231 by vkrause:

Merge commits 636231, 636595, 636610, 637462 and 637469 from
enterprise branch:

- allow to drag messages from the search result window into the folder
  tree
- add copy/cut actions for messages to the search result window


 M  +2 -1      branches/work/kdepim-3.5.5+/kmail/Makefile.am  
 M  +19 -5     branches/work/kdepim-3.5.5+/kmail/kmfoldertree.cpp  
 M  +7 -42     branches/work/kdepim-3.5.5+/kmail/kmheaders.cpp  
 M  +7 -2      branches/work/kdepim-3.5.5+/kmail/kmheaders.h  
 A             branches/work/kdepim-3.5.5+/kmail/messagecopyhelper.cpp   \
branches/kdepim/enterprise/kdepim/kmail/messagecopyhelper.cpp#637543  A             \
branches/work/kdepim-3.5.5+/kmail/messagecopyhelper.h   \
branches/kdepim/enterprise/kdepim/kmail/messagecopyhelper.h#637543  M  +70 -1     \
branches/work/kdepim-3.5.5+/kmail/searchwindow.cpp    M  +4 -1      \
branches/work/kdepim-3.5.5+/kmail/searchwindow.h    M  +1 -1      \
branches/work/kdepim-3.5.5+/libkdepim/maillistdrag.cpp    M  +1 -1      \
branches/work/kdepim-3.5.5+/libkdepim/maillistdrag.h  


--- branches/work/kdepim-3.5.5+/kmail/Makefile.am #638230:638231
@@ -133,7 +133,8 @@
                 templatesconfiguration_kfg.kcfgc \
                 templateparser.cpp \
                 kmmsgtag.cpp \
-                copyfolderjob.cpp
+                copyfolderjob.cpp \
+                messagecopyhelper.cpp
 
 kmail_SOURCES = main.cpp
 
--- branches/work/kdepim-3.5.5+/kmail/kmfoldertree.cpp #638230:638231
@@ -10,6 +10,7 @@
 #include "kmfolderimap.h"
 #include "kmfoldercachedimap.h"
 #include "kmfolderdia.h"
+#include "kmheaders.h"
 #include "kmmainwidget.h"
 #include "kmailicalifaceimpl.h"
 #include "accountmanager.h"
@@ -20,6 +21,8 @@
 #include "expirypropertiesdialog.h"
 #include "newfolderdialog.h"
 #include "acljobs.h"
+#include "messagecopyhelper.h"
+using KMail::MessageCopyHelper;
 
 #include <maillistdrag.h>
 using namespace KPIM;
@@ -1407,7 +1410,7 @@
 
     QListViewItem *item = itemAt( contentsToViewport(e->pos()) );
     KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>(item);
-    if (fti && (fti != oldSelected) && acceptDrag(e))
+    if (fti && acceptDrag(e) && ( fti != oldSelected || e->source() != \
mMainWidget->headers()->viewport() ) )  {
       int action = -1;
       int keybstate = kapp->keyboardModifiers();
@@ -1434,10 +1437,21 @@
           moveOrCopyFolder( mCopySourceFolder, fti->folder(), (action == DRAG_MOVE) \
);  }
       } else {
-        if ( action == DRAG_MOVE && fti->folder() )
-          emit folderDrop( fti->folder() );
-        else if ( action == DRAG_COPY && fti->folder() )
-          emit folderDropCopy( fti->folder() );
+        if ( e->source() == mMainWidget->headers()->viewport() ) {
+          // KMHeaders does copy/move itself
+          if ( action == DRAG_MOVE && fti->folder() )
+            emit folderDrop( fti->folder() );
+          else if ( action == DRAG_COPY && fti->folder() )
+            emit folderDropCopy( fti->folder() );
+        } else if ( action == DRAG_COPY || action == DRAG_MOVE ) {
+          MailList list;
+          if ( !MailListDrag::decode( e, list ) ) {
+            kdWarning() << k_funcinfo << "Could not decode drag data!" << endl;
+          } else {
+            QValueList<Q_UINT32> serNums = \
MessageCopyHelper::serNumListFromMailList( list ); +            new \
MessageCopyHelper( serNums, fti->folder(), action == DRAG_MOVE, this ); +          }
+        }
       }
       e->accept( true );
     } else
--- branches/work/kdepim-3.5.5+/kmail/kmheaders.cpp #638230:638231
@@ -20,6 +20,8 @@
 using KMail::FolderJob;
 #include "actionscheduler.h"
 using KMail::ActionScheduler;
+#include "messagecopyhelper.h"
+using KMail::MessageCopyHelper;
 #include "broadcaststatus.h"
 using KPIM::BroadcastStatus;
 #include "progressmanager.h"
@@ -3388,47 +3390,11 @@
 
 void KMHeaders::pasteMessages()
 {
-  if ( mCopiedMessages.isEmpty() || !folder() )
-    return;
-
-  KMFolder *sourceFolder = 0, *f = 0;
-  int index;
-  QPtrList<KMMsgBase> list;
-
-  for ( QValueList<Q_UINT32>::ConstIterator it = mCopiedMessages.constBegin(); it != \
                mCopiedMessages.constEnd(); ++it ) {
-    KMMsgDict::instance()->getLocation( *it, &f, &index );
-    if ( !f ) // not found
-      continue;
-    if ( !sourceFolder ) {
-      sourceFolder = f;
-      sourceFolder->open();
-    }
-    if ( f != sourceFolder ) { // should not happen...
-      sourceFolder->close();
-      kdWarning() << k_funcinfo << "Found messages from diffrent source folders - \
                aborting" << endl;
-      return;
-    }
-    if ( sourceFolder == folder() ) {
-      KMessageBox::error( this, i18n("The selected messages are already in this \
                folder.") );
-      sourceFolder->close();
-      return;
-    }
-    KMMsgBase *msgBase = f->getMsgBase( index );
-    if ( msgBase )
-      list.append( msgBase );
-  }
-
-  KMCommand *command;
+  new MessageCopyHelper( mCopiedMessages, folder(), mMoveMessages, this );
   if ( mMoveMessages ) {
-    command = new KMMoveCommand( folder(), list );
     mCopiedMessages.clear();
     updateActions();
-  } else {
-    command = new KMCopyCommand( folder(), list );
   }
-  mOpenFolders.insert( command, sourceFolder );
-  connect( command, SIGNAL(completed(KMCommand*)), SLOT(copyCompleted(KMCommand*)) \
                );
-  command->start();
 }
 
 void KMHeaders::updateActions()
@@ -3454,12 +3420,11 @@
     paste->setEnabled( true );
 }
 
-void KMHeaders::copyCompleted(KMCommand * command)
+void KMHeaders::setCopiedMessages(const QValueList< Q_UINT32 > & msgs, bool move)
 {
-  if ( mOpenFolders.contains( command ) ) {
-    mOpenFolders[command]->close();
-    mOpenFolders.remove( command );
-  }
+  mCopiedMessages = msgs;
+  mMoveMessages = move;
+  updateActions();
 }
 
 #include "kmheaders.moc"
--- branches/work/kdepim-3.5.5+/kmail/kmheaders.h #638230:638231
@@ -183,6 +183,13 @@
   QFont todoFont() const { return mTodoFont; }
   QFont dateFont() const { return mDateFont; }
 
+  /**
+    Sets the list of copied/cutted messages.
+    @param msgs A list of serial numbers.
+    @param move if true, the messages were cutted
+  */
+  void setCopiedMessages( const QValueList<Q_UINT32> &msgs, bool move );
+
 signals:
   /** emitted when the list view item corresponding to this message
       has been selected */
@@ -348,7 +355,6 @@
   void pasteMessages();
 
   void updateActions();
-  void copyCompleted( KMCommand *command );
 
 private:
   /** Is equivalent to clearing the list and inserting an item for
@@ -446,6 +452,5 @@
   // copied messages
   QValueList<Q_UINT32> mCopiedMessages;
   bool mMoveMessages;
-  QMap<KMCommand*, QGuardedPtr<KMFolder> > mOpenFolders;
 }; // class
 #endif
--- branches/work/kdepim-3.5.5+/kmail/searchwindow.cpp #638230:638231
@@ -28,9 +28,12 @@
 #include "kmfoldermgr.h"
 #include "kmfoldersearch.h"
 #include "kmfoldertree.h"
+#include "kmheaders.h"
 #include "kmsearchpatternedit.h"
 #include "kmsearchpattern.h"
 #include "folderrequester.h"
+#include "messagecopyhelper.h"
+#include "textsource.h"
 
 #include <kapplication.h>
 #include <kdebug.h>
@@ -38,6 +41,7 @@
 #include <kwin.h>
 #include <kconfig.h>
 #include <kstdaction.h>
+#include <kiconloader.h>
 
 #include <qcheckbox.h>
 #include <qlayout.h>
@@ -50,6 +54,9 @@
 #include <qcursor.h>
 #include <qpopupmenu.h>
 
+#include <maillistdrag.h>
+using namespace KPIM;
+
 #include <mimelib/enum.h>
 #include <mimelib/boyermor.h>
 
@@ -60,6 +67,44 @@
 
 const int SearchWindow::MSGID_COLUMN = 4;
 
+// KListView sub-class for dnd support
+class MatchListView : public KListView
+{
+  public:
+    MatchListView( QWidget *parent, SearchWindow* sw, const char* name = 0 ) :
+      KListView( parent, name ),
+      mSearchWindow( sw )
+    {}
+
+  protected:
+    virtual QDragObject* dragObject()
+    {
+      KMMessageList list = mSearchWindow->selectedMessages();
+      MailList mailList;
+      for ( KMMsgBase* msg = list.first(); msg; msg = list.next() ) {
+        if ( !msg )
+          continue;
+        MailSummary mailSummary( msg->getMsgSerNum(), msg->msgIdMD5(),
+                                 msg->subject(), msg->fromStrip(),
+                                 msg->toStrip(), msg->date() );
+        mailList.append( mailSummary );
+      }
+      MailListDrag *d = new MailListDrag( mailList, viewport(), new KMTextSource );
+
+      QPixmap pixmap;
+      if( mailList.count() == 1 )
+        pixmap = QPixmap( DesktopIcon("message", KIcon::SizeSmall) );
+      else
+        pixmap = QPixmap( DesktopIcon("kmultiple", KIcon::SizeSmall) );
+
+      d->setPixmap( pixmap );
+      return d;
+    }
+
+  private:
+    SearchWindow* mSearchWindow;
+};
+
 //-----------------------------------------------------------------------------
 SearchWindow::SearchWindow(KMMainWidget* w, const char* name,
                          KMFolder *curFolder, bool modal):
@@ -157,7 +202,7 @@
   connect( mChkbxAllFolders, SIGNAL(toggled(bool)),
            this, SLOT(setEnabledSearchButton(bool)) );
 
-  mLbxMatches = new KListView(searchWidget, "Find Messages");
+  mLbxMatches = new MatchListView(searchWidget, this, "Find Messages");
 
   /*
      Default is to sort by date. TODO: Unfortunately this sorts *while*
@@ -190,6 +235,8 @@
   mLbxMatches->setColumnWidth(MSGID_COLUMN, 0);
   mLbxMatches->header()->setResizeEnabled(false, MSGID_COLUMN);
 
+  mLbxMatches->setDragEnabled( true );
+
   connect(mLbxMatches, SIGNAL(doubleClicked(QListViewItem *)),
           this, SLOT(slotShowMsg(QListViewItem *)));
   connect( mLbxMatches, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint \
&, int )), @@ -256,6 +303,7 @@
 
   //set up actions
   KActionCollection *ac = actionCollection();
+  ac->setWidget( this );
   mReplyAction = new KAction( i18n("&Reply..."), "mail_reply", 0, this,
                               SLOT(slotReplyToMsg()), ac, "search_reply" );
   mReplyAllAction = new KAction( i18n("Reply to &All..."), "mail_replyall",
@@ -297,6 +345,10 @@
   mPrintAction = KStdAction::print( this, SLOT(slotPrintMsg()), ac, "search_print" \
);  mClearAction = new KAction( i18n("Clear Selection"), 0, 0, this,
                               SLOT(slotClearSelection()), ac, \
"search_clear_selection" ); +
+  mCopyAction = KStdAction::copy( this, SLOT(slotCopyMsgs()), ac, \
"search_copy_messages" ); +  mCutAction = KStdAction::cut( this, SLOT(slotCutMsgs()), \
ac, "search_cut_messages" ); +
   connect(mTimer, SIGNAL(timeout()), this, SLOT(updStatus()));
   connect(kmkernel->searchFolderMgr(), SIGNAL(folderInvalidated(KMFolder*)),
           this, SLOT(folderInvalidated(KMFolder*)));
@@ -717,6 +769,8 @@
     mPrintAction->setEnabled( single_actions );
     mForwardDigestAction->setEnabled( !single_actions );
     mRedirectAction->setEnabled( single_actions );
+    mCopyAction->setEnabled( count > 0 );
+    mCutAction->setEnabled( count > 0 );
 }
 
 //-----------------------------------------------------------------------------
@@ -746,8 +800,11 @@
     mReplyListAction->plug(menu);
     mForwardActionMenu->plug(menu);
     menu->insertSeparator();
+    mCopyAction->plug(menu);
+    mCutAction->plug(menu);
     menu->insertItem(i18n("&Copy To"), msgCopyMenu);
     menu->insertItem(i18n("&Move To"), msgMoveMenu);
+    menu->insertSeparator();
     mSaveAsAction->plug(menu);
     mSaveAtchAction->plug(menu);
     mPrintAction->plug(menu);
@@ -838,5 +895,17 @@
     command->start();
 }
 
+void SearchWindow::slotCopyMsgs()
+{
+  QValueList<Q_UINT32> list = MessageCopyHelper::serNumListFromMsgList( \
selectedMessages() ); +  mKMMainWidget->headers()->setCopiedMessages( list, false );
+}
+
+void SearchWindow::slotCutMsgs()
+{
+  QValueList<Q_UINT32> list = MessageCopyHelper::serNumListFromMsgList( \
selectedMessages() ); +  mKMMainWidget->headers()->setCopiedMessages( list, true );
+}
+
 } // namespace KMail
 #include "searchwindow.moc"
--- branches/work/kdepim-3.5.5+/kmail/searchwindow.h #638230:638231
@@ -127,6 +127,8 @@
   void slotSaveMsg();
   void slotSaveAttachments();
   void slotPrintMsg();
+  void slotCopyMsgs();
+  void slotCutMsgs();
 
   /** GUI cleanup after search */
   virtual void searchDone();
@@ -170,7 +172,8 @@
   QMap<int,KMFolder*> mMenuToFolder;
   KAction *mReplyAction, *mReplyAllAction, *mReplyListAction, *mSaveAsAction,
     *mForwardInlineAction, *mForwardAttachedAction, *mForwardDigestAction,
-    *mRedirectAction, *mPrintAction, *mClearAction, *mSaveAtchAction;
+    *mRedirectAction, *mPrintAction, *mClearAction, *mSaveAtchAction,
+    *mCopyAction, *mCutAction;
   KActionMenu *mForwardActionMenu;
   QValueList<QGuardedPtr<KMFolder> > mFolders;
 
--- branches/work/kdepim-3.5.5+/libkdepim/maillistdrag.cpp #638230:638231
@@ -37,7 +37,7 @@
       mSubject( subject ), mFrom( from ), mTo( to ), mDate( date )
 {}
 
-Q_UINT32 MailSummary::serialNumber() 
+Q_UINT32 MailSummary::serialNumber() const 
 { 
     return mSerialNumber; 
 }
--- branches/work/kdepim-3.5.5+/libkdepim/maillistdrag.h #638230:638231
@@ -56,7 +56,7 @@
     void set( Q_UINT32, QString, QString, QString, QString, time_t );
 
     /*** KMail unique identification number ***/
-    Q_UINT32 serialNumber();
+    Q_UINT32 serialNumber() const;
 
     /*** MD5 checksum of message identification string ***/
     QString messageId();


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

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