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

List:       kde-commits
Subject:    branches/KDE/3.5/kdepim
From:       Volker Krause <vkrause () kde ! org>
Date:       2008-08-18 18:18:49
Message-ID: 1219083529.818414.9226.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 848928 by vkrause:

Merged revisions 788582-788633,788635-789924,789926-790348,790350-790351,790353-791183,791185-79 \
1199,791201-791413,791415-791429,791431-791440,791443-792201,792203-792229,792232-792949,792951- \
792956,792958-793295,793297-793304,793306-793471,793473-793538,793540-794733,794735-795744,79574 \
6-795763,795765,795767-797347,797349-797351,797353-797721,797723-798444,798447-798448,798450-798 \
495,798497-800070,800072-800167,800169-800440,800442-800614,800616-802138,802140-802148,802150-8 \
02151,802153-803256,803258-803259,803261-803299,803301-803308,803310-803338,803340-803380,803383 \
-803397,803399-804108,804110-804615,804617-804641,804643-804990,804992-804993,804995-805190,8051 \
92-805347,805349-805427,805429,805431-805459,805461-805670,805672-805700,805703-805824,805826,80 \
5828-807760,807762-809626,809628-809708,809710-810236,810238-810302,810304,810306-811064,811066- \
811205,811207-813546,813549-814372,814374,814376-816024,816026-816313,816315-816322,816324-817070,817072-817087,817089-817567,
  817569-817603,817605-817709,817711-818287,818289-818311,818313-819076,819078-820073,820075-821 \
035,821037-821124,821126-821345,821347-821370,821372-821378,821380-821648,821650,821652-821813,8 \
21815-821835,821837-822268,822270-823852,823854-823864,823866-823882,823884-824217,824219-824277 \
,824279-824285,824287-824288,824290-824805,824807-825075,825077-825083,825085-825805,825807-8263 \
54,826356-827490,827492-827612,827614-827891,827893-827903,827905-827944,827946-827949,827951-828972,828974-829034 \
via svnmerge from  https://vkrause@svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim

........
  r788582 | ahartmetz | 2008-03-21 22:45:51 +0100 (Fri, 21 Mar 2008) | 1 line
  
  Only enable actions that actually make sense. This may or may not fix bugs reported in the \
Intevation Bugzilla but it seems to be the right thing to do and it gives us a more solid \
                foundation to work with :)
........
  r817102 | tilladam | 2008-06-05 11:21:28 +0200 (Thu, 05 Jun 2008) | 5 lines
  
  Only enable the "copy to" and "move to" actions if there is
  somewhere to move or copy them to, namely another addressbook.
  
  kolab/issue2659
........
  r829034 | tilladam | 2008-07-07 12:14:25 +0200 (Mon, 07 Jul 2008) | 7 lines
  
  Check if the added contact actually made it into the addressbook, after
  the insert (as libkabc provides no other error handling) and don't 
  remove the original if it didn't. This happens when the resource
  or subresource selection dialog is cancelled.
  
  kolab/issue2522
........


 _M            . (directory)  
 M  +75 -21    kaddressbook/kabcore.cpp  


** branches/KDE/3.5/kdepim #property svnmerge-integrated
   - /branches/kdepim/enterprise/kdepim:1-767022,767033,767233-767554,767556,767558-767946,76794 \
8-769318,769320-769354,769356-771105,771107-771251,771253-772311,772313-772316,772318-775194,775 \
196-775202,775204,775207-775211,775213-778001,778003-778004,778007,778010-778011,778013-778029,7 \
78031-778727,778729-779448,779450-779482,779484-779505,779507-779852,779854-779994,780211,780250 \
-780452,780454-780495,780497,780499-780529,780531-782028,782030-783127,783129-783243,783245,7832 \
48-783477,783479-784380,784382-784426,784428-784691,784693-785478,785480-785558,787827,788634,78 \
9925,790349-790352,791184-791440,791443-792201,792203-792957,793296,794734,795745-795763,795765, \
795767-798445,798447-798448,798450-798495,798497-800070,800072-800167,800169-802138,802140-80214 \
8,802150-802151,802153-803259,803261-803299,803301-803308,803310-803380,803383-803397,803399-804 \
993,804995-805347,805349-805427,805429-805459,805461-805702,807761-809708,809710-810236,810238-810302,810304,810306-811205,811
  207-813547,813549-814372,814374,814376-816024,816026-816313,816315-816322,816324-817070,817072 \
