author | eilers <eilers> | 2003-10-20 15:58:00 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-10-20 15:58:00 (UTC) |
commit | fccc5d110dea3bc32176694c8e5fc7f014706be6 (patch) (unidiff) | |
tree | 6dd44a78cadfd55fc8935dc661318e3ab12dd7b7 /libopie2/opiepim/core | |
parent | 758775c190470e569a0616bbd87d1a378c19b747 (diff) | |
download | opie-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..
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 72 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 24 |
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,14 +1,18 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | #include "opimnotifymanager.h" |
2 | 2 | ||
3 | #include "oconversion.h" | ||
4 | |||
5 | #include <qstringlist.h> | ||
6 | |||
3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 7 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
4 | : m_rem( rem ), m_al( al ) | 8 | : m_rem( rem ), m_al( al ) |
5 | {} | 9 | {} |
6 | OPimNotifyManager::~OPimNotifyManager() { | 10 | OPimNotifyManager::~OPimNotifyManager() { |
7 | } | 11 | } |
8 | /* use static_cast and type instead of dynamic... */ | 12 | /* use static_cast and type instead of dynamic... */ |
9 | void OPimNotifyManager::add( const OPimNotify& noti) { | 13 | void OPimNotifyManager::add( const OPimNotify& noti) { |
10 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 14 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
11 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 15 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
12 | m_rem.append( rem ); | 16 | m_rem.append( rem ); |
13 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 17 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
14 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 18 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
@@ -58,17 +62,85 @@ void OPimNotifyManager::setReminders( const Reminders& rem) { | |||
58 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { | 62 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { |
59 | 63 | ||
60 | } | 64 | } |
61 | /* FIXME!!! */ | 65 | /* FIXME!!! */ |
62 | /** | 66 | /** |
63 | * same as above... | 67 | * same as above... |
64 | * Also implement Url model | 68 | * Also implement Url model |
65 | * have a MainWindow.... | 69 | * have a MainWindow.... |
66 | */ | 70 | */ |
67 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 71 | void OPimNotifyManager::deregister( const OPimNotify& ) { |
68 | 72 | ||
69 | } | 73 | } |
74 | |||
70 | bool OPimNotifyManager::isEmpty()const { | 75 | bool 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.. | ||
82 | QString 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 | } | ||
106 | QString 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 | |||
123 | void 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 | |||
137 | void 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 | |||
@@ -30,25 +30,47 @@ public: | |||
30 | /* register is a Ansi C keyword... */ | 30 | /* register is a Ansi C keyword... */ |
31 | /** | 31 | /** |
32 | * This function will register the Notify to the Alarm Server | 32 | * This function will register the Notify to the Alarm Server |
33 | * or datebook depending on the type of the notify | 33 | * or datebook depending on the type of the notify |
34 | */ | 34 | */ |
35 | void registerNotify( const OPimNotify& ); | 35 | void registerNotify( const OPimNotify& ); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * this will do the opposite.. | 38 | * this will do the opposite.. |
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 | |||
45 | private: | 67 | private: |
46 | Reminders m_rem; | 68 | Reminders m_rem; |
47 | Alarms m_al; | 69 | Alarms m_al; |
48 | 70 | ||
49 | class Private; | 71 | class Private; |
50 | Private *d; | 72 | Private *d; |
51 | 73 | ||
52 | }; | 74 | }; |
53 | 75 | ||
54 | #endif | 76 | #endif |