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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] move contacts between resources
From:       Till Adam <till () adam-lilienthal ! de>
Date:       2004-09-13 9:08:05
Message-ID: 200409131108.06264.till () adam-lilienthal ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hey folks,

the attached patch makes it possible to move a contact (or several of them) to 
a different resource. It adds a RMB menu entry and an entry in the Edit menu 
for that. If you have several contacts selected, the target resource is only 
asked for once, then all contacts are moved to that resource. 

Ok to commit to HEAD? I need it in the branch as well, for proko2, but unless 
Tobias considers it a bugfix, we'll have to apply the patch locally.

Till

["KAddressBook-move-between-resources.diff" (text/x-diff)]

Index: kabcore.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/kabcore.cpp,v
retrieving revision 1.119
diff -u -3 -p -r1.119 kabcore.cpp
--- kabcore.cpp	4 Aug 2004 16:33:35 -0000	1.119
+++ kabcore.cpp	10 Sep 2004 10:43:21 -0000
@@ -323,6 +323,7 @@ void KABCore::setContactSelected( const 
   mActionCopy->setEnabled( selected );
   mActionDelete->setEnabled( selected );
   mActionEditAddressee->setEnabled( selected );
+  mActionStoreAddresseeIn->setEnabled( selected );
   mActionMail->setEnabled( selected );
   mActionMailVCard->setEnabled( selected );
   mActionChat->setEnabled( selected );
@@ -693,6 +694,35 @@ void KABCore::editContact( const QString
   }
 }
 
+void KABCore::storeContactIn( const QString &uid )
+{
+  // First, locate the contact entry
+  QStringList uidList;
+  if ( uid.isNull() ) {
+    uidList = mViewManager->selectedUids();
+  } else {
+    uidList << uid;
+  }
+  KABC::Resource *resource = requestResource( mWidget );
+  KABLock::self( mAddressBook )->lock( resource );
+  QStringList::Iterator it( uidList.begin() );
+  while ( resource && it != uidList.end() ) {
+    KABC::Addressee addr = mAddressBook->findByUid( *it++ );
+    if ( !addr.isEmpty() ) {
+      KABC::Addressee newAddr( addr );
+      // We need to set a new uid, otherwise the insert below is
+      // ignored. This is bad for syncing, but unavoidable, afaiks
+      newAddr.setUid( KApplication::randomString( 10 ) );
+      newAddr.setResource( resource );
+      addressBook()->insertAddressee( newAddr );
+      KABLock::self( mAddressBook )->lock( addr.resource() );
+      addressBook()->removeAddressee( addr );
+      KABLock::self( mAddressBook )->unlock( addr.resource() );
+    }
+  }
+  KABLock::self( mAddressBook )->unlock( resource );
+}
+
 void KABCore::save()
 {
   KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
@@ -1039,6 +1069,13 @@ void KABCore::initActions()
                                actionCollection(), "edit_delete" );
   mActionDelete->setWhatsThis( i18n( "Delete all selected contacts." ) );
 
+  
+  mActionStoreAddresseeIn = new KAction( i18n( "St&ore Contact in..." ), "", 0,
+                                      this, SLOT( storeContactIn() ),
+                                      actionCollection(), "edit_store_in" );
+  mActionStoreAddresseeIn->setWhatsThis( i18n( "Store a contact in a different \
Addressbook<p>You will be presented with a dialog where you can select a new storage \
place for this contact." ) ); +
+
   mActionUndo->setEnabled( false );
   mActionRedo->setEnabled( false );
 
Index: kabcore.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/kabcore.h,v
retrieving revision 1.37
diff -u -3 -p -r1.37 kabcore.h
--- kabcore.h	14 Jul 2004 16:34:09 -0000	1.37
+++ kabcore.h	10 Sep 2004 10:43:21 -0000
@@ -307,6 +307,12 @@ class KABCore : public KAB::Core
     void editContact( const QString &uid = QString::null );
 
     /**
+     * Let the user chose a different resource for the selected contacts.
+     * If the adding to the new resource is successfull, the contact is
+     * removed from the old one. */
+    void storeContactIn( const QString &uid = QString::null );
+
+    /**
       Launches the ldap search dialog.
      */
     void openLDAPDialog();
@@ -381,6 +387,7 @@ class KABCore : public KAB::Core
     KAction *mActionDelete;
     KAction *mActionCopy;
     KAction *mActionEditAddressee;
+    KAction *mActionStoreAddresseeIn;
     KAction *mActionMerge;
     KAction *mActionMail;
     KAction *mActionMailVCard;
Index: kaddressbook_part.rc
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/kaddressbook_part.rc,v
retrieving revision 1.29
diff -u -3 -p -r1.29 kaddressbook_part.rc
--- kaddressbook_part.rc	30 Jun 2004 00:57:49 -0000	1.29
+++ kaddressbook_part.rc	10 Sep 2004 10:43:21 -0000
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="kaddressbook" version="14">
+<kpartgui name="kaddressbook" version="15">
 
   <MenuBar>
     <Menu name="file" noMerge="1"><text>&amp;File</text>
@@ -29,6 +29,7 @@
       <Action name="edit_paste"/>
       <Separator/>
       <Action name="edit_delete" append="edit_paste_merge"/>
+      <Action name="edit_store_in"/>
       <Action name="edit_select_all"/>
       <Action name="edit_merge"/>
       <Action name="edit_set_categories"/>
@@ -68,6 +69,7 @@
     <Action name="file_properties"/>
     <Action name="file_new_contact"/>
     <Action name="edit_delete"/>
+    <Action name="edit_store_in"/>
     <Separator/>
     <Action name="file_mail"/>
     <Action name="file_mail_vcard"/>
@@ -93,6 +95,7 @@
     <Action name="edit_paste"/>
     <Separator/>
     <Action name="edit_delete"/>
+    <Action name="edit_store_in"/>
   </ToolBar>
 
 </kpartgui>
Index: kaddressbookui.rc
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/kaddressbookui.rc,v
retrieving revision 1.49
diff -u -3 -p -r1.49 kaddressbookui.rc
--- kaddressbookui.rc	30 Jun 2004 00:57:49 -0000	1.49
+++ kaddressbookui.rc	10 Sep 2004 10:43:21 -0000
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="kaddressbook" version="13">
+<kpartgui name="kaddressbook" version="14">
 
   <MenuBar>
     <Menu name="file" noMerge="1"><text>&amp;File</text>
@@ -29,6 +29,7 @@
       <Action name="edit_paste"/>
       <Separator/>
       <Action name="edit_delete" append="edit_paste_merge"/>
+      <Action name="edit_store_in"/>
       <Action name="edit_select_all"/>
       <Action name="edit_merge"/>
       <Action name="edit_set_categories"/>
@@ -71,6 +72,7 @@
     <Action name="file_properties"/>
     <Action name="file_new_contact"/>
     <Action name="edit_delete"/>
+    <Action name="edit_store_in"/>
     <Separator/>
     <Action name="file_mail"/>
     <Action name="file_mail_vcard"/>
@@ -96,6 +98,7 @@
     <Action name="edit_paste"/>
     <Separator/>
     <Action name="edit_delete"/>
+    <Action name="edit_store_in"/>
   </ToolBar>
 
 </kpartgui>


[Attachment #8 (application/pgp-signature)]

_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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