summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimnotifymanager.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimnotifymanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index d6f0ead..1771fad 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -1,54 +1,84 @@
1#include "opimnotifymanager.h" 1/*
2 2 This file is part of the Opie Project
3#include "oconversion.h" 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29#include <opie2/opimnotifymanager.h>
30
31#include <opie2/oconversion.h>
4 32
5#include <qstringlist.h> 33#include <qstringlist.h>
6 34
35namespace Opie {
36
7OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) 37OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
8 : m_rem( rem ), m_al( al ) 38 : m_rem( rem ), m_al( al )
9{} 39{}
10OPimNotifyManager::~OPimNotifyManager() { 40OPimNotifyManager::~OPimNotifyManager() {
11} 41}
12/* use static_cast and type instead of dynamic... */ 42/* use static_cast and type instead of dynamic... */
13void OPimNotifyManager::add( const OPimNotify& noti) { 43void OPimNotifyManager::add( const OPimNotify& noti) {
14 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 44 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
15 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 45 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
16 m_rem.append( rem ); 46 m_rem.append( rem );
17 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 47 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
18 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 48 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
19 m_al.append( al ); 49 m_al.append( al );
20 } 50 }
21} 51}
22void OPimNotifyManager::remove( const OPimNotify& noti) { 52void OPimNotifyManager::remove( const OPimNotify& noti) {
23 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 53 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
24 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 54 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
25 m_rem.remove( rem ); 55 m_rem.remove( rem );
26 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 56 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
27 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 57 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
28 m_al.remove( al ); 58 m_al.remove( al );
29 } 59 }
30} 60}
31void OPimNotifyManager::replace( const OPimNotify& noti) { 61void OPimNotifyManager::replace( const OPimNotify& noti) {
32 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 62 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
33 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 63 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
34 m_rem.remove( rem ); 64 m_rem.remove( rem );
35 m_rem.append( rem ); 65 m_rem.append( rem );
36 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 66 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
37 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 67 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
38 m_al.remove( al ); 68 m_al.remove( al );
39 m_al.append( al ); 69 m_al.append( al );
40 } 70 }
41} 71}
42OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { 72OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
43 return m_rem; 73 return m_rem;
44} 74}
45OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { 75OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
46 return m_al; 76 return m_al;
47} 77}
48OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const { 78OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const {
49 Alarms::ConstIterator it; 79 Alarms::ConstIterator it;
50 found = true; 80 found = true;
51 81
52 for ( it = m_al.begin(); it != m_al.end(); ++it ){ 82 for ( it = m_al.begin(); it != m_al.end(); ++it ){
53 if ( (*it).dateTime() == when ) 83 if ( (*it).dateTime() == when )
54 return (*it); 84 return (*it);
@@ -115,48 +145,49 @@ QString OPimNotifyManager::alarmsToString() const
115 // now write the list 145 // now write the list
116 qWarning("als: %s", als.join("____________").latin1() ); 146 qWarning("als: %s", als.join("____________").latin1() );
117 str = als.join(";"); 147 str = als.join(";");
118 } 148 }
119 149
120 return str; 150 return str;
121} 151}
122QString OPimNotifyManager::remindersToString() const 152QString OPimNotifyManager::remindersToString() const
123{ 153{
124 QString str; 154 QString str;
125 155
126 OPimNotifyManager::Reminders reminders = m_rem; 156 OPimNotifyManager::Reminders reminders = m_rem;
127 if (!reminders.isEmpty() ) { 157 if (!reminders.isEmpty() ) {
128 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 158 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
129 QStringList records; 159 QStringList records;
130 for ( ; it != reminders.end(); ++it ) { 160 for ( ; it != reminders.end(); ++it ) {
131 records << QString::number( (*it).recordUid() ); 161 records << QString::number( (*it).recordUid() );
132 } 162 }
133 str = records.join(";"); 163 str = records.join(";");
134 } 164 }
135 165
136 return str; 166 return str;
137} 167}
138 168
139void OPimNotifyManager::alarmsFromString( const QString& str ) 169void OPimNotifyManager::alarmsFromString( const QString& str )
140{ 170{
141 QStringList als = QStringList::split(";", str ); 171 QStringList als = QStringList::split(";", str );
142 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { 172 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
143 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 173 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
144 qWarning("alarm: %s", alarm.join("___").latin1() ); 174 qWarning("alarm: %s", alarm.join("___").latin1() );
145 qWarning("alarm[0]: %s %s", alarm[0].latin1(), 175 qWarning("alarm[0]: %s %s", alarm[0].latin1(),
146 OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 176 OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
147 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), 177 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ),
148 alarm[1].toInt() ); 178 alarm[1].toInt() );
149 add( al ); 179 add( al );
150 } 180 }
151} 181}
152 182
153void OPimNotifyManager::remindersFromString( const QString& str ) 183void OPimNotifyManager::remindersFromString( const QString& str )
154{ 184{
155 185
156 QStringList rems = QStringList::split(";", str ); 186 QStringList rems = QStringList::split(";", str );
157 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { 187 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
158 OPimReminder rem( (*it).toInt() ); 188 OPimReminder rem( (*it).toInt() );
159 add( rem ); 189 add( rem );
160 } 190 }
161 191
162} 192}
193}