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

List:       kde-commits
Subject:    proko2: kdepim/kresources/kolab/shared
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2004-06-29 11:39:00
Message-ID: 20040629113900.AD39A1678 () office ! kde ! org
[Download RAW message or body]

CVS commit by thorsen: 

Make a single method to find a writable resource


  M +9 -24     resourcekolabbase.cpp   1.1.2.6
  M +3 -5      resourcekolabbase.h   1.1.2.9


--- kdepim/kresources/kolab/shared/resourcekolabbase.cpp  #1.1.2.5:1.1.2.6
@@ -129,28 +129,12 @@ bool ResourceKolabBase::connectToKMail()
 }
 
-QString ResourceKolabBase::findWritableResource( const QMap<QString, bool>& resources,
-                                                 const QString& type )
-{
-  QStringList possible;
-  QMap<QString, bool>::ConstIterator it;
-  for ( it = resources.begin(); it != resources.end(); ++it )
-    if ( it.data() )
-      // Writable possibility
-      possible << it.key();
-  return findWritableResource( possible, type );
-}
-
-QString ResourceKolabBase::findWritableResource( const QStringList& resources,
-                                                 const QString& type )
+QString ResourceKolabBase::findWritableResource( const ResourceMap& resources )
 {
-  QStringList possible;
-  QStringList::ConstIterator it;
+  ResourceMap possible;
+  ResourceMap::ConstIterator it;
   for ( it = resources.begin(); it != resources.end(); ++it ) {
-    // Ask KMail if this one is writable
-
-// TODO: This is done some other way
-//    if ( kmailIsWritableFolder( type, *it ) )
-      // Writable possibility
-      possible << *it;
+    if ( it.data().writable() && it.data().active() )
+      // Writable and active possibility
+      possible[ it.key() ] = it.data();
   }
 
@@ -160,10 +144,11 @@ QString ResourceKolabBase::findWritableR
   if ( possible.count() == 1 )
     // Just one found
-    return possible[ 0 ];
+    return possible.begin().key();
 
   // Several found, ask the user
+  // TODO: Show the label instead of the resource name
   return KInputDialog::getItem( i18n( "Select Resource Folder" ),
                                 i18n( "You have more than one writable resource folder. "
                                       "Please select the one you want to write to." ),
-                                possible );
+                                possible.keys() );
 }

--- kdepim/kresources/kolab/shared/resourcekolabbase.h  #1.1.2.8:1.1.2.9
@@ -38,4 +38,6 @@
 #include <qmap.h>
 
+#include "subresource.h"
+
 class QCString;
 class QStringList;
@@ -130,9 +132,5 @@ protected:
 
   /// If only one of these is writable, return that. Otherwise return null.
-  QString findWritableResource( const QMap<QString, bool>& resources,
-                                const QString& type );
-  /// If only one of these is writable, return that. Otherwise return null.
-  QString findWritableResource( const QStringList& resources,
-                                const QString& type );
+  QString findWritableResource( const ResourceMap& resources );
 
   bool mSilent;


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

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