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) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 105c106..41b714e 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -158,26 +158,24 @@ bool ODateBookAccessBackend_SQL::load()
// It is save here to create the table, even if it
// do exist. ( Is that correct for all databases ?? )
QString qu = "create table datebook( uid INTEGER PRIMARY KEY ";
QMap<int, QString>::Iterator it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
}
qu += " );";
qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
- owarn << "command: " << qu << "" << oendl;
-
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success )
return false;
update();
return true;
}
void ODateBookAccessBackend_SQL::update()
{
@@ -279,25 +277,24 @@ bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
qu += "insert into custom_data VALUES("
+ QString::number( ev.uid() )
+ ","
+ QString::number( id++ )
+ ",'"
+ it.key() //.latin1()
+ "',"
+ "0" // Priority for future enhancements
+ ",'"
+ it.data() //.latin1()
+ "');";
}
- owarn << "add " << qu << "" << oendl;
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
return false;
}
// Update list of uid's
update();
return true;
}
@@ -319,28 +316,24 @@ bool ODateBookAccessBackend_SQL::remove( int uid )
// Update list of uid's
update();
return true;
}
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
{
QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
QArray<int> nix;
return nix;
}
return extractUids( res );
@@ -350,37 +343,37 @@ 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 );
}
-OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()const
{
QArray<int> nonRepUids = nonRepeats();
OPimEvent::ValueList list;
for (uint i = 0; i < nonRepUids.count(); ++i ){
list.append( find( nonRepUids[i] ) );
}
return list;
}
-OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()const
{
QArray<int> rawRepUids = rawRepeats();
OPimEvent::ValueList list;
for (uint i = 0; i < rawRepUids.count(); ++i ){
list.append( find( rawRepUids[i] ) );
}
return list;
}
@@ -401,55 +394,51 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
OSQLResult res = m_driver->query( &raw );
return extractUids( res );
}
/* ===== Private Functions ========================================== */
QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
- owarn << "extractUids" << oendl;
QTime t;
t.start();
OSQLResultItem::ValueList list = res.results();
OSQLResultItem::ValueList::Iterator it;
QArray<int> ints(list.count() );
- owarn << " count = " << list.count() << "" << oendl;
int i = 0;
for (it = list.begin(); it != list.end(); ++it ) {
ints[i] = (*it).data("uid").toInt();
i++;
}
- owarn << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
return ints;
}
QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) const
{
QTime t;
t.start();
QMap<QString, QString> customMap;
FindCustomQuery query( uid );
OSQLResult res_custom = m_driver->query( &query );
if ( res_custom.state() == OSQLResult::Failure ) {
- owarn << "OSQLResult::Failure in find query !!" << oendl;
QMap<QString, QString> empty;
return empty;
}
OSQLResultItem::ValueList list = res_custom.results();
OSQLResultItem::ValueList::Iterator it = list.begin();
for ( ; it != list.end(); ++it ) {
customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
}
odebug << "RequestCustom needed: " << t.elapsed() << " ms" << oendl;
return customMap;