summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index d0c8052..f121cc2 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -40,6 +40,6 @@
#include <qpe/recordfields.h>
-#include <opie2/ocontactfields.h>
-#include <opie2/oconversion.h>
+#include <opie2/opimcontactfields.h>
+#include <opie2/opimdateconversion.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
@@ -106,13 +106,13 @@ namespace Opie {
/**
- * inserts/adds a OContact to the table
+ * inserts/adds a OPimContact to the table
*/
class InsertQuery : public OSQLQuery {
public:
- InsertQuery(const OContact& );
+ InsertQuery(const OPimContact& );
~InsertQuery();
QString query()const;
private:
- OContact m_contact;
+ OPimContact m_contact;
};
@@ -177,5 +177,5 @@ namespace Opie {
qu += "create table addressbook( uid PRIMARY KEY ";
- QStringList fieldList = OContactFields::untrfields( false );
+ QStringList fieldList = OPimContactFields::untrfields( false );
for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it );
@@ -224,5 +224,5 @@ namespace Opie {
- InsertQuery::InsertQuery( const OContact& contact )
+ InsertQuery::InsertQuery( const OPimContact& contact )
: OSQLQuery(), m_contact( contact ) {
}
@@ -232,5 +232,5 @@ namespace Opie {
/*
- * converts from a OContact to a query
+ * converts from a OPimContact to a query
*/
QString InsertQuery::query()const{
@@ -245,6 +245,6 @@ namespace Opie {
QMap<int, QString> contactMap = m_contact.toMap();
- QStringList fieldList = OContactFields::untrfields( false );
- QMap<QString, int> translate = OContactFields::untrFieldsToId();
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
// Convert Column-String to Id and get value for this id..
@@ -296,5 +296,5 @@ namespace Opie {
// Get the translation from the ID to the String
- QMap<int, QString> transMap = OContactFields::idToUntrFields();
+ QMap<int, QString> transMap = OPimContactFields::idToUntrFields();
for( QMap<int, QString>::Iterator it = contactMap.begin();
@@ -460,9 +460,9 @@ namespace Opie {
namespace Opie {
-OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */,
+OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */,
const QString& filename ):
- OContactAccessBackend(), m_changed(false), m_driver( NULL )
+ OPimContactAccessBackend(), m_changed(false), m_driver( NULL )
{
- qWarning("C'tor OContactAccessBackend_SQL starts");
+ qWarning("C'tor OPimContactAccessBackend_SQL starts");
QTime t;
t.start();
@@ -481,8 +481,8 @@ OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname
load();
- qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() );
+ qWarning("C'tor OPimContactAccessBackend_SQL ends: %d ms", t.elapsed() );
}
-OContactAccessBackend_SQL::~OContactAccessBackend_SQL ()
+OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL ()
{
if( m_driver )
@@ -490,5 +490,5 @@ OContactAccessBackend_SQL::~OContactAccessBackend_SQL ()
}
-bool OContactAccessBackend_SQL::load ()
+bool OPimContactAccessBackend_SQL::load ()
{
if (!m_driver->open() )
@@ -507,10 +507,10 @@ bool OContactAccessBackend_SQL::load ()
}
-bool OContactAccessBackend_SQL::reload()
+bool OPimContactAccessBackend_SQL::reload()
{
return load();
}
-bool OContactAccessBackend_SQL::save()
+bool OPimContactAccessBackend_SQL::save()
{
return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
@@ -518,5 +518,5 @@ bool OContactAccessBackend_SQL::save()
-void OContactAccessBackend_SQL::clear ()
+void OPimContactAccessBackend_SQL::clear ()
{
ClearQuery cle;
@@ -526,10 +526,10 @@ void OContactAccessBackend_SQL::clear ()
}
-bool OContactAccessBackend_SQL::wasChangedExternally()
+bool OPimContactAccessBackend_SQL::wasChangedExternally()
{
return false;
}
-QArray<int> OContactAccessBackend_SQL::allRecords() const
+QArray<int> OPimContactAccessBackend_SQL::allRecords() const
{
@@ -537,10 +537,10 @@ QArray<int> OContactAccessBackend_SQL::allRecords() const
// Thus, we don't have to call update here...
if ( m_changed )
- ((OContactAccessBackend_SQL*)this)->update();
+ ((OPimContactAccessBackend_SQL*)this)->update();
return m_uids;
}
-bool OContactAccessBackend_SQL::add ( const OContact &newcontact )
+bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
{
InsertQuery ins( newcontact );
@@ -558,5 +558,5 @@ bool OContactAccessBackend_SQL::add ( const OContact &newcontact )
-bool OContactAccessBackend_SQL::remove ( int uid )
+bool OPimContactAccessBackend_SQL::remove ( int uid )
{
RemoveQuery rem( uid );
@@ -571,5 +571,5 @@ bool OContactAccessBackend_SQL::remove ( int uid )
}
-bool OContactAccessBackend_SQL::replace ( const OContact &contact )
+bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact )
{
if ( !remove( contact.uid() ) )
@@ -580,14 +580,14 @@ bool OContactAccessBackend_SQL::replace ( const OContact &contact )
-OContact OContactAccessBackend_SQL::find ( int uid ) const
+OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const
{
- qWarning("OContactAccessBackend_SQL::find()");
+ qWarning("OPimContactAccessBackend_SQL::find()");
QTime t;
t.start();
- OContact retContact( requestNonCustom( uid ) );
+ OPimContact retContact( requestNonCustom( uid ) );
retContact.setExtraMap( requestCustom( uid ) );
- qWarning("OContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() );
+ qWarning("OPimContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() );
return retContact;
}
@@ -595,11 +595,11 @@ OContact OContactAccessBackend_SQL::find ( int uid ) const
-QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() )
+QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() )
{
QString qu = "SELECT uid FROM addressbook WHERE";
QMap<int, QString> queryFields = query.toMap();
- QStringList fieldList = OContactFields::untrfields( false );
- QMap<QString, int> translate = OContactFields::untrFieldsToId();
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
// Convert every filled field to a SQL-Query
@@ -615,5 +615,5 @@ QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, i
// LIKE is not case sensitive, GLOB is case sensitive
// Do exist a better solution to switch this ?
- if ( settings & OContactAccess::IgnoreCase )
+ if ( settings & OPimContactAccess::IgnoreCase )
qu += "(\"" + *it + "\"" + " LIKE " + "'"
+ queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND ";
@@ -644,5 +644,5 @@ QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, i
}
-QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
+QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
{
QArray<int> nix(0);
@@ -650,13 +650,13 @@ QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
}
-const uint OContactAccessBackend_SQL::querySettings()
+const uint OPimContactAccessBackend_SQL::querySettings()
{
- return OContactAccess::IgnoreCase
- || OContactAccess::WildCards;
+ return OPimContactAccess::IgnoreCase
+ || OPimContactAccess::WildCards;
}
-bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
+bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
{
- /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
+ /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
* may be added with any of the other settings. IgnoreCase should never used alone.
* Wildcards, RegExp, ExactMatch should never used at the same time...
@@ -665,12 +665,12 @@ bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
// Step 1: Check whether the given settings are supported by this backend
if ( ( querySettings & (
- OContactAccess::IgnoreCase
- | OContactAccess::WildCards
-// | OContactAccess::DateDiff
-// | OContactAccess::DateYear
-// | OContactAccess::DateMonth
-// | OContactAccess::DateDay
-// | OContactAccess::RegExp
-// | OContactAccess::ExactMatch
+ OPimContactAccess::IgnoreCase
+ | OPimContactAccess::WildCards
+// | OPimContactAccess::DateDiff
+// | OPimContactAccess::DateYear
+// | OPimContactAccess::DateMonth
+// | OPimContactAccess::DateDay
+// | OPimContactAccess::RegExp
+// | OPimContactAccess::ExactMatch
) ) != querySettings )
return false;
@@ -679,20 +679,20 @@ bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
// IngoreCase alone is invalid
- if ( querySettings == OContactAccess::IgnoreCase )
+ if ( querySettings == OPimContactAccess::IgnoreCase )
return false;
// WildCards, RegExp and ExactMatch should never used at the same time
- switch ( querySettings & ~( OContactAccess::IgnoreCase
- | OContactAccess::DateDiff
- | OContactAccess::DateYear
- | OContactAccess::DateMonth
- | OContactAccess::DateDay
+ switch ( querySettings & ~( OPimContactAccess::IgnoreCase
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
)
){
- case OContactAccess::RegExp:
+ case OPimContactAccess::RegExp:
return ( true );
- case OContactAccess::WildCards:
+ case OPimContactAccess::WildCards:
return ( true );
- case OContactAccess::ExactMatch:
+ case OPimContactAccess::ExactMatch:
return ( true );
case 0: // one of the upper removed bits were set..
@@ -704,5 +704,5 @@ bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
}
-QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int )
+QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int )
{
QTime t;
@@ -736,5 +736,5 @@ QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int )
-void OContactAccessBackend_SQL::update()
+void OPimContactAccessBackend_SQL::update()
{
qWarning("Update starts");
@@ -757,5 +757,5 @@ void OContactAccessBackend_SQL::update()
}
-QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
+QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
qWarning("extractUids");
@@ -779,5 +779,5 @@ QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
#ifdef __STORE_HORIZONTAL_
-QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
+QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
{
QTime t;
@@ -799,6 +799,6 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
t3.start();
// Now loop through all columns
- QStringList fieldList = OContactFields::untrfields( false );
- QMap<QString, int> translate = OContactFields::untrFieldsToId();
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
// Get data for the selected column and store it with the
@@ -821,5 +821,5 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
QDate date( year, month, day );
- nonCustomMap.insert( id, OConversion::dateToString( date ) );
+ nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) );
}
}
@@ -844,5 +844,5 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
#else
-QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
+QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
{
QTime t;
@@ -867,5 +867,5 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
QTime t3;
t3.start();
- QMap<QString, int> translateMap = OContactFields::untrFieldsToId();
+ QMap<QString, int> translateMap = OPimContactFields::untrFieldsToId();
OSQLResultItem::ValueList list = res_noncustom.results();
@@ -888,5 +888,5 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day );
QDate date( year, month, day );
- nonCustomMap.insert( typeId, OConversion::dateToString( date ) );
+ nonCustomMap.insert( typeId, OPimDateConversion::dateToString( date ) );
}
break;
@@ -907,5 +907,5 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
#endif // __STORE_HORIZONTAL_
-QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) const
+QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const
{
QTime t;