Diffstat (limited to 'libopie2/opiepim/core/opimnotifymanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 120 |
1 files changed, 88 insertions, 32 deletions
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 1771fad..a54d597 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -28,9 +28,13 @@ | |||
28 | */ | 28 | */ |
29 | #include <opie2/opimnotifymanager.h> | ||
30 | 29 | ||
30 | #include "opimnotifymanager.h" | ||
31 | |||
32 | /* OPIE */ | ||
31 | #include <opie2/oconversion.h> | 33 | #include <opie2/oconversion.h> |
32 | 34 | ||
35 | /* QT */ | ||
33 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
34 | 37 | ||
35 | namespace Opie { | 38 | namespace Opie |
39 | { | ||
36 | 40 | ||
@@ -39,10 +43,18 @@ OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | |||
39 | {} | 43 | {} |
40 | OPimNotifyManager::~OPimNotifyManager() { | 44 | |
41 | } | 45 | |
46 | OPimNotifyManager::~OPimNotifyManager() | ||
47 | {} | ||
48 | |||
49 | |||
42 | /* use static_cast and type instead of dynamic... */ | 50 | /* use static_cast and type instead of dynamic... */ |
43 | void OPimNotifyManager::add( const OPimNotify& noti) { | 51 | void OPimNotifyManager::add( const OPimNotify& noti ) |
44 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 52 | { |
53 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | ||
54 | { | ||
45 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 55 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
46 | m_rem.append( rem ); | 56 | m_rem.append( rem ); |
47 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 57 | } |
58 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) | ||
59 | { | ||
48 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 60 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
@@ -51,7 +63,13 @@ void OPimNotifyManager::add( const OPimNotify& noti) { | |||
51 | } | 63 | } |
52 | void OPimNotifyManager::remove( const OPimNotify& noti) { | 64 | |
53 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 65 | |
66 | void OPimNotifyManager::remove( const OPimNotify& noti ) | ||
67 | { | ||
68 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | ||
69 | { | ||
54 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 70 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
55 | m_rem.remove( rem ); | 71 | m_rem.remove( rem ); |
56 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 72 | } |
73 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) | ||
74 | { | ||
57 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 75 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
@@ -60,4 +78,8 @@ void OPimNotifyManager::remove( const OPimNotify& noti) { | |||
60 | } | 78 | } |
61 | void OPimNotifyManager::replace( const OPimNotify& noti) { | 79 | |
62 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 80 | |
81 | void OPimNotifyManager::replace( const OPimNotify& noti ) | ||
82 | { | ||
83 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | ||
84 | { | ||
63 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 85 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
@@ -65,3 +87,5 @@ void OPimNotifyManager::replace( const OPimNotify& noti) { | |||
65 | m_rem.append( rem ); | 87 | m_rem.append( rem ); |
66 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 88 | } |
89 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) | ||
90 | { | ||
67 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 91 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
@@ -71,9 +95,18 @@ void OPimNotifyManager::replace( const OPimNotify& noti) { | |||
71 | } | 95 | } |
72 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { | 96 | |
97 | |||
98 | OPimNotifyManager::Reminders OPimNotifyManager::reminders() const | ||
99 | { | ||
73 | return m_rem; | 100 | return m_rem; |
74 | } | 101 | } |
75 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { | 102 | |
103 | |||
104 | OPimNotifyManager::Alarms OPimNotifyManager::alarms() const | ||
105 | { | ||
76 | return m_al; | 106 | return m_al; |
77 | } | 107 | } |
78 | OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const { | 108 | |
109 | |||
110 | OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const | ||
111 | { | ||
79 | Alarms::ConstIterator it; | 112 | Alarms::ConstIterator it; |
@@ -81,3 +114,4 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found | |||
81 | 114 | ||
82 | for ( it = m_al.begin(); it != m_al.end(); ++it ){ | 115 | for ( it = m_al.begin(); it != m_al.end(); ++it ) |
116 | { | ||
83 | if ( (*it).dateTime() == when ) | 117 | if ( (*it).dateTime() == when ) |
@@ -93,8 +127,14 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found | |||
93 | 127 | ||
94 | void OPimNotifyManager::setAlarms( const Alarms& al) { | 128 | void OPimNotifyManager::setAlarms( const Alarms& al ) |
129 | { | ||
95 | m_al = al; | 130 | m_al = al; |
96 | } | 131 | } |
97 | void OPimNotifyManager::setReminders( const Reminders& rem) { | 132 | |
133 | |||
134 | void OPimNotifyManager::setReminders( const Reminders& rem ) | ||
135 | { | ||
98 | m_rem = rem; | 136 | m_rem = rem; |
99 | } | 137 | } |
138 | |||
139 | |||
100 | /* FIXME!!! */ | 140 | /* FIXME!!! */ |
@@ -107,5 +147,7 @@ void OPimNotifyManager::setReminders( const Reminders& rem) { | |||
107 | */ | 147 | */ |
108 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { | 148 | void OPimNotifyManager::registerNotify( const OPimNotify& ) |
109 | 149 | { | |
110 | } | 150 | } |
151 | |||
152 | |||
111 | /* FIXME!!! */ | 153 | /* FIXME!!! */ |
@@ -116,7 +158,9 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) { | |||
116 | */ | 158 | */ |
117 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 159 | void OPimNotifyManager::deregister( const OPimNotify& ) |
118 | 160 | { | |
119 | } | 161 | } |
120 | 162 | ||
121 | bool OPimNotifyManager::isEmpty()const { | 163 | |
164 | bool OPimNotifyManager::isEmpty() const | ||
165 | { | ||
122 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | 166 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); |
@@ -126,3 +170,4 @@ bool OPimNotifyManager::isEmpty()const { | |||
126 | 170 | ||
127 | // Taken from otodoaccessxml.. | 171 | |
172 | // Taken from otodoaccessxml.. code duplication bad. any alternative? | ||
128 | QString OPimNotifyManager::alarmsToString() const | 173 | QString OPimNotifyManager::alarmsToString() const |
@@ -132,8 +177,11 @@ QString OPimNotifyManager::alarmsToString() const | |||
132 | OPimNotifyManager::Alarms alarms = m_al; | 177 | OPimNotifyManager::Alarms alarms = m_al; |
133 | if ( !alarms.isEmpty() ) { | 178 | if ( !alarms.isEmpty() ) |
179 | { | ||
134 | QStringList als; | 180 | QStringList als; |
135 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 181 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
136 | for ( ; it != alarms.end(); ++it ) { | 182 | for ( ; it != alarms.end(); ++it ) |
183 | { | ||
137 | /* only if time is valid */ | 184 | /* only if time is valid */ |
138 | if ( (*it).dateTime().isValid() ) { | 185 | if ( ( *it ).dateTime().isValid() ) |
186 | { | ||
139 | als << OConversion::dateTimeToString( (*it).dateTime() ) | 187 | als << OConversion::dateTimeToString( (*it).dateTime() ) |
@@ -151,2 +199,4 @@ QString OPimNotifyManager::alarmsToString() const | |||
151 | } | 199 | } |
200 | |||
201 | |||
152 | QString OPimNotifyManager::remindersToString() const | 202 | QString OPimNotifyManager::remindersToString() const |
@@ -156,6 +206,8 @@ QString OPimNotifyManager::remindersToString() const | |||
156 | OPimNotifyManager::Reminders reminders = m_rem; | 206 | OPimNotifyManager::Reminders reminders = m_rem; |
157 | if (!reminders.isEmpty() ) { | 207 | if ( !reminders.isEmpty() ) |
208 | { | ||
158 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 209 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
159 | QStringList records; | 210 | QStringList records; |
160 | for ( ; it != reminders.end(); ++it ) { | 211 | for ( ; it != reminders.end(); ++it ) |
212 | { | ||
161 | records << QString::number( (*it).recordUid() ); | 213 | records << QString::number( (*it).recordUid() ); |
@@ -168,2 +220,3 @@ QString OPimNotifyManager::remindersToString() const | |||
168 | 220 | ||
221 | |||
169 | void OPimNotifyManager::alarmsFromString( const QString& str ) | 222 | void OPimNotifyManager::alarmsFromString( const QString& str ) |
@@ -171,3 +224,4 @@ void OPimNotifyManager::alarmsFromString( const QString& str ) | |||
171 | QStringList als = QStringList::split(";", str ); | 224 | QStringList als = QStringList::split(";", str ); |
172 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 225 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) |
226 | { | ||
173 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 227 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty |
@@ -182,2 +236,3 @@ void OPimNotifyManager::alarmsFromString( const QString& str ) | |||
182 | 236 | ||
237 | |||
183 | void OPimNotifyManager::remindersFromString( const QString& str ) | 238 | void OPimNotifyManager::remindersFromString( const QString& str ) |
@@ -186,3 +241,4 @@ void OPimNotifyManager::remindersFromString( const QString& str ) | |||
186 | QStringList rems = QStringList::split(";", str ); | 241 | QStringList rems = QStringList::split(";", str ); |
187 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 242 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) |
243 | { | ||
188 | OPimReminder rem( (*it).toInt() ); | 244 | OPimReminder rem( (*it).toInt() ); |