-817087,817089-817101,817103-819076,819078-821035,821037-821124,821126-821378,821380-821648,8216 \
50-822268,822270-824277,824279-825075,825077-825083,825085-826354,826356-827612,827614-827891,82 \
7893-827944,827946-827949,827951-829033,829035-830477,830479-830875,830877-830932,830934-836103, \
836105-836275,836278-836391,836393-836428,836430-837231,837233-837624,840224-840428,840430-840706,840708-840710,840712-843750,843760
  + /branches/kdepim/enterprise/kdepim:1-767022,767033,767233-767554,767556,767558-767946,767948 \
-769318,769320-769354,769356-771105,771107-771251,771253-772311,772313-772316,772318-775194,7751 \
96-775202,775204,775207-775211,775213-778001,778003-778004,778007,778010-778011,778013-778029,77 \
8031-778727,778729-779448,779450-779482,779484-779505,779507-779852,779854-779994,780211,780250- \
780452,780454-780495,780497,780499-780529,780531-782028,782030-783127,783129-783243,783245,78324 \
8-783477,783479-784380,784382-784426,784428-784691,784693-785478,785480-785558,787827,788582-791 \
440,791443-792201,792203-793304,793306-793471,793473-793538,793540-795763,795765,795767-798445,7 \
98447-798448,798450-798495,798497-800070,800072-800167,800169-802138,802140-802148,802150-802151 \
,802153-803259,803261-803299,803301-803308,803310-803380,803383-803397,803399-804993,804995-8053 \
47,805349-805427,805429-805459,805461-805824,805826,805828-809708,809710-810236,810238-810302,810304,810306-811205,811207-813
  547,813549-814372,814374,814376-816024,816026-816313,816315-816322,816324-817070,817072-817087 \
,817089-819076,819078-821035,821037-821124,821126-821378,821380-821648,821650-822268,822270-8242 \
77,824279-825075,825077-825083,825085-826354,826356-827612,827614-827891,827893-827944,827946-82 \
7949,827951-830477,830479-830875,830877-830932,830934-836103,836105-836275,836278-836391,836393- \
836428,836430-837231,837233-837624,840224-840428,840430-840706,840708-840710,840712-843750,843760
                
--- branches/KDE/3.5/kdepim/kaddressbook/kabcore.cpp #848927:848928
@@ -65,6 +65,7 @@
 #include <libkdepim/addresseeview.h>
 #include <libkdepim/categoryeditdialog.h>
 #include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/resourceabc.h>
 #include "distributionlisteditor.h"
 
 #include "addresseeutil.h"
@@ -277,14 +278,13 @@
   while ( ( resource = resIt.current() ) != 0 ) {
     ++resIt;
     if ( !resource->readOnly() ) {
-      KRES::Resource *res = static_cast<KRES::Resource*>( resource );
-      if ( res )
-        kresResources.append( res );
+      KRES::Resource *res = resource; // downcast
+      kresResources.append( res );
     }
   }
 
   KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
-  return static_cast<KABC::Resource*>( res );
+  return static_cast<KABC::Resource*>( res ); // upcast
 }
 
 QWidget *KABCore::widget() const
@@ -337,32 +337,84 @@
 #endif
   mExtensionManager->setSelectionChanged();
 
