author | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
commit | 507b362d42d5eed6277ad17422b6ba61acca636e (patch) (unidiff) | |
tree | d3d29451d37649b102c3e171e2927437925f8ce8 /korganizer | |
parent | a704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff) | |
download | kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2 |
print AB
-rw-r--r-- | korganizer/koeventviewer.cpp | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 42 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.h | 5 |
3 files changed, 33 insertions, 16 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index cee0466..5de667e 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,595 +1,595 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KPIM::AddresseeView av ( &dia ); | 90 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | } | 97 | } |
98 | dia.exec(); | 98 | dia.exec(); |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | #else | 104 | #else |
105 | { | 105 | { |
106 | if ( "uid:organizer" == n ) { | 106 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 111 | if (attendees.count()) { |
112 | Attendee *a; | 112 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 113 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 114 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 123 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 124 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 125 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 126 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 128 | #ifndef DESKTOP_VERSION |
129 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 129 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
130 | e << n.mid(7); | 130 | e << n.mid(7); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | #ifndef KORG_NODCOP | 136 | #ifndef KORG_NODCOP |
137 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 137 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
138 | QString tmpStr; | 138 | QString tmpStr; |
139 | if (n.startsWith("mailto:")) { | 139 | if (n.startsWith("mailto:")) { |
140 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 140 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
141 | //emit showIncidence(n); | 141 | //emit showIncidence(n); |
142 | return; | 142 | return; |
143 | } else if (n.startsWith("uid:")) { | 143 | } else if (n.startsWith("uid:")) { |
144 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 144 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
145 | const QByteArray noParamData; | 145 | const QByteArray noParamData; |
146 | const QByteArray paramData; | 146 | const QByteArray paramData; |
147 | QByteArray replyData; | 147 | QByteArray replyData; |
148 | QCString replyTypeStr; | 148 | QCString replyTypeStr; |
149 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 149 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
150 | bool foundAbbrowser = PING_ABBROWSER; | 150 | bool foundAbbrowser = PING_ABBROWSER; |
151 | 151 | ||
152 | if (foundAbbrowser) { | 152 | if (foundAbbrowser) { |
153 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 153 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
154 | //client->send("kaddressbook","KAddressBookIface", | 154 | //client->send("kaddressbook","KAddressBookIface", |
155 | QDataStream arg(paramData, IO_WriteOnly); | 155 | QDataStream arg(paramData, IO_WriteOnly); |
156 | arg << n.mid(6); | 156 | arg << n.mid(6); |
157 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 157 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
158 | return; | 158 | return; |
159 | } else { | 159 | } else { |
160 | /* | 160 | /* |
161 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 161 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
162 | We start it without its main interface | 162 | We start it without its main interface |
163 | */ | 163 | */ |
164 | KIconLoader* iconLoader = new KIconLoader(); | 164 | KIconLoader* iconLoader = new KIconLoader(); |
165 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 165 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
166 | ActionManager::setStartedKAddressBook(true); | 166 | ActionManager::setStartedKAddressBook(true); |
167 | tmpStr = "kaddressbook --editor-only --uid "; | 167 | tmpStr = "kaddressbook --editor-only --uid "; |
168 | tmpStr += KProcess::quote(n.mid(6)); | 168 | tmpStr += KProcess::quote(n.mid(6)); |
169 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 169 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | } else { | 172 | } else { |
173 | //QTextBrowser::setSource(n); | 173 | //QTextBrowser::setSource(n); |
174 | } | 174 | } |
175 | #endif | 175 | #endif |
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 178 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
179 | { | 179 | { |
180 | int number=text.contains("\n"); | 180 | int number=text.contains("\n"); |
181 | QString str = "<" + tag + ">"; | 181 | QString str = "<" + tag + ">"; |
182 | QString tmpText=text; | 182 | QString tmpText=text; |
183 | QString tmpStr=str; | 183 | QString tmpStr=str; |
184 | if(number !=-1) | 184 | if(number !=-1) |
185 | { | 185 | { |
186 | if (number > 0) { | 186 | if (number > 0) { |
187 | int pos=0; | 187 | int pos=0; |
188 | QString tmp; | 188 | QString tmp; |
189 | for(int i=0;i<=number;i++) { | 189 | for(int i=0;i<=number;i++) { |
190 | pos=tmpText.find("\n"); | 190 | pos=tmpText.find("\n"); |
191 | tmp=tmpText.left(pos); | 191 | tmp=tmpText.left(pos); |
192 | tmpText=tmpText.right(tmpText.length()-pos-1); | 192 | tmpText=tmpText.right(tmpText.length()-pos-1); |
193 | tmpStr+=tmp+"<br>"; | 193 | tmpStr+=tmp+"<br>"; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | else tmpStr += tmpText; | 196 | else tmpStr += tmpText; |
197 | tmpStr+="</" + tag + ">"; | 197 | tmpStr+="</" + tag + ">"; |
198 | mText.append(tmpStr); | 198 | mText.append(tmpStr); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | { | 201 | { |
202 | str += text + "</" + tag + ">"; | 202 | str += text + "</" + tag + ">"; |
203 | mText.append(str); | 203 | mText.append(str); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void KOEventViewer::setColorMode( int m ) | 207 | void KOEventViewer::setColorMode( int m ) |
208 | { | 208 | { |
209 | mColorMode = m; | 209 | mColorMode = m; |
210 | } | 210 | } |
211 | void KOEventViewer::appendEvent(Event *event, int mode ) | 211 | void KOEventViewer::appendEvent(Event *event, int mode ) |
212 | { | 212 | { |
213 | mMailSubject = ""; | 213 | mMailSubject = ""; |
214 | mCurrentIncidence = event; | 214 | mCurrentIncidence = event; |
215 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 215 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
216 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 216 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
217 | if ( mode == 0 ) { | 217 | if ( mode == 0 ) { |
218 | addTag("h2",event->summary()); | 218 | addTag("h2",event->summary()); |
219 | } | 219 | } |
220 | else { | 220 | else { |
221 | if ( mColorMode == 1 ) { | 221 | if ( mColorMode == 1 ) { |
222 | mText +="<font color=\"#00A000\">"; | 222 | mText +="<font color=\"#00A000\">"; |
223 | } | 223 | } |
224 | if ( mColorMode == 2 ) { | 224 | if ( mColorMode == 2 ) { |
225 | mText +="<font color=\"#C00000\">"; | 225 | mText +="<font color=\"#C00000\">"; |
226 | } | 226 | } |
227 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 227 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
228 | if ( mode == 1 ) { | 228 | if ( mode == 1 ) { |
229 | addTag("h2",i18n( "Local: " ) +event->summary()); | 229 | addTag("h2",i18n( "Local: " ) +event->summary()); |
230 | } else { | 230 | } else { |
231 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 231 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
232 | } | 232 | } |
233 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 233 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
234 | if ( mColorMode ) | 234 | if ( mColorMode ) |
235 | mText += "</font>"; | 235 | mText += "</font>"; |
236 | } | 236 | } |
237 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 237 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
238 | if (event->cancelled ()) { | 238 | if (event->cancelled ()) { |
239 | mText +="<font color=\"#B00000\">"; | 239 | mText +="<font color=\"#B00000\">"; |
240 | addTag("i",i18n("This event has been cancelled!")); | 240 | addTag("i",i18n("This event has been cancelled!")); |
241 | mText.append("<br>"); | 241 | mText.append("<br>"); |
242 | mText += "</font>"; | 242 | mText += "</font>"; |
243 | mMailSubject += i18n("(cancelled)"); | 243 | mMailSubject += i18n("(cancelled)"); |
244 | } | 244 | } |
245 | if (!event->location().isEmpty()) { | 245 | if (!event->location().isEmpty()) { |
246 | addTag("b",i18n("Location: ")); | 246 | addTag("b",i18n("Location: ")); |
247 | mText.append(event->location()+"<br>"); | 247 | mText.append(event->location()+"<br>"); |
248 | mMailSubject += i18n(" at ") + event->location(); | 248 | mMailSubject += i18n(" at ") + event->location(); |
249 | } | 249 | } |
250 | if (event->doesFloat()) { | 250 | if (event->doesFloat()) { |
251 | if (event->isMultiDay()) { | 251 | if (event->isMultiDay()) { |
252 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 252 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
253 | .arg(event->dtStartDateStr(shortDate)) | 253 | .arg(event->dtStartDateStr(shortDate)) |
254 | .arg(event->dtEndDateStr(shortDate))); | 254 | .arg(event->dtEndDateStr(shortDate))); |
255 | } else { | 255 | } else { |
256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
257 | } | 257 | } |
258 | } else { | 258 | } else { |
259 | if (event->isMultiDay()) { | 259 | if (event->isMultiDay()) { |
260 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 260 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
261 | .arg(event->dtStartStr( shortDate))); | 261 | .arg(event->dtStartStr( shortDate))); |
262 | mText.append(i18n("<p><b>To:</b> %1</p>") | 262 | mText.append(i18n("<p><b>To:</b> %1</p>") |
263 | .arg(event->dtEndStr(shortDate))); | 263 | .arg(event->dtEndStr(shortDate))); |
264 | } else { | 264 | } else { |
265 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 265 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
266 | .arg(event->dtStartDateStr( shortDate ))); | 266 | .arg(event->dtStartDateStr( shortDate ))); |
267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
268 | .arg(event->dtStartTimeStr()) | 268 | .arg(event->dtStartTimeStr()) |
269 | .arg(event->dtEndTimeStr())); | 269 | .arg(event->dtEndTimeStr())); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | if (event->recurrence()->doesRecur()) { | 273 | if (event->recurrence()->doesRecur()) { |
274 | 274 | ||
275 | QString recurText = event->recurrence()->recurrenceText(); | 275 | QString recurText = event->recurrence()->recurrenceText(); |
276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
277 | bool last; | 277 | bool last; |
278 | QDate start = QDate::currentDate(); | 278 | QDate start = QDate::currentDate(); |
279 | QDate next; | 279 | QDate next; |
280 | next = event->recurrence()->getPreviousDate( start , &last ); | 280 | next = event->recurrence()->getPreviousDate( start , &last ); |
281 | if ( !last ) { | 281 | if ( !last ) { |
282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); | 282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); |
283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); | 285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); |
286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); | 286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); |
287 | 287 | ||
288 | } else { | 288 | } else { |
289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
291 | } | 291 | } |
292 | } else { | 292 | } else { |
293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | if (event->isAlarmEnabled()) { | 298 | if (event->isAlarmEnabled()) { |
299 | Alarm *alarm =event->alarms().first() ; | 299 | Alarm *alarm =event->alarms().first() ; |
300 | QDateTime t = alarm->time(); | 300 | QDateTime t = alarm->time(); |
301 | int min = t.secsTo( event->dtStart() )/60; | 301 | int min = t.secsTo( event->dtStart() )/60; |
302 | QString s =i18n("( %1 min before )").arg( min ); | 302 | QString s =i18n("( %1 min before )").arg( min ); |
303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
305 | //addTag("p",s); | 305 | //addTag("p",s); |
306 | } | 306 | } |
307 | 307 | ||
308 | addTag("b",i18n("Access: ")); | 308 | addTag("b",i18n("Access: ")); |
309 | mText.append(event->secrecyStr()+"<br>"); | 309 | mText.append(event->secrecyStr()+"<br>"); |
310 | if (!event->description().isEmpty()) { | 310 | if (!event->description().isEmpty()) { |
311 | addTag("p",i18n("<b>Details: </b>")); | 311 | addTag("p",i18n("<b>Details: </b>")); |
312 | addTag("p",event->description()); | 312 | addTag("p",event->description()); |
313 | } | 313 | } |
314 | 314 | ||
315 | formatCategories(event); | 315 | formatCategories(event); |
316 | 316 | ||
317 | formatReadOnly(event); | 317 | formatReadOnly(event); |
318 | formatAttendees(event); | 318 | formatAttendees(event); |
319 | 319 | ||
320 | setText(mText); | 320 | setText(mText); |
321 | //QWhatsThis::add(this,mText); | 321 | //QWhatsThis::add(this,mText); |
322 | 322 | ||
323 | } | 323 | } |
324 | 324 | ||
325 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 325 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
326 | { | 326 | { |
327 | mMailSubject = ""; | 327 | mMailSubject = ""; |
328 | mCurrentIncidence = event; | 328 | mCurrentIncidence = event; |
329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
331 | if (mode == 0 ) | 331 | if (mode == 0 ) |
332 | addTag("h2",event->summary()); | 332 | addTag("h2",event->summary()); |
333 | else { | 333 | else { |
334 | if ( mColorMode == 1 ) { | 334 | if ( mColorMode == 1 ) { |
335 | mText +="<font color=\"#00A000\">"; | 335 | mText +="<font color=\"#00A000\">"; |
336 | } | 336 | } |
337 | if ( mColorMode == 2 ) { | 337 | if ( mColorMode == 2 ) { |
338 | mText +="<font color=\"#B00000\">"; | 338 | mText +="<font color=\"#B00000\">"; |
339 | } | 339 | } |
340 | if ( mode == 1 ) { | 340 | if ( mode == 1 ) { |
341 | addTag("h2",i18n( "Local: " ) +event->summary()); | 341 | addTag("h2",i18n( "Local: " ) +event->summary()); |
342 | } else { | 342 | } else { |
343 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 343 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
344 | } | 344 | } |
345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
346 | if ( mColorMode ) | 346 | if ( mColorMode ) |
347 | mText += "</font>"; | 347 | mText += "</font>"; |
348 | } | 348 | } |
349 | mMailSubject += i18n( "Todo " )+ event->summary(); | 349 | mMailSubject += i18n( "Todo " )+ event->summary(); |
350 | if (event->cancelled ()) { | 350 | if (event->cancelled ()) { |
351 | mText +="<font color=\"#B00000\">"; | 351 | mText +="<font color=\"#B00000\">"; |
352 | addTag("i",i18n("This todo has been cancelled!")); | 352 | addTag("i",i18n("This todo has been cancelled!")); |
353 | mText.append("<br>"); | 353 | mText.append("<br>"); |
354 | mText += "</font>"; | 354 | mText += "</font>"; |
355 | mMailSubject += i18n("(cancelled)"); | 355 | mMailSubject += i18n("(cancelled)"); |
356 | } | 356 | } |
357 | 357 | ||
358 | if (!event->location().isEmpty()) { | 358 | if (!event->location().isEmpty()) { |
359 | addTag("b",i18n("Location: ")); | 359 | addTag("b",i18n("Location: ")); |
360 | mText.append(event->location()+"<br>"); | 360 | mText.append(event->location()+"<br>"); |
361 | mMailSubject += i18n(" at ") + event->location(); | 361 | mMailSubject += i18n(" at ") + event->location(); |
362 | } | 362 | } |
363 | if (event->hasStartDate()) { | 363 | if (event->hasStartDate()) { |
364 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 364 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
365 | } | 365 | } |
366 | if (event->hasDueDate()) { | 366 | if (event->hasDueDate()) { |
367 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 367 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
368 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 368 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
369 | } | 369 | } |
370 | addTag("b",i18n("Access: ")); | 370 | addTag("b",i18n("Access: ")); |
371 | mText.append(event->secrecyStr()+"<br>"); | 371 | mText.append(event->secrecyStr()+"<br>"); |
372 | if (!event->description().isEmpty()) { | 372 | if (!event->description().isEmpty()) { |
373 | addTag("p",i18n("<b>Details: </b>")); | 373 | addTag("p",i18n("<b>Details: </b>")); |
374 | addTag("p",event->description()); | 374 | addTag("p",event->description()); |
375 | } | 375 | } |
376 | 376 | ||
377 | formatCategories(event); | 377 | formatCategories(event); |
378 | 378 | ||
379 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 379 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
380 | .arg(QString::number(event->priority()))); | 380 | .arg(QString::number(event->priority()))); |
381 | 381 | ||
382 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 382 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
383 | .arg(event->percentComplete())); | 383 | .arg(event->percentComplete())); |
384 | 384 | ||
385 | formatReadOnly(event); | 385 | formatReadOnly(event); |
386 | formatAttendees(event); | 386 | formatAttendees(event); |
387 | if ( event->relatedTo() ) { | 387 | if ( event->relatedTo() ) { |
388 | addTag("b",i18n("Parent todo: ")); | 388 | addTag("b",i18n("Parent todo: ")); |
389 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 389 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
390 | } | 390 | } |
391 | QPtrList<Incidence> Relations = event->relations(); | 391 | QPtrList<Incidence> Relations = event->relations(); |
392 | Incidence *to; | 392 | Incidence *to; |
393 | if ( Relations.first() ) | 393 | if ( Relations.first() ) |
394 | addTag("b",i18n("Sub todos:<br>")); | 394 | addTag("b",i18n("Sub todos:<br>")); |
395 | for (to=Relations.first();to;to=Relations.next()) { | 395 | for (to=Relations.first();to;to=Relations.next()) { |
396 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 396 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
397 | 397 | ||
398 | } | 398 | } |
399 | setText(mText); | 399 | setText(mText); |
400 | } | 400 | } |
401 | 401 | ||
402 | void KOEventViewer::formatCategories(Incidence *event) | 402 | void KOEventViewer::formatCategories(Incidence *event) |
403 | { | 403 | { |
404 | if (!event->categoriesStr().isEmpty()) { | 404 | if (!event->categoriesStr().isEmpty()) { |
405 | if (event->categories().count() == 1) { | 405 | if (event->categories().count() == 1) { |
406 | addTag("h3",i18n("Category")); | 406 | addTag("h3",i18n("Category")); |
407 | } else { | 407 | } else { |
408 | addTag("h3",i18n("Categories")); | 408 | addTag("h3",i18n("Categories")); |
409 | } | 409 | } |
410 | addTag("p",event->categoriesStr()); | 410 | addTag("p",event->categoriesStr()); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | void KOEventViewer::formatAttendees(Incidence *event) | 413 | void KOEventViewer::formatAttendees(Incidence *event) |
414 | { | 414 | { |
415 | QPtrList<Attendee> attendees = event->attendees(); | 415 | QPtrList<Attendee> attendees = event->attendees(); |
416 | if (attendees.count()) { | 416 | if (attendees.count()) { |
417 | 417 | ||
418 | 418 | ||
419 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 419 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
420 | addTag("h3",i18n("Organizer")); | 420 | addTag("h3",i18n("Organizer")); |
421 | mText.append("<ul><li>"); | 421 | mText.append("<ul><li>"); |
422 | #ifndef KORG_NOKABC | 422 | #ifndef KORG_NOKABC |
423 | 423 | ||
424 | #ifdef DESKTOP_VERSION | 424 | #ifdef DESKTOP_VERSION |
425 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 425 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
426 | KABC::Addressee::List addressList; | 426 | KABC::Addressee::List addressList; |
427 | addressList = add_book->findByEmail(event->organizer()); | 427 | addressList = add_book->findByEmail(event->organizer()); |
428 | KABC::Addressee o = addressList.first(); | 428 | KABC::Addressee o = addressList.first(); |
429 | if (!o.isEmpty() && addressList.size()<2) { | 429 | if (!o.isEmpty() && addressList.size()<2) { |
430 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 430 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
431 | mText += o.formattedName(); | 431 | mText += o.formattedName(); |
432 | mText += "</a>\n"; | 432 | mText += "</a>\n"; |
433 | } else { | 433 | } else { |
434 | mText.append(event->organizer()); | 434 | mText.append(event->organizer()); |
435 | } | 435 | } |
436 | #else //DESKTOP_VERSION | 436 | #else //DESKTOP_VERSION |
437 | mText += "<a href=\"uid:organizer\">"; | 437 | mText += "<a href=\"uid:organizer\">"; |
438 | mText += event->organizer(); | 438 | mText += event->organizer(); |
439 | mText += "</a>\n"; | 439 | mText += "</a>\n"; |
440 | #endif //DESKTOP_VERSION | 440 | #endif //DESKTOP_VERSION |
441 | 441 | ||
442 | 442 | ||
443 | #else | 443 | #else |
444 | mText.append(event->organizer()); | 444 | mText.append(event->organizer()); |
445 | #endif | 445 | #endif |
446 | 446 | ||
447 | if (iconPath) { | 447 | if (iconPath) { |
448 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 448 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
449 | mText += "<IMG src=\"" + iconPath + "\">"; | 449 | mText += "<IMG src=\"" + iconPath + "\">"; |
450 | mText += "</a>\n"; | 450 | mText += "</a>\n"; |
451 | } | 451 | } |
452 | mText.append("</li></ul>"); | 452 | mText.append("</li></ul>"); |
453 | 453 | ||
454 | addTag("h3",i18n("Attendees")); | 454 | addTag("h3",i18n("Attendees")); |
455 | Attendee *a; | 455 | Attendee *a; |
456 | mText.append("<ul>"); | 456 | mText.append("<ul>"); |
457 | for(a=attendees.first();a;a=attendees.next()) { | 457 | for(a=attendees.first();a;a=attendees.next()) { |
458 | #ifndef KORG_NOKABC | 458 | #ifndef KORG_NOKABC |
459 | #ifdef DESKTOP_VERSION | 459 | #ifdef DESKTOP_VERSION |
460 | if (a->name().isEmpty()) { | 460 | if (a->name().isEmpty()) { |
461 | addressList = add_book->findByEmail(a->email()); | 461 | addressList = add_book->findByEmail(a->email()); |
462 | KABC::Addressee o = addressList.first(); | 462 | KABC::Addressee o = addressList.first(); |
463 | if (!o.isEmpty() && addressList.size()<2) { | 463 | if (!o.isEmpty() && addressList.size()<2) { |
464 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 464 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
465 | mText += o.formattedName(); | 465 | mText += o.formattedName(); |
466 | mText += "</a>\n"; | 466 | mText += "</a>\n"; |
467 | } else { | 467 | } else { |
468 | mText += "<li>"; | 468 | mText += "<li>"; |
469 | mText.append(a->email()); | 469 | mText.append(a->email()); |
470 | mText += "\n"; | 470 | mText += "\n"; |
471 | } | 471 | } |
472 | } else { | 472 | } else { |
473 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 473 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
474 | if (!a->name().isEmpty()) mText += a->name(); | 474 | if (!a->name().isEmpty()) mText += a->name(); |
475 | else mText += a->email(); | 475 | else mText += a->email(); |
476 | mText += "</a>\n"; | 476 | mText += "</a>\n"; |
477 | } | 477 | } |
478 | #else //DESKTOP_VERSION | 478 | #else //DESKTOP_VERSION |
479 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 479 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
480 | if (!a->name().isEmpty()) mText += a->name(); | 480 | if (!a->name().isEmpty()) mText += a->name(); |
481 | else mText += a->email(); | 481 | else mText += a->email(); |
482 | mText += "</a>\n"; | 482 | mText += "</a>\n"; |
483 | #endif //DESKTOP_VERSION | 483 | #endif //DESKTOP_VERSION |
484 | #else | 484 | #else |
485 | //qDebug("nokabc "); | 485 | //qDebug("nokabc "); |
486 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 486 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
487 | if (!a->name().isEmpty()) mText += a->name(); | 487 | if (!a->name().isEmpty()) mText += a->name(); |
488 | else mText += a->email(); | 488 | else mText += a->email(); |
489 | mText += "</a>\n"; | 489 | mText += "</a>\n"; |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | 492 | ||
493 | if (!a->email().isEmpty()) { | 493 | if (!a->email().isEmpty()) { |
494 | if (iconPath) { | 494 | if (iconPath) { |
495 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 495 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
496 | mText += "<IMG src=\"" + iconPath + "\">"; | 496 | mText += "<IMG src=\"" + iconPath + "\">"; |
497 | mText += "</a>\n"; | 497 | mText += "</a>\n"; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | if (a->status() != Attendee::NeedsAction ) | 500 | if (a->status() != Attendee::NeedsAction ) |
501 | mText +="[" + a->statusStr() + "] "; | 501 | mText +="[" + a->statusStr() + "] "; |
502 | if (a->role() == Attendee::Chair ) | 502 | if (a->role() == Attendee::Chair ) |
503 | mText +="(" + a->roleStr().left(1) + ".)"; | 503 | mText +="(" + a->roleStr().left(1) + ".)"; |
504 | } | 504 | } |
505 | mText.append("</li></ul>"); | 505 | mText.append("</li></ul>"); |
506 | } | 506 | } |
507 | 507 | ||
508 | } | 508 | } |
509 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 509 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
510 | { | 510 | { |
511 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 511 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
512 | if (mode == 0 ) { | 512 | if (mode == 0 ) { |
513 | addTag("h2",i18n("Journal from: ")); | 513 | addTag("h2",i18n("Journal from: ")); |
514 | } | 514 | } |
515 | else { | 515 | else { |
516 | if ( mode == 1 ) { | 516 | if ( mode == 1 ) { |
517 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 517 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
518 | } else { | 518 | } else { |
519 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 519 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | topLevelWidget()->setCaption("Journal Viewer"); | 522 | topLevelWidget()->setCaption("Journal Viewer"); |
523 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 523 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
524 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 524 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
525 | if (!jour->description().isEmpty()) { | 525 | if (!jour->description().isEmpty()) { |
526 | addTag("p",jour->description()); | 526 | addTag("p",jour->description()); |
527 | } | 527 | } |
528 | setText(mText); | 528 | setText(mText); |
529 | } | 529 | } |
530 | 530 | ||
531 | void KOEventViewer::formatReadOnly(Incidence *event) | 531 | void KOEventViewer::formatReadOnly(Incidence *event) |
532 | { | 532 | { |
533 | if (event->isReadOnly()) { | 533 | if (event->isReadOnly()) { |
534 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 534 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | void KOEventViewer::setSyncMode( bool b ) | 537 | void KOEventViewer::setSyncMode( bool b ) |
538 | { | 538 | { |
539 | mSyncMode = b; | 539 | mSyncMode = b; |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 543 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
544 | { | 544 | { |
545 | if ( clearV ) | 545 | if ( clearV ) |
546 | clearEvents(); | 546 | clearEvents(); |
547 | if ( mSyncMode ) { | 547 | if ( mSyncMode ) { |
548 | if ( clearV ) | 548 | if ( clearV ) |
549 | appendTodo(event,1 ); | 549 | appendTodo(event,1 ); |
550 | else | 550 | else |
551 | appendTodo(event,2); | 551 | appendTodo(event,2); |
552 | } else | 552 | } else |
553 | appendTodo(event); | 553 | appendTodo(event); |
554 | } | 554 | } |
555 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 555 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
556 | { | 556 | { |
557 | if ( clearV ) | 557 | if ( clearV ) |
558 | clearEvents(); | 558 | clearEvents(); |
559 | if ( mSyncMode ) { | 559 | if ( mSyncMode ) { |
560 | if ( clearV ) | 560 | if ( clearV ) |
561 | appendJournal(event, 1); | 561 | appendJournal(event, 1); |
562 | else | 562 | else |
563 | appendJournal(event, 2); | 563 | appendJournal(event, 2); |
564 | } else | 564 | } else |
565 | appendJournal(event); | 565 | appendJournal(event); |
566 | } | 566 | } |
567 | 567 | ||
568 | void KOEventViewer::setEvent(Event *event) | 568 | void KOEventViewer::setEvent(Event *event) |
569 | { | 569 | { |
570 | clearEvents(); | 570 | clearEvents(); |
571 | if ( mSyncMode ) | 571 | if ( mSyncMode ) |
572 | appendEvent(event, 1); | 572 | appendEvent(event, 1); |
573 | else | 573 | else |
574 | appendEvent(event); | 574 | appendEvent(event); |
575 | } | 575 | } |
576 | 576 | ||
577 | void KOEventViewer::addEvent(Event *event) | 577 | void KOEventViewer::addEvent(Event *event) |
578 | { | 578 | { |
579 | if ( mSyncMode ) | 579 | if ( mSyncMode ) |
580 | appendEvent(event, 2); | 580 | appendEvent(event, 2); |
581 | else | 581 | else |
582 | appendEvent(event); | 582 | appendEvent(event); |
583 | } | 583 | } |
584 | 584 | ||
585 | void KOEventViewer::clearEvents(bool now) | 585 | void KOEventViewer::clearEvents(bool now) |
586 | { | 586 | { |
587 | mText = ""; | 587 | mText = ""; |
588 | if (now) setText(mText); | 588 | if (now) setText(mText); |
589 | } | 589 | } |
590 | 590 | ||
591 | void KOEventViewer::addText(QString text) | 591 | void KOEventViewer::addText(QString text) |
592 | { | 592 | { |
593 | mText.append(text); | 593 | mText.append(text); |
594 | setText(mText); | 594 | setText(mText); |
595 | } | 595 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 219f7c3..7166a01 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,725 +1,741 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | 27 | #ifdef DESKTOP_VERSION | |
28 | #include <qpaintdevicemetrics.h> | ||
29 | #endif | ||
28 | #include <kglobal.h> | 30 | #include <kglobal.h> |
29 | #include <klocale.h> | 31 | #include <klocale.h> |
30 | #include <kdebug.h> | 32 | #include <kdebug.h> |
31 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
32 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
33 | 35 | ||
34 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
35 | 37 | ||
36 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
37 | #include "calprinter.h" | 39 | #include "calprinter.h" |
38 | #endif | 40 | #endif |
39 | #include "koglobals.h" | 41 | #include "koglobals.h" |
40 | #include "koprefs.h" | 42 | #include "koprefs.h" |
41 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
42 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
43 | #include "kowhatsnextview.h" | 45 | #include "kowhatsnextview.h" |
44 | using namespace KOrg; | 46 | using namespace KOrg; |
45 | 47 | ||
46 | void WhatsNextTextBrowser::setSource(const QString& n) | 48 | void WhatsNextTextBrowser::setSource(const QString& n) |
47 | { | 49 | { |
48 | 50 | ||
49 | if (n.startsWith("event:")) { | 51 | if (n.startsWith("event:")) { |
50 | emit showIncidence(n); | 52 | emit showIncidence(n); |
51 | return; | 53 | return; |
52 | } else if (n.startsWith("todo:")) { | 54 | } else if (n.startsWith("todo:")) { |
53 | emit showIncidence(n); | 55 | emit showIncidence(n); |
54 | return; | 56 | return; |
55 | } else { | 57 | } else { |
56 | QTextBrowser::setSource(n); | 58 | QTextBrowser::setSource(n); |
57 | } | 59 | } |
58 | } | 60 | } |
61 | void WhatsNextTextBrowser::printMe() | ||
62 | { | ||
63 | #ifdef DESKTOP_VERSION | ||
64 | QPrinter printer; | ||
65 | if (!printer.setup() ) | ||
66 | return; | ||
67 | QPainter p; | ||
68 | p.begin ( &printer ); | ||
69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
70 | float dx, dy; | ||
71 | int wid = (m.width() * 9)/10; | ||
72 | dx = (float) wid/(float)contentsWidth (); | ||
73 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
74 | float scale; | ||
75 | // scale to fit the width or height of the paper | ||
76 | if ( dx < dy ) | ||
77 | scale = dx; | ||
78 | else | ||
79 | scale = dy; | ||
80 | p.translate( m.width()/10,0 ); | ||
81 | p.scale( scale, scale ); | ||
82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
83 | p.end(); | ||
84 | #endif | ||
85 | } | ||
59 | 86 | ||
60 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
61 | const char *name) | 88 | const char *name) |
62 | : KOrg::BaseView(calendar, parent, name) | 89 | : KOrg::BaseView(calendar, parent, name) |
63 | { | 90 | { |
64 | // mDateLabel = | 91 | // mDateLabel = |
65 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
66 | // mDateLabel->setMargin(2); | 93 | // mDateLabel->setMargin(2); |
67 | // mDateLabel->setAlignment(AlignCenter); | 94 | // mDateLabel->setAlignment(AlignCenter); |
68 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 95 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
69 | mView = new WhatsNextTextBrowser(this); | 96 | mView = new WhatsNextTextBrowser(this); |
70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
71 | QStyleSheet* stsh = mView->styleSheet(); | 98 | QStyleSheet* stsh = mView->styleSheet(); |
72 | QStyleSheetItem * style ; | 99 | QStyleSheetItem * style ; |
73 | style = stsh->item ("h2" ); | 100 | style = stsh->item ("h2" ); |
74 | if ( style ) { | 101 | if ( style ) { |
75 | style->setMargin(QStyleSheetItem::MarginAll,0); | 102 | style->setMargin(QStyleSheetItem::MarginAll,0); |
76 | } | 103 | } |
77 | style = stsh->item ("h3" ); | 104 | style = stsh->item ("h3" ); |
78 | if ( style ) { | 105 | if ( style ) { |
79 | style->setMargin(QStyleSheetItem::MarginAll,0); | 106 | style->setMargin(QStyleSheetItem::MarginAll,0); |
80 | } | 107 | } |
81 | mEventViewer = 0; | 108 | mEventViewer = 0; |
82 | 109 | ||
83 | QBoxLayout *topLayout = new QVBoxLayout(this); | 110 | QBoxLayout *topLayout = new QVBoxLayout(this); |
84 | // topLayout->addWidget(mDateLabel); | 111 | // topLayout->addWidget(mDateLabel); |
85 | topLayout->addWidget(mView); | 112 | topLayout->addWidget(mView); |
86 | mTimer = new QTimer( this ); | 113 | mTimer = new QTimer( this ); |
87 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
88 | 115 | ||
89 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
90 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
91 | } | 118 | } |
92 | 119 | ||
93 | KOWhatsNextView::~KOWhatsNextView() | 120 | KOWhatsNextView::~KOWhatsNextView() |
94 | { | 121 | { |
95 | } | 122 | } |
96 | 123 | ||
97 | int KOWhatsNextView::maxDatesHint() | 124 | int KOWhatsNextView::maxDatesHint() |
98 | { | 125 | { |
99 | return 0; | 126 | return 0; |
100 | } | 127 | } |
101 | 128 | ||
102 | int KOWhatsNextView::currentDateCount() | 129 | int KOWhatsNextView::currentDateCount() |
103 | { | 130 | { |
104 | return 0; | 131 | return 0; |
105 | } | 132 | } |
106 | 133 | ||
107 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
108 | { | 135 | { |
109 | QPtrList<Incidence> eventList; | 136 | QPtrList<Incidence> eventList; |
110 | 137 | ||
111 | return eventList; | 138 | return eventList; |
112 | } | 139 | } |
113 | 140 | ||
114 | void KOWhatsNextView::printMe() | 141 | void KOWhatsNextView::printMe() |
115 | { | 142 | { |
116 | #ifdef DESKTOP_VERSION | 143 | #ifdef DESKTOP_VERSION |
117 | QPrinter printer; | 144 | mView->printMe(); |
118 | if (!printer.setup() ) | ||
119 | return; | ||
120 | QTextBrowser tb; | ||
121 | tb.setFixedSize( 600, 4000 ); | ||
122 | QPainter::redirect ( tb.viewport(), &printer ); | ||
123 | updateView(); | ||
124 | tb.setText( mText ); | ||
125 | tb.show(); | ||
126 | tb.repaint(); | ||
127 | tb.hide(); | ||
128 | KMessageBox::information( this, i18n("Printing What's Next View!\n\nPlease close after\nprinting is finished.")); | ||
129 | #endif | 145 | #endif |
130 | } | 146 | } |
131 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
132 | const QDate &td) | 148 | const QDate &td) |
133 | { | 149 | { |
134 | #ifndef KORG_NOPRINTER | 150 | #ifndef KORG_NOPRINTER |
135 | calPrinter->preview(CalPrinter::Day, fd, td); | 151 | calPrinter->preview(CalPrinter::Day, fd, td); |
136 | #endif | 152 | #endif |
137 | } | 153 | } |
138 | void KOWhatsNextView::updateConfig() | 154 | void KOWhatsNextView::updateConfig() |
139 | { | 155 | { |
140 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 156 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
141 | updateView(); | 157 | updateView(); |
142 | 158 | ||
143 | } | 159 | } |
144 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
145 | { | 161 | { |
146 | //qDebug("KOWhatsNextView::showEvent "); | 162 | //qDebug("KOWhatsNextView::showEvent "); |
147 | restartTimer(); | 163 | restartTimer(); |
148 | QWidget::showEvent ( e ); | 164 | QWidget::showEvent ( e ); |
149 | } | 165 | } |
150 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
151 | { | 167 | { |
152 | //qDebug(" KOWhatsNextView::hideEvent"); | 168 | //qDebug(" KOWhatsNextView::hideEvent"); |
153 | mTimer->stop(); | 169 | mTimer->stop(); |
154 | QWidget::hideEvent ( e ); | 170 | QWidget::hideEvent ( e ); |
155 | } | 171 | } |
156 | void KOWhatsNextView::restartTimer() | 172 | void KOWhatsNextView::restartTimer() |
157 | { | 173 | { |
158 | //qDebug("KOWhatsNextView::restartTimer() "); | 174 | //qDebug("KOWhatsNextView::restartTimer() "); |
159 | mTimer->start( 300000 ); | 175 | mTimer->start( 300000 ); |
160 | //mTimer->start( 5000 ); | 176 | //mTimer->start( 5000 ); |
161 | } | 177 | } |
162 | void KOWhatsNextView::updateView() | 178 | void KOWhatsNextView::updateView() |
163 | { | 179 | { |
164 | if ( mTimer->isActive() ) | 180 | if ( mTimer->isActive() ) |
165 | restartTimer(); | 181 | restartTimer(); |
166 | //qDebug("KOWhatsNextView::updateView() "); | 182 | //qDebug("KOWhatsNextView::updateView() "); |
167 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 183 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
168 | KIconLoader kil("korganizer"); | 184 | KIconLoader kil("korganizer"); |
169 | QString ipath;// = new QString(); | 185 | QString ipath;// = new QString(); |
170 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 186 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
171 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 187 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
172 | mText = "<table width=\"100%\">\n"; | 188 | mText = "<table width=\"100%\">\n"; |
173 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 189 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
174 | #ifdef DESKTOP_VERSION | 190 | #ifdef DESKTOP_VERSION |
175 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 191 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
176 | #else | 192 | #else |
177 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 193 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
178 | #endif | 194 | #endif |
179 | // mText += "<img src=\""; | 195 | // mText += "<img src=\""; |
180 | // mText += ipath; | 196 | // mText += ipath; |
181 | // mText += "\">"; | 197 | // mText += "\">"; |
182 | mEventDate = QDate::currentDate(); | 198 | mEventDate = QDate::currentDate(); |
183 | #ifdef DESKTOP_VERSION | 199 | #ifdef DESKTOP_VERSION |
184 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 200 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
185 | #else | 201 | #else |
186 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 202 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
187 | #endif | 203 | #endif |
188 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 204 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
189 | int iii; | 205 | int iii; |
190 | mTodos.clear(); | 206 | mTodos.clear(); |
191 | QPtrList<Event> events; | 207 | QPtrList<Event> events; |
192 | QPtrList<Todo> todos = calendar()->todos(); | 208 | QPtrList<Todo> todos = calendar()->todos(); |
193 | Todo * todo; | 209 | Todo * todo; |
194 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 210 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
195 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 211 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
196 | bool itemAdded = false; | 212 | bool itemAdded = false; |
197 | for ( iii = 0; iii < daysToShow; ++iii ) { | 213 | for ( iii = 0; iii < daysToShow; ++iii ) { |
198 | QString date; | 214 | QString date; |
199 | itemAdded = false; | 215 | itemAdded = false; |
200 | events = calendar()->events( mEventDate, true ); | 216 | events = calendar()->events( mEventDate, true ); |
201 | 217 | ||
202 | if ( iii == 0 ) { // today !!! | 218 | if ( iii == 0 ) { // today !!! |
203 | todo = todos.first(); | 219 | todo = todos.first(); |
204 | while(todo) { | 220 | while(todo) { |
205 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 221 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
206 | if ( ! itemAdded ) { | 222 | if ( ! itemAdded ) { |
207 | appendDay ( iii, mEventDate ); | 223 | appendDay ( iii, mEventDate ); |
208 | //itemAdded = true; | 224 | //itemAdded = true; |
209 | 225 | ||
210 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 226 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
211 | appendEvent(todo, false, false, !itemAdded ); | 227 | appendEvent(todo, false, false, !itemAdded ); |
212 | itemAdded = true; | 228 | itemAdded = true; |
213 | } | 229 | } |
214 | todo = todos.next(); | 230 | todo = todos.next(); |
215 | } | 231 | } |
216 | } | 232 | } |
217 | 233 | ||
218 | 234 | ||
219 | if (events.count() > 0) { | 235 | if (events.count() > 0) { |
220 | // mText += "<p></p>"; | 236 | // mText += "<p></p>"; |
221 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 237 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
222 | // mText += "<h2>"; | 238 | // mText += "<h2>"; |
223 | //mText += " <img src=\""; | 239 | //mText += " <img src=\""; |
224 | //mText += ipath; | 240 | //mText += ipath; |
225 | //mText += "\">"; | 241 | //mText += "\">"; |
226 | if ( ! itemAdded ) { | 242 | if ( ! itemAdded ) { |
227 | appendDay ( iii, mEventDate ); | 243 | appendDay ( iii, mEventDate ); |
228 | 244 | ||
229 | } | 245 | } |
230 | // for first day (iii == 0) | 246 | // for first day (iii == 0) |
231 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 247 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
232 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 248 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
233 | // we must append it in the first successful call of appendEvent() | 249 | // we must append it in the first successful call of appendEvent() |
234 | Event *ev = events.first(); | 250 | Event *ev = events.first(); |
235 | while(ev) { | 251 | while(ev) { |
236 | //qDebug("+++++event append %s", ev->summary().latin1()); | 252 | //qDebug("+++++event append %s", ev->summary().latin1()); |
237 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 253 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
238 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 254 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
239 | itemAdded = true; | 255 | itemAdded = true; |
240 | } | 256 | } |
241 | ev = events.next(); | 257 | ev = events.next(); |
242 | } | 258 | } |
243 | 259 | ||
244 | //mText += "</table>\n"; | 260 | //mText += "</table>\n"; |
245 | } | 261 | } |
246 | 262 | ||
247 | todo = todos.first(); | 263 | todo = todos.first(); |
248 | while(todo) { | 264 | while(todo) { |
249 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 265 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
250 | if ( ! itemAdded ) { | 266 | if ( ! itemAdded ) { |
251 | appendDay ( iii, mEventDate ); | 267 | appendDay ( iii, mEventDate ); |
252 | //itemAdded = true; | 268 | //itemAdded = true; |
253 | } | 269 | } |
254 | appendEvent(todo, false , iii!= 0,!itemAdded); | 270 | appendEvent(todo, false , iii!= 0,!itemAdded); |
255 | itemAdded = true; | 271 | itemAdded = true; |
256 | } | 272 | } |
257 | todo = todos.next(); | 273 | todo = todos.next(); |
258 | } | 274 | } |
259 | if ( !itemAdded && iii == 0 ) { | 275 | if ( !itemAdded && iii == 0 ) { |
260 | // appendDay ( iii, mEventDate ); | 276 | // appendDay ( iii, mEventDate ); |
261 | //mText += "<table>"; | 277 | //mText += "<table>"; |
262 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 278 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
263 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 279 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
264 | //mText +="</table>"; | 280 | //mText +="</table>"; |
265 | } | 281 | } |
266 | if ( itemAdded ) | 282 | if ( itemAdded ) |
267 | mText += "</table>\n"; | 283 | mText += "</table>\n"; |
268 | mEventDate = mEventDate.addDays( 1 ); | 284 | mEventDate = mEventDate.addDays( 1 ); |
269 | } | 285 | } |
270 | 286 | ||
271 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 287 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
272 | if (todos.count() > 0 && topmostPrios > 0 ) { | 288 | if (todos.count() > 0 && topmostPrios > 0 ) { |
273 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 289 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
274 | // mText += "<h2>"; | 290 | // mText += "<h2>"; |
275 | //<img src=\""; | 291 | //<img src=\""; |
276 | // mText += ipath; | 292 | // mText += ipath; |
277 | // mText += "\">"; | 293 | // mText += "\">"; |
278 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 294 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
279 | 295 | ||
280 | //mText += "<ul>\n"; | 296 | //mText += "<ul>\n"; |
281 | bool gotone = false; | 297 | bool gotone = false; |
282 | int priority = 1; | 298 | int priority = 1; |
283 | int priosFound = 0; | 299 | int priosFound = 0; |
284 | #ifdef DESKTOP_VERSION | 300 | #ifdef DESKTOP_VERSION |
285 | mText +="<p></p>"; | 301 | mText +="<p></p>"; |
286 | #endif | 302 | #endif |
287 | 303 | ||
288 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 304 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
289 | mText += "<ul>\n"; | 305 | mText += "<ul>\n"; |
290 | while (!gotone && priority<6) { | 306 | while (!gotone && priority<6) { |
291 | todo = todos.first(); | 307 | todo = todos.first(); |
292 | while(todo) { | 308 | while(todo) { |
293 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 309 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
294 | if ( appendTodo(todo) ) | 310 | if ( appendTodo(todo) ) |
295 | gotone = true; | 311 | gotone = true; |
296 | } | 312 | } |
297 | todo = todos.next(); | 313 | todo = todos.next(); |
298 | } | 314 | } |
299 | if ( gotone ) { | 315 | if ( gotone ) { |
300 | gotone = false; | 316 | gotone = false; |
301 | ++priosFound; | 317 | ++priosFound; |
302 | if ( priosFound == topmostPrios ) | 318 | if ( priosFound == topmostPrios ) |
303 | break; | 319 | break; |
304 | } | 320 | } |
305 | priority++; | 321 | priority++; |
306 | // kdDebug() << "adding the todos..." << endl; | 322 | // kdDebug() << "adding the todos..." << endl; |
307 | } | 323 | } |
308 | mText += "</ul>\n"; | 324 | mText += "</ul>\n"; |
309 | } | 325 | } |
310 | 326 | ||
311 | int replys = 0; | 327 | int replys = 0; |
312 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 328 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
313 | if (events.count() > 0) { | 329 | if (events.count() > 0) { |
314 | Event *ev = events.first(); | 330 | Event *ev = events.first(); |
315 | while(ev) { | 331 | while(ev) { |
316 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 332 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
317 | if (me!=0) { | 333 | if (me!=0) { |
318 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 334 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
319 | if (replys == 0) { | 335 | if (replys == 0) { |
320 | mText += "<p></p>"; | 336 | mText += "<p></p>"; |
321 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 337 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
322 | //mText += "<h2>"; | 338 | //mText += "<h2>"; |
323 | //<img src=\""; | 339 | //<img src=\""; |
324 | // mText += ipath; | 340 | // mText += ipath; |
325 | // mText += "\">"; | 341 | // mText += "\">"; |
326 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 342 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
327 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 343 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
328 | mText += "<table>\n"; | 344 | mText += "<table>\n"; |
329 | } | 345 | } |
330 | replys++; | 346 | replys++; |
331 | appendEvent(ev,true); | 347 | appendEvent(ev,true); |
332 | } | 348 | } |
333 | } | 349 | } |
334 | ev = events.next(); | 350 | ev = events.next(); |
335 | } | 351 | } |
336 | } | 352 | } |
337 | todos = calendar()->todos(); | 353 | todos = calendar()->todos(); |
338 | if (todos.count() > 0) { | 354 | if (todos.count() > 0) { |
339 | Todo *to = todos.first(); | 355 | Todo *to = todos.first(); |
340 | while(to) { | 356 | while(to) { |
341 | if ( !to->isCompleted() ){ | 357 | if ( !to->isCompleted() ){ |
342 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 358 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
343 | if (me!=0) { | 359 | if (me!=0) { |
344 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 360 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
345 | if (replys == 0) { | 361 | if (replys == 0) { |
346 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 362 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
347 | mText += "<table>\n"; | 363 | mText += "<table>\n"; |
348 | } | 364 | } |
349 | replys++; | 365 | replys++; |
350 | appendEvent(to, true); | 366 | appendEvent(to, true); |
351 | } | 367 | } |
352 | } | 368 | } |
353 | } | 369 | } |
354 | to = todos.next(); | 370 | to = todos.next(); |
355 | } | 371 | } |
356 | } | 372 | } |
357 | if (replys > 0 ) mText += "</table>\n"; | 373 | if (replys > 0 ) mText += "</table>\n"; |
358 | 374 | ||
359 | 375 | ||
360 | mText += "</td></tr>\n</table>\n"; | 376 | mText += "</td></tr>\n</table>\n"; |
361 | 377 | ||
362 | mView->setText(mText); | 378 | mView->setText(mText); |
363 | mView->setFocus(); | 379 | mView->setFocus(); |
364 | 380 | ||
365 | // QPixmap bPix = SmallIcon( "back" ); | 381 | // QPixmap bPix = SmallIcon( "back" ); |
366 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 382 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
367 | // QWidget* test = new QWidget(); | 383 | // QWidget* test = new QWidget(); |
368 | // test->setBackgroundMode(FixedPixmap ); | 384 | // test->setBackgroundMode(FixedPixmap ); |
369 | // test->setBackgroundPixmap ( bPix ); | 385 | // test->setBackgroundPixmap ( bPix ); |
370 | // test->resize( 300, 400 ); | 386 | // test->resize( 300, 400 ); |
371 | // test->show(); | 387 | // test->show(); |
372 | // mView->setBackgroundMode(FixedPixmap ); | 388 | // mView->setBackgroundMode(FixedPixmap ); |
373 | // mView->setBackgroundPixmap ( bPix ); | 389 | // mView->setBackgroundPixmap ( bPix ); |
374 | // qDebug("%s ",mText.latin1()); | 390 | // qDebug("%s ",mText.latin1()); |
375 | } | 391 | } |
376 | 392 | ||
377 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 393 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
378 | { | 394 | { |
379 | QString date; | 395 | QString date; |
380 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 396 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
381 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 397 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
382 | if ( i == 0 ) { | 398 | if ( i == 0 ) { |
383 | //mText += "<table>\n"; | 399 | //mText += "<table>\n"; |
384 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 400 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
385 | } | 401 | } |
386 | else if ( i == 1 ) | 402 | else if ( i == 1 ) |
387 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 403 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
388 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 404 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
389 | mText += "<h2>" + date + "</h2>\n"; | 405 | mText += "<h2>" + date + "</h2>\n"; |
390 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 406 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
391 | mText += "<table>\n"; | 407 | mText += "<table>\n"; |
392 | 408 | ||
393 | 409 | ||
394 | 410 | ||
395 | } else { | 411 | } else { |
396 | if ( i == 0 ) { | 412 | if ( i == 0 ) { |
397 | //mText += "<table>\n"; | 413 | //mText += "<table>\n"; |
398 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 414 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
399 | } | 415 | } |
400 | 416 | ||
401 | #ifdef DESKTOP_VERSION | 417 | #ifdef DESKTOP_VERSION |
402 | else if ( i == 1 ) { | 418 | else if ( i == 1 ) { |
403 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 419 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
404 | } | 420 | } |
405 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 421 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
406 | #else | 422 | #else |
407 | else if ( i == 1 ) { | 423 | else if ( i == 1 ) { |
408 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 424 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
409 | } | 425 | } |
410 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 426 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
411 | 427 | ||
412 | #endif | 428 | #endif |
413 | mText += "<h2>" + date + "</h2>\n"; | 429 | mText += "<h2>" + date + "</h2>\n"; |
414 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 430 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
415 | mText += "<table>\n"; | 431 | mText += "<table>\n"; |
416 | } | 432 | } |
417 | } | 433 | } |
418 | 434 | ||
419 | 435 | ||
420 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 436 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
421 | { | 437 | { |
422 | updateView(); | 438 | updateView(); |
423 | } | 439 | } |
424 | 440 | ||
425 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 441 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
426 | { | 442 | { |
427 | } | 443 | } |
428 | 444 | ||
429 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 445 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
430 | { | 446 | { |
431 | switch(action) { | 447 | switch(action) { |
432 | case KOGlobals::EVENTADDED: | 448 | case KOGlobals::EVENTADDED: |
433 | updateView(); | 449 | updateView(); |
434 | break; | 450 | break; |
435 | case KOGlobals::EVENTEDITED: | 451 | case KOGlobals::EVENTEDITED: |
436 | updateView(); | 452 | updateView(); |
437 | break; | 453 | break; |
438 | case KOGlobals::EVENTDELETED: | 454 | case KOGlobals::EVENTDELETED: |
439 | updateView(); | 455 | updateView(); |
440 | break; | 456 | break; |
441 | default: | 457 | default: |
442 | updateView(); | 458 | updateView(); |
443 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 459 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
444 | } | 460 | } |
445 | } | 461 | } |
446 | 462 | ||
447 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 463 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
448 | { | 464 | { |
449 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 465 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
450 | return false; | 466 | return false; |
451 | QDateTime cdt = QDateTime::currentDateTime(); | 467 | QDateTime cdt = QDateTime::currentDateTime(); |
452 | QDateTime noc; | 468 | QDateTime noc; |
453 | QString tempText; | 469 | QString tempText; |
454 | if ( appendTable && !notRed ) { | 470 | if ( appendTable && !notRed ) { |
455 | tempText = "<table>"; | 471 | tempText = "<table>"; |
456 | } | 472 | } |
457 | bool ok = true; | 473 | bool ok = true; |
458 | if ( reply ) { | 474 | if ( reply ) { |
459 | noc = ev->getNextOccurence( cdt, &ok ); | 475 | noc = ev->getNextOccurence( cdt, &ok ); |
460 | if (! ok && ev->type() == "Event") | 476 | if (! ok && ev->type() == "Event") |
461 | return false; | 477 | return false; |
462 | } | 478 | } |
463 | tempText += "<tr><td><b>"; | 479 | tempText += "<tr><td><b>"; |
464 | if (ev->type()=="Event") { | 480 | if (ev->type()=="Event") { |
465 | if (reply) { | 481 | if (reply) { |
466 | if (!ev->doesFloat()) | 482 | if (!ev->doesFloat()) |
467 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 483 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
468 | else | 484 | else |
469 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 485 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
470 | 486 | ||
471 | } else { | 487 | } else { |
472 | if (!ev->doesFloat()) { | 488 | if (!ev->doesFloat()) { |
473 | Event *event = static_cast<Event *>(ev); | 489 | Event *event = static_cast<Event *>(ev); |
474 | QDateTime st,end; | 490 | QDateTime st,end; |
475 | if ( event->recurrence()->doesRecur() ) { | 491 | if ( event->recurrence()->doesRecur() ) { |
476 | QDate recDate= mEventDate; | 492 | QDate recDate= mEventDate; |
477 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 493 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
478 | while ( ! event->recursOn( recDate ) ) { | 494 | while ( ! event->recursOn( recDate ) ) { |
479 | recDate = recDate.addDays( -1 ); | 495 | recDate = recDate.addDays( -1 ); |
480 | 496 | ||
481 | } | 497 | } |
482 | st = QDateTime ( recDate, event->dtStart().time() ); | 498 | st = QDateTime ( recDate, event->dtStart().time() ); |
483 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 499 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
484 | } | 500 | } |
485 | else { | 501 | else { |
486 | st = event->dtStart(); | 502 | st = event->dtStart(); |
487 | end = event->dtEnd(); | 503 | end = event->dtEnd(); |
488 | } | 504 | } |
489 | 505 | ||
490 | 506 | ||
491 | QString dateText; | 507 | QString dateText; |
492 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 508 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
493 | if ( st.date() < mEventDate ) | 509 | if ( st.date() < mEventDate ) |
494 | dateText = "++:++-"; | 510 | dateText = "++:++-"; |
495 | else | 511 | else |
496 | dateText = event->dtStartTimeStr() + "-"; | 512 | dateText = event->dtStartTimeStr() + "-"; |
497 | if ( end.date() > mEventDate ) | 513 | if ( end.date() > mEventDate ) |
498 | dateText += "++:++"; | 514 | dateText += "++:++"; |
499 | else | 515 | else |
500 | dateText += event->dtEndTimeStr(); | 516 | dateText += event->dtEndTimeStr(); |
501 | if ( notRed ) | 517 | if ( notRed ) |
502 | tempText += dateText; | 518 | tempText += dateText; |
503 | else { | 519 | else { |
504 | if ( end < cdt ) { | 520 | if ( end < cdt ) { |
505 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 521 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
506 | return false; | 522 | return false; |
507 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 523 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
508 | } | 524 | } |
509 | else if ( st < cdt ) | 525 | else if ( st < cdt ) |
510 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 526 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
511 | else | 527 | else |
512 | tempText += dateText; | 528 | tempText += dateText; |
513 | 529 | ||
514 | } | 530 | } |
515 | 531 | ||
516 | } else { | 532 | } else { |
517 | tempText += i18n("Allday:"); | 533 | tempText += i18n("Allday:"); |
518 | 534 | ||
519 | } | 535 | } |
520 | } | 536 | } |
521 | } else { | 537 | } else { |
522 | mTodos.append( ev ); | 538 | mTodos.append( ev ); |
523 | tempText += i18n("ToDo:"); | 539 | tempText += i18n("ToDo:"); |
524 | if (reply) { | 540 | if (reply) { |
525 | tempText += " "; | 541 | tempText += " "; |
526 | if ( noc != cdt ) { | 542 | if ( noc != cdt ) { |
527 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 543 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
528 | } | 544 | } |
529 | } else { | 545 | } else { |
530 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 546 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
531 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 547 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
532 | QString dfs = KGlobal::locale()->dateFormatShort(); | 548 | QString dfs = KGlobal::locale()->dateFormatShort(); |
533 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 549 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
534 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 550 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
535 | KGlobal::locale()->setDateFormatShort(dfs); | 551 | KGlobal::locale()->setDateFormatShort(dfs); |
536 | } else { | 552 | } else { |
537 | if (!ev->doesFloat() ) | 553 | if (!ev->doesFloat() ) |
538 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 554 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
539 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 555 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
540 | 556 | ||
541 | 557 | ||
542 | } else | 558 | } else |
543 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 559 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
544 | mTodos.append( ev ); | 560 | mTodos.append( ev ); |
545 | } | 561 | } |
546 | } | 562 | } |
547 | } | 563 | } |
548 | tempText += "</b></td><td>"; | 564 | tempText += "</b></td><td>"; |
549 | bool needClose = false; | 565 | bool needClose = false; |
550 | if ( ev->cancelled() ) { | 566 | if ( ev->cancelled() ) { |
551 | tempText += "<font color=\"#F00000\">[c"; | 567 | tempText += "<font color=\"#F00000\">[c"; |
552 | needClose =true; | 568 | needClose =true; |
553 | 569 | ||
554 | } | 570 | } |
555 | if ( ev->isAlarmEnabled() ) { | 571 | if ( ev->isAlarmEnabled() ) { |
556 | if ( !needClose) | 572 | if ( !needClose) |
557 | tempText +="["; | 573 | tempText +="["; |
558 | tempText += "a"; | 574 | tempText += "a"; |
559 | needClose =true; | 575 | needClose =true; |
560 | 576 | ||
561 | } | 577 | } |
562 | if ( ev->description().length() > 0 ) { | 578 | if ( ev->description().length() > 0 ) { |
563 | if ( !needClose) | 579 | if ( !needClose) |
564 | tempText +="["; | 580 | tempText +="["; |
565 | tempText += "i"; | 581 | tempText += "i"; |
566 | needClose =true; | 582 | needClose =true; |
567 | } | 583 | } |
568 | if ( ev->recurrence()->doesRecur() ) { | 584 | if ( ev->recurrence()->doesRecur() ) { |
569 | if ( !needClose) | 585 | if ( !needClose) |
570 | tempText +="["; | 586 | tempText +="["; |
571 | tempText += "r"; | 587 | tempText += "r"; |
572 | needClose =true; | 588 | needClose =true; |
573 | } | 589 | } |
574 | if ( needClose ) { | 590 | if ( needClose ) { |
575 | tempText += "] "; | 591 | tempText += "] "; |
576 | } | 592 | } |
577 | if ( ev->cancelled() ) | 593 | if ( ev->cancelled() ) |
578 | tempText += "</font>"; | 594 | tempText += "</font>"; |
579 | tempText += "<a "; | 595 | tempText += "<a "; |
580 | if (ev->type()=="Event") tempText += "href=\"event:"; | 596 | if (ev->type()=="Event") tempText += "href=\"event:"; |
581 | if (ev->type()=="Todo") tempText += "href=\"todo:"; | 597 | if (ev->type()=="Todo") tempText += "href=\"todo:"; |
582 | tempText += ev->uid() + "\">"; | 598 | tempText += ev->uid() + "\">"; |
583 | if ( ev->summary().length() > 0 ) | 599 | if ( ev->summary().length() > 0 ) |
584 | tempText += ev->summary(); | 600 | tempText += ev->summary(); |
585 | else | 601 | else |
586 | tempText += i18n("-no summary-"); | 602 | tempText += i18n("-no summary-"); |
587 | tempText += "</a>"; | 603 | tempText += "</a>"; |
588 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 604 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
589 | if ( !ev->location().isEmpty() ) | 605 | if ( !ev->location().isEmpty() ) |
590 | tempText += " ("+ev->location() +")"; | 606 | tempText += " ("+ev->location() +")"; |
591 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 607 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
592 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 608 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
593 | tempText += "</td></tr>\n"; | 609 | tempText += "</td></tr>\n"; |
594 | mText += tempText; | 610 | mText += tempText; |
595 | return true; | 611 | return true; |
596 | } | 612 | } |
597 | 613 | ||
598 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 614 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
599 | { | 615 | { |
600 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 616 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
601 | 617 | ||
602 | mTodos.append( ev ); | 618 | mTodos.append( ev ); |
603 | if ( !isSub ) | 619 | if ( !isSub ) |
604 | mText += "<p>"; | 620 | mText += "<p>"; |
605 | else | 621 | else |
606 | mText += "<li>"; | 622 | mText += "<li>"; |
607 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 623 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
608 | 624 | ||
609 | 625 | ||
610 | mText += ind; | 626 | mText += ind; |
611 | bool needClose = false; | 627 | bool needClose = false; |
612 | if ( ev->cancelled() ) { | 628 | if ( ev->cancelled() ) { |
613 | mText += "<font color=\"#F00000\">[c"; | 629 | mText += "<font color=\"#F00000\">[c"; |
614 | needClose =true; | 630 | needClose =true; |
615 | 631 | ||
616 | } | 632 | } |
617 | if ( ev->isAlarmEnabled() ) { | 633 | if ( ev->isAlarmEnabled() ) { |
618 | if ( !needClose) | 634 | if ( !needClose) |
619 | mText +="["; | 635 | mText +="["; |
620 | mText += "a"; | 636 | mText += "a"; |
621 | needClose =true; | 637 | needClose =true; |
622 | 638 | ||
623 | } | 639 | } |
624 | 640 | ||
625 | if ( ev->description().length() > 0 ) { | 641 | if ( ev->description().length() > 0 ) { |
626 | if ( !needClose) | 642 | if ( !needClose) |
627 | mText +="["; | 643 | mText +="["; |
628 | mText += "i"; | 644 | mText += "i"; |
629 | needClose =true; | 645 | needClose =true; |
630 | } | 646 | } |
631 | // if ( ev->recurrence()->doesRecur() ) { | 647 | // if ( ev->recurrence()->doesRecur() ) { |
632 | // if ( !needClose) | 648 | // if ( !needClose) |
633 | // mText +="("; | 649 | // mText +="("; |
634 | // mText += "r"; | 650 | // mText += "r"; |
635 | // needClose =true; | 651 | // needClose =true; |
636 | // } | 652 | // } |
637 | if ( needClose ) | 653 | if ( needClose ) |
638 | mText += "] "; | 654 | mText += "] "; |
639 | if ( ev->cancelled() ) | 655 | if ( ev->cancelled() ) |
640 | mText += "</font>"; | 656 | mText += "</font>"; |
641 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 657 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
642 | mText += ev->summary(); | 658 | mText += ev->summary(); |
643 | mText += "</a>"; | 659 | mText += "</a>"; |
644 | if ( ((Todo*)ev)->hasDueDate () ) { | 660 | if ( ((Todo*)ev)->hasDueDate () ) { |
645 | QString year = ""; | 661 | QString year = ""; |
646 | int ye = ((Todo*)ev)->dtDue().date().year(); | 662 | int ye = ((Todo*)ev)->dtDue().date().year(); |
647 | if ( QDateTime::currentDateTime().date().year() != ye ) | 663 | if ( QDateTime::currentDateTime().date().year() != ye ) |
648 | year = QString::number( ye ); | 664 | year = QString::number( ye ); |
649 | QString dfs = KGlobal::locale()->dateFormatShort(); | 665 | QString dfs = KGlobal::locale()->dateFormatShort(); |
650 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 666 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
651 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 667 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
652 | KGlobal::locale()->setDateFormatShort(dfs); | 668 | KGlobal::locale()->setDateFormatShort(dfs); |
653 | } | 669 | } |
654 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 670 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
655 | if ( !ev->location().isEmpty() ) | 671 | if ( !ev->location().isEmpty() ) |
656 | mText += " ("+ev->location() +")"; | 672 | mText += " ("+ev->location() +")"; |
657 | if ( !isSub ) { | 673 | if ( !isSub ) { |
658 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 674 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
659 | mText += " ["+ev->relatedTo()->summary() +"]"; | 675 | mText += " ["+ev->relatedTo()->summary() +"]"; |
660 | mText += "</p>\n"; | 676 | mText += "</p>\n"; |
661 | } | 677 | } |
662 | else { | 678 | else { |
663 | ind += "-"; | 679 | ind += "-"; |
664 | mText += "</li>\n"; | 680 | mText += "</li>\n"; |
665 | } | 681 | } |
666 | QPtrList<Incidence> Relations = ev->relations(); | 682 | QPtrList<Incidence> Relations = ev->relations(); |
667 | Incidence *to; | 683 | Incidence *to; |
668 | for (to=Relations.first();to;to=Relations.next()) { | 684 | for (to=Relations.first();to;to=Relations.next()) { |
669 | if (!((Todo*)to)->isCompleted()) | 685 | if (!((Todo*)to)->isCompleted()) |
670 | appendTodo( to, ind , true ); | 686 | appendTodo( to, ind , true ); |
671 | } | 687 | } |
672 | 688 | ||
673 | return true; | 689 | return true; |
674 | } | 690 | } |
675 | 691 | ||
676 | /* | 692 | /* |
677 | void KOWhatsNextView::createEventViewer() | 693 | void KOWhatsNextView::createEventViewer() |
678 | { | 694 | { |
679 | if (!mEventViewer) { | 695 | if (!mEventViewer) { |
680 | 696 | ||
681 | mEventViewer = new KOEventViewerDialog(this); | 697 | mEventViewer = new KOEventViewerDialog(this); |
682 | } | 698 | } |
683 | } | 699 | } |
684 | */ | 700 | */ |
685 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 701 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
686 | { | 702 | { |
687 | mEventViewer = v; | 703 | mEventViewer = v; |
688 | } | 704 | } |
689 | 705 | ||
690 | // TODO: Create this function in CalendarView and remove it from here | 706 | // TODO: Create this function in CalendarView and remove it from here |
691 | void KOWhatsNextView::showIncidence(const QString &uid) | 707 | void KOWhatsNextView::showIncidence(const QString &uid) |
692 | { | 708 | { |
693 | 709 | ||
694 | if ( !mEventViewer ) { | 710 | if ( !mEventViewer ) { |
695 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 711 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
696 | return; | 712 | return; |
697 | } | 713 | } |
698 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 714 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
699 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 715 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
700 | if (uid.startsWith("event:")) { | 716 | if (uid.startsWith("event:")) { |
701 | #ifdef DESKTOP_VERSION | 717 | #ifdef DESKTOP_VERSION |
702 | Event *event = calendar()->event(uid.mid(8)); | 718 | Event *event = calendar()->event(uid.mid(8)); |
703 | #else | 719 | #else |
704 | Event *event = calendar()->event(uid.mid(6)); | 720 | Event *event = calendar()->event(uid.mid(6)); |
705 | #endif | 721 | #endif |
706 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 722 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
707 | if (!event) return; | 723 | if (!event) return; |
708 | //createEventViewer(); | 724 | //createEventViewer(); |
709 | mEventViewer->setEvent(event); | 725 | mEventViewer->setEvent(event); |
710 | } else if (uid.startsWith("todo:")) { | 726 | } else if (uid.startsWith("todo:")) { |
711 | #ifdef DESKTOP_VERSION | 727 | #ifdef DESKTOP_VERSION |
712 | Todo *todo = calendar()->todo(uid.mid(7)); | 728 | Todo *todo = calendar()->todo(uid.mid(7)); |
713 | #else | 729 | #else |
714 | Todo *todo = calendar()->todo(uid.mid(5)); | 730 | Todo *todo = calendar()->todo(uid.mid(5)); |
715 | #endif | 731 | #endif |
716 | if (!todo) return; | 732 | if (!todo) return; |
717 | //createEventViewer(); | 733 | //createEventViewer(); |
718 | mEventViewer->setTodo(todo); | 734 | mEventViewer->setTodo(todo); |
719 | } else { | 735 | } else { |
720 | return; | 736 | return; |
721 | 737 | ||
722 | } | 738 | } |
723 | mEventViewer->showMe(); | 739 | mEventViewer->showMe(); |
724 | mEventViewer->raise(); | 740 | mEventViewer->raise(); |
725 | } | 741 | } |
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h index 0231cf2..715037f 100644 --- a/korganizer/kowhatsnextview.h +++ b/korganizer/kowhatsnextview.h | |||
@@ -1,99 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOWHATSNEXTVIEW_H | 19 | #ifndef KOWHATSNEXTVIEW_H |
20 | #define KOWHATSNEXTVIEW_H | 20 | #define KOWHATSNEXTVIEW_H |
21 | 21 | ||
22 | #include <qtextbrowser.h> | 22 | #include <qtextbrowser.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | 24 | ||
25 | #include <korganizer/baseview.h> | 25 | #include <korganizer/baseview.h> |
26 | 26 | ||
27 | class QListView; | 27 | class QListView; |
28 | class QLabel; | 28 | class QLabel; |
29 | 29 | ||
30 | class KOEventViewerDialog; | 30 | class KOEventViewerDialog; |
31 | 31 | ||
32 | #include <qpainter.h> | 32 | #include <qpainter.h> |
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | class WhatsNextTextBrowser : public QTextBrowser { | 34 | class WhatsNextTextBrowser : public QTextBrowser { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
37 | WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {} | 37 | WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}; |
38 | 38 | ||
39 | void setSource(const QString &); | 39 | void setSource(const QString &); |
40 | void printMe(); | ||
40 | 41 | ||
41 | signals: | 42 | signals: |
42 | void showIncidence(const QString &uid); | 43 | void showIncidence(const QString &uid); |
43 | }; | 44 | }; |
44 | 45 | ||
45 | 46 | ||
46 | /** | 47 | /** |
47 | This class provides a view of the next events and todos | 48 | This class provides a view of the next events and todos |
48 | */ | 49 | */ |
49 | class KOWhatsNextView : public KOrg::BaseView | 50 | class KOWhatsNextView : public KOrg::BaseView |
50 | { | 51 | { |
51 | Q_OBJECT | 52 | Q_OBJECT |
52 | public: | 53 | public: |
53 | KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, | 54 | KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, |
54 | const char *name = 0); | 55 | const char *name = 0); |
55 | ~KOWhatsNextView(); | 56 | ~KOWhatsNextView(); |
56 | 57 | ||
57 | virtual int maxDatesHint(); | 58 | virtual int maxDatesHint(); |
58 | virtual int currentDateCount(); | 59 | virtual int currentDateCount(); |
59 | void setEventViewer(KOEventViewerDialog* v ); | 60 | void setEventViewer(KOEventViewerDialog* v ); |
60 | virtual QPtrList<Incidence> selectedIncidences(); | 61 | virtual QPtrList<Incidence> selectedIncidences(); |
61 | DateList selectedDates() | 62 | DateList selectedDates() |
62 | {DateList q; | 63 | {DateList q; |
63 | return q;} | 64 | return q;} |
64 | virtual void printPreview(CalPrinter *calPrinter, | 65 | virtual void printPreview(CalPrinter *calPrinter, |
65 | const QDate &, const QDate &); | 66 | const QDate &, const QDate &); |
66 | 67 | ||
67 | public slots: | 68 | public slots: |
68 | virtual void updateView(); | 69 | virtual void updateView(); |
69 | void printMe(); | 70 | void printMe(); |
70 | virtual void showDates(const QDate &start, const QDate &end); | 71 | virtual void showDates(const QDate &start, const QDate &end); |
71 | virtual void showEvents(QPtrList<Event> eventList); | 72 | virtual void showEvents(QPtrList<Event> eventList); |
72 | void updateConfig(); | 73 | void updateConfig(); |
73 | void changeEventDisplay(Event *, int); | 74 | void changeEventDisplay(Event *, int); |
74 | 75 | ||
75 | protected: | 76 | protected: |
76 | bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); | 77 | bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); |
77 | bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); | 78 | bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); |
78 | void appendDay( int i, QDate date ); | 79 | void appendDay( int i, QDate date ); |
79 | QDate mEventDate; | 80 | QDate mEventDate; |
80 | virtual void showEvent ( QShowEvent * ); | 81 | virtual void showEvent ( QShowEvent * ); |
81 | virtual void hideEvent ( QHideEvent * ); | 82 | virtual void hideEvent ( QHideEvent * ); |
82 | 83 | ||
83 | private slots: | 84 | private slots: |
84 | void showIncidence(const QString &); | 85 | void showIncidence(const QString &); |
85 | void restartTimer(); | 86 | void restartTimer(); |
86 | 87 | ||
87 | 88 | ||
88 | private: | 89 | private: |
89 | //void createEventViewer(); | 90 | //void createEventViewer(); |
90 | QTimer* mTimer; | 91 | QTimer* mTimer; |
91 | QTextBrowser *mView; | 92 | WhatsNextTextBrowser *mView; |
92 | QString mText; | 93 | QString mText; |
93 | // QLabel *mDateLabel; | 94 | // QLabel *mDateLabel; |
94 | KOEventViewerDialog *mEventViewer; | 95 | KOEventViewerDialog *mEventViewer; |
95 | 96 | ||
96 | QValueList<Incidence *> mTodos; | 97 | QValueList<Incidence *> mTodos; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | #endif | 100 | #endif |