summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimnotifymanager.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimnotifymanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp35
1 files changed, 33 insertions, 2 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,30 +1,60 @@
1#include "opimnotifymanager.h" 1/*
2 This file is part of the Opie Project
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>
2 30
3#include "oconversion.h" 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}
@@ -139,24 +169,25 @@ QString OPimNotifyManager::remindersToString() const
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}