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

List:       kde-commits
Subject:    kdepim/kontact/plugins/kmail
From:       Daniel Molkentin <molkentin () kde ! org>
Date:       2004-09-21 22:55:50
Message-ID: 20040921225550.3882E24FF () office ! kde ! org
[Download RAW message or body]

CVS commit by danimo: 

dragging addresses to the mail icon will now open a new mail with the adresses primary mail addresses.


  M +25 -10    kmail_plugin.cpp   1.40
  M +1 -1      kmail_plugin.h   1.24


--- kdepim/kontact/plugins/kmail/kmail_plugin.cpp  #1.39:1.40
@@ -34,8 +34,12 @@
 #include <ktempfile.h>
 
+#include <kabc/addressee.h>
+
 #include <libkcal/vcaldrag.h>
 #include <libkcal/icaldrag.h>
 #include <libkcal/calendarlocal.h>
 
+#include <libkdepim/kvcarddrag.h>
+
 #include <kmail/kmail_part.h>
 #include <kmail/kmkernel.h>
@@ -68,21 +72,32 @@ KMailPlugin::KMailPlugin(Kontact::Core *
 bool KMailPlugin::canDecodeDrag( QMimeSource *qms )
 {
-  return ( ICalDrag::canDecode( qms ) || VCalDrag::canDecode( qms ));
+  return ( ICalDrag::canDecode( qms ) ||
+           VCalDrag::canDecode( qms ) ||
+           KVCardDrag::canDecode( qms ) );
 }
 
 void KMailPlugin::processDropEvent( QDropEvent * de )
 {
+  kdDebug() << k_funcinfo << endl;
   CalendarLocal cal;
+  KABC::Addressee::List list;
 
-  if ( !VCalDrag::decode( de, &cal ) &&
-       !ICalDrag::decode( de, &cal ) )
-    return;
-
+  if ( VCalDrag::decode( de, &cal ) && ICalDrag::decode( de, &cal ) ) {
   KTempFile tmp( locateLocal( "tmp", "incidences-" ), ".ics" );
-  cal.save(tmp.name());
-  openComposer( KURL::fromPathOrURL( tmp.name() ) );
+    cal.save( tmp.name() );
+    openComposer( QString::null, KURL::fromPathOrURL( tmp.name() ) );
+  }
+  else if ( KVCardDrag::decode( de, list ) ) {
+    KABC::Addressee::List::Iterator it;
+    QStringList to;
+    for ( it = list.begin(); it != list.end(); ++it ) {
+      to += ( *it ).fullEmail();
+    }
+    openComposer( to.join(", ") );
+  }
+
 }
 
-void KMailPlugin::openComposer( const KURL& attach )
+void KMailPlugin::openComposer( const QString& to, const KURL& attach )
 {
   (void) part(); // ensure part is loaded
@@ -92,5 +107,5 @@ void KMailPlugin::openComposer( const KU
       mStub->openComposer( "", "", "", "", "", false, KURL(), attach );
     else
-      mStub->newMessage();
+      mStub->openComposer( to, "", "", "", "", false, KURL() );
   }
 }
@@ -98,5 +113,5 @@ void KMailPlugin::openComposer( const KU
 void KMailPlugin::slotNewMail()
 {
-  openComposer( KURL() );
+  openComposer( QString::null );
 }
 

--- kdepim/kontact/plugins/kmail/kmail_plugin.h  #1.23:1.24
@@ -62,5 +62,5 @@ class KMailPlugin : public Kontact::Plug
   protected:
     virtual KPIM::Part* createPart();
-    void openComposer( const KURL& );
+    void openComposer( const QString& to, const KURL& = KURL() );
     bool canDecodeDrag( QMimeSource * );
     void processDropEvent( QDropEvent * );


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

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