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