-rw-r--r-- | korganizer/koeventviewer.cpp | 12 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 26 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 2 |
4 files changed, 30 insertions, 11 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 417d89c..44da058 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,695 +1,707 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KABC::AddresseeView av ( &dia ); | 90 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | } | 97 | } |
98 | dia.exec(); | 98 | dia.exec(); |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | #else | 104 | #else |
105 | { | 105 | { |
106 | if ( "uid:organizer" == n ) { | 106 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 111 | if (attendees.count()) { |
112 | Attendee *a; | 112 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 113 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 114 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 123 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 124 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 125 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 126 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 128 | #ifndef DESKTOP_VERSION |
129 | if ( n.mid(7,3) == "ALL" ) { | 129 | if ( n.mid(7,3) == "ALL" ) { |
130 | qDebug("all "); | 130 | qDebug("all "); |
131 | mailToAttendees( true ); | 131 | mailToAttendees( true ); |
132 | } else if ( n.mid(7,4) == "RSVP" ) { | 132 | } else if ( n.mid(7,4) == "RSVP" ) { |
133 | mailToAttendees( false ); | 133 | mailToAttendees( false ); |
134 | qDebug("rsvp "); | 134 | qDebug("rsvp "); |
135 | } else { | 135 | } else { |
136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
137 | e << n.mid(7); | 137 | e << n.mid(7); |
138 | } | 138 | } |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | #ifndef KORG_NODCOP | 144 | #ifndef KORG_NODCOP |
145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
146 | QString tmpStr; | 146 | QString tmpStr; |
147 | if (n.startsWith("mailto:")) { | 147 | if (n.startsWith("mailto:")) { |
148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
149 | //emit showIncidence(n); | 149 | //emit showIncidence(n); |
150 | return; | 150 | return; |
151 | } else if (n.startsWith("uid:")) { | 151 | } else if (n.startsWith("uid:")) { |
152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
153 | const QByteArray noParamData; | 153 | const QByteArray noParamData; |
154 | const QByteArray paramData; | 154 | const QByteArray paramData; |
155 | QByteArray replyData; | 155 | QByteArray replyData; |
156 | QCString replyTypeStr; | 156 | QCString replyTypeStr; |
157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
158 | bool foundAbbrowser = PING_ABBROWSER; | 158 | bool foundAbbrowser = PING_ABBROWSER; |
159 | 159 | ||
160 | if (foundAbbrowser) { | 160 | if (foundAbbrowser) { |
161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
162 | //client->send("kaddressbook","KAddressBookIface", | 162 | //client->send("kaddressbook","KAddressBookIface", |
163 | QDataStream arg(paramData, IO_WriteOnly); | 163 | QDataStream arg(paramData, IO_WriteOnly); |
164 | arg << n.mid(6); | 164 | arg << n.mid(6); |
165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
166 | return; | 166 | return; |
167 | } else { | 167 | } else { |
168 | /* | 168 | /* |
169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
170 | We start it without its main interface | 170 | We start it without its main interface |
171 | */ | 171 | */ |
172 | KIconLoader* iconLoader = new KIconLoader(); | 172 | KIconLoader* iconLoader = new KIconLoader(); |
173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
174 | ActionManager::setStartedKAddressBook(true); | 174 | ActionManager::setStartedKAddressBook(true); |
175 | tmpStr = "kaddressbook --editor-only --uid "; | 175 | tmpStr = "kaddressbook --editor-only --uid "; |
176 | tmpStr += KProcess::quote(n.mid(6)); | 176 | tmpStr += KProcess::quote(n.mid(6)); |
177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } else { | 180 | } else { |
181 | //QTextBrowser::setSource(n); | 181 | //QTextBrowser::setSource(n); |
182 | } | 182 | } |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | void KOEventViewer::mailToAttendees( bool all ) | 185 | void KOEventViewer::mailToAttendees( bool all ) |
186 | { | 186 | { |
187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
188 | if (attendees.count() == 0) return; | 188 | if (attendees.count() == 0) return; |
189 | QStringList nameList; | 189 | QStringList nameList; |
190 | QStringList emailList; | 190 | QStringList emailList; |
191 | QStringList uidList; | 191 | QStringList uidList; |
192 | Attendee* a; | 192 | Attendee* a; |
193 | for(a=attendees.first();a;a=attendees.next()) { | 193 | for(a=attendees.first();a;a=attendees.next()) { |
194 | if ( !all && !a->RSVP() ) continue; | 194 | if ( !all && !a->RSVP() ) continue; |
195 | if (!a->email().isEmpty()) { | 195 | if (!a->email().isEmpty()) { |
196 | nameList.append (a->name() ); | 196 | nameList.append (a->name() ); |
197 | emailList.append (a->email() ); | 197 | emailList.append (a->email() ); |
198 | uidList.append (a->uid() ); | 198 | uidList.append (a->uid() ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 201 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
202 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | } | 206 | } |
207 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 207 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
208 | { | 208 | { |
209 | int number=text.contains("\n"); | 209 | int number=text.contains("\n"); |
210 | QString str = "<" + tag + ">"; | 210 | QString str = "<" + tag + ">"; |
211 | QString tmpText=text; | 211 | QString tmpText=text; |
212 | QString tmpStr=str; | 212 | QString tmpStr=str; |
213 | if(number !=-1) | 213 | if(number !=-1) |
214 | { | 214 | { |
215 | if (number > 0) { | 215 | if (number > 0) { |
216 | int pos=0; | 216 | int pos=0; |
217 | QString tmp; | 217 | QString tmp; |
218 | for(int i=0;i<=number;i++) { | 218 | for(int i=0;i<=number;i++) { |
219 | pos=tmpText.find("\n"); | 219 | pos=tmpText.find("\n"); |
220 | tmp=tmpText.left(pos); | 220 | tmp=tmpText.left(pos); |
221 | tmpText=tmpText.right(tmpText.length()-pos-1); | 221 | tmpText=tmpText.right(tmpText.length()-pos-1); |
222 | tmpStr+=tmp+"<br>"; | 222 | tmpStr+=tmp+"<br>"; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | else tmpStr += tmpText; | 225 | else tmpStr += tmpText; |
226 | tmpStr+="</" + tag + ">"; | 226 | tmpStr+="</" + tag + ">"; |
227 | mText.append(tmpStr); | 227 | mText.append(tmpStr); |
228 | } | 228 | } |
229 | else | 229 | else |
230 | { | 230 | { |
231 | str += text + "</" + tag + ">"; | 231 | str += text + "</" + tag + ">"; |
232 | mText.append(str); | 232 | mText.append(str); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | void KOEventViewer::setColorMode( int m ) | 236 | void KOEventViewer::setColorMode( int m ) |
237 | { | 237 | { |
238 | mColorMode = m; | 238 | mColorMode = m; |
239 | } | 239 | } |
240 | void KOEventViewer::appendEvent(Event *event, int mode ) | 240 | void KOEventViewer::appendEvent(Event *event, int mode ) |
241 | { | 241 | { |
242 | mMailSubject = ""; | 242 | mMailSubject = ""; |
243 | mCurrentIncidence = event; | 243 | mCurrentIncidence = event; |
244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
245 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 245 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
246 | if ( mode == 0 ) { | 246 | if ( mode == 0 ) { |
247 | addTag("h2",event->summary()); | 247 | addTag("h2",event->summary()); |
248 | } | 248 | } |
249 | else { | 249 | else { |
250 | if ( mColorMode == 1 ) { | 250 | if ( mColorMode == 1 ) { |
251 | mText +="<font color=\"#00A000\">"; | 251 | mText +="<font color=\"#00A000\">"; |
252 | } | 252 | } |
253 | if ( mColorMode == 2 ) { | 253 | if ( mColorMode == 2 ) { |
254 | mText +="<font color=\"#C00000\">"; | 254 | mText +="<font color=\"#C00000\">"; |
255 | } | 255 | } |
256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
257 | if ( mode == 1 ) { | 257 | if ( mode == 1 ) { |
258 | addTag("h2",i18n( "Local: " ) +event->summary()); | 258 | addTag("h2",i18n( "Local: " ) +event->summary()); |
259 | } else { | 259 | } else { |
260 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 260 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
261 | } | 261 | } |
262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
263 | if ( mColorMode ) | 263 | if ( mColorMode ) |
264 | mText += "</font>"; | 264 | mText += "</font>"; |
265 | } | 265 | } |
266 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 266 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
267 | if (event->cancelled ()) { | 267 | if (event->cancelled ()) { |
268 | mText +="<font color=\"#B00000\">"; | 268 | mText +="<font color=\"#B00000\">"; |
269 | addTag("i",i18n("This event has been cancelled!")); | 269 | addTag("i",i18n("This event has been cancelled!")); |
270 | mText.append("<br>"); | 270 | mText.append("<br>"); |
271 | mText += "</font>"; | 271 | mText += "</font>"; |
272 | mMailSubject += i18n("(cancelled)"); | 272 | mMailSubject += i18n("(cancelled)"); |
273 | } | 273 | } |
274 | if (!event->location().isEmpty()) { | 274 | if (!event->location().isEmpty()) { |
275 | addTag("b",i18n("Location: ")); | 275 | addTag("b",i18n("Location: ")); |
276 | mText.append(event->location()+"<br>"); | 276 | mText.append(event->location()+"<br>"); |
277 | mMailSubject += i18n(" at ") + event->location(); | 277 | mMailSubject += i18n(" at ") + event->location(); |
278 | } | 278 | } |
279 | if (event->doesFloat()) { | 279 | if (event->doesFloat()) { |
280 | if (event->isMultiDay()) { | 280 | if (event->isMultiDay()) { |
281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
282 | .arg(event->dtStartDateStr(shortDate)) | 282 | .arg(event->dtStartDateStr(shortDate)) |
283 | .arg(event->dtEndDateStr(shortDate))); | 283 | .arg(event->dtEndDateStr(shortDate))); |
284 | } else { | 284 | } else { |
285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
286 | } | 286 | } |
287 | } else { | 287 | } else { |
288 | if (event->isMultiDay()) { | 288 | if (event->isMultiDay()) { |
289 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 289 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
290 | .arg(event->dtStartStr( shortDate))); | 290 | .arg(event->dtStartStr( shortDate))); |
291 | mText.append(i18n("<p><b>To:</b> %1</p>") | 291 | mText.append(i18n("<p><b>To:</b> %1</p>") |
292 | .arg(event->dtEndStr(shortDate))); | 292 | .arg(event->dtEndStr(shortDate))); |
293 | } else { | 293 | } else { |
294 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 294 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
295 | .arg(event->dtStartDateStr( shortDate ))); | 295 | .arg(event->dtStartDateStr( shortDate ))); |
296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
297 | .arg(event->dtStartTimeStr()) | 297 | .arg(event->dtStartTimeStr()) |
298 | .arg(event->dtEndTimeStr())); | 298 | .arg(event->dtEndTimeStr())); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | if (event->recurrence()->doesRecur()) { | 302 | if (event->recurrence()->doesRecur()) { |
303 | 303 | ||
304 | QString recurText = event->recurrence()->recurrenceText(); | 304 | QString recurText = event->recurrence()->recurrenceText(); |
305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
306 | bool ok; | 306 | bool ok; |
307 | QDate start = QDate::currentDate(); | 307 | QDate start = QDate::currentDate(); |
308 | QDateTime next; | 308 | QDateTime next; |
309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
310 | if ( ok ) { | 310 | if ( ok ) { |
311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
314 | 314 | ||
315 | } else { | 315 | } else { |
316 | bool last; | 316 | bool last; |
317 | QDate nextd; | 317 | QDate nextd; |
318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
319 | if ( last ) { | 319 | if ( last ) { |
320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } else { | 324 | } else { |
325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | if (event->isAlarmEnabled()) { | 330 | if (event->isAlarmEnabled()) { |
331 | Alarm *alarm =event->alarms().first() ; | 331 | Alarm *alarm =event->alarms().first() ; |
332 | QDateTime t = alarm->time(); | 332 | QDateTime t = alarm->time(); |
333 | int min = t.secsTo( event->dtStart() )/60; | 333 | int min = t.secsTo( event->dtStart() )/60; |
334 | QString s =i18n("( %1 min before )").arg( min ); | 334 | QString s =i18n("( %1 min before )").arg( min ); |
335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
337 | //addTag("p",s); | 337 | //addTag("p",s); |
338 | } | 338 | } |
339 | 339 | ||
340 | addTag("b",i18n("Access: ")); | 340 | addTag("b",i18n("Access: ")); |
341 | mText.append(event->secrecyStr()+"<br>"); | 341 | mText.append(event->secrecyStr()+"<br>"); |
342 | 342 | ||
343 | 343 | ||
344 | if ( KOPrefs::instance()->mEVshowDetails ) { | 344 | if ( KOPrefs::instance()->mEVshowDetails ) { |
345 | if (!event->description().isEmpty()) { | 345 | if (!event->description().isEmpty()) { |
346 | addTag("p",i18n("<b>Details: </b>")); | 346 | addTag("p",i18n("<b>Details: </b>")); |
347 | addTag("p",event->description()); | 347 | addTag("p",event->description()); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | formatCategories(event); | 350 | formatCategories(event); |
351 | 351 | ||
352 | formatReadOnly(event); | 352 | formatReadOnly(event); |
353 | formatAttendees(event); | 353 | formatAttendees(event); |
354 | 354 | ||
355 | if ( KOPrefs::instance()->mEVshowCreated ) { | 355 | if ( KOPrefs::instance()->mEVshowCreated ) { |
356 | addTag("p",i18n("<b>Created: ") +" </b>"); | 356 | addTag("p",i18n("<b>Created: ") +" </b>"); |
357 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 357 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
358 | 358 | ||
359 | } | 359 | } |
360 | if ( KOPrefs::instance()->mEVshowChanged ) { | 360 | if ( KOPrefs::instance()->mEVshowChanged ) { |
361 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 361 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
362 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 362 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
363 | 363 | ||
364 | } | 364 | } |
365 | setText(mText); | 365 | setText(mText); |
366 | //QWhatsThis::add(this,mText); | 366 | //QWhatsThis::add(this,mText); |
367 | 367 | ||
368 | } | 368 | } |
369 | 369 | ||
370 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 370 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
371 | { | 371 | { |
372 | mMailSubject = ""; | 372 | mMailSubject = ""; |
373 | mCurrentIncidence = event; | 373 | mCurrentIncidence = event; |
374 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 374 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
375 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 375 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
376 | if (mode == 0 ) | 376 | if (mode == 0 ) |
377 | addTag("h2",event->summary()); | 377 | addTag("h2",event->summary()); |
378 | else { | 378 | else { |
379 | if ( mColorMode == 1 ) { | 379 | if ( mColorMode == 1 ) { |
380 | mText +="<font color=\"#00A000\">"; | 380 | mText +="<font color=\"#00A000\">"; |
381 | } | 381 | } |
382 | if ( mColorMode == 2 ) { | 382 | if ( mColorMode == 2 ) { |
383 | mText +="<font color=\"#B00000\">"; | 383 | mText +="<font color=\"#B00000\">"; |
384 | } | 384 | } |
385 | if ( mode == 1 ) { | 385 | if ( mode == 1 ) { |
386 | addTag("h2",i18n( "Local: " ) +event->summary()); | 386 | addTag("h2",i18n( "Local: " ) +event->summary()); |
387 | } else { | 387 | } else { |
388 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 388 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
389 | } | 389 | } |
390 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 390 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
391 | if ( mColorMode ) | 391 | if ( mColorMode ) |
392 | mText += "</font>"; | 392 | mText += "</font>"; |
393 | } | 393 | } |
394 | mMailSubject += i18n( "Todo " )+ event->summary(); | 394 | mMailSubject += i18n( "Todo " )+ event->summary(); |
395 | 395 | ||
396 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 396 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
397 | mText +="<font color=\"#B00000\">"; | 397 | mText +="<font color=\"#B00000\">"; |
398 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 398 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
399 | mText += "</font>"; | 399 | mText += "</font>"; |
400 | } else { | 400 | } else { |
401 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 401 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
402 | .arg(event->percentComplete())); | 402 | .arg(event->percentComplete())); |
403 | } | 403 | } |
404 | 404 | ||
405 | if (event->cancelled ()) { | 405 | if (event->cancelled ()) { |
406 | mText +="<font color=\"#B00000\">"; | 406 | mText +="<font color=\"#B00000\">"; |
407 | addTag("i",i18n("This todo has been cancelled!")); | 407 | addTag("i",i18n("This todo has been cancelled!")); |
408 | mText.append("<br>"); | 408 | mText.append("<br>"); |
409 | mText += "</font>"; | 409 | mText += "</font>"; |
410 | mMailSubject += i18n("(cancelled)"); | 410 | mMailSubject += i18n("(cancelled)"); |
411 | } | 411 | } |
412 | 412 | ||
413 | if (!event->location().isEmpty()) { | 413 | if (!event->location().isEmpty()) { |
414 | addTag("b",i18n("Location: ")); | 414 | addTag("b",i18n("Location: ")); |
415 | mText.append(event->location()+"<br>"); | 415 | mText.append(event->location()+"<br>"); |
416 | mMailSubject += i18n(" at ") + event->location(); | 416 | mMailSubject += i18n(" at ") + event->location(); |
417 | } | 417 | } |
418 | 418 | ||
419 | if (event->recurrence()->doesRecur()) { | 419 | if (event->recurrence()->doesRecur()) { |
420 | 420 | ||
421 | QString recurText = event->recurrence()->recurrenceText(); | 421 | QString recurText = event->recurrence()->recurrenceText(); |
422 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 422 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
423 | 423 | ||
424 | } | 424 | } |
425 | if (event->hasStartDate()) { | 425 | if (event->hasStartDate()) { |
426 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 426 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
427 | } | 427 | } |
428 | if (event->hasDueDate()) { | 428 | if (event->hasDueDate()) { |
429 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 429 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
430 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 430 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
431 | } | 431 | } |
432 | addTag("b",i18n("Access: ")); | 432 | addTag("b",i18n("Access: ")); |
433 | mText.append(event->secrecyStr()+"<br>"); | 433 | mText.append(event->secrecyStr()+"<br>"); |
434 | if ( KOPrefs::instance()->mEVshowDetails ) { | 434 | if ( KOPrefs::instance()->mEVshowDetails ) { |
435 | if (!event->description().isEmpty()) { | 435 | if (!event->description().isEmpty()) { |
436 | addTag("p",i18n("<b>Details: </b>")); | 436 | addTag("p",i18n("<b>Details: </b>")); |
437 | addTag("p",event->description()); | 437 | addTag("p",event->description()); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | formatCategories(event); | 441 | formatCategories(event); |
442 | 442 | ||
443 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 443 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
444 | .arg(QString::number(event->priority()))); | 444 | .arg(QString::number(event->priority()))); |
445 | 445 | ||
446 | formatReadOnly(event); | 446 | formatReadOnly(event); |
447 | formatAttendees(event); | 447 | formatAttendees(event); |
448 | if ( event->relatedTo() ) { | 448 | if ( event->relatedTo() ) { |
449 | addTag("b",i18n("Parent todo:<br>")); | 449 | addTag("b",i18n("Parent todo:<br>")); |
450 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 450 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
451 | } | 451 | } |
452 | QPtrList<Incidence> Relations = event->relations(); | 452 | QPtrList<Incidence> Relations = event->relations(); |
453 | Incidence *to; | 453 | Incidence *to; |
454 | if ( Relations.first() ) | 454 | if ( Relations.first() ) |
455 | addTag("b",i18n("Sub todos:<br>")); | 455 | addTag("b",i18n("Sub todos:<br>")); |
456 | for (to=Relations.first();to;to=Relations.next()) { | 456 | for (to=Relations.first();to;to=Relations.next()) { |
457 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 457 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
458 | 458 | ||
459 | } | 459 | } |
460 | if ( KOPrefs::instance()->mEVshowCreated ) { | 460 | if ( KOPrefs::instance()->mEVshowCreated ) { |
461 | addTag("p",i18n("<b>Created: ") +" </b>"); | 461 | addTag("p",i18n("<b>Created: ") +" </b>"); |
462 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 462 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
463 | 463 | ||
464 | } | 464 | } |
465 | if ( KOPrefs::instance()->mEVshowChanged ) { | 465 | if ( KOPrefs::instance()->mEVshowChanged ) { |
466 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 466 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
467 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 467 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
468 | 468 | ||
469 | } | 469 | } |
470 | setText(mText); | 470 | setText(mText); |
471 | } | 471 | } |
472 | 472 | ||
473 | void KOEventViewer::formatCategories(Incidence *event) | 473 | void KOEventViewer::formatCategories(Incidence *event) |
474 | { | 474 | { |
475 | if (!event->categoriesStr().isEmpty()) { | 475 | if (!event->categoriesStr().isEmpty()) { |
476 | if (event->categories().count() == 1) { | 476 | if (event->categories().count() == 1) { |
477 | addTag("h3",i18n("Category")); | 477 | addTag("h3",i18n("Category")); |
478 | } else { | 478 | } else { |
479 | addTag("h3",i18n("Categories")); | 479 | addTag("h3",i18n("Categories")); |
480 | } | 480 | } |
481 | addTag("p",event->categoriesStr()); | 481 | addTag("p",event->categoriesStr()); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | void KOEventViewer::formatAttendees(Incidence *event) | 484 | void KOEventViewer::formatAttendees(Incidence *event) |
485 | { | 485 | { |
486 | QPtrList<Attendee> attendees = event->attendees(); | 486 | QPtrList<Attendee> attendees = event->attendees(); |
487 | if (attendees.count()) { | 487 | if (attendees.count()) { |
488 | 488 | ||
489 | 489 | ||
490 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 490 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
491 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 491 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
492 | addTag("h3",i18n("Organizer")); | 492 | addTag("h3",i18n("Organizer")); |
493 | mText.append("<ul><li>"); | 493 | mText.append("<ul><li>"); |
494 | #ifndef KORG_NOKABC | 494 | #ifndef KORG_NOKABC |
495 | 495 | ||
496 | #ifdef DESKTOP_VERSION | 496 | #ifdef DESKTOP_VERSION |
497 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 497 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
498 | KABC::Addressee::List addressList; | 498 | KABC::Addressee::List addressList; |
499 | addressList = add_book->findByEmail(event->organizer()); | 499 | addressList = add_book->findByEmail(event->organizer()); |
500 | KABC::Addressee o = addressList.first(); | 500 | KABC::Addressee o = addressList.first(); |
501 | if (!o.isEmpty() && addressList.size()<2) { | 501 | if (!o.isEmpty() && addressList.size()<2) { |
502 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 502 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
503 | mText += o.formattedName(); | 503 | mText += o.formattedName(); |
504 | mText += "</a>\n"; | 504 | mText += "</a>\n"; |
505 | } else { | 505 | } else { |
506 | mText.append(event->organizer()); | 506 | mText.append(event->organizer()); |
507 | } | 507 | } |
508 | #else //DESKTOP_VERSION | 508 | #else //DESKTOP_VERSION |
509 | mText += "<a href=\"uid:organizer\">"; | 509 | mText += "<a href=\"uid:organizer\">"; |
510 | mText += event->organizer(); | 510 | mText += event->organizer(); |
511 | mText += "</a>\n"; | 511 | mText += "</a>\n"; |
512 | #endif //DESKTOP_VERSION | 512 | #endif //DESKTOP_VERSION |
513 | 513 | ||
514 | 514 | ||
515 | #else | 515 | #else |
516 | mText.append(event->organizer()); | 516 | mText.append(event->organizer()); |
517 | #endif | 517 | #endif |
518 | 518 | ||
519 | if (iconPath) { | 519 | if (iconPath) { |
520 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 520 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
521 | mText += "<IMG src=\"" + iconPath + "\">"; | 521 | mText += "<IMG src=\"" + iconPath + "\">"; |
522 | mText += "</a>\n"; | 522 | mText += "</a>\n"; |
523 | } | 523 | } |
524 | mText.append("</li></ul>"); | 524 | mText.append("</li></ul>"); |
525 | 525 | ||
526 | addTag("h3",i18n("Attendees")); | 526 | addTag("h3",i18n("Attendees")); |
527 | Attendee *a; | 527 | Attendee *a; |
528 | mText.append("<ul>"); | 528 | mText.append("<ul>"); |
529 | int a_count = 0; | 529 | int a_count = 0; |
530 | int a_count_nr = 0; | 530 | int a_count_nr = 0; |
531 | 531 | ||
532 | for(a=attendees.first();a;a=attendees.next()) { | 532 | for(a=attendees.first();a;a=attendees.next()) { |
533 | #ifndef KORG_NOKABC | 533 | #ifndef KORG_NOKABC |
534 | #ifdef DESKTOP_VERSION | 534 | #ifdef DESKTOP_VERSION |
535 | if (a->name().isEmpty()) { | 535 | if (a->name().isEmpty()) { |
536 | addressList = add_book->findByEmail(a->email()); | 536 | addressList = add_book->findByEmail(a->email()); |
537 | KABC::Addressee o = addressList.first(); | 537 | KABC::Addressee o = addressList.first(); |
538 | if (!o.isEmpty() && addressList.size()<2) { | 538 | if (!o.isEmpty() && addressList.size()<2) { |
539 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 539 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
540 | mText += o.formattedName(); | 540 | mText += o.formattedName(); |
541 | mText += "</a>\n"; | 541 | mText += "</a>\n"; |
542 | } else { | 542 | } else { |
543 | mText += "<li>"; | 543 | mText += "<li>"; |
544 | mText.append(a->email()); | 544 | mText.append(a->email()); |
545 | mText += "\n"; | 545 | mText += "\n"; |
546 | } | 546 | } |
547 | } else { | 547 | } else { |
548 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 548 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
549 | if (!a->name().isEmpty()) mText += a->name(); | 549 | if (!a->name().isEmpty()) mText += a->name(); |
550 | else mText += a->email(); | 550 | else mText += a->email(); |
551 | mText += "</a>\n"; | 551 | mText += "</a>\n"; |
552 | } | 552 | } |
553 | #else //DESKTOP_VERSION | 553 | #else //DESKTOP_VERSION |
554 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 554 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
555 | if (!a->name().isEmpty()) mText += a->name(); | 555 | if (!a->name().isEmpty()) mText += a->name(); |
556 | else mText += a->email(); | 556 | else mText += a->email(); |
557 | mText += "</a>\n"; | 557 | mText += "</a>\n"; |
558 | #endif //DESKTOP_VERSION | 558 | #endif //DESKTOP_VERSION |
559 | #else | 559 | #else |
560 | //qDebug("nokabc "); | 560 | //qDebug("nokabc "); |
561 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 561 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
562 | if (!a->name().isEmpty()) mText += a->name(); | 562 | if (!a->name().isEmpty()) mText += a->name(); |
563 | else mText += a->email(); | 563 | else mText += a->email(); |
564 | mText += "</a>\n"; | 564 | mText += "</a>\n"; |
565 | #endif | 565 | #endif |
566 | 566 | ||
567 | 567 | ||
568 | if (!a->email().isEmpty()) { | 568 | if (!a->email().isEmpty()) { |
569 | if (iconPath) { | 569 | if (iconPath) { |
570 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 570 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
571 | if ( a->RSVP() ) { | 571 | if ( a->RSVP() ) { |
572 | ++a_count_nr; | 572 | ++a_count_nr; |
573 | mText += "<IMG src=\"" + iconPath + "\">"; | 573 | mText += "<IMG src=\"" + iconPath + "\">"; |
574 | } | 574 | } |
575 | else { | 575 | else { |
576 | ++a_count; | 576 | ++a_count; |
577 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 577 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
578 | } | 578 | } |
579 | mText += "</a>\n"; | 579 | mText += "</a>\n"; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | if (a->status() != Attendee::NeedsAction ) | 582 | if (a->status() != Attendee::NeedsAction ) |
583 | mText +="[" + a->statusStr() + "] "; | 583 | mText +="[" + a->statusStr() + "] "; |
584 | if (a->role() == Attendee::Chair ) | 584 | if (a->role() == Attendee::Chair ) |
585 | mText +="(" + a->roleStr().left(1) + ".)"; | 585 | mText +="(" + a->roleStr().left(1) + ".)"; |
586 | } | 586 | } |
587 | mText.append("</li></ul>"); | 587 | mText.append("</li></ul>"); |
588 | if ( (a_count+a_count_nr) > 1 ) { | 588 | if ( (a_count+a_count_nr) > 1 ) { |
589 | mText += "<a href=\"mailto:ALL\">"; | 589 | mText += "<a href=\"mailto:ALL\">"; |
590 | mText += i18n( "Mail to all" ); | 590 | mText += i18n( "Mail to all" ); |
591 | mText += "</a> ( "; | 591 | mText += "</a> ( "; |
592 | mText += "<IMG src=\"" + iconPath + "\">"; | 592 | mText += "<IMG src=\"" + iconPath + "\">"; |
593 | mText += i18n( " and " ); | 593 | mText += i18n( " and " ); |
594 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 594 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
595 | mText += "<br>\n"; | 595 | mText += "<br>\n"; |
596 | 596 | ||
597 | 597 | ||
598 | } | 598 | } |
599 | if ( a_count_nr > 1 ) { | 599 | if ( a_count_nr > 1 ) { |
600 | mText += "<a href=\"mailto:RSVP\">"; | 600 | mText += "<a href=\"mailto:RSVP\">"; |
601 | mText += i18n( "Mail to selected" ); | 601 | mText += i18n( "Mail to selected" ); |
602 | mText += "</a> ( "; | 602 | mText += "</a> ( "; |
603 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 603 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
604 | mText += "<br>\n"; | 604 | mText += "<br>\n"; |
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | } | 608 | } |
609 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 609 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
610 | { | 610 | { |
611 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 611 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
612 | if (mode == 0 ) { | 612 | if (mode == 0 ) { |
613 | addTag("h2",i18n("Journal from: ")); | 613 | addTag("h2",i18n("Journal from: ")); |
614 | } | 614 | } |
615 | else { | 615 | else { |
616 | if ( mode == 1 ) { | 616 | if ( mode == 1 ) { |
617 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 617 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
618 | } else { | 618 | } else { |
619 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 619 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | topLevelWidget()->setCaption("Journal Viewer"); | 622 | topLevelWidget()->setCaption("Journal Viewer"); |
623 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 623 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
624 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 624 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
625 | if (!jour->description().isEmpty()) { | 625 | if (!jour->description().isEmpty()) { |
626 | addTag("p",jour->description()); | 626 | addTag("p",jour->description()); |
627 | } | 627 | } |
628 | setText(mText); | 628 | setText(mText); |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOEventViewer::formatReadOnly(Incidence *event) | 631 | void KOEventViewer::formatReadOnly(Incidence *event) |
632 | { | 632 | { |
633 | if (event->isReadOnly()) { | 633 | if (event->isReadOnly()) { |
634 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 634 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | void KOEventViewer::setSyncMode( bool b ) | 637 | void KOEventViewer::setSyncMode( bool b ) |
638 | { | 638 | { |
639 | mSyncMode = b; | 639 | mSyncMode = b; |
640 | } | 640 | } |
641 | 641 | ||
642 | 642 | ||
643 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 643 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
644 | { | 644 | { |
645 | if ( clearV ) | 645 | if ( clearV ) |
646 | clearEvents(); | 646 | clearEvents(); |
647 | if ( mSyncMode ) { | 647 | if ( mSyncMode ) { |
648 | if ( clearV ) | 648 | if ( clearV ) |
649 | appendTodo(event,1 ); | 649 | appendTodo(event,1 ); |
650 | else | 650 | else |
651 | appendTodo(event,2); | 651 | appendTodo(event,2); |
652 | } else | 652 | } else |
653 | appendTodo(event); | 653 | appendTodo(event); |
654 | } | 654 | } |
655 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 655 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
656 | { | 656 | { |
657 | if ( clearV ) | 657 | if ( clearV ) |
658 | clearEvents(); | 658 | clearEvents(); |
659 | if ( mSyncMode ) { | 659 | if ( mSyncMode ) { |
660 | if ( clearV ) | 660 | if ( clearV ) |
661 | appendJournal(event, 1); | 661 | appendJournal(event, 1); |
662 | else | 662 | else |
663 | appendJournal(event, 2); | 663 | appendJournal(event, 2); |
664 | } else | 664 | } else |
665 | appendJournal(event); | 665 | appendJournal(event); |
666 | } | 666 | } |
667 | 667 | ||
668 | void KOEventViewer::setEvent(Event *event) | 668 | void KOEventViewer::setEvent(Event *event) |
669 | { | 669 | { |
670 | clearEvents(); | 670 | clearEvents(); |
671 | if ( mSyncMode ) | 671 | if ( mSyncMode ) |
672 | appendEvent(event, 1); | 672 | appendEvent(event, 1); |
673 | else | 673 | else |
674 | appendEvent(event); | 674 | appendEvent(event); |
675 | } | 675 | } |
676 | 676 | ||
677 | void KOEventViewer::addEvent(Event *event) | 677 | void KOEventViewer::addEvent(Event *event) |
678 | { | 678 | { |
679 | if ( mSyncMode ) | 679 | if ( mSyncMode ) |
680 | appendEvent(event, 2); | 680 | appendEvent(event, 2); |
681 | else | 681 | else |
682 | appendEvent(event); | 682 | appendEvent(event); |
683 | } | 683 | } |
684 | 684 | ||
685 | void KOEventViewer::clearEvents(bool now) | 685 | void KOEventViewer::clearEvents(bool now) |
686 | { | 686 | { |
687 | mText = ""; | 687 | mText = ""; |
688 | if (now) setText(mText); | 688 | if (now) setText(mText); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KOEventViewer::addText(QString text) | 691 | void KOEventViewer::addText(QString text) |
692 | { | 692 | { |
693 | mText.append(text); | 693 | mText.append(text); |
694 | setText(mText); | 694 | setText(mText); |
695 | } | 695 | } |
696 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | ||
697 | { | ||
698 | switch ( e->key() ) { | ||
699 | case Qt::Key_Return: | ||
700 | case Qt::Key_Enter : | ||
701 | e->ignore(); | ||
702 | break; | ||
703 | default: | ||
704 | QTextBrowser::keyPressEvent ( e ); | ||
705 | break; | ||
706 | } | ||
707 | } | ||
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index cf44284..d8142ca 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h | |||
@@ -1,75 +1,76 @@ | |||
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 | class KOEventViewer : public QTextBrowser { | 33 | class KOEventViewer : public QTextBrowser { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | KOEventViewer(QWidget *parent=0,const char *name=0); | 36 | KOEventViewer(QWidget *parent=0,const char *name=0); |
37 | virtual ~KOEventViewer(); | 37 | virtual ~KOEventViewer(); |
38 | 38 | ||
39 | void setSource(const QString &); | 39 | void setSource(const QString &); |
40 | void setEvent(Event *event); | 40 | void setEvent(Event *event); |
41 | void addEvent(Event *event); | 41 | void addEvent(Event *event); |
42 | void setTodo(Todo *event, bool clearV = true ); | 42 | void setTodo(Todo *event, bool clearV = true ); |
43 | void setJournal(Journal *jour, bool clearV = true ); | 43 | void setJournal(Journal *jour, bool clearV = true ); |
44 | 44 | ||
45 | void appendEvent(Event *event, int mode = 0 ); | 45 | void appendEvent(Event *event, int mode = 0 ); |
46 | void appendTodo(Todo *event, int mode = 0 ); | 46 | void appendTodo(Todo *event, int mode = 0 ); |
47 | void appendJournal(Journal *jour, int mode = 0 ); | 47 | void appendJournal(Journal *jour, int mode = 0 ); |
48 | 48 | ||
49 | void clearEvents(bool now=false); | 49 | void clearEvents(bool now=false); |
50 | 50 | ||
51 | void addText(QString text); | 51 | void addText(QString text); |
52 | void setSyncMode( bool ); | 52 | void setSyncMode( bool ); |
53 | void setColorMode( int ); | 53 | void setColorMode( int ); |
54 | void mailToAttendees( bool all ); | 54 | void mailToAttendees( bool all ); |
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | int mColorMode; | 57 | int mColorMode; |
58 | void addTag(const QString & tag,const QString & text); | 58 | void addTag(const QString & tag,const QString & text); |
59 | 59 | ||
60 | void formatCategories(Incidence *event); | 60 | void formatCategories(Incidence *event); |
61 | void formatAttendees(Incidence *event); | 61 | void formatAttendees(Incidence *event); |
62 | void formatReadOnly(Incidence *event); | 62 | void formatReadOnly(Incidence *event); |
63 | void keyPressEvent ( QKeyEvent * e ); | ||
63 | 64 | ||
64 | private: | 65 | private: |
65 | QTextBrowser *mEventTextView; | 66 | QTextBrowser *mEventTextView; |
66 | bool mSyncMode; | 67 | bool mSyncMode; |
67 | 68 | ||
68 | QString mText; | 69 | QString mText; |
69 | QString mMailSubject; | 70 | QString mMailSubject; |
70 | Incidence* mCurrentIncidence; | 71 | Incidence* mCurrentIncidence; |
71 | signals: | 72 | signals: |
72 | void launchaddressbook(QString uid); | 73 | void launchaddressbook(QString uid); |
73 | }; | 74 | }; |
74 | 75 | ||
75 | #endif | 76 | #endif |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index f6f7258..23e62d3 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,260 +1,266 @@ | |||
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 <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | 24 | ||
25 | #include "koeventviewer.h" | 25 | #include "koeventviewer.h" |
26 | #include "koprefs.h" | 26 | #include "koprefs.h" |
27 | #include <libkcal/todo.h> | 27 | #include <libkcal/todo.h> |
28 | #include "qapp.h" | 28 | #include "qapp.h" |
29 | 29 | ||
30 | #include "koeventviewerdialog.h" | 30 | #include "koeventviewerdialog.h" |
31 | extern int globalFlagBlockAgenda; | 31 | extern int globalFlagBlockAgenda; |
32 | 32 | ||
33 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 33 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
34 | : KDialogBase(parent,name, | 34 | : KDialogBase(parent,name, |
35 | #ifndef DESKTOP_VERSION | 35 | #ifndef DESKTOP_VERSION |
36 | true , | 36 | true , |
37 | #else | 37 | #else |
38 | false, | 38 | false, |
39 | #endif | 39 | #endif |
40 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 40 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
41 | { | 41 | { |
42 | 42 | ||
43 | mEventViewer = new KOEventViewer(this); | 43 | mEventViewer = new KOEventViewer(this); |
44 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 44 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
45 | setMainWidget(mEventViewer); | 45 | setMainWidget(mEventViewer); |
46 | setButtonText(Ok, i18n("Edit") ); | 46 | setButtonText(Ok, i18n("Edit") ); |
47 | 47 | ||
48 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 48 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
49 | SLOT(editIncidence())); | 49 | SLOT(editIncidence())); |
50 | QObject::connect(this,SIGNAL(user1Clicked()), | 50 | QObject::connect(this,SIGNAL(user1Clicked()), |
51 | SLOT(showIncidence())); | 51 | SLOT(showIncidence())); |
52 | mIncidence = 0; | 52 | mIncidence = 0; |
53 | // TODO: Set a sensible size (based on the content?). | 53 | // TODO: Set a sensible size (based on the content?). |
54 | //showMaximized(); | 54 | //showMaximized(); |
55 | //qDebug("++++++++++++KOEventViewerDialog() "); | 55 | //qDebug("++++++++++++KOEventViewerDialog() "); |
56 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 56 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
57 | // setFixedSize( 240,284 ); | 57 | // setFixedSize( 240,284 ); |
58 | // move( 0, 15 ); | 58 | // move( 0, 15 ); |
59 | // } else { | 59 | // } else { |
60 | // setMinimumSize(300,200); | 60 | // setMinimumSize(300,200); |
61 | // resize(320,300); | 61 | // resize(320,300); |
62 | // } | 62 | // } |
63 | mSyncMode = false; | 63 | mSyncMode = false; |
64 | mSyncResult = 0; | 64 | mSyncResult = 0; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewerDialog::~KOEventViewerDialog() | 68 | KOEventViewerDialog::~KOEventViewerDialog() |
69 | { | 69 | { |
70 | //qDebug("-------~KOEventViewerDialog() "); | 70 | //qDebug("-------~KOEventViewerDialog() "); |
71 | } | 71 | } |
72 | void KOEventViewerDialog::showMe() | 72 | void KOEventViewerDialog::showMe() |
73 | { | 73 | { |
74 | 74 | ||
75 | #ifdef DESKTOP_VERSION | 75 | #ifdef DESKTOP_VERSION |
76 | show(); | 76 | show(); |
77 | #else | 77 | #else |
78 | showMaximized(); | 78 | showMaximized(); |
79 | #endif | 79 | #endif |
80 | setFocus(); | ||
81 | setActiveWindow(); | 80 | setActiveWindow(); |
81 | mEventViewer->setFocus(); | ||
82 | 82 | ||
83 | } | 83 | } |
84 | void KOEventViewerDialog::setSyncMode( bool b ) | 84 | void KOEventViewerDialog::setSyncMode( bool b ) |
85 | { | 85 | { |
86 | mSyncMode = b; | 86 | mSyncMode = b; |
87 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 87 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
88 | if ( mSyncMode ) { | 88 | if ( mSyncMode ) { |
89 | findButton( Close )->setText( i18n("Cancel Sync")); | 89 | findButton( Close )->setText( i18n("Cancel Sync")); |
90 | findButton( Ok )->setText( i18n("Remote")); | 90 | findButton( Ok )->setText( i18n("Remote")); |
91 | findButton( User1 )->setText( i18n("Local")); | 91 | findButton( User1 )->setText( i18n("Local")); |
92 | } else { | 92 | } else { |
93 | findButton( Close )->setText( i18n("Close")); | 93 | findButton( Close )->setText( i18n("Close")); |
94 | findButton( Ok )->setText( i18n("Edit")); | 94 | findButton( Ok )->setText( i18n("Edit")); |
95 | findButton( User1 )->setText( i18n("Agenda")); | 95 | findButton( User1 )->setText( i18n("Agenda")); |
96 | } | 96 | } |
97 | mEventViewer->setSyncMode( b ); | 97 | mEventViewer->setSyncMode( b ); |
98 | } | 98 | } |
99 | void KOEventViewerDialog::setColorMode( int m ) | 99 | void KOEventViewerDialog::setColorMode( int m ) |
100 | { | 100 | { |
101 | mEventViewer->setColorMode( m ); | 101 | mEventViewer->setColorMode( m ); |
102 | } | 102 | } |
103 | int KOEventViewerDialog::executeS( bool local ) | 103 | int KOEventViewerDialog::executeS( bool local ) |
104 | { | 104 | { |
105 | mSyncResult = 3; | 105 | mSyncResult = 3; |
106 | if ( local ) | 106 | if ( local ) |
107 | findButton( User1 )->setFocus(); | 107 | findButton( User1 )->setFocus(); |
108 | else | 108 | else |
109 | findButton( Ok )->setFocus(); | 109 | findButton( Ok )->setFocus(); |
110 | exec(); | 110 | exec(); |
111 | return mSyncResult; | 111 | return mSyncResult; |
112 | } | 112 | } |
113 | 113 | ||
114 | void KOEventViewerDialog::updateConfig() | 114 | void KOEventViewerDialog::updateConfig() |
115 | { | 115 | { |
116 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 116 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
117 | 117 | ||
118 | } | 118 | } |
119 | void KOEventViewerDialog::setEvent(Event *event) | 119 | void KOEventViewerDialog::setEvent(Event *event) |
120 | { | 120 | { |
121 | mEventViewer->setEvent(event); | 121 | mEventViewer->setEvent(event); |
122 | mIncidence = event; | 122 | mIncidence = event; |
123 | findButton( Close )->setFocus(); | 123 | mEventViewer->setFocus(); |
124 | //findButton( Close )->setFocus(); | ||
124 | if ( !mSyncMode ) { | 125 | if ( !mSyncMode ) { |
125 | findButton( User1 )->setText( i18n("Agenda")); | 126 | findButton( User1 )->setText( i18n("Agenda")); |
126 | } | 127 | } |
127 | } | 128 | } |
128 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 129 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
129 | { | 130 | { |
130 | if ( in->type() == "Event" ) | 131 | if ( in->type() == "Event" ) |
131 | setEvent( (Event*) in ); | 132 | setEvent( (Event*) in ); |
132 | else if ( in->type() =="Todo" ) | 133 | else if ( in->type() =="Todo" ) |
133 | setTodo( (Todo*) in ); | 134 | setTodo( (Todo*) in ); |
134 | else if ( in->type() =="Journal" ) | 135 | else if ( in->type() =="Journal" ) |
135 | setJournal( (Journal*) in ); | 136 | setJournal( (Journal*) in ); |
136 | } | 137 | } |
137 | void KOEventViewerDialog::addIncidence(Incidence *in) | 138 | void KOEventViewerDialog::addIncidence(Incidence *in) |
138 | { | 139 | { |
139 | if ( in->type() == "Event" ) | 140 | if ( in->type() == "Event" ) |
140 | addEvent( (Event*) in ); | 141 | addEvent( (Event*) in ); |
141 | else if ( in->type() =="Todo" ) | 142 | else if ( in->type() =="Todo" ) |
142 | mEventViewer->setTodo( (Todo*) in, false ); | 143 | mEventViewer->setTodo( (Todo*) in, false ); |
143 | else if ( in->type() =="Journal" ) | 144 | else if ( in->type() =="Journal" ) |
144 | mEventViewer->setJournal( (Journal*) in, false ); | 145 | mEventViewer->setJournal( (Journal*) in, false ); |
145 | if ( mSyncMode ) { | 146 | if ( mSyncMode ) { |
146 | findButton( User1 )->setFocus(); | 147 | findButton( User1 )->setFocus(); |
147 | setCaption(i18n("Conflict! Please choose entry")); | 148 | setCaption(i18n("Conflict! Please choose entry")); |
148 | } | 149 | } |
149 | } | 150 | } |
150 | 151 | ||
151 | void KOEventViewerDialog::addEvent(Event *event) | 152 | void KOEventViewerDialog::addEvent(Event *event) |
152 | { | 153 | { |
153 | mEventViewer->addEvent(event); | 154 | mEventViewer->addEvent(event); |
154 | mIncidence = event; | 155 | mIncidence = event; |
155 | findButton( Close )->setFocus(); | 156 | mEventViewer->setFocus(); |
157 | //findButton( Close )->setFocus(); | ||
156 | if ( !mSyncMode ) { | 158 | if ( !mSyncMode ) { |
157 | findButton( User1 )->setText( i18n("Agenda")); | 159 | findButton( User1 )->setText( i18n("Agenda")); |
158 | } | 160 | } |
159 | } | 161 | } |
160 | 162 | ||
161 | void KOEventViewerDialog::setTodo(Todo *event) | 163 | void KOEventViewerDialog::setTodo(Todo *event) |
162 | { | 164 | { |
163 | mEventViewer->setTodo(event); | 165 | mEventViewer->setTodo(event); |
164 | mIncidence = (Incidence*)event; | 166 | mIncidence = (Incidence*)event; |
165 | findButton( Close )->setFocus(); | 167 | mEventViewer->setFocus(); |
168 | //findButton( Close )->setFocus(); | ||
166 | if ( !mSyncMode ) { | 169 | if ( !mSyncMode ) { |
167 | findButton( User1 )->setText( i18n("Set complete")); | 170 | findButton( User1 )->setText( i18n("Set complete")); |
168 | } | 171 | } |
169 | } | 172 | } |
170 | void KOEventViewerDialog::setJournal(Journal *j) | 173 | void KOEventViewerDialog::setJournal(Journal *j) |
171 | { | 174 | { |
172 | mEventViewer->setJournal(j); | 175 | mEventViewer->setJournal(j); |
173 | mIncidence = (Incidence*)j; | 176 | mIncidence = (Incidence*)j; |
174 | findButton( Close )->setFocus(); | 177 | mEventViewer->setFocus(); |
178 | //findButton( Close )->setFocus(); | ||
175 | if ( !mSyncMode ) { | 179 | if ( !mSyncMode ) { |
176 | findButton( User1 )->setText( i18n("Agenda")); | 180 | findButton( User1 )->setText( i18n("Agenda")); |
177 | } | 181 | } |
178 | } | 182 | } |
179 | 183 | ||
180 | void KOEventViewerDialog::addText(QString text) | 184 | void KOEventViewerDialog::addText(QString text) |
181 | { | 185 | { |
182 | mEventViewer->addText(text); | 186 | mEventViewer->addText(text); |
183 | findButton( Close )->setFocus(); | 187 | mEventViewer->setFocus(); |
188 | //findButton( Close )->setFocus(); | ||
184 | } | 189 | } |
185 | void KOEventViewerDialog::editIncidence() | 190 | void KOEventViewerDialog::editIncidence() |
186 | { | 191 | { |
187 | if ( mSyncMode ) { | 192 | if ( mSyncMode ) { |
188 | mSyncResult = 2; | 193 | mSyncResult = 2; |
189 | accept(); | 194 | accept(); |
190 | return; | 195 | return; |
191 | } | 196 | } |
192 | if ( mIncidence ){ | 197 | if ( mIncidence ){ |
193 | #ifndef DESKTOP_VERSION | 198 | #ifndef DESKTOP_VERSION |
194 | hide(); | 199 | hide(); |
195 | #endif | 200 | #endif |
196 | emit editIncidence( mIncidence ); | 201 | emit editIncidence( mIncidence ); |
197 | } | 202 | } |
198 | } | 203 | } |
199 | void KOEventViewerDialog::showIncidence() | 204 | void KOEventViewerDialog::showIncidence() |
200 | { | 205 | { |
201 | 206 | ||
202 | if ( mSyncMode ) { | 207 | if ( mSyncMode ) { |
203 | mSyncResult = 1; | 208 | mSyncResult = 1; |
204 | accept(); | 209 | accept(); |
205 | return; | 210 | return; |
206 | } | 211 | } |
207 | 212 | ||
208 | if ( mIncidence ){ | 213 | if ( mIncidence ){ |
209 | #ifndef DESKTOP_VERSION | 214 | #ifndef DESKTOP_VERSION |
210 | hide(); | 215 | hide(); |
211 | #endif | 216 | #endif |
212 | QDate date; | 217 | QDate date; |
213 | if ( mIncidence->type() == "Todo" ) { | 218 | if ( mIncidence->type() == "Todo" ) { |
214 | /* | 219 | /* |
215 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 220 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
216 | date = ((Todo*)mIncidence)->dtDue().date(); | 221 | date = ((Todo*)mIncidence)->dtDue().date(); |
217 | else { | 222 | else { |
218 | globalFlagBlockAgenda = 2; | 223 | globalFlagBlockAgenda = 2; |
219 | emit showAgendaView( false ); | 224 | emit showAgendaView( false ); |
220 | return; | 225 | return; |
221 | } | 226 | } |
222 | */ | 227 | */ |
223 | ((Todo*)mIncidence)->setCompleted( true ); | 228 | ((Todo*)mIncidence)->setCompleted( true ); |
224 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 229 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
225 | hide(); | 230 | hide(); |
226 | emit todoCompleted(((Todo*)mIncidence)); | 231 | emit todoCompleted(((Todo*)mIncidence)); |
227 | return; | 232 | return; |
228 | 233 | ||
229 | } else | 234 | } else |
230 | date = mIncidence->dtStart().date(); | 235 | date = mIncidence->dtStart().date(); |
231 | globalFlagBlockAgenda = 1; | 236 | globalFlagBlockAgenda = 1; |
232 | emit showAgendaView( false ); | 237 | emit showAgendaView( false ); |
233 | globalFlagBlockAgenda = 2; | 238 | globalFlagBlockAgenda = 2; |
234 | emit jumpToTime( date ); | 239 | emit jumpToTime( date ); |
235 | } | 240 | } |
236 | } | 241 | } |
237 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 242 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
238 | { | 243 | { |
239 | switch ( e->key() ) { | 244 | switch ( e->key() ) { |
240 | 245 | ||
241 | case Qt::Key_A : | 246 | case Qt::Key_A : |
242 | case Qt::Key_L : | 247 | case Qt::Key_L : |
243 | showIncidence(); | 248 | showIncidence(); |
244 | break; | 249 | break; |
245 | case Qt::Key_E : | 250 | case Qt::Key_E : |
246 | case Qt::Key_R : | 251 | case Qt::Key_R : |
247 | editIncidence(); | 252 | editIncidence(); |
248 | break; | 253 | break; |
249 | case Qt::Key_C: | 254 | case Qt::Key_C: |
250 | case Qt::Key_Escape: | 255 | case Qt::Key_Escape: |
251 | close(); | 256 | close(); |
252 | break; | 257 | break; |
253 | case Qt::Key_I: | 258 | case Qt::Key_I: |
254 | accept(); | 259 | accept(); |
255 | break; | 260 | break; |
256 | default: | 261 | default: |
262 | KDialogBase::keyPressEvent ( e ); | ||
257 | break; | 263 | break; |
258 | } | 264 | } |
259 | 265 | ||
260 | } | 266 | } |
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index aa1b244..cef59a2 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -1,405 +1,405 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qgroupbox.h> | 27 | #include <qgroupbox.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | 32 | ||
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkdepim/kdateedit.h> | 36 | #include <libkdepim/kdateedit.h> |
37 | 37 | ||
38 | #include "koglobals.h" | 38 | #include "koglobals.h" |
39 | #include "koprefs.h" | 39 | #include "koprefs.h" |
40 | 40 | ||
41 | #include "calendarview.h" | 41 | #include "calendarview.h" |
42 | #include "koviewmanager.h" | 42 | #include "koviewmanager.h" |
43 | #include "searchdialog.h" | 43 | #include "searchdialog.h" |
44 | 44 | ||
45 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | 45 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) |
46 | : QVBox( 0 ) | 46 | : QVBox( 0 ) |
47 | 47 | ||
48 | { | 48 | { |
49 | mCalendar = calendar; | 49 | mCalendar = calendar; |
50 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); | 50 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); |
51 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); | 51 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); |
52 | 52 | ||
53 | // Search expression | 53 | // Search expression |
54 | QHBoxLayout *subLayout = new QHBoxLayout(); | 54 | QHBoxLayout *subLayout = new QHBoxLayout(); |
55 | layout->addLayout(subLayout); | 55 | layout->addLayout(subLayout); |
56 | searchLabel = new QLabel(topFrame); | 56 | searchLabel = new QLabel(topFrame); |
57 | searchLabel->setText(i18n("Search for:")); | 57 | searchLabel->setText(i18n("Search for:")); |
58 | subLayout->addWidget(searchLabel); | 58 | subLayout->addWidget(searchLabel); |
59 | 59 | ||
60 | searchEdit = new QLineEdit(topFrame); | 60 | searchEdit = new QLineEdit(topFrame); |
61 | subLayout->addWidget(searchEdit); | 61 | subLayout->addWidget(searchEdit); |
62 | QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); | 62 | QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); |
63 | //OkButton->setDefault( true ); | 63 | //OkButton->setDefault( true ); |
64 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); | 64 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); |
65 | subLayout->addWidget(OkButton); | 65 | subLayout->addWidget(OkButton); |
66 | searchEdit->setText("*"); // Find all events by default | 66 | searchEdit->setText("*"); // Find all events by default |
67 | searchEdit->setFocus(); | 67 | searchEdit->setFocus(); |
68 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 68 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
69 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); | 69 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); |
70 | // Subjects to search | 70 | // Subjects to search |
71 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), | 71 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), |
72 | // topFrame); | 72 | // topFrame); |
73 | 73 | ||
74 | QHBox *incidenceGroup = new QHBox( topFrame ); | 74 | QHBox *incidenceGroup = new QHBox( topFrame ); |
75 | layout->addWidget(incidenceGroup); | 75 | layout->addWidget(incidenceGroup); |
76 | 76 | ||
77 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); | 77 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); |
78 | mSearchEvent->setChecked(true); | 78 | mSearchEvent->setChecked(true); |
79 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); | 79 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); |
80 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); | 80 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); |
81 | 81 | ||
82 | QHBox *subjectGroup = new QHBox( topFrame ); | 82 | QHBox *subjectGroup = new QHBox( topFrame ); |
83 | layout->addWidget(subjectGroup); | 83 | layout->addWidget(subjectGroup); |
84 | 84 | ||
85 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); | 85 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); |
86 | mSummaryCheck->setChecked(true); | 86 | mSummaryCheck->setChecked(true); |
87 | mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); | 87 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); |
88 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); | 88 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); |
89 | 89 | ||
90 | QHBox *attendeeGroup = new QHBox( topFrame ); | 90 | QHBox *attendeeGroup = new QHBox( topFrame ); |
91 | layout->addWidget(attendeeGroup ); | 91 | layout->addWidget(attendeeGroup ); |
92 | new QLabel( i18n("Attendee:"),attendeeGroup ); | 92 | new QLabel( i18n("Attendee:"),attendeeGroup ); |
93 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); | 93 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); |
94 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); | 94 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); |
95 | // Date range | 95 | // Date range |
96 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), | 96 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), |
97 | // topFrame); | 97 | // topFrame); |
98 | // layout->addWidget(rangeGroup); | 98 | // layout->addWidget(rangeGroup); |
99 | 99 | ||
100 | QWidget *rangeWidget = new QWidget(topFrame); | 100 | QWidget *rangeWidget = new QWidget(topFrame); |
101 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); | 101 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); |
102 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); | 102 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); |
103 | mStartDate = new KDateEdit(rangeWidget); | 103 | mStartDate = new KDateEdit(rangeWidget); |
104 | rangeLayout->addWidget(mStartDate); | 104 | rangeLayout->addWidget(mStartDate); |
105 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); | 105 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); |
106 | mEndDate = new KDateEdit(rangeWidget); | 106 | mEndDate = new KDateEdit(rangeWidget); |
107 | mEndDate->setDate(QDate::currentDate().addDays(365)); | 107 | mEndDate->setDate(QDate::currentDate().addDays(365)); |
108 | rangeLayout->addWidget(mEndDate); | 108 | rangeLayout->addWidget(mEndDate); |
109 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); | 109 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); |
110 | rangeLayout->addWidget( (QWidget*)wt ); | 110 | rangeLayout->addWidget( (QWidget*)wt ); |
111 | layout->addWidget(rangeWidget); | 111 | layout->addWidget(rangeWidget); |
112 | // Results list view | 112 | // Results list view |
113 | listView = new KOListView(mCalendar,topFrame); | 113 | listView = new KOListView(mCalendar,topFrame); |
114 | layout->addWidget(listView); | 114 | layout->addWidget(listView); |
115 | 115 | ||
116 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); | 116 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); |
117 | 117 | ||
118 | setCaption( i18n("KO/Pi Find: ")); | 118 | setCaption( i18n("KO/Pi Find: ")); |
119 | #ifdef DESKTOP_VERSION | 119 | #ifdef DESKTOP_VERSION |
120 | OkButton = new QPushButton( i18n("Close"), this ); | 120 | OkButton = new QPushButton( i18n("Close"), this ); |
121 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); | 121 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); |
122 | #endif | 122 | #endif |
123 | } | 123 | } |
124 | 124 | ||
125 | SearchDialog::~SearchDialog() | 125 | SearchDialog::~SearchDialog() |
126 | { | 126 | { |
127 | 127 | ||
128 | } | 128 | } |
129 | void SearchDialog::accept() | 129 | void SearchDialog::accept() |
130 | { | 130 | { |
131 | doSearch(); | 131 | doSearch(); |
132 | } | 132 | } |
133 | void SearchDialog::updateList() | 133 | void SearchDialog::updateList() |
134 | { | 134 | { |
135 | //listView->updateList(); | 135 | //listView->updateList(); |
136 | if ( isVisible() ) { | 136 | if ( isVisible() ) { |
137 | updateView(); | 137 | updateView(); |
138 | //qDebug("SearchDialog::updated "); | 138 | //qDebug("SearchDialog::updated "); |
139 | } | 139 | } |
140 | else { | 140 | else { |
141 | listView->clear(); | 141 | listView->clear(); |
142 | //qDebug("SearchDialog::cleared "); | 142 | //qDebug("SearchDialog::cleared "); |
143 | 143 | ||
144 | } | 144 | } |
145 | } | 145 | } |
146 | void SearchDialog::searchTextChanged( const QString &_text ) | 146 | void SearchDialog::searchTextChanged( const QString &_text ) |
147 | { | 147 | { |
148 | #if 0 | 148 | #if 0 |
149 | enableButton( KDialogBase::User1, !_text.isEmpty() ); | 149 | enableButton( KDialogBase::User1, !_text.isEmpty() ); |
150 | #endif | 150 | #endif |
151 | } | 151 | } |
152 | 152 | ||
153 | void SearchDialog::doSearch() | 153 | void SearchDialog::doSearch() |
154 | { | 154 | { |
155 | QRegExp re; | 155 | QRegExp re; |
156 | 156 | ||
157 | re.setWildcard(true); // most people understand these better. | 157 | re.setWildcard(true); // most people understand these better. |
158 | re.setCaseSensitive(false); | 158 | re.setCaseSensitive(false); |
159 | re.setPattern(searchEdit->text()); | 159 | re.setPattern(searchEdit->text()); |
160 | if (!re.isValid() ) { | 160 | if (!re.isValid() ) { |
161 | KMessageBox::sorry(this, | 161 | KMessageBox::sorry(this, |
162 | i18n("Invalid search expression,\ncannot perform " | 162 | i18n("Invalid search expression,\ncannot perform " |
163 | "the search.\nPlease enter a search expression\n" | 163 | "the search.\nPlease enter a search expression\n" |
164 | "using the wildcard characters\n '*' and '?'" | 164 | "using the wildcard characters\n '*' and '?'" |
165 | "where needed.")); | 165 | "where needed.")); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | 168 | ||
169 | search(re); | 169 | search(re); |
170 | 170 | ||
171 | listView->setStartDate( mStartDate->date() ); | 171 | listView->setStartDate( mStartDate->date() ); |
172 | listView->showEvents(mMatchedEvents); | 172 | listView->showEvents(mMatchedEvents); |
173 | listView->addTodos(mMatchedTodos); | 173 | listView->addTodos(mMatchedTodos); |
174 | listView->addJournals(mMatchedJournals); | 174 | listView->addJournals(mMatchedJournals); |
175 | 175 | ||
176 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { | 176 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { |
177 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); | 177 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); |
178 | } else { | 178 | } else { |
179 | QString mess; | 179 | QString mess; |
180 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); | 180 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); |
181 | setCaption( i18n("KO/Pi Find: ") + mess); | 181 | setCaption( i18n("KO/Pi Find: ") + mess); |
182 | 182 | ||
183 | } | 183 | } |
184 | searchEdit->setFocus(); | 184 | searchEdit->setFocus(); |
185 | } | 185 | } |
186 | void SearchDialog::updateConfig() | 186 | void SearchDialog::updateConfig() |
187 | { | 187 | { |
188 | listView->updateConfig(); | 188 | listView->updateConfig(); |
189 | } | 189 | } |
190 | void SearchDialog::updateView() | 190 | void SearchDialog::updateView() |
191 | { | 191 | { |
192 | 192 | ||
193 | QRegExp re; | 193 | QRegExp re; |
194 | re.setWildcard(true); // most people understand these better. | 194 | re.setWildcard(true); // most people understand these better. |
195 | re.setCaseSensitive(false); | 195 | re.setCaseSensitive(false); |
196 | re.setPattern(searchEdit->text()); | 196 | re.setPattern(searchEdit->text()); |
197 | if (re.isValid()) { | 197 | if (re.isValid()) { |
198 | search(re); | 198 | search(re); |
199 | } else { | 199 | } else { |
200 | mMatchedEvents.clear(); | 200 | mMatchedEvents.clear(); |
201 | mMatchedTodos.clear(); | 201 | mMatchedTodos.clear(); |
202 | mMatchedJournals.clear(); | 202 | mMatchedJournals.clear(); |
203 | } | 203 | } |
204 | listView->setStartDate( mStartDate->date() ); | 204 | listView->setStartDate( mStartDate->date() ); |
205 | listView->showEvents(mMatchedEvents); | 205 | listView->showEvents(mMatchedEvents); |
206 | listView->addTodos(mMatchedTodos); | 206 | listView->addTodos(mMatchedTodos); |
207 | listView->addJournals(mMatchedJournals); | 207 | listView->addJournals(mMatchedJournals); |
208 | } | 208 | } |
209 | 209 | ||
210 | void SearchDialog::search(const QRegExp &re) | 210 | void SearchDialog::search(const QRegExp &re) |
211 | { | 211 | { |
212 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), | 212 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), |
213 | mEndDate->date(), | 213 | mEndDate->date(), |
214 | false /*mInclusiveCheck->isChecked()*/ ); | 214 | false /*mInclusiveCheck->isChecked()*/ ); |
215 | 215 | ||
216 | mMatchedEvents.clear(); | 216 | mMatchedEvents.clear(); |
217 | if ( mSearchEvent->isChecked() ) { | 217 | if ( mSearchEvent->isChecked() ) { |
218 | Event *ev; | 218 | Event *ev; |
219 | for(ev=events.first();ev;ev=events.next()) { | 219 | for(ev=events.first();ev;ev=events.next()) { |
220 | if (mSummaryCheck->isChecked()) { | 220 | if (mSummaryCheck->isChecked()) { |
221 | #if QT_VERSION >= 0x030000 | 221 | #if QT_VERSION >= 0x030000 |
222 | if (re.search(ev->summary()) != -1) | 222 | if (re.search(ev->summary()) != -1) |
223 | #else | 223 | #else |
224 | if (re.match(ev->summary()) != -1) | 224 | if (re.match(ev->summary()) != -1) |
225 | #endif | 225 | #endif |
226 | { | 226 | { |
227 | mMatchedEvents.append(ev); | 227 | mMatchedEvents.append(ev); |
228 | continue; | 228 | continue; |
229 | } | 229 | } |
230 | #if QT_VERSION >= 0x030000 | 230 | #if QT_VERSION >= 0x030000 |
231 | if (re.search(ev->location()) != -1) | 231 | if (re.search(ev->location()) != -1) |
232 | #else | 232 | #else |
233 | if (re.match(ev->location()) != -1) | 233 | if (re.match(ev->location()) != -1) |
234 | #endif | 234 | #endif |
235 | { | 235 | { |
236 | mMatchedEvents.append(ev); | 236 | mMatchedEvents.append(ev); |
237 | continue; | 237 | continue; |
238 | } | 238 | } |
239 | } | 239 | } |
240 | if (mDescriptionCheck->isChecked()) { | 240 | if (mDescriptionCheck->isChecked()) { |
241 | #if QT_VERSION >= 0x030000 | 241 | #if QT_VERSION >= 0x030000 |
242 | if (re.search(ev->description()) != -1) | 242 | if (re.search(ev->description()) != -1) |
243 | #else | 243 | #else |
244 | if (re.match(ev->description()) != -1) | 244 | if (re.match(ev->description()) != -1) |
245 | #endif | 245 | #endif |
246 | { | 246 | { |
247 | mMatchedEvents.append(ev); | 247 | mMatchedEvents.append(ev); |
248 | continue; | 248 | continue; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | if (mCategoryCheck->isChecked()) { | 251 | if (mCategoryCheck->isChecked()) { |
252 | #if QT_VERSION >= 0x030000 | 252 | #if QT_VERSION >= 0x030000 |
253 | if (re.search(ev->categoriesStr()) != -1) | 253 | if (re.search(ev->categoriesStr()) != -1) |
254 | #else | 254 | #else |
255 | if (re.match(ev->categoriesStr()) != -1) | 255 | if (re.match(ev->categoriesStr()) != -1) |
256 | #endif | 256 | #endif |
257 | { | 257 | { |
258 | mMatchedEvents.append(ev); | 258 | mMatchedEvents.append(ev); |
259 | continue; | 259 | continue; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 262 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
263 | QPtrList<Attendee> tmpAList = ev->attendees(); | 263 | QPtrList<Attendee> tmpAList = ev->attendees(); |
264 | Attendee *a; | 264 | Attendee *a; |
265 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 265 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
266 | if (mSearchAName->isChecked()) { | 266 | if (mSearchAName->isChecked()) { |
267 | #if QT_VERSION >= 0x030000 | 267 | #if QT_VERSION >= 0x030000 |
268 | if (re.search(a->name()) != -1) | 268 | if (re.search(a->name()) != -1) |
269 | #else | 269 | #else |
270 | if (re.match(a->name()) != -1) | 270 | if (re.match(a->name()) != -1) |
271 | #endif | 271 | #endif |
272 | { | 272 | { |
273 | mMatchedEvents.append(ev); | 273 | mMatchedEvents.append(ev); |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | if (mSearchAEmail->isChecked()) { | 277 | if (mSearchAEmail->isChecked()) { |
278 | #if QT_VERSION >= 0x030000 | 278 | #if QT_VERSION >= 0x030000 |
279 | if (re.search(a->email()) != -1) | 279 | if (re.search(a->email()) != -1) |
280 | #else | 280 | #else |
281 | if (re.match(a->email()) != -1) | 281 | if (re.match(a->email()) != -1) |
282 | #endif | 282 | #endif |
283 | { | 283 | { |
284 | mMatchedEvents.append(ev); | 284 | mMatchedEvents.append(ev); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | } | 291 | } |
292 | QPtrList<Todo> todos = mCalendar->todos( ); | 292 | QPtrList<Todo> todos = mCalendar->todos( ); |
293 | mMatchedTodos.clear(); | 293 | mMatchedTodos.clear(); |
294 | if ( mSearchTodo->isChecked() ) { | 294 | if ( mSearchTodo->isChecked() ) { |
295 | Todo *tod; | 295 | Todo *tod; |
296 | for(tod=todos.first();tod;tod=todos.next()) { | 296 | for(tod=todos.first();tod;tod=todos.next()) { |
297 | if (mSummaryCheck->isChecked()) { | 297 | if (mSummaryCheck->isChecked()) { |
298 | #if QT_VERSION >= 0x030000 | 298 | #if QT_VERSION >= 0x030000 |
299 | if (re.search(tod->summary()) != -1) | 299 | if (re.search(tod->summary()) != -1) |
300 | #else | 300 | #else |
301 | if (re.match(tod->summary()) != -1) | 301 | if (re.match(tod->summary()) != -1) |
302 | #endif | 302 | #endif |
303 | { | 303 | { |
304 | mMatchedTodos.append(tod); | 304 | mMatchedTodos.append(tod); |
305 | continue; | 305 | continue; |
306 | } | 306 | } |
307 | } | 307 | } |
308 | if (mDescriptionCheck->isChecked()) { | 308 | if (mDescriptionCheck->isChecked()) { |
309 | #if QT_VERSION >= 0x030000 | 309 | #if QT_VERSION >= 0x030000 |
310 | if (re.search(tod->description()) != -1) | 310 | if (re.search(tod->description()) != -1) |
311 | #else | 311 | #else |
312 | if (re.match(tod->description()) != -1) | 312 | if (re.match(tod->description()) != -1) |
313 | #endif | 313 | #endif |
314 | { | 314 | { |
315 | mMatchedTodos.append(tod); | 315 | mMatchedTodos.append(tod); |
316 | continue; | 316 | continue; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | if (mCategoryCheck->isChecked()) { | 319 | if (mCategoryCheck->isChecked()) { |
320 | #if QT_VERSION >= 0x030000 | 320 | #if QT_VERSION >= 0x030000 |
321 | if (re.search(tod->categoriesStr()) != -1) | 321 | if (re.search(tod->categoriesStr()) != -1) |
322 | #else | 322 | #else |
323 | if (re.match(tod->categoriesStr()) != -1) | 323 | if (re.match(tod->categoriesStr()) != -1) |
324 | #endif | 324 | #endif |
325 | { | 325 | { |
326 | mMatchedTodos.append(tod); | 326 | mMatchedTodos.append(tod); |
327 | continue; | 327 | continue; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 330 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
331 | QPtrList<Attendee> tmpAList = tod->attendees(); | 331 | QPtrList<Attendee> tmpAList = tod->attendees(); |
332 | Attendee *a; | 332 | Attendee *a; |
333 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 333 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
334 | if (mSearchAName->isChecked()) { | 334 | if (mSearchAName->isChecked()) { |
335 | #if QT_VERSION >= 0x030000 | 335 | #if QT_VERSION >= 0x030000 |
336 | if (re.search(a->name()) != -1) | 336 | if (re.search(a->name()) != -1) |
337 | #else | 337 | #else |
338 | if (re.match(a->name()) != -1) | 338 | if (re.match(a->name()) != -1) |
339 | #endif | 339 | #endif |
340 | { | 340 | { |
341 | mMatchedTodos.append(tod); | 341 | mMatchedTodos.append(tod); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | if (mSearchAEmail->isChecked()) { | 345 | if (mSearchAEmail->isChecked()) { |
346 | #if QT_VERSION >= 0x030000 | 346 | #if QT_VERSION >= 0x030000 |
347 | if (re.search(a->email()) != -1) | 347 | if (re.search(a->email()) != -1) |
348 | #else | 348 | #else |
349 | if (re.match(a->email()) != -1) | 349 | if (re.match(a->email()) != -1) |
350 | #endif | 350 | #endif |
351 | { | 351 | { |
352 | mMatchedTodos.append(tod); | 352 | mMatchedTodos.append(tod); |
353 | break; | 353 | break; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | mMatchedJournals.clear(); | 360 | mMatchedJournals.clear(); |
361 | if (mSearchJournal->isChecked() ) { | 361 | if (mSearchJournal->isChecked() ) { |
362 | QPtrList<Journal> journals = mCalendar->journals( ); | 362 | QPtrList<Journal> journals = mCalendar->journals( ); |
363 | Journal* journ; | 363 | Journal* journ; |
364 | 364 | ||
365 | for(journ=journals.first();journ;journ=journals.next()) { | 365 | for(journ=journals.first();journ;journ=journals.next()) { |
366 | if ( journ->dtStart().date() <= mEndDate->date() | 366 | if ( journ->dtStart().date() <= mEndDate->date() |
367 | &&journ->dtStart().date() >= mStartDate->date()) { | 367 | &&journ->dtStart().date() >= mStartDate->date()) { |
368 | #if QT_VERSION >= 0x030000 | 368 | #if QT_VERSION >= 0x030000 |
369 | if (re.search(journ->description()) != -1) | 369 | if (re.search(journ->description()) != -1) |
370 | #else | 370 | #else |
371 | if (re.match(journ->description()) != -1) | 371 | if (re.match(journ->description()) != -1) |
372 | #endif | 372 | #endif |
373 | { | 373 | { |
374 | mMatchedJournals.append(journ); | 374 | mMatchedJournals.append(journ); |
375 | continue; | 375 | continue; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | } | 381 | } |
382 | 382 | ||
383 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 383 | void SearchDialog::keyPressEvent ( QKeyEvent *e) |
384 | { | 384 | { |
385 | switch ( e->key() ) { | 385 | switch ( e->key() ) { |
386 | case Qt::Key_Escape: | 386 | case Qt::Key_Escape: |
387 | hide(); | 387 | hide(); |
388 | break; | 388 | break; |
389 | case Qt::Key_F: | 389 | case Qt::Key_F: |
390 | if ( e->state() == Qt::ControlButton ) { | 390 | if ( e->state() == Qt::ControlButton ) { |
391 | qDebug("full "); | 391 | qDebug("full "); |
392 | 392 | ||
393 | } | 393 | } |
394 | break; | 394 | break; |
395 | case Qt::Key_Return: | 395 | case Qt::Key_Return: |
396 | case Qt::Key_Enter: | 396 | case Qt::Key_Enter: |
397 | doSearch(); | 397 | doSearch(); |
398 | break; | 398 | break; |
399 | 399 | ||
400 | default: | 400 | default: |
401 | e->ignore(); | 401 | e->ignore(); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | //mMatchedJournals; | 405 | //mMatchedJournals; |