summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index e79696c..2ee76cc 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -34,25 +34,25 @@
#include <stdio.h>
#include <stdlib.h>
#include <qarray.h>
#include <qstringlist.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
-#include <opie2/orecur.h>
+#include <opie2/opimrecurrence.h>
#include <opie2/odatebookaccessbackend_sql.h>
namespace Opie {
ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
const QString& fileName )
: ODateBookAccessBackend(), m_driver( NULL )
{
m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
// Get the standart sql-driver from the OSQLManager..
@@ -66,45 +66,45 @@ ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
}
ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
if( m_driver )
delete m_driver;
}
void ODateBookAccessBackend_SQL::initFields()
{
// This map contains the translation of the fieldtype id's to
// the names of the table columns
- m_fieldMap.insert( OEvent::FUid, "uid" );
- m_fieldMap.insert( OEvent::FCategories, "Categories" );
- m_fieldMap.insert( OEvent::FDescription, "Description" );
- m_fieldMap.insert( OEvent::FLocation, "Location" );
- m_fieldMap.insert( OEvent::FType, "Type" );
- m_fieldMap.insert( OEvent::FAlarm, "Alarm" );
- m_fieldMap.insert( OEvent::FSound, "Sound" );
- m_fieldMap.insert( OEvent::FRType, "RType" );
- m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" );
- m_fieldMap.insert( OEvent::FRPosition, "RPosition" );
- m_fieldMap.insert( OEvent::FRFreq, "RFreq" );
- m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" );
- m_fieldMap.insert( OEvent::FREndDate, "REndDate" );
- m_fieldMap.insert( OEvent::FRCreated, "RCreated" );
- m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" );
- m_fieldMap.insert( OEvent::FStart, "Start" );
- m_fieldMap.insert( OEvent::FEnd, "End" );
- m_fieldMap.insert( OEvent::FNote, "Note" );
- m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" );
- m_fieldMap.insert( OEvent::FRecParent, "RecParent" );
- m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" );
+ m_fieldMap.insert( OPimEvent::FUid, "uid" );
+ m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
+ m_fieldMap.insert( OPimEvent::FDescription, "Description" );
+ m_fieldMap.insert( OPimEvent::FLocation, "Location" );
+ m_fieldMap.insert( OPimEvent::FType, "Type" );
+ m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
+ m_fieldMap.insert( OPimEvent::FSound, "Sound" );
+ m_fieldMap.insert( OPimEvent::FRType, "RType" );
+ m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
+ m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
+ m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
+ m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
+ m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
+ m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
+ m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
+ m_fieldMap.insert( OPimEvent::FStart, "Start" );
+ m_fieldMap.insert( OPimEvent::FEnd, "End" );
+ m_fieldMap.insert( OPimEvent::FNote, "Note" );
+ m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
+ m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
+ m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
// Create a map that maps the column name to the id
QMapConstIterator<int, QString> it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
m_reverseFieldMap.insert( it.data(), it.key() );
}
}
bool ODateBookAccessBackend_SQL::load()
{
if (!m_driver->open() )
@@ -156,67 +156,67 @@ bool ODateBookAccessBackend_SQL::reload()
}
bool ODateBookAccessBackend_SQL::save()
{
return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
}
QArray<int> ODateBookAccessBackend_SQL::allRecords()const
{
return m_uids;
}
-QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) {
+QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) {
return QArray<int>();
}
void ODateBookAccessBackend_SQL::clear()
{
QString qu = "drop table datebook;";
qu += "drop table custom_data;";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
reload();
}
-OEvent ODateBookAccessBackend_SQL::find( int uid ) const{
+OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
QString qu = "select *";
qu += "from datebook where uid = " + QString::number(uid);
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
OSQLResultItem resItem = res.first();
// Create Map for date event and insert UID
QMap<int,QString> dateEventMap;
- dateEventMap.insert( OEvent::FUid, QString::number( uid ) );
+ dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
// Now insert the data out of the columns into the map.
QMapConstIterator<int, QString> it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
}
// Last step: Put map into date event and return it
- OEvent retDate( dateEventMap );
+ OPimEvent retDate( dateEventMap );
return retDate;
}
// FIXME: Speed up update of uid's..
-bool ODateBookAccessBackend_SQL::add( const OEvent& ev )
+bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
{
QMap<int,QString> eventMap = ev.toMap();
QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
QMap<int, QString>::Iterator it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
if ( !eventMap[it.key()].isEmpty() )
qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] );
else
qu += QString( ",\"\"" );
}
qu += " );";
@@ -263,25 +263,25 @@ bool ODateBookAccessBackend_SQL::remove( int uid )
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
return false;
}
// Update list of uid's
update();
return true;
}
-bool ODateBookAccessBackend_SQL::replace( const OEvent& ev )
+bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
{
remove( ev.uid() );
return add( ev );
}
QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
{
return allRecords();
}
QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
{
@@ -300,40 +300,40 @@ QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
{
QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\"";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
QArray<int> nix;
return nix;
}
return extractUids( res );
}
-OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
{
QArray<int> nonRepUids = nonRepeats();
- OEvent::ValueList list;
+ OPimEvent::ValueList list;
for (uint i = 0; i < nonRepUids.count(); ++i ){
list.append( find( nonRepUids[i] ) );
}
return list;
}
-OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
{
QArray<int> rawRepUids = rawRepeats();
- OEvent::ValueList list;
+ OPimEvent::ValueList list;
for (uint i = 0; i < rawRepUids.count(); ++i ){
list.append( find( rawRepUids[i] ) );
}
return list;
}
QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
{
QArray<int> null;