summaryrefslogtreecommitdiff
path: root/libopie2
authoreilers <eilers>2003-10-20 15:58:00 (UTC)
committer eilers <eilers>2003-10-20 15:58:00 (UTC)
commitfccc5d110dea3bc32176694c8e5fc7f014706be6 (patch) (side-by-side diff)
tree6dd44a78cadfd55fc8935dc661318e3ab12dd7b7 /libopie2
parent758775c190470e569a0616bbd87d1a378c19b747 (diff)
downloadopie-fccc5d110dea3bc32176694c8e5fc7f014706be6.zip
opie-fccc5d110dea3bc32176694c8e5fc7f014706be6.tar.gz
opie-fccc5d110dea3bc32176694c8e5fc7f014706be6.tar.bz2
Pushing todo closer to sql support. Recurrances and custom entries still missing.
But before I add this, I have to do some cleanup..
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp52
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp2
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp72
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h24
-rw-r--r--libopie2/opiepim/ocontactfields.cpp233
-rw-r--r--libopie2/opiepim/ocontactfields.h7
7 files changed, 260 insertions, 132 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index d255c66..ebd03bb 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -9,6 +9,9 @@
#include <opie2/osqlquery.h>
#include "otodoaccesssql.h"
+#include "opimstate.h"
+#include "opimnotifymanager.h"
+#include "orecur.h"
/*
* first some query
@@ -120,7 +123,8 @@ namespace {
QString qu;
qu += "create table todolist( uid PRIMARY KEY, categories, completed, ";
qu += "description, summary, priority, DueDate, progress , state, ";
- qu += "Recurrence, notifiers, maintainer, startdate, completeddate)";
+ qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);";
+ qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
return qu;
}
@@ -181,14 +185,23 @@ namespace {
+ QString::number(month)
+ "-" + QString::number( day ) + "'" + ","
+ QString::number( m_todo.progress() ) + ","
- + "''" + "," // state (conversion needed)
-// + QString::number( m_todo.state() ) + ","
- + "''" + "," // Recurrence (conversion needed)
- + "''" + "," // Notifiers (conversion needed)
- + "''" + "," // Maintainers (conversion needed)
+ + QString::number( m_todo.state().state() ) + ","
+ + "'" + m_todo.recurrence().toString() + "'"+ ",";
+
+ if ( m_todo.hasNotifiers() ) {
+ OPimNotifyManager manager = m_todo.notifiers();
+ qu += "'" + manager.remindersToString() + "'" + ","
+ + "'" + manager.alarmsToString() + "'" + ",";
+ }
+ else{
+ qu += QString( "''" ) + ","
+ + "''" + ",";
+ }
+
+ qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
+ "'" + QString::number(sYear) + "-"
- + QString::number(sMonth)
- + "-" + QString::number(sDay) + "'" + ","
+ + QString::number(sMonth)
+ + "-" + QString::number(sDay) + "'" + ","
+ "'" + QString::number(eYear) + "-"
+ QString::number(eMonth)
+ "-"+QString::number(eDay) + "'"
@@ -530,6 +543,17 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
to.setStartDate( startDate );
if ( hasCompletedDate )
to.setCompletedDate( completedDate );
+
+ OPimNotifyManager& manager = to.notifiers();
+ manager.alarmsFromString( item.data("alarms") );
+ manager.remindersFromString( item.data("reminders") );
+
+ OPimState pimState;
+ pimState.setState( QString( item.data("state") ).toInt() );
+ to.setState( pimState );
+
+ // Recurrence not supported yet
+ // to.setRecurrence(
return to;
}
@@ -621,18 +645,10 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
}
QBitArray OTodoAccessBackendSQL::supports()const {
- QBitArray ar( OTodo::CompletedDate + 1 );
- ar.fill( true );
- ar[OTodo::CrossReference] = false;
- ar[OTodo::State ] = false;
- ar[OTodo::Reminders] = false;
- ar[OTodo::Notifiers] = false;
- ar[OTodo::Maintainer] = false;
-
- return ar;
+ return sup();
}
-QBitArray OTodoAccessBackendSQL::sup() {
+QBitArray OTodoAccessBackendSQL::sup() const{
QBitArray ar( OTodo::CompletedDate + 1 );
ar.fill( true );
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 77d8b77..1c55567 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -44,7 +44,7 @@ private:
inline OTodo todo( OSQLResultItem& )const;
inline QArray<int> uids( const OSQLResult& )const;
OTodo todo( int uid )const;
- QBitArray sup();
+ QBitArray sup() const;
QAsciiDict<int> m_dict;
OSQLDriver* m_driver;
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index f688735..4a5cb33 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -568,7 +568,7 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
/*
* save reminders and notifiers!
- * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:....
+ * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:....
*/
if ( ev.hasNotifiers() ) {
OPimNotifyManager manager = ev.notifiers();
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index 06b5987..53ad4c3 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -1,5 +1,9 @@
#include "opimnotifymanager.h"
+#include "oconversion.h"
+
+#include <qstringlist.h>
+
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
@@ -67,8 +71,76 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) {
void OPimNotifyManager::deregister( const OPimNotify& ) {
}
+
bool OPimNotifyManager::isEmpty()const {
qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
else return false;
}
+
+// Taken from otodoaccessxml..
+QString OPimNotifyManager::alarmsToString() const
+{
+ QString str;
+
+ OPimNotifyManager::Alarms alarms = m_al;
+ if ( !alarms.isEmpty() ) {
+ QStringList als;
+ OPimNotifyManager::Alarms::Iterator it = alarms.begin();
+ for ( ; it != alarms.end(); ++it ) {
+ /* only if time is valid */
+ if ( (*it).dateTime().isValid() ) {
+ als << OConversion::dateTimeToString( (*it).dateTime() )
+ + ":" + QString::number( (*it).duration() )
+ + ":" + QString::number( (*it).sound() )
+ + ":";
+ }
+ }
+ // now write the list
+ qWarning("als: %s", als.join("____________").latin1() );
+ str = als.join(";");
+ }
+
+ return str;
+}
+QString OPimNotifyManager::remindersToString() const
+{
+ QString str;
+
+ OPimNotifyManager::Reminders reminders = m_rem;
+ if (!reminders.isEmpty() ) {
+ OPimNotifyManager::Reminders::Iterator it = reminders.begin();
+ QStringList records;
+ for ( ; it != reminders.end(); ++it ) {
+ records << QString::number( (*it).recordUid() );
+ }
+ str = records.join(";");
+ }
+
+ return str;
+}
+
+void OPimNotifyManager::alarmsFromString( const QString& str )
+{
+ QStringList als = QStringList::split(";", str );
+ for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
+ QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
+ qWarning("alarm: %s", alarm.join("___").latin1() );
+ qWarning("alarm[0]: %s %s", alarm[0].latin1(),
+ OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
+ OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ),
+ alarm[1].toInt() );
+ add( al );
+ }
+}
+
+void OPimNotifyManager::remindersFromString( const QString& str )
+{
+
+ QStringList rems = QStringList::split(";", str );
+ for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
+ OPimReminder rem( (*it).toInt() );
+ add( rem );
+ }
+
+}
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h
index 0ac30a1..48410e7 100644
--- a/libopie2/opiepim/core/opimnotifymanager.h
+++ b/libopie2/opiepim/core/opimnotifymanager.h
@@ -39,9 +39,31 @@ public:
*/
void deregister( const OPimNotify& );
-
bool isEmpty()const;
+ /**
+ * Return all alarms as string
+ */
+ QString alarmsToString() const;
+ /**
+ * Return all notifiers as string
+ */
+ QString remindersToString() const;
+
+ /**
+ * Convert string to alarms
+ * @param str String created by alarmsToString()
+ */
+ void alarmsFromString( const QString& str );
+
+ /**
+ * Convert string to reminders
+ * @param str String created by remindersToString()
+ */
+ void remindersFromString( const QString& str );
+
+
+
private:
Reminders m_rem;
Alarms m_al;
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp
index 7206f0d..0f08a5a 100644
--- a/libopie2/opiepim/ocontactfields.cpp
+++ b/libopie2/opiepim/ocontactfields.cpp
@@ -11,24 +11,33 @@
/*!
\internal
- Returns a list of details field names for a contact.
+ Returns a list of personal field names for a contact.
*/
-QStringList OContactFields::untrdetailsfields( bool sorted )
+QStringList OContactFields::personalfields( bool sorted, bool translated )
{
QStringList list;
- QMap<int, QString> mapIdToStr = idToUntrFields();
+ QMap<int, QString> mapIdToStr;
+ if ( translated )
+ mapIdToStr = idToTrFields();
+ else
+ mapIdToStr = idToUntrFields();
- list.append( mapIdToStr[ Qtopia::Office ] );
- list.append( mapIdToStr[ Qtopia::Profession ] );
- list.append( mapIdToStr[ Qtopia::Assistant ] );
- list.append( mapIdToStr[ Qtopia::Manager ] );
+ list.append( mapIdToStr[ Qtopia::AddressUid ] );
+ list.append( mapIdToStr[ Qtopia::AddressCategory ] );
- list.append( mapIdToStr[ Qtopia::Spouse ] );
- list.append( mapIdToStr[ Qtopia::Gender ] );
- list.append( mapIdToStr[ Qtopia::Birthday ] );
- list.append( mapIdToStr[ Qtopia::Anniversary ] );
- list.append( mapIdToStr[ Qtopia::Nickname ] );
- list.append( mapIdToStr[ Qtopia::Children ] );
+ list.append( mapIdToStr[ Qtopia::Title ] );
+ list.append( mapIdToStr[ Qtopia::FirstName ] );
+ list.append( mapIdToStr[ Qtopia::MiddleName ] );
+ list.append( mapIdToStr[ Qtopia::LastName ] );
+ list.append( mapIdToStr[ Qtopia::Suffix ] );
+ list.append( mapIdToStr[ Qtopia::FileAs ] );
+
+ list.append( mapIdToStr[ Qtopia::JobTitle ] );
+ list.append( mapIdToStr[ Qtopia::Department ] );
+ list.append( mapIdToStr[ Qtopia::Company ] );
+
+ list.append( mapIdToStr[ Qtopia::Notes ] );
+ list.append( mapIdToStr[ Qtopia::Groups ] );
if (sorted) list.sort();
return list;
@@ -36,38 +45,45 @@ QStringList OContactFields::untrdetailsfields( bool sorted )
/*!
\internal
- Returns a translated list of details field names for a contact.
+ Returns a list of details field names for a contact.
*/
-QStringList OContactFields::trdetailsfields( bool sorted )
+QStringList OContactFields::detailsfields( bool sorted, bool translated )
{
QStringList list;
- QMap<int, QString> mapIdToStr = idToTrFields();
+ QMap<int, QString> mapIdToStr;
+ if ( translated )
+ mapIdToStr = idToTrFields();
+ else
+ mapIdToStr = idToUntrFields();
- list.append( mapIdToStr[Qtopia::Office] );
- list.append( mapIdToStr[Qtopia::Profession] );
- list.append( mapIdToStr[Qtopia::Assistant] );
- list.append( mapIdToStr[Qtopia::Manager] );
+ list.append( mapIdToStr[ Qtopia::Office ] );
+ list.append( mapIdToStr[ Qtopia::Profession ] );
+ list.append( mapIdToStr[ Qtopia::Assistant ] );
+ list.append( mapIdToStr[ Qtopia::Manager ] );
- list.append( mapIdToStr[Qtopia::Spouse] );
- list.append( mapIdToStr[Qtopia::Gender] );
- list.append( mapIdToStr[Qtopia::Birthday] );
- list.append( mapIdToStr[Qtopia::Anniversary] );
- list.append( mapIdToStr[Qtopia::Nickname] );
- list.append( mapIdToStr[Qtopia::Children] );
+ list.append( mapIdToStr[ Qtopia::Spouse ] );
+ list.append( mapIdToStr[ Qtopia::Gender ] );
+ list.append( mapIdToStr[ Qtopia::Birthday ] );
+ list.append( mapIdToStr[ Qtopia::Anniversary ] );
+ list.append( mapIdToStr[ Qtopia::Nickname ] );
+ list.append( mapIdToStr[ Qtopia::Children ] );
if (sorted) list.sort();
return list;
}
-
/*!
\internal
- Returns a translated list of phone field names for a contact.
+ Returns a list of phone field names for a contact.
*/
-QStringList OContactFields::trphonefields( bool sorted )
+QStringList OContactFields::phonefields( bool sorted, bool translated )
{
QStringList list;
- QMap<int, QString> mapIdToStr = idToTrFields();
+ QMap<int, QString> mapIdToStr;
+ if ( translated )
+ mapIdToStr = idToTrFields();
+ else
+ mapIdToStr = idToUntrFields();
list.append( mapIdToStr[Qtopia::BusinessPhone] );
list.append( mapIdToStr[Qtopia::BusinessFax] );
@@ -89,58 +105,22 @@ QStringList OContactFields::trphonefields( bool sorted )
return list;
}
-
/*!
\internal
- Returns a list of phone field names for a contact.
+ Returns a list of field names for a contact.
*/
-QStringList OContactFields::untrphonefields( bool sorted )
+QStringList OContactFields::fields( bool sorted, bool translated )
{
QStringList list;
- QMap<int, QString> mapIdToStr = idToUntrFields();
-
- list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
- list.append( mapIdToStr[ Qtopia::BusinessFax ] );
- list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
- list.append( mapIdToStr[ Qtopia::BusinessPager ] );
- list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
-
- list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
- list.append( mapIdToStr[ Qtopia::Emails ] );
+ QMap<int, QString> mapIdToStr;
+ if ( translated )
+ mapIdToStr = idToTrFields();
+ else
+ mapIdToStr = idToUntrFields();
- list.append( mapIdToStr[ Qtopia::HomePhone ] );
- list.append( mapIdToStr[ Qtopia::HomeFax ] );
- list.append( mapIdToStr[ Qtopia::HomeMobile ] );
- //list.append( mapIdToStr[Qtopia::HomePager] );
- list.append( mapIdToStr[Qtopia::HomeWebPage] );
+ list += personalfields( sorted, translated );
- if (sorted) list.sort();
-
- return list;
-}
-
-
-/*!
- \internal
- Returns a translated list of field names for a contact.
-*/
-QStringList OContactFields::trfields( bool sorted )
-{
- QStringList list;
- QMap<int, QString> mapIdToStr = idToTrFields();
-
- list.append( mapIdToStr[Qtopia::Title]);
- list.append( mapIdToStr[Qtopia::FirstName] );
- list.append( mapIdToStr[Qtopia::MiddleName] );
- list.append( mapIdToStr[Qtopia::LastName] );
- list.append( mapIdToStr[Qtopia::Suffix] );
- list.append( mapIdToStr[Qtopia::FileAs] );
-
- list.append( mapIdToStr[Qtopia::JobTitle] );
- list.append( mapIdToStr[Qtopia::Department] );
- list.append( mapIdToStr[Qtopia::Company] );
-
- list += trphonefields( sorted );
+ list += phonefields( sorted, translated );
list.append( mapIdToStr[Qtopia::BusinessStreet] );
list.append( mapIdToStr[Qtopia::BusinessCity] );
@@ -154,62 +134,91 @@ QStringList OContactFields::trfields( bool sorted )
list.append( mapIdToStr[Qtopia::HomeZip] );
list.append( mapIdToStr[Qtopia::HomeCountry] );
- list += trdetailsfields( sorted );
-
- list.append( mapIdToStr[Qtopia::Notes] );
- list.append( mapIdToStr[Qtopia::Groups] );
+ list += detailsfields( sorted, translated );
if (sorted) list.sort();
return list;
}
+
/*!
\internal
- Returns an untranslated list of field names for a contact.
+ Returns an untranslated list of personal field names for a contact.
*/
-QStringList OContactFields::untrfields( bool sorted )
+QStringList OContactFields::untrpersonalfields( bool sorted )
{
- QStringList list;
- QMap<int, QString> mapIdToStr = idToUntrFields();
+ return personalfields( sorted, false );
+}
- list.append( mapIdToStr[ Qtopia::AddressUid ] );
- list.append( mapIdToStr[ Qtopia::AddressCategory ] );
- list.append( mapIdToStr[ Qtopia::Title ] );
- list.append( mapIdToStr[ Qtopia::FirstName ] );
- list.append( mapIdToStr[ Qtopia::MiddleName ] );
- list.append( mapIdToStr[ Qtopia::LastName ] );
- list.append( mapIdToStr[ Qtopia::Suffix ] );
- list.append( mapIdToStr[ Qtopia::FileAs ] );
+/*!
+ \internal
+ Returns a translated list of personal field names for a contact.
+*/
+QStringList OContactFields::trpersonalfields( bool sorted )
+{
+ return personalfields( sorted, true );
+}
- list.append( mapIdToStr[ Qtopia::JobTitle ] );
- list.append( mapIdToStr[ Qtopia::Department ] );
- list.append( mapIdToStr[ Qtopia::Company ] );
- list += untrphonefields( sorted );
+/*!
+ \internal
+ Returns an untranslated list of details field names for a contact.
+*/
+QStringList OContactFields::untrdetailsfields( bool sorted )
+{
+ return detailsfields( sorted, false );
+}
- list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
- list.append( mapIdToStr[ Qtopia::BusinessCity ] );
- list.append( mapIdToStr[ Qtopia::BusinessState ] );
- list.append( mapIdToStr[ Qtopia::BusinessZip ] );
- list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
- list.append( mapIdToStr[ Qtopia::HomeStreet ] );
- list.append( mapIdToStr[ Qtopia::HomeCity ] );
- list.append( mapIdToStr[ Qtopia::HomeState ] );
- list.append( mapIdToStr[ Qtopia::HomeZip ] );
- list.append( mapIdToStr[ Qtopia::HomeCountry ] );
+/*!
+ \internal
+ Returns a translated list of details field names for a contact.
+*/
+QStringList OContactFields::trdetailsfields( bool sorted )
+{
+ return detailsfields( sorted, true );
+}
- list += untrdetailsfields( sorted );
- list.append( mapIdToStr[ Qtopia::Notes ] );
- list.append( mapIdToStr[ Qtopia::Groups ] );
+/*!
+ \internal
+ Returns a translated list of phone field names for a contact.
+*/
+QStringList OContactFields::trphonefields( bool sorted )
+{
+ return phonefields( sorted, true );
+}
- if (sorted) list.sort();
+/*!
+ \internal
+ Returns an untranslated list of phone field names for a contact.
+*/
+QStringList OContactFields::untrphonefields( bool sorted )
+{
+ return phonefields( sorted, false );
+}
- return list;
+
+/*!
+ \internal
+ Returns a translated list of field names for a contact.
+*/
+QStringList OContactFields::trfields( bool sorted )
+{
+ return fields( sorted, true );
+}
+
+/*!
+ \internal
+ Returns an untranslated list of field names for a contact.
+*/
+QStringList OContactFields::untrfields( bool sorted )
+{
+ return fields( sorted, false );
}
+
QMap<int, QString> OContactFields::idToTrFields()
{
QMap<int, QString> ret_map;
@@ -329,7 +338,7 @@ QMap<int, QString> OContactFields::idToUntrFields()
//personal
ret_map.insert( Qtopia::Spouse, "Spouse" );
- ret_map.insert( Qtopia::Gender, "Gender" );
+ ret_map.insert( Qtopia::Gender, "Gender" );
ret_map.insert( Qtopia::Birthday, "Birthday" );
ret_map.insert( Qtopia::Anniversary, "Anniversary" );
ret_map.insert( Qtopia::Nickname, "Nickname" );
@@ -357,6 +366,8 @@ QMap<QString, int> OContactFields::trFieldsToId()
return ret_map;
}
+/* ======================================================================= */
+
QMap<QString, int> OContactFields::untrFieldsToId()
{
QMap<int, QString> idtostr = idToUntrFields();
diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/ocontactfields.h
index 9f6171b..f105de7 100644
--- a/libopie2/opiepim/ocontactfields.h
+++ b/libopie2/opiepim/ocontactfields.h
@@ -43,6 +43,13 @@ class OContactFields{
bool changedFieldOrder;
public:
+ static QStringList personalfields( bool sorted = true, bool translated = false );
+ static QStringList phonefields( bool sorted = true, bool translated = false );
+ static QStringList detailsfields( bool sorted = true, bool translated = false );
+ static QStringList fields( bool sorted = true, bool translated = false );
+
+ static QStringList trpersonalfields( bool sorted = true );
+ static QStringList untrpersonalfields( bool sorted = true );
static QStringList trphonefields( bool sorted = true );
static QStringList untrphonefields( bool sorted = true );
static QStringList trdetailsfields( bool sorted = true );