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

List:       kde-commits
Subject:    KDE/kdepim/libkleo/backends/qgpgme
From:       Laurent Montel <montel () kde ! org>
Date:       2007-06-18 9:01:48
Message-ID: 1182157308.287410.22279.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 677014 by mlaurent:

Q3Dict--


 M  +45 -32    qgpgmecryptoconfig.cpp  
 M  +5 -5      qgpgmecryptoconfig.h  


--- trunk/KDE/kdepim/libkleo/backends/qgpgme/qgpgmecryptoconfig.cpp #677013:677014
@@ -62,9 +62,8 @@
 // Change size of mFlags bitfield if adding new values here
 
 QGpgMECryptoConfig::QGpgMECryptoConfig()
- : mComponents( 7 ), mParsed( false )
+ :  mParsed( false )
 {
-    mComponents.setAutoDelete( true );
 }
 
 QGpgMECryptoConfig::~QGpgMECryptoConfig()
@@ -125,10 +124,11 @@
 {
   if ( !mParsed )
     const_cast<QGpgMECryptoConfig*>( this )->runGpgConf( true );
-  Q3DictIterator<QGpgMECryptoConfigComponent> it( mComponents );
   QStringList names;
-  for( ; it.current(); ++it )
-    names.push_back( it.currentKey() );
+  QList<QString> keylist = mComponents.uniqueKeys();
+  foreach (QString key, keylist) {
+	names << key;
+  }
   return names;
 }
 