+  KABC::Addressee::List list = mViewManager->selectedAddressees();
+  const bool someSelected = list.size() > 0;
+  const bool singleSelected = list.size() == 1;
+  bool writable = mReadWrite;
+
+  if ( writable ) {
+    //check if every single (sub)resource is writable
+    //### We have a performance problem here - everytime *one* item is added or
+    //    removed we re-check *all* items. If this turns out to be a bottleneck
+    //    we need to keep some state and check new items only.
+    KABC::Addressee::List::ConstIterator addrIt = list.constBegin();
+    for ( ; addrIt != list.constEnd(); ++addrIt ) {
+      KABC::Resource *res = ( *addrIt ).resource();
+      if ( !res ) {
+        kdDebug() << "KABCore::setContactSelected: this addressee has no resource!" << endl;
+        writable = false;
+        break;
+      }
+      if ( res->readOnly() ) {
+        writable = false;
+        break;
+      }
+      //HACK: manual polymorphism
+      if ( res->inherits( "KPIM::ResourceABC" ) ) {
+        KPIM::ResourceABC *resAbc = static_cast<KPIM::ResourceABC *>( res );
+
+        QString subresource = resAbc->uidToResourceMap()[ ( *addrIt ).uid() ];
+        if ( !subresource.isEmpty() && !resAbc->subresourceWritable( subresource ) ) {
+          writable = false;
+          break;
+        }
+      }
+    }
+  }
+
+  bool moreThanOneResource = mAddressBook->resources().count() > 1;
+  if ( !moreThanOneResource && !mAddressBook->resources().isEmpty() ) {
+      KABC::Resource *res = mAddressBook->resources().first();
+      if ( res->inherits( "KPIM::ResourceABC" ) ) {
+        KPIM::ResourceABC *resAbc = static_cast<KPIM::ResourceABC *>( res );
+        const QStringList subresources = resAbc->subresources();
+        int writeables = 0;
+        for ( QStringList::ConstIterator it = subresources.begin(); it != subresources.end(); \
++it ) { +            if ( resAbc->subresourceActive(*it) && resAbc->subresourceWritable(*it) ) \
{ +                writeables++;
+            }
+        }
+        moreThanOneResource = ( writeables >= 2 );
+      }
+  }
+
   // update the actions
-  bool selected = !uid.isEmpty();
 
+  mActionCopy->setEnabled( someSelected );
+  mActionCut->setEnabled( someSelected && writable );
+  mActionDelete->setEnabled( someSelected && writable );
+  // the "edit" dialog doubles as the details dialog and it knows when the addressee is \
read-only +  // (### this does not make much sense from the user perspective!)
+  mActionEditAddressee->setEnabled( singleSelected );
+  mActionCopyAddresseeTo->setEnabled( someSelected && moreThanOneResource );
+  mActionMoveAddresseeTo->setEnabled( someSelected && moreThanOneResource && writable );
+  mActionMail->setEnabled( someSelected );
+  mActionMailVCard->setEnabled( someSelected );
+  mActionChat->setEnabled( singleSelected && mKIMProxy && mKIMProxy->initialize() );
+  mActionWhoAmI->setEnabled( singleSelected );
+  mActionCategories->setEnabled( someSelected && writable );
+  mActionMerge->setEnabled( ( list.size() == 2 ) && writable );
+
   if ( mReadWrite ) {
-    mActionCut->setEnabled( selected );
-
     QClipboard *cb = QApplication::clipboard();
-    KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
+    list = AddresseeUtil::clipboardToAddressees( cb->text() );
     mActionPaste->setEnabled( !list.isEmpty() );
   }
-
-  mActionCopy->setEnabled( selected );
-  mActionDelete->setEnabled( selected );
-  mActionEditAddressee->setEnabled( selected );
-  mActionCopyAddresseeTo->setEnabled( selected );
-  mActionMoveAddresseeTo->setEnabled( selected );
-  mActionMail->setEnabled( selected );
-  mActionMailVCard->setEnabled( selected );
-  mActionChat->setEnabled( selected && mKIMProxy && mKIMProxy->initialize() );
-  mActionWhoAmI->setEnabled( selected );
-  mActionCategories->setEnabled( selected );
-  mActionMerge->setEnabled( selected );
 }
 
 void KABCore::sendMail()
 {
+  //FIXME: breaks with email addresses containing ","
   sendMail( mViewManager->selectedEmails().join( ", " ) );
 }
 
@@ -533,6 +585,7 @@
   KABC::Addressee::List addrList = mViewManager->selectedAddressees();
 
   if ( addrList.count() > 1 ) {
+    // can probably be removed because we now check the selection in setContactSelected().
     KMessageBox::sorry( mWidget, i18n( "Please select only one contact." ) );
     return;
   }
@@ -780,7 +833,8 @@
       newAddr.setUid( KApplication::randomString( 10 ) );
       newAddr.setResource( resource );
       addressBook()->insertAddressee( newAddr );
-      if ( !copy ) {
+      const bool inserted = addressBook()->find( newAddr ) != addressBook()->end();
+      if ( !copy && inserted ) {
           KABLock::self( mAddressBook )->lock( addr.resource() );
           addressBook()->removeAddressee( addr );
           KABLock::self( mAddressBook )->unlock( addr.resource() );


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

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