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

List:       kde-commits
Subject:    tags/kdesupport-for-4.4/akonadi
From:       Marc Mutz <mutz () kde ! org>
Date:       2010-07-06 12:56:21
Message-ID: 20100706125621.77984AC85D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1146710 by mutz:

Revert commits 1146660 and 1146698, which should have gone to trunk instead. Sorry.

 M  +1 -6      libs/imapset.cpp  
 M  +0 -6      libs/imapset_p.h  
 M  +0 -3      server/src/akonadi.cpp  
 M  +1 -1      server/src/handler/fetchhelper.h  
 M  +0 -3      server/src/handlerhelper.cpp  
 M  +0 -3      server/src/storage/dbupdater.cpp  
 M  +0 -4      server/src/storage/entities.xsl  
 M  +1 -137    server/src/storage/entity.cpp  
 M  +116 -18   server/src/storage/entity.h  
 M  +0 -2      server/src/storage/parthelper.cpp  
 M  +0 -1      server/src/storage/querybuilder.cpp  


--- tags/kdesupport-for-4.4/akonadi/libs/imapset.cpp #1146709:1146710
@@ -173,12 +173,7 @@
 
 void ImapSet::add(const QList<Id> & values)
 {
-  add( values.toVector() );
-}
-
-void ImapSet::add(const QVector<Id> & values)
-{
-  QVector<Id> vals = values;
+  QList<Id> vals = values;
   qSort( vals );
   for( int i = 0; i < vals.count(); ++i ) {
     const int begin = vals[i];
--- tags/kdesupport-for-4.4/akonadi/libs/imapset_p.h #1146709:1146710
@@ -166,12 +166,6 @@
       No interval merging is performed.
       @param values List of positive integer numbers in arbitrary order
     */
-    void add( const QVector<Id> &values );
-
-    /**
-       @overload
-       @deprecated Use the QVector version instead.
-    */
     void add( const QList<Id> &values );
 
     /**
--- tags/kdesupport-for-4.4/akonadi/server/src/akonadi.cpp #1146709:1146710
@@ -38,9 +38,6 @@
 #include "libs/xdgbasedirs_p.h"
 #include "libs/protocol_p.h"
 
-#include <QtSql/QSqlQuery>
-#include <QtSql/QSqlError>
-
 #include <QtCore/QCoreApplication>
 #include <QtCore/QDir>
 #include <QtCore/QProcess>
--- tags/kdesupport-for-4.4/akonadi/server/src/handler/fetchhelper.h #1146709:1146710
@@ -22,7 +22,6 @@
 
 #include "scope.h"
 #include "libs/imapset_p.h"
-#include "storage/countquerybuilder.h"
 #include "storage/datastore.h"
 #include <QtCore/QStack>
 
@@ -30,6 +29,7 @@
 
 class AkonadiConnection;
 class ImapSet;
+class QueryBuilder;
 class Response;
 
 class FetchHelper : public QObject
--- tags/kdesupport-for-4.4/akonadi/server/src/handlerhelper.cpp #1146709:1146710
@@ -19,15 +19,12 @@
 
 #include "handlerhelper.h"
 #include "imapstreamparser.h"
-#include "storage/countquerybuilder.h"
 #include "storage/datastore.h"
 #include "storage/selectquerybuilder.h"
 #include "libs/imapparser_p.h"
 #include "libs/protocol_p.h"
 #include "handler.h"
 
-#include <QtSql/QSqlError>
-
 using namespace Akonadi;
 
 QByteArray Akonadi::HandlerHelper::normalizeCollectionName(const QByteArray &name)
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/dbupdater.cpp #1146709:1146710
@@ -21,9 +21,6 @@
 #include "entities.h"
 #include "akdebug.h"
 
-#include <QSqlQuery>
-#include <QSqlError>
-
 #include <QDomDocument>
 #include <QFile>
 
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/entities.xsl #1146709:1146710
@@ -45,10 +45,6 @@
 #include &lt;QtCore/QString&gt;
 #include &lt;QtCore/QVariant&gt;
 
-template &lt;typename T&gt; class QList;
-class QSqlQuery;
-class QStringList;
-
 namespace Akonadi {
 
 // forward declaration for table classes
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/entity.cpp #1146709:1146710
@@ -19,15 +19,12 @@
 
 #include "entity.h"
 #include "datastore.h"
-#include "countquerybuilder.h"
 
 #include <QtCore/QStringList>
 #include <QtCore/QVariant>
 #include <QtSql/QSqlQuery>
-#include <QtSql/QSqlDatabase>
-#include <QtSql/QSqlError>
 
-using namespace Akonadi;
+namespace Akonadi {
 
 Entity::Entity()
   : m_id( -1 )
@@ -59,137 +56,4 @@
   return DataStore::self()->database();
 }
 
-int Entity::countImpl( const QString & tableName, const QString & column, const \
                QVariant & value )
-{
-  QSqlDatabase db = database();
-  if ( !db.isOpen() )
-    return -1;
-
-  CountQueryBuilder builder;
-  builder.addTable( tableName );
-  builder.addValueCondition( column, Query::Equals, value );
-
-  if ( !builder.exec() ) {
-    qDebug() << "Error during counting records in table" << tableName
-             << builder.query().lastError().text();
-    return -1;
   }
-
-  return builder.result();
-}
-
-bool Entity::removeImpl( const QString & tableName, const QString & column, const \
                QVariant & value )
-{
-  QSqlDatabase db = database();
-  if ( !db.isOpen() )
-    return false;
-
-  QueryBuilder builder( QueryBuilder::Delete );
-  builder.addTable( tableName );
-  builder.addValueCondition( column, Query::Equals, value );
-
-  if ( !builder.exec() ) {
-    qDebug() << "Error during deleting records from table"
-             << tableName << builder.query().lastError().text();
-    return false;
-  }
-  return true;
-}
-
-bool Entity::relatesToImpl( const QString & tableName, const QString & leftColumn, \
                const QString & rightColumn, qint64 leftId, qint64 rightId )
-{
-  QSqlDatabase db = database();
-  if ( !db.isOpen() )
-    return false;
-
-  CountQueryBuilder builder;
-  builder.addTable( tableName );
-  builder.addValueCondition( leftColumn,  Query::Equals, leftId  );
-  builder.addValueCondition( rightColumn, Query::Equals, rightId );
-
-  if ( !builder.exec() ) {
-    qDebug() << "Error during counting records in table" << tableName
-             << builder.query().lastError().text();
-    return false;
-  }
-
-  if ( builder.result() > 0 )
-    return true;
-  return false;
-}
-
-bool Entity::addToRelationImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 leftId, qint64 \
                rightId )
-{
-  QSqlDatabase db = database();
-  if ( !db.isOpen() )
-    return false;
-
-  QString statement = QLatin1String("INSERT INTO ");
-  statement.append( tableName );
-  statement.append( QLatin1String(" ( ") );
-  statement.append( leftColumn );
-  statement.append( QLatin1String(" , ") );
-  statement.append( rightColumn );
-  statement.append( QLatin1String(" ) VALUES ( :left, :right )") );
-
-  QSqlQuery query( db );
-  query.prepare( statement );
-  query.bindValue( QLatin1String(":left"), leftId );
-  query.bindValue( QLatin1String(":right"), rightId );
-
-  if ( !query.exec() ) {
-    qDebug() << "Error during adding a record to table" << tableName
-             << query.lastError().text();
-    return false;
-  }
-
-  return true;
-}
-
-bool Entity::removeFromRelationImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 leftId, qint64 \
                rightId )
-{
-  QSqlDatabase db = database();
-  if ( !db.isOpen() )
-    return false;
-
-  QueryBuilder builder( QueryBuilder::Delete );
-  builder.addTable( tableName );
-  builder.addValueCondition( leftColumn,  Query::Equals, leftId  );
-  builder.addValueCondition( rightColumn, Query::Equals, rightId );
-
-  if ( !builder.exec() ) {
-    qDebug() << "Error during removing a record from relation table" << tableName
-             << builder.query().lastError().text();
-    return false;
-  }
-
-  return true;
-}
-
-bool Entity::clearRelationImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 id, RelationSide side \
                )
-{
-      QSqlDatabase db = database();
-      if ( !db.isOpen() )
-        return false;
-
-      QueryBuilder builder( QueryBuilder::Delete );
-      builder.addTable( tableName );
-      switch ( side ) {
-        case Left:
-          builder.addValueCondition( leftColumn,  Query::Equals, id );
-          break;
-        case Right:
-          builder.addValueCondition( rightColumn, Query::Equals, id );
-          break;
-        default:
-          qFatal("Invalid enum value");
-      }
-      if ( !builder.exec() ) {
-        qDebug() << "Error during clearing relation table" << tableName
-            << "for id" << id << builder.query().lastError().text();
-        return false;
-      }
-
-      return true;
-
-}
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/entity.h #1146709:1146710
@@ -20,6 +20,7 @@
 #ifndef ENTITY_H
 #define ENTITY_H
 
+#include "countquerybuilder.h"
 #include "../akonadiprivate_export.h"
 
 #include <QtCore/Qt>
@@ -27,10 +28,11 @@
 #include <QtCore/QDebug>
 #include <QtCore/QString>
 #include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtSql/QSqlDatabase>
+#include <QtSql/QSqlQuery>
+#include <QtSql/QSqlError>
 
-class QVariant;
-class QSqlDatabase;
-
 namespace Akonadi {
 
 /**
@@ -49,7 +51,7 @@
     template <typename T> static QString joinByName( const QList<T> &list, const \
QString &sep )  {
       QStringList tmp;
-      Q_FOREACH( const T & t, list )
+      foreach ( T t, list )
         tmp << t.name();
       return tmp.join( sep );
     }
@@ -61,16 +63,43 @@
     */
     template <typename T> inline static int count( const QString &column, const \
QVariant &value )  {
-        return Entity::countImpl( T::tableName(), column, value );
+      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return -1;
+
+      CountQueryBuilder builder;
+      builder.addTable( T::tableName() );
+      builder.addValueCondition( column, Query::Equals, value );
+
+      if ( !builder.exec() ) {
+        qDebug() << "Error during counting records in table" << T::tableName()
+            << builder.query().lastError().text();
+        return -1;
     }
 
+      return builder.result();
+    }
+
     /**
       Deletes all records having @p value in @p column.
     */
     template <typename T> inline static bool remove( const QString &column, const \
QVariant &value )  {
-        return Entity::removeImpl( T::tableName(), column, value );
+      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return false;
+
+      QueryBuilder builder( QueryBuilder::Delete );
+      builder.addTable( T::tableName() );
+      builder.addValueCondition( column, Query::Equals, value );
+
+      if ( !builder.exec() ) {
+        qDebug() << "Error during deleting records from table"
+            << T::tableName() << builder.query().lastError().text();
+        return false;
     }
+      return true;
+    }
 
     /**
       Checks whether an entry in a n:m relation table exists.
@@ -79,9 +108,26 @@
      */
     template <typename T> inline static bool relatesTo( qint64 leftId, qint64 \
rightId )  {
-        return Entity::relatesToImpl( T::tableName(), T::leftColumn(), \
T::rightColumn(), leftId, rightId ); +      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return false;
+
+      CountQueryBuilder builder;
+      builder.addTable( T::tableName() );
+      builder.addValueCondition( T::leftColumn(), Query::Equals, leftId );
+      builder.addValueCondition( T::rightColumn(), Query::Equals, rightId );
+
+      if ( !builder.exec() ) {
+        qDebug() << "Error during counting records in table" << T::tableName()
+            << builder.query().lastError().text();
+        return false;
     }
 
+      if ( builder.result() > 0 )
+        return true;
+      return false;
+    }
+
     /**
       Adds an entry to a n:m relation table (specified by the template parameter).
       @param leftId Identifier of the left part of the relation.
@@ -89,9 +135,32 @@
     */
     template <typename T> inline static bool addToRelation( qint64 leftId, qint64 \
rightId )  {
-        return Entity::addToRelationImpl( T::tableName(), T::leftColumn(), \
T::rightColumn(), leftId, rightId ); +      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return false;
+
+      QString statement = QLatin1String("INSERT INTO ");
+      statement.append( T::tableName() );
+      statement.append( QLatin1String(" ( ") );
+      statement.append( T::leftColumn() );
+      statement.append( QLatin1String(" , ") );
+      statement.append( T::rightColumn() );
+      statement.append( QLatin1String(" ) VALUES ( :left, :right )") );
+
+      QSqlQuery query( db );
+      query.prepare( statement );
+      query.bindValue( QLatin1String(":left"), leftId );
+      query.bindValue( QLatin1String(":right"), rightId );
+
+      if ( !query.exec() ) {
+        qDebug() << "Error during adding a record to table" << T::tableName()
+          << query.lastError().text();
+        return false;
     }
 
+      return true;
+    }
+
     /**
       Removes an entry from a n:m relation table (specified by the template \
parameter).  @param leftId Identifier of the left part of the relation.
@@ -99,9 +168,24 @@
     */
     template <typename T> inline static bool removeFromRelation( qint64 leftId, \
qint64 rightId )  {
-        return Entity::removeFromRelationImpl( T::tableName(), T::leftColumn(), \
T::rightColumn(), leftId, rightId ); +      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return false;
+
+      QueryBuilder builder( QueryBuilder::Delete );
+      builder.addTable( T::tableName() );
+      builder.addValueCondition( T::leftColumn(), Query::Equals, leftId );
+      builder.addValueCondition( T::rightColumn(), Query::Equals, rightId );
+
+      if ( !builder.exec() ) {
+        qDebug() << "Error during removing a record from relation table" << \
T::tableName() +          << builder.query().lastError().text();
+        return false;
     }
 
+      return true;
+    }
+
     enum RelationSide {
       Left,
       Right
@@ -114,22 +198,36 @@
     */
     template <typename T> inline static bool clearRelation( qint64 id, RelationSide \
side = Left )  {
-        return Entity::clearRelationImpl( T::tableName(), T::leftColumn(), \
T::rightColumn(), id, side ); +      QSqlDatabase db = database();
+      if ( !db.isOpen() )
+        return false;
+
+      QueryBuilder builder( QueryBuilder::Delete );
+      builder.addTable( T::tableName() );
+      switch ( side ) {
+        case Left:
+          builder.addValueCondition( T::leftColumn(), Query::Equals, id );
+          break;
+        case Right:
+          builder.addValueCondition( T::rightColumn(), Query::Equals, id );
+          break;
+        default:
+          qFatal("Invalid enum value");
     }
+      if ( !builder.exec() ) {
+        qDebug() << "Error during clearing relation table" << T::tableName()
+            << "for id" << id << builder.query().lastError().text();
+        return false;
+      }
 
+      return true;
+    }
+
   protected:
     Entity();
     Entity( qint64 id );
 
- private:
-    static int countImpl( const QString & tableName, const QString & column, const \
                QVariant & value );
-    static bool removeImpl( const QString & tableName, const QString & column, const \
                QVariant & value );
-    static bool relatesToImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 leftId, qint64 \
                rightId );
-    static bool addToRelationImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 leftId, qint64 \
                rightId );
-    static bool removeFromRelationImpl( const QString & tableName, const QString & \
                leftColumn, const QString & rightColumn, qint64 leftId, qint64 \
                rightId );
-    static bool clearRelationImpl( const QString & tableName, const QString & \
leftColumn, const QString & rightColumn, qint64 id, RelationSide side );  
-
   private:
     static QSqlDatabase database();
     qint64 m_id;
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/parthelper.cpp \
#1146709:1146710 @@ -27,8 +27,6 @@
 #include <QFile>
 #include <QDebug>
 
-#include <QSqlError>
-
 using namespace Akonadi;
 
 PartHelper::PartHelper()
--- tags/kdesupport-for-4.4/akonadi/server/src/storage/querybuilder.cpp \
#1146709:1146710 @@ -24,7 +24,6 @@
 #endif
 
 #include <QSqlRecord>
-#include <QSqlError>
 
 using namespace Akonadi;
 


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

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