summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core
authoreilers <eilers>2003-10-20 15:58:00 (UTC)
committer eilers <eilers>2003-10-20 15:58:00 (UTC)
commitfccc5d110dea3bc32176694c8e5fc7f014706be6 (patch) (unidiff)
tree6dd44a78cadfd55fc8935dc661318e3ab12dd7b7 /libopie2/opiepim/core
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/opiepim/core') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp72
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h24
2 files changed, 95 insertions, 1 deletions
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 @@
1#include "opimnotifymanager.h" 1#include "opimnotifymanager.h"
2 2
3#include "oconversion.h"
4
5#include <qstringlist.h>
6
3OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) 7OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
4 : m_rem( rem ), m_al( al ) 8 : m_rem( rem ), m_al( al )
5{} 9{}
@@ -67,8 +71,76 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) {
67void OPimNotifyManager::deregister( const OPimNotify& ) { 71void OPimNotifyManager::deregister( const OPimNotify& ) {
68 72
69} 73}
74
70bool OPimNotifyManager::isEmpty()const { 75bool OPimNotifyManager::isEmpty()const {
71 qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); 76 qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
72 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 77 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
73 else return false; 78 else return false;
74} 79}
80
81// Taken from otodoaccessxml..
82QString OPimNotifyManager::alarmsToString() const
83{
84 QString str;
85
86 OPimNotifyManager::Alarms alarms = m_al;
87 if ( !alarms.isEmpty() ) {
88 QStringList als;
89 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
90 for ( ; it != alarms.end(); ++it ) {
91 /* only if time is valid */
92 if ( (*it).dateTime().isValid() ) {
93 als << OConversion::dateTimeToString( (*it).dateTime() )
94 + ":" + QString::number( (*it).duration() )
95 + ":" + QString::number( (*it).sound() )
96 + ":";
97 }
98 }
99 // now write the list
100 qWarning("als: %s", als.join("____________").latin1() );
101 str = als.join(";");
102 }
103
104 return str;
105}
106QString OPimNotifyManager::remindersToString() const
107{
108 QString str;
109
110 OPimNotifyManager::Reminders reminders = m_rem;
111 if (!reminders.isEmpty() ) {
112 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
113 QStringList records;
114 for ( ; it != reminders.end(); ++it ) {
115 records << QString::number( (*it).recordUid() );
116 }
117 str = records.join(";");
118 }
119
120 return str;
121}
122
123void OPimNotifyManager::alarmsFromString( const QString& str )
124{
125 QStringList als = QStringList::split(";", str );
126 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
127 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
128 qWarning("alarm: %s", alarm.join("___").latin1() );
129 qWarning("alarm[0]: %s %s", alarm[0].latin1(),
130 OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
131 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ),
132 alarm[1].toInt() );
133 add( al );
134 }
135}
136
137void OPimNotifyManager::remindersFromString( const QString& str )
138{
139
140 QStringList rems = QStringList::split(";", str );
141 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
142 OPimReminder rem( (*it).toInt() );
143 add( rem );
144 }
145
146}
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:
39 */ 39 */
40 void deregister( const OPimNotify& ); 40 void deregister( const OPimNotify& );
41 41
42
43 bool isEmpty()const; 42 bool isEmpty()const;
44 43
44 /**
45 * Return all alarms as string
46 */
47 QString alarmsToString() const;
48 /**
49 * Return all notifiers as string
50 */
51 QString remindersToString() const;
52
53 /**
54 * Convert string to alarms
55 * @param str String created by alarmsToString()
56 */
57 void alarmsFromString( const QString& str );
58
59 /**
60 * Convert string to reminders
61 * @param str String created by remindersToString()
62 */
63 void remindersFromString( const QString& str );
64
65
66
45private: 67private:
46 Reminders m_rem; 68 Reminders m_rem;
47 Alarms m_al; 69 Alarms m_al;