summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimnotifymanager.cpp
authormickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
committer mickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
commitf9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (unidiff)
tree4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/core/opimnotifymanager.cpp
parent2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff)
downloadopie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2
cosmetics
Diffstat (limited to 'libopie2/opiepim/core/opimnotifymanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp120
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
@@ -26,60 +26,94 @@
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
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
35namespace Opie { 38namespace Opie
39{
36 40
37OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) 41OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
38 : m_rem( rem ), m_al( al ) 42 : m_rem( rem ), m_al( al )
39{} 43{}
40OPimNotifyManager::~OPimNotifyManager() { 44
41} 45
46OPimNotifyManager::~OPimNotifyManager()
47{}
48
49
42/* use static_cast and type instead of dynamic... */ 50/* use static_cast and type instead of dynamic... */
43void OPimNotifyManager::add( const OPimNotify& noti) { 51void 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);
49 m_al.append( al ); 61 m_al.append( al );
50 } 62 }
51} 63}
52void OPimNotifyManager::remove( const OPimNotify& noti) { 64
53 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 65
66void 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);
58 m_al.remove( al ); 76 m_al.remove( al );
59 } 77 }
60} 78}
61void OPimNotifyManager::replace( const OPimNotify& noti) { 79
62 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 80
81void 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);
64 m_rem.remove( rem ); 86 m_rem.remove( rem );
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);
68 m_al.remove( al ); 92 m_al.remove( al );
69 m_al.append( al ); 93 m_al.append( al );
70 } 94 }
71} 95}
72OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { 96
97
98OPimNotifyManager::Reminders OPimNotifyManager::reminders() const
99{
73 return m_rem; 100 return m_rem;
74} 101}
75OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { 102
103
104OPimNotifyManager::Alarms OPimNotifyManager::alarms() const
105{
76 return m_al; 106 return m_al;
77} 107}
78OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const { 108
109
110OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const
111{
79 Alarms::ConstIterator it; 112 Alarms::ConstIterator it;
80 found = true; 113 found = true;
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 )
84 return (*it); 118 return (*it);
85 } 119 }
@@ -91,12 +125,18 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found
91} 125}
92 126
93 127
94void OPimNotifyManager::setAlarms( const Alarms& al) { 128void OPimNotifyManager::setAlarms( const Alarms& al )
129{
95 m_al = al; 130 m_al = al;
96} 131}
97void OPimNotifyManager::setReminders( const Reminders& rem) { 132
133
134void OPimNotifyManager::setReminders( const Reminders& rem )
135{
98 m_rem = rem; 136 m_rem = rem;
99} 137}
138
139
100/* FIXME!!! */ 140/* FIXME!!! */
101/** 141/**
102 * The idea is to check if the provider for our service 142 * The idea is to check if the provider for our service
@@ -105,37 +145,45 @@ void OPimNotifyManager::setReminders( const Reminders& rem) {
105 * if not the Factory to get the backend... 145 * if not the Factory to get the backend...
106 * Qtopia1.6 services would be kewl to have here.... 146 * Qtopia1.6 services would be kewl to have here....
107 */ 147 */
108void OPimNotifyManager::registerNotify( const OPimNotify& ) { 148void OPimNotifyManager::registerNotify( const OPimNotify& )
109 149{
110} 150}
151
152
111/* FIXME!!! */ 153/* FIXME!!! */
112/** 154/**
113 * same as above... 155 * same as above...
114 * Also implement Url model 156 * Also implement Url model
115 * have a MainWindow.... 157 * have a MainWindow....
116 */ 158 */
117void OPimNotifyManager::deregister( const OPimNotify& ) { 159void OPimNotifyManager::deregister( const OPimNotify& )
118 160{
119} 161}
120 162
121bool OPimNotifyManager::isEmpty()const { 163
164bool 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() );
123 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 167 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
124 else return false; 168 else return false;
125} 169}
126 170
127// Taken from otodoaccessxml.. 171
172// Taken from otodoaccessxml.. code duplication bad. any alternative?
128QString OPimNotifyManager::alarmsToString() const 173QString OPimNotifyManager::alarmsToString() const
129{ 174{
130 QString str; 175 QString str;
131 176
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() )
140 + ":" + QString::number( (*it).duration() ) 188 + ":" + QString::number( (*it).duration() )
141 + ":" + QString::number( (*it).sound() ) 189 + ":" + QString::number( (*it).sound() )
@@ -149,15 +197,19 @@ QString OPimNotifyManager::alarmsToString() const
149 197
150 return str; 198 return str;
151} 199}
200
201
152QString OPimNotifyManager::remindersToString() const 202QString OPimNotifyManager::remindersToString() const
153{ 203{
154 QString str; 204 QString str;
155 205
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() );
162 } 214 }
163 str = records.join(";"); 215 str = records.join(";");
@@ -166,10 +218,12 @@ QString OPimNotifyManager::remindersToString() const
166 return str; 218 return str;
167} 219}
168 220
221
169void OPimNotifyManager::alarmsFromString( const QString& str ) 222void OPimNotifyManager::alarmsFromString( const QString& str )
170{ 223{
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
174 qWarning("alarm: %s", alarm.join("___").latin1() ); 228 qWarning("alarm: %s", alarm.join("___").latin1() );
175 qWarning("alarm[0]: %s %s", alarm[0].latin1(), 229 qWarning("alarm[0]: %s %s", alarm[0].latin1(),
@@ -180,11 +234,13 @@ void OPimNotifyManager::alarmsFromString( const QString& str )
180 } 234 }
181} 235}
182 236
237
183void OPimNotifyManager::remindersFromString( const QString& str ) 238void OPimNotifyManager::remindersFromString( const QString& str )
184{ 239{
185 240
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() );
189 add( rem ); 245 add( rem );
190 } 246 }