@@ -136,19 +136,20 @@
 {
   if ( !mParsed )
     const_cast<QGpgMECryptoConfig*>( this )->runGpgConf( false );
-  return mComponents.find( name );
+  return mComponents.value( name );
 }
 
 void QGpgMECryptoConfig::sync( bool runtime )
 {
-  Q3DictIterator<QGpgMECryptoConfigComponent> it( mComponents );
-  for( ; it.current(); ++it )
-    it.current()->sync( runtime );
+  foreach (QGpgMECryptoConfigComponent *it, mComponents){
+  	it->sync(runtime);
+  }
 }
 
 void QGpgMECryptoConfig::clear()
 {
   s_duringClear = true;
+  qDeleteAll(mComponents);
   mComponents.clear();
   s_duringClear = false;
   mParsed = false; // next call to componentList/component will need to run gpgconf \
again @@ -157,14 +158,15 @@
 ////
 
 QGpgMECryptoConfigComponent::QGpgMECryptoConfigComponent( QGpgMECryptoConfig*, const \
                QString& name, const QString& description )
-  : mGroups( 7 ), mName( name ), mDescription( description )
+  : mName( name ), mDescription( description )
 {
-  mGroups.setAutoDelete( true );
   runGpgConf();
 }
 
 QGpgMECryptoConfigComponent::~QGpgMECryptoConfigComponent()
 {
+  qDeleteAll(mGroups);
+  mGroups.clear();
 }
 
 void QGpgMECryptoConfigComponent::runGpgConf()
@@ -236,16 +238,17 @@
 
 QStringList QGpgMECryptoConfigComponent::groupList() const
 {
-  Q3DictIterator<QGpgMECryptoConfigGroup> it( mGroups );
   QStringList names;
-  for( ; it.current(); ++it )
-    names.push_back( it.currentKey() );
+  QList<QString> keylist = mGroups.uniqueKeys();
+  foreach (QString key, keylist) {
+        names << key;
+  }
   return names;
 }
 
 Kleo::CryptoConfigGroup* QGpgMECryptoConfigComponent::group(const QString& name ) \
const  {
-  return mGroups.find( name );
+  return mGroups.value( name );
 }
 
 void QGpgMECryptoConfigComponent::sync( bool runtime )
@@ -256,26 +259,30 @@
   QList<QGpgMECryptoConfigEntry *> dirtyEntries;
 
   // Collect all dirty entries
-  Q3DictIterator<QGpgMECryptoConfigGroup> groupit( mGroups );
-  for( ; groupit.current(); ++groupit ) {
-    Q3DictIterator<QGpgMECryptoConfigEntry> it( groupit.current()->mEntries );
-    for( ; it.current(); ++it ) {
-      if ( it.current()->isDirty() ) {
-        // OK, we can set it.currentKey() to it.current()->outputString()
-        QString line = it.currentKey();
-        if ( it.current()->isSet() ) { // set option
+  QList<QString> keylist = mGroups.uniqueKeys();
+  foreach (QString key, keylist) {
+    QHash<QString,QGpgMECryptoConfigEntry*> entry = mGroups[key]->mEntries;
+    QList<QString> keylistentry = entry.uniqueKeys(); 
+    foreach (QString keyentry, keylistentry) {
+      if(entry[keyentry]->isDirty())
+      {
+       // OK, we can set it.currentKey() to it.current()->outputString()
+        QString line = keyentry;
+        if ( entry[keyentry]->isSet() ) { // set option
           line += ":0:";
-          line += it.current()->outputString();
+          line += entry[keyentry]->outputString();
         } else {                       // unset option
           line += ":16:";
         }
         line += '\n';
         QByteArray line8bit = line.toUtf8(); // encode with utf8, and K3ProcIO uses \
utf8 when reading.  tmpFile.write( line8bit.data(), line8bit.size()-1 /*no 0*/ );
-        dirtyEntries.append( it.current() );
+        dirtyEntries.append( entry[keyentry] );
+
       }
-    }
+    } 
   }
+
   tmpFile.flush();
   if ( dirtyEntries.isEmpty() )
     return;
@@ -327,26 +334,32 @@
 ////
 
 QGpgMECryptoConfigGroup::QGpgMECryptoConfigGroup( const QString & name, const \
                QString& description, int level )
-  : mEntries( 29 ),
+  :
     mName( name ),
     mDescription( description ),
     mLevel( static_cast<Kleo::CryptoConfigEntry::Level>( level ) )
 {
-  mEntries.setAutoDelete( true );
 }
 
+QGpgMECryptoConfigGroup::~QGpgMECryptoConfigGroup()
+{
+  qDeleteAll(mEntries);
+  mEntries.clear();
+}
+
 QStringList QGpgMECryptoConfigGroup::entryList() const
 {
-  Q3DictIterator<QGpgMECryptoConfigEntry> it( mEntries );
   QStringList names;
-  for( ; it.current(); ++it )
-    names.push_back( it.currentKey() );
+  QList<QString> keylist = mEntries.uniqueKeys();
+  foreach (QString key, keylist) {
+        names << key;
+  }
   return names;
 }
 
 Kleo::CryptoConfigEntry* QGpgMECryptoConfigGroup::entry( const QString& name ) const
 {
-  return mEntries.find( name );
+  return mEntries.value( name );
 }
 
 ////
--- trunk/KDE/kdepim/libkleo/backends/qgpgme/qgpgmecryptoconfig.h #677013:677014
@@ -36,7 +36,7 @@
 #include "libkleo_export.h"
 #include "kleo/cryptoconfig.h"
 
-#include <q3dict.h>
+#include <QHash>
 #include <QStringList>
 #include <QObject>
 #include <QVariant>
@@ -72,7 +72,7 @@
   void runGpgConf( bool showErrors );
 
 private:
-  Q3Dict<QGpgMECryptoConfigComponent> mComponents;
+  QHash<QString, QGpgMECryptoConfigComponent*> mComponents;
   bool mParsed;
 };
 
@@ -100,7 +100,7 @@
   void runGpgConf();
 
 private:
-  Q3Dict<QGpgMECryptoConfigGroup> mGroups;
+  QHash<QString,QGpgMECryptoConfigGroup*> mGroups;
   QString mName;
   QString mDescription;
   QGpgMECryptoConfigGroup* mCurrentGroup; // during parsing
@@ -111,7 +111,7 @@
 
 public:
   QGpgMECryptoConfigGroup( const QString & name, const QString& description, int \
                level );
-  ~QGpgMECryptoConfigGroup() {}
+  ~QGpgMECryptoConfigGroup();
 
   QString name() const { return mName; }
   QString iconName() const { return QString(); }
@@ -122,7 +122,7 @@
 
 private:
   friend class QGpgMECryptoConfigComponent; // it adds the entries
-  Q3Dict<QGpgMECryptoConfigEntry> mEntries;
+  QHash<QString,QGpgMECryptoConfigEntry*> mEntries;
   QString mName;
   QString mDescription;
   Kleo::CryptoConfigEntry::Level mLevel;


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

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