summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp401
-rw-r--r--kabc/addresseeview.h60
-rw-r--r--kabc/kabc.pro2
-rw-r--r--kabc/kabcE.pro2
-rw-r--r--kaddressbook/details/look_html.cpp2
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/kaddressbookE.pro6
-rw-r--r--kaddressbook/xxportmanager.cpp2
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/incomingdialog.cpp3
-rw-r--r--korganizer/korganizerE.pro4
-rw-r--r--korganizer/publishdialog.cpp3
-rw-r--r--libkdepim/libkdepim.pro2
-rw-r--r--libkdepim/libkdepimE.pro2
14 files changed, 482 insertions, 13 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
new file mode 100644
index 0000000..b4717d7
--- a/dev/null
+++ b/kabc/addresseeview.cpp
@@ -0,0 +1,401 @@
1/*
2 This file is part of libkdepim.
3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#include <kabc/address.h>
23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h>
25#include <kglobal.h>
26//US#include <kglobalsettings.h>
27#include <kiconloader.h>
28#include <klocale.h>
29//US #include <kstringhandler.h>
30#include <qscrollview.h>
31#include <qregexp.h>
32#include <qfile.h>
33#include <qapplication.h>
34
35
36#include "externalapphandler.h"
37#include "addresseeview.h"
38
39
40//US #ifndef DESKTOP_VERSION
41//US #include <qtopia/qcopenvelope_qws.h>
42//US #include <qpe/qpeapplication.h>
43//US #endif
44
45//US static int kphoneInstalled = 0;
46
47using namespace KPIM;
48
49AddresseeView::AddresseeView( QWidget *parent, const char *name )
50//US : KTextBrowser( parent, name )
51 : QTextBrowser( parent, name )
52
53
54{
55//US setWrapPolicy( QTextEdit::AtWordBoundary );
56 setLinkUnderline( false );
57 // setVScrollBarMode( QScrollView::AlwaysOff );
58 //setHScrollBarMode( QScrollView::AlwaysOff );
59
60//US QStyleSheet *sheet = styleSheet();
61//US QStyleSheetItem *link = sheet->item( "a" );
62//US link->setColor( KGlobalSettings::linkColor() );
63
64}
65
66void AddresseeView::setSource(const QString& n)
67{
68 //qDebug("********AddresseeView::setSource %s", n.latin1());
69
70 if ( n.left( 6 ) == "mailto" )
71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
72 else if ( n.left( 7 ) == "phoneto" )
73 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
74 else if ( n.left( 5 ) == "faxto" )
75 ExternalAppHandler::instance()->callByFax( n.mid(6) );
76 else if ( n.left( 5 ) == "smsto" )
77 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
78 else if ( n.left( 7 ) == "pagerto" )
79 ExternalAppHandler::instance()->callByPager( n.mid(8) );
80 else if ( n.left( 5 ) == "sipto" )
81 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
82
83}
84void AddresseeView::setAddressee( const KABC::Addressee& addr )
85{
86 ExternalAppHandler* eah = ExternalAppHandler::instance();
87 bool kemailAvail = eah->isEmailAppAvailable();
88 bool kphoneAvail = eah->isPhoneAppAvailable();
89 bool kfaxAvail = eah->isFaxAppAvailable();
90 bool ksmsAvail = eah->isSMSAppAvailable();
91 bool kpagerAvail = eah->isPagerAppAvailable();
92 bool ksipAvail = eah->isSIPAppAvailable();
93
94
95 mAddressee = addr;
96 // clear view
97 setText( QString::null );
98
99 if ( mAddressee.isEmpty() )
100 return;
101
102 QString name = ( mAddressee.assembledName().isEmpty() ?
103 mAddressee.formattedName() : mAddressee.assembledName() );
104
105 QString dynamicPart;
106
107 QStringList emails = mAddressee.emails();
108 QStringList::ConstIterator emailIt;
109 QString type = i18n( "Email" );
110 emailIt = emails.begin();
111 if ( emailIt != emails.end() ) {
112 if ( kemailAvail ) {
113 dynamicPart += QString(
114 "<tr><td align=\"right\"><b>%1</b></td>"
115 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
116 .arg( type )
117 .arg( name )
118 .arg( *emailIt )
119 .arg( *emailIt );
120 ++emailIt;
121 } else {
122 dynamicPart += QString(
123 "<tr><td align=\"right\"><b>%1</b></td>"
124 "<td align=\"left\">%2</td></tr>" )
125 .arg( type )
126 .arg( *emailIt );
127 ++emailIt;
128 }
129 }
130 if ( mAddressee.birthday().date().isValid() ) {
131 dynamicPart += QString(
132 "<tr><td align=\"right\"><b>%1</b></td>"
133 "<td align=\"left\">%2</td></tr>" )
134 .arg( i18n ("Birthday") )
135 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
136 }
137 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
138 KABC::PhoneNumber::List::ConstIterator phoneIt;
139 QString extension;
140 int phonetype;
141 QString sms;
142 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
143 phonetype = (*phoneIt).type();
144 if (ksmsAvail &&
145 (
146 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
147 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
148 )
149 )
150 {
151 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
152 .arg( (*phoneIt).number() );
153
154 }
155 else
156 sms = "";
157
158 extension = QString::null;
159 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
160 if (kfaxAvail) extension = "faxto:";
161 }
162 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
163 if (kpagerAvail) extension = "pagerto:";
164 }
165 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
166 if (ksipAvail) extension = "sipto:";
167 }
168 else if (kphoneAvail) {
169 extension = "phoneto:";
170 }
171 else
172 extension = QString::null;
173
174 if ( !extension.isEmpty() ) {
175 dynamicPart += QString(
176 "<tr><td align=\"right\"><b>%1</b></td>"
177 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
178 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
179 .arg( extension )
180 .arg( (*phoneIt).number() )
181 .arg( (*phoneIt).number() )
182 .arg( sms );
183
184 } else {
185 dynamicPart += QString(
186 "<tr><td align=\"right\"><b>%1</b></td>"
187 "<td align=\"left\">%2 %3</td></tr>" )
188 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
189 .arg( (*phoneIt).number() )
190 .arg( sms );
191 }
192 }
193
194
195 for ( ; emailIt != emails.end(); ++emailIt ) {
196 if ( kemailAvail ) {
197 dynamicPart += QString(
198 "<tr><td align=\"right\"><b>%1</b></td>"
199 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
200 .arg( type )
201 .arg( name )
202 .arg( *emailIt )
203 .arg( *emailIt );
204 } else {
205 dynamicPart += QString(
206 "<tr><td align=\"right\"><b>%1</b></td>"
207 "<td align=\"left\">%2</td></tr>" )
208 .arg( type )
209 .arg( *emailIt );
210 }
211 }
212
213 if ( !mAddressee.url().url().isEmpty() ) {
214 dynamicPart += QString(
215 "<tr><td align=\"right\"><b>%1</b></td>"
216 "<td align=\"left\">%2</td></tr>" )
217 .arg( i18n( "Homepage" ) )
218//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
219 .arg( mAddressee.url().url() );
220 //qDebug("AddresseeView::setAddressee has to be verified.");
221 }
222
223 KABC::Address::List addresses = mAddressee.addresses();
224 KABC::Address::List::ConstIterator addrIt;
225 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
226 if ( true /*(*addrIt).label().isEmpty()*/ ) {
227 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
228//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
229 //qDebug("adresss %s ",formattedAddress.latin1() );
230 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
231 //qDebug("AddresseeView::setAddressee has to be verified.");
232
233 dynamicPart += QString(
234 "<tr><td align=\"right\"><b>%1</b></td>"
235 "<td align=\"left\">%2</td></tr>" )
236 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
237 .arg( formattedAddress );
238 } else {
239
240 dynamicPart += QString(
241 "<tr><td align=\"right\"><b>%1</b></td>"
242 "<td align=\"left\">%2</td></tr>" )
243 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
244//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
245 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
246
247 }
248 }
249
250 QString notes;
251 if ( !mAddressee.note().isEmpty() ) {
252 notes = QString(
253 "<tr>"
254 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
255 "<td align=\"left\">%2</td>" // note
256 "</tr>" ).arg( i18n( "Notes" ) )
257//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
258 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
259 //qDebug("AddresseeView::setAddressee has to be verified.");
260 }
261
262 QString aRole = "";
263 QString aOrga = "";
264 if ( true /*!mAddressee.role().isEmpty()*/ ) {
265 aRole = "<tr>"
266 "<td align=\"left\">" + mAddressee.role() + "</td>"
267 "</tr>";
268 }
269 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
270 aOrga = "<tr>"
271 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
272 "</tr>";
273 }
274 mText = "";
275 QString picString = "";
276 KABC::Picture picture = mAddressee.photo();
277 bool picAvailintern = false;
278 bool picAvailUrl = false;
279 if (! picture.undefined() ) {
280 picAvailintern = (picture.isIntern() && !picture.data().isNull());
281 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
282 }
283 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
284 if ( picAvailintern ) {
285 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
286 } else {
287 if ( picAvailUrl ) {
288 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
289 } else {
290 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
291 }
292 }
293 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
294 mText = QString::fromLatin1(
295 "<html>"
296 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
297 "<table>"
298 "<tr>"
299 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
300 "%3"
301 "</td>"
302 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
303 "</tr>"
304 "%5" // role
305 "%6" // organization
306 "<td colspan=\"2\">&nbsp;</td>"
307 "%7" // dynamic part
308 "%8" // notes
309 "</table>"
310 "</body>"
311 "</html>")
312//US
313 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
314//US
315 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
316 .arg( picString )
317 .arg( name )
318 .arg( aRole )
319 .arg( aOrga )
320 .arg( dynamicPart )
321 .arg( notes );
322
323 } else { // no picture!
324
325mText = "<table width=\"100%\">\n";
326 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
327#ifdef DESKTOP_VERSION
328 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
329#else
330 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
331#endif
332
333#ifdef DESKTOP_VERSION
334 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
335#else
336 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>";
337#endif
338 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
339
340 mText += "<table><td colspan=\"2\">&nbsp;</td>";
341 /*
342 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
343 "<td align=\"left\"><b>%2</b></td></tr>" )
344 .arg( i18n(" ") )
345 .arg( name );
346 */
347 if ( ! mAddressee.role().isEmpty() )
348 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
349 "<td align=\"left\">%2</td></tr>" )
350 .arg( i18n(" ") )
351 .arg( mAddressee.role());
352 if ( ! mAddressee.organization().isEmpty() )
353 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
354 "<td align=\"left\">%2</td></tr>" )
355 .arg( i18n(" ") )
356 .arg( mAddressee.organization());
357 mText += dynamicPart;
358 mText += notes;
359 mText += "</table>";
360
361 }
362
363 // at last display it...
364 setText( mText );
365
366}
367
368KABC::Addressee AddresseeView::addressee() const
369{
370 return mAddressee;
371}
372void AddresseeView::addTag(const QString & tag,const QString & text)
373{
374 if ( text.isEmpty() )
375 return;
376 int number=text.contains("\n");
377 QString str = "<" + tag + ">";
378 QString tmpText=text;
379 QString tmpStr=str;
380 if(number !=-1)
381 {
382 if (number > 0) {
383 int pos=0;
384 QString tmp;
385 for(int i=0;i<=number;i++) {
386 pos=tmpText.find("\n");
387 tmp=tmpText.left(pos);
388 tmpText=tmpText.right(tmpText.length()-pos-1);
389 tmpStr+=tmp+"<br>";
390 }
391 }
392 else tmpStr += tmpText;
393 tmpStr+="</" + tag + ">";
394 mText.append(tmpStr);
395 }
396 else
397 {
398 str += text + "</" + tag + ">";
399 mText.append(str);
400 }
401}
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h
new file mode 100644
index 0000000..1865fc4
--- a/dev/null
+++ b/kabc/addresseeview.h
@@ -0,0 +1,60 @@
1/*
2 This file is part of libkdepim.
3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#ifndef KPIM_ADDRESSEEVIEW_H
23#define KPIM_ADDRESSEEVIEW_H
24
25#include <kabc/addressee.h>
26
27//US #include <ktextbrowser.h>
28#include <qtextbrowser.h>
29
30namespace KPIM {
31
32//US class AddresseeView : public KTextBrowser
33class AddresseeView : public QTextBrowser
34{
35 public:
36 AddresseeView( QWidget *parent = 0, const char *name = 0 );
37
38 /**
39 Sets the addressee object. The addressee is displayed immediately.
40
41 @param addr The addressee object.
42 */
43 void setAddressee( const KABC::Addressee& addr );
44 void setSource(const QString& n);
45 /**
46 Returns the current addressee object.
47 */
48 KABC::Addressee addressee() const;
49
50 private:
51 KABC::Addressee mAddressee;
52 QString mText;
53 void addTag(const QString & tag,const QString & text);
54 class AddresseeViewPrivate;
55 AddresseeViewPrivate *d;
56};
57
58}
59
60#endif
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index 417f5b0..d690acc 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,218 +1,220 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug 3#release debug
4DESTDIR=../bin 4DESTDIR=../bin
5 5
6TARGET = microkabc 6TARGET = microkabc
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui .. 10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui ..
11 11
12#LIBS += -lmicrokde -lldap 12#LIBS += -lmicrokde -lldap
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED DESKTOP_VERSION 14DEFINES += KAB_EMBEDDED DESKTOP_VERSION
15unix : { 15unix : {
16 16
17OBJECTS_DIR = obj/unix 17OBJECTS_DIR = obj/unix
18MOC_DIR = moc/unix 18MOC_DIR = moc/unix
19} 19}
20win32: { 20win32: {
21DEFINES += _WIN32_ 21DEFINES += _WIN32_
22OBJECTS_DIR = obj/win 22OBJECTS_DIR = obj/win
23MOC_DIR = moc/win 23MOC_DIR = moc/win
24} 24}
25INTERFACES = \ 25INTERFACES = \
26 26
27 27
28HEADERS = \ 28HEADERS = \
29 resource.h \ 29 resource.h \
30 stdaddressbook.h \ 30 stdaddressbook.h \
31 agent.h \ 31 agent.h \
32 geo.h \ 32 geo.h \
33 key.h \ 33 key.h \
34 field.h \ 34 field.h \
35 plugin.h \ 35 plugin.h \
36 address.h \ 36 address.h \
37 addresseelist.h \ 37 addresseelist.h \
38 addresseeview.h \
38formatfactory.h \ 39formatfactory.h \
39 formatplugin.h \ 40 formatplugin.h \
40 phonenumber.h \ 41 phonenumber.h \
41distributionlist.h \ 42distributionlist.h \
42distributionlistdialog.h \ 43distributionlistdialog.h \
43distributionlisteditor.h \ 44distributionlisteditor.h \
44vcardformatplugin.h \ 45vcardformatplugin.h \
45formats/vcardformatplugin2.h \ 46formats/vcardformatplugin2.h \
46 picture.h \ 47 picture.h \
47 secrecy.h \ 48 secrecy.h \
48 sound.h \ 49 sound.h \
49 addressbook.h \ 50 addressbook.h \
50 syncprefwidget.h \ 51 syncprefwidget.h \
51 timezone.h \ 52 timezone.h \
52 tmpaddressbook.h \ 53 tmpaddressbook.h \
53 addressee.h \ 54 addressee.h \
54 addresseedialog.h \ 55 addresseedialog.h \
55 vcardconverter.h \ 56 vcardconverter.h \
56 vcard21parser.h \ 57 vcard21parser.h \
57 vcardformatimpl.h \ 58 vcardformatimpl.h \
58 plugins/file/resourcefile.h \ 59 plugins/file/resourcefile.h \
59 plugins/file/resourcefileconfig.h \ 60 plugins/file/resourcefileconfig.h \
60 plugins/dir/resourcedir.h \ 61 plugins/dir/resourcedir.h \
61 plugins/dir/resourcedirconfig.h \ 62 plugins/dir/resourcedirconfig.h \
62 vcardparser/vcardline.h \ 63 vcardparser/vcardline.h \
63 vcardparser/vcard.h \ 64 vcardparser/vcard.h \
64 vcardparser/vcardtool.h \ 65 vcardparser/vcardtool.h \
65 vcardparser/vcardparser.h \ 66 vcardparser/vcardparser.h \
66vcard/include/VCardAdrParam.h \ 67vcard/include/VCardAdrParam.h \
67vcard/include/VCardAdrValue.h \ 68vcard/include/VCardAdrValue.h \
68vcard/include/VCardAgentParam.h \ 69vcard/include/VCardAgentParam.h \
69vcard/include/VCardContentLine.h \ 70vcard/include/VCardContentLine.h \
70vcard/include/VCardDateParam.h \ 71vcard/include/VCardDateParam.h \
71vcard/include/VCardDateValue.h \ 72vcard/include/VCardDateValue.h \
72vcard/include/VCardEmailParam.h \ 73vcard/include/VCardEmailParam.h \
73vcard/include/VCardGeoValue.h \ 74vcard/include/VCardGeoValue.h \
74vcard/include/VCardGroup.h \ 75vcard/include/VCardGroup.h \
75vcard/include/VCardImageParam.h \ 76vcard/include/VCardImageParam.h \
76vcard/include/VCardImageValue.h \ 77vcard/include/VCardImageValue.h \
77vcard/include/VCardLangValue.h \ 78vcard/include/VCardLangValue.h \
78vcard/include/VCardNValue.h \ 79vcard/include/VCardNValue.h \
79vcard/include/VCardParam.h \ 80vcard/include/VCardParam.h \
80vcard/include/VCardPhoneNumberValue.h \ 81vcard/include/VCardPhoneNumberValue.h \
81vcard/include/VCardSourceParam.h \ 82vcard/include/VCardSourceParam.h \
82vcard/include/VCardTelParam.h \ 83vcard/include/VCardTelParam.h \
83vcard/include/VCardTextParam.h \ 84vcard/include/VCardTextParam.h \
84vcard/include/VCardTextValue.h \ 85vcard/include/VCardTextValue.h \
85vcard/include/VCardTextBinParam.h \ 86vcard/include/VCardTextBinParam.h \
86vcard/include/VCardURIValue.h \ 87vcard/include/VCardURIValue.h \
87vcard/include/VCardVCard.h \ 88vcard/include/VCardVCard.h \
88vcard/include/VCardEntity.h \ 89vcard/include/VCardEntity.h \
89vcard/include/VCardValue.h \ 90vcard/include/VCardValue.h \
90vcard/include/VCardSoundValue.h \ 91vcard/include/VCardSoundValue.h \
91vcard/include/VCardAgentValue.h \ 92vcard/include/VCardAgentValue.h \
92vcard/include/VCardTelValue.h \ 93vcard/include/VCardTelValue.h \
93vcard/include/VCardTextBinValue.h \ 94vcard/include/VCardTextBinValue.h \
94vcard/include/VCardOrgValue.h \ 95vcard/include/VCardOrgValue.h \
95vcard/include/VCardUTCValue.h \ 96vcard/include/VCardUTCValue.h \
96vcard/include/VCardClassValue.h \ 97vcard/include/VCardClassValue.h \
97vcard/include/VCardFloatValue.h \ 98vcard/include/VCardFloatValue.h \
98vcard/include/VCardTextListValue.h \ 99vcard/include/VCardTextListValue.h \
99vcard/include/generated/AdrParam-generated.h \ 100vcard/include/generated/AdrParam-generated.h \
100vcard/include/generated/AdrValue-generated.h \ 101vcard/include/generated/AdrValue-generated.h \
101vcard/include/generated/AgentParam-generated.h \ 102vcard/include/generated/AgentParam-generated.h \
102vcard/include/generated/ContentLine-generated.h \ 103vcard/include/generated/ContentLine-generated.h \
103vcard/include/generated/DateParam-generated.h \ 104vcard/include/generated/DateParam-generated.h \
104vcard/include/generated/DateValue-generated.h \ 105vcard/include/generated/DateValue-generated.h \
105vcard/include/generated/EmailParam-generated.h \ 106vcard/include/generated/EmailParam-generated.h \
106vcard/include/generated/GeoValue-generated.h \ 107vcard/include/generated/GeoValue-generated.h \
107vcard/include/generated/Group-generated.h \ 108vcard/include/generated/Group-generated.h \
108vcard/include/generated/ImageParam-generated.h \ 109vcard/include/generated/ImageParam-generated.h \
109vcard/include/generated/ImageValue-generated.h \ 110vcard/include/generated/ImageValue-generated.h \
110vcard/include/generated/LangValue-generated.h \ 111vcard/include/generated/LangValue-generated.h \
111vcard/include/generated/NValue-generated.h \ 112vcard/include/generated/NValue-generated.h \
112vcard/include/generated/Param-generated.h \ 113vcard/include/generated/Param-generated.h \
113vcard/include/generated/PhoneNumberValue-generated.h \ 114vcard/include/generated/PhoneNumberValue-generated.h \
114vcard/include/generated/SourceParam-generated.h \ 115vcard/include/generated/SourceParam-generated.h \
115vcard/include/generated/TelParam-generated.h \ 116vcard/include/generated/TelParam-generated.h \
116vcard/include/generated/TextParam-generated.h \ 117vcard/include/generated/TextParam-generated.h \
117vcard/include/generated/TextNSParam-generated.h \ 118vcard/include/generated/TextNSParam-generated.h \
118vcard/include/generated/TextValue-generated.h \ 119vcard/include/generated/TextValue-generated.h \
119vcard/include/generated/TextBinParam-generated.h \ 120vcard/include/generated/TextBinParam-generated.h \
120vcard/include/generated/URIValue-generated.h \ 121vcard/include/generated/URIValue-generated.h \
121vcard/include/generated/VCard-generated.h \ 122vcard/include/generated/VCard-generated.h \
122vcard/include/generated/VCardEntity-generated.h \ 123vcard/include/generated/VCardEntity-generated.h \
123vcard/include/generated/Value-generated.h \ 124vcard/include/generated/Value-generated.h \
124vcard/include/generated/SoundValue-generated.h \ 125vcard/include/generated/SoundValue-generated.h \
125vcard/include/generated/AgentValue-generated.h \ 126vcard/include/generated/AgentValue-generated.h \
126vcard/include/generated/TelValue-generated.h \ 127vcard/include/generated/TelValue-generated.h \
127vcard/include/generated/TextBinValue-generated.h \ 128vcard/include/generated/TextBinValue-generated.h \
128vcard/include/generated/OrgValue-generated.h \ 129vcard/include/generated/OrgValue-generated.h \
129vcard/include/generated/UTCValue-generated.h \ 130vcard/include/generated/UTCValue-generated.h \
130vcard/include/generated/ClassValue-generated.h \ 131vcard/include/generated/ClassValue-generated.h \
131vcard/include/generated/FloatValue-generated.h \ 132vcard/include/generated/FloatValue-generated.h \
132vcard/include/generated/TextListValue-generated.h 133vcard/include/generated/TextListValue-generated.h
133 134
134 135
135# plugins/ldap/resourceldap.h \ 136# plugins/ldap/resourceldap.h \
136# plugins/ldap/resourceldapconfig.h \ 137# plugins/ldap/resourceldapconfig.h \
137#formats/binary/binaryformat.h \ 138#formats/binary/binaryformat.h \
138 139
139#vcard/include/VCardTextNSParam.h \ 140#vcard/include/VCardTextNSParam.h \
140 141
141SOURCES = \ 142SOURCES = \
142distributionlist.cpp \ 143distributionlist.cpp \
143distributionlistdialog.cpp \ 144distributionlistdialog.cpp \
144distributionlisteditor.cpp \ 145distributionlisteditor.cpp \
145vcardformatplugin.cpp \ 146vcardformatplugin.cpp \
146formats/vcardformatplugin2.cpp \ 147formats/vcardformatplugin2.cpp \
147formatfactory.cpp \ 148formatfactory.cpp \
148 resource.cpp \ 149 resource.cpp \
149 stdaddressbook.cpp \ 150 stdaddressbook.cpp \
150 plugin.cpp \ 151 plugin.cpp \
151 agent.cpp \ 152 agent.cpp \
152 geo.cpp \ 153 geo.cpp \
153 key.cpp \ 154 key.cpp \
154 field.cpp \ 155 field.cpp \
156 addresseeview.cpp \
155 address.cpp \ 157 address.cpp \
156 phonenumber.cpp \ 158 phonenumber.cpp \
157 picture.cpp \ 159 picture.cpp \
158 secrecy.cpp \ 160 secrecy.cpp \
159 sound.cpp \ 161 sound.cpp \
160 addressbook.cpp \ 162 addressbook.cpp \
161 syncprefwidget.cpp \ 163 syncprefwidget.cpp \
162 timezone.cpp \ 164 timezone.cpp \
163 tmpaddressbook.cpp \ 165 tmpaddressbook.cpp \
164 addressee.cpp \ 166 addressee.cpp \
165 addresseelist.cpp \ 167 addresseelist.cpp \
166 addresseedialog.cpp \ 168 addresseedialog.cpp \
167 vcardconverter.cpp \ 169 vcardconverter.cpp \
168 vcard21parser.cpp \ 170 vcard21parser.cpp \
169 vcardformatimpl.cpp \ 171 vcardformatimpl.cpp \
170 plugins/file/resourcefile.cpp \ 172 plugins/file/resourcefile.cpp \
171 plugins/file/resourcefileconfig.cpp \ 173 plugins/file/resourcefileconfig.cpp \
172 plugins/dir/resourcedir.cpp \ 174 plugins/dir/resourcedir.cpp \
173 plugins/dir/resourcedirconfig.cpp \ 175 plugins/dir/resourcedirconfig.cpp \
174 vcardparser/vcardline.cpp \ 176 vcardparser/vcardline.cpp \
175 vcardparser/vcard.cpp \ 177 vcardparser/vcard.cpp \
176 vcardparser/vcardtool.cpp \ 178 vcardparser/vcardtool.cpp \
177 vcardparser/vcardparser.cpp \ 179 vcardparser/vcardparser.cpp \
178vcard/AdrParam.cpp \ 180vcard/AdrParam.cpp \
179vcard/AdrValue.cpp \ 181vcard/AdrValue.cpp \
180vcard/AgentParam.cpp \ 182vcard/AgentParam.cpp \
181vcard/ContentLine.cpp \ 183vcard/ContentLine.cpp \
182vcard/DateParam.cpp \ 184vcard/DateParam.cpp \
183vcard/DateValue.cpp \ 185vcard/DateValue.cpp \
184vcard/EmailParam.cpp \ 186vcard/EmailParam.cpp \
185vcard/Entity.cpp \ 187vcard/Entity.cpp \
186vcard/Enum.cpp \ 188vcard/Enum.cpp \
187vcard/GeoValue.cpp \ 189vcard/GeoValue.cpp \
188vcard/ImageParam.cpp \ 190vcard/ImageParam.cpp \
189vcard/ImageValue.cpp \ 191vcard/ImageValue.cpp \
190vcard/LangValue.cpp \ 192vcard/LangValue.cpp \
191vcard/NValue.cpp \ 193vcard/NValue.cpp \
192vcard/Param.cpp \ 194vcard/Param.cpp \
193vcard/PhoneNumberValue.cpp \ 195vcard/PhoneNumberValue.cpp \
194vcard/RToken.cpp \ 196vcard/RToken.cpp \
195vcard/SourceParam.cpp \ 197vcard/SourceParam.cpp \
196vcard/TelParam.cpp \ 198vcard/TelParam.cpp \
197vcard/TextParam.cpp \ 199vcard/TextParam.cpp \
198vcard/TextValue.cpp \ 200vcard/TextValue.cpp \
199vcard/TextBinParam.cpp \ 201vcard/TextBinParam.cpp \
200vcard/URIValue.cpp \ 202vcard/URIValue.cpp \
201vcard/VCardv.cpp \ 203vcard/VCardv.cpp \
202vcard/VCardEntity.cpp \ 204vcard/VCardEntity.cpp \
203vcard/Value.cpp \ 205vcard/Value.cpp \
204vcard/SoundValue.cpp \ 206vcard/SoundValue.cpp \
205vcard/AgentValue.cpp \ 207vcard/AgentValue.cpp \
206vcard/TelValue.cpp \ 208vcard/TelValue.cpp \
207vcard/TextBinValue.cpp \ 209vcard/TextBinValue.cpp \
208vcard/OrgValue.cpp \ 210vcard/OrgValue.cpp \
209vcard/UTCValue.cpp \ 211vcard/UTCValue.cpp \
210vcard/ClassValue.cpp \ 212vcard/ClassValue.cpp \
211vcard/FloatValue.cpp \ 213vcard/FloatValue.cpp \
212vcard/TextListValue.cpp 214vcard/TextListValue.cpp
213 215
214 216
215# plugins/ldap/resourceldap.cpp \ 217# plugins/ldap/resourceldap.cpp \
216# plugins/ldap/resourceldapconfig.cpp \ 218# plugins/ldap/resourceldapconfig.cpp \
217 219
218#formats/binary/binaryformat.cpp \ 220#formats/binary/binaryformat.cpp \
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
index dfdbcff..b360e8c 100644
--- a/kabc/kabcE.pro
+++ b/kabc/kabcE.pro
@@ -1,193 +1,195 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc 3TARGET = microkabc
4 4
5 5
6INCLUDEPATH += . $(KDEPIMDIR) vcard/include vcard/include/generated $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/libkdepim $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += . $(KDEPIMDIR) vcard/include vcard/include/generated $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/libkdepim $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde 10LIBS += -lmicrokde
11LIBS += -lmicrokdepim 11LIBS += -lmicrokdepim
12#LIBS += -lldap 12#LIBS += -lldap
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED 14DEFINES += KAB_EMBEDDED
15 15
16INTERFACES = \ 16INTERFACES = \
17 17
18HEADERS = \ 18HEADERS = \
19 address.h \ 19 address.h \
20 addressbook.h \ 20 addressbook.h \
21 addressee.h \ 21 addressee.h \
22 addresseedialog.h \ 22 addresseedialog.h \
23 addresseelist.h \ 23 addresseelist.h \
24 addresseeview.h \
24 agent.h \ 25 agent.h \
25 distributionlist.h \ 26 distributionlist.h \
26 distributionlistdialog.h \ 27 distributionlistdialog.h \
27 distributionlisteditor.h \ 28 distributionlisteditor.h \
28 field.h \ 29 field.h \
29 formatfactory.h \ 30 formatfactory.h \
30 formatplugin.h \ 31 formatplugin.h \
31 geo.h \ 32 geo.h \
32 key.h \ 33 key.h \
33 phonenumber.h \ 34 phonenumber.h \
34 picture.h \ 35 picture.h \
35 plugin.h \ 36 plugin.h \
36 resource.h \ 37 resource.h \
37 secrecy.h \ 38 secrecy.h \
38 sound.h \ 39 sound.h \
39 stdaddressbook.h \ 40 stdaddressbook.h \
40 syncprefwidget.h \ 41 syncprefwidget.h \
41 timezone.h \ 42 timezone.h \
42 tmpaddressbook.h \ 43 tmpaddressbook.h \
43 vcardconverter.h \ 44 vcardconverter.h \
44 vcard21parser.h \ 45 vcard21parser.h \
45 vcardformatimpl.h \ 46 vcardformatimpl.h \
46 vcardformatplugin.h \ 47 vcardformatplugin.h \
47 vcardparser/vcardline.h \ 48 vcardparser/vcardline.h \
48 vcardparser/vcard.h \ 49 vcardparser/vcard.h \
49 vcardparser/vcardtool.h \ 50 vcardparser/vcardtool.h \
50 vcardparser/vcardparser.h \ 51 vcardparser/vcardparser.h \
51 vcard/include/VCardAdrParam.h \ 52 vcard/include/VCardAdrParam.h \
52 vcard/include/VCardAdrValue.h \ 53 vcard/include/VCardAdrValue.h \
53 vcard/include/VCardAgentParam.h \ 54 vcard/include/VCardAgentParam.h \
54 vcard/include/VCardContentLine.h \ 55 vcard/include/VCardContentLine.h \
55 vcard/include/VCardDateParam.h \ 56 vcard/include/VCardDateParam.h \
56 vcard/include/VCardDateValue.h \ 57 vcard/include/VCardDateValue.h \
57 vcard/include/VCardEmailParam.h \ 58 vcard/include/VCardEmailParam.h \
58 vcard/include/VCardGeoValue.h \ 59 vcard/include/VCardGeoValue.h \
59 vcard/include/VCardGroup.h \ 60 vcard/include/VCardGroup.h \
60 vcard/include/VCardImageParam.h \ 61 vcard/include/VCardImageParam.h \
61 vcard/include/VCardImageValue.h \ 62 vcard/include/VCardImageValue.h \
62 vcard/include/VCardLangValue.h \ 63 vcard/include/VCardLangValue.h \
63 vcard/include/VCardNValue.h \ 64 vcard/include/VCardNValue.h \
64 vcard/include/VCardParam.h \ 65 vcard/include/VCardParam.h \
65 vcard/include/VCardPhoneNumberValue.h \ 66 vcard/include/VCardPhoneNumberValue.h \
66 vcard/include/VCardSourceParam.h \ 67 vcard/include/VCardSourceParam.h \
67 vcard/include/VCardTelParam.h \ 68 vcard/include/VCardTelParam.h \
68 vcard/include/VCardTextParam.h \ 69 vcard/include/VCardTextParam.h \
69 vcard/include/VCardTextNSParam.h \ 70 vcard/include/VCardTextNSParam.h \
70 vcard/include/VCardTextValue.h \ 71 vcard/include/VCardTextValue.h \
71 vcard/include/VCardTextBinParam.h \ 72 vcard/include/VCardTextBinParam.h \
72 vcard/include/VCardURIValue.h \ 73 vcard/include/VCardURIValue.h \
73 vcard/include/VCardVCard.h \ 74 vcard/include/VCardVCard.h \
74 vcard/include/VCardEntity.h \ 75 vcard/include/VCardEntity.h \
75 vcard/include/VCardValue.h \ 76 vcard/include/VCardValue.h \
76 vcard/include/VCardSoundValue.h \ 77 vcard/include/VCardSoundValue.h \
77 vcard/include/VCardAgentValue.h \ 78 vcard/include/VCardAgentValue.h \
78 vcard/include/VCardTelValue.h \ 79 vcard/include/VCardTelValue.h \
79 vcard/include/VCardTextBinValue.h \ 80 vcard/include/VCardTextBinValue.h \
80 vcard/include/VCardOrgValue.h \ 81 vcard/include/VCardOrgValue.h \
81 vcard/include/VCardUTCValue.h \ 82 vcard/include/VCardUTCValue.h \
82 vcard/include/VCardClassValue.h \ 83 vcard/include/VCardClassValue.h \
83 vcard/include/VCardFloatValue.h \ 84 vcard/include/VCardFloatValue.h \
84 vcard/include/VCardTextListValue.h \ 85 vcard/include/VCardTextListValue.h \
85 vcard/include/generated/AdrParam-generated.h \ 86 vcard/include/generated/AdrParam-generated.h \
86 vcard/include/generated/AdrValue-generated.h \ 87 vcard/include/generated/AdrValue-generated.h \
87 vcard/include/generated/AgentParam-generated.h \ 88 vcard/include/generated/AgentParam-generated.h \
88 vcard/include/generated/ContentLine-generated.h \ 89 vcard/include/generated/ContentLine-generated.h \
89 vcard/include/generated/DateParam-generated.h \ 90 vcard/include/generated/DateParam-generated.h \
90 vcard/include/generated/DateValue-generated.h \ 91 vcard/include/generated/DateValue-generated.h \
91 vcard/include/generated/EmailParam-generated.h \ 92 vcard/include/generated/EmailParam-generated.h \
92 vcard/include/generated/GeoValue-generated.h \ 93 vcard/include/generated/GeoValue-generated.h \
93 vcard/include/generated/Group-generated.h \ 94 vcard/include/generated/Group-generated.h \
94 vcard/include/generated/ImageParam-generated.h \ 95 vcard/include/generated/ImageParam-generated.h \
95 vcard/include/generated/ImageValue-generated.h \ 96 vcard/include/generated/ImageValue-generated.h \
96 vcard/include/generated/LangValue-generated.h \ 97 vcard/include/generated/LangValue-generated.h \
97 vcard/include/generated/NValue-generated.h \ 98 vcard/include/generated/NValue-generated.h \
98 vcard/include/generated/Param-generated.h \ 99 vcard/include/generated/Param-generated.h \
99 vcard/include/generated/PhoneNumberValue-generated.h \ 100 vcard/include/generated/PhoneNumberValue-generated.h \
100 vcard/include/generated/SourceParam-generated.h \ 101 vcard/include/generated/SourceParam-generated.h \
101 vcard/include/generated/TelParam-generated.h \ 102 vcard/include/generated/TelParam-generated.h \
102 vcard/include/generated/TextParam-generated.h \ 103 vcard/include/generated/TextParam-generated.h \
103 vcard/include/generated/TextNSParam-generated.h \ 104 vcard/include/generated/TextNSParam-generated.h \
104 vcard/include/generated/TextValue-generated.h \ 105 vcard/include/generated/TextValue-generated.h \
105 vcard/include/generated/TextBinParam-generated.h \ 106 vcard/include/generated/TextBinParam-generated.h \
106 vcard/include/generated/URIValue-generated.h \ 107 vcard/include/generated/URIValue-generated.h \
107 vcard/include/generated/VCard-generated.h \ 108 vcard/include/generated/VCard-generated.h \
108 vcard/include/generated/VCardEntity-generated.h \ 109 vcard/include/generated/VCardEntity-generated.h \
109 vcard/include/generated/Value-generated.h \ 110 vcard/include/generated/Value-generated.h \
110 vcard/include/generated/SoundValue-generated.h \ 111 vcard/include/generated/SoundValue-generated.h \
111 vcard/include/generated/AgentValue-generated.h \ 112 vcard/include/generated/AgentValue-generated.h \
112 vcard/include/generated/TelValue-generated.h \ 113 vcard/include/generated/TelValue-generated.h \
113 vcard/include/generated/TextBinValue-generated.h \ 114 vcard/include/generated/TextBinValue-generated.h \
114 vcard/include/generated/OrgValue-generated.h \ 115 vcard/include/generated/OrgValue-generated.h \
115 vcard/include/generated/UTCValue-generated.h \ 116 vcard/include/generated/UTCValue-generated.h \
116 vcard/include/generated/ClassValue-generated.h \ 117 vcard/include/generated/ClassValue-generated.h \
117 vcard/include/generated/FloatValue-generated.h \ 118 vcard/include/generated/FloatValue-generated.h \
118 vcard/include/generated/TextListValue-generated.h 119 vcard/include/generated/TextListValue-generated.h
119 120
120 121
121 122
122 123
123SOURCES = \ 124SOURCES = \
124 address.cpp \ 125 address.cpp \
125 addressbook.cpp \ 126 addressbook.cpp \
126 addressee.cpp \ 127 addressee.cpp \
127 addresseedialog.cpp \ 128 addresseedialog.cpp \
128 addresseelist.cpp \ 129 addresseelist.cpp \
130 addresseeview.cpp \
129 agent.cpp \ 131 agent.cpp \
130 distributionlist.cpp \ 132 distributionlist.cpp \
131 distributionlistdialog.cpp \ 133 distributionlistdialog.cpp \
132 distributionlisteditor.cpp \ 134 distributionlisteditor.cpp \
133 field.cpp \ 135 field.cpp \
134 formatfactory.cpp \ 136 formatfactory.cpp \
135 geo.cpp \ 137 geo.cpp \
136 key.cpp \ 138 key.cpp \
137 phonenumber.cpp \ 139 phonenumber.cpp \
138 picture.cpp \ 140 picture.cpp \
139 plugin.cpp \ 141 plugin.cpp \
140 resource.cpp \ 142 resource.cpp \
141 secrecy.cpp \ 143 secrecy.cpp \
142 sound.cpp \ 144 sound.cpp \
143 stdaddressbook.cpp \ 145 stdaddressbook.cpp \
144 syncprefwidget.cpp \ 146 syncprefwidget.cpp \
145 timezone.cpp \ 147 timezone.cpp \
146 tmpaddressbook.cpp \ 148 tmpaddressbook.cpp \
147 vcardconverter.cpp \ 149 vcardconverter.cpp \
148 vcard21parser.cpp \ 150 vcard21parser.cpp \
149 vcardformatimpl.cpp \ 151 vcardformatimpl.cpp \
150 vcardformatplugin.cpp \ 152 vcardformatplugin.cpp \
151 vcardparser/vcardline.cpp \ 153 vcardparser/vcardline.cpp \
152 vcardparser/vcard.cpp \ 154 vcardparser/vcard.cpp \
153 vcardparser/vcardtool.cpp \ 155 vcardparser/vcardtool.cpp \
154 vcardparser/vcardparser.cpp \ 156 vcardparser/vcardparser.cpp \
155vcard/AdrParam.cpp \ 157vcard/AdrParam.cpp \
156vcard/AdrValue.cpp \ 158vcard/AdrValue.cpp \
157vcard/AgentParam.cpp \ 159vcard/AgentParam.cpp \
158vcard/ContentLine.cpp \ 160vcard/ContentLine.cpp \
159vcard/DateParam.cpp \ 161vcard/DateParam.cpp \
160vcard/DateValue.cpp \ 162vcard/DateValue.cpp \
161vcard/EmailParam.cpp \ 163vcard/EmailParam.cpp \
162vcard/Entity.cpp \ 164vcard/Entity.cpp \
163vcard/Enum.cpp \ 165vcard/Enum.cpp \
164vcard/GeoValue.cpp \ 166vcard/GeoValue.cpp \
165vcard/ImageParam.cpp \ 167vcard/ImageParam.cpp \
166vcard/ImageValue.cpp \ 168vcard/ImageValue.cpp \
167vcard/LangValue.cpp \ 169vcard/LangValue.cpp \
168vcard/NValue.cpp \ 170vcard/NValue.cpp \
169vcard/Param.cpp \ 171vcard/Param.cpp \
170vcard/PhoneNumberValue.cpp \ 172vcard/PhoneNumberValue.cpp \
171vcard/RToken.cpp \ 173vcard/RToken.cpp \
172vcard/SourceParam.cpp \ 174vcard/SourceParam.cpp \
173vcard/TelParam.cpp \ 175vcard/TelParam.cpp \
174vcard/TextParam.cpp \ 176vcard/TextParam.cpp \
175vcard/TextValue.cpp \ 177vcard/TextValue.cpp \
176vcard/TextBinParam.cpp \ 178vcard/TextBinParam.cpp \
177vcard/URIValue.cpp \ 179vcard/URIValue.cpp \
178vcard/VCardv.cpp \ 180vcard/VCardv.cpp \
179vcard/VCardEntity.cpp \ 181vcard/VCardEntity.cpp \
180vcard/Value.cpp \ 182vcard/Value.cpp \
181vcard/SoundValue.cpp \ 183vcard/SoundValue.cpp \
182vcard/AgentValue.cpp \ 184vcard/AgentValue.cpp \
183vcard/TelValue.cpp \ 185vcard/TelValue.cpp \
184vcard/TextBinValue.cpp \ 186vcard/TextBinValue.cpp \
185vcard/OrgValue.cpp \ 187vcard/OrgValue.cpp \
186vcard/UTCValue.cpp \ 188vcard/UTCValue.cpp \
187vcard/ClassValue.cpp \ 189vcard/ClassValue.cpp \
188vcard/FloatValue.cpp \ 190vcard/FloatValue.cpp \
189vcard/TextListValue.cpp 191vcard/TextListValue.cpp
190 192
191 193
192# plugins/ldap/resourceldap.cpp \ 194# plugins/ldap/resourceldap.cpp \
193# plugins/ldap/resourceldapconfig.cpp \ 195# plugins/ldap/resourceldapconfig.cpp \
diff --git a/kaddressbook/details/look_html.cpp b/kaddressbook/details/look_html.cpp
index 2a70273..63364a7 100644
--- a/kaddressbook/details/look_html.cpp
+++ b/kaddressbook/details/look_html.cpp
@@ -1,45 +1,45 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <libkdepim/addresseeview.h> 24#include <addresseeview.h>
25 25
26#include "look_html.h" 26#include "look_html.h"
27#include <qscrollview.h> 27#include <qscrollview.h>
28KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) 28KABHtmlView::KABHtmlView( QWidget *parent, const char *name )
29 : KABBasicLook( parent, name ) 29 : KABBasicLook( parent, name )
30{ 30{
31 mView = new KPIM::AddresseeView( this ); 31 mView = new KPIM::AddresseeView( this );
32} 32}
33 33
34KABHtmlView::~KABHtmlView() 34KABHtmlView::~KABHtmlView()
35{ 35{
36} 36}
37 37
38void KABHtmlView::setAddressee( const KABC::Addressee &addr ) 38void KABHtmlView::setAddressee( const KABC::Addressee &addr )
39{ 39{
40 mView->setAddressee( addr ); 40 mView->setAddressee( addr );
41} 41}
42 42
43#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
44#include "look_html.moc" 44#include "look_html.moc"
45#endif //KAB_EMBEDDED 45#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f21507a..32dd43a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2091 +1,2091 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35 35
36#ifndef KAB_EMBEDDED 36#ifndef KAB_EMBEDDED
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qapplicaton.h> 40#include <qapplicaton.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qvbox.h> 43#include <qvbox.h>
44#include <kabc/addresseelist.h> 44#include <kabc/addresseelist.h>
45#include <kabc/errorhandler.h> 45#include <kabc/errorhandler.h>
46#include <kabc/resource.h> 46#include <kabc/resource.h>
47#include <kabc/vcardconverter.h> 47#include <kabc/vcardconverter.h>
48#include <kapplication.h> 48#include <kapplication.h>
49#include <kactionclasses.h> 49#include <kactionclasses.h>
50#include <kcmultidialog.h> 50#include <kcmultidialog.h>
51#include <kdebug.h> 51#include <kdebug.h>
52#include <kdeversion.h> 52#include <kdeversion.h>
53#include <kkeydialog.h> 53#include <kkeydialog.h>
54#include <kmessagebox.h> 54#include <kmessagebox.h>
55#include <kprinter.h> 55#include <kprinter.h>
56#include <kprotocolinfo.h> 56#include <kprotocolinfo.h>
57#include <kresources/selectdialog.h> 57#include <kresources/selectdialog.h>
58#include <kstandarddirs.h> 58#include <kstandarddirs.h>
59#include <ktempfile.h> 59#include <ktempfile.h>
60#include <kxmlguiclient.h> 60#include <kxmlguiclient.h>
61#include <kaboutdata.h> 61#include <kaboutdata.h>
62#include <libkdepim/categoryselectdialog.h> 62#include <libkdepim/categoryselectdialog.h>
63 63
64#include "addresseeutil.h" 64#include "addresseeutil.h"
65#include "addresseeeditordialog.h" 65#include "addresseeeditordialog.h"
66#include "extensionmanager.h" 66#include "extensionmanager.h"
67#include "kstdaction.h" 67#include "kstdaction.h"
68#include "kaddressbookservice.h" 68#include "kaddressbookservice.h"
69#include "ldapsearchdialog.h" 69#include "ldapsearchdialog.h"
70#include "printing/printingwizard.h" 70#include "printing/printingwizard.h"
71#else // KAB_EMBEDDED 71#else // KAB_EMBEDDED
72 72
73#include <kapplication.h> 73#include <kapplication.h>
74#include "KDGanttMinimizeSplitter.h" 74#include "KDGanttMinimizeSplitter.h"
75#include "kaddressbookmain.h" 75#include "kaddressbookmain.h"
76#include "kactioncollection.h" 76#include "kactioncollection.h"
77#include "addresseedialog.h" 77#include "addresseedialog.h"
78//US 78//US
79#include <libkdepim/addresseeview.h> 79#include <addresseeview.h>
80 80
81#include <qapp.h> 81#include <qapp.h>
82#include <qmenubar.h> 82#include <qmenubar.h>
83//#include <qtoolbar.h> 83//#include <qtoolbar.h>
84#include <qmessagebox.h> 84#include <qmessagebox.h>
85#include <kdebug.h> 85#include <kdebug.h>
86#include <kiconloader.h> // needed for SmallIcon 86#include <kiconloader.h> // needed for SmallIcon
87#include <kresources/kcmkresources.h> 87#include <kresources/kcmkresources.h>
88#include <ktoolbar.h> 88#include <ktoolbar.h>
89 89
90 90
91//#include <qlabel.h> 91//#include <qlabel.h>
92 92
93 93
94#ifndef DESKTOP_VERSION 94#ifndef DESKTOP_VERSION
95#include <qpe/ir.h> 95#include <qpe/ir.h>
96#include <qpe/qpemenubar.h> 96#include <qpe/qpemenubar.h>
97#include <qtopia/qcopenvelope_qws.h> 97#include <qtopia/qcopenvelope_qws.h>
98#else 98#else
99 99
100#include <qmenubar.h> 100#include <qmenubar.h>
101#endif 101#endif
102 102
103#endif // KAB_EMBEDDED 103#endif // KAB_EMBEDDED
104#include "kcmconfigs/kcmkabconfig.h" 104#include "kcmconfigs/kcmkabconfig.h"
105#include "kcmconfigs/kcmkdepimconfig.h" 105#include "kcmconfigs/kcmkdepimconfig.h"
106#include "kpimglobalprefs.h" 106#include "kpimglobalprefs.h"
107#include "externalapphandler.h" 107#include "externalapphandler.h"
108 108
109 109
110#include <kresources/selectdialog.h> 110#include <kresources/selectdialog.h>
111#include <kmessagebox.h> 111#include <kmessagebox.h>
112 112
113#include <picture.h> 113#include <picture.h>
114#include <resource.h> 114#include <resource.h>
115 115
116//US#include <qsplitter.h> 116//US#include <qsplitter.h>
117#include <qmap.h> 117#include <qmap.h>
118#include <qdir.h> 118#include <qdir.h>
119#include <qfile.h> 119#include <qfile.h>
120#include <qvbox.h> 120#include <qvbox.h>
121#include <qlayout.h> 121#include <qlayout.h>
122#include <qclipboard.h> 122#include <qclipboard.h>
123#include <qtextstream.h> 123#include <qtextstream.h>
124 124
125#include <libkdepim/categoryselectdialog.h> 125#include <libkdepim/categoryselectdialog.h>
126#include <kabc/vcardconverter.h> 126#include <kabc/vcardconverter.h>
127 127
128 128
129#include "addresseeutil.h" 129#include "addresseeutil.h"
130#include "undocmds.h" 130#include "undocmds.h"
131#include "addresseeeditordialog.h" 131#include "addresseeeditordialog.h"
132#include "viewmanager.h" 132#include "viewmanager.h"
133#include "details/detailsviewcontainer.h" 133#include "details/detailsviewcontainer.h"
134#include "kabprefs.h" 134#include "kabprefs.h"
135#include "xxportmanager.h" 135#include "xxportmanager.h"
136#include "incsearchwidget.h" 136#include "incsearchwidget.h"
137#include "jumpbuttonbar.h" 137#include "jumpbuttonbar.h"
138#include "extensionmanager.h" 138#include "extensionmanager.h"
139#include "addresseeconfig.h" 139#include "addresseeconfig.h"
140#include <kcmultidialog.h> 140#include <kcmultidialog.h>
141 141
142#ifdef _WIN32_ 142#ifdef _WIN32_
143 143
144#include "kaimportoldialog.h" 144#include "kaimportoldialog.h"
145#endif 145#endif
146 146
147bool pasteWithNewUid = true; 147bool pasteWithNewUid = true;
148 148
149#ifdef KAB_EMBEDDED 149#ifdef KAB_EMBEDDED
150KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 150KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
151 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 151 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
152 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 152 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
153 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 153 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
154#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
155KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 155KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
156 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 156 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
157 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 157 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
158 mReadWrite( readWrite ), mModified( false ) 158 mReadWrite( readWrite ), mModified( false )
159#endif //KAB_EMBEDDED 159#endif //KAB_EMBEDDED
160{ 160{
161 161
162 mExtensionBarSplitter = 0; 162 mExtensionBarSplitter = 0;
163 mIsPart = !parent->inherits( "KAddressBookMain" ); 163 mIsPart = !parent->inherits( "KAddressBookMain" );
164 164
165 mAddressBook = KABC::StdAddressBook::self(); 165 mAddressBook = KABC::StdAddressBook::self();
166 KABC::StdAddressBook::setAutomaticSave( false ); 166 KABC::StdAddressBook::setAutomaticSave( false );
167 167
168#ifndef KAB_EMBEDDED 168#ifndef KAB_EMBEDDED
169 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 169 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
170#endif //KAB_EMBEDDED 170#endif //KAB_EMBEDDED
171 171
172 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 172 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
173 SLOT( addressBookChanged() ) ); 173 SLOT( addressBookChanged() ) );
174 174
175 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 175 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
176 "X-Department", "KADDRESSBOOK" ); 176 "X-Department", "KADDRESSBOOK" );
177 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 177 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
178 "X-Profession", "KADDRESSBOOK" ); 178 "X-Profession", "KADDRESSBOOK" );
179 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 179 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
180 "X-AssistantsName", "KADDRESSBOOK" ); 180 "X-AssistantsName", "KADDRESSBOOK" );
181 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 181 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
182 "X-ManagersName", "KADDRESSBOOK" ); 182 "X-ManagersName", "KADDRESSBOOK" );
183 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 183 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
184 "X-SpousesName", "KADDRESSBOOK" ); 184 "X-SpousesName", "KADDRESSBOOK" );
185 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 185 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
186 "X-Office", "KADDRESSBOOK" ); 186 "X-Office", "KADDRESSBOOK" );
187 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 187 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
188 "X-IMAddress", "KADDRESSBOOK" ); 188 "X-IMAddress", "KADDRESSBOOK" );
189 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 189 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
190 "X-Anniversary", "KADDRESSBOOK" ); 190 "X-Anniversary", "KADDRESSBOOK" );
191 191
192 //US added this field to become compatible with Opie/qtopia addressbook 192 //US added this field to become compatible with Opie/qtopia addressbook
193 // values can be "female" or "male" or "". An empty field represents undefined. 193 // values can be "female" or "male" or "". An empty field represents undefined.
194 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 194 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
195 "X-Gender", "KADDRESSBOOK" ); 195 "X-Gender", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
197 "X-Children", "KADDRESSBOOK" ); 197 "X-Children", "KADDRESSBOOK" );
198 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 198 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
199 "X-FreeBusyUrl", "KADDRESSBOOK" ); 199 "X-FreeBusyUrl", "KADDRESSBOOK" );
200 200
201 initGUI(); 201 initGUI();
202 202
203 mIncSearchWidget->setFocus(); 203 mIncSearchWidget->setFocus();
204 204
205 205
206 connect( mViewManager, SIGNAL( selected( const QString& ) ), 206 connect( mViewManager, SIGNAL( selected( const QString& ) ),
207 SLOT( setContactSelected( const QString& ) ) ); 207 SLOT( setContactSelected( const QString& ) ) );
208 connect( mViewManager, SIGNAL( executed( const QString& ) ), 208 connect( mViewManager, SIGNAL( executed( const QString& ) ),
209 SLOT( executeContact( const QString& ) ) ); 209 SLOT( executeContact( const QString& ) ) );
210 210
211 connect( mViewManager, SIGNAL( deleteRequest( ) ), 211 connect( mViewManager, SIGNAL( deleteRequest( ) ),
212 SLOT( deleteContacts( ) ) ); 212 SLOT( deleteContacts( ) ) );
213 connect( mViewManager, SIGNAL( modified() ), 213 connect( mViewManager, SIGNAL( modified() ),
214 SLOT( setModified() ) ); 214 SLOT( setModified() ) );
215 215
216 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 216 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
217 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 217 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
218 218
219 connect( mXXPortManager, SIGNAL( modified() ), 219 connect( mXXPortManager, SIGNAL( modified() ),
220 SLOT( setModified() ) ); 220 SLOT( setModified() ) );
221 221
222 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 222 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
223 SLOT( incrementalSearch( const QString& ) ) ); 223 SLOT( incrementalSearch( const QString& ) ) );
224 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 224 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
225 mJumpButtonBar, SLOT( recreateButtons() ) ); 225 mJumpButtonBar, SLOT( recreateButtons() ) );
226 226
227 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 227 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
228 SLOT( sendMail( const QString& ) ) ); 228 SLOT( sendMail( const QString& ) ) );
229 229
230 230
231 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 231 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
232 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 232 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
233 233
234 234
235#ifndef KAB_EMBEDDED 235#ifndef KAB_EMBEDDED
236 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 236 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
237 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 237 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
238 238
239 connect( mDetails, SIGNAL( browse( const QString& ) ), 239 connect( mDetails, SIGNAL( browse( const QString& ) ),
240 SLOT( browse( const QString& ) ) ); 240 SLOT( browse( const QString& ) ) );
241 241
242 242
243 mAddressBookService = new KAddressBookService( this ); 243 mAddressBookService = new KAddressBookService( this );
244 244
245#endif //KAB_EMBEDDED 245#endif //KAB_EMBEDDED
246 mEditorDialog = 0; 246 mEditorDialog = 0;
247 createAddresseeEditorDialog( this ); 247 createAddresseeEditorDialog( this );
248 setModified( false ); 248 setModified( false );
249} 249}
250 250
251KABCore::~KABCore() 251KABCore::~KABCore()
252{ 252{
253 // save(); 253 // save();
254 //saveSettings(); 254 //saveSettings();
255 //KABPrefs::instance()->writeConfig(); 255 //KABPrefs::instance()->writeConfig();
256 delete AddresseeConfig::instance(); 256 delete AddresseeConfig::instance();
257 mAddressBook = 0; 257 mAddressBook = 0;
258 KABC::StdAddressBook::close(); 258 KABC::StdAddressBook::close();
259} 259}
260 260
261void KABCore::restoreSettings() 261void KABCore::restoreSettings()
262{ 262{
263 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 263 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
264 264
265 bool state; 265 bool state;
266 266
267 if (mMultipleViewsAtOnce) 267 if (mMultipleViewsAtOnce)
268 state = KABPrefs::instance()->mDetailsPageVisible; 268 state = KABPrefs::instance()->mDetailsPageVisible;
269 else 269 else
270 state = false; 270 state = false;
271 271
272 mActionDetails->setChecked( state ); 272 mActionDetails->setChecked( state );
273 setDetailsVisible( state ); 273 setDetailsVisible( state );
274 274
275 state = KABPrefs::instance()->mJumpButtonBarVisible; 275 state = KABPrefs::instance()->mJumpButtonBarVisible;
276 276
277 mActionJumpBar->setChecked( state ); 277 mActionJumpBar->setChecked( state );
278 setJumpButtonBarVisible( state ); 278 setJumpButtonBarVisible( state );
279/*US 279/*US
280 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 280 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
281 if ( splitterSize.count() == 0 ) { 281 if ( splitterSize.count() == 0 ) {
282 splitterSize.append( width() / 2 ); 282 splitterSize.append( width() / 2 );
283 splitterSize.append( width() / 2 ); 283 splitterSize.append( width() / 2 );
284 } 284 }
285 mMiniSplitter->setSizes( splitterSize ); 285 mMiniSplitter->setSizes( splitterSize );
286 if ( mExtensionBarSplitter ) { 286 if ( mExtensionBarSplitter ) {
287 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 287 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
288 if ( splitterSize.count() == 0 ) { 288 if ( splitterSize.count() == 0 ) {
289 splitterSize.append( width() / 2 ); 289 splitterSize.append( width() / 2 );
290 splitterSize.append( width() / 2 ); 290 splitterSize.append( width() / 2 );
291 } 291 }
292 mExtensionBarSplitter->setSizes( splitterSize ); 292 mExtensionBarSplitter->setSizes( splitterSize );
293 293
294 } 294 }
295*/ 295*/
296 mViewManager->restoreSettings(); 296 mViewManager->restoreSettings();
297 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 297 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
298 mExtensionManager->restoreSettings(); 298 mExtensionManager->restoreSettings();
299#ifdef DESKTOP_VERSION 299#ifdef DESKTOP_VERSION
300 int wid = width(); 300 int wid = width();
301 if ( wid < 10 ) 301 if ( wid < 10 )
302 wid = 400; 302 wid = 400;
303#else 303#else
304 int wid = QApplication::desktop()->width(); 304 int wid = QApplication::desktop()->width();
305 if ( wid < 640 ) 305 if ( wid < 640 )
306 wid = QApplication::desktop()->height(); 306 wid = QApplication::desktop()->height();
307#endif 307#endif
308 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 308 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
309 if ( true /*splitterSize.count() == 0*/ ) { 309 if ( true /*splitterSize.count() == 0*/ ) {
310 splitterSize.append( wid / 2 ); 310 splitterSize.append( wid / 2 );
311 splitterSize.append( wid / 2 ); 311 splitterSize.append( wid / 2 );
312 } 312 }
313 mMiniSplitter->setSizes( splitterSize ); 313 mMiniSplitter->setSizes( splitterSize );
314 if ( mExtensionBarSplitter ) { 314 if ( mExtensionBarSplitter ) {
315 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 315 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
316 if ( true /*splitterSize.count() == 0*/ ) { 316 if ( true /*splitterSize.count() == 0*/ ) {
317 splitterSize.append( wid / 2 ); 317 splitterSize.append( wid / 2 );
318 splitterSize.append( wid / 2 ); 318 splitterSize.append( wid / 2 );
319 } 319 }
320 mExtensionBarSplitter->setSizes( splitterSize ); 320 mExtensionBarSplitter->setSizes( splitterSize );
321 321
322 } 322 }
323 323
324 324
325} 325}
326 326
327void KABCore::saveSettings() 327void KABCore::saveSettings()
328{ 328{
329 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 329 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
330 if ( mExtensionBarSplitter ) 330 if ( mExtensionBarSplitter )
331 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 331 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
332 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 332 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
333 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 333 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
334#ifndef KAB_EMBEDDED 334#ifndef KAB_EMBEDDED
335 335
336 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 336 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
337 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 337 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
338#endif //KAB_EMBEDDED 338#endif //KAB_EMBEDDED
339 mExtensionManager->saveSettings(); 339 mExtensionManager->saveSettings();
340 mViewManager->saveSettings(); 340 mViewManager->saveSettings();
341 341
342 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 342 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
343} 343}
344 344
345KABC::AddressBook *KABCore::addressBook() const 345KABC::AddressBook *KABCore::addressBook() const
346{ 346{
347 return mAddressBook; 347 return mAddressBook;
348} 348}
349 349
350KConfig *KABCore::config() 350KConfig *KABCore::config()
351{ 351{
352#ifndef KAB_EMBEDDED 352#ifndef KAB_EMBEDDED
353 return KABPrefs::instance()->config(); 353 return KABPrefs::instance()->config();
354#else //KAB_EMBEDDED 354#else //KAB_EMBEDDED
355 return KABPrefs::instance()->getConfig(); 355 return KABPrefs::instance()->getConfig();
356#endif //KAB_EMBEDDED 356#endif //KAB_EMBEDDED
357} 357}
358 358
359KActionCollection *KABCore::actionCollection() const 359KActionCollection *KABCore::actionCollection() const
360{ 360{
361 return mGUIClient->actionCollection(); 361 return mGUIClient->actionCollection();
362} 362}
363 363
364KABC::Field *KABCore::currentSearchField() const 364KABC::Field *KABCore::currentSearchField() const
365{ 365{
366 if (mIncSearchWidget) 366 if (mIncSearchWidget)
367 return mIncSearchWidget->currentField(); 367 return mIncSearchWidget->currentField();
368 else 368 else
369 return 0; 369 return 0;
370} 370}
371 371
372QStringList KABCore::selectedUIDs() const 372QStringList KABCore::selectedUIDs() const
373{ 373{
374 return mViewManager->selectedUids(); 374 return mViewManager->selectedUids();
375} 375}
376 376
377KABC::Resource *KABCore::requestResource( QWidget *parent ) 377KABC::Resource *KABCore::requestResource( QWidget *parent )
378{ 378{
379 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 379 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
380 380
381 QPtrList<KRES::Resource> kresResources; 381 QPtrList<KRES::Resource> kresResources;
382 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 382 QPtrListIterator<KABC::Resource> resIt( kabcResources );
383 KABC::Resource *resource; 383 KABC::Resource *resource;
384 while ( ( resource = resIt.current() ) != 0 ) { 384 while ( ( resource = resIt.current() ) != 0 ) {
385 ++resIt; 385 ++resIt;
386 if ( !resource->readOnly() ) { 386 if ( !resource->readOnly() ) {
387 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 387 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
388 if ( res ) 388 if ( res )
389 kresResources.append( res ); 389 kresResources.append( res );
390 } 390 }
391 } 391 }
392 392
393 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 393 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
394 return static_cast<KABC::Resource*>( res ); 394 return static_cast<KABC::Resource*>( res );
395} 395}
396 396
397#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
398KAboutData *KABCore::createAboutData() 398KAboutData *KABCore::createAboutData()
399#else //KAB_EMBEDDED 399#else //KAB_EMBEDDED
400void KABCore::createAboutData() 400void KABCore::createAboutData()
401#endif //KAB_EMBEDDED 401#endif //KAB_EMBEDDED
402{ 402{
403#ifndef KAB_EMBEDDED 403#ifndef KAB_EMBEDDED
404 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 404 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
405 "3.1", I18N_NOOP( "The KDE Address Book" ), 405 "3.1", I18N_NOOP( "The KDE Address Book" ),
406 KAboutData::License_GPL_V2, 406 KAboutData::License_GPL_V2,
407 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 407 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
408 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 408 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
409 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 409 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
410 about->addAuthor( "Cornelius Schumacher", 410 about->addAuthor( "Cornelius Schumacher",
411 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 411 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
412 "schumacher@kde.org" ); 412 "schumacher@kde.org" );
413 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 413 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
414 "mpilone@slac.com" ); 414 "mpilone@slac.com" );
415 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 415 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
416 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 416 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
417 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 417 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
418 "michel@klaralvdalens-datakonsult.se" ); 418 "michel@klaralvdalens-datakonsult.se" );
419 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 419 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
420 "hansen@kde.org" ); 420 "hansen@kde.org" );
421 421
422 return about; 422 return about;
423#endif //KAB_EMBEDDED 423#endif //KAB_EMBEDDED
424 424
425 QString version; 425 QString version;
426#include <../version> 426#include <../version>
427 QMessageBox::about( this, "About KAddressbook/Pi", 427 QMessageBox::about( this, "About KAddressbook/Pi",
428 "KAddressbook/Platform-independent\n" 428 "KAddressbook/Platform-independent\n"
429 "(KA/Pi) " +version + " - " + 429 "(KA/Pi) " +version + " - " +
430#ifdef DESKTOP_VERSION 430#ifdef DESKTOP_VERSION
431 "Desktop Edition\n" 431 "Desktop Edition\n"
432#else 432#else
433 "PDA-Edition\n" 433 "PDA-Edition\n"
434 "for: Zaurus 5500 / 7x0 / 8x0\n" 434 "for: Zaurus 5500 / 7x0 / 8x0\n"
435#endif 435#endif
436 436
437 "(c) 2004 Ulf Schenk\n" 437 "(c) 2004 Ulf Schenk\n"
438 "(c) 2004 Lutz Rogowski\n" 438 "(c) 2004 Lutz Rogowski\n"
439 "(c) 1997-2003, The KDE PIM Team\n" 439 "(c) 1997-2003, The KDE PIM Team\n"
440 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 440 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
441 "Don Sanders Original author\n" 441 "Don Sanders Original author\n"
442 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 442 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
443 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 443 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
444 "Greg Stern DCOP interface\n" 444 "Greg Stern DCOP interface\n"
445 "Mark Westcot Contact pinning\n" 445 "Mark Westcot Contact pinning\n"
446 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 446 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
447 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 447 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
448#ifdef _WIN32_ 448#ifdef _WIN32_
449 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 449 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
450#endif 450#endif
451 ); 451 );
452} 452}
453 453
454void KABCore::setContactSelected( const QString &uid ) 454void KABCore::setContactSelected( const QString &uid )
455{ 455{
456 KABC::Addressee addr = mAddressBook->findByUid( uid ); 456 KABC::Addressee addr = mAddressBook->findByUid( uid );
457 if ( !mDetails->isHidden() ) 457 if ( !mDetails->isHidden() )
458 mDetails->setAddressee( addr ); 458 mDetails->setAddressee( addr );
459 459
460 if ( !addr.isEmpty() ) { 460 if ( !addr.isEmpty() ) {
461 emit contactSelected( addr.formattedName() ); 461 emit contactSelected( addr.formattedName() );
462 KABC::Picture pic = addr.photo(); 462 KABC::Picture pic = addr.photo();
463 if ( pic.isIntern() ) { 463 if ( pic.isIntern() ) {
464//US emit contactSelected( pic.data() ); 464//US emit contactSelected( pic.data() );
465//US instead use: 465//US instead use:
466 QPixmap px; 466 QPixmap px;
467 if (pic.data().isNull() != true) 467 if (pic.data().isNull() != true)
468 { 468 {
469 px.convertFromImage(pic.data()); 469 px.convertFromImage(pic.data());
470 } 470 }
471 471
472 emit contactSelected( px ); 472 emit contactSelected( px );
473 } 473 }
474 } 474 }
475 475
476 476
477 mExtensionManager->setSelectionChanged(); 477 mExtensionManager->setSelectionChanged();
478 478
479 // update the actions 479 // update the actions
480 bool selected = !uid.isEmpty(); 480 bool selected = !uid.isEmpty();
481 481
482 if ( mReadWrite ) { 482 if ( mReadWrite ) {
483 mActionCut->setEnabled( selected ); 483 mActionCut->setEnabled( selected );
484 mActionPaste->setEnabled( selected ); 484 mActionPaste->setEnabled( selected );
485 } 485 }
486 486
487 mActionCopy->setEnabled( selected ); 487 mActionCopy->setEnabled( selected );
488 mActionDelete->setEnabled( selected ); 488 mActionDelete->setEnabled( selected );
489 mActionEditAddressee->setEnabled( selected ); 489 mActionEditAddressee->setEnabled( selected );
490 mActionMail->setEnabled( selected ); 490 mActionMail->setEnabled( selected );
491 mActionMailVCard->setEnabled( selected ); 491 mActionMailVCard->setEnabled( selected );
492 //if (mActionBeam) 492 //if (mActionBeam)
493 //mActionBeam->setEnabled( selected ); 493 //mActionBeam->setEnabled( selected );
494 494
495 if (mActionBeamVCard) 495 if (mActionBeamVCard)
496 mActionBeamVCard->setEnabled( selected ); 496 mActionBeamVCard->setEnabled( selected );
497 497
498 mActionWhoAmI->setEnabled( selected ); 498 mActionWhoAmI->setEnabled( selected );
499 mActionCategories->setEnabled( selected ); 499 mActionCategories->setEnabled( selected );
500} 500}
501 501
502void KABCore::sendMail() 502void KABCore::sendMail()
503{ 503{
504 sendMail( mViewManager->selectedEmails().join( ", " ) ); 504 sendMail( mViewManager->selectedEmails().join( ", " ) );
505} 505}
506 506
507void KABCore::sendMail( const QString& emaillist ) 507void KABCore::sendMail( const QString& emaillist )
508{ 508{
509 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 509 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
510 if (emaillist.contains(",") > 0) 510 if (emaillist.contains(",") > 0)
511 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 511 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
512 else 512 else
513 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 513 ExternalAppHandler::instance()->mailToOneContact( emaillist );
514} 514}
515 515
516 516
517 517
518void KABCore::mailVCard() 518void KABCore::mailVCard()
519{ 519{
520 QStringList uids = mViewManager->selectedUids(); 520 QStringList uids = mViewManager->selectedUids();
521 if ( !uids.isEmpty() ) 521 if ( !uids.isEmpty() )
522 mailVCard( uids ); 522 mailVCard( uids );
523} 523}
524 524
525void KABCore::mailVCard( const QStringList& uids ) 525void KABCore::mailVCard( const QStringList& uids )
526{ 526{
527 QStringList urls; 527 QStringList urls;
528 528
529// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 529// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
530 530
531 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 531 QString dirName = "/tmp/" + KApplication::randomString( 8 );
532 532
533 533
534 534
535 QDir().mkdir( dirName, true ); 535 QDir().mkdir( dirName, true );
536 536
537 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 537 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
538 KABC::Addressee a = mAddressBook->findByUid( *it ); 538 KABC::Addressee a = mAddressBook->findByUid( *it );
539 539
540 if ( a.isEmpty() ) 540 if ( a.isEmpty() )
541 continue; 541 continue;
542 542
543 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 543 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
544 544
545 QString fileName = dirName + "/" + name; 545 QString fileName = dirName + "/" + name;
546 546
547 QFile outFile(fileName); 547 QFile outFile(fileName);
548 548
549 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 549 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
550 KABC::VCardConverter converter; 550 KABC::VCardConverter converter;
551 QString vcard; 551 QString vcard;
552 552
553 converter.addresseeToVCard( a, vcard ); 553 converter.addresseeToVCard( a, vcard );
554 554
555 QTextStream t( &outFile ); // use a text stream 555 QTextStream t( &outFile ); // use a text stream
556 t.setEncoding( QTextStream::UnicodeUTF8 ); 556 t.setEncoding( QTextStream::UnicodeUTF8 );
557 t << vcard; 557 t << vcard;
558 558
559 outFile.close(); 559 outFile.close();
560 560
561 urls.append( fileName ); 561 urls.append( fileName );
562 } 562 }
563 } 563 }
564 564
565 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 565 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
566 566
567 567
568/*US 568/*US
569 kapp->invokeMailer( QString::null, QString::null, QString::null, 569 kapp->invokeMailer( QString::null, QString::null, QString::null,
570 QString::null, // subject 570 QString::null, // subject
571 QString::null, // body 571 QString::null, // body
572 QString::null, 572 QString::null,
573 urls ); // attachments 573 urls ); // attachments
574*/ 574*/
575 575
576} 576}
577 577
578/** 578/**
579 Beams the "WhoAmI contact. 579 Beams the "WhoAmI contact.
580*/ 580*/
581void KABCore::beamMySelf() 581void KABCore::beamMySelf()
582{ 582{
583 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 583 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
584 if (!a.isEmpty()) 584 if (!a.isEmpty())
585 { 585 {
586 QStringList uids; 586 QStringList uids;
587 uids << a.uid(); 587 uids << a.uid();
588 588
589 beamVCard(uids); 589 beamVCard(uids);
590 } else { 590 } else {
591 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 591 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
592 592
593 593
594 } 594 }
595} 595}
596 596
597void KABCore::beamVCard() 597void KABCore::beamVCard()
598{ 598{
599 QStringList uids = mViewManager->selectedUids(); 599 QStringList uids = mViewManager->selectedUids();
600 if ( !uids.isEmpty() ) 600 if ( !uids.isEmpty() )
601 beamVCard( uids ); 601 beamVCard( uids );
602} 602}
603 603
604 604
605void KABCore::beamVCard(const QStringList& uids) 605void KABCore::beamVCard(const QStringList& uids)
606{ 606{
607/*US 607/*US
608 QString beamFilename; 608 QString beamFilename;
609 Opie::OPimContact c; 609 Opie::OPimContact c;
610 if ( actionPersonal->isOn() ) { 610 if ( actionPersonal->isOn() ) {
611 beamFilename = addressbookPersonalVCardName(); 611 beamFilename = addressbookPersonalVCardName();
612 if ( !QFile::exists( beamFilename ) ) 612 if ( !QFile::exists( beamFilename ) )
613 return; // can't beam a non-existent file 613 return; // can't beam a non-existent file
614 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 614 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
615 beamFilename ); 615 beamFilename );
616 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 616 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
617 Opie::OPimContactAccess::List allList = access->allRecords(); 617 Opie::OPimContactAccess::List allList = access->allRecords();
618 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 618 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
619 c = *it; 619 c = *it;
620 620
621 delete access; 621 delete access;
622 } else { 622 } else {
623 unlink( beamfile ); // delete if exists 623 unlink( beamfile ); // delete if exists
624 mkdir("/tmp/obex/", 0755); 624 mkdir("/tmp/obex/", 0755);
625 c = m_abView -> currentEntry(); 625 c = m_abView -> currentEntry();
626 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 626 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
627 beamfile ); 627 beamfile );
628 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 628 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
629 access->add( c ); 629 access->add( c );
630 access->save(); 630 access->save();
631 delete access; 631 delete access;
632 632
633 beamFilename = beamfile; 633 beamFilename = beamfile;
634 } 634 }
635 635
636 owarn << "Beaming: " << beamFilename << oendl; 636 owarn << "Beaming: " << beamFilename << oendl;
637*/ 637*/
638 638
639#if 0 639#if 0
640 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 640 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
641 641
642 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 642 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
643 643
644 QString name = "contact.vcf"; 644 QString name = "contact.vcf";
645 645
646 QString fileName = dirName + "/" + name; 646 QString fileName = dirName + "/" + name;
647#endif 647#endif
648 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 648 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
649 // 649 //
650 QString fileName = "/tmp/kapibeamfile.vcf"; 650 QString fileName = "/tmp/kapibeamfile.vcf";
651 651
652 652
653 //QDir().mkdir( dirName, true ); 653 //QDir().mkdir( dirName, true );
654 654
655 655
656 KABC::VCardConverter converter; 656 KABC::VCardConverter converter;
657 QString description; 657 QString description;
658 QString datastream; 658 QString datastream;
659 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 659 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
660 KABC::Addressee a = mAddressBook->findByUid( *it ); 660 KABC::Addressee a = mAddressBook->findByUid( *it );
661 661
662 if ( a.isEmpty() ) 662 if ( a.isEmpty() )
663 continue; 663 continue;
664 664
665 if (description.isEmpty()) 665 if (description.isEmpty())
666 description = a.formattedName(); 666 description = a.formattedName();
667 667
668 QString vcard; 668 QString vcard;
669 converter.addresseeToVCard( a, vcard ); 669 converter.addresseeToVCard( a, vcard );
670 int start = 0; 670 int start = 0;
671 int next; 671 int next;
672 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 672 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
673 int semi = vcard.find(";", next); 673 int semi = vcard.find(";", next);
674 int dopp = vcard.find(":", next); 674 int dopp = vcard.find(":", next);
675 int sep; 675 int sep;
676 if ( semi < dopp && semi >= 0 ) 676 if ( semi < dopp && semi >= 0 )
677 sep = semi ; 677 sep = semi ;
678 else 678 else
679 sep = dopp; 679 sep = dopp;
680 datastream +=vcard.mid( start, next - start); 680 datastream +=vcard.mid( start, next - start);
681 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 681 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
682 start = sep; 682 start = sep;
683 } 683 }
684 datastream += vcard.mid( start,vcard.length() ); 684 datastream += vcard.mid( start,vcard.length() );
685 } 685 }
686#ifndef DESKTOP_VERSION 686#ifndef DESKTOP_VERSION
687 QFile outFile(fileName); 687 QFile outFile(fileName);
688 if ( outFile.open(IO_WriteOnly) ) { 688 if ( outFile.open(IO_WriteOnly) ) {
689 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 689 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
690 QTextStream t( &outFile ); // use a text stream 690 QTextStream t( &outFile ); // use a text stream
691 t.setEncoding( QTextStream::UnicodeUTF8 ); 691 t.setEncoding( QTextStream::UnicodeUTF8 );
692 t <<datastream; 692 t <<datastream;
693 outFile.close(); 693 outFile.close();
694 Ir *ir = new Ir( this ); 694 Ir *ir = new Ir( this );
695 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 695 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
696 ir->send( fileName, description, "text/x-vCard" ); 696 ir->send( fileName, description, "text/x-vCard" );
697 } else { 697 } else {
698 qDebug("Error open temp beam file "); 698 qDebug("Error open temp beam file ");
699 return; 699 return;
700 } 700 }
701#endif 701#endif
702 702
703} 703}
704 704
705void KABCore::beamDone( Ir *ir ) 705void KABCore::beamDone( Ir *ir )
706{ 706{
707#ifndef DESKTOP_VERSION 707#ifndef DESKTOP_VERSION
708 delete ir; 708 delete ir;
709#endif 709#endif
710} 710}
711 711
712 712
713void KABCore::browse( const QString& url ) 713void KABCore::browse( const QString& url )
714{ 714{
715#ifndef KAB_EMBEDDED 715#ifndef KAB_EMBEDDED
716 kapp->invokeBrowser( url ); 716 kapp->invokeBrowser( url );
717#else //KAB_EMBEDDED 717#else //KAB_EMBEDDED
718 qDebug("KABCore::browse must be fixed"); 718 qDebug("KABCore::browse must be fixed");
719#endif //KAB_EMBEDDED 719#endif //KAB_EMBEDDED
720} 720}
721 721
722void KABCore::selectAllContacts() 722void KABCore::selectAllContacts()
723{ 723{
724 mViewManager->setSelected( QString::null, true ); 724 mViewManager->setSelected( QString::null, true );
725} 725}
726 726
727void KABCore::deleteContacts() 727void KABCore::deleteContacts()
728{ 728{
729 QStringList uidList = mViewManager->selectedUids(); 729 QStringList uidList = mViewManager->selectedUids();
730 deleteContacts( uidList ); 730 deleteContacts( uidList );
731} 731}
732 732
733void KABCore::deleteContacts( const QStringList &uids ) 733void KABCore::deleteContacts( const QStringList &uids )
734{ 734{
735 if ( uids.count() > 0 ) { 735 if ( uids.count() > 0 ) {
736 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 736 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
737 UndoStack::instance()->push( command ); 737 UndoStack::instance()->push( command );
738 RedoStack::instance()->clear(); 738 RedoStack::instance()->clear();
739 739
740 // now if we deleted anything, refresh 740 // now if we deleted anything, refresh
741 setContactSelected( QString::null ); 741 setContactSelected( QString::null );
742 setModified( true ); 742 setModified( true );
743 } 743 }
744} 744}
745 745
746void KABCore::copyContacts() 746void KABCore::copyContacts()
747{ 747{
748 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 748 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
749 749
750 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 750 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
751 751
752 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 752 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
753 753
754 QClipboard *cb = QApplication::clipboard(); 754 QClipboard *cb = QApplication::clipboard();
755 cb->setText( clipText ); 755 cb->setText( clipText );
756} 756}
757 757
758void KABCore::cutContacts() 758void KABCore::cutContacts()
759{ 759{
760 QStringList uidList = mViewManager->selectedUids(); 760 QStringList uidList = mViewManager->selectedUids();
761 761
762//US if ( uidList.size() > 0 ) { 762//US if ( uidList.size() > 0 ) {
763 if ( uidList.count() > 0 ) { 763 if ( uidList.count() > 0 ) {
764 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 764 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
765 UndoStack::instance()->push( command ); 765 UndoStack::instance()->push( command );
766 RedoStack::instance()->clear(); 766 RedoStack::instance()->clear();
767 767
768 setModified( true ); 768 setModified( true );
769 } 769 }
770} 770}
771 771
772void KABCore::pasteContacts() 772void KABCore::pasteContacts()
773{ 773{
774 QClipboard *cb = QApplication::clipboard(); 774 QClipboard *cb = QApplication::clipboard();
775 775
776 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 776 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
777 777
778 pasteContacts( list ); 778 pasteContacts( list );
779} 779}
780 780
781void KABCore::pasteContacts( KABC::Addressee::List &list ) 781void KABCore::pasteContacts( KABC::Addressee::List &list )
782{ 782{
783 KABC::Resource *resource = requestResource( this ); 783 KABC::Resource *resource = requestResource( this );
784 KABC::Addressee::List::Iterator it; 784 KABC::Addressee::List::Iterator it;
785 for ( it = list.begin(); it != list.end(); ++it ) 785 for ( it = list.begin(); it != list.end(); ++it )
786 (*it).setResource( resource ); 786 (*it).setResource( resource );
787 787
788 PwPasteCommand *command = new PwPasteCommand( this, list ); 788 PwPasteCommand *command = new PwPasteCommand( this, list );
789 UndoStack::instance()->push( command ); 789 UndoStack::instance()->push( command );
790 RedoStack::instance()->clear(); 790 RedoStack::instance()->clear();
791 791
792 setModified( true ); 792 setModified( true );
793} 793}
794 794
795void KABCore::setWhoAmI() 795void KABCore::setWhoAmI()
796{ 796{
797 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 797 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
798 798
799 if ( addrList.count() > 1 ) { 799 if ( addrList.count() > 1 ) {
800 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 800 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
801 return; 801 return;
802 } 802 }
803 803
804 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 804 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
805 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 805 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
806 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 806 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
807} 807}
808 808
809void KABCore::setCategories() 809void KABCore::setCategories()
810{ 810{
811 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 811 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
812 if ( !dlg.exec() ) 812 if ( !dlg.exec() )
813 return; 813 return;
814 814
815 bool merge = false; 815 bool merge = false;
816 QString msg = i18n( "Merge with existing categories?" ); 816 QString msg = i18n( "Merge with existing categories?" );
817 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 817 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
818 merge = true; 818 merge = true;
819 819
820 QStringList categories = dlg.selectedCategories(); 820 QStringList categories = dlg.selectedCategories();
821 821
822 QStringList uids = mViewManager->selectedUids(); 822 QStringList uids = mViewManager->selectedUids();
823 QStringList::Iterator it; 823 QStringList::Iterator it;
824 for ( it = uids.begin(); it != uids.end(); ++it ) { 824 for ( it = uids.begin(); it != uids.end(); ++it ) {
825 KABC::Addressee addr = mAddressBook->findByUid( *it ); 825 KABC::Addressee addr = mAddressBook->findByUid( *it );
826 if ( !addr.isEmpty() ) { 826 if ( !addr.isEmpty() ) {
827 if ( !merge ) 827 if ( !merge )
828 addr.setCategories( categories ); 828 addr.setCategories( categories );
829 else { 829 else {
830 QStringList addrCategories = addr.categories(); 830 QStringList addrCategories = addr.categories();
831 QStringList::Iterator catIt; 831 QStringList::Iterator catIt;
832 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 832 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
833 if ( !addrCategories.contains( *catIt ) ) 833 if ( !addrCategories.contains( *catIt ) )
834 addrCategories.append( *catIt ); 834 addrCategories.append( *catIt );
835 } 835 }
836 addr.setCategories( addrCategories ); 836 addr.setCategories( addrCategories );
837 } 837 }
838 838
839 mAddressBook->insertAddressee( addr ); 839 mAddressBook->insertAddressee( addr );
840 } 840 }
841 } 841 }
842 842
843 if ( uids.count() > 0 ) 843 if ( uids.count() > 0 )
844 setModified( true ); 844 setModified( true );
845} 845}
846 846
847void KABCore::setSearchFields( const KABC::Field::List &fields ) 847void KABCore::setSearchFields( const KABC::Field::List &fields )
848{ 848{
849 mIncSearchWidget->setFields( fields ); 849 mIncSearchWidget->setFields( fields );
850} 850}
851 851
852void KABCore::incrementalSearch( const QString& text ) 852void KABCore::incrementalSearch( const QString& text )
853{ 853{
854 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 854 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
855} 855}
856 856
857void KABCore::setModified() 857void KABCore::setModified()
858{ 858{
859 setModified( true ); 859 setModified( true );
860} 860}
861 861
862void KABCore::setModifiedWOrefresh() 862void KABCore::setModifiedWOrefresh()
863{ 863{
864 // qDebug("KABCore::setModifiedWOrefresh() "); 864 // qDebug("KABCore::setModifiedWOrefresh() ");
865 mModified = true; 865 mModified = true;
866 mActionSave->setEnabled( mModified ); 866 mActionSave->setEnabled( mModified );
867#ifdef DESKTOP_VERSION 867#ifdef DESKTOP_VERSION
868 mDetails->refreshView(); 868 mDetails->refreshView();
869#endif 869#endif
870 870
871} 871}
872void KABCore::setModified( bool modified ) 872void KABCore::setModified( bool modified )
873{ 873{
874 mModified = modified; 874 mModified = modified;
875 mActionSave->setEnabled( mModified ); 875 mActionSave->setEnabled( mModified );
876 876
877 if ( modified ) 877 if ( modified )
878 mJumpButtonBar->recreateButtons(); 878 mJumpButtonBar->recreateButtons();
879 879
880 mViewManager->refreshView(); 880 mViewManager->refreshView();
881 mDetails->refreshView(); 881 mDetails->refreshView();
882 882
883} 883}
884 884
885bool KABCore::modified() const 885bool KABCore::modified() const
886{ 886{
887 return mModified; 887 return mModified;
888} 888}
889 889
890void KABCore::contactModified( const KABC::Addressee &addr ) 890void KABCore::contactModified( const KABC::Addressee &addr )
891{ 891{
892 892
893 Command *command = 0; 893 Command *command = 0;
894 QString uid; 894 QString uid;
895 895
896 // check if it exists already 896 // check if it exists already
897 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 897 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
898 if ( origAddr.isEmpty() ) 898 if ( origAddr.isEmpty() )
899 command = new PwNewCommand( mAddressBook, addr ); 899 command = new PwNewCommand( mAddressBook, addr );
900 else { 900 else {
901 command = new PwEditCommand( mAddressBook, origAddr, addr ); 901 command = new PwEditCommand( mAddressBook, origAddr, addr );
902 uid = addr.uid(); 902 uid = addr.uid();
903 } 903 }
904 904
905 UndoStack::instance()->push( command ); 905 UndoStack::instance()->push( command );
906 RedoStack::instance()->clear(); 906 RedoStack::instance()->clear();
907 907
908 setModified( true ); 908 setModified( true );
909} 909}
910 910
911void KABCore::newContact() 911void KABCore::newContact()
912{ 912{
913 913
914 914
915 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 915 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
916 916
917 QPtrList<KRES::Resource> kresResources; 917 QPtrList<KRES::Resource> kresResources;
918 QPtrListIterator<KABC::Resource> it( kabcResources ); 918 QPtrListIterator<KABC::Resource> it( kabcResources );
919 KABC::Resource *resource; 919 KABC::Resource *resource;
920 while ( ( resource = it.current() ) != 0 ) { 920 while ( ( resource = it.current() ) != 0 ) {
921 ++it; 921 ++it;
922 if ( !resource->readOnly() ) { 922 if ( !resource->readOnly() ) {
923 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 923 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
924 if ( res ) 924 if ( res )
925 kresResources.append( res ); 925 kresResources.append( res );
926 } 926 }
927 } 927 }
928 928
929 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 929 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
930 resource = static_cast<KABC::Resource*>( res ); 930 resource = static_cast<KABC::Resource*>( res );
931 931
932 if ( resource ) { 932 if ( resource ) {
933 KABC::Addressee addr; 933 KABC::Addressee addr;
934 addr.setResource( resource ); 934 addr.setResource( resource );
935 mEditorDialog->setAddressee( addr ); 935 mEditorDialog->setAddressee( addr );
936 KApplication::execDialog ( mEditorDialog ); 936 KApplication::execDialog ( mEditorDialog );
937 937
938 } else 938 } else
939 return; 939 return;
940 940
941 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 941 // mEditorDict.insert( dialog->addressee().uid(), dialog );
942 942
943 943
944} 944}
945 945
946void KABCore::addEmail( QString aStr ) 946void KABCore::addEmail( QString aStr )
947{ 947{
948#ifndef KAB_EMBEDDED 948#ifndef KAB_EMBEDDED
949 QString fullName, email; 949 QString fullName, email;
950 950
951 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 951 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
952 952
953 // Try to lookup the addressee matching the email address 953 // Try to lookup the addressee matching the email address
954 bool found = false; 954 bool found = false;
955 QStringList emailList; 955 QStringList emailList;
956 KABC::AddressBook::Iterator it; 956 KABC::AddressBook::Iterator it;
957 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 957 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
958 emailList = (*it).emails(); 958 emailList = (*it).emails();
959 if ( emailList.contains( email ) > 0 ) { 959 if ( emailList.contains( email ) > 0 ) {
960 found = true; 960 found = true;
961 (*it).setNameFromString( fullName ); 961 (*it).setNameFromString( fullName );
962 editContact( (*it).uid() ); 962 editContact( (*it).uid() );
963 } 963 }
964 } 964 }
965 965
966 if ( !found ) { 966 if ( !found ) {
967 KABC::Addressee addr; 967 KABC::Addressee addr;
968 addr.setNameFromString( fullName ); 968 addr.setNameFromString( fullName );
969 addr.insertEmail( email, true ); 969 addr.insertEmail( email, true );
970 970
971 mAddressBook->insertAddressee( addr ); 971 mAddressBook->insertAddressee( addr );
972 mViewManager->refreshView( addr.uid() ); 972 mViewManager->refreshView( addr.uid() );
973 editContact( addr.uid() ); 973 editContact( addr.uid() );
974 } 974 }
975#else //KAB_EMBEDDED 975#else //KAB_EMBEDDED
976 qDebug("KABCore::addEmail finsih method"); 976 qDebug("KABCore::addEmail finsih method");
977#endif //KAB_EMBEDDED 977#endif //KAB_EMBEDDED
978} 978}
979 979
980void KABCore::importVCard( const KURL &url, bool showPreview ) 980void KABCore::importVCard( const KURL &url, bool showPreview )
981{ 981{
982 mXXPortManager->importVCard( url, showPreview ); 982 mXXPortManager->importVCard( url, showPreview );
983} 983}
984void KABCore::importFromOL() 984void KABCore::importFromOL()
985{ 985{
986#ifdef _WIN32_ 986#ifdef _WIN32_
987 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 987 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
988 idgl->exec(); 988 idgl->exec();
989 KABC::Addressee::List list = idgl->getAddressList(); 989 KABC::Addressee::List list = idgl->getAddressList();
990 if ( list.count() > 0 ) { 990 if ( list.count() > 0 ) {
991 KABC::Addressee::List listNew; 991 KABC::Addressee::List listNew;
992 KABC::Addressee::List listExisting; 992 KABC::Addressee::List listExisting;
993 KABC::Addressee::List::Iterator it; 993 KABC::Addressee::List::Iterator it;
994 KABC::AddressBook::Iterator iter; 994 KABC::AddressBook::Iterator iter;
995 for ( it = list.begin(); it != list.end(); ++it ) { 995 for ( it = list.begin(); it != list.end(); ++it ) {
996 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 996 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
997 listNew.append( (*it) ); 997 listNew.append( (*it) );
998 else 998 else
999 listExisting.append( (*it) ); 999 listExisting.append( (*it) );
1000 } 1000 }
1001 if ( listExisting.count() > 0 ) 1001 if ( listExisting.count() > 0 )
1002 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1002 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1003 if ( listNew.count() > 0 ) { 1003 if ( listNew.count() > 0 ) {
1004 pasteWithNewUid = false; 1004 pasteWithNewUid = false;
1005 pasteContacts( listNew ); 1005 pasteContacts( listNew );
1006 pasteWithNewUid = true; 1006 pasteWithNewUid = true;
1007 } 1007 }
1008 } 1008 }
1009 delete idgl; 1009 delete idgl;
1010#endif 1010#endif
1011} 1011}
1012 1012
1013void KABCore::importVCard( const QString &vCard, bool showPreview ) 1013void KABCore::importVCard( const QString &vCard, bool showPreview )
1014{ 1014{
1015 mXXPortManager->importVCard( vCard, showPreview ); 1015 mXXPortManager->importVCard( vCard, showPreview );
1016} 1016}
1017 1017
1018//US added a second method without defaultparameter 1018//US added a second method without defaultparameter
1019void KABCore::editContact2() { 1019void KABCore::editContact2() {
1020 editContact( QString::null ); 1020 editContact( QString::null );
1021} 1021}
1022 1022
1023void KABCore::editContact( const QString &uid ) 1023void KABCore::editContact( const QString &uid )
1024{ 1024{
1025 1025
1026 if ( mExtensionManager->isQuickEditVisible() ) 1026 if ( mExtensionManager->isQuickEditVisible() )
1027 return; 1027 return;
1028 1028
1029 // First, locate the contact entry 1029 // First, locate the contact entry
1030 QString localUID = uid; 1030 QString localUID = uid;
1031 if ( localUID.isNull() ) { 1031 if ( localUID.isNull() ) {
1032 QStringList uidList = mViewManager->selectedUids(); 1032 QStringList uidList = mViewManager->selectedUids();
1033 if ( uidList.count() > 0 ) 1033 if ( uidList.count() > 0 )
1034 localUID = *( uidList.at( 0 ) ); 1034 localUID = *( uidList.at( 0 ) );
1035 } 1035 }
1036 1036
1037 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1037 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1038 if ( !addr.isEmpty() ) { 1038 if ( !addr.isEmpty() ) {
1039 mEditorDialog->setAddressee( addr ); 1039 mEditorDialog->setAddressee( addr );
1040 KApplication::execDialog ( mEditorDialog ); 1040 KApplication::execDialog ( mEditorDialog );
1041 } 1041 }
1042} 1042}
1043 1043
1044/** 1044/**
1045 Shows or edits the detail view for the given uid. If the uid is QString::null, 1045 Shows or edits the detail view for the given uid. If the uid is QString::null,
1046 the method will try to find a selected addressee in the view. 1046 the method will try to find a selected addressee in the view.
1047 */ 1047 */
1048void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1048void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1049{ 1049{
1050 if ( mMultipleViewsAtOnce ) 1050 if ( mMultipleViewsAtOnce )
1051 { 1051 {
1052 editContact( uid ); 1052 editContact( uid );
1053 } 1053 }
1054 else 1054 else
1055 { 1055 {
1056 setDetailsVisible( true ); 1056 setDetailsVisible( true );
1057 mActionDetails->setChecked(true); 1057 mActionDetails->setChecked(true);
1058 } 1058 }
1059 1059
1060} 1060}
1061 1061
1062void KABCore::save() 1062void KABCore::save()
1063{ 1063{
1064 if ( !mModified ) 1064 if ( !mModified )
1065 return; 1065 return;
1066 QString text = i18n( "There was an error while attempting to save\n the " 1066 QString text = i18n( "There was an error while attempting to save\n the "
1067 "address book. Please check that some \nother application is " 1067 "address book. Please check that some \nother application is "
1068 "not using it. " ); 1068 "not using it. " );
1069 statusMessage(i18n("Saving addressbook ... ")); 1069 statusMessage(i18n("Saving addressbook ... "));
1070#ifndef KAB_EMBEDDED 1070#ifndef KAB_EMBEDDED
1071 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1071 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1072 if ( !b || !b->save() ) { 1072 if ( !b || !b->save() ) {
1073 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1073 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1074 } 1074 }
1075#else //KAB_EMBEDDED 1075#else //KAB_EMBEDDED
1076 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1076 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1077 if ( !b || !b->save() ) { 1077 if ( !b || !b->save() ) {
1078 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1078 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1079 } 1079 }
1080#endif //KAB_EMBEDDED 1080#endif //KAB_EMBEDDED
1081 1081
1082 statusMessage(i18n("Addressbook saved!")); 1082 statusMessage(i18n("Addressbook saved!"));
1083 setModified( false ); 1083 setModified( false );
1084} 1084}
1085 1085
1086void KABCore::statusMessage(QString mess , int time ) 1086void KABCore::statusMessage(QString mess , int time )
1087{ 1087{
1088 //topLevelWidget()->setCaption( mess ); 1088 //topLevelWidget()->setCaption( mess );
1089 // pending setting timer to revome message 1089 // pending setting timer to revome message
1090} 1090}
1091void KABCore::undo() 1091void KABCore::undo()
1092{ 1092{
1093 UndoStack::instance()->undo(); 1093 UndoStack::instance()->undo();
1094 1094
1095 // Refresh the view 1095 // Refresh the view
1096 mViewManager->refreshView(); 1096 mViewManager->refreshView();
1097} 1097}
1098 1098
1099void KABCore::redo() 1099void KABCore::redo()
1100{ 1100{
1101 RedoStack::instance()->redo(); 1101 RedoStack::instance()->redo();
1102 1102
1103 // Refresh the view 1103 // Refresh the view
1104 mViewManager->refreshView(); 1104 mViewManager->refreshView();
1105} 1105}
1106 1106
1107void KABCore::setJumpButtonBarVisible( bool visible ) 1107void KABCore::setJumpButtonBarVisible( bool visible )
1108{ 1108{
1109 if (mMultipleViewsAtOnce) 1109 if (mMultipleViewsAtOnce)
1110 { 1110 {
1111 if ( visible ) 1111 if ( visible )
1112 mJumpButtonBar->show(); 1112 mJumpButtonBar->show();
1113 else 1113 else
1114 mJumpButtonBar->hide(); 1114 mJumpButtonBar->hide();
1115 } 1115 }
1116 else 1116 else
1117 { 1117 {
1118 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1118 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1119 if (mViewManager->isVisible()) 1119 if (mViewManager->isVisible())
1120 { 1120 {
1121 if ( visible ) 1121 if ( visible )
1122 mJumpButtonBar->show(); 1122 mJumpButtonBar->show();
1123 else 1123 else
1124 mJumpButtonBar->hide(); 1124 mJumpButtonBar->hide();
1125 } 1125 }
1126 else 1126 else
1127 { 1127 {
1128 mJumpButtonBar->hide(); 1128 mJumpButtonBar->hide();
1129 } 1129 }
1130 } 1130 }
1131} 1131}
1132 1132
1133 1133
1134void KABCore::setDetailsToState() 1134void KABCore::setDetailsToState()
1135{ 1135{
1136 setDetailsVisible( mActionDetails->isChecked() ); 1136 setDetailsVisible( mActionDetails->isChecked() );
1137} 1137}
1138 1138
1139 1139
1140 1140
1141void KABCore::setDetailsVisible( bool visible ) 1141void KABCore::setDetailsVisible( bool visible )
1142{ 1142{
1143 if (visible && mDetails->isHidden()) 1143 if (visible && mDetails->isHidden())
1144 { 1144 {
1145 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1145 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1146 if ( addrList.count() > 0 ) 1146 if ( addrList.count() > 0 )
1147 mDetails->setAddressee( addrList[ 0 ] ); 1147 mDetails->setAddressee( addrList[ 0 ] );
1148 } 1148 }
1149 1149
1150 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1150 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1151 // the listview and the detailview. We do that by changing the splitbar size. 1151 // the listview and the detailview. We do that by changing the splitbar size.
1152 if (mMultipleViewsAtOnce) 1152 if (mMultipleViewsAtOnce)
1153 { 1153 {
1154 if ( visible ) 1154 if ( visible )
1155 mDetails->show(); 1155 mDetails->show();
1156 else 1156 else
1157 mDetails->hide(); 1157 mDetails->hide();
1158 } 1158 }
1159 else 1159 else
1160 { 1160 {
1161 if ( visible ) { 1161 if ( visible ) {
1162 mViewManager->hide(); 1162 mViewManager->hide();
1163 mDetails->show(); 1163 mDetails->show();
1164 } 1164 }
1165 else { 1165 else {
1166 mViewManager->show(); 1166 mViewManager->show();
1167 mDetails->hide(); 1167 mDetails->hide();
1168 } 1168 }
1169 setJumpButtonBarVisible( !visible ); 1169 setJumpButtonBarVisible( !visible );
1170 } 1170 }
1171 1171
1172} 1172}
1173 1173
1174void KABCore::extensionChanged( int id ) 1174void KABCore::extensionChanged( int id )
1175{ 1175{
1176 //change the details view only for non desktop systems 1176 //change the details view only for non desktop systems
1177#ifndef DESKTOP_VERSION 1177#ifndef DESKTOP_VERSION
1178 1178
1179 if (id == 0) 1179 if (id == 0)
1180 { 1180 {
1181 //the user disabled the extension. 1181 //the user disabled the extension.
1182 1182
1183 if (mMultipleViewsAtOnce) 1183 if (mMultipleViewsAtOnce)
1184 { // enable detailsview again 1184 { // enable detailsview again
1185 setDetailsVisible( true ); 1185 setDetailsVisible( true );
1186 mActionDetails->setChecked( true ); 1186 mActionDetails->setChecked( true );
1187 } 1187 }
1188 else 1188 else
1189 { //go back to the listview 1189 { //go back to the listview
1190 setDetailsVisible( false ); 1190 setDetailsVisible( false );
1191 mActionDetails->setChecked( false ); 1191 mActionDetails->setChecked( false );
1192 mActionDetails->setEnabled(true); 1192 mActionDetails->setEnabled(true);
1193 } 1193 }
1194 1194
1195 } 1195 }
1196 else 1196 else
1197 { 1197 {
1198 //the user enabled the extension. 1198 //the user enabled the extension.
1199 setDetailsVisible( false ); 1199 setDetailsVisible( false );
1200 mActionDetails->setChecked( false ); 1200 mActionDetails->setChecked( false );
1201 1201
1202 if (!mMultipleViewsAtOnce) 1202 if (!mMultipleViewsAtOnce)
1203 { 1203 {
1204 mActionDetails->setEnabled(false); 1204 mActionDetails->setEnabled(false);
1205 } 1205 }
1206 1206
1207 mExtensionManager->setSelectionChanged(); 1207 mExtensionManager->setSelectionChanged();
1208 1208
1209 } 1209 }
1210 1210
1211#endif// DESKTOP_VERSION 1211#endif// DESKTOP_VERSION
1212 1212
1213} 1213}
1214 1214
1215 1215
1216void KABCore::extensionModified( const KABC::Addressee::List &list ) 1216void KABCore::extensionModified( const KABC::Addressee::List &list )
1217{ 1217{
1218 1218
1219 if ( list.count() != 0 ) { 1219 if ( list.count() != 0 ) {
1220 KABC::Addressee::List::ConstIterator it; 1220 KABC::Addressee::List::ConstIterator it;
1221 for ( it = list.begin(); it != list.end(); ++it ) 1221 for ( it = list.begin(); it != list.end(); ++it )
1222 mAddressBook->insertAddressee( *it ); 1222 mAddressBook->insertAddressee( *it );
1223 if ( list.count() > 1 ) 1223 if ( list.count() > 1 )
1224 setModified(); 1224 setModified();
1225 else 1225 else
1226 setModifiedWOrefresh(); 1226 setModifiedWOrefresh();
1227 } 1227 }
1228 if ( list.count() == 0 ) 1228 if ( list.count() == 0 )
1229 mViewManager->refreshView(); 1229 mViewManager->refreshView();
1230 else 1230 else
1231 mViewManager->refreshView( list[ 0 ].uid() ); 1231 mViewManager->refreshView( list[ 0 ].uid() );
1232 1232
1233 1233
1234 1234
1235} 1235}
1236 1236
1237QString KABCore::getNameByPhone( const QString &phone ) 1237QString KABCore::getNameByPhone( const QString &phone )
1238{ 1238{
1239#ifndef KAB_EMBEDDED 1239#ifndef KAB_EMBEDDED
1240 QRegExp r( "[/*/-/ ]" ); 1240 QRegExp r( "[/*/-/ ]" );
1241 QString localPhone( phone ); 1241 QString localPhone( phone );
1242 1242
1243 bool found = false; 1243 bool found = false;
1244 QString ownerName = ""; 1244 QString ownerName = "";
1245 KABC::AddressBook::Iterator iter; 1245 KABC::AddressBook::Iterator iter;
1246 KABC::PhoneNumber::List::Iterator phoneIter; 1246 KABC::PhoneNumber::List::Iterator phoneIter;
1247 KABC::PhoneNumber::List phoneList; 1247 KABC::PhoneNumber::List phoneList;
1248 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1248 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1249 phoneList = (*iter).phoneNumbers(); 1249 phoneList = (*iter).phoneNumbers();
1250 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1250 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1251 ++phoneIter) { 1251 ++phoneIter) {
1252 // Get rid of separator chars so just the numbers are compared. 1252 // Get rid of separator chars so just the numbers are compared.
1253 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1253 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1254 ownerName = (*iter).formattedName(); 1254 ownerName = (*iter).formattedName();
1255 found = true; 1255 found = true;
1256 } 1256 }
1257 } 1257 }
1258 } 1258 }
1259 1259
1260 return ownerName; 1260 return ownerName;
1261#else //KAB_EMBEDDED 1261#else //KAB_EMBEDDED
1262 qDebug("KABCore::getNameByPhone finsih method"); 1262 qDebug("KABCore::getNameByPhone finsih method");
1263 return ""; 1263 return "";
1264#endif //KAB_EMBEDDED 1264#endif //KAB_EMBEDDED
1265 1265
1266} 1266}
1267 1267
1268void KABCore::openConfigDialog() 1268void KABCore::openConfigDialog()
1269{ 1269{
1270 KABPrefs* kab_prefs = KABPrefs::instance(); 1270 KABPrefs* kab_prefs = KABPrefs::instance();
1271 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1271 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1272 1272
1273 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1273 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1274 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1274 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1275 ConfigureDialog->addModule(kabcfg ); 1275 ConfigureDialog->addModule(kabcfg );
1276 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1276 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1277 ConfigureDialog->addModule(kdelibcfg ); 1277 ConfigureDialog->addModule(kdelibcfg );
1278 1278
1279 1279
1280 1280
1281 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1281 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1282 this, SLOT( configurationChanged() ) ); 1282 this, SLOT( configurationChanged() ) );
1283 connect( ConfigureDialog, SIGNAL( okClicked() ), 1283 connect( ConfigureDialog, SIGNAL( okClicked() ),
1284 this, SLOT( configurationChanged() ) ); 1284 this, SLOT( configurationChanged() ) );
1285 saveSettings(); 1285 saveSettings();
1286#ifndef DESKTOP_VERSION 1286#ifndef DESKTOP_VERSION
1287 ConfigureDialog->showMaximized(); 1287 ConfigureDialog->showMaximized();
1288#endif 1288#endif
1289 if ( ConfigureDialog->exec() ) 1289 if ( ConfigureDialog->exec() )
1290 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1290 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1291 delete ConfigureDialog; 1291 delete ConfigureDialog;
1292} 1292}
1293 1293
1294void KABCore::openLDAPDialog() 1294void KABCore::openLDAPDialog()
1295{ 1295{
1296#ifndef KAB_EMBEDDED 1296#ifndef KAB_EMBEDDED
1297 if ( !mLdapSearchDialog ) { 1297 if ( !mLdapSearchDialog ) {
1298 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1298 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1299 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1299 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1300 SLOT( refreshView() ) ); 1300 SLOT( refreshView() ) );
1301 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1301 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1302 SLOT( setModified() ) ); 1302 SLOT( setModified() ) );
1303 } else 1303 } else
1304 mLdapSearchDialog->restoreSettings(); 1304 mLdapSearchDialog->restoreSettings();
1305 1305
1306 if ( mLdapSearchDialog->isOK() ) 1306 if ( mLdapSearchDialog->isOK() )
1307 mLdapSearchDialog->exec(); 1307 mLdapSearchDialog->exec();
1308#else //KAB_EMBEDDED 1308#else //KAB_EMBEDDED
1309 qDebug("KABCore::openLDAPDialog() finsih method"); 1309 qDebug("KABCore::openLDAPDialog() finsih method");
1310#endif //KAB_EMBEDDED 1310#endif //KAB_EMBEDDED
1311} 1311}
1312 1312
1313void KABCore::print() 1313void KABCore::print()
1314{ 1314{
1315#ifndef KAB_EMBEDDED 1315#ifndef KAB_EMBEDDED
1316 KPrinter printer; 1316 KPrinter printer;
1317 if ( !printer.setup( this ) ) 1317 if ( !printer.setup( this ) )
1318 return; 1318 return;
1319 1319
1320 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1320 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1321 mViewManager->selectedUids(), this ); 1321 mViewManager->selectedUids(), this );
1322 1322
1323 wizard.exec(); 1323 wizard.exec();
1324#else //KAB_EMBEDDED 1324#else //KAB_EMBEDDED
1325 qDebug("KABCore::print() finsih method"); 1325 qDebug("KABCore::print() finsih method");
1326#endif //KAB_EMBEDDED 1326#endif //KAB_EMBEDDED
1327 1327
1328} 1328}
1329 1329
1330 1330
1331void KABCore::addGUIClient( KXMLGUIClient *client ) 1331void KABCore::addGUIClient( KXMLGUIClient *client )
1332{ 1332{
1333 if ( mGUIClient ) 1333 if ( mGUIClient )
1334 mGUIClient->insertChildClient( client ); 1334 mGUIClient->insertChildClient( client );
1335 else 1335 else
1336 KMessageBox::error( this, "no KXMLGUICLient"); 1336 KMessageBox::error( this, "no KXMLGUICLient");
1337} 1337}
1338 1338
1339 1339
1340void KABCore::configurationChanged() 1340void KABCore::configurationChanged()
1341{ 1341{
1342 mExtensionManager->reconfigure(); 1342 mExtensionManager->reconfigure();
1343} 1343}
1344 1344
1345void KABCore::addressBookChanged() 1345void KABCore::addressBookChanged()
1346{ 1346{
1347/*US 1347/*US
1348 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1348 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1349 while ( it.current() ) { 1349 while ( it.current() ) {
1350 if ( it.current()->dirty() ) { 1350 if ( it.current()->dirty() ) {
1351 QString text = i18n( "Data has been changed externally. Unsaved " 1351 QString text = i18n( "Data has been changed externally. Unsaved "
1352 "changes will be lost." ); 1352 "changes will be lost." );
1353 KMessageBox::information( this, text ); 1353 KMessageBox::information( this, text );
1354 } 1354 }
1355 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1355 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1356 ++it; 1356 ++it;
1357 } 1357 }
1358*/ 1358*/
1359 if (mEditorDialog) 1359 if (mEditorDialog)
1360 { 1360 {
1361 if (mEditorDialog->dirty()) 1361 if (mEditorDialog->dirty())
1362 { 1362 {
1363 QString text = i18n( "Data has been changed externally. Unsaved " 1363 QString text = i18n( "Data has been changed externally. Unsaved "
1364 "changes will be lost." ); 1364 "changes will be lost." );
1365 KMessageBox::information( this, text ); 1365 KMessageBox::information( this, text );
1366 } 1366 }
1367 QString currentuid = mEditorDialog->addressee().uid(); 1367 QString currentuid = mEditorDialog->addressee().uid();
1368 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1368 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1369 } 1369 }
1370 mViewManager->refreshView(); 1370 mViewManager->refreshView();
1371// mDetails->refreshView(); 1371// mDetails->refreshView();
1372 1372
1373 1373
1374} 1374}
1375 1375
1376AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1376AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1377 const char *name ) 1377 const char *name )
1378{ 1378{
1379 1379
1380 if ( mEditorDialog == 0 ) { 1380 if ( mEditorDialog == 0 ) {
1381 mEditorDialog = new AddresseeEditorDialog( this, parent, 1381 mEditorDialog = new AddresseeEditorDialog( this, parent,
1382 name ? name : "editorDialog" ); 1382 name ? name : "editorDialog" );
1383 1383
1384 1384
1385 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1385 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1386 SLOT( contactModified( const KABC::Addressee& ) ) ); 1386 SLOT( contactModified( const KABC::Addressee& ) ) );
1387 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1387 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1388 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1388 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1389 } 1389 }
1390 1390
1391 return mEditorDialog; 1391 return mEditorDialog;
1392} 1392}
1393 1393
1394void KABCore::slotEditorDestroyed( const QString &uid ) 1394void KABCore::slotEditorDestroyed( const QString &uid )
1395{ 1395{
1396 //mEditorDict.remove( uid ); 1396 //mEditorDict.remove( uid );
1397} 1397}
1398 1398
1399void KABCore::initGUI() 1399void KABCore::initGUI()
1400{ 1400{
1401#ifndef KAB_EMBEDDED 1401#ifndef KAB_EMBEDDED
1402 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1402 QHBoxLayout *topLayout = new QHBoxLayout( this );
1403 topLayout->setSpacing( KDialogBase::spacingHint() ); 1403 topLayout->setSpacing( KDialogBase::spacingHint() );
1404 1404
1405 mExtensionBarSplitter = new QSplitter( this ); 1405 mExtensionBarSplitter = new QSplitter( this );
1406 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1406 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1407 1407
1408 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1408 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1409 1409
1410 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1410 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1411 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1411 mIncSearchWidget = new IncSearchWidget( viewSpace );
1412 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1412 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1413 SLOT( incrementalSearch( const QString& ) ) ); 1413 SLOT( incrementalSearch( const QString& ) ) );
1414 1414
1415 mViewManager = new ViewManager( this, viewSpace ); 1415 mViewManager = new ViewManager( this, viewSpace );
1416 viewSpace->setStretchFactor( mViewManager, 1 ); 1416 viewSpace->setStretchFactor( mViewManager, 1 );
1417 1417
1418 mDetails = new ViewContainer( mDetailsSplitter ); 1418 mDetails = new ViewContainer( mDetailsSplitter );
1419 1419
1420 mJumpButtonBar = new JumpButtonBar( this, this ); 1420 mJumpButtonBar = new JumpButtonBar( this, this );
1421 1421
1422 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1422 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1423 1423
1424 topLayout->addWidget( mExtensionBarSplitter ); 1424 topLayout->addWidget( mExtensionBarSplitter );
1425 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1425 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1426 topLayout->addWidget( mJumpButtonBar ); 1426 topLayout->addWidget( mJumpButtonBar );
1427 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1427 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1428 1428
1429 mXXPortManager = new XXPortManager( this, this ); 1429 mXXPortManager = new XXPortManager( this, this );
1430 1430
1431#else //KAB_EMBEDDED 1431#else //KAB_EMBEDDED
1432 //US initialize viewMenu before settingup viewmanager. 1432 //US initialize viewMenu before settingup viewmanager.
1433 // Viewmanager needs this menu to plugin submenues. 1433 // Viewmanager needs this menu to plugin submenues.
1434 viewMenu = new QPopupMenu( this ); 1434 viewMenu = new QPopupMenu( this );
1435 settingsMenu = new QPopupMenu( this ); 1435 settingsMenu = new QPopupMenu( this );
1436 //filterMenu = new QPopupMenu( this ); 1436 //filterMenu = new QPopupMenu( this );
1437 ImportMenu = new QPopupMenu( this ); 1437 ImportMenu = new QPopupMenu( this );
1438 ExportMenu = new QPopupMenu( this ); 1438 ExportMenu = new QPopupMenu( this );
1439 1439
1440 changeMenu= new QPopupMenu( this ); 1440 changeMenu= new QPopupMenu( this );
1441 1441
1442//US since we have no splitter for the embedded system, setup 1442//US since we have no splitter for the embedded system, setup
1443// a layout with two frames. One left and one right. 1443// a layout with two frames. One left and one right.
1444 1444
1445 QBoxLayout *topLayout; 1445 QBoxLayout *topLayout;
1446 1446
1447 // = new QHBoxLayout( this ); 1447 // = new QHBoxLayout( this );
1448// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1448// QBoxLayout *topLayout = (QBoxLayout*)layout();
1449 1449
1450// QWidget *mainBox = new QWidget( this ); 1450// QWidget *mainBox = new QWidget( this );
1451// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1451// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1452 1452
1453#ifdef DESKTOP_VERSION 1453#ifdef DESKTOP_VERSION
1454 topLayout = new QHBoxLayout( this ); 1454 topLayout = new QHBoxLayout( this );
1455 1455
1456 1456
1457 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1457 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1458 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1458 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1459 1459
1460 topLayout->addWidget(mMiniSplitter ); 1460 topLayout->addWidget(mMiniSplitter );
1461 1461
1462 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1462 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1463 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1463 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1464 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1464 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1465 mDetails = new ViewContainer( mMiniSplitter ); 1465 mDetails = new ViewContainer( mMiniSplitter );
1466 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1466 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1467#else 1467#else
1468 if ( QApplication::desktop()->width() > 480 ) { 1468 if ( QApplication::desktop()->width() > 480 ) {
1469 topLayout = new QHBoxLayout( this ); 1469 topLayout = new QHBoxLayout( this );
1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1472 } else { 1472 } else {
1473 1473
1474 topLayout = new QHBoxLayout( this ); 1474 topLayout = new QHBoxLayout( this );
1475 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1475 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1476 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1476 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1477 } 1477 }
1478 1478
1479 topLayout->addWidget(mMiniSplitter ); 1479 topLayout->addWidget(mMiniSplitter );
1480 mViewManager = new ViewManager( this, mMiniSplitter ); 1480 mViewManager = new ViewManager( this, mMiniSplitter );
1481 mDetails = new ViewContainer( mMiniSplitter ); 1481 mDetails = new ViewContainer( mMiniSplitter );
1482 1482
1483 1483
1484 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1484 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1485#endif 1485#endif
1486 //eh->hide(); 1486 //eh->hide();
1487 // topLayout->addWidget(mExtensionManager ); 1487 // topLayout->addWidget(mExtensionManager );
1488 1488
1489 1489
1490/*US 1490/*US
1491#ifndef KAB_NOSPLITTER 1491#ifndef KAB_NOSPLITTER
1492 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1492 QHBoxLayout *topLayout = new QHBoxLayout( this );
1493//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1493//US topLayout->setSpacing( KDialogBase::spacingHint() );
1494 topLayout->setSpacing( 10 ); 1494 topLayout->setSpacing( 10 );
1495 1495
1496 mDetailsSplitter = new QSplitter( this ); 1496 mDetailsSplitter = new QSplitter( this );
1497 1497
1498 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1498 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1499 1499
1500 mViewManager = new ViewManager( this, viewSpace ); 1500 mViewManager = new ViewManager( this, viewSpace );
1501 viewSpace->setStretchFactor( mViewManager, 1 ); 1501 viewSpace->setStretchFactor( mViewManager, 1 );
1502 1502
1503 mDetails = new ViewContainer( mDetailsSplitter ); 1503 mDetails = new ViewContainer( mDetailsSplitter );
1504 1504
1505 topLayout->addWidget( mDetailsSplitter ); 1505 topLayout->addWidget( mDetailsSplitter );
1506 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1506 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1507#else //KAB_NOSPLITTER 1507#else //KAB_NOSPLITTER
1508 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1508 QHBoxLayout *topLayout = new QHBoxLayout( this );
1509//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1509//US topLayout->setSpacing( KDialogBase::spacingHint() );
1510 topLayout->setSpacing( 10 ); 1510 topLayout->setSpacing( 10 );
1511 1511
1512// mDetailsSplitter = new QSplitter( this ); 1512// mDetailsSplitter = new QSplitter( this );
1513 1513
1514 QVBox *viewSpace = new QVBox( this ); 1514 QVBox *viewSpace = new QVBox( this );
1515 1515
1516 mViewManager = new ViewManager( this, viewSpace ); 1516 mViewManager = new ViewManager( this, viewSpace );
1517 viewSpace->setStretchFactor( mViewManager, 1 ); 1517 viewSpace->setStretchFactor( mViewManager, 1 );
1518 1518
1519 mDetails = new ViewContainer( this ); 1519 mDetails = new ViewContainer( this );
1520 1520
1521 topLayout->addWidget( viewSpace ); 1521 topLayout->addWidget( viewSpace );
1522// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1522// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1523 topLayout->addWidget( mDetails ); 1523 topLayout->addWidget( mDetails );
1524#endif //KAB_NOSPLITTER 1524#endif //KAB_NOSPLITTER
1525*/ 1525*/
1526 1526
1527 1527
1528#endif //KAB_EMBEDDED 1528#endif //KAB_EMBEDDED
1529 initActions(); 1529 initActions();
1530 1530
1531#ifdef KAB_EMBEDDED 1531#ifdef KAB_EMBEDDED
1532 addActionsManually(); 1532 addActionsManually();
1533 //US make sure the export and import menues are initialized before creating the xxPortManager. 1533 //US make sure the export and import menues are initialized before creating the xxPortManager.
1534 mXXPortManager = new XXPortManager( this, this ); 1534 mXXPortManager = new XXPortManager( this, this );
1535 1535
1536 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1536 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1537 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1537 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1538 // mActionQuit->plug ( mMainWindow->toolBar()); 1538 // mActionQuit->plug ( mMainWindow->toolBar());
1539 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1539 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1540 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1540 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1541 // mIncSearchWidget->hide(); 1541 // mIncSearchWidget->hide();
1542 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1542 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1543 SLOT( incrementalSearch( const QString& ) ) ); 1543 SLOT( incrementalSearch( const QString& ) ) );
1544 1544
1545 1545
1546 mJumpButtonBar = new JumpButtonBar( this, this ); 1546 mJumpButtonBar = new JumpButtonBar( this, this );
1547 1547
1548 topLayout->addWidget( mJumpButtonBar ); 1548 topLayout->addWidget( mJumpButtonBar );
1549//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1549//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1550 1550
1551// mMainWindow->getIconToolBar()->raise(); 1551// mMainWindow->getIconToolBar()->raise();
1552 1552
1553#endif //KAB_EMBEDDED 1553#endif //KAB_EMBEDDED
1554 1554
1555} 1555}
1556void KABCore::initActions() 1556void KABCore::initActions()
1557{ 1557{
1558//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1558//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1559 1559
1560#ifndef KAB_EMBEDDED 1560#ifndef KAB_EMBEDDED
1561 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1561 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1562 SLOT( clipboardDataChanged() ) ); 1562 SLOT( clipboardDataChanged() ) );
1563#endif //KAB_EMBEDDED 1563#endif //KAB_EMBEDDED
1564 1564
1565 // file menu 1565 // file menu
1566 if ( mIsPart ) { 1566 if ( mIsPart ) {
1567 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1567 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1568 SLOT( sendMail() ), actionCollection(), 1568 SLOT( sendMail() ), actionCollection(),
1569 "kaddressbook_mail" ); 1569 "kaddressbook_mail" );
1570 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1570 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1571 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1571 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1572 1572
1573 } else { 1573 } else {
1574 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1574 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1575 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1575 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1576 } 1576 }
1577 1577
1578 1578
1579 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1579 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1580 SLOT( save() ), actionCollection(), "file_sync" ); 1580 SLOT( save() ), actionCollection(), "file_sync" );
1581 1581
1582 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1582 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1583 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1583 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1584 1584
1585 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1585 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1586 this, SLOT( mailVCard() ), 1586 this, SLOT( mailVCard() ),
1587 actionCollection(), "file_mail_vcard"); 1587 actionCollection(), "file_mail_vcard");
1588 1588
1589 mActionBeamVCard = 0; 1589 mActionBeamVCard = 0;
1590 mActionBeam = 0; 1590 mActionBeam = 0;
1591 1591
1592#ifndef DESKTOP_VERSION 1592#ifndef DESKTOP_VERSION
1593 if ( Ir::supported() ) { 1593 if ( Ir::supported() ) {
1594 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1594 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1595 SLOT( beamVCard() ), actionCollection(), 1595 SLOT( beamVCard() ), actionCollection(),
1596 "kaddressbook_beam_vcard" ); 1596 "kaddressbook_beam_vcard" );
1597 1597
1598 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1598 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1599 SLOT( beamMySelf() ), actionCollection(), 1599 SLOT( beamMySelf() ), actionCollection(),
1600 "kaddressbook_beam_myself" ); 1600 "kaddressbook_beam_myself" );
1601 } 1601 }
1602#endif 1602#endif
1603 1603
1604 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1604 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1605 this, SLOT( editContact2() ), 1605 this, SLOT( editContact2() ),
1606 actionCollection(), "file_properties" ); 1606 actionCollection(), "file_properties" );
1607 1607
1608#ifdef KAB_EMBEDDED 1608#ifdef KAB_EMBEDDED
1609 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1609 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1610 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1610 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1611 mMainWindow, SLOT( exit() ), 1611 mMainWindow, SLOT( exit() ),
1612 actionCollection(), "quit" ); 1612 actionCollection(), "quit" );
1613#endif //KAB_EMBEDDED 1613#endif //KAB_EMBEDDED
1614 1614
1615 // edit menu 1615 // edit menu
1616 if ( mIsPart ) { 1616 if ( mIsPart ) {
1617 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1617 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1618 SLOT( copyContacts() ), actionCollection(), 1618 SLOT( copyContacts() ), actionCollection(),
1619 "kaddressbook_copy" ); 1619 "kaddressbook_copy" );
1620 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1620 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1621 SLOT( cutContacts() ), actionCollection(), 1621 SLOT( cutContacts() ), actionCollection(),
1622 "kaddressbook_cut" ); 1622 "kaddressbook_cut" );
1623 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1623 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1624 SLOT( pasteContacts() ), actionCollection(), 1624 SLOT( pasteContacts() ), actionCollection(),
1625 "kaddressbook_paste" ); 1625 "kaddressbook_paste" );
1626 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1626 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1627 SLOT( selectAllContacts() ), actionCollection(), 1627 SLOT( selectAllContacts() ), actionCollection(),
1628 "kaddressbook_select_all" ); 1628 "kaddressbook_select_all" );
1629 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1629 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1630 SLOT( undo() ), actionCollection(), 1630 SLOT( undo() ), actionCollection(),
1631 "kaddressbook_undo" ); 1631 "kaddressbook_undo" );
1632 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1632 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1633 this, SLOT( redo() ), actionCollection(), 1633 this, SLOT( redo() ), actionCollection(),
1634 "kaddressbook_redo" ); 1634 "kaddressbook_redo" );
1635 } else { 1635 } else {
1636 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1636 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1637 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1637 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1638 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1638 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1639 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1639 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1640 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1640 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1641 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1641 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1642 } 1642 }
1643 1643
1644 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1644 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1645 Key_Delete, this, SLOT( deleteContacts() ), 1645 Key_Delete, this, SLOT( deleteContacts() ),
1646 actionCollection(), "edit_delete" ); 1646 actionCollection(), "edit_delete" );
1647 1647
1648 mActionUndo->setEnabled( false ); 1648 mActionUndo->setEnabled( false );
1649 mActionRedo->setEnabled( false ); 1649 mActionRedo->setEnabled( false );
1650 1650
1651 // settings menu 1651 // settings menu
1652#ifdef KAB_EMBEDDED 1652#ifdef KAB_EMBEDDED
1653//US special menuentry to configure the addressbook resources. On KDE 1653//US special menuentry to configure the addressbook resources. On KDE
1654// you do that through the control center !!! 1654// you do that through the control center !!!
1655 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1655 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1656 SLOT( configureResources() ), actionCollection(), 1656 SLOT( configureResources() ), actionCollection(),
1657 "kaddressbook_configure_resources" ); 1657 "kaddressbook_configure_resources" );
1658#endif //KAB_EMBEDDED 1658#endif //KAB_EMBEDDED
1659 1659
1660 if ( mIsPart ) { 1660 if ( mIsPart ) {
1661 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1661 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1662 SLOT( openConfigDialog() ), actionCollection(), 1662 SLOT( openConfigDialog() ), actionCollection(),
1663 "kaddressbook_configure" ); 1663 "kaddressbook_configure" );
1664 1664
1665 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1665 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1666 this, SLOT( configureKeyBindings() ), actionCollection(), 1666 this, SLOT( configureKeyBindings() ), actionCollection(),
1667 "kaddressbook_configure_shortcuts" ); 1667 "kaddressbook_configure_shortcuts" );
1668#ifdef KAB_EMBEDDED 1668#ifdef KAB_EMBEDDED
1669 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1669 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1670 mActionConfigureToolbars->setEnabled( false ); 1670 mActionConfigureToolbars->setEnabled( false );
1671#endif //KAB_EMBEDDED 1671#endif //KAB_EMBEDDED
1672 1672
1673 } else { 1673 } else {
1674 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1674 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1675 1675
1676 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1676 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1677 } 1677 }
1678 1678
1679 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1679 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1680 actionCollection(), "options_show_jump_bar" ); 1680 actionCollection(), "options_show_jump_bar" );
1681 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1681 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1682 1682
1683 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1683 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1684 actionCollection(), "options_show_details" ); 1684 actionCollection(), "options_show_details" );
1685 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1685 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1686 1686
1687 // misc 1687 // misc
1688 // only enable LDAP lookup if we can handle the protocol 1688 // only enable LDAP lookup if we can handle the protocol
1689#ifndef KAB_EMBEDDED 1689#ifndef KAB_EMBEDDED
1690 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1690 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1691 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1691 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1692 this, SLOT( openLDAPDialog() ), actionCollection(), 1692 this, SLOT( openLDAPDialog() ), actionCollection(),
1693 "ldap_lookup" ); 1693 "ldap_lookup" );
1694 } 1694 }
1695#else //KAB_EMBEDDED 1695#else //KAB_EMBEDDED
1696 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1696 //qDebug("KABCore::initActions() LDAP has to be implemented");
1697#endif //KAB_EMBEDDED 1697#endif //KAB_EMBEDDED
1698 1698
1699 1699
1700 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1700 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1701 SLOT( setWhoAmI() ), actionCollection(), 1701 SLOT( setWhoAmI() ), actionCollection(),
1702 "set_personal" ); 1702 "set_personal" );
1703 1703
1704 1704
1705 1705
1706 1706
1707 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1707 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1708 SLOT( setCategories() ), actionCollection(), 1708 SLOT( setCategories() ), actionCollection(),
1709 "edit_set_categories" ); 1709 "edit_set_categories" );
1710 1710
1711 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1711 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1712 SLOT( removeVoice() ), actionCollection(), 1712 SLOT( removeVoice() ), actionCollection(),
1713 "remove_voice" ); 1713 "remove_voice" );
1714 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1714 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1715 SLOT( importFromOL() ), actionCollection(), 1715 SLOT( importFromOL() ), actionCollection(),
1716 "import_OL" ); 1716 "import_OL" );
1717#ifdef KAB_EMBEDDED 1717#ifdef KAB_EMBEDDED
1718 mActionLicence = new KAction( i18n( "Licence" ), 0, 1718 mActionLicence = new KAction( i18n( "Licence" ), 0,
1719 this, SLOT( showLicence() ), actionCollection(), 1719 this, SLOT( showLicence() ), actionCollection(),
1720 "licence_about_data" ); 1720 "licence_about_data" );
1721 mActionFaq = new KAction( i18n( "Faq" ), 0, 1721 mActionFaq = new KAction( i18n( "Faq" ), 0,
1722 this, SLOT( faq() ), actionCollection(), 1722 this, SLOT( faq() ), actionCollection(),
1723 "faq_about_data" ); 1723 "faq_about_data" );
1724 1724
1725 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1725 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1726 this, SLOT( createAboutData() ), actionCollection(), 1726 this, SLOT( createAboutData() ), actionCollection(),
1727 "kaddressbook_about_data" ); 1727 "kaddressbook_about_data" );
1728#endif //KAB_EMBEDDED 1728#endif //KAB_EMBEDDED
1729 1729
1730 clipboardDataChanged(); 1730 clipboardDataChanged();
1731 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1731 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1732 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1732 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1733} 1733}
1734 1734
1735//US we need this function, to plug all actions into the correct menues. 1735//US we need this function, to plug all actions into the correct menues.
1736// KDE uses a XML format to plug the actions, but we work her without this overhead. 1736// KDE uses a XML format to plug the actions, but we work her without this overhead.
1737void KABCore::addActionsManually() 1737void KABCore::addActionsManually()
1738{ 1738{
1739//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1739//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1740 1740
1741#ifdef KAB_EMBEDDED 1741#ifdef KAB_EMBEDDED
1742 QPopupMenu *fileMenu = new QPopupMenu( this ); 1742 QPopupMenu *fileMenu = new QPopupMenu( this );
1743 QPopupMenu *editMenu = new QPopupMenu( this ); 1743 QPopupMenu *editMenu = new QPopupMenu( this );
1744 QPopupMenu *helpMenu = new QPopupMenu( this ); 1744 QPopupMenu *helpMenu = new QPopupMenu( this );
1745 1745
1746 KToolBar* tb = mMainWindow->toolBar(); 1746 KToolBar* tb = mMainWindow->toolBar();
1747 1747
1748#ifdef DESKTOP_VERSION 1748#ifdef DESKTOP_VERSION
1749 QMenuBar* mb = mMainWindow->menuBar(); 1749 QMenuBar* mb = mMainWindow->menuBar();
1750 1750
1751 //US setup menubar. 1751 //US setup menubar.
1752 //Disable the following block if you do not want to have a menubar. 1752 //Disable the following block if you do not want to have a menubar.
1753 mb->insertItem( "&File", fileMenu ); 1753 mb->insertItem( "&File", fileMenu );
1754 mb->insertItem( "&Edit", editMenu ); 1754 mb->insertItem( "&Edit", editMenu );
1755 mb->insertItem( "&View", viewMenu ); 1755 mb->insertItem( "&View", viewMenu );
1756 mb->insertItem( "&Settings", settingsMenu ); 1756 mb->insertItem( "&Settings", settingsMenu );
1757 mb->insertItem( "&Change selected", changeMenu ); 1757 mb->insertItem( "&Change selected", changeMenu );
1758 mb->insertItem( "&Help", helpMenu ); 1758 mb->insertItem( "&Help", helpMenu );
1759 mIncSearchWidget = new IncSearchWidget( tb ); 1759 mIncSearchWidget = new IncSearchWidget( tb );
1760 // tb->insertWidget(-1, 0, mIncSearchWidget); 1760 // tb->insertWidget(-1, 0, mIncSearchWidget);
1761 1761
1762#else 1762#else
1763 //US setup toolbar 1763 //US setup toolbar
1764 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1764 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1765 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1765 QPopupMenu *popupBarTB = new QPopupMenu( this );
1766 menuBarTB->insertItem( "ME", popupBarTB); 1766 menuBarTB->insertItem( "ME", popupBarTB);
1767 tb->insertWidget(-1, 0, menuBarTB); 1767 tb->insertWidget(-1, 0, menuBarTB);
1768 mIncSearchWidget = new IncSearchWidget( tb ); 1768 mIncSearchWidget = new IncSearchWidget( tb );
1769 1769
1770 tb->enableMoving(false); 1770 tb->enableMoving(false);
1771 popupBarTB->insertItem( "&File", fileMenu ); 1771 popupBarTB->insertItem( "&File", fileMenu );
1772 popupBarTB->insertItem( "&Edit", editMenu ); 1772 popupBarTB->insertItem( "&Edit", editMenu );
1773 popupBarTB->insertItem( "&View", viewMenu ); 1773 popupBarTB->insertItem( "&View", viewMenu );
1774 popupBarTB->insertItem( "&Settings", settingsMenu ); 1774 popupBarTB->insertItem( "&Settings", settingsMenu );
1775 mViewManager->getFilterAction()->plug ( popupBarTB); 1775 mViewManager->getFilterAction()->plug ( popupBarTB);
1776 popupBarTB->insertItem( "&Change selected", changeMenu ); 1776 popupBarTB->insertItem( "&Change selected", changeMenu );
1777 popupBarTB->insertItem( "&Help", helpMenu ); 1777 popupBarTB->insertItem( "&Help", helpMenu );
1778 if (QApplication::desktop()->width() > 320 ) { 1778 if (QApplication::desktop()->width() > 320 ) {
1779 // mViewManager->getFilterAction()->plug ( tb); 1779 // mViewManager->getFilterAction()->plug ( tb);
1780 } 1780 }
1781#endif 1781#endif
1782 // mActionQuit->plug ( mMainWindow->toolBar()); 1782 // mActionQuit->plug ( mMainWindow->toolBar());
1783 1783
1784 1784
1785 1785
1786 //US Now connect the actions with the menue entries. 1786 //US Now connect the actions with the menue entries.
1787 mActionPrint->plug( fileMenu ); 1787 mActionPrint->plug( fileMenu );
1788 mActionMail->plug( fileMenu ); 1788 mActionMail->plug( fileMenu );
1789 fileMenu->insertSeparator(); 1789 fileMenu->insertSeparator();
1790 1790
1791 mActionNewContact->plug( fileMenu ); 1791 mActionNewContact->plug( fileMenu );
1792 mActionNewContact->plug( tb ); 1792 mActionNewContact->plug( tb );
1793 1793
1794 mActionEditAddressee->plug( fileMenu ); 1794 mActionEditAddressee->plug( fileMenu );
1795 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1795 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1796 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1796 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1797 mActionEditAddressee->plug( tb ); 1797 mActionEditAddressee->plug( tb );
1798 1798
1799 fileMenu->insertSeparator(); 1799 fileMenu->insertSeparator();
1800 mActionSave->plug( fileMenu ); 1800 mActionSave->plug( fileMenu );
1801 fileMenu->insertItem( "&Import", ImportMenu ); 1801 fileMenu->insertItem( "&Import", ImportMenu );
1802 fileMenu->insertItem( "&Export", ExportMenu ); 1802 fileMenu->insertItem( "&Export", ExportMenu );
1803 fileMenu->insertSeparator(); 1803 fileMenu->insertSeparator();
1804 mActionMailVCard->plug( fileMenu ); 1804 mActionMailVCard->plug( fileMenu );
1805#ifndef DESKTOP_VERSION 1805#ifndef DESKTOP_VERSION
1806 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1806 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1807 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1807 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1808#endif 1808#endif
1809 fileMenu->insertSeparator(); 1809 fileMenu->insertSeparator();
1810 mActionQuit->plug( fileMenu ); 1810 mActionQuit->plug( fileMenu );
1811#ifdef _WIN32_ 1811#ifdef _WIN32_
1812 mActionImportOL->plug( ImportMenu ); 1812 mActionImportOL->plug( ImportMenu );
1813#endif 1813#endif
1814 // edit menu 1814 // edit menu
1815 mActionUndo->plug( editMenu ); 1815 mActionUndo->plug( editMenu );
1816 mActionRedo->plug( editMenu ); 1816 mActionRedo->plug( editMenu );
1817 editMenu->insertSeparator(); 1817 editMenu->insertSeparator();
1818 mActionCut->plug( editMenu ); 1818 mActionCut->plug( editMenu );
1819 mActionCopy->plug( editMenu ); 1819 mActionCopy->plug( editMenu );
1820 mActionPaste->plug( editMenu ); 1820 mActionPaste->plug( editMenu );
1821 mActionDelete->plug( editMenu ); 1821 mActionDelete->plug( editMenu );
1822 editMenu->insertSeparator(); 1822 editMenu->insertSeparator();
1823 mActionSelectAll->plug( editMenu ); 1823 mActionSelectAll->plug( editMenu );
1824 1824
1825 mActionRemoveVoice->plug( changeMenu ); 1825 mActionRemoveVoice->plug( changeMenu );
1826 // settings menu 1826 // settings menu
1827//US special menuentry to configure the addressbook resources. On KDE 1827//US special menuentry to configure the addressbook resources. On KDE
1828// you do that through the control center !!! 1828// you do that through the control center !!!
1829 mActionConfigResources->plug( settingsMenu ); 1829 mActionConfigResources->plug( settingsMenu );
1830 settingsMenu->insertSeparator(); 1830 settingsMenu->insertSeparator();
1831 1831
1832 mActionConfigKAddressbook->plug( settingsMenu ); 1832 mActionConfigKAddressbook->plug( settingsMenu );
1833 1833
1834 if ( mIsPart ) { 1834 if ( mIsPart ) {
1835 mActionConfigShortcuts->plug( settingsMenu ); 1835 mActionConfigShortcuts->plug( settingsMenu );
1836 mActionConfigureToolbars->plug( settingsMenu ); 1836 mActionConfigureToolbars->plug( settingsMenu );
1837 1837
1838 } else { 1838 } else {
1839 mActionKeyBindings->plug( settingsMenu ); 1839 mActionKeyBindings->plug( settingsMenu );
1840 } 1840 }
1841 1841
1842 settingsMenu->insertSeparator(); 1842 settingsMenu->insertSeparator();
1843 1843
1844 mActionJumpBar->plug( settingsMenu ); 1844 mActionJumpBar->plug( settingsMenu );
1845 mActionDetails->plug( settingsMenu ); 1845 mActionDetails->plug( settingsMenu );
1846 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1846 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1847 mActionDetails->plug( tb ); 1847 mActionDetails->plug( tb );
1848 settingsMenu->insertSeparator(); 1848 settingsMenu->insertSeparator();
1849 1849
1850 mActionWhoAmI->plug( settingsMenu ); 1850 mActionWhoAmI->plug( settingsMenu );
1851 mActionCategories->plug( settingsMenu ); 1851 mActionCategories->plug( settingsMenu );
1852 1852
1853 mActionLicence->plug( helpMenu ); 1853 mActionLicence->plug( helpMenu );
1854 mActionFaq->plug( helpMenu ); 1854 mActionFaq->plug( helpMenu );
1855 mActionAboutKAddressbook->plug( helpMenu ); 1855 mActionAboutKAddressbook->plug( helpMenu );
1856 1856
1857 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1857 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1858 1858
1859 mActionSave->plug( tb ); 1859 mActionSave->plug( tb );
1860 mViewManager->getFilterAction()->plug ( tb); 1860 mViewManager->getFilterAction()->plug ( tb);
1861 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1861 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1862 mActionUndo->plug( tb ); 1862 mActionUndo->plug( tb );
1863 mActionDelete->plug( tb ); 1863 mActionDelete->plug( tb );
1864 mActionRedo->plug( tb ); 1864 mActionRedo->plug( tb );
1865 } 1865 }
1866 } 1866 }
1867 //mActionQuit->plug ( tb ); 1867 //mActionQuit->plug ( tb );
1868 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1868 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1869 1869
1870 //US link the searchwidget first to this. 1870 //US link the searchwidget first to this.
1871 // The real linkage to the toolbar happens later. 1871 // The real linkage to the toolbar happens later.
1872//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1872//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1873//US tb->insertItem( mIncSearchWidget ); 1873//US tb->insertItem( mIncSearchWidget );
1874/*US 1874/*US
1875 mIncSearchWidget = new IncSearchWidget( tb ); 1875 mIncSearchWidget = new IncSearchWidget( tb );
1876 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1876 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1877 SLOT( incrementalSearch( const QString& ) ) ); 1877 SLOT( incrementalSearch( const QString& ) ) );
1878 1878
1879 mJumpButtonBar = new JumpButtonBar( this, this ); 1879 mJumpButtonBar = new JumpButtonBar( this, this );
1880 1880
1881//US topLayout->addWidget( mJumpButtonBar ); 1881//US topLayout->addWidget( mJumpButtonBar );
1882 this->layout()->add( mJumpButtonBar ); 1882 this->layout()->add( mJumpButtonBar );
1883*/ 1883*/
1884 1884
1885#endif //KAB_EMBEDDED 1885#endif //KAB_EMBEDDED
1886} 1886}
1887void KABCore::showLicence() 1887void KABCore::showLicence()
1888{ 1888{
1889 KApplication::showLicence(); 1889 KApplication::showLicence();
1890} 1890}
1891void KABCore::removeVoice() 1891void KABCore::removeVoice()
1892{ 1892{
1893 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 1893 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
1894 return; 1894 return;
1895 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1895 KABC::Addressee::List list = mViewManager->selectedAddressees();
1896 KABC::Addressee::List::Iterator it; 1896 KABC::Addressee::List::Iterator it;
1897 for ( it = list.begin(); it != list.end(); ++it ) { 1897 for ( it = list.begin(); it != list.end(); ++it ) {
1898 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1898 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1899 PhoneNumber::List::Iterator phoneIt; 1899 PhoneNumber::List::Iterator phoneIt;
1900 bool found = false; 1900 bool found = false;
1901 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1901 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1902 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1902 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1903 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1903 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1904 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1904 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1905 (*it).insertPhoneNumber( (*phoneIt) ); 1905 (*it).insertPhoneNumber( (*phoneIt) );
1906 found = true; 1906 found = true;
1907 } 1907 }
1908 } 1908 }
1909 1909
1910 } 1910 }
1911 if ( found ) 1911 if ( found )
1912 contactModified((*it) ); 1912 contactModified((*it) );
1913 } 1913 }
1914} 1914}
1915 1915
1916 1916
1917 1917
1918void KABCore::clipboardDataChanged() 1918void KABCore::clipboardDataChanged()
1919{ 1919{
1920 1920
1921 if ( mReadWrite ) 1921 if ( mReadWrite )
1922 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1922 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1923 1923
1924} 1924}
1925 1925
1926void KABCore::updateActionMenu() 1926void KABCore::updateActionMenu()
1927{ 1927{
1928 UndoStack *undo = UndoStack::instance(); 1928 UndoStack *undo = UndoStack::instance();
1929 RedoStack *redo = RedoStack::instance(); 1929 RedoStack *redo = RedoStack::instance();
1930 1930
1931 if ( undo->isEmpty() ) 1931 if ( undo->isEmpty() )
1932 mActionUndo->setText( i18n( "Undo" ) ); 1932 mActionUndo->setText( i18n( "Undo" ) );
1933 else 1933 else
1934 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1934 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1935 1935
1936 mActionUndo->setEnabled( !undo->isEmpty() ); 1936 mActionUndo->setEnabled( !undo->isEmpty() );
1937 1937
1938 if ( !redo->top() ) 1938 if ( !redo->top() )
1939 mActionRedo->setText( i18n( "Redo" ) ); 1939 mActionRedo->setText( i18n( "Redo" ) );
1940 else 1940 else
1941 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1941 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1942 1942
1943 mActionRedo->setEnabled( !redo->isEmpty() ); 1943 mActionRedo->setEnabled( !redo->isEmpty() );
1944} 1944}
1945 1945
1946void KABCore::configureKeyBindings() 1946void KABCore::configureKeyBindings()
1947{ 1947{
1948#ifndef KAB_EMBEDDED 1948#ifndef KAB_EMBEDDED
1949 KKeyDialog::configure( actionCollection(), true ); 1949 KKeyDialog::configure( actionCollection(), true );
1950#else //KAB_EMBEDDED 1950#else //KAB_EMBEDDED
1951 qDebug("KABCore::configureKeyBindings() not implemented"); 1951 qDebug("KABCore::configureKeyBindings() not implemented");
1952#endif //KAB_EMBEDDED 1952#endif //KAB_EMBEDDED
1953} 1953}
1954 1954
1955#ifdef KAB_EMBEDDED 1955#ifdef KAB_EMBEDDED
1956void KABCore::configureResources() 1956void KABCore::configureResources()
1957{ 1957{
1958 KRES::KCMKResources dlg( this, "" , 0 ); 1958 KRES::KCMKResources dlg( this, "" , 0 );
1959 1959
1960 if ( !dlg.exec() ) 1960 if ( !dlg.exec() )
1961 return; 1961 return;
1962 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1962 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1963} 1963}
1964#endif //KAB_EMBEDDED 1964#endif //KAB_EMBEDDED
1965 1965
1966 1966
1967/* this method will be called through the QCop interface from Ko/Pi to select addresses 1967/* this method will be called through the QCop interface from Ko/Pi to select addresses
1968 * for the attendees list of an event. 1968 * for the attendees list of an event.
1969 */ 1969 */
1970void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 1970void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
1971{ 1971{
1972 QStringList nameList; 1972 QStringList nameList;
1973 QStringList emailList; 1973 QStringList emailList;
1974 QStringList uidList; 1974 QStringList uidList;
1975 1975
1976 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 1976 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1977 uint i=0; 1977 uint i=0;
1978 for (i=0; i < list.count(); i++) 1978 for (i=0; i < list.count(); i++)
1979 { 1979 {
1980 nameList.append(list[i].realName()); 1980 nameList.append(list[i].realName());
1981 emailList.append(list[i].preferredEmail()); 1981 emailList.append(list[i].preferredEmail());
1982 uidList.append(list[i].uid()); 1982 uidList.append(list[i].uid());
1983 } 1983 }
1984 1984
1985 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 1985 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
1986 1986
1987} 1987}
1988 1988
1989/* this method will be called through the QCop interface from other apps to show details of a contact. 1989/* this method will be called through the QCop interface from other apps to show details of a contact.
1990 */ 1990 */
1991void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 1991void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
1992{ 1992{
1993 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 1993 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
1994 1994
1995 QString foundUid = QString::null; 1995 QString foundUid = QString::null;
1996 if ( ! uid.isEmpty() ) { 1996 if ( ! uid.isEmpty() ) {
1997 Addressee adrr = mAddressBook->findByUid( uid ); 1997 Addressee adrr = mAddressBook->findByUid( uid );
1998 if ( !adrr.isEmpty() ) { 1998 if ( !adrr.isEmpty() ) {
1999 foundUid = uid; 1999 foundUid = uid;
2000 } 2000 }
2001 if ( email == "sendbacklist" ) { 2001 if ( email == "sendbacklist" ) {
2002 //qDebug("ssssssssssssssssssssssend "); 2002 //qDebug("ssssssssssssssssssssssend ");
2003 QStringList nameList; 2003 QStringList nameList;
2004 QStringList emailList; 2004 QStringList emailList;
2005 QStringList uidList; 2005 QStringList uidList;
2006 nameList.append(adrr.realName()); 2006 nameList.append(adrr.realName());
2007 emailList = adrr.emails(); 2007 emailList = adrr.emails();
2008 uidList.append( adrr.preferredEmail()); 2008 uidList.append( adrr.preferredEmail());
2009 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2009 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2010 return; 2010 return;
2011 } 2011 }
2012 2012
2013 } 2013 }
2014 2014
2015 if ( email == "sendbacklist" ) 2015 if ( email == "sendbacklist" )
2016 return; 2016 return;
2017 if (foundUid.isEmpty()) 2017 if (foundUid.isEmpty())
2018 { 2018 {
2019 //find the uid of the person first 2019 //find the uid of the person first
2020 Addressee::List namelist; 2020 Addressee::List namelist;
2021 Addressee::List emaillist; 2021 Addressee::List emaillist;
2022 2022
2023 if (!name.isEmpty()) 2023 if (!name.isEmpty())
2024 namelist = mAddressBook->findByName( name ); 2024 namelist = mAddressBook->findByName( name );
2025 2025
2026 if (!email.isEmpty()) 2026 if (!email.isEmpty())
2027 emaillist = mAddressBook->findByEmail( email ); 2027 emaillist = mAddressBook->findByEmail( email );
2028 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2028 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2029 //check if we have a match in Namelist and Emaillist 2029 //check if we have a match in Namelist and Emaillist
2030 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2030 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2031 foundUid = emaillist[0].uid(); 2031 foundUid = emaillist[0].uid();
2032 } 2032 }
2033 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2033 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2034 foundUid = namelist[0].uid(); 2034 foundUid = namelist[0].uid();
2035 else 2035 else
2036 { 2036 {
2037 for (int i = 0; i < namelist.count(); i++) 2037 for (int i = 0; i < namelist.count(); i++)
2038 { 2038 {
2039 for (int j = 0; j < emaillist.count(); j++) 2039 for (int j = 0; j < emaillist.count(); j++)
2040 { 2040 {
2041 if (namelist[i] == emaillist[j]) 2041 if (namelist[i] == emaillist[j])
2042 { 2042 {
2043 foundUid = namelist[i].uid(); 2043 foundUid = namelist[i].uid();
2044 } 2044 }
2045 } 2045 }
2046 } 2046 }
2047 } 2047 }
2048 } 2048 }
2049 else 2049 else
2050 { 2050 {
2051 foundUid = uid; 2051 foundUid = uid;
2052 } 2052 }
2053 2053
2054 if (!foundUid.isEmpty()) 2054 if (!foundUid.isEmpty())
2055 { 2055 {
2056 2056
2057 // raise Ka/Pi if it is in the background 2057 // raise Ka/Pi if it is in the background
2058#ifndef DESKTOP_VERSION 2058#ifndef DESKTOP_VERSION
2059#ifndef KORG_NODCOP 2059#ifndef KORG_NODCOP
2060 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2060 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2061#endif 2061#endif
2062#endif 2062#endif
2063 2063
2064 mMainWindow->showMaximized(); 2064 mMainWindow->showMaximized();
2065 mMainWindow-> raise(); 2065 mMainWindow-> raise();
2066 2066
2067 mViewManager->setSelected( "", false); 2067 mViewManager->setSelected( "", false);
2068 mViewManager->refreshView( "" ); 2068 mViewManager->refreshView( "" );
2069 mViewManager->setSelected( foundUid, true ); 2069 mViewManager->setSelected( foundUid, true );
2070 mViewManager->refreshView( foundUid ); 2070 mViewManager->refreshView( foundUid );
2071 2071
2072 if ( !mMultipleViewsAtOnce ) 2072 if ( !mMultipleViewsAtOnce )
2073 { 2073 {
2074 setDetailsVisible( true ); 2074 setDetailsVisible( true );
2075 mActionDetails->setChecked(true); 2075 mActionDetails->setChecked(true);
2076 } 2076 }
2077 } 2077 }
2078} 2078}
2079 2079
2080 2080
2081void KABCore::faq() 2081void KABCore::faq()
2082{ 2082{
2083 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2083 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2084} 2084}
2085 2085
2086 2086
2087 2087
2088 2088
2089#ifndef KAB_EMBEDDED 2089#ifndef KAB_EMBEDDED
2090#include "kabcore.moc" 2090#include "kabcore.moc"
2091#endif //KAB_EMBEDDED 2091#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kaddressbookE.pro b/kaddressbook/kaddressbookE.pro
index 1c9eeef..c027895 100644
--- a/kaddressbook/kaddressbookE.pro
+++ b/kaddressbook/kaddressbookE.pro
@@ -1,159 +1,161 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 3
4 4
5 TARGET = kapi 5 TARGET = kapi
6OBJECTS_DIR = obj/$(PLATFORM) 6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM) 7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=$(QPEDIR)/bin 8DESTDIR=$(QPEDIR)/bin
9 9
10INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include 10INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include
11DEFINES += KAB_EMBEDDED KAB_NOSPLITTER 11DEFINES += KAB_EMBEDDED KAB_NOSPLITTER
12#DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL 12#DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL
13#DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13#DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#DEFINES += KORG_NOLVALTERNATION 14#DEFINES += KORG_NOLVALTERNATION
15LIBS += -lmicrokdepim 15#LIBS += -lmicrokdepim
16LIBS += -lmicrokcal 16#LIBS += -lmicrokcal
17LIBS += -lmicrokde 17LIBS += -lmicrokde
18LIBS += -lmicroqtcompat 18LIBS += -lmicroqtcompat
19LIBS += -lmicrokabc 19LIBS += -lmicrokabc
20LIBS += -lqpe 20LIBS += -lqpe
21LIBS += -ljpeg 21LIBS += -ljpeg
22LIBS += $(QTOPIALIB) 22LIBS += $(QTOPIALIB)
23LIBS += -L$(QPEDIR)/lib 23LIBS += -L$(QPEDIR)/lib
24LIBS += -Wl,-export-dynamic 24LIBS += -Wl,-export-dynamic
25LIBS += $(GCC3EXTRALIB1)
26LIBS += $(GCC3EXTRALIB2)
25 27
26INTERFACES = \ 28INTERFACES = \
27# filteredit_base.ui \ 29# filteredit_base.ui \
28# kofilterview_base.ui \ 30# kofilterview_base.ui \
29 31
30HEADERS = \ 32HEADERS = \
31features/mergewidget.h \ 33features/mergewidget.h \
32features/distributionlistwidget.h \ 34features/distributionlistwidget.h \
33kcmconfigs/addresseewidget.h \ 35kcmconfigs/addresseewidget.h \
34kcmconfigs/extensionconfigdialog.h \ 36kcmconfigs/extensionconfigdialog.h \
35kcmconfigs/kcmkabconfig.h \ 37kcmconfigs/kcmkabconfig.h \
36kcmconfigs/kabconfigwidget.h \ 38kcmconfigs/kabconfigwidget.h \
37addresseeeditordialog.h \ 39addresseeeditordialog.h \
38addresseeeditorwidget.h \ 40addresseeeditorwidget.h \
39addresseditwidget.h \ 41addresseditwidget.h \
40addresseeconfig.h \ 42addresseeconfig.h \
41addresseeutil.h \ 43addresseeutil.h \
42emaileditwidget.h \ 44emaileditwidget.h \
43filtereditdialog.h \ 45filtereditdialog.h \
44kaddressbookmain.h \ 46kaddressbookmain.h \
45kabprefs.h \ 47kabprefs.h \
46kabcore.h \ 48kabcore.h \
47viewmanager.h \ 49viewmanager.h \
48extensionmanager.h \ 50extensionmanager.h \
49extensionwidget.h \ 51extensionwidget.h \
50kaddressbookview.h \ 52kaddressbookview.h \
51geowidget.h \ 53geowidget.h \
52imagewidget.h \ 54imagewidget.h \
53incsearchwidget.h \ 55incsearchwidget.h \
54jumpbuttonbar.h \ 56jumpbuttonbar.h \
55phoneeditwidget.h \ 57phoneeditwidget.h \
56secrecywidget.h \ 58secrecywidget.h \
57keywidget.h \ 59keywidget.h \
58nameeditdialog.h \ 60nameeditdialog.h \
59filter.h \ 61filter.h \
60addviewdialog.h \ 62addviewdialog.h \
61configurewidget.h \ 63configurewidget.h \
62viewconfigurewidget.h \ 64viewconfigurewidget.h \
63viewconfigurefieldspage.h \ 65viewconfigurefieldspage.h \
64viewconfigurefilterpage.h \ 66viewconfigurefilterpage.h \
65typecombo.h \ 67typecombo.h \
66undo.h \ 68undo.h \
67undocmds.h \ 69undocmds.h \
68xxportmanager.h \ 70xxportmanager.h \
69xxportobject.h \ 71xxportobject.h \
70xxportselectdialog.h \ 72xxportselectdialog.h \
71details/detailsviewcontainer.h \ 73details/detailsviewcontainer.h \
72details/look_basic.h \ 74details/look_basic.h \
73details/look_html.h \ 75details/look_html.h \
74views/kaddressbookiconview.h \ 76views/kaddressbookiconview.h \
75views/kaddressbooktableview.h \ 77views/kaddressbooktableview.h \
76views/kaddressbookcardview.h \ 78views/kaddressbookcardview.h \
77views/configuretableviewdialog.h \ 79views/configuretableviewdialog.h \
78views/configurecardviewdialog.h \ 80views/configurecardviewdialog.h \
79views/cardview.h \ 81views/cardview.h \
80views/colorlistbox.h \ 82views/colorlistbox.h \
81views/contactlistview.h \ 83views/contactlistview.h \
82xxport/vcard_xxport.h \ 84xxport/vcard_xxport.h \
83xxport/kde2_xxport.h \ 85xxport/kde2_xxport.h \
84xxport/csv_xxport.h \ 86xxport/csv_xxport.h \
85xxport/csvimportdialog.h \ 87xxport/csvimportdialog.h \
86xxport/opie_xxport.h \ 88xxport/opie_xxport.h \
87xxport/qtopia_xxport.h \ 89xxport/qtopia_xxport.h \
88xxport/sharpdtm_xxport.h \ 90xxport/sharpdtm_xxport.h \
89#details/look_details.h \ 91#details/look_details.h \
90#mainwindoiw.h \ 92#mainwindoiw.h \
91# alarmclient.h \ 93# alarmclient.h \
92# calendarview.h \ 94# calendarview.h \
93# customlistviewitem.h \ 95# customlistviewitem.h \
94# datenavigator.h 96# datenavigator.h
95 97
96SOURCES = \ 98SOURCES = \
97addresseeeditordialog.cpp \ 99addresseeeditordialog.cpp \
98addresseeeditorwidget.cpp \ 100addresseeeditorwidget.cpp \
99addresseditwidget.cpp \ 101addresseditwidget.cpp \
100addresseeconfig.cpp \ 102addresseeconfig.cpp \
101addresseeutil.cpp \ 103addresseeutil.cpp \
102extensionmanager.cpp \ 104extensionmanager.cpp \
103features/mergewidget.cpp \ 105features/mergewidget.cpp \
104features/distributionlistwidget.cpp \ 106features/distributionlistwidget.cpp \
105kcmconfigs/addresseewidget.cpp \ 107kcmconfigs/addresseewidget.cpp \
106kcmconfigs/extensionconfigdialog.cpp \ 108kcmconfigs/extensionconfigdialog.cpp \
107kcmconfigs/kcmkabconfig.cpp \ 109kcmconfigs/kcmkabconfig.cpp \
108kcmconfigs/kabconfigwidget.cpp \ 110kcmconfigs/kabconfigwidget.cpp \
109emaileditwidget.cpp \ 111emaileditwidget.cpp \
110filtereditdialog.cpp \ 112filtereditdialog.cpp \
111mainembedded.cpp \ 113mainembedded.cpp \
112kaddressbookmain.cpp \ 114kaddressbookmain.cpp \
113kabcore.cpp \ 115kabcore.cpp \
114kabprefs.cpp \ 116kabprefs.cpp \
115viewmanager.cpp \ 117viewmanager.cpp \
116kaddressbookview.cpp \ 118kaddressbookview.cpp \
117extensionwidget.cpp \ 119extensionwidget.cpp \
118geowidget.cpp \ 120geowidget.cpp \
119imagewidget.cpp \ 121imagewidget.cpp \
120incsearchwidget.cpp \ 122incsearchwidget.cpp \
121jumpbuttonbar.cpp \ 123jumpbuttonbar.cpp \
122phoneeditwidget.cpp \ 124phoneeditwidget.cpp \
123secrecywidget.cpp \ 125secrecywidget.cpp \
124keywidget.cpp \ 126keywidget.cpp \
125nameeditdialog.cpp \ 127nameeditdialog.cpp \
126filter.cpp \ 128filter.cpp \
127addviewdialog.cpp \ 129addviewdialog.cpp \
128configurewidget.cpp \ 130configurewidget.cpp \
129viewconfigurewidget.cpp \ 131viewconfigurewidget.cpp \
130viewconfigurefieldspage.cpp \ 132viewconfigurefieldspage.cpp \
131viewconfigurefilterpage.cpp \ 133viewconfigurefilterpage.cpp \
132undo.cpp \ 134undo.cpp \
133undocmds.cpp \ 135undocmds.cpp \
134xxportmanager.cpp \ 136xxportmanager.cpp \
135xxportobject.cpp \ 137xxportobject.cpp \
136xxportselectdialog.cpp \ 138xxportselectdialog.cpp \
137details/detailsviewcontainer.cpp \ 139details/detailsviewcontainer.cpp \
138details/look_basic.cpp \ 140details/look_basic.cpp \
139details/look_html.cpp \ 141details/look_html.cpp \
140views/kaddressbookiconview.cpp \ 142views/kaddressbookiconview.cpp \
141views/kaddressbooktableview.cpp \ 143views/kaddressbooktableview.cpp \
142views/kaddressbookcardview.cpp \ 144views/kaddressbookcardview.cpp \
143views/configuretableviewdialog.cpp \ 145views/configuretableviewdialog.cpp \
144views/configurecardviewdialog.cpp \ 146views/configurecardviewdialog.cpp \
145views/cardview.cpp \ 147views/cardview.cpp \
146views/contactlistview.cpp \ 148views/contactlistview.cpp \
147views/colorlistbox.cpp \ 149views/colorlistbox.cpp \
148xxport/vcard_xxport.cpp \ 150xxport/vcard_xxport.cpp \
149xxport/kde2_xxport.cpp \ 151xxport/kde2_xxport.cpp \
150xxport/csv_xxport.cpp \ 152xxport/csv_xxport.cpp \
151xxport/csvimportdialog.cpp \ 153xxport/csvimportdialog.cpp \
152xxport/opie_xxport.cpp \ 154xxport/opie_xxport.cpp \
153xxport/qtopia_xxport.cpp \ 155xxport/qtopia_xxport.cpp \
154xxport/sharpdtm_xxport.cpp \ 156xxport/sharpdtm_xxport.cpp \
155#details/look_details.cpp \ 157#details/look_details.cpp \
156#mainwindow.cpp \ 158#mainwindow.cpp \
157# calendarview.cpp \ 159# calendarview.cpp \
158# timespanview.cpp 160# timespanview.cpp
159 161
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp
index 713b0fc..810c3e2 100644
--- a/kaddressbook/xxportmanager.cpp
+++ b/kaddressbook/xxportmanager.cpp
@@ -1,243 +1,243 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qlist.h> 32#include <qlist.h>
33 33
34#include <kabc/addressbook.h> 34#include <kabc/addressbook.h>
35#include <kabc/resource.h> 35#include <kabc/resource.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kdialogbase.h> 37#include <kdialogbase.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42#include <ktrader.h> 42#include <ktrader.h>
43#else //KAB_EMBEDDED 43#else //KAB_EMBEDDED
44extern "C" 44extern "C"
45{ 45{
46 void* init_microkaddrbk_csv_xxport(); 46 void* init_microkaddrbk_csv_xxport();
47 void* init_microkaddrbk_kde2_xxport(); 47 void* init_microkaddrbk_kde2_xxport();
48 void* init_microkaddrbk_vcard_xxport(); 48 void* init_microkaddrbk_vcard_xxport();
49 void* init_microkaddrbk_opie_xxport(); 49 void* init_microkaddrbk_opie_xxport();
50 void* init_microkaddrbk_qtopia_xxport(); 50 void* init_microkaddrbk_qtopia_xxport();
51 void* init_microkaddrbk_sharpdtm_xxport(); 51 void* init_microkaddrbk_sharpdtm_xxport();
52} 52}
53#endif //KAB_EMBEDDED 53#endif //KAB_EMBEDDED
54 54
55#include <libkdepim/addresseeview.h> 55#include <addresseeview.h>
56 56
57#include "kabcore.h" 57#include "kabcore.h"
58#include "undocmds.h" 58#include "undocmds.h"
59#include "xxportselectdialog.h" 59#include "xxportselectdialog.h"
60 60
61#include "xxportmanager.h" 61#include "xxportmanager.h"
62 62
63KURL XXPortManager::importURL = KURL(); 63KURL XXPortManager::importURL = KURL();
64QString XXPortManager::importData = QString::null; 64QString XXPortManager::importData = QString::null;
65 65
66class PreviewDialog : public KDialogBase 66class PreviewDialog : public KDialogBase
67{ 67{
68 public: 68 public:
69 PreviewDialog( const KABC::Addressee &addr, 69 PreviewDialog( const KABC::Addressee &addr,
70 QWidget *parent, const char *name = 0 ); 70 QWidget *parent, const char *name = 0 );
71}; 71};
72 72
73XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) 73XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name )
74 : QObject( parent, name ), mCore( core ), mShowPreview( false ) 74 : QObject( parent, name ), mCore( core ), mShowPreview( false )
75{ 75{
76 loadPlugins(); 76 loadPlugins();
77} 77}
78 78
79XXPortManager::~XXPortManager() 79XXPortManager::~XXPortManager()
80{ 80{
81} 81}
82 82
83void XXPortManager::restoreSettings() 83void XXPortManager::restoreSettings()
84{ 84{
85} 85}
86 86
87void XXPortManager::saveSettings() 87void XXPortManager::saveSettings()
88{ 88{
89} 89}
90 90
91void XXPortManager::importVCard( const KURL &url ) 91void XXPortManager::importVCard( const KURL &url )
92{ 92{
93 importVCard( url, false ); 93 importVCard( url, false );
94} 94}
95 95
96void XXPortManager::importVCard( const KURL &url, bool showPreview ) 96void XXPortManager::importVCard( const KURL &url, bool showPreview )
97{ 97{
98 importURL = url; 98 importURL = url;
99 mShowPreview = showPreview; 99 mShowPreview = showPreview;
100 slotImport( "vcard", "<empty>" ); 100 slotImport( "vcard", "<empty>" );
101 mShowPreview = false; 101 mShowPreview = false;
102 importURL = KURL(); 102 importURL = KURL();
103} 103}
104 104
105void XXPortManager::importVCard( const QString &vCard, bool showPreview ) 105void XXPortManager::importVCard( const QString &vCard, bool showPreview )
106{ 106{
107 importData = vCard; 107 importData = vCard;
108 mShowPreview = showPreview; 108 mShowPreview = showPreview;
109 slotImport( "vcard", "<empty>" ); 109 slotImport( "vcard", "<empty>" );
110 mShowPreview = false; 110 mShowPreview = false;
111 importData = ""; 111 importData = "";
112} 112}
113 113
114void XXPortManager::slotImport( const QString &identifier, const QString &data ) 114void XXPortManager::slotImport( const QString &identifier, const QString &data )
115{ 115{
116 XXPortObject *obj = mXXPortObjects[ identifier ]; 116 XXPortObject *obj = mXXPortObjects[ identifier ];
117 if ( !obj ) { 117 if ( !obj ) {
118 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 118 KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
119 return; 119 return;
120 } 120 }
121 121
122 KABC::Resource *resource = mCore->requestResource( mCore ); 122 KABC::Resource *resource = mCore->requestResource( mCore );
123 if ( !resource ) 123 if ( !resource )
124 return; 124 return;
125 125
126 KABC::AddresseeList list = obj->importContacts( data ); 126 KABC::AddresseeList list = obj->importContacts( data );
127 KABC::AddresseeList::Iterator it; 127 KABC::AddresseeList::Iterator it;
128 bool imported = false; 128 bool imported = false;
129 for ( it = list.begin(); it != list.end(); ++it ) { 129 for ( it = list.begin(); it != list.end(); ++it ) {
130 if ( mShowPreview ) { 130 if ( mShowPreview ) {
131 PreviewDialog dlg( *it, mCore ); 131 PreviewDialog dlg( *it, mCore );
132 if ( !dlg.exec() ) 132 if ( !dlg.exec() )
133 continue; 133 continue;
134 } 134 }
135 135
136 (*it).setResource( resource ); 136 (*it).setResource( resource );
137 // We use a PwNewCommand so the user can undo it. 137 // We use a PwNewCommand so the user can undo it.
138 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); 138 PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it );
139 UndoStack::instance()->push( command ); 139 UndoStack::instance()->push( command );
140 RedoStack::instance()->clear(); 140 RedoStack::instance()->clear();
141 imported = true; 141 imported = true;
142 } 142 }
143 143
144 if ( imported ) { 144 if ( imported ) {
145 KMessageBox::information( mCore, i18n( "contacts successfully imported." ) ); 145 KMessageBox::information( mCore, i18n( "contacts successfully imported." ) );
146 146
147 emit modified(); 147 emit modified();
148 } 148 }
149} 149}
150 150
151void XXPortManager::slotExport( const QString &identifier, const QString &data ) 151void XXPortManager::slotExport( const QString &identifier, const QString &data )
152{ 152{
153 XXPortObject *obj = mXXPortObjects[ identifier ]; 153 XXPortObject *obj = mXXPortObjects[ identifier ];
154 if ( !obj ) { 154 if ( !obj ) {
155 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 155 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
156 return; 156 return;
157 } 157 }
158 158
159 KABC::AddresseeList addrList; 159 KABC::AddresseeList addrList;
160 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); 160 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore );
161 if ( dlg.exec() ) 161 if ( dlg.exec() )
162 addrList = dlg.contacts(); 162 addrList = dlg.contacts();
163 else 163 else
164 return; 164 return;
165 165
166 if ( !obj->exportContacts( addrList, data ) ) 166 if ( !obj->exportContacts( addrList, data ) )
167 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); 167 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) );
168 else 168 else
169 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); 169 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) );
170} 170}
171 171
172void XXPortManager::loadPlugins() 172void XXPortManager::loadPlugins()
173{ 173{
174 mXXPortObjects.clear(); 174 mXXPortObjects.clear();
175 175
176#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
177 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); 177 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" );
178 KTrader::OfferList::ConstIterator it; 178 KTrader::OfferList::ConstIterator it;
179 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 179 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
180 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) 180 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) )
181 continue; 181 continue;
182 182
183 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 183 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
184 if ( !factory ) { 184 if ( !factory ) {
185 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; 185 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
186 continue; 186 continue;
187 } 187 }
188 188
189 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); 189 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
190 190
191 if ( !xxportFactory ) { 191 if ( !xxportFactory ) {
192 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; 192 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
193 continue; 193 continue;
194 } 194 }
195 195
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 QList<XXPortFactory> factorylist; 197 QList<XXPortFactory> factorylist;
198 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); 198 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport()));
199 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); 199 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport()));
200 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); 200 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport()));
201 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport())); 201 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport()));
202 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport())); 202 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport()));
203 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport())); 203 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport()));
204 204
205 QListIterator<XXPortFactory> it(factorylist); 205 QListIterator<XXPortFactory> it(factorylist);
206 for ( ; it.current(); ++it ) 206 for ( ; it.current(); ++it )
207 { 207 {
208 XXPortFactory *xxportFactory = it.current(); 208 XXPortFactory *xxportFactory = it.current();
209#endif //KAB_EMBEDDED 209#endif //KAB_EMBEDDED
210 210
211 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); 211 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
212 if ( obj ) { 212 if ( obj ) {
213 mCore->addGUIClient( obj ); 213 mCore->addGUIClient( obj );
214 mXXPortObjects.insert( obj->identifier(), obj ); 214 mXXPortObjects.insert( obj->identifier(), obj );
215 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 215 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
216 this, SLOT( slotExport( const QString&, const QString& ) ) ); 216 this, SLOT( slotExport( const QString&, const QString& ) ) );
217 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), 217 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
218 this, SLOT( slotImport( const QString&, const QString& ) ) ); 218 this, SLOT( slotImport( const QString&, const QString& ) ) );
219 } 219 }
220 } 220 }
221} 221}
222 222
223 223
224PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, 224PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
225 const char *name ) 225 const char *name )
226 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, 226 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent,
227 name, true, true ) 227 name, true, true )
228{ 228{
229 QWidget *page = plainPage(); 229 QWidget *page = plainPage();
230 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); 230 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
231 231
232 KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); 232 KPIM::AddresseeView *view = new KPIM::AddresseeView( page );
233 view->setAddressee( addr ); 233 view->setAddressee( addr );
234 234
235 layout->addWidget( view ); 235 layout->addWidget( view );
236 236
237 resize( 400, 300 ); 237 resize( 400, 300 );
238} 238}
239 239
240#ifndef KAB_EMBEDDED 240#ifndef KAB_EMBEDDED
241#include "xxportmanager.moc" 241#include "xxportmanager.moc"
242#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
243 243
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 369c7a0..56b3fb0 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3606 +1,3608 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h> 86#include <libkcal/phoneformat.h>
87#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
88#include "komailclient.h" 88#include "komailclient.h"
89#endif 89#endif
90#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
91#include "calprinter.h" 91#include "calprinter.h"
92#endif 92#endif
93#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
94#include "kocore.h" 94#include "kocore.h"
95#endif 95#endif
96#include "koeventeditor.h" 96#include "koeventeditor.h"
97#include "kotodoeditor.h" 97#include "kotodoeditor.h"
98#include "koprefs.h" 98#include "koprefs.h"
99#include "koeventviewerdialog.h" 99#include "koeventviewerdialog.h"
100#include "publishdialog.h" 100#include "publishdialog.h"
101#include "kofilterview.h" 101#include "kofilterview.h"
102#include "koglobals.h" 102#include "koglobals.h"
103#include "koviewmanager.h" 103#include "koviewmanager.h"
104#include "koagendaview.h" 104#include "koagendaview.h"
105#include "kodialogmanager.h" 105#include "kodialogmanager.h"
106#include "outgoingdialog.h" 106#include "outgoingdialog.h"
107#include "incomingdialog.h" 107#include "incomingdialog.h"
108#include "statusdialog.h" 108#include "statusdialog.h"
109#include "kdatenavigator.h" 109#include "kdatenavigator.h"
110#include "kotodoview.h" 110#include "kotodoview.h"
111#include "datenavigator.h" 111#include "datenavigator.h"
112#include "resourceview.h" 112#include "resourceview.h"
113#include "navigatorbar.h" 113#include "navigatorbar.h"
114#include "searchdialog.h" 114#include "searchdialog.h"
115#include "mainwindow.h" 115#include "mainwindow.h"
116 116
117#include "calendarview.h" 117#include "calendarview.h"
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119#include <qtopia/alarmserver.h> 119#include <qtopia/alarmserver.h>
120#endif 120#endif
121#ifndef _WIN32_ 121#ifndef _WIN32_
122#include <stdlib.h> 122#include <stdlib.h>
123#include <stdio.h> 123#include <stdio.h>
124#include <unistd.h> 124#include <unistd.h>
125#else 125#else
126#include <qprocess.h> 126#include <qprocess.h>
127#endif 127#endif
128using namespace KOrg; 128using namespace KOrg;
129using namespace KCal; 129using namespace KCal;
130extern int globalFlagBlockAgenda; 130extern int globalFlagBlockAgenda;
131extern int globalFlagBlockStartup; 131extern int globalFlagBlockStartup;
132 132
133 133
134 134
135class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
136{ 136{
137 public: 137 public:
138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
139 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
140 { 140 {
141 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
142 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
143 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
144 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
146 lay->addWidget( format ); 146 lay->addWidget( format );
147 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
149 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
150 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
151 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
152 vcal->setChecked( true ); 152 vcal->setChecked( true );
153 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
154 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
155 tz->setChecked( true ); 155 tz->setChecked( true );
156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
157 lay->addWidget( ok ); 157 lay->addWidget( ok );
158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
159 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
162 resize( 200, 200 ); 162 resize( 200, 200 );
163 } 163 }
164 164
165 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
166 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
167private: 167private:
168 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
169}; 169};
170class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202 202
203 203
204CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
205 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
206 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
207 mCalendar( calendar ), 207 mCalendar( calendar ),
208 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
209{ 209{
210 210
211 mEventEditor = 0; 211 mEventEditor = 0;
212 mTodoEditor = 0; 212 mTodoEditor = 0;
213 213
214 init(); 214 init();
215} 215}
216 216
217CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
218 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
219 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
220 mCalendar( calendar ), 220 mCalendar( calendar ),
221 mResourceManager( 0 ) 221 mResourceManager( 0 )
222{ 222{
223 223
224 mEventEditor = 0; 224 mEventEditor = 0;
225 mTodoEditor = 0; 225 mTodoEditor = 0;
226 init();} 226 init();}
227 227
228void CalendarView::init() 228void CalendarView::init()
229{ 229{
230 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
231 mDatePickerMode = 0; 231 mDatePickerMode = 0;
232 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
233 writeLocale(); 233 writeLocale();
234 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
235 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
236 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
237 mModified = false; 237 mModified = false;
238 mReadOnly = false; 238 mReadOnly = false;
239 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
240 mCalPrinter = 0; 240 mCalPrinter = 0;
241 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
242 242
243 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
244 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
245 245
246 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
247 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
248 248
249 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
250#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
251 // create the main layout frames. 251 // create the main layout frames.
252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
253 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
254 254
255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
256 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
258 258
259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
260 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
264 264
265#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
266 mResourceView = 0; 266 mResourceView = 0;
267#else 267#else
268 if ( mResourceManager ) { 268 if ( mResourceManager ) {
269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
270 mResourceView->updateView(); 270 mResourceView->updateView();
271 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
272 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
273 } else { 273 } else {
274 mResourceView = 0; 274 mResourceView = 0;
275 } 275 }
276#endif 276#endif
277 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
279 279
280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
281 rightLayout->addWidget( mNavigatorBar ); 281 rightLayout->addWidget( mNavigatorBar );
282 282
283 mRightFrame = new QWidgetStack( rightBox ); 283 mRightFrame = new QWidgetStack( rightBox );
284 rightLayout->addWidget( mRightFrame, 1 ); 284 rightLayout->addWidget( mRightFrame, 1 );
285 285
286 mLeftFrame = mLeftSplitter; 286 mLeftFrame = mLeftSplitter;
287#else 287#else
288 QWidget *mainBox = new QWidget( this ); 288 QWidget *mainBox = new QWidget( this );
289 QWidget *leftFrame = new QWidget( mainBox ); 289 QWidget *leftFrame = new QWidget( mainBox );
290 290
291 QBoxLayout * mainBoxLayout; 291 QBoxLayout * mainBoxLayout;
292 QBoxLayout * leftFrameLayout; 292 QBoxLayout * leftFrameLayout;
293 if ( KOPrefs::instance()->mVerticalScreen ) { 293 if ( KOPrefs::instance()->mVerticalScreen ) {
294 mainBoxLayout = new QVBoxLayout(mainBox); 294 mainBoxLayout = new QVBoxLayout(mainBox);
295 leftFrameLayout = new QHBoxLayout(leftFrame ); 295 leftFrameLayout = new QHBoxLayout(leftFrame );
296 } else { 296 } else {
297 mainBoxLayout = new QHBoxLayout(mainBox); 297 mainBoxLayout = new QHBoxLayout(mainBox);
298 leftFrameLayout = new QVBoxLayout(leftFrame ); 298 leftFrameLayout = new QVBoxLayout(leftFrame );
299 } 299 }
300 topLayout->addWidget( mainBox ); 300 topLayout->addWidget( mainBox );
301 mainBoxLayout->addWidget (leftFrame); 301 mainBoxLayout->addWidget (leftFrame);
302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
303 "CalendarView::DateNavigator", QDate::currentDate()); 303 "CalendarView::DateNavigator", QDate::currentDate());
304 // mDateNavigator->blockSignals( true ); 304 // mDateNavigator->blockSignals( true );
305 leftFrameLayout->addWidget( mDateNavigator ); 305 leftFrameLayout->addWidget( mDateNavigator );
306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
308 308
309 if ( QApplication::desktop()->width() < 480 ) { 309 if ( QApplication::desktop()->width() < 480 ) {
310 leftFrameLayout->addWidget(mFilterView); 310 leftFrameLayout->addWidget(mFilterView);
311 leftFrameLayout->addWidget(mTodoList, 2 ); 311 leftFrameLayout->addWidget(mTodoList, 2 );
312 312
313 } else { 313 } else {
314 leftFrameLayout->addWidget(mTodoList,2 ); 314 leftFrameLayout->addWidget(mTodoList,2 );
315 leftFrameLayout->addWidget(mFilterView ); 315 leftFrameLayout->addWidget(mFilterView );
316 } 316 }
317 mFilterView->hide(); 317 mFilterView->hide();
318 QWidget *rightBox = new QWidget( mainBox ); 318 QWidget *rightBox = new QWidget( mainBox );
319 mainBoxLayout->addWidget ( rightBox, 10 ); 319 mainBoxLayout->addWidget ( rightBox, 10 );
320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
322 mRightFrame = new QWidgetStack( rightBox ); 322 mRightFrame = new QWidgetStack( rightBox );
323 rightLayout->addWidget( mNavigatorBar ); 323 rightLayout->addWidget( mNavigatorBar );
324 rightLayout->addWidget( mRightFrame, 10 ); 324 rightLayout->addWidget( mRightFrame, 10 );
325 325
326 mLeftFrame = leftFrame; 326 mLeftFrame = leftFrame;
327 if ( KOPrefs::instance()->mVerticalScreen ) { 327 if ( KOPrefs::instance()->mVerticalScreen ) {
328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
330 } else { 330 } else {
331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
333 } 333 }
334 334
335 //qDebug("Calendarview Size %d %d ", width(), height()); 335 //qDebug("Calendarview Size %d %d ", width(), height());
336#endif 336#endif
337 337
338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
339 SLOT( showDates( const KCal::DateList & ) ) ); 339 SLOT( showDates( const KCal::DateList & ) ) );
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
342 342
343 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 343 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
344 mNavigator, SLOT( selectPreviousYear() ) ); 344 mNavigator, SLOT( selectPreviousYear() ) );
345 connect( mNavigatorBar, SIGNAL( goNextYear() ), 345 connect( mNavigatorBar, SIGNAL( goNextYear() ),
346 mNavigator, SLOT( selectNextYear() ) ); 346 mNavigator, SLOT( selectNextYear() ) );
347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
348 mNavigator, SLOT( selectPreviousMonth() ) ); 348 mNavigator, SLOT( selectPreviousMonth() ) );
349 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 349 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
350 mNavigator, SLOT( selectNextMonth() ) ); 350 mNavigator, SLOT( selectNextMonth() ) );
351 351
352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
354 354
355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
356 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 356 mNavigator, SLOT( selectWeek( const QDate & ) ) );
357 357
358 connect( mDateNavigator, SIGNAL( goPrevYear() ), 358 connect( mDateNavigator, SIGNAL( goPrevYear() ),
359 mNavigator, SLOT( selectPreviousYear() ) ); 359 mNavigator, SLOT( selectPreviousYear() ) );
360 connect( mDateNavigator, SIGNAL( goNextYear() ), 360 connect( mDateNavigator, SIGNAL( goNextYear() ),
361 mNavigator, SLOT( selectNextYear() ) ); 361 mNavigator, SLOT( selectNextYear() ) );
362 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 362 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
363 mNavigator, SLOT( selectPreviousMonth() ) ); 363 mNavigator, SLOT( selectPreviousMonth() ) );
364 connect( mDateNavigator, SIGNAL( goNextMonth() ), 364 connect( mDateNavigator, SIGNAL( goNextMonth() ),
365 mNavigator, SLOT( selectNextMonth() ) ); 365 mNavigator, SLOT( selectNextMonth() ) );
366 366
367 connect( mDateNavigator, SIGNAL( goPrevious() ), 367 connect( mDateNavigator, SIGNAL( goPrevious() ),
368 mNavigator, SLOT( selectPrevious() ) ); 368 mNavigator, SLOT( selectPrevious() ) );
369 connect( mDateNavigator, SIGNAL( goNext() ), 369 connect( mDateNavigator, SIGNAL( goNext() ),
370 mNavigator, SLOT( selectNext() ) ); 370 mNavigator, SLOT( selectNext() ) );
371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
372 mNavigator, SLOT( slotMonthSelect( int ) ) ); 372 mNavigator, SLOT( slotMonthSelect( int ) ) );
373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 375
376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
378 378
379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
380 SLOT( eventAdded( Event *) ) ); 380 SLOT( eventAdded( Event *) ) );
381 381
382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
383 383
384 connect( this, SIGNAL( configChanged() ), 384 connect( this, SIGNAL( configChanged() ),
385 mDateNavigator, SLOT( updateConfig() ) ); 385 mDateNavigator, SLOT( updateConfig() ) );
386 386
387 connect( mTodoList, SIGNAL( newTodoSignal() ), 387 connect( mTodoList, SIGNAL( newTodoSignal() ),
388 SLOT( newTodo() ) ); 388 SLOT( newTodo() ) );
389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
390 SLOT( newSubTodo( Todo * ) ) ); 390 SLOT( newSubTodo( Todo * ) ) );
391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
392 SLOT( editTodo( Todo * ) ) ); 392 SLOT( editTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
394 SLOT( showTodo( Todo *) ) ); 394 SLOT( showTodo( Todo *) ) );
395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
396 SLOT( deleteTodo( Todo *) ) ); 396 SLOT( deleteTodo( Todo *) ) );
397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
399 SLOT( purgeCompleted() ) ); 399 SLOT( purgeCompleted() ) );
400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
401 SIGNAL( todoModified( Todo *, int ) ) ); 401 SIGNAL( todoModified( Todo *, int ) ) );
402 402
403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
404 this, SLOT ( cloneIncidence( Incidence * ) ) ); 404 this, SLOT ( cloneIncidence( Incidence * ) ) );
405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
406 this, SLOT (cancelIncidence( Incidence * ) ) ); 406 this, SLOT (cancelIncidence( Incidence * ) ) );
407 407
408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
409 this, SLOT ( moveIncidence( Incidence * ) ) ); 409 this, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
411 this, SLOT ( beamIncidence( Incidence * ) ) ); 411 this, SLOT ( beamIncidence( Incidence * ) ) );
412 412
413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
414 this, SLOT ( todo_unsub( Todo * ) ) ); 414 this, SLOT ( todo_unsub( Todo * ) ) );
415 415
416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
417 SLOT( updateTodo( Todo *, int ) ) ); 417 SLOT( updateTodo( Todo *, int ) ) );
418 connect( this, SIGNAL( todoModified( Todo *, int )), this, 418 connect( this, SIGNAL( todoModified( Todo *, int )), this,
419 SLOT( changeTodoDisplay( Todo *, int ) ) ); 419 SLOT( changeTodoDisplay( Todo *, int ) ) );
420 420
421 421
422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
426 426
427 427
428 428
429 429
430 430
431 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 431 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
432 SLOT(checkClipboard())); 432 SLOT(checkClipboard()));
433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
434 SLOT( processTodoListSelection( Incidence * ) ) ); 434 SLOT( processTodoListSelection( Incidence * ) ) );
435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
436 436
437 // kdDebug() << "CalendarView::CalendarView() done" << endl; 437 // kdDebug() << "CalendarView::CalendarView() done" << endl;
438 438
439 mDateFrame = new QVBox(0,0,WType_Popup); 439 mDateFrame = new QVBox(0,0,WType_Popup);
440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
442 mDateFrame->setLineWidth(3); 442 mDateFrame->setLineWidth(3);
443 mDateFrame->hide(); 443 mDateFrame->hide();
444 mDateFrame->setCaption( i18n( "Pick a date to display")); 444 mDateFrame->setCaption( i18n( "Pick a date to display"));
445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
446 446
447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
448 448
449 mEventEditor = mDialogManager->getEventEditor(); 449 mEventEditor = mDialogManager->getEventEditor();
450 mTodoEditor = mDialogManager->getTodoEditor(); 450 mTodoEditor = mDialogManager->getTodoEditor();
451 451
452 mFlagEditDescription = false; 452 mFlagEditDescription = false;
453 453
454 mSuspendTimer = new QTimer( this ); 454 mSuspendTimer = new QTimer( this );
455 mAlarmTimer = new QTimer( this ); 455 mAlarmTimer = new QTimer( this );
456 mRecheckAlarmTimer = new QTimer( this ); 456 mRecheckAlarmTimer = new QTimer( this );
457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 460 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 462 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 464}
465 465
466 466
467CalendarView::~CalendarView() 467CalendarView::~CalendarView()
468{ 468{
469 // kdDebug() << "~CalendarView()" << endl; 469 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 470 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 471 delete mDialogManager;
472 delete mViewManager; 472 delete mViewManager;
473 delete mStorage; 473 delete mStorage;
474 delete mDateFrame ; 474 delete mDateFrame ;
475 delete beamDialog; 475 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 476 //kdDebug() << "~CalendarView() done" << endl;
477} 477}
478void CalendarView::timerAlarm() 478void CalendarView::timerAlarm()
479{ 479{
480 //qDebug("CalendarView::timerAlarm() "); 480 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 481 computeAlarm(mAlarmNotification );
482} 482}
483 483
484void CalendarView::suspendAlarm() 484void CalendarView::suspendAlarm()
485{ 485{
486 //qDebug(" CalendarView::suspendAlarm() "); 486 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 487 computeAlarm(mSuspendAlarmNotification );
488 488
489} 489}
490 490
491void CalendarView::startAlarm( QString mess , QString filename) 491void CalendarView::startAlarm( QString mess , QString filename)
492{ 492{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
495 495
496} 496}
497 497
498void CalendarView::checkNextTimerAlarm() 498void CalendarView::checkNextTimerAlarm()
499{ 499{
500 mCalendar->checkAlarmForIncidence( 0, true ); 500 mCalendar->checkAlarmForIncidence( 0, true );
501} 501}
502 502
503void CalendarView::computeAlarm( QString msg ) 503void CalendarView::computeAlarm( QString msg )
504{ 504{
505 505
506 QString mess = msg; 506 QString mess = msg;
507 QString mAlarmMessage = mess.mid( 9 ); 507 QString mAlarmMessage = mess.mid( 9 );
508 QString filename = MainWindow::resourcePath(); 508 QString filename = MainWindow::resourcePath();
509 filename += "koalarm.wav"; 509 filename += "koalarm.wav";
510 QString tempfilename; 510 QString tempfilename;
511 if ( mess.left( 13 ) == "suspend_alarm") { 511 if ( mess.left( 13 ) == "suspend_alarm") {
512 bool error = false; 512 bool error = false;
513 int len = mess.mid( 13 ).find("+++"); 513 int len = mess.mid( 13 ).find("+++");
514 if ( len < 2 ) 514 if ( len < 2 )
515 error = true; 515 error = true;
516 else { 516 else {
517 tempfilename = mess.mid( 13, len ); 517 tempfilename = mess.mid( 13, len );
518 if ( !QFile::exists( tempfilename ) ) 518 if ( !QFile::exists( tempfilename ) )
519 error = true; 519 error = true;
520 } 520 }
521 if ( ! error ) { 521 if ( ! error ) {
522 filename = tempfilename; 522 filename = tempfilename;
523 } 523 }
524 mAlarmMessage = mess.mid( 13+len+3 ); 524 mAlarmMessage = mess.mid( 13+len+3 );
525 //qDebug("suspend file %s ",tempfilename.latin1() ); 525 //qDebug("suspend file %s ",tempfilename.latin1() );
526 startAlarm( mAlarmMessage, filename); 526 startAlarm( mAlarmMessage, filename);
527 return; 527 return;
528 } 528 }
529 if ( mess.left( 11 ) == "timer_alarm") { 529 if ( mess.left( 11 ) == "timer_alarm") {
530 //mTimerTime = 0; 530 //mTimerTime = 0;
531 startAlarm( mess.mid( 11 ), filename ); 531 startAlarm( mess.mid( 11 ), filename );
532 return; 532 return;
533 } 533 }
534 if ( mess.left( 10 ) == "proc_alarm") { 534 if ( mess.left( 10 ) == "proc_alarm") {
535 bool error = false; 535 bool error = false;
536 int len = mess.mid( 10 ).find("+++"); 536 int len = mess.mid( 10 ).find("+++");
537 if ( len < 2 ) 537 if ( len < 2 )
538 error = true; 538 error = true;
539 else { 539 else {
540 tempfilename = mess.mid( 10, len ); 540 tempfilename = mess.mid( 10, len );
541 if ( !QFile::exists( tempfilename ) ) 541 if ( !QFile::exists( tempfilename ) )
542 error = true; 542 error = true;
543 } 543 }
544 if ( error ) { 544 if ( error ) {
545 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 545 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
546 mAlarmMessage += mess.mid( 10+len+3+9 ); 546 mAlarmMessage += mess.mid( 10+len+3+9 );
547 } else { 547 } else {
548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
549 //qDebug("-----system command %s ",tempfilename.latin1() ); 549 //qDebug("-----system command %s ",tempfilename.latin1() );
550#ifndef _WIN32_ 550#ifndef _WIN32_
551 if ( vfork () == 0 ) { 551 if ( vfork () == 0 ) {
552 execl ( tempfilename.latin1(), 0 ); 552 execl ( tempfilename.latin1(), 0 );
553 return; 553 return;
554 } 554 }
555#else 555#else
556 QProcess* p = new QProcess(); 556 QProcess* p = new QProcess();
557 p->addArgument( tempfilename.latin1() ); 557 p->addArgument( tempfilename.latin1() );
558 p->start(); 558 p->start();
559 return; 559 return;
560#endif 560#endif
561 561
562 return; 562 return;
563 } 563 }
564 564
565 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 565 //qDebug("+++++++system command %s ",tempfilename.latin1() );
566 } 566 }
567 if ( mess.left( 11 ) == "audio_alarm") { 567 if ( mess.left( 11 ) == "audio_alarm") {
568 bool error = false; 568 bool error = false;
569 int len = mess.mid( 11 ).find("+++"); 569 int len = mess.mid( 11 ).find("+++");
570 if ( len < 2 ) 570 if ( len < 2 )
571 error = true; 571 error = true;
572 else { 572 else {
573 tempfilename = mess.mid( 11, len ); 573 tempfilename = mess.mid( 11, len );
574 if ( !QFile::exists( tempfilename ) ) 574 if ( !QFile::exists( tempfilename ) )
575 error = true; 575 error = true;
576 } 576 }
577 if ( ! error ) { 577 if ( ! error ) {
578 filename = tempfilename; 578 filename = tempfilename;
579 } 579 }
580 mAlarmMessage = mess.mid( 11+len+3+9 ); 580 mAlarmMessage = mess.mid( 11+len+3+9 );
581 //qDebug("audio file command %s ",tempfilename.latin1() ); 581 //qDebug("audio file command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 9 ) == "cal_alarm") { 583 if ( mess.left( 9 ) == "cal_alarm") {
584 mAlarmMessage = mess.mid( 9 ) ; 584 mAlarmMessage = mess.mid( 9 ) ;
585 } 585 }
586 586
587 startAlarm( mAlarmMessage, filename ); 587 startAlarm( mAlarmMessage, filename );
588 588
589 589
590} 590}
591 591
592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
593{ 593{
594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
595 595
596 mSuspendAlarmNotification = noti; 596 mSuspendAlarmNotification = noti;
597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
599 mSuspendTimer->start( ms , true ); 599 mSuspendTimer->start( ms , true );
600 600
601} 601}
602 602
603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
604{ 604{
605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
607#ifndef DESKTOP_VERSION 607#ifndef DESKTOP_VERSION
608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
609#endif 609#endif
610 return; 610 return;
611 } 611 }
612 int maxSec; 612 int maxSec;
613 //maxSec = 5; //testing only 613 //maxSec = 5; //testing only
614 maxSec = 86400+3600; // one day+1hour 614 maxSec = 86400+3600; // one day+1hour
615 mAlarmNotification = noti; 615 mAlarmNotification = noti;
616 int sec = QDateTime::currentDateTime().secsTo( qdt ); 616 int sec = QDateTime::currentDateTime().secsTo( qdt );
617 if ( sec > maxSec ) { 617 if ( sec > maxSec ) {
618 mRecheckAlarmTimer->start( maxSec * 1000 ); 618 mRecheckAlarmTimer->start( maxSec * 1000 );
619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
620 return; 620 return;
621 } else { 621 } else {
622 mRecheckAlarmTimer->stop(); 622 mRecheckAlarmTimer->stop();
623 } 623 }
624 //qDebug("Alarm timer started with secs: %d ", sec); 624 //qDebug("Alarm timer started with secs: %d ", sec);
625 mAlarmTimer->start( sec *1000 , true ); 625 mAlarmTimer->start( sec *1000 , true );
626 626
627} 627}
628// called by mRecheckAlarmTimer to get next alarm 628// called by mRecheckAlarmTimer to get next alarm
629// we need this, because a QTimer has only a max range of 25 days 629// we need this, because a QTimer has only a max range of 25 days
630void CalendarView::recheckTimerAlarm() 630void CalendarView::recheckTimerAlarm()
631{ 631{
632 mAlarmTimer->stop(); 632 mAlarmTimer->stop();
633 mRecheckAlarmTimer->stop(); 633 mRecheckAlarmTimer->stop();
634 mCalendar->checkAlarmForIncidence( 0, true ); 634 mCalendar->checkAlarmForIncidence( 0, true );
635} 635}
636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
637{ 637{
638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
640#ifndef DESKTOP_VERSION 640#ifndef DESKTOP_VERSION
641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
642#endif 642#endif
643 return; 643 return;
644 } 644 }
645 mAlarmTimer->stop(); 645 mAlarmTimer->stop();
646} 646}
647void CalendarView::selectWeekNum ( int num ) 647void CalendarView::selectWeekNum ( int num )
648{ 648{
649 dateNavigator()->selectWeek( num ); 649 dateNavigator()->selectWeek( num );
650 mViewManager->showWeekView(); 650 mViewManager->showWeekView();
651} 651}
652KOViewManager *CalendarView::viewManager() 652KOViewManager *CalendarView::viewManager()
653{ 653{
654 return mViewManager; 654 return mViewManager;
655} 655}
656 656
657KODialogManager *CalendarView::dialogManager() 657KODialogManager *CalendarView::dialogManager()
658{ 658{
659 return mDialogManager; 659 return mDialogManager;
660} 660}
661 661
662QDate CalendarView::startDate() 662QDate CalendarView::startDate()
663{ 663{
664 DateList dates = mNavigator->selectedDates(); 664 DateList dates = mNavigator->selectedDates();
665 665
666 return dates.first(); 666 return dates.first();
667} 667}
668 668
669QDate CalendarView::endDate() 669QDate CalendarView::endDate()
670{ 670{
671 DateList dates = mNavigator->selectedDates(); 671 DateList dates = mNavigator->selectedDates();
672 672
673 return dates.last(); 673 return dates.last();
674} 674}
675 675
676 676
677void CalendarView::createPrinter() 677void CalendarView::createPrinter()
678{ 678{
679#ifndef KORG_NOPRINTER 679#ifndef KORG_NOPRINTER
680 if (!mCalPrinter) { 680 if (!mCalPrinter) {
681 mCalPrinter = new CalPrinter(this, mCalendar); 681 mCalPrinter = new CalPrinter(this, mCalendar);
682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
683 } 683 }
684#endif 684#endif
685} 685}
686 686
687void CalendarView::confSync() 687void CalendarView::confSync()
688{ 688{
689 static KSyncPrefsDialog* sp = 0; 689 static KSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 690 if ( ! sp ) {
691 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KSyncPrefsDialog( this, "syncprefs", true );
692 } 692 }
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 702}
703 703
704 704
705//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
707 707
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 714
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 716{
717 717
718 //void setZaurusId(int id); 718 //void setZaurusId(int id);
719 // int zaurusId() const; 719 // int zaurusId() const;
720 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
721 // int zaurusUid() const; 721 // int zaurusUid() const;
722 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
723 // int zaurusStat() const; 723 // int zaurusStat() const;
724 // 0 equal 724 // 0 equal
725 // 1 take local 725 // 1 take local
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 730 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 //if ( remCh ) 732 //if ( remCh )
733 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 733 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
734 locCh = ( local->lastModified() > mLastCalendarSync ); 734 locCh = ( local->lastModified() > mLastCalendarSync );
735 if ( !remCh && ! locCh ) { 735 if ( !remCh && ! locCh ) {
736 //qDebug("both not changed "); 736 //qDebug("both not changed ");
737 lastSync = local->lastModified().addDays(1); 737 lastSync = local->lastModified().addDays(1);
738 } else { 738 } else {
739 if ( locCh ) { 739 if ( locCh ) {
740 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); 740 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1());
741 lastSync = local->lastModified().addDays( -1 ); 741 lastSync = local->lastModified().addDays( -1 );
742 if ( !remCh ) 742 if ( !remCh )
743 remote->setLastModified( lastSync.addDays( -1 ) ); 743 remote->setLastModified( lastSync.addDays( -1 ) );
744 } else { 744 } else {
745 //qDebug(" not loc changed "); 745 //qDebug(" not loc changed ");
746 lastSync = local->lastModified().addDays( 1 ); 746 lastSync = local->lastModified().addDays( 1 );
747 if ( remCh ) 747 if ( remCh )
748 remote->setLastModified( lastSync.addDays( 1 ) ); 748 remote->setLastModified( lastSync.addDays( 1 ) );
749 749
750 } 750 }
751 } 751 }
752 full = true; 752 full = true;
753 if ( mode < SYNC_PREF_ASK ) 753 if ( mode < SYNC_PREF_ASK )
754 mode = SYNC_PREF_ASK; 754 mode = SYNC_PREF_ASK;
755 } else { 755 } else {
756 if ( local->lastModified() == remote->lastModified() ) 756 if ( local->lastModified() == remote->lastModified() )
757 if ( local->revision() == remote->revision() ) 757 if ( local->revision() == remote->revision() )
758 return 0; 758 return 0;
759 759
760 } 760 }
761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
762 762
763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
765 //full = true; //debug only 765 //full = true; //debug only
766 if ( full ) { 766 if ( full ) {
767 bool equ = false; 767 bool equ = false;
768 if ( local->type() == "Event" ) { 768 if ( local->type() == "Event" ) {
769 equ = (*((Event*) local) == *((Event*) remote)); 769 equ = (*((Event*) local) == *((Event*) remote));
770 } 770 }
771 else if ( local->type() =="Todo" ) 771 else if ( local->type() =="Todo" )
772 equ = (*((Todo*) local) == (*(Todo*) remote)); 772 equ = (*((Todo*) local) == (*(Todo*) remote));
773 else if ( local->type() =="Journal" ) 773 else if ( local->type() =="Journal" )
774 equ = (*((Journal*) local) == *((Journal*) remote)); 774 equ = (*((Journal*) local) == *((Journal*) remote));
775 if ( equ ) { 775 if ( equ ) {
776 //qDebug("equal "); 776 //qDebug("equal ");
777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
778 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 778 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
779 } 779 }
780 if ( mode < SYNC_PREF_FORCE_LOCAL ) 780 if ( mode < SYNC_PREF_FORCE_LOCAL )
781 return 0; 781 return 0;
782 782
783 }//else //debug only 783 }//else //debug only
784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
785 } 785 }
786 int result; 786 int result;
787 bool localIsNew; 787 bool localIsNew;
788 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 788 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
789 789
790 if ( full && mode < SYNC_PREF_NEWEST ) 790 if ( full && mode < SYNC_PREF_NEWEST )
791 mode = SYNC_PREF_ASK; 791 mode = SYNC_PREF_ASK;
792 792
793 switch( mode ) { 793 switch( mode ) {
794 case SYNC_PREF_LOCAL: 794 case SYNC_PREF_LOCAL:
795 if ( lastSync > remote->lastModified() ) 795 if ( lastSync > remote->lastModified() )
796 return 1; 796 return 1;
797 if ( lastSync > local->lastModified() ) 797 if ( lastSync > local->lastModified() )
798 return 2; 798 return 2;
799 return 1; 799 return 1;
800 break; 800 break;
801 case SYNC_PREF_REMOTE: 801 case SYNC_PREF_REMOTE:
802 if ( lastSync > remote->lastModified() ) 802 if ( lastSync > remote->lastModified() )
803 return 1; 803 return 1;
804 if ( lastSync > local->lastModified() ) 804 if ( lastSync > local->lastModified() )
805 return 2; 805 return 2;
806 return 2; 806 return 2;
807 break; 807 break;
808 case SYNC_PREF_NEWEST: 808 case SYNC_PREF_NEWEST:
809 if ( local->lastModified() > remote->lastModified() ) 809 if ( local->lastModified() > remote->lastModified() )
810 return 1; 810 return 1;
811 else 811 else
812 return 2; 812 return 2;
813 break; 813 break;
814 case SYNC_PREF_ASK: 814 case SYNC_PREF_ASK:
815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
816 if ( lastSync > remote->lastModified() ) 816 if ( lastSync > remote->lastModified() )
817 return 1; 817 return 1;
818 if ( lastSync > local->lastModified() ) 818 if ( lastSync > local->lastModified() )
819 return 2; 819 return 2;
820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
821 localIsNew = local->lastModified() >= remote->lastModified(); 821 localIsNew = local->lastModified() >= remote->lastModified();
822 if ( localIsNew ) 822 if ( localIsNew )
823 getEventViewerDialog()->setColorMode( 1 ); 823 getEventViewerDialog()->setColorMode( 1 );
824 else 824 else
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 getEventViewerDialog()->setIncidence(local); 826 getEventViewerDialog()->setIncidence(local);
827 if ( localIsNew ) 827 if ( localIsNew )
828 getEventViewerDialog()->setColorMode( 2 ); 828 getEventViewerDialog()->setColorMode( 2 );
829 else 829 else
830 getEventViewerDialog()->setColorMode( 1 ); 830 getEventViewerDialog()->setColorMode( 1 );
831 getEventViewerDialog()->addIncidence(remote); 831 getEventViewerDialog()->addIncidence(remote);
832 getEventViewerDialog()->setColorMode( 0 ); 832 getEventViewerDialog()->setColorMode( 0 );
833 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 833 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
834 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 834 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
835 getEventViewerDialog()->showMe(); 835 getEventViewerDialog()->showMe();
836 result = getEventViewerDialog()->executeS( localIsNew ); 836 result = getEventViewerDialog()->executeS( localIsNew );
837 return result; 837 return result;
838 838
839 break; 839 break;
840 case SYNC_PREF_FORCE_LOCAL: 840 case SYNC_PREF_FORCE_LOCAL:
841 return 1; 841 return 1;
842 break; 842 break;
843 case SYNC_PREF_FORCE_REMOTE: 843 case SYNC_PREF_FORCE_REMOTE:
844 return 2; 844 return 2;
845 break; 845 break;
846 846
847 default: 847 default:
848 // SYNC_PREF_TAKE_BOTH not implemented 848 // SYNC_PREF_TAKE_BOTH not implemented
849 break; 849 break;
850 } 850 }
851 return 0; 851 return 0;
852} 852}
853Event* CalendarView::getLastSyncEvent() 853Event* CalendarView::getLastSyncEvent()
854{ 854{
855 Event* lse; 855 Event* lse;
856 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 856 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
857 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
858 if (!lse) { 858 if (!lse) {
859 lse = new Event(); 859 lse = new Event();
860 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 860 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
861 QString sum = ""; 861 QString sum = "";
862 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 862 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
863 sum = "E: "; 863 sum = "E: ";
864 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 864 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
865 lse->setDtStart( mLastCalendarSync ); 865 lse->setDtStart( mLastCalendarSync );
866 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 866 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
867 lse->setCategories( i18n("SyncEvent") ); 867 lse->setCategories( i18n("SyncEvent") );
868 lse->setReadOnly( true ); 868 lse->setReadOnly( true );
869 mCalendar->addEvent( lse ); 869 mCalendar->addEvent( lse );
870 } 870 }
871 871
872 return lse; 872 return lse;
873 873
874} 874}
875// probaly useless 875// probaly useless
876void CalendarView::setupExternSyncProfiles() 876void CalendarView::setupExternSyncProfiles()
877{ 877{
878 Event* lse; 878 Event* lse;
879 mExternLastSyncEvent.clear(); 879 mExternLastSyncEvent.clear();
880 int i; 880 int i;
881 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 881 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
882 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 882 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
883 if ( lse ) 883 if ( lse )
884 mExternLastSyncEvent.append( lse ); 884 mExternLastSyncEvent.append( lse );
885 else 885 else
886 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 886 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
887 } 887 }
888 888
889} 889}
890// we check, if the to delete event has a id for a profile 890// we check, if the to delete event has a id for a profile
891// if yes, we set this id in the profile to delete 891// if yes, we set this id in the profile to delete
892void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 892void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
893{ 893{
894 if ( lastSync.count() == 0 ) { 894 if ( lastSync.count() == 0 ) {
895 //qDebug(" lastSync.count() == 0"); 895 //qDebug(" lastSync.count() == 0");
896 return; 896 return;
897 } 897 }
898 if ( toDelete->type() == "Journal" ) 898 if ( toDelete->type() == "Journal" )
899 return; 899 return;
900 900
901 Event* eve = lastSync.first(); 901 Event* eve = lastSync.first();
902 902
903 while ( eve ) { 903 while ( eve ) {
904 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 904 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
905 if ( !id.isEmpty() ) { 905 if ( !id.isEmpty() ) {
906 QString des = eve->description(); 906 QString des = eve->description();
907 QString pref = "e"; 907 QString pref = "e";
908 if ( toDelete->type() == "Todo" ) 908 if ( toDelete->type() == "Todo" )
909 pref = "t"; 909 pref = "t";
910 des += pref+ id + ","; 910 des += pref+ id + ",";
911 eve->setReadOnly( false ); 911 eve->setReadOnly( false );
912 eve->setDescription( des ); 912 eve->setDescription( des );
913 //qDebug("setdes %s ", des.latin1()); 913 //qDebug("setdes %s ", des.latin1());
914 eve->setReadOnly( true ); 914 eve->setReadOnly( true );
915 } 915 }
916 eve = lastSync.next(); 916 eve = lastSync.next();
917 } 917 }
918 918
919} 919}
920void CalendarView::checkExternalId( Incidence * inc ) 920void CalendarView::checkExternalId( Incidence * inc )
921{ 921{
922 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 922 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
923 checkExternSyncEvent( lastSync, inc ); 923 checkExternSyncEvent( lastSync, inc );
924 924
925} 925}
926bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 926bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
927{ 927{
928 bool syncOK = true; 928 bool syncOK = true;
929 int addedEvent = 0; 929 int addedEvent = 0;
930 int addedEventR = 0; 930 int addedEventR = 0;
931 int deletedEventR = 0; 931 int deletedEventR = 0;
932 int deletedEventL = 0; 932 int deletedEventL = 0;
933 int changedLocal = 0; 933 int changedLocal = 0;
934 int changedRemote = 0; 934 int changedRemote = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 QDateTime modifiedCalendar = mLastCalendarSync;; 947 QDateTime modifiedCalendar = mLastCalendarSync;;
948 eventLSync = getLastSyncEvent(); 948 eventLSync = getLastSyncEvent();
949 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 949 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
950 if ( eventR ) { 950 if ( eventR ) {
951 eventRSync = (Event*) eventR->clone(); 951 eventRSync = (Event*) eventR->clone();
952 remote->deleteEvent(eventR ); 952 remote->deleteEvent(eventR );
953 953
954 } else { 954 } else {
955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 955 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
956 eventRSync = (Event*)eventLSync->clone(); 956 eventRSync = (Event*)eventLSync->clone();
957 } else { 957 } else {
958 fullDateRange = true; 958 fullDateRange = true;
959 eventRSync = new Event(); 959 eventRSync = new Event();
960 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 960 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
961 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 961 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
962 eventRSync->setDtStart( mLastCalendarSync ); 962 eventRSync->setDtStart( mLastCalendarSync );
963 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 963 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
964 eventRSync->setCategories( i18n("SyncEvent") ); 964 eventRSync->setCategories( i18n("SyncEvent") );
965 } 965 }
966 } 966 }
967 if ( eventLSync->dtStart() == mLastCalendarSync ) 967 if ( eventLSync->dtStart() == mLastCalendarSync )
968 fullDateRange = true; 968 fullDateRange = true;
969 969
970 if ( ! fullDateRange ) { 970 if ( ! fullDateRange ) {
971 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 971 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
972 972
973 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 973 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
974 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 974 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
975 fullDateRange = true; 975 fullDateRange = true;
976 } 976 }
977 } 977 }
978 if ( fullDateRange ) 978 if ( fullDateRange )
979 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 979 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
980 else 980 else
981 mLastCalendarSync = eventLSync->dtStart(); 981 mLastCalendarSync = eventLSync->dtStart();
982 // for resyncing if own file has changed 982 // for resyncing if own file has changed
983 if ( mCurrentSyncDevice == "deleteaftersync" ) { 983 if ( mCurrentSyncDevice == "deleteaftersync" ) {
984 mLastCalendarSync = loadedFileVersion; 984 mLastCalendarSync = loadedFileVersion;
985 qDebug("setting mLastCalendarSync "); 985 qDebug("setting mLastCalendarSync ");
986 } 986 }
987 //qDebug("*************************** "); 987 //qDebug("*************************** ");
988 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 988 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
989 QPtrList<Incidence> er = remote->rawIncidences(); 989 QPtrList<Incidence> er = remote->rawIncidences();
990 Incidence* inR = er.first(); 990 Incidence* inR = er.first();
991 Incidence* inL; 991 Incidence* inL;
992 QProgressBar bar( er.count(),0 ); 992 QProgressBar bar( er.count(),0 );
993 bar.setCaption (i18n("Syncing - close to abort!") ); 993 bar.setCaption (i18n("Syncing - close to abort!") );
994 994
995 int w = 300; 995 int w = 300;
996 if ( QApplication::desktop()->width() < 320 ) 996 if ( QApplication::desktop()->width() < 320 )
997 w = 220; 997 w = 220;
998 int h = bar.sizeHint().height() ; 998 int h = bar.sizeHint().height() ;
999 int dw = QApplication::desktop()->width(); 999 int dw = QApplication::desktop()->width();
1000 int dh = QApplication::desktop()->height(); 1000 int dh = QApplication::desktop()->height();
1001 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1001 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1002 bar.show(); 1002 bar.show();
1003 int modulo = (er.count()/10)+1; 1003 int modulo = (er.count()/10)+1;
1004 int incCounter = 0; 1004 int incCounter = 0;
1005 while ( inR ) { 1005 while ( inR ) {
1006 if ( ! bar.isVisible() ) 1006 if ( ! bar.isVisible() )
1007 return false; 1007 return false;
1008 if ( incCounter % modulo == 0 ) 1008 if ( incCounter % modulo == 0 )
1009 bar.setProgress( incCounter ); 1009 bar.setProgress( incCounter );
1010 ++incCounter; 1010 ++incCounter;
1011 uid = inR->uid(); 1011 uid = inR->uid();
1012 bool skipIncidence = false; 1012 bool skipIncidence = false;
1013 if ( uid.left(15) == QString("last-syncEvent-") ) 1013 if ( uid.left(15) == QString("last-syncEvent-") )
1014 skipIncidence = true; 1014 skipIncidence = true;
1015 QString idS; 1015 QString idS;
1016 qApp->processEvents(); 1016 qApp->processEvents();
1017 if ( !skipIncidence ) { 1017 if ( !skipIncidence ) {
1018 inL = local->incidence( uid ); 1018 inL = local->incidence( uid );
1019 if ( inL ) { // maybe conflict - same uid in both calendars 1019 if ( inL ) { // maybe conflict - same uid in both calendars
1020 int maxrev = inL->revision(); 1020 int maxrev = inL->revision();
1021 if ( maxrev < inR->revision() ) 1021 if ( maxrev < inR->revision() )
1022 maxrev = inR->revision(); 1022 maxrev = inR->revision();
1023 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1023 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1024 //qDebug("take %d %s ", take, inL->summary().latin1()); 1024 //qDebug("take %d %s ", take, inL->summary().latin1());
1025 if ( take == 3 ) 1025 if ( take == 3 )
1026 return false; 1026 return false;
1027 if ( take == 1 ) {// take local 1027 if ( take == 1 ) {// take local
1028 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1028 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1029 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1029 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1030 else 1030 else
1031 idS = inR->IDStr(); 1031 idS = inR->IDStr();
1032 remote->deleteIncidence( inR ); 1032 remote->deleteIncidence( inR );
1033 if ( inL->revision() < maxrev ) 1033 if ( inL->revision() < maxrev )
1034 inL->setRevision( maxrev ); 1034 inL->setRevision( maxrev );
1035 inR = inL->clone(); 1035 inR = inL->clone();
1036 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1036 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1037 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1037 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1038 inR->setIDStr( idS ); 1038 inR->setIDStr( idS );
1039 remote->addIncidence( inR ); 1039 remote->addIncidence( inR );
1040 ++changedRemote; 1040 ++changedRemote;
1041 } else { 1041 } else {
1042 if ( inR->revision() < maxrev ) 1042 if ( inR->revision() < maxrev )
1043 inR->setRevision( maxrev ); 1043 inR->setRevision( maxrev );
1044 idS = inL->IDStr(); 1044 idS = inL->IDStr();
1045 local->deleteIncidence( inL ); 1045 local->deleteIncidence( inL );
1046 inL = inR->clone(); 1046 inL = inR->clone();
1047 inL->setIDStr( idS ); 1047 inL->setIDStr( idS );
1048 local->addIncidence( inL ); 1048 local->addIncidence( inL );
1049 ++changedLocal; 1049 ++changedLocal;
1050 } 1050 }
1051 } 1051 }
1052 } else { // no conflict 1052 } else { // no conflict
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 QString des = eventLSync->description(); 1054 QString des = eventLSync->description();
1055 QString pref = "e"; 1055 QString pref = "e";
1056 if ( inR->type() == "Todo" ) 1056 if ( inR->type() == "Todo" )
1057 pref = "t"; 1057 pref = "t";
1058 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1058 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1059 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1059 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1060 //remote->deleteIncidence( inR ); 1060 //remote->deleteIncidence( inR );
1061 ++deletedEventR; 1061 ++deletedEventR;
1062 } else { 1062 } else {
1063 inR->setLastModified( modifiedCalendar ); 1063 inR->setLastModified( modifiedCalendar );
1064 inL = inR->clone(); 1064 inL = inR->clone();
1065 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1066 ++addedEvent; 1066 ++addedEvent;
1067 } 1067 }
1068 } else { 1068 } else {
1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1070 inR->setLastModified( modifiedCalendar ); 1070 inR->setLastModified( modifiedCalendar );
1071 local->addIncidence( inR->clone() ); 1071 local->addIncidence( inR->clone() );
1072 ++addedEvent; 1072 ++addedEvent;
1073 } else { 1073 } else {
1074 checkExternSyncEvent(eventRSyncSharp, inR); 1074 checkExternSyncEvent(eventRSyncSharp, inR);
1075 remote->deleteIncidence( inR ); 1075 remote->deleteIncidence( inR );
1076 ++deletedEventR; 1076 ++deletedEventR;
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 } 1080 }
1081 inR = er.next(); 1081 inR = er.next();
1082 } 1082 }
1083 QPtrList<Incidence> el = local->rawIncidences(); 1083 QPtrList<Incidence> el = local->rawIncidences();
1084 inL = el.first(); 1084 inL = el.first();
1085 modulo = (el.count()/10)+1; 1085 modulo = (el.count()/10)+1;
1086 bar.setCaption (i18n("Add / remove events") ); 1086 bar.setCaption (i18n("Add / remove events") );
1087 bar.setTotalSteps ( el.count() ) ; 1087 bar.setTotalSteps ( el.count() ) ;
1088 bar.show(); 1088 bar.show();
1089 incCounter = 0; 1089 incCounter = 0;
1090 1090
1091 while ( inL ) { 1091 while ( inL ) {
1092 1092
1093 qApp->processEvents(); 1093 qApp->processEvents();
1094 if ( ! bar.isVisible() ) 1094 if ( ! bar.isVisible() )
1095 return false; 1095 return false;
1096 if ( incCounter % modulo == 0 ) 1096 if ( incCounter % modulo == 0 )
1097 bar.setProgress( incCounter ); 1097 bar.setProgress( incCounter );
1098 ++incCounter; 1098 ++incCounter;
1099 uid = inL->uid(); 1099 uid = inL->uid();
1100 bool skipIncidence = false; 1100 bool skipIncidence = false;
1101 if ( uid.left(15) == QString("last-syncEvent-") ) 1101 if ( uid.left(15) == QString("last-syncEvent-") )
1102 skipIncidence = true; 1102 skipIncidence = true;
1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1104 skipIncidence = true; 1104 skipIncidence = true;
1105 if ( !skipIncidence ) { 1105 if ( !skipIncidence ) {
1106 inR = remote->incidence( uid ); 1106 inR = remote->incidence( uid );
1107 if ( ! inR ) { 1107 if ( ! inR ) {
1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1110 checkExternSyncEvent(eventLSyncSharp, inL); 1110 checkExternSyncEvent(eventLSyncSharp, inL);
1111 local->deleteIncidence( inL ); 1111 local->deleteIncidence( inL );
1112 ++deletedEventL; 1112 ++deletedEventL;
1113 } else { 1113 } else {
1114 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1114 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1115 inL->removeID(mCurrentSyncDevice ); 1115 inL->removeID(mCurrentSyncDevice );
1116 ++addedEventR; 1116 ++addedEventR;
1117 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1117 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1118 inL->setLastModified( modifiedCalendar ); 1118 inL->setLastModified( modifiedCalendar );
1119 inR = inL->clone(); 1119 inR = inL->clone();
1120 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1120 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1121 remote->addIncidence( inR ); 1121 remote->addIncidence( inR );
1122 } 1122 }
1123 } 1123 }
1124 } else { 1124 } else {
1125 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1125 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1126 checkExternSyncEvent(eventLSyncSharp, inL); 1126 checkExternSyncEvent(eventLSyncSharp, inL);
1127 local->deleteIncidence( inL ); 1127 local->deleteIncidence( inL );
1128 ++deletedEventL; 1128 ++deletedEventL;
1129 } else { 1129 } else {
1130 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1130 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1131 ++addedEventR; 1131 ++addedEventR;
1132 inL->setLastModified( modifiedCalendar ); 1132 inL->setLastModified( modifiedCalendar );
1133 remote->addIncidence( inL->clone() ); 1133 remote->addIncidence( inL->clone() );
1134 } 1134 }
1135 } 1135 }
1136 } 1136 }
1137 } 1137 }
1138 } 1138 }
1139 inL = el.next(); 1139 inL = el.next();
1140 } 1140 }
1141 int delFut = 0; 1141 int delFut = 0;
1142 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1142 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1143 er = remote->rawIncidences(); 1143 er = remote->rawIncidences();
1144 inR = er.first(); 1144 inR = er.first();
1145 QDateTime dt; 1145 QDateTime dt;
1146 QDateTime cur = QDateTime::currentDateTime(); 1146 QDateTime cur = QDateTime::currentDateTime();
1147 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); 1147 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
1148 while ( inR ) { 1148 while ( inR ) {
1149 if ( inR->type() == "Todo" ) { 1149 if ( inR->type() == "Todo" ) {
1150 Todo * t = (Todo*)inR; 1150 Todo * t = (Todo*)inR;
1151 if ( t->hasDueDate() ) 1151 if ( t->hasDueDate() )
1152 dt = t->dtDue(); 1152 dt = t->dtDue();
1153 else 1153 else
1154 dt = cur.addSecs( 62 ); 1154 dt = cur.addSecs( 62 );
1155 } 1155 }
1156 else if (inR->type() == "Event" ) { 1156 else if (inR->type() == "Event" ) {
1157 bool ok; 1157 bool ok;
1158 dt = inR->getNextOccurence( cur, &ok ); 1158 dt = inR->getNextOccurence( cur, &ok );
1159 if ( !ok ) 1159 if ( !ok )
1160 dt = cur.addSecs( -62 ); 1160 dt = cur.addSecs( -62 );
1161 } 1161 }
1162 else 1162 else
1163 dt = inR->dtStart(); 1163 dt = inR->dtStart();
1164 if ( dt < cur || dt > end ) { 1164 if ( dt < cur || dt > end ) {
1165 remote->deleteIncidence( inR ); 1165 remote->deleteIncidence( inR );
1166 ++delFut; 1166 ++delFut;
1167 } 1167 }
1168 inR = er.next(); 1168 inR = er.next();
1169 } 1169 }
1170 } 1170 }
1171 bar.hide(); 1171 bar.hide();
1172 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1172 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1173 eventLSync->setReadOnly( false ); 1173 eventLSync->setReadOnly( false );
1174 eventLSync->setDtStart( mLastCalendarSync ); 1174 eventLSync->setDtStart( mLastCalendarSync );
1175 eventRSync->setDtStart( mLastCalendarSync ); 1175 eventRSync->setDtStart( mLastCalendarSync );
1176 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1176 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1177 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1177 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1178 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1178 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1179 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1179 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1180 eventLSync->setReadOnly( true ); 1180 eventLSync->setReadOnly( true );
1181 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1181 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1182 remote->addEvent( eventRSync ); 1182 remote->addEvent( eventRSync );
1183 QString mes; 1183 QString mes;
1184 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1184 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1185 QString delmess; 1185 QString delmess;
1186 if ( delFut ) { 1186 if ( delFut ) {
1187 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1187 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1188 mes += delmess; 1188 mes += delmess;
1189 } 1189 }
1190 if ( KOPrefs::instance()->mShowSyncSummary ) { 1190 if ( KOPrefs::instance()->mShowSyncSummary ) {
1191 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1191 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1192 } 1192 }
1193 qDebug( mes ); 1193 qDebug( mes );
1194 mCalendar->checkAlarmForIncidence( 0, true ); 1194 mCalendar->checkAlarmForIncidence( 0, true );
1195 return syncOK; 1195 return syncOK;
1196} 1196}
1197 1197
1198void CalendarView::setSyncDevice( QString s ) 1198void CalendarView::setSyncDevice( QString s )
1199{ 1199{
1200 mCurrentSyncDevice= s; 1200 mCurrentSyncDevice= s;
1201} 1201}
1202void CalendarView::setSyncName( QString s ) 1202void CalendarView::setSyncName( QString s )
1203{ 1203{
1204 mCurrentSyncName= s; 1204 mCurrentSyncName= s;
1205} 1205}
1206bool CalendarView::syncCalendar(QString filename, int mode) 1206bool CalendarView::syncCalendar(QString filename, int mode)
1207{ 1207{
1208 mGlobalSyncMode = SYNC_MODE_NORMAL; 1208 mGlobalSyncMode = SYNC_MODE_NORMAL;
1209 CalendarLocal* calendar = new CalendarLocal(); 1209 CalendarLocal* calendar = new CalendarLocal();
1210 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1210 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1211 FileStorage* storage = new FileStorage( calendar ); 1211 FileStorage* storage = new FileStorage( calendar );
1212 bool syncOK = false; 1212 bool syncOK = false;
1213 storage->setFileName( filename ); 1213 storage->setFileName( filename );
1214 // qDebug("loading ... "); 1214 // qDebug("loading ... ");
1215 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1215 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1216 getEventViewerDialog()->setSyncMode( true ); 1216 getEventViewerDialog()->setSyncMode( true );
1217 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1217 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1218 getEventViewerDialog()->setSyncMode( false ); 1218 getEventViewerDialog()->setSyncMode( false );
1219 if ( syncOK ) { 1219 if ( syncOK ) {
1220 if ( KOPrefs::instance()->mWriteBackFile ) 1220 if ( KOPrefs::instance()->mWriteBackFile )
1221 { 1221 {
1222 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1222 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1223 storage->save(); 1223 storage->save();
1224 } 1224 }
1225 } 1225 }
1226 setModified( true ); 1226 setModified( true );
1227 } 1227 }
1228 delete storage; 1228 delete storage;
1229 delete calendar; 1229 delete calendar;
1230 if ( syncOK ) 1230 if ( syncOK )
1231 updateView(); 1231 updateView();
1232 return syncOK; 1232 return syncOK;
1233} 1233}
1234void CalendarView::syncPhone() 1234void CalendarView::syncPhone()
1235{ 1235{
1236 syncExternal( 1 ); 1236 syncExternal( 1 );
1237} 1237}
1238void CalendarView::syncExternal( int mode ) 1238void CalendarView::syncExternal( int mode )
1239{ 1239{
1240 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1240 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1241 //mCurrentSyncDevice = "sharp-DTM"; 1241 //mCurrentSyncDevice = "sharp-DTM";
1242 if ( KOPrefs::instance()->mAskForPreferences ) 1242 if ( KOPrefs::instance()->mAskForPreferences )
1243 edit_sync_options(); 1243 edit_sync_options();
1244 qApp->processEvents(); 1244 qApp->processEvents();
1245 CalendarLocal* calendar = new CalendarLocal(); 1245 CalendarLocal* calendar = new CalendarLocal();
1246 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1246 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1247 bool syncOK = false; 1247 bool syncOK = false;
1248 bool loadSuccess = false; 1248 bool loadSuccess = false;
1249 PhoneFormat* phoneFormat = 0; 1249 PhoneFormat* phoneFormat = 0;
1250#ifndef DESKTOP_VERSION 1250#ifndef DESKTOP_VERSION
1251 SharpFormat* sharpFormat = 0; 1251 SharpFormat* sharpFormat = 0;
1252 if ( mode == 0 ) { // sharp 1252 if ( mode == 0 ) { // sharp
1253 sharpFormat = new SharpFormat () ; 1253 sharpFormat = new SharpFormat () ;
1254 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1254 loadSuccess = sharpFormat->load( calendar, mCalendar );
1255 1255
1256 } else 1256 } else
1257#endif 1257#endif
1258 if ( mode == 1 ) { // phone 1258 if ( mode == 1 ) { // phone
1259 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1259 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1260 KOPrefs::instance()->mPhoneDevice, 1260 KOPrefs::instance()->mPhoneDevice,
1261 KOPrefs::instance()->mPhoneConnection, 1261 KOPrefs::instance()->mPhoneConnection,
1262 KOPrefs::instance()->mPhoneModel); 1262 KOPrefs::instance()->mPhoneModel);
1263 loadSuccess = phoneFormat->load( calendar,mCalendar); 1263 loadSuccess = phoneFormat->load( calendar,mCalendar);
1264 1264
1265 } else 1265 } else
1266 return; 1266 return;
1267 if ( loadSuccess ) { 1267 if ( loadSuccess ) {
1268 getEventViewerDialog()->setSyncMode( true ); 1268 getEventViewerDialog()->setSyncMode( true );
1269 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1269 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1270 getEventViewerDialog()->setSyncMode( false ); 1270 getEventViewerDialog()->setSyncMode( false );
1271 qApp->processEvents(); 1271 qApp->processEvents();
1272 if ( syncOK ) { 1272 if ( syncOK ) {
1273 if ( KOPrefs::instance()->mWriteBackFile ) 1273 if ( KOPrefs::instance()->mWriteBackFile )
1274 { 1274 {
1275 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1275 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1276 Incidence* inc = iL.first(); 1276 Incidence* inc = iL.first();
1277 if ( phoneFormat ) { 1277 if ( phoneFormat ) {
1278 while ( inc ) { 1278 while ( inc ) {
1279 inc->removeID(mCurrentSyncDevice); 1279 inc->removeID(mCurrentSyncDevice);
1280 inc = iL.next(); 1280 inc = iL.next();
1281 } 1281 }
1282 } 1282 }
1283#ifndef DESKTOP_VERSION 1283#ifndef DESKTOP_VERSION
1284 if ( sharpFormat ) 1284 if ( sharpFormat )
1285 sharpFormat->save(calendar); 1285 sharpFormat->save(calendar);
1286#endif 1286#endif
1287 if ( phoneFormat ) 1287 if ( phoneFormat )
1288 phoneFormat->save(calendar); 1288 phoneFormat->save(calendar);
1289 iL = calendar->rawIncidences(); 1289 iL = calendar->rawIncidences();
1290 inc = iL.first(); 1290 inc = iL.first();
1291 Incidence* loc; 1291 Incidence* loc;
1292 while ( inc ) { 1292 while ( inc ) {
1293 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1293 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1294 loc = mCalendar->incidence(inc->uid() ); 1294 loc = mCalendar->incidence(inc->uid() );
1295 if ( loc ) { 1295 if ( loc ) {
1296 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1296 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1297 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1297 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1298 } 1298 }
1299 } 1299 }
1300 inc = iL.next(); 1300 inc = iL.next();
1301 } 1301 }
1302 Incidence* lse = getLastSyncEvent(); 1302 Incidence* lse = getLastSyncEvent();
1303 if ( lse ) { 1303 if ( lse ) {
1304 lse->setReadOnly( false ); 1304 lse->setReadOnly( false );
1305 lse->setDescription( "" ); 1305 lse->setDescription( "" );
1306 lse->setReadOnly( true ); 1306 lse->setReadOnly( true );
1307 } 1307 }
1308 } 1308 }
1309 } 1309 }
1310 setModified( true ); 1310 setModified( true );
1311 } else { 1311 } else {
1312 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1312 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1313 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1313 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1314 question, i18n("Ok")) ; 1314 question, i18n("Ok")) ;
1315 1315
1316 } 1316 }
1317 delete calendar; 1317 delete calendar;
1318 updateView(); 1318 updateView();
1319 return ;//syncOK; 1319 return ;//syncOK;
1320 1320
1321} 1321}
1322void CalendarView::syncSharp() 1322void CalendarView::syncSharp()
1323{ 1323{
1324 syncExternal( 0 ); 1324 syncExternal( 0 );
1325 1325
1326} 1326}
1327 1327
1328 1328
1329#include <kabc/stdaddressbook.h> 1329//#include <kabc/stdaddressbook.h>
1330bool CalendarView::importBday() 1330bool CalendarView::importBday()
1331{ 1331{
1332#if 0
1332 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1333 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1333 KABC::AddressBook::Iterator it; 1334 KABC::AddressBook::Iterator it;
1334 int count = 0; 1335 int count = 0;
1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1336 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1336 ++count; 1337 ++count;
1337 } 1338 }
1338 QProgressBar bar(count,0 ); 1339 QProgressBar bar(count,0 );
1339 int w = 300; 1340 int w = 300;
1340 if ( QApplication::desktop()->width() < 320 ) 1341 if ( QApplication::desktop()->width() < 320 )
1341 w = 220; 1342 w = 220;
1342 int h = bar.sizeHint().height() ; 1343 int h = bar.sizeHint().height() ;
1343 int dw = QApplication::desktop()->width(); 1344 int dw = QApplication::desktop()->width();
1344 int dh = QApplication::desktop()->height(); 1345 int dh = QApplication::desktop()->height();
1345 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1346 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1346 bar.show(); 1347 bar.show();
1347 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1348 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1348 qApp->processEvents(); 1349 qApp->processEvents();
1349 count = 0; 1350 count = 0;
1350 int addCount = 0; 1351 int addCount = 0;
1351 KCal::Attendee* a = 0; 1352 KCal::Attendee* a = 0;
1352 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1353 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1353 if ( ! bar.isVisible() ) 1354 if ( ! bar.isVisible() )
1354 return false; 1355 return false;
1355 bar.setProgress( count++ ); 1356 bar.setProgress( count++ );
1356 qApp->processEvents(); 1357 qApp->processEvents();
1357 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1358 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1358 if ( (*it).birthday().date().isValid() ){ 1359 if ( (*it).birthday().date().isValid() ){
1359 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1360 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1360 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1361 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1361 ++addCount; 1362 ++addCount;
1362 } 1363 }
1363 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1364 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1364 if ( anni.isValid() ){ 1365 if ( anni.isValid() ){
1365 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1366 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1367 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1367 ++addCount; 1368 ++addCount;
1368 } 1369 }
1369 } 1370 }
1370 updateView(); 1371 updateView();
1371 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1372 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1373#endif
1372 return true; 1374 return true;
1373} 1375}
1374 1376
1375bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1377bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1376{ 1378{
1377 //qDebug("addAnni "); 1379 //qDebug("addAnni ");
1378 Event * ev = new Event(); 1380 Event * ev = new Event();
1379 if ( a ) { 1381 if ( a ) {
1380 ev->addAttendee( a ); 1382 ev->addAttendee( a );
1381 } 1383 }
1382 QString kind; 1384 QString kind;
1383 if ( birthday ) 1385 if ( birthday )
1384 kind = i18n( "Birthday" ); 1386 kind = i18n( "Birthday" );
1385 else 1387 else
1386 kind = i18n( "Anniversary" ); 1388 kind = i18n( "Anniversary" );
1387 ev->setSummary( name + " - " + kind ); 1389 ev->setSummary( name + " - " + kind );
1388 ev->setOrganizer( "nobody@nowhere" ); 1390 ev->setOrganizer( "nobody@nowhere" );
1389 ev->setCategories( kind ); 1391 ev->setCategories( kind );
1390 ev->setDtStart( QDateTime(date) ); 1392 ev->setDtStart( QDateTime(date) );
1391 ev->setDtEnd( QDateTime(date) ); 1393 ev->setDtEnd( QDateTime(date) );
1392 ev->setFloats( true ); 1394 ev->setFloats( true );
1393 Recurrence * rec = ev->recurrence(); 1395 Recurrence * rec = ev->recurrence();
1394 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1396 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1395 rec->addYearlyNum( date.month() ); 1397 rec->addYearlyNum( date.month() );
1396 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1398 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1397 delete ev; 1399 delete ev;
1398 return false; 1400 return false;
1399 } 1401 }
1400 return true; 1402 return true;
1401 1403
1402} 1404}
1403bool CalendarView::importQtopia( const QString &categories, 1405bool CalendarView::importQtopia( const QString &categories,
1404 const QString &datebook, 1406 const QString &datebook,
1405 const QString &todolist ) 1407 const QString &todolist )
1406{ 1408{
1407 1409
1408 QtopiaFormat qtopiaFormat; 1410 QtopiaFormat qtopiaFormat;
1409 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1411 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1410 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1412 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1411 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1413 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1412 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1414 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1413 1415
1414 updateView(); 1416 updateView();
1415 return true; 1417 return true;
1416 1418
1417#if 0 1419#if 0
1418 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1420 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1419 mCurrentSyncDevice = "qtopia-XML"; 1421 mCurrentSyncDevice = "qtopia-XML";
1420 if ( KOPrefs::instance()->mAskForPreferences ) 1422 if ( KOPrefs::instance()->mAskForPreferences )
1421 edit_sync_options(); 1423 edit_sync_options();
1422 qApp->processEvents(); 1424 qApp->processEvents();
1423 CalendarLocal* calendar = new CalendarLocal(); 1425 CalendarLocal* calendar = new CalendarLocal();
1424 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1426 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1425 bool syncOK = false; 1427 bool syncOK = false;
1426 QtopiaFormat qtopiaFormat; 1428 QtopiaFormat qtopiaFormat;
1427 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1429 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1428 bool loadOk = true; 1430 bool loadOk = true;
1429 if ( !categories.isEmpty() ) 1431 if ( !categories.isEmpty() )
1430 loadOk = qtopiaFormat.load( calendar, categories ); 1432 loadOk = qtopiaFormat.load( calendar, categories );
1431 if ( loadOk && !datebook.isEmpty() ) 1433 if ( loadOk && !datebook.isEmpty() )
1432 loadOk = qtopiaFormat.load( calendar, datebook ); 1434 loadOk = qtopiaFormat.load( calendar, datebook );
1433 if ( loadOk && !todolist.isEmpty() ) 1435 if ( loadOk && !todolist.isEmpty() )
1434 loadOk = qtopiaFormat.load( calendar, todolist ); 1436 loadOk = qtopiaFormat.load( calendar, todolist );
1435 1437
1436 if ( loadOk ) { 1438 if ( loadOk ) {
1437 getEventViewerDialog()->setSyncMode( true ); 1439 getEventViewerDialog()->setSyncMode( true );
1438 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1440 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1439 getEventViewerDialog()->setSyncMode( false ); 1441 getEventViewerDialog()->setSyncMode( false );
1440 qApp->processEvents(); 1442 qApp->processEvents();
1441 if ( syncOK ) { 1443 if ( syncOK ) {
1442 if ( KOPrefs::instance()->mWriteBackFile ) 1444 if ( KOPrefs::instance()->mWriteBackFile )
1443 { 1445 {
1444 // write back XML file 1446 // write back XML file
1445 1447
1446 } 1448 }
1447 setModified( true ); 1449 setModified( true );
1448 } 1450 }
1449 } else { 1451 } else {
1450 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1452 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1451 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1453 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1452 question, i18n("Ok")) ; 1454 question, i18n("Ok")) ;
1453 } 1455 }
1454 delete calendar; 1456 delete calendar;
1455 updateView(); 1457 updateView();
1456 return syncOK; 1458 return syncOK;
1457 1459
1458 1460
1459#endif 1461#endif
1460 1462
1461} 1463}
1462 1464
1463void CalendarView::setSyncEventsReadOnly() 1465void CalendarView::setSyncEventsReadOnly()
1464{ 1466{
1465 Event * ev; 1467 Event * ev;
1466 QPtrList<Event> eL = mCalendar->rawEvents(); 1468 QPtrList<Event> eL = mCalendar->rawEvents();
1467 ev = eL.first(); 1469 ev = eL.first();
1468 while ( ev ) { 1470 while ( ev ) {
1469 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1471 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1470 ev->setReadOnly( true ); 1472 ev->setReadOnly( true );
1471 ev = eL.next(); 1473 ev = eL.next();
1472 } 1474 }
1473} 1475}
1474bool CalendarView::openCalendar(QString filename, bool merge) 1476bool CalendarView::openCalendar(QString filename, bool merge)
1475{ 1477{
1476 1478
1477 if (filename.isEmpty()) { 1479 if (filename.isEmpty()) {
1478 return false; 1480 return false;
1479 } 1481 }
1480 1482
1481 if (!QFile::exists(filename)) { 1483 if (!QFile::exists(filename)) {
1482 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1484 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1483 return false; 1485 return false;
1484 } 1486 }
1485 1487
1486 globalFlagBlockAgenda = 1; 1488 globalFlagBlockAgenda = 1;
1487 if (!merge) mCalendar->close(); 1489 if (!merge) mCalendar->close();
1488 1490
1489 mStorage->setFileName( filename ); 1491 mStorage->setFileName( filename );
1490 1492
1491 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1493 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1492 if ( merge ) ;//setModified( true ); 1494 if ( merge ) ;//setModified( true );
1493 else { 1495 else {
1494 //setModified( true ); 1496 //setModified( true );
1495 mViewManager->setDocumentId( filename ); 1497 mViewManager->setDocumentId( filename );
1496 mDialogManager->setDocumentId( filename ); 1498 mDialogManager->setDocumentId( filename );
1497 mTodoList->setDocumentId( filename ); 1499 mTodoList->setDocumentId( filename );
1498 } 1500 }
1499 globalFlagBlockAgenda = 2; 1501 globalFlagBlockAgenda = 2;
1500 // if ( getLastSyncEvent() ) 1502 // if ( getLastSyncEvent() )
1501 // getLastSyncEvent()->setReadOnly( true ); 1503 // getLastSyncEvent()->setReadOnly( true );
1502 mCalendar->reInitAlarmSettings(); 1504 mCalendar->reInitAlarmSettings();
1503 setSyncEventsReadOnly(); 1505 setSyncEventsReadOnly();
1504 updateUnmanagedViews(); 1506 updateUnmanagedViews();
1505 updateView(); 1507 updateView();
1506 if ( filename != MainWindow::defaultFileName() ) 1508 if ( filename != MainWindow::defaultFileName() )
1507 saveCalendar( MainWindow::defaultFileName() ); 1509 saveCalendar( MainWindow::defaultFileName() );
1508 loadedFileVersion = QDateTime::currentDateTime(); 1510 loadedFileVersion = QDateTime::currentDateTime();
1509 return true; 1511 return true;
1510 } else { 1512 } else {
1511 // while failing to load, the calendar object could 1513 // while failing to load, the calendar object could
1512 // have become partially populated. Clear it out. 1514 // have become partially populated. Clear it out.
1513 if ( !merge ) mCalendar->close(); 1515 if ( !merge ) mCalendar->close();
1514 1516
1515 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1517 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1516 1518
1517 globalFlagBlockAgenda = 2; 1519 globalFlagBlockAgenda = 2;
1518 updateView(); 1520 updateView();
1519 } 1521 }
1520 return false; 1522 return false;
1521} 1523}
1522void CalendarView::setLoadedFileVersion(QDateTime dt) 1524void CalendarView::setLoadedFileVersion(QDateTime dt)
1523{ 1525{
1524 loadedFileVersion = dt; 1526 loadedFileVersion = dt;
1525} 1527}
1526bool CalendarView::checkFileChanged(QString fn) 1528bool CalendarView::checkFileChanged(QString fn)
1527{ 1529{
1528 QFileInfo finf ( fn ); 1530 QFileInfo finf ( fn );
1529 if ( !finf.exists() ) 1531 if ( !finf.exists() )
1530 return true; 1532 return true;
1531 QDateTime dt = finf.lastModified (); 1533 QDateTime dt = finf.lastModified ();
1532 if ( dt <= loadedFileVersion ) 1534 if ( dt <= loadedFileVersion )
1533 return false; 1535 return false;
1534 return true; 1536 return true;
1535 1537
1536} 1538}
1537bool CalendarView::checkFileVersion(QString fn) 1539bool CalendarView::checkFileVersion(QString fn)
1538{ 1540{
1539 QFileInfo finf ( fn ); 1541 QFileInfo finf ( fn );
1540 if ( !finf.exists() ) 1542 if ( !finf.exists() )
1541 return true; 1543 return true;
1542 QDateTime dt = finf.lastModified (); 1544 QDateTime dt = finf.lastModified ();
1543 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1545 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1544 //qDebug("file on disk version %s",dt.toString().latin1()); 1546 //qDebug("file on disk version %s",dt.toString().latin1());
1545 if ( dt <= loadedFileVersion ) 1547 if ( dt <= loadedFileVersion )
1546 return true; 1548 return true;
1547 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1549 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1548 i18n("KO/Pi Warning"),i18n("Overwrite"), 1550 i18n("KO/Pi Warning"),i18n("Overwrite"),
1549 i18n("Sync+save")); 1551 i18n("Sync+save"));
1550 1552
1551 if ( km == KMessageBox::Cancel ) 1553 if ( km == KMessageBox::Cancel )
1552 return false; 1554 return false;
1553 if ( km == KMessageBox::Yes ) 1555 if ( km == KMessageBox::Yes )
1554 return true; 1556 return true;
1555 1557
1556 setSyncDevice("deleteaftersync" ); 1558 setSyncDevice("deleteaftersync" );
1557 KOPrefs::instance()->mAskForPreferences = true; 1559 KOPrefs::instance()->mAskForPreferences = true;
1558 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1560 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1559 KOPrefs::instance()->mWriteBackFile = false; 1561 KOPrefs::instance()->mWriteBackFile = false;
1560 KOPrefs::instance()->mWriteBackExistingOnly = false; 1562 KOPrefs::instance()->mWriteBackExistingOnly = false;
1561 KOPrefs::instance()->mShowSyncSummary = false; 1563 KOPrefs::instance()->mShowSyncSummary = false;
1562 syncCalendar( fn, 3 ); 1564 syncCalendar( fn, 3 );
1563 Event * e = getLastSyncEvent(); 1565 Event * e = getLastSyncEvent();
1564 mCalendar->deleteEvent ( e ); 1566 mCalendar->deleteEvent ( e );
1565 updateView(); 1567 updateView();
1566 return true; 1568 return true;
1567} 1569}
1568 1570
1569bool CalendarView::saveCalendar( QString filename ) 1571bool CalendarView::saveCalendar( QString filename )
1570{ 1572{
1571 1573
1572 // Store back all unsaved data into calendar object 1574 // Store back all unsaved data into calendar object
1573 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1575 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1574 if ( mViewManager->currentView() ) 1576 if ( mViewManager->currentView() )
1575 mViewManager->currentView()->flushView(); 1577 mViewManager->currentView()->flushView();
1576 1578
1577 //mStorage->setFileName( filename ); 1579 //mStorage->setFileName( filename );
1578 1580
1579 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1581 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1580 mStorage->setFileName( filename ); 1582 mStorage->setFileName( filename );
1581 bool success; 1583 bool success;
1582 success = mStorage->save(); 1584 success = mStorage->save();
1583 if ( !success ) { 1585 if ( !success ) {
1584 return false; 1586 return false;
1585 } 1587 }
1586 1588
1587 return true; 1589 return true;
1588} 1590}
1589 1591
1590void CalendarView::closeCalendar() 1592void CalendarView::closeCalendar()
1591{ 1593{
1592 1594
1593 // child windows no longer valid 1595 // child windows no longer valid
1594 emit closingDown(); 1596 emit closingDown();
1595 1597
1596 mCalendar->close(); 1598 mCalendar->close();
1597 setModified(false); 1599 setModified(false);
1598 updateView(); 1600 updateView();
1599} 1601}
1600 1602
1601void CalendarView::archiveCalendar() 1603void CalendarView::archiveCalendar()
1602{ 1604{
1603 mDialogManager->showArchiveDialog(); 1605 mDialogManager->showArchiveDialog();
1604} 1606}
1605 1607
1606 1608
1607void CalendarView::readSettings() 1609void CalendarView::readSettings()
1608{ 1610{
1609 1611
1610 1612
1611 // mViewManager->showAgendaView(); 1613 // mViewManager->showAgendaView();
1612 QString str; 1614 QString str;
1613 //qDebug("CalendarView::readSettings() "); 1615 //qDebug("CalendarView::readSettings() ");
1614 // read settings from the KConfig, supplying reasonable 1616 // read settings from the KConfig, supplying reasonable
1615 // defaults where none are to be found 1617 // defaults where none are to be found
1616 KConfig *config = KOGlobals::config(); 1618 KConfig *config = KOGlobals::config();
1617#ifndef KORG_NOSPLITTER 1619#ifndef KORG_NOSPLITTER
1618 config->setGroup("KOrganizer Geometry"); 1620 config->setGroup("KOrganizer Geometry");
1619 1621
1620 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1622 QValueList<int> sizes = config->readIntListEntry("Separator1");
1621 if (sizes.count() != 2) { 1623 if (sizes.count() != 2) {
1622 sizes << mDateNavigator->minimumSizeHint().width(); 1624 sizes << mDateNavigator->minimumSizeHint().width();
1623 sizes << 300; 1625 sizes << 300;
1624 } 1626 }
1625 mPanner->setSizes(sizes); 1627 mPanner->setSizes(sizes);
1626 1628
1627 sizes = config->readIntListEntry("Separator2"); 1629 sizes = config->readIntListEntry("Separator2");
1628 if ( ( mResourceView && sizes.count() == 4 ) || 1630 if ( ( mResourceView && sizes.count() == 4 ) ||
1629 ( !mResourceView && sizes.count() == 3 ) ) { 1631 ( !mResourceView && sizes.count() == 3 ) ) {
1630 mLeftSplitter->setSizes(sizes); 1632 mLeftSplitter->setSizes(sizes);
1631 } 1633 }
1632#endif 1634#endif
1633 globalFlagBlockAgenda = 1; 1635 globalFlagBlockAgenda = 1;
1634 mViewManager->showAgendaView(); 1636 mViewManager->showAgendaView();
1635 //mViewManager->readSettings( config ); 1637 //mViewManager->readSettings( config );
1636 mTodoList->restoreLayout(config,QString("Todo Layout")); 1638 mTodoList->restoreLayout(config,QString("Todo Layout"));
1637 readFilterSettings(config); 1639 readFilterSettings(config);
1638 config->setGroup( "Views" ); 1640 config->setGroup( "Views" );
1639 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1641 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1640 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1642 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1641 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1643 else if ( dateCount == 7 ) mNavigator->selectWeek();
1642 else mNavigator->selectDates( dateCount ); 1644 else mNavigator->selectDates( dateCount );
1643 // mViewManager->readSettings( config ); 1645 // mViewManager->readSettings( config );
1644 updateConfig(); 1646 updateConfig();
1645 globalFlagBlockAgenda = 2; 1647 globalFlagBlockAgenda = 2;
1646 mViewManager->readSettings( config ); 1648 mViewManager->readSettings( config );
1647#ifdef DESKTOP_VERSION 1649#ifdef DESKTOP_VERSION
1648 config->setGroup("WidgetLayout"); 1650 config->setGroup("WidgetLayout");
1649 QStringList list; 1651 QStringList list;
1650 list = config->readListEntry("MainLayout"); 1652 list = config->readListEntry("MainLayout");
1651 int x,y,w,h; 1653 int x,y,w,h;
1652 if ( ! list.isEmpty() ) { 1654 if ( ! list.isEmpty() ) {
1653 x = list[0].toInt(); 1655 x = list[0].toInt();
1654 y = list[1].toInt(); 1656 y = list[1].toInt();
1655 w = list[2].toInt(); 1657 w = list[2].toInt();
1656 h = list[3].toInt(); 1658 h = list[3].toInt();
1657 topLevelWidget()->setGeometry(x,y,w,h); 1659 topLevelWidget()->setGeometry(x,y,w,h);
1658 1660
1659 } else { 1661 } else {
1660 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1662 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1661 } 1663 }
1662 list = config->readListEntry("EditEventLayout"); 1664 list = config->readListEntry("EditEventLayout");
1663 if ( ! list.isEmpty() ) { 1665 if ( ! list.isEmpty() ) {
1664 x = list[0].toInt(); 1666 x = list[0].toInt();
1665 y = list[1].toInt(); 1667 y = list[1].toInt();
1666 w = list[2].toInt(); 1668 w = list[2].toInt();
1667 h = list[3].toInt(); 1669 h = list[3].toInt();
1668 mEventEditor->setGeometry(x,y,w,h); 1670 mEventEditor->setGeometry(x,y,w,h);
1669 1671
1670 } 1672 }
1671 list = config->readListEntry("EditTodoLayout"); 1673 list = config->readListEntry("EditTodoLayout");
1672 if ( ! list.isEmpty() ) { 1674 if ( ! list.isEmpty() ) {
1673 x = list[0].toInt(); 1675 x = list[0].toInt();
1674 y = list[1].toInt(); 1676 y = list[1].toInt();
1675 w = list[2].toInt(); 1677 w = list[2].toInt();
1676 h = list[3].toInt(); 1678 h = list[3].toInt();
1677 mTodoEditor->setGeometry(x,y,w,h); 1679 mTodoEditor->setGeometry(x,y,w,h);
1678 1680
1679 } 1681 }
1680 list = config->readListEntry("ViewerLayout"); 1682 list = config->readListEntry("ViewerLayout");
1681 if ( ! list.isEmpty() ) { 1683 if ( ! list.isEmpty() ) {
1682 x = list[0].toInt(); 1684 x = list[0].toInt();
1683 y = list[1].toInt(); 1685 y = list[1].toInt();
1684 w = list[2].toInt(); 1686 w = list[2].toInt();
1685 h = list[3].toInt(); 1687 h = list[3].toInt();
1686 getEventViewerDialog()->setGeometry(x,y,w,h); 1688 getEventViewerDialog()->setGeometry(x,y,w,h);
1687 } 1689 }
1688#endif 1690#endif
1689 1691
1690} 1692}
1691 1693
1692 1694
1693void CalendarView::writeSettings() 1695void CalendarView::writeSettings()
1694{ 1696{
1695 // kdDebug() << "CalendarView::writeSettings" << endl; 1697 // kdDebug() << "CalendarView::writeSettings" << endl;
1696 1698
1697 KConfig *config = KOGlobals::config(); 1699 KConfig *config = KOGlobals::config();
1698 1700
1699#ifndef KORG_NOSPLITTER 1701#ifndef KORG_NOSPLITTER
1700 config->setGroup("KOrganizer Geometry"); 1702 config->setGroup("KOrganizer Geometry");
1701 1703
1702 QValueList<int> list = mPanner->sizes(); 1704 QValueList<int> list = mPanner->sizes();
1703 config->writeEntry("Separator1",list); 1705 config->writeEntry("Separator1",list);
1704 1706
1705 list = mLeftSplitter->sizes(); 1707 list = mLeftSplitter->sizes();
1706 config->writeEntry("Separator2",list); 1708 config->writeEntry("Separator2",list);
1707#endif 1709#endif
1708 1710
1709 mViewManager->writeSettings( config ); 1711 mViewManager->writeSettings( config );
1710 mTodoList->saveLayout(config,QString("Todo Layout")); 1712 mTodoList->saveLayout(config,QString("Todo Layout"));
1711 mDialogManager->writeSettings( config ); 1713 mDialogManager->writeSettings( config );
1712 //KOPrefs::instance()->usrWriteConfig(); 1714 //KOPrefs::instance()->usrWriteConfig();
1713 KOPrefs::instance()->writeConfig(); 1715 KOPrefs::instance()->writeConfig();
1714 1716
1715 writeFilterSettings(config); 1717 writeFilterSettings(config);
1716 1718
1717 config->setGroup( "Views" ); 1719 config->setGroup( "Views" );
1718 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1720 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1719 1721
1720#ifdef DESKTOP_VERSION 1722#ifdef DESKTOP_VERSION
1721 config->setGroup("WidgetLayout"); 1723 config->setGroup("WidgetLayout");
1722 QStringList list ;//= config->readListEntry("MainLayout"); 1724 QStringList list ;//= config->readListEntry("MainLayout");
1723 int x,y,w,h; 1725 int x,y,w,h;
1724 QWidget* wid; 1726 QWidget* wid;
1725 wid = topLevelWidget(); 1727 wid = topLevelWidget();
1726 x = wid->geometry().x(); 1728 x = wid->geometry().x();
1727 y = wid->geometry().y(); 1729 y = wid->geometry().y();
1728 w = wid->width(); 1730 w = wid->width();
1729 h = wid->height(); 1731 h = wid->height();
1730 list.clear(); 1732 list.clear();
1731 list << QString::number( x ); 1733 list << QString::number( x );
1732 list << QString::number( y ); 1734 list << QString::number( y );
1733 list << QString::number( w ); 1735 list << QString::number( w );
1734 list << QString::number( h ); 1736 list << QString::number( h );
1735 config->writeEntry("MainLayout",list ); 1737 config->writeEntry("MainLayout",list );
1736 1738
1737 wid = mEventEditor; 1739 wid = mEventEditor;
1738 x = wid->geometry().x(); 1740 x = wid->geometry().x();
1739 y = wid->geometry().y(); 1741 y = wid->geometry().y();
1740 w = wid->width(); 1742 w = wid->width();
1741 h = wid->height(); 1743 h = wid->height();
1742 list.clear(); 1744 list.clear();
1743 list << QString::number( x ); 1745 list << QString::number( x );
1744 list << QString::number( y ); 1746 list << QString::number( y );
1745 list << QString::number( w ); 1747 list << QString::number( w );
1746 list << QString::number( h ); 1748 list << QString::number( h );
1747 config->writeEntry("EditEventLayout",list ); 1749 config->writeEntry("EditEventLayout",list );
1748 1750
1749 wid = mTodoEditor; 1751 wid = mTodoEditor;
1750 x = wid->geometry().x(); 1752 x = wid->geometry().x();
1751 y = wid->geometry().y(); 1753 y = wid->geometry().y();
1752 w = wid->width(); 1754 w = wid->width();
1753 h = wid->height(); 1755 h = wid->height();
1754 list.clear(); 1756 list.clear();
1755 list << QString::number( x ); 1757 list << QString::number( x );
1756 list << QString::number( y ); 1758 list << QString::number( y );
1757 list << QString::number( w ); 1759 list << QString::number( w );
1758 list << QString::number( h ); 1760 list << QString::number( h );
1759 config->writeEntry("EditTodoLayout",list ); 1761 config->writeEntry("EditTodoLayout",list );
1760 wid = getEventViewerDialog(); 1762 wid = getEventViewerDialog();
1761 x = wid->geometry().x(); 1763 x = wid->geometry().x();
1762 y = wid->geometry().y(); 1764 y = wid->geometry().y();
1763 w = wid->width(); 1765 w = wid->width();
1764 h = wid->height(); 1766 h = wid->height();
1765 list.clear(); 1767 list.clear();
1766 list << QString::number( x ); 1768 list << QString::number( x );
1767 list << QString::number( y ); 1769 list << QString::number( y );
1768 list << QString::number( w ); 1770 list << QString::number( w );
1769 list << QString::number( h ); 1771 list << QString::number( h );
1770 config->writeEntry("ViewerLayout",list ); 1772 config->writeEntry("ViewerLayout",list );
1771 wid = mDialogManager->getSearchDialog(); 1773 wid = mDialogManager->getSearchDialog();
1772 if ( wid ) { 1774 if ( wid ) {
1773 x = wid->geometry().x(); 1775 x = wid->geometry().x();
1774 y = wid->geometry().y(); 1776 y = wid->geometry().y();
1775 w = wid->width(); 1777 w = wid->width();
1776 h = wid->height(); 1778 h = wid->height();
1777 list.clear(); 1779 list.clear();
1778 list << QString::number( x ); 1780 list << QString::number( x );
1779 list << QString::number( y ); 1781 list << QString::number( y );
1780 list << QString::number( w ); 1782 list << QString::number( w );
1781 list << QString::number( h ); 1783 list << QString::number( h );
1782 config->writeEntry("SearchLayout",list ); 1784 config->writeEntry("SearchLayout",list );
1783 } 1785 }
1784#endif 1786#endif
1785 1787
1786 1788
1787 config->sync(); 1789 config->sync();
1788} 1790}
1789 1791
1790void CalendarView::readFilterSettings(KConfig *config) 1792void CalendarView::readFilterSettings(KConfig *config)
1791{ 1793{
1792 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1794 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1793 1795
1794 mFilters.clear(); 1796 mFilters.clear();
1795 1797
1796 config->setGroup("General"); 1798 config->setGroup("General");
1797 QStringList filterList = config->readListEntry("CalendarFilters"); 1799 QStringList filterList = config->readListEntry("CalendarFilters");
1798 1800
1799 QStringList::ConstIterator it = filterList.begin(); 1801 QStringList::ConstIterator it = filterList.begin();
1800 QStringList::ConstIterator end = filterList.end(); 1802 QStringList::ConstIterator end = filterList.end();
1801 while(it != end) { 1803 while(it != end) {
1802 // kdDebug() << " filter: " << (*it) << endl; 1804 // kdDebug() << " filter: " << (*it) << endl;
1803 1805
1804 CalFilter *filter; 1806 CalFilter *filter;
1805 filter = new CalFilter(*it); 1807 filter = new CalFilter(*it);
1806 config->setGroup("Filter_" + (*it)); 1808 config->setGroup("Filter_" + (*it));
1807 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1809 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1808 filter->setCriteria(config->readNumEntry("Criteria",0)); 1810 filter->setCriteria(config->readNumEntry("Criteria",0));
1809 filter->setCategoryList(config->readListEntry("CategoryList")); 1811 filter->setCategoryList(config->readListEntry("CategoryList"));
1810 mFilters.append(filter); 1812 mFilters.append(filter);
1811 1813
1812 ++it; 1814 ++it;
1813 } 1815 }
1814 1816
1815 if (mFilters.count() == 0) { 1817 if (mFilters.count() == 0) {
1816 CalFilter *filter = new CalFilter(i18n("Default")); 1818 CalFilter *filter = new CalFilter(i18n("Default"));
1817 mFilters.append(filter); 1819 mFilters.append(filter);
1818 } 1820 }
1819 mFilterView->updateFilters(); 1821 mFilterView->updateFilters();
1820 config->setGroup("FilterView"); 1822 config->setGroup("FilterView");
1821 1823
1822 mFilterView->blockSignals(true); 1824 mFilterView->blockSignals(true);
1823 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1825 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1824 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1826 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1825 mFilterView->blockSignals(false); 1827 mFilterView->blockSignals(false);
1826 // We do it manually to avoid it being done twice by the above calls 1828 // We do it manually to avoid it being done twice by the above calls
1827 updateFilter(); 1829 updateFilter();
1828} 1830}
1829 1831
1830void CalendarView::writeFilterSettings(KConfig *config) 1832void CalendarView::writeFilterSettings(KConfig *config)
1831{ 1833{
1832 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1834 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1833 1835
1834 QStringList filterList; 1836 QStringList filterList;
1835 1837
1836 CalFilter *filter = mFilters.first(); 1838 CalFilter *filter = mFilters.first();
1837 while(filter) { 1839 while(filter) {
1838 // kdDebug() << " fn: " << filter->name() << endl; 1840 // kdDebug() << " fn: " << filter->name() << endl;
1839 filterList << filter->name(); 1841 filterList << filter->name();
1840 config->setGroup("Filter_" + filter->name()); 1842 config->setGroup("Filter_" + filter->name());
1841 config->writeEntry("Criteria",filter->criteria()); 1843 config->writeEntry("Criteria",filter->criteria());
1842 config->writeEntry("CategoryList",filter->categoryList()); 1844 config->writeEntry("CategoryList",filter->categoryList());
1843 filter = mFilters.next(); 1845 filter = mFilters.next();
1844 } 1846 }
1845 config->setGroup("General"); 1847 config->setGroup("General");
1846 config->writeEntry("CalendarFilters",filterList); 1848 config->writeEntry("CalendarFilters",filterList);
1847 1849
1848 config->setGroup("FilterView"); 1850 config->setGroup("FilterView");
1849 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1851 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1850 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1852 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1851} 1853}
1852 1854
1853 1855
1854void CalendarView::goToday() 1856void CalendarView::goToday()
1855{ 1857{
1856 mNavigator->selectToday(); 1858 mNavigator->selectToday();
1857} 1859}
1858 1860
1859void CalendarView::goNext() 1861void CalendarView::goNext()
1860{ 1862{
1861 mNavigator->selectNext(); 1863 mNavigator->selectNext();
1862} 1864}
1863 1865
1864void CalendarView::goPrevious() 1866void CalendarView::goPrevious()
1865{ 1867{
1866 mNavigator->selectPrevious(); 1868 mNavigator->selectPrevious();
1867} 1869}
1868void CalendarView::goNextMonth() 1870void CalendarView::goNextMonth()
1869{ 1871{
1870 mNavigator->selectNextMonth(); 1872 mNavigator->selectNextMonth();
1871} 1873}
1872 1874
1873void CalendarView::goPreviousMonth() 1875void CalendarView::goPreviousMonth()
1874{ 1876{
1875 mNavigator->selectPreviousMonth(); 1877 mNavigator->selectPreviousMonth();
1876} 1878}
1877void CalendarView::writeLocale() 1879void CalendarView::writeLocale()
1878{ 1880{
1879 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1881 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1880 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1882 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1881 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1883 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1882 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1884 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1883 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1885 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1884 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1886 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1885 dummy = KOPrefs::instance()->mUserDateFormatShort; 1887 dummy = KOPrefs::instance()->mUserDateFormatShort;
1886 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1888 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1887 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1889 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1888 KOPrefs::instance()->mDaylightsavingStart, 1890 KOPrefs::instance()->mDaylightsavingStart,
1889 KOPrefs::instance()->mDaylightsavingEnd ); 1891 KOPrefs::instance()->mDaylightsavingEnd );
1890 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1892 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1891} 1893}
1892void CalendarView::updateConfig() 1894void CalendarView::updateConfig()
1893{ 1895{
1894 writeLocale(); 1896 writeLocale();
1895 if ( KOPrefs::instance()->mUseAppColors ) 1897 if ( KOPrefs::instance()->mUseAppColors )
1896 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1898 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1897 emit configChanged(); 1899 emit configChanged();
1898 mTodoList->updateConfig(); 1900 mTodoList->updateConfig();
1899 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1901 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1900 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1902 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1901 // To make the "fill window" configurations work 1903 // To make the "fill window" configurations work
1902 //mViewManager->raiseCurrentView(); 1904 //mViewManager->raiseCurrentView();
1903} 1905}
1904 1906
1905 1907
1906void CalendarView::eventChanged(Event *event) 1908void CalendarView::eventChanged(Event *event)
1907{ 1909{
1908 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1910 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1909 //updateUnmanagedViews(); 1911 //updateUnmanagedViews();
1910} 1912}
1911 1913
1912void CalendarView::eventAdded(Event *event) 1914void CalendarView::eventAdded(Event *event)
1913{ 1915{
1914 changeEventDisplay(event,KOGlobals::EVENTADDED); 1916 changeEventDisplay(event,KOGlobals::EVENTADDED);
1915} 1917}
1916 1918
1917void CalendarView::eventToBeDeleted(Event *) 1919void CalendarView::eventToBeDeleted(Event *)
1918{ 1920{
1919 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1921 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1920} 1922}
1921 1923
1922void CalendarView::eventDeleted() 1924void CalendarView::eventDeleted()
1923{ 1925{
1924 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1926 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1925} 1927}
1926void CalendarView::changeTodoDisplay(Todo *which, int action) 1928void CalendarView::changeTodoDisplay(Todo *which, int action)
1927{ 1929{
1928 changeIncidenceDisplay((Incidence *)which, action); 1930 changeIncidenceDisplay((Incidence *)which, action);
1929 mDateNavigator->updateView(); 1931 mDateNavigator->updateView();
1930 //mDialogManager->updateSearchDialog(); 1932 //mDialogManager->updateSearchDialog();
1931 1933
1932 if (which) { 1934 if (which) {
1933 mViewManager->currentView()->updateView(); 1935 mViewManager->currentView()->updateView();
1934 //mTodoList->updateView(); 1936 //mTodoList->updateView();
1935 } 1937 }
1936 1938
1937} 1939}
1938 1940
1939void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1941void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1940{ 1942{
1941 updateUnmanagedViews(); 1943 updateUnmanagedViews();
1942 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1944 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1943 if ( action == KOGlobals::EVENTDELETED ) { //delete 1945 if ( action == KOGlobals::EVENTDELETED ) { //delete
1944 mCalendar->checkAlarmForIncidence( 0, true ); 1946 mCalendar->checkAlarmForIncidence( 0, true );
1945 if ( mEventViewerDialog ) 1947 if ( mEventViewerDialog )
1946 mEventViewerDialog->hide(); 1948 mEventViewerDialog->hide();
1947 } 1949 }
1948 else 1950 else
1949 mCalendar->checkAlarmForIncidence( which , false ); 1951 mCalendar->checkAlarmForIncidence( which , false );
1950} 1952}
1951 1953
1952// most of the changeEventDisplays() right now just call the view's 1954// most of the changeEventDisplays() right now just call the view's
1953// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1955// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1954void CalendarView::changeEventDisplay(Event *which, int action) 1956void CalendarView::changeEventDisplay(Event *which, int action)
1955{ 1957{
1956 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1958 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1957 changeIncidenceDisplay((Incidence *)which, action); 1959 changeIncidenceDisplay((Incidence *)which, action);
1958 mDateNavigator->updateView(); 1960 mDateNavigator->updateView();
1959 //mDialogManager->updateSearchDialog(); 1961 //mDialogManager->updateSearchDialog();
1960 1962
1961 if (which) { 1963 if (which) {
1962 // If there is an event view visible update the display 1964 // If there is an event view visible update the display
1963 mViewManager->currentView()->changeEventDisplay(which,action); 1965 mViewManager->currentView()->changeEventDisplay(which,action);
1964 // TODO: check, if update needed 1966 // TODO: check, if update needed
1965 // if (which->getTodoStatus()) { 1967 // if (which->getTodoStatus()) {
1966 mTodoList->updateView(); 1968 mTodoList->updateView();
1967 // } 1969 // }
1968 } else { 1970 } else {
1969 mViewManager->currentView()->updateView(); 1971 mViewManager->currentView()->updateView();
1970 } 1972 }
1971} 1973}
1972 1974
1973 1975
1974void CalendarView::updateTodoViews() 1976void CalendarView::updateTodoViews()
1975{ 1977{
1976 1978
1977 mTodoList->updateView(); 1979 mTodoList->updateView();
1978 mViewManager->currentView()->updateView(); 1980 mViewManager->currentView()->updateView();
1979 1981
1980} 1982}
1981 1983
1982 1984
1983void CalendarView::updateView(const QDate &start, const QDate &end) 1985void CalendarView::updateView(const QDate &start, const QDate &end)
1984{ 1986{
1985 mTodoList->updateView(); 1987 mTodoList->updateView();
1986 mViewManager->updateView(start, end); 1988 mViewManager->updateView(start, end);
1987 //mDateNavigator->updateView(); 1989 //mDateNavigator->updateView();
1988} 1990}
1989 1991
1990void CalendarView::updateView() 1992void CalendarView::updateView()
1991{ 1993{
1992 DateList tmpList = mNavigator->selectedDates(); 1994 DateList tmpList = mNavigator->selectedDates();
1993 1995
1994 // We assume that the navigator only selects consecutive days. 1996 // We assume that the navigator only selects consecutive days.
1995 updateView( tmpList.first(), tmpList.last() ); 1997 updateView( tmpList.first(), tmpList.last() );
1996} 1998}
1997 1999
1998void CalendarView::updateUnmanagedViews() 2000void CalendarView::updateUnmanagedViews()
1999{ 2001{
2000 mDateNavigator->updateDayMatrix(); 2002 mDateNavigator->updateDayMatrix();
2001} 2003}
2002 2004
2003int CalendarView::msgItemDelete() 2005int CalendarView::msgItemDelete()
2004{ 2006{
2005 return KMessageBox::warningContinueCancel(this, 2007 return KMessageBox::warningContinueCancel(this,
2006 i18n("This item will be\npermanently deleted."), 2008 i18n("This item will be\npermanently deleted."),
2007 i18n("KO/Pi Confirmation"),i18n("Delete")); 2009 i18n("KO/Pi Confirmation"),i18n("Delete"));
2008} 2010}
2009 2011
2010 2012
2011void CalendarView::edit_cut() 2013void CalendarView::edit_cut()
2012{ 2014{
2013 Event *anEvent=0; 2015 Event *anEvent=0;
2014 2016
2015 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2017 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2016 2018
2017 if (mViewManager->currentView()->isEventView()) { 2019 if (mViewManager->currentView()->isEventView()) {
2018 if ( incidence && incidence->type() == "Event" ) { 2020 if ( incidence && incidence->type() == "Event" ) {
2019 anEvent = static_cast<Event *>(incidence); 2021 anEvent = static_cast<Event *>(incidence);
2020 } 2022 }
2021 } 2023 }
2022 2024
2023 if (!anEvent) { 2025 if (!anEvent) {
2024 KNotifyClient::beep(); 2026 KNotifyClient::beep();
2025 return; 2027 return;
2026 } 2028 }
2027 DndFactory factory( mCalendar ); 2029 DndFactory factory( mCalendar );
2028 factory.cutEvent(anEvent); 2030 factory.cutEvent(anEvent);
2029 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2031 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2030} 2032}
2031 2033
2032void CalendarView::edit_copy() 2034void CalendarView::edit_copy()
2033{ 2035{
2034 Event *anEvent=0; 2036 Event *anEvent=0;
2035 2037
2036 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2038 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2037 2039
2038 if (mViewManager->currentView()->isEventView()) { 2040 if (mViewManager->currentView()->isEventView()) {
2039 if ( incidence && incidence->type() == "Event" ) { 2041 if ( incidence && incidence->type() == "Event" ) {
2040 anEvent = static_cast<Event *>(incidence); 2042 anEvent = static_cast<Event *>(incidence);
2041 } 2043 }
2042 } 2044 }
2043 2045
2044 if (!anEvent) { 2046 if (!anEvent) {
2045 KNotifyClient::beep(); 2047 KNotifyClient::beep();
2046 return; 2048 return;
2047 } 2049 }
2048 DndFactory factory( mCalendar ); 2050 DndFactory factory( mCalendar );
2049 factory.copyEvent(anEvent); 2051 factory.copyEvent(anEvent);
2050} 2052}
2051 2053
2052void CalendarView::edit_paste() 2054void CalendarView::edit_paste()
2053{ 2055{
2054 QDate date = mNavigator->selectedDates().first(); 2056 QDate date = mNavigator->selectedDates().first();
2055 2057
2056 DndFactory factory( mCalendar ); 2058 DndFactory factory( mCalendar );
2057 Event *pastedEvent = factory.pasteEvent( date ); 2059 Event *pastedEvent = factory.pasteEvent( date );
2058 2060
2059 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2061 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2060} 2062}
2061 2063
2062void CalendarView::edit_options() 2064void CalendarView::edit_options()
2063{ 2065{
2064 mDialogManager->showOptionsDialog(); 2066 mDialogManager->showOptionsDialog();
2065 //writeSettings(); 2067 //writeSettings();
2066} 2068}
2067void CalendarView::edit_sync_options() 2069void CalendarView::edit_sync_options()
2068{ 2070{
2069 //mDialogManager->showSyncOptions(); 2071 //mDialogManager->showSyncOptions();
2070 //KOPrefs::instance()->mSyncAlgoPrefs 2072 //KOPrefs::instance()->mSyncAlgoPrefs
2071 QDialog dia( this, "dia", true ); 2073 QDialog dia( this, "dia", true );
2072 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2074 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2073 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2075 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2074 QVBoxLayout lay ( &dia ); 2076 QVBoxLayout lay ( &dia );
2075 lay.setSpacing( 2 ); 2077 lay.setSpacing( 2 );
2076 lay.setMargin( 3 ); 2078 lay.setMargin( 3 );
2077 lay.addWidget(&gr); 2079 lay.addWidget(&gr);
2078 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2080 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2079 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2081 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2080 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2082 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2081 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2083 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2082 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2084 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2083 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2085 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2084 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2086 //QRadioButton both( i18n("Take both on conflict"), &gr );
2085 QPushButton pb ( "OK", &dia); 2087 QPushButton pb ( "OK", &dia);
2086 lay.addWidget( &pb ); 2088 lay.addWidget( &pb );
2087 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2089 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2088 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2090 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2089 case 0: 2091 case 0:
2090 loc.setChecked( true); 2092 loc.setChecked( true);
2091 break; 2093 break;
2092 case 1: 2094 case 1:
2093 rem.setChecked( true ); 2095 rem.setChecked( true );
2094 break; 2096 break;
2095 case 2: 2097 case 2:
2096 newest.setChecked( true); 2098 newest.setChecked( true);
2097 break; 2099 break;
2098 case 3: 2100 case 3:
2099 ask.setChecked( true); 2101 ask.setChecked( true);
2100 break; 2102 break;
2101 case 4: 2103 case 4:
2102 f_loc.setChecked( true); 2104 f_loc.setChecked( true);
2103 break; 2105 break;
2104 case 5: 2106 case 5:
2105 f_rem.setChecked( true); 2107 f_rem.setChecked( true);
2106 break; 2108 break;
2107 case 6: 2109 case 6:
2108 // both.setChecked( true); 2110 // both.setChecked( true);
2109 break; 2111 break;
2110 default: 2112 default:
2111 break; 2113 break;
2112 } 2114 }
2113 if ( dia.exec() ) { 2115 if ( dia.exec() ) {
2114 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2116 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2115 } 2117 }
2116 2118
2117} 2119}
2118 2120
2119void CalendarView::slotSelectPickerDate( QDate d) 2121void CalendarView::slotSelectPickerDate( QDate d)
2120{ 2122{
2121 mDateFrame->hide(); 2123 mDateFrame->hide();
2122 if ( mDatePickerMode == 1 ) { 2124 if ( mDatePickerMode == 1 ) {
2123 mNavigator->slotDaySelect( d ); 2125 mNavigator->slotDaySelect( d );
2124 } else if ( mDatePickerMode == 2 ) { 2126 } else if ( mDatePickerMode == 2 ) {
2125 if ( mMoveIncidence->type() == "Todo" ) { 2127 if ( mMoveIncidence->type() == "Todo" ) {
2126 Todo * to = (Todo *) mMoveIncidence; 2128 Todo * to = (Todo *) mMoveIncidence;
2127 QTime tim; 2129 QTime tim;
2128 if ( to->hasDueDate() ) 2130 if ( to->hasDueDate() )
2129 tim = to->dtDue().time(); 2131 tim = to->dtDue().time();
2130 else { 2132 else {
2131 tim = QTime ( 0,0,0 ); 2133 tim = QTime ( 0,0,0 );
2132 to->setFloats( true ); 2134 to->setFloats( true );
2133 to->setHasDueDate( true ); 2135 to->setHasDueDate( true );
2134 } 2136 }
2135 QDateTime dt ( d,tim ); 2137 QDateTime dt ( d,tim );
2136 to->setDtDue( dt ); 2138 to->setDtDue( dt );
2137 todoChanged( to ); 2139 todoChanged( to );
2138 } else { 2140 } else {
2139 QTime tim = mMoveIncidence->dtStart().time(); 2141 QTime tim = mMoveIncidence->dtStart().time();
2140 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2142 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2141 QDateTime dt ( d,tim ); 2143 QDateTime dt ( d,tim );
2142 mMoveIncidence->setDtStart( dt ); 2144 mMoveIncidence->setDtStart( dt );
2143 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2145 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2144 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2146 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2145 } 2147 }
2146 2148
2147 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2149 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2148 } 2150 }
2149} 2151}
2150 2152
2151void CalendarView::removeCategories() 2153void CalendarView::removeCategories()
2152{ 2154{
2153 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2155 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2154 QStringList catList = KOPrefs::instance()->mCustomCategories; 2156 QStringList catList = KOPrefs::instance()->mCustomCategories;
2155 QStringList catIncList; 2157 QStringList catIncList;
2156 QStringList newCatList; 2158 QStringList newCatList;
2157 Incidence* inc = incList.first(); 2159 Incidence* inc = incList.first();
2158 int i; 2160 int i;
2159 int count = 0; 2161 int count = 0;
2160 while ( inc ) { 2162 while ( inc ) {
2161 newCatList.clear(); 2163 newCatList.clear();
2162 catIncList = inc->categories() ; 2164 catIncList = inc->categories() ;
2163 for( i = 0; i< catIncList.count(); ++i ) { 2165 for( i = 0; i< catIncList.count(); ++i ) {
2164 if ( catList.contains (catIncList[i])) 2166 if ( catList.contains (catIncList[i]))
2165 newCatList.append( catIncList[i] ); 2167 newCatList.append( catIncList[i] );
2166 } 2168 }
2167 newCatList.sort(); 2169 newCatList.sort();
2168 inc->setCategories( newCatList.join(",") ); 2170 inc->setCategories( newCatList.join(",") );
2169 inc = incList.next(); 2171 inc = incList.next();
2170 } 2172 }
2171} 2173}
2172 2174
2173int CalendarView::addCategories() 2175int CalendarView::addCategories()
2174{ 2176{
2175 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2177 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2176 QStringList catList = KOPrefs::instance()->mCustomCategories; 2178 QStringList catList = KOPrefs::instance()->mCustomCategories;
2177 QStringList catIncList; 2179 QStringList catIncList;
2178 Incidence* inc = incList.first(); 2180 Incidence* inc = incList.first();
2179 int i; 2181 int i;
2180 int count = 0; 2182 int count = 0;
2181 while ( inc ) { 2183 while ( inc ) {
2182 catIncList = inc->categories() ; 2184 catIncList = inc->categories() ;
2183 for( i = 0; i< catIncList.count(); ++i ) { 2185 for( i = 0; i< catIncList.count(); ++i ) {
2184 if ( !catList.contains (catIncList[i])) { 2186 if ( !catList.contains (catIncList[i])) {
2185 catList.append( catIncList[i] ); 2187 catList.append( catIncList[i] );
2186 //qDebug("add cat %s ", catIncList[i].latin1()); 2188 //qDebug("add cat %s ", catIncList[i].latin1());
2187 ++count; 2189 ++count;
2188 } 2190 }
2189 } 2191 }
2190 inc = incList.next(); 2192 inc = incList.next();
2191 } 2193 }
2192 catList.sort(); 2194 catList.sort();
2193 KOPrefs::instance()->mCustomCategories = catList; 2195 KOPrefs::instance()->mCustomCategories = catList;
2194 return count; 2196 return count;
2195} 2197}
2196 2198
2197void CalendarView::manageCategories() 2199void CalendarView::manageCategories()
2198{ 2200{
2199 KOCatPrefs* cp = new KOCatPrefs(); 2201 KOCatPrefs* cp = new KOCatPrefs();
2200 cp->show(); 2202 cp->show();
2201 int w =cp->sizeHint().width() ; 2203 int w =cp->sizeHint().width() ;
2202 int h = cp->sizeHint().height() ; 2204 int h = cp->sizeHint().height() ;
2203 int dw = QApplication::desktop()->width(); 2205 int dw = QApplication::desktop()->width();
2204 int dh = QApplication::desktop()->height(); 2206 int dh = QApplication::desktop()->height();
2205 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2207 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2206 if ( !cp->exec() ) { 2208 if ( !cp->exec() ) {
2207 delete cp; 2209 delete cp;
2208 return; 2210 return;
2209 } 2211 }
2210 int count = 0; 2212 int count = 0;
2211 if ( cp->addCat() ) { 2213 if ( cp->addCat() ) {
2212 count = addCategories(); 2214 count = addCategories();
2213 if ( count ) { 2215 if ( count ) {
2214 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2216 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2215 writeSettings(); 2217 writeSettings();
2216 } 2218 }
2217 } else { 2219 } else {
2218 removeCategories(); 2220 removeCategories();
2219 updateView(); 2221 updateView();
2220 } 2222 }
2221 delete cp; 2223 delete cp;
2222} 2224}
2223 2225
2224void CalendarView::beamIncidence(Incidence * Inc) 2226void CalendarView::beamIncidence(Incidence * Inc)
2225{ 2227{
2226 QPtrList<Incidence> delSel ; 2228 QPtrList<Incidence> delSel ;
2227 delSel.append(Inc); 2229 delSel.append(Inc);
2228 beamIncidenceList( delSel ); 2230 beamIncidenceList( delSel );
2229} 2231}
2230void CalendarView::beamCalendar() 2232void CalendarView::beamCalendar()
2231{ 2233{
2232 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2234 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2233 //qDebug("beamCalendar() "); 2235 //qDebug("beamCalendar() ");
2234 beamIncidenceList( delSel ); 2236 beamIncidenceList( delSel );
2235} 2237}
2236void CalendarView::beamFilteredCalendar() 2238void CalendarView::beamFilteredCalendar()
2237{ 2239{
2238 QPtrList<Incidence> delSel = mCalendar->incidences(); 2240 QPtrList<Incidence> delSel = mCalendar->incidences();
2239 //qDebug("beamFilteredCalendar() "); 2241 //qDebug("beamFilteredCalendar() ");
2240 beamIncidenceList( delSel ); 2242 beamIncidenceList( delSel );
2241} 2243}
2242void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2244void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2243{ 2245{
2244 if ( beamDialog->exec () == QDialog::Rejected ) 2246 if ( beamDialog->exec () == QDialog::Rejected )
2245 return; 2247 return;
2246 2248
2247 QString fn = "/tmp/kopibeamfile"; 2249 QString fn = "/tmp/kopibeamfile";
2248 QString mes; 2250 QString mes;
2249 bool createbup = true; 2251 bool createbup = true;
2250 if ( createbup ) { 2252 if ( createbup ) {
2251 QString description = "\n"; 2253 QString description = "\n";
2252 CalendarLocal* cal = new CalendarLocal(); 2254 CalendarLocal* cal = new CalendarLocal();
2253 if ( beamDialog->beamLocal() ) 2255 if ( beamDialog->beamLocal() )
2254 cal->setLocalTime(); 2256 cal->setLocalTime();
2255 else 2257 else
2256 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2258 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2257 Incidence *incidence = delSel.first(); 2259 Incidence *incidence = delSel.first();
2258 bool addText = false; 2260 bool addText = false;
2259 if ( delSel.count() < 10 ) 2261 if ( delSel.count() < 10 )
2260 addText = true; 2262 addText = true;
2261 else { 2263 else {
2262 description.sprintf(i18n(" %d items?"),delSel.count() ); 2264 description.sprintf(i18n(" %d items?"),delSel.count() );
2263 } 2265 }
2264 while ( incidence ) { 2266 while ( incidence ) {
2265 Incidence *in = incidence->clone(); 2267 Incidence *in = incidence->clone();
2266 if ( addText ) 2268 if ( addText )
2267 description += in->summary() + "\n"; 2269 description += in->summary() + "\n";
2268 cal->addIncidence( in ); 2270 cal->addIncidence( in );
2269 incidence = delSel.next(); 2271 incidence = delSel.next();
2270 } 2272 }
2271 if ( beamDialog->beamVcal() ) { 2273 if ( beamDialog->beamVcal() ) {
2272 fn += ".vcs"; 2274 fn += ".vcs";
2273 FileStorage storage( cal, fn, new VCalFormat ); 2275 FileStorage storage( cal, fn, new VCalFormat );
2274 storage.save(); 2276 storage.save();
2275 } else { 2277 } else {
2276 fn += ".ics"; 2278 fn += ".ics";
2277 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2279 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2278 storage.save(); 2280 storage.save();
2279 } 2281 }
2280 delete cal; 2282 delete cal;
2281 mes = i18n("KO/Pi: Ready for beaming"); 2283 mes = i18n("KO/Pi: Ready for beaming");
2282 setCaption(mes); 2284 setCaption(mes);
2283 2285
2284#ifndef DESKTOP_VERSION 2286#ifndef DESKTOP_VERSION
2285 Ir *ir = new Ir( this ); 2287 Ir *ir = new Ir( this );
2286 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2288 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2287 ir->send( fn, description, "text/x-vCalendar" ); 2289 ir->send( fn, description, "text/x-vCalendar" );
2288#endif 2290#endif
2289 } 2291 }
2290} 2292}
2291void CalendarView::beamDone( Ir *ir ) 2293void CalendarView::beamDone( Ir *ir )
2292{ 2294{
2293#ifndef DESKTOP_VERSION 2295#ifndef DESKTOP_VERSION
2294 delete ir; 2296 delete ir;
2295#endif 2297#endif
2296} 2298}
2297 2299
2298void CalendarView::moveIncidence(Incidence * inc ) 2300void CalendarView::moveIncidence(Incidence * inc )
2299{ 2301{
2300 if ( !inc ) return; 2302 if ( !inc ) return;
2301 // qDebug("showDatePickerForIncidence( ) "); 2303 // qDebug("showDatePickerForIncidence( ) ");
2302 if ( mDateFrame->isVisible() ) 2304 if ( mDateFrame->isVisible() )
2303 mDateFrame->hide(); 2305 mDateFrame->hide();
2304 else { 2306 else {
2305 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2307 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2306 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2308 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2307 int dw = QApplication::desktop()->width(); 2309 int dw = QApplication::desktop()->width();
2308 int dh = QApplication::desktop()->height(); 2310 int dh = QApplication::desktop()->height();
2309 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2311 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2310 mDateFrame->show(); 2312 mDateFrame->show();
2311 } 2313 }
2312 mDatePickerMode = 2; 2314 mDatePickerMode = 2;
2313 mMoveIncidence = inc ; 2315 mMoveIncidence = inc ;
2314 QDate da; 2316 QDate da;
2315 if ( mMoveIncidence->type() == "Todo" ) { 2317 if ( mMoveIncidence->type() == "Todo" ) {
2316 Todo * to = (Todo *) mMoveIncidence; 2318 Todo * to = (Todo *) mMoveIncidence;
2317 if ( to->hasDueDate() ) 2319 if ( to->hasDueDate() )
2318 da = to->dtDue().date(); 2320 da = to->dtDue().date();
2319 else 2321 else
2320 da = QDate::currentDate(); 2322 da = QDate::currentDate();
2321 } else { 2323 } else {
2322 da = mMoveIncidence->dtStart().date(); 2324 da = mMoveIncidence->dtStart().date();
2323 } 2325 }
2324 mDatePicker->setDate( da ); 2326 mDatePicker->setDate( da );
2325} 2327}
2326void CalendarView::showDatePicker( ) 2328void CalendarView::showDatePicker( )
2327{ 2329{
2328 //qDebug("CalendarView::showDatePicker( ) "); 2330 //qDebug("CalendarView::showDatePicker( ) ");
2329 if ( mDateFrame->isVisible() ) 2331 if ( mDateFrame->isVisible() )
2330 mDateFrame->hide(); 2332 mDateFrame->hide();
2331 else { 2333 else {
2332 int w =mDatePicker->sizeHint().width() ; 2334 int w =mDatePicker->sizeHint().width() ;
2333 int h = mDatePicker->sizeHint().height() ; 2335 int h = mDatePicker->sizeHint().height() ;
2334 int dw = QApplication::desktop()->width(); 2336 int dw = QApplication::desktop()->width();
2335 int dh = QApplication::desktop()->height(); 2337 int dh = QApplication::desktop()->height();
2336 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2338 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2337 mDateFrame->show(); 2339 mDateFrame->show();
2338 } 2340 }
2339 mDatePickerMode = 1; 2341 mDatePickerMode = 1;
2340 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2342 mDatePicker->setDate( mNavigator->selectedDates().first() );
2341} 2343}
2342 2344
2343void CalendarView::showEventEditor() 2345void CalendarView::showEventEditor()
2344{ 2346{
2345#ifdef DESKTOP_VERSION 2347#ifdef DESKTOP_VERSION
2346 mEventEditor->show(); 2348 mEventEditor->show();
2347#else 2349#else
2348 mEventEditor->showMaximized(); 2350 mEventEditor->showMaximized();
2349#endif 2351#endif
2350} 2352}
2351void CalendarView::showTodoEditor() 2353void CalendarView::showTodoEditor()
2352{ 2354{
2353#ifdef DESKTOP_VERSION 2355#ifdef DESKTOP_VERSION
2354 mTodoEditor->show(); 2356 mTodoEditor->show();
2355#else 2357#else
2356 mTodoEditor->showMaximized(); 2358 mTodoEditor->showMaximized();
2357#endif 2359#endif
2358} 2360}
2359void CalendarView::cancelIncidence(Incidence * inc ) 2361void CalendarView::cancelIncidence(Incidence * inc )
2360{ 2362{
2361 inc->setCancelled( ! inc->cancelled() ); 2363 inc->setCancelled( ! inc->cancelled() );
2362 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2364 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2363 updateView(); 2365 updateView();
2364} 2366}
2365void CalendarView::cloneIncidence(Incidence * orgInc ) 2367void CalendarView::cloneIncidence(Incidence * orgInc )
2366{ 2368{
2367 Incidence * newInc = orgInc->clone(); 2369 Incidence * newInc = orgInc->clone();
2368 newInc->recreate(); 2370 newInc->recreate();
2369 2371
2370 if ( newInc->type() == "Todo" ) { 2372 if ( newInc->type() == "Todo" ) {
2371 Todo* t = (Todo*) newInc; 2373 Todo* t = (Todo*) newInc;
2372 mTodoEditor->editTodo( t ); 2374 mTodoEditor->editTodo( t );
2373 showTodoEditor(); 2375 showTodoEditor();
2374 if ( mTodoEditor->exec() ) { 2376 if ( mTodoEditor->exec() ) {
2375 mCalendar->addTodo( t ); 2377 mCalendar->addTodo( t );
2376 updateView(); 2378 updateView();
2377 } else { 2379 } else {
2378 delete t; 2380 delete t;
2379 } 2381 }
2380 } 2382 }
2381 else { 2383 else {
2382 Event* e = (Event*) newInc; 2384 Event* e = (Event*) newInc;
2383 mEventEditor->editEvent( e ); 2385 mEventEditor->editEvent( e );
2384 showEventEditor(); 2386 showEventEditor();
2385 if ( mEventEditor->exec() ) { 2387 if ( mEventEditor->exec() ) {
2386 mCalendar->addEvent( e ); 2388 mCalendar->addEvent( e );
2387 updateView(); 2389 updateView();
2388 } else { 2390 } else {
2389 delete e; 2391 delete e;
2390 } 2392 }
2391 } 2393 }
2392} 2394}
2393 2395
2394void CalendarView::newEvent() 2396void CalendarView::newEvent()
2395{ 2397{
2396 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2398 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2397 KOAgendaView *aView = mViewManager->agendaView(); 2399 KOAgendaView *aView = mViewManager->agendaView();
2398 if (aView) { 2400 if (aView) {
2399 if (aView->selectionStart().isValid()) { 2401 if (aView->selectionStart().isValid()) {
2400 if (aView->selectedIsAllDay()) { 2402 if (aView->selectedIsAllDay()) {
2401 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2403 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2402 } else { 2404 } else {
2403 newEvent(aView->selectionStart(),aView->selectionEnd()); 2405 newEvent(aView->selectionStart(),aView->selectionEnd());
2404 } 2406 }
2405 return; 2407 return;
2406 } 2408 }
2407 } 2409 }
2408 2410
2409 QDate date = mNavigator->selectedDates().first(); 2411 QDate date = mNavigator->selectedDates().first();
2410 QDateTime current = QDateTime::currentDateTime(); 2412 QDateTime current = QDateTime::currentDateTime();
2411 if ( date <= current.date() ) { 2413 if ( date <= current.date() ) {
2412 int hour = current.time().hour() +1; 2414 int hour = current.time().hour() +1;
2413 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2415 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2414 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2416 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2415 } else 2417 } else
2416 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2418 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2417 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2419 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2418 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2420 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2419} 2421}
2420 2422
2421void CalendarView::newEvent(QDateTime fh) 2423void CalendarView::newEvent(QDateTime fh)
2422{ 2424{
2423 newEvent(fh, 2425 newEvent(fh,
2424 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2426 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2425} 2427}
2426 2428
2427void CalendarView::newEvent(QDate dt) 2429void CalendarView::newEvent(QDate dt)
2428{ 2430{
2429 newEvent(QDateTime(dt, QTime(0,0,0)), 2431 newEvent(QDateTime(dt, QTime(0,0,0)),
2430 QDateTime(dt, QTime(0,0,0)), true); 2432 QDateTime(dt, QTime(0,0,0)), true);
2431} 2433}
2432 2434
2433void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2435void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2434{ 2436{
2435 2437
2436 mEventEditor->newEvent(fromHint,toHint,allDay); 2438 mEventEditor->newEvent(fromHint,toHint,allDay);
2437 if ( mFilterView->filtersEnabled() ) { 2439 if ( mFilterView->filtersEnabled() ) {
2438 CalFilter *filter = mFilterView->selectedFilter(); 2440 CalFilter *filter = mFilterView->selectedFilter();
2439 if (filter && filter->showCategories()) { 2441 if (filter && filter->showCategories()) {
2440 mEventEditor->setCategories(filter->categoryList().join(",") ); 2442 mEventEditor->setCategories(filter->categoryList().join(",") );
2441 } 2443 }
2442 if ( filter ) 2444 if ( filter )
2443 mEventEditor->setSecrecy( filter->getSecrecy() ); 2445 mEventEditor->setSecrecy( filter->getSecrecy() );
2444 } 2446 }
2445 showEventEditor(); 2447 showEventEditor();
2446} 2448}
2447void CalendarView::todoAdded(Todo * t) 2449void CalendarView::todoAdded(Todo * t)
2448{ 2450{
2449 2451
2450 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2452 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2451 updateTodoViews(); 2453 updateTodoViews();
2452} 2454}
2453void CalendarView::todoChanged(Todo * t) 2455void CalendarView::todoChanged(Todo * t)
2454{ 2456{
2455 emit todoModified( t, 4 ); 2457 emit todoModified( t, 4 );
2456 // updateTodoViews(); 2458 // updateTodoViews();
2457} 2459}
2458void CalendarView::todoToBeDeleted(Todo *) 2460void CalendarView::todoToBeDeleted(Todo *)
2459{ 2461{
2460 //qDebug("todoToBeDeleted(Todo *) "); 2462 //qDebug("todoToBeDeleted(Todo *) ");
2461 updateTodoViews(); 2463 updateTodoViews();
2462} 2464}
2463void CalendarView::todoDeleted() 2465void CalendarView::todoDeleted()
2464{ 2466{
2465 //qDebug(" todoDeleted()"); 2467 //qDebug(" todoDeleted()");
2466 updateTodoViews(); 2468 updateTodoViews();
2467} 2469}
2468 2470
2469 2471
2470 2472
2471void CalendarView::newTodo() 2473void CalendarView::newTodo()
2472{ 2474{
2473 2475
2474 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2476 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2475 if ( mFilterView->filtersEnabled() ) { 2477 if ( mFilterView->filtersEnabled() ) {
2476 CalFilter *filter = mFilterView->selectedFilter(); 2478 CalFilter *filter = mFilterView->selectedFilter();
2477 if (filter && filter->showCategories()) { 2479 if (filter && filter->showCategories()) {
2478 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2480 mTodoEditor->setCategories(filter->categoryList().join(",") );
2479 } 2481 }
2480 if ( filter ) 2482 if ( filter )
2481 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2483 mTodoEditor->setSecrecy( filter->getSecrecy() );
2482 } 2484 }
2483 showTodoEditor(); 2485 showTodoEditor();
2484} 2486}
2485 2487
2486void CalendarView::newSubTodo() 2488void CalendarView::newSubTodo()
2487{ 2489{
2488 Todo *todo = selectedTodo(); 2490 Todo *todo = selectedTodo();
2489 if ( todo ) newSubTodo( todo ); 2491 if ( todo ) newSubTodo( todo );
2490} 2492}
2491 2493
2492void CalendarView::newSubTodo(Todo *parentEvent) 2494void CalendarView::newSubTodo(Todo *parentEvent)
2493{ 2495{
2494 2496
2495 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2497 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2496 showTodoEditor(); 2498 showTodoEditor();
2497} 2499}
2498 2500
2499void CalendarView::newFloatingEvent() 2501void CalendarView::newFloatingEvent()
2500{ 2502{
2501 DateList tmpList = mNavigator->selectedDates(); 2503 DateList tmpList = mNavigator->selectedDates();
2502 QDate date = tmpList.first(); 2504 QDate date = tmpList.first();
2503 2505
2504 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2506 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2505 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2507 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2506} 2508}
2507 2509
2508 2510
2509void CalendarView::editEvent( Event *event ) 2511void CalendarView::editEvent( Event *event )
2510{ 2512{
2511 2513
2512 if ( !event ) return; 2514 if ( !event ) return;
2513 if ( event->isReadOnly() ) { 2515 if ( event->isReadOnly() ) {
2514 showEvent( event ); 2516 showEvent( event );
2515 return; 2517 return;
2516 } 2518 }
2517 mEventEditor->editEvent( event , mFlagEditDescription); 2519 mEventEditor->editEvent( event , mFlagEditDescription);
2518 showEventEditor(); 2520 showEventEditor();
2519} 2521}
2520void CalendarView::editJournal( Journal *jour ) 2522void CalendarView::editJournal( Journal *jour )
2521{ 2523{
2522 if ( !jour ) return; 2524 if ( !jour ) return;
2523 mDialogManager->hideSearchDialog(); 2525 mDialogManager->hideSearchDialog();
2524 mViewManager->showJournalView(); 2526 mViewManager->showJournalView();
2525 mNavigator->slotDaySelect( jour->dtStart().date() ); 2527 mNavigator->slotDaySelect( jour->dtStart().date() );
2526} 2528}
2527void CalendarView::editTodo( Todo *todo ) 2529void CalendarView::editTodo( Todo *todo )
2528{ 2530{
2529 if ( !todo ) return; 2531 if ( !todo ) return;
2530 2532
2531 if ( todo->isReadOnly() ) { 2533 if ( todo->isReadOnly() ) {
2532 showTodo( todo ); 2534 showTodo( todo );
2533 return; 2535 return;
2534 } 2536 }
2535 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2537 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2536 showTodoEditor(); 2538 showTodoEditor();
2537 2539
2538} 2540}
2539 2541
2540KOEventViewerDialog* CalendarView::getEventViewerDialog() 2542KOEventViewerDialog* CalendarView::getEventViewerDialog()
2541{ 2543{
2542 if ( !mEventViewerDialog ) { 2544 if ( !mEventViewerDialog ) {
2543 mEventViewerDialog = new KOEventViewerDialog(this); 2545 mEventViewerDialog = new KOEventViewerDialog(this);
2544 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2546 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2545 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2547 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2546 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2548 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2547 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2549 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2548 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2550 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2549 viewManager(), SLOT( showAgendaView( bool ) ) ); 2551 viewManager(), SLOT( showAgendaView( bool ) ) );
2550 mEventViewerDialog->resize( 640, 480 ); 2552 mEventViewerDialog->resize( 640, 480 );
2551 2553
2552 } 2554 }
2553 return mEventViewerDialog; 2555 return mEventViewerDialog;
2554} 2556}
2555void CalendarView::showEvent(Event *event) 2557void CalendarView::showEvent(Event *event)
2556{ 2558{
2557 getEventViewerDialog()->setEvent(event); 2559 getEventViewerDialog()->setEvent(event);
2558 getEventViewerDialog()->showMe(); 2560 getEventViewerDialog()->showMe();
2559} 2561}
2560 2562
2561void CalendarView::showTodo(Todo *event) 2563void CalendarView::showTodo(Todo *event)
2562{ 2564{
2563 getEventViewerDialog()->setTodo(event); 2565 getEventViewerDialog()->setTodo(event);
2564 getEventViewerDialog()->showMe(); 2566 getEventViewerDialog()->showMe();
2565} 2567}
2566void CalendarView::showJournal( Journal *jour ) 2568void CalendarView::showJournal( Journal *jour )
2567{ 2569{
2568 getEventViewerDialog()->setJournal(jour); 2570 getEventViewerDialog()->setJournal(jour);
2569 getEventViewerDialog()->showMe(); 2571 getEventViewerDialog()->showMe();
2570 2572
2571} 2573}
2572// void CalendarView::todoModified (Todo *event, int changed) 2574// void CalendarView::todoModified (Todo *event, int changed)
2573// { 2575// {
2574// // if (mDialogList.find (event) != mDialogList.end ()) { 2576// // if (mDialogList.find (event) != mDialogList.end ()) {
2575// // kdDebug() << "Todo modified and open" << endl; 2577// // kdDebug() << "Todo modified and open" << endl;
2576// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2578// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2577// // temp->modified (changed); 2579// // temp->modified (changed);
2578 2580
2579// // } 2581// // }
2580 2582
2581// mViewManager->updateView(); 2583// mViewManager->updateView();
2582// } 2584// }
2583 2585
2584void CalendarView::appointment_show() 2586void CalendarView::appointment_show()
2585{ 2587{
2586 Event *anEvent = 0; 2588 Event *anEvent = 0;
2587 2589
2588 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2590 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2589 2591
2590 if (mViewManager->currentView()->isEventView()) { 2592 if (mViewManager->currentView()->isEventView()) {
2591 if ( incidence && incidence->type() == "Event" ) { 2593 if ( incidence && incidence->type() == "Event" ) {
2592 anEvent = static_cast<Event *>(incidence); 2594 anEvent = static_cast<Event *>(incidence);
2593 } 2595 }
2594 } 2596 }
2595 2597
2596 if (!anEvent) { 2598 if (!anEvent) {
2597 KNotifyClient::beep(); 2599 KNotifyClient::beep();
2598 return; 2600 return;
2599 } 2601 }
2600 2602
2601 showEvent(anEvent); 2603 showEvent(anEvent);
2602} 2604}
2603 2605
2604void CalendarView::appointment_edit() 2606void CalendarView::appointment_edit()
2605{ 2607{
2606 Event *anEvent = 0; 2608 Event *anEvent = 0;
2607 2609
2608 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2610 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2609 2611
2610 if (mViewManager->currentView()->isEventView()) { 2612 if (mViewManager->currentView()->isEventView()) {
2611 if ( incidence && incidence->type() == "Event" ) { 2613 if ( incidence && incidence->type() == "Event" ) {
2612 anEvent = static_cast<Event *>(incidence); 2614 anEvent = static_cast<Event *>(incidence);
2613 } 2615 }
2614 } 2616 }
2615 2617
2616 if (!anEvent) { 2618 if (!anEvent) {
2617 KNotifyClient::beep(); 2619 KNotifyClient::beep();
2618 return; 2620 return;
2619 } 2621 }
2620 2622
2621 editEvent(anEvent); 2623 editEvent(anEvent);
2622} 2624}
2623 2625
2624void CalendarView::appointment_delete() 2626void CalendarView::appointment_delete()
2625{ 2627{
2626 Event *anEvent = 0; 2628 Event *anEvent = 0;
2627 2629
2628 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2630 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2629 2631
2630 if (mViewManager->currentView()->isEventView()) { 2632 if (mViewManager->currentView()->isEventView()) {
2631 if ( incidence && incidence->type() == "Event" ) { 2633 if ( incidence && incidence->type() == "Event" ) {
2632 anEvent = static_cast<Event *>(incidence); 2634 anEvent = static_cast<Event *>(incidence);
2633 } 2635 }
2634 } 2636 }
2635 2637
2636 if (!anEvent) { 2638 if (!anEvent) {
2637 KNotifyClient::beep(); 2639 KNotifyClient::beep();
2638 return; 2640 return;
2639 } 2641 }
2640 2642
2641 deleteEvent(anEvent); 2643 deleteEvent(anEvent);
2642} 2644}
2643 2645
2644void CalendarView::todo_unsub(Todo *anTodo ) 2646void CalendarView::todo_unsub(Todo *anTodo )
2645{ 2647{
2646 // Todo *anTodo = selectedTodo(); 2648 // Todo *anTodo = selectedTodo();
2647 if (!anTodo) return; 2649 if (!anTodo) return;
2648 if (!anTodo->relatedTo()) return; 2650 if (!anTodo->relatedTo()) return;
2649 anTodo->relatedTo()->removeRelation(anTodo); 2651 anTodo->relatedTo()->removeRelation(anTodo);
2650 anTodo->setRelatedTo(0); 2652 anTodo->setRelatedTo(0);
2651 anTodo->updated(); 2653 anTodo->updated();
2652 anTodo->setRelatedToUid(""); 2654 anTodo->setRelatedToUid("");
2653 setModified(true); 2655 setModified(true);
2654 updateView(); 2656 updateView();
2655} 2657}
2656 2658
2657void CalendarView::deleteTodo(Todo *todo) 2659void CalendarView::deleteTodo(Todo *todo)
2658{ 2660{
2659 if (!todo) { 2661 if (!todo) {
2660 KNotifyClient::beep(); 2662 KNotifyClient::beep();
2661 return; 2663 return;
2662 } 2664 }
2663 if (KOPrefs::instance()->mConfirm) { 2665 if (KOPrefs::instance()->mConfirm) {
2664 switch (msgItemDelete()) { 2666 switch (msgItemDelete()) {
2665 case KMessageBox::Continue: // OK 2667 case KMessageBox::Continue: // OK
2666 if (!todo->relations().isEmpty()) { 2668 if (!todo->relations().isEmpty()) {
2667 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2669 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2668 i18n("Delete To-Do")); 2670 i18n("Delete To-Do"));
2669 } else { 2671 } else {
2670 checkExternalId( todo ); 2672 checkExternalId( todo );
2671 calendar()->deleteTodo(todo); 2673 calendar()->deleteTodo(todo);
2672 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2674 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2673 updateView(); 2675 updateView();
2674 } 2676 }
2675 break; 2677 break;
2676 } // switch 2678 } // switch
2677 } else { 2679 } else {
2678 if (!todo->relations().isEmpty()) { 2680 if (!todo->relations().isEmpty()) {
2679 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2681 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2680 i18n("Delete To-Do")); 2682 i18n("Delete To-Do"));
2681 } else { 2683 } else {
2682 checkExternalId( todo ); 2684 checkExternalId( todo );
2683 mCalendar->deleteTodo(todo); 2685 mCalendar->deleteTodo(todo);
2684 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2686 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2685 updateView(); 2687 updateView();
2686 } 2688 }
2687 } 2689 }
2688 emit updateSearchDialog(); 2690 emit updateSearchDialog();
2689} 2691}
2690void CalendarView::deleteJournal(Journal *jour) 2692void CalendarView::deleteJournal(Journal *jour)
2691{ 2693{
2692 if (!jour) { 2694 if (!jour) {
2693 KNotifyClient::beep(); 2695 KNotifyClient::beep();
2694 return; 2696 return;
2695 } 2697 }
2696 if (KOPrefs::instance()->mConfirm) { 2698 if (KOPrefs::instance()->mConfirm) {
2697 switch (msgItemDelete()) { 2699 switch (msgItemDelete()) {
2698 case KMessageBox::Continue: // OK 2700 case KMessageBox::Continue: // OK
2699 calendar()->deleteJournal(jour); 2701 calendar()->deleteJournal(jour);
2700 updateView(); 2702 updateView();
2701 break; 2703 break;
2702 } // switch 2704 } // switch
2703 } else { 2705 } else {
2704 calendar()->deleteJournal(jour);; 2706 calendar()->deleteJournal(jour);;
2705 updateView(); 2707 updateView();
2706 } 2708 }
2707 emit updateSearchDialog(); 2709 emit updateSearchDialog();
2708} 2710}
2709 2711
2710void CalendarView::deleteEvent(Event *anEvent) 2712void CalendarView::deleteEvent(Event *anEvent)
2711{ 2713{
2712 if (!anEvent) { 2714 if (!anEvent) {
2713 KNotifyClient::beep(); 2715 KNotifyClient::beep();
2714 return; 2716 return;
2715 } 2717 }
2716 2718
2717 if (anEvent->recurrence()->doesRecur()) { 2719 if (anEvent->recurrence()->doesRecur()) {
2718 QDate itemDate = mViewManager->currentSelectionDate(); 2720 QDate itemDate = mViewManager->currentSelectionDate();
2719 int km; 2721 int km;
2720 if (!itemDate.isValid()) { 2722 if (!itemDate.isValid()) {
2721 //kdDebug() << "Date Not Valid" << endl; 2723 //kdDebug() << "Date Not Valid" << endl;
2722 if (KOPrefs::instance()->mConfirm) { 2724 if (KOPrefs::instance()->mConfirm) {
2723 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2725 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2724 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2726 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2725 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2727 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2726 if ( km == KMessageBox::Continue ) 2728 if ( km == KMessageBox::Continue )
2727 km = KMessageBox::No; // No = all below 2729 km = KMessageBox::No; // No = all below
2728 } else 2730 } else
2729 km = KMessageBox::No; 2731 km = KMessageBox::No;
2730 } else { 2732 } else {
2731 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2733 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2732 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2734 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2733 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2735 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2734 i18n("KO/Pi Confirmation"),i18n("Current"), 2736 i18n("KO/Pi Confirmation"),i18n("Current"),
2735 i18n("All")); 2737 i18n("All"));
2736 } 2738 }
2737 switch(km) { 2739 switch(km) {
2738 2740
2739 case KMessageBox::No: // Continue // all 2741 case KMessageBox::No: // Continue // all
2740 //qDebug("KMessageBox::No "); 2742 //qDebug("KMessageBox::No ");
2741 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2743 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2742 schedule(Scheduler::Cancel,anEvent); 2744 schedule(Scheduler::Cancel,anEvent);
2743 2745
2744 checkExternalId( anEvent); 2746 checkExternalId( anEvent);
2745 mCalendar->deleteEvent(anEvent); 2747 mCalendar->deleteEvent(anEvent);
2746 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2748 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2747 break; 2749 break;
2748 2750
2749 // Disabled because it does not work 2751 // Disabled because it does not work
2750 //#if 0 2752 //#if 0
2751 case KMessageBox::Yes: // just this one 2753 case KMessageBox::Yes: // just this one
2752 //QDate qd = mNavigator->selectedDates().first(); 2754 //QDate qd = mNavigator->selectedDates().first();
2753 //if (!qd.isValid()) { 2755 //if (!qd.isValid()) {
2754 // kdDebug() << "no date selected, or invalid date" << endl; 2756 // kdDebug() << "no date selected, or invalid date" << endl;
2755 // KNotifyClient::beep(); 2757 // KNotifyClient::beep();
2756 // return; 2758 // return;
2757 //} 2759 //}
2758 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2760 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2759 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2761 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2760 anEvent->addExDate(itemDate); 2762 anEvent->addExDate(itemDate);
2761 int duration = anEvent->recurrence()->duration(); 2763 int duration = anEvent->recurrence()->duration();
2762 if ( duration > 0 ) { 2764 if ( duration > 0 ) {
2763 anEvent->recurrence()->setDuration( duration - 1 ); 2765 anEvent->recurrence()->setDuration( duration - 1 );
2764 } 2766 }
2765 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2767 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2766 } 2768 }
2767 break; 2769 break;
2768 //#endif 2770 //#endif
2769 } // switch 2771 } // switch
2770 } else { 2772 } else {
2771 if (KOPrefs::instance()->mConfirm) { 2773 if (KOPrefs::instance()->mConfirm) {
2772 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2774 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2773 i18n("\nAre you sure you want\nto delete this event?"), 2775 i18n("\nAre you sure you want\nto delete this event?"),
2774 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2776 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2775 case KMessageBox::Continue: // OK 2777 case KMessageBox::Continue: // OK
2776 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2778 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2777 schedule(Scheduler::Cancel,anEvent); 2779 schedule(Scheduler::Cancel,anEvent);
2778 checkExternalId( anEvent); 2780 checkExternalId( anEvent);
2779 mCalendar->deleteEvent(anEvent); 2781 mCalendar->deleteEvent(anEvent);
2780 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2782 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2781 break; 2783 break;
2782 } // switch 2784 } // switch
2783 } else { 2785 } else {
2784 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2786 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2785 schedule(Scheduler::Cancel,anEvent); 2787 schedule(Scheduler::Cancel,anEvent);
2786 checkExternalId( anEvent); 2788 checkExternalId( anEvent);
2787 mCalendar->deleteEvent(anEvent); 2789 mCalendar->deleteEvent(anEvent);
2788 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2790 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2789 } 2791 }
2790 } // if-else 2792 } // if-else
2791 emit updateSearchDialog(); 2793 emit updateSearchDialog();
2792} 2794}
2793 2795
2794bool CalendarView::deleteEvent(const QString &uid) 2796bool CalendarView::deleteEvent(const QString &uid)
2795{ 2797{
2796 Event *ev = mCalendar->event(uid); 2798 Event *ev = mCalendar->event(uid);
2797 if (ev) { 2799 if (ev) {
2798 deleteEvent(ev); 2800 deleteEvent(ev);
2799 return true; 2801 return true;
2800 } else { 2802 } else {
2801 return false; 2803 return false;
2802 } 2804 }
2803} 2805}
2804 2806
2805/*****************************************************************************/ 2807/*****************************************************************************/
2806 2808
2807void CalendarView::action_mail() 2809void CalendarView::action_mail()
2808{ 2810{
2809#ifndef KORG_NOMAIL 2811#ifndef KORG_NOMAIL
2810 KOMailClient mailClient; 2812 KOMailClient mailClient;
2811 2813
2812 Incidence *incidence = currentSelection(); 2814 Incidence *incidence = currentSelection();
2813 2815
2814 if (!incidence) { 2816 if (!incidence) {
2815 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2817 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2816 return; 2818 return;
2817 } 2819 }
2818 if(incidence->attendeeCount() == 0 ) { 2820 if(incidence->attendeeCount() == 0 ) {
2819 KMessageBox::sorry(this, 2821 KMessageBox::sorry(this,
2820 i18n("Can't generate mail:\nNo attendees defined.\n")); 2822 i18n("Can't generate mail:\nNo attendees defined.\n"));
2821 return; 2823 return;
2822 } 2824 }
2823 2825
2824 CalendarLocal cal_tmp; 2826 CalendarLocal cal_tmp;
2825 Event *event = 0; 2827 Event *event = 0;
2826 Event *ev = 0; 2828 Event *ev = 0;
2827 if ( incidence && incidence->type() == "Event" ) { 2829 if ( incidence && incidence->type() == "Event" ) {
2828 event = static_cast<Event *>(incidence); 2830 event = static_cast<Event *>(incidence);
2829 ev = new Event(*event); 2831 ev = new Event(*event);
2830 cal_tmp.addEvent(ev); 2832 cal_tmp.addEvent(ev);
2831 } 2833 }
2832 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2834 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2833 QString attachment = mForm.toString( &cal_tmp ); 2835 QString attachment = mForm.toString( &cal_tmp );
2834 if (ev) delete(ev); 2836 if (ev) delete(ev);
2835 2837
2836 mailClient.mailAttendees(currentSelection(), attachment); 2838 mailClient.mailAttendees(currentSelection(), attachment);
2837 2839
2838#endif 2840#endif
2839 2841
2840#if 0 2842#if 0
2841 Event *anEvent = 0; 2843 Event *anEvent = 0;
2842 if (mViewManager->currentView()->isEventView()) { 2844 if (mViewManager->currentView()->isEventView()) {
2843 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2845 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2844 } 2846 }
2845 2847
2846 if (!anEvent) { 2848 if (!anEvent) {
2847 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2849 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2848 return; 2850 return;
2849 } 2851 }
2850 if(anEvent->attendeeCount() == 0 ) { 2852 if(anEvent->attendeeCount() == 0 ) {
2851 KMessageBox::sorry(this, 2853 KMessageBox::sorry(this,
2852 i18n("Can't generate mail:\nNo attendees defined.\n")); 2854 i18n("Can't generate mail:\nNo attendees defined.\n"));
2853 return; 2855 return;
2854 } 2856 }
2855 2857
2856 mailobject.emailEvent(anEvent); 2858 mailobject.emailEvent(anEvent);
2857#endif 2859#endif
2858} 2860}
2859 2861
2860 2862
2861void CalendarView::schedule_publish(Incidence *incidence) 2863void CalendarView::schedule_publish(Incidence *incidence)
2862{ 2864{
2863 Event *event = 0; 2865 Event *event = 0;
2864 Todo *todo = 0; 2866 Todo *todo = 0;
2865 2867
2866 if (incidence == 0) { 2868 if (incidence == 0) {
2867 incidence = mViewManager->currentView()->selectedIncidences().first(); 2869 incidence = mViewManager->currentView()->selectedIncidences().first();
2868 if (incidence == 0) { 2870 if (incidence == 0) {
2869 incidence = mTodoList->selectedIncidences().first(); 2871 incidence = mTodoList->selectedIncidences().first();
2870 } 2872 }
2871 } 2873 }
2872 if ( incidence && incidence->type() == "Event" ) { 2874 if ( incidence && incidence->type() == "Event" ) {
2873 event = static_cast<Event *>(incidence); 2875 event = static_cast<Event *>(incidence);
2874 } else { 2876 } else {
2875 if ( incidence && incidence->type() == "Todo" ) { 2877 if ( incidence && incidence->type() == "Todo" ) {
2876 todo = static_cast<Todo *>(incidence); 2878 todo = static_cast<Todo *>(incidence);
2877 } 2879 }
2878 } 2880 }
2879 2881
2880 if (!event && !todo) { 2882 if (!event && !todo) {
2881 KMessageBox::sorry(this,i18n("No event selected.")); 2883 KMessageBox::sorry(this,i18n("No event selected."));
2882 return; 2884 return;
2883 } 2885 }
2884 2886
2885 PublishDialog *publishdlg = new PublishDialog(); 2887 PublishDialog *publishdlg = new PublishDialog();
2886 if (incidence->attendeeCount()>0) { 2888 if (incidence->attendeeCount()>0) {
2887 QPtrList<Attendee> attendees = incidence->attendees(); 2889 QPtrList<Attendee> attendees = incidence->attendees();
2888 attendees.first(); 2890 attendees.first();
2889 while ( attendees.current()!=0 ) { 2891 while ( attendees.current()!=0 ) {
2890 publishdlg->addAttendee(attendees.current()); 2892 publishdlg->addAttendee(attendees.current());
2891 attendees.next(); 2893 attendees.next();
2892 } 2894 }
2893 } 2895 }
2894 bool send = true; 2896 bool send = true;
2895 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2897 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2896 if ( publishdlg->exec() != QDialog::Accepted ) 2898 if ( publishdlg->exec() != QDialog::Accepted )
2897 send = false; 2899 send = false;
2898 } 2900 }
2899 if ( send ) { 2901 if ( send ) {
2900 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2902 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2901 if ( event ) { 2903 if ( event ) {
2902 Event *ev = new Event(*event); 2904 Event *ev = new Event(*event);
2903 ev->registerObserver(0); 2905 ev->registerObserver(0);
2904 ev->clearAttendees(); 2906 ev->clearAttendees();
2905 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2907 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2906 delete(ev); 2908 delete(ev);
2907 } 2909 }
2908 } else { 2910 } else {
2909 if ( todo ) { 2911 if ( todo ) {
2910 Todo *ev = new Todo(*todo); 2912 Todo *ev = new Todo(*todo);
2911 ev->registerObserver(0); 2913 ev->registerObserver(0);
2912 ev->clearAttendees(); 2914 ev->clearAttendees();
2913 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2915 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2914 delete(ev); 2916 delete(ev);
2915 } 2917 }
2916 } 2918 }
2917 } 2919 }
2918 } 2920 }
2919 delete publishdlg; 2921 delete publishdlg;
2920} 2922}
2921 2923
2922void CalendarView::schedule_request(Incidence *incidence) 2924void CalendarView::schedule_request(Incidence *incidence)
2923{ 2925{
2924 schedule(Scheduler::Request,incidence); 2926 schedule(Scheduler::Request,incidence);
2925} 2927}
2926 2928
2927void CalendarView::schedule_refresh(Incidence *incidence) 2929void CalendarView::schedule_refresh(Incidence *incidence)
2928{ 2930{
2929 schedule(Scheduler::Refresh,incidence); 2931 schedule(Scheduler::Refresh,incidence);
2930} 2932}
2931 2933
2932void CalendarView::schedule_cancel(Incidence *incidence) 2934void CalendarView::schedule_cancel(Incidence *incidence)
2933{ 2935{
2934 schedule(Scheduler::Cancel,incidence); 2936 schedule(Scheduler::Cancel,incidence);
2935} 2937}
2936 2938
2937void CalendarView::schedule_add(Incidence *incidence) 2939void CalendarView::schedule_add(Incidence *incidence)
2938{ 2940{
2939 schedule(Scheduler::Add,incidence); 2941 schedule(Scheduler::Add,incidence);
2940} 2942}
2941 2943
2942void CalendarView::schedule_reply(Incidence *incidence) 2944void CalendarView::schedule_reply(Incidence *incidence)
2943{ 2945{
2944 schedule(Scheduler::Reply,incidence); 2946 schedule(Scheduler::Reply,incidence);
2945} 2947}
2946 2948
2947void CalendarView::schedule_counter(Incidence *incidence) 2949void CalendarView::schedule_counter(Incidence *incidence)
2948{ 2950{
2949 schedule(Scheduler::Counter,incidence); 2951 schedule(Scheduler::Counter,incidence);
2950} 2952}
2951 2953
2952void CalendarView::schedule_declinecounter(Incidence *incidence) 2954void CalendarView::schedule_declinecounter(Incidence *incidence)
2953{ 2955{
2954 schedule(Scheduler::Declinecounter,incidence); 2956 schedule(Scheduler::Declinecounter,incidence);
2955} 2957}
2956 2958
2957void CalendarView::schedule_publish_freebusy(int daysToPublish) 2959void CalendarView::schedule_publish_freebusy(int daysToPublish)
2958{ 2960{
2959 QDateTime start = QDateTime::currentDateTime(); 2961 QDateTime start = QDateTime::currentDateTime();
2960 QDateTime end = start.addDays(daysToPublish); 2962 QDateTime end = start.addDays(daysToPublish);
2961 2963
2962 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2964 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2963 freebusy->setOrganizer(KOPrefs::instance()->email()); 2965 freebusy->setOrganizer(KOPrefs::instance()->email());
2964 2966
2965 2967
2966 PublishDialog *publishdlg = new PublishDialog(); 2968 PublishDialog *publishdlg = new PublishDialog();
2967 if ( publishdlg->exec() == QDialog::Accepted ) { 2969 if ( publishdlg->exec() == QDialog::Accepted ) {
2968 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2970 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2969 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2971 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2970 delete(freebusy); 2972 delete(freebusy);
2971 } 2973 }
2972 } 2974 }
2973 delete publishdlg; 2975 delete publishdlg;
2974} 2976}
2975 2977
2976void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2978void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2977{ 2979{
2978 Event *event = 0; 2980 Event *event = 0;
2979 Todo *todo = 0; 2981 Todo *todo = 0;
2980 2982
2981 if (incidence == 0) { 2983 if (incidence == 0) {
2982 incidence = mViewManager->currentView()->selectedIncidences().first(); 2984 incidence = mViewManager->currentView()->selectedIncidences().first();
2983 if (incidence == 0) { 2985 if (incidence == 0) {
2984 incidence = mTodoList->selectedIncidences().first(); 2986 incidence = mTodoList->selectedIncidences().first();
2985 } 2987 }
2986 } 2988 }
2987 if ( incidence && incidence->type() == "Event" ) { 2989 if ( incidence && incidence->type() == "Event" ) {
2988 event = static_cast<Event *>(incidence); 2990 event = static_cast<Event *>(incidence);
2989 } 2991 }
2990 if ( incidence && incidence->type() == "Todo" ) { 2992 if ( incidence && incidence->type() == "Todo" ) {
2991 todo = static_cast<Todo *>(incidence); 2993 todo = static_cast<Todo *>(incidence);
2992 } 2994 }
2993 2995
2994 if (!event && !todo) { 2996 if (!event && !todo) {
2995 KMessageBox::sorry(this,i18n("No event selected.")); 2997 KMessageBox::sorry(this,i18n("No event selected."));
2996 return; 2998 return;
2997 } 2999 }
2998 3000
2999 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3001 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3000 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3002 KMessageBox::sorry(this,i18n("The event has no attendees."));
3001 return; 3003 return;
3002 } 3004 }
3003 3005
3004 Event *ev = 0; 3006 Event *ev = 0;
3005 if (event) ev = new Event(*event); 3007 if (event) ev = new Event(*event);
3006 Todo *to = 0; 3008 Todo *to = 0;
3007 if (todo) to = new Todo(*todo); 3009 if (todo) to = new Todo(*todo);
3008 3010
3009 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3011 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3010 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3012 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3011 if (!me) { 3013 if (!me) {
3012 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3014 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3013 return; 3015 return;
3014 } 3016 }
3015 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3017 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3016 StatusDialog *statdlg = new StatusDialog(this); 3018 StatusDialog *statdlg = new StatusDialog(this);
3017 if (!statdlg->exec()==QDialog::Accepted) return; 3019 if (!statdlg->exec()==QDialog::Accepted) return;
3018 me->setStatus( statdlg->status() ); 3020 me->setStatus( statdlg->status() );
3019 delete(statdlg); 3021 delete(statdlg);
3020 } 3022 }
3021 Attendee *menew = new Attendee(*me); 3023 Attendee *menew = new Attendee(*me);
3022 if (ev) { 3024 if (ev) {
3023 ev->clearAttendees(); 3025 ev->clearAttendees();
3024 ev->addAttendee(menew,false); 3026 ev->addAttendee(menew,false);
3025 } else { 3027 } else {
3026 if (to) { 3028 if (to) {
3027 todo->clearAttendees(); 3029 todo->clearAttendees();
3028 todo->addAttendee(menew,false); 3030 todo->addAttendee(menew,false);
3029 } 3031 }
3030 } 3032 }
3031 } 3033 }
3032 3034
3033 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3035 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3034 if (ev) { 3036 if (ev) {
3035 if ( !dlg->addMessage(ev,method) ) delete(ev); 3037 if ( !dlg->addMessage(ev,method) ) delete(ev);
3036 } else { 3038 } else {
3037 if (to) { 3039 if (to) {
3038 if ( !dlg->addMessage(to,method) ) delete(to); 3040 if ( !dlg->addMessage(to,method) ) delete(to);
3039 } 3041 }
3040 } 3042 }
3041} 3043}
3042 3044
3043void CalendarView::openAddressbook() 3045void CalendarView::openAddressbook()
3044{ 3046{
3045 KRun::runCommand("kaddressbook"); 3047 KRun::runCommand("kaddressbook");
3046} 3048}
3047 3049
3048void CalendarView::setModified(bool modified) 3050void CalendarView::setModified(bool modified)
3049{ 3051{
3050 if ( modified ) 3052 if ( modified )
3051 emit signalmodified(); 3053 emit signalmodified();
3052 if (mModified != modified) { 3054 if (mModified != modified) {
3053 mModified = modified; 3055 mModified = modified;
3054 emit modifiedChanged(mModified); 3056 emit modifiedChanged(mModified);
3055 } 3057 }
3056} 3058}
3057 3059
3058bool CalendarView::isReadOnly() 3060bool CalendarView::isReadOnly()
3059{ 3061{
3060 return mReadOnly; 3062 return mReadOnly;
3061} 3063}
3062 3064
3063void CalendarView::setReadOnly(bool readOnly) 3065void CalendarView::setReadOnly(bool readOnly)
3064{ 3066{
3065 if (mReadOnly != readOnly) { 3067 if (mReadOnly != readOnly) {
3066 mReadOnly = readOnly; 3068 mReadOnly = readOnly;
3067 emit readOnlyChanged(mReadOnly); 3069 emit readOnlyChanged(mReadOnly);
3068 } 3070 }
3069} 3071}
3070 3072
3071bool CalendarView::isModified() 3073bool CalendarView::isModified()
3072{ 3074{
3073 return mModified; 3075 return mModified;
3074} 3076}
3075 3077
3076void CalendarView::printSetup() 3078void CalendarView::printSetup()
3077{ 3079{
3078#ifndef KORG_NOPRINTER 3080#ifndef KORG_NOPRINTER
3079 createPrinter(); 3081 createPrinter();
3080 3082
3081 mCalPrinter->setupPrinter(); 3083 mCalPrinter->setupPrinter();
3082#endif 3084#endif
3083} 3085}
3084 3086
3085void CalendarView::print() 3087void CalendarView::print()
3086{ 3088{
3087#ifndef KORG_NOPRINTER 3089#ifndef KORG_NOPRINTER
3088 createPrinter(); 3090 createPrinter();
3089 3091
3090 DateList tmpDateList = mNavigator->selectedDates(); 3092 DateList tmpDateList = mNavigator->selectedDates();
3091 mCalPrinter->print(CalPrinter::Month, 3093 mCalPrinter->print(CalPrinter::Month,
3092 tmpDateList.first(), tmpDateList.last()); 3094 tmpDateList.first(), tmpDateList.last());
3093#endif 3095#endif
3094} 3096}
3095 3097
3096void CalendarView::printPreview() 3098void CalendarView::printPreview()
3097{ 3099{
3098#ifndef KORG_NOPRINTER 3100#ifndef KORG_NOPRINTER
3099 kdDebug() << "CalendarView::printPreview()" << endl; 3101 kdDebug() << "CalendarView::printPreview()" << endl;
3100 3102
3101 createPrinter(); 3103 createPrinter();
3102 3104
3103 DateList tmpDateList = mNavigator->selectedDates(); 3105 DateList tmpDateList = mNavigator->selectedDates();
3104 3106
3105 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3107 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3106 tmpDateList.last()); 3108 tmpDateList.last());
3107#endif 3109#endif
3108} 3110}
3109 3111
3110void CalendarView::exportICalendar() 3112void CalendarView::exportICalendar()
3111{ 3113{
3112 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3114 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3113 3115
3114 // Force correct extension 3116 // Force correct extension
3115 if (filename.right(4) != ".ics") filename += ".ics"; 3117 if (filename.right(4) != ".ics") filename += ".ics";
3116 3118
3117 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3119 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3118 storage.save(); 3120 storage.save();
3119} 3121}
3120 3122
3121bool CalendarView::exportVCalendar( QString filename ) 3123bool CalendarView::exportVCalendar( QString filename )
3122{ 3124{
3123 if (mCalendar->journals().count() > 0) { 3125 if (mCalendar->journals().count() > 0) {
3124 int result = KMessageBox::warningContinueCancel(this, 3126 int result = KMessageBox::warningContinueCancel(this,
3125 i18n("The journal entries can not be\nexported to a vCalendar file."), 3127 i18n("The journal entries can not be\nexported to a vCalendar file."),
3126 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3128 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3127 true); 3129 true);
3128 if (result != KMessageBox::Continue) return false; 3130 if (result != KMessageBox::Continue) return false;
3129 } 3131 }
3130 3132
3131 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3133 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3132 3134
3133 // Force correct extension 3135 // Force correct extension
3134 if (filename.right(4) != ".vcs") filename += ".vcs"; 3136 if (filename.right(4) != ".vcs") filename += ".vcs";
3135 3137
3136 FileStorage storage( mCalendar, filename, new VCalFormat ); 3138 FileStorage storage( mCalendar, filename, new VCalFormat );
3137 return storage.save(); 3139 return storage.save();
3138 3140
3139} 3141}
3140 3142
3141void CalendarView::eventUpdated(Incidence *) 3143void CalendarView::eventUpdated(Incidence *)
3142{ 3144{
3143 setModified(); 3145 setModified();
3144 // Don't call updateView here. The code, which has caused the update of the 3146 // Don't call updateView here. The code, which has caused the update of the
3145 // event is responsible for updating the view. 3147 // event is responsible for updating the view.
3146 // updateView(); 3148 // updateView();
3147} 3149}
3148 3150
3149void CalendarView::adaptNavigationUnits() 3151void CalendarView::adaptNavigationUnits()
3150{ 3152{
3151 if (mViewManager->currentView()->isEventView()) { 3153 if (mViewManager->currentView()->isEventView()) {
3152 int days = mViewManager->currentView()->currentDateCount(); 3154 int days = mViewManager->currentView()->currentDateCount();
3153 if (days == 1) { 3155 if (days == 1) {
3154 emit changeNavStringPrev(i18n("&Previous Day")); 3156 emit changeNavStringPrev(i18n("&Previous Day"));
3155 emit changeNavStringNext(i18n("&Next Day")); 3157 emit changeNavStringNext(i18n("&Next Day"));
3156 } else { 3158 } else {
3157 emit changeNavStringPrev(i18n("&Previous Week")); 3159 emit changeNavStringPrev(i18n("&Previous Week"));
3158 emit changeNavStringNext(i18n("&Next Week")); 3160 emit changeNavStringNext(i18n("&Next Week"));
3159 } 3161 }
3160 } 3162 }
3161} 3163}
3162 3164
3163void CalendarView::processMainViewSelection( Incidence *incidence ) 3165void CalendarView::processMainViewSelection( Incidence *incidence )
3164{ 3166{
3165 if ( incidence ) mTodoList->clearSelection(); 3167 if ( incidence ) mTodoList->clearSelection();
3166 processIncidenceSelection( incidence ); 3168 processIncidenceSelection( incidence );
3167} 3169}
3168 3170
3169void CalendarView::processTodoListSelection( Incidence *incidence ) 3171void CalendarView::processTodoListSelection( Incidence *incidence )
3170{ 3172{
3171 if ( incidence && mViewManager->currentView() ) { 3173 if ( incidence && mViewManager->currentView() ) {
3172 mViewManager->currentView()->clearSelection(); 3174 mViewManager->currentView()->clearSelection();
3173 } 3175 }
3174 processIncidenceSelection( incidence ); 3176 processIncidenceSelection( incidence );
3175} 3177}
3176 3178
3177void CalendarView::processIncidenceSelection( Incidence *incidence ) 3179void CalendarView::processIncidenceSelection( Incidence *incidence )
3178{ 3180{
3179 if ( incidence == mSelectedIncidence ) return; 3181 if ( incidence == mSelectedIncidence ) return;
3180 3182
3181 mSelectedIncidence = incidence; 3183 mSelectedIncidence = incidence;
3182 3184
3183 emit incidenceSelected( mSelectedIncidence ); 3185 emit incidenceSelected( mSelectedIncidence );
3184 3186
3185 if ( incidence && incidence->type() == "Event" ) { 3187 if ( incidence && incidence->type() == "Event" ) {
3186 Event *event = static_cast<Event *>( incidence ); 3188 Event *event = static_cast<Event *>( incidence );
3187 if ( event->organizer() == KOPrefs::instance()->email() ) { 3189 if ( event->organizer() == KOPrefs::instance()->email() ) {
3188 emit organizerEventsSelected( true ); 3190 emit organizerEventsSelected( true );
3189 } else { 3191 } else {
3190 emit organizerEventsSelected(false); 3192 emit organizerEventsSelected(false);
3191 } 3193 }
3192 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3194 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3193 KOPrefs::instance()->email() ) ) { 3195 KOPrefs::instance()->email() ) ) {
3194 emit groupEventsSelected( true ); 3196 emit groupEventsSelected( true );
3195 } else { 3197 } else {
3196 emit groupEventsSelected(false); 3198 emit groupEventsSelected(false);
3197 } 3199 }
3198 return; 3200 return;
3199 } else { 3201 } else {
3200 if ( incidence && incidence->type() == "Todo" ) { 3202 if ( incidence && incidence->type() == "Todo" ) {
3201 emit todoSelected( true ); 3203 emit todoSelected( true );
3202 Todo *event = static_cast<Todo *>( incidence ); 3204 Todo *event = static_cast<Todo *>( incidence );
3203 if ( event->organizer() == KOPrefs::instance()->email() ) { 3205 if ( event->organizer() == KOPrefs::instance()->email() ) {
3204 emit organizerEventsSelected( true ); 3206 emit organizerEventsSelected( true );
3205 } else { 3207 } else {
3206 emit organizerEventsSelected(false); 3208 emit organizerEventsSelected(false);
3207 } 3209 }
3208 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3210 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3209 KOPrefs::instance()->email() ) ) { 3211 KOPrefs::instance()->email() ) ) {
3210 emit groupEventsSelected( true ); 3212 emit groupEventsSelected( true );
3211 } else { 3213 } else {
3212 emit groupEventsSelected(false); 3214 emit groupEventsSelected(false);
3213 } 3215 }
3214 return; 3216 return;
3215 } else { 3217 } else {
3216 emit todoSelected( false ); 3218 emit todoSelected( false );
3217 emit organizerEventsSelected(false); 3219 emit organizerEventsSelected(false);
3218 emit groupEventsSelected(false); 3220 emit groupEventsSelected(false);
3219 } 3221 }
3220 return; 3222 return;
3221 } 3223 }
3222 3224
3223 /* if ( incidence && incidence->type() == "Todo" ) { 3225 /* if ( incidence && incidence->type() == "Todo" ) {
3224 emit todoSelected( true ); 3226 emit todoSelected( true );
3225 } else { 3227 } else {
3226 emit todoSelected( false ); 3228 emit todoSelected( false );
3227 }*/ 3229 }*/
3228} 3230}
3229 3231
3230 3232
3231void CalendarView::checkClipboard() 3233void CalendarView::checkClipboard()
3232{ 3234{
3233#ifndef KORG_NODND 3235#ifndef KORG_NODND
3234 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3236 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3235 emit pasteEnabled(true); 3237 emit pasteEnabled(true);
3236 } else { 3238 } else {
3237 emit pasteEnabled(false); 3239 emit pasteEnabled(false);
3238 } 3240 }
3239#endif 3241#endif
3240} 3242}
3241 3243
3242void CalendarView::showDates(const DateList &selectedDates) 3244void CalendarView::showDates(const DateList &selectedDates)
3243{ 3245{
3244 // kdDebug() << "CalendarView::selectDates()" << endl; 3246 // kdDebug() << "CalendarView::selectDates()" << endl;
3245 3247
3246 if ( mViewManager->currentView() ) { 3248 if ( mViewManager->currentView() ) {
3247 updateView( selectedDates.first(), selectedDates.last() ); 3249 updateView( selectedDates.first(), selectedDates.last() );
3248 } else { 3250 } else {
3249 mViewManager->showAgendaView(); 3251 mViewManager->showAgendaView();
3250 } 3252 }
3251 3253
3252 QString selDates; 3254 QString selDates;
3253 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3255 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3254 if (selectedDates.first() < selectedDates.last() ) 3256 if (selectedDates.first() < selectedDates.last() )
3255 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3257 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3256 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3258 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3257 3259
3258} 3260}
3259 3261
3260QPtrList<CalFilter> CalendarView::filters() 3262QPtrList<CalFilter> CalendarView::filters()
3261{ 3263{
3262 return mFilters; 3264 return mFilters;
3263 3265
3264} 3266}
3265void CalendarView::editFilters() 3267void CalendarView::editFilters()
3266{ 3268{
3267 // kdDebug() << "CalendarView::editFilters()" << endl; 3269 // kdDebug() << "CalendarView::editFilters()" << endl;
3268 3270
3269 CalFilter *filter = mFilters.first(); 3271 CalFilter *filter = mFilters.first();
3270 while(filter) { 3272 while(filter) {
3271 kdDebug() << " Filter: " << filter->name() << endl; 3273 kdDebug() << " Filter: " << filter->name() << endl;
3272 filter = mFilters.next(); 3274 filter = mFilters.next();
3273 } 3275 }
3274 3276
3275 mDialogManager->showFilterEditDialog(&mFilters); 3277 mDialogManager->showFilterEditDialog(&mFilters);
3276} 3278}
3277void CalendarView::toggleFilter() 3279void CalendarView::toggleFilter()
3278{ 3280{
3279 showFilter(! mFilterView->isVisible()); 3281 showFilter(! mFilterView->isVisible());
3280} 3282}
3281 3283
3282KOFilterView *CalendarView::filterView() 3284KOFilterView *CalendarView::filterView()
3283{ 3285{
3284 return mFilterView; 3286 return mFilterView;
3285} 3287}
3286void CalendarView::selectFilter( int fil ) 3288void CalendarView::selectFilter( int fil )
3287{ 3289{
3288 mFilterView->setSelectedFilter( fil ); 3290 mFilterView->setSelectedFilter( fil );
3289} 3291}
3290void CalendarView::showFilter(bool visible) 3292void CalendarView::showFilter(bool visible)
3291{ 3293{
3292 if (visible) mFilterView->show(); 3294 if (visible) mFilterView->show();
3293 else mFilterView->hide(); 3295 else mFilterView->hide();
3294} 3296}
3295void CalendarView::toggleFilerEnabled( ) 3297void CalendarView::toggleFilerEnabled( )
3296{ 3298{
3297 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3299 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3298 if ( !mFilterView->filtersEnabled() ) 3300 if ( !mFilterView->filtersEnabled() )
3299 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3301 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3300 3302
3301} 3303}
3302void CalendarView::updateFilter() 3304void CalendarView::updateFilter()
3303{ 3305{
3304 CalFilter *filter = mFilterView->selectedFilter(); 3306 CalFilter *filter = mFilterView->selectedFilter();
3305 if (filter) { 3307 if (filter) {
3306 if (mFilterView->filtersEnabled()) { 3308 if (mFilterView->filtersEnabled()) {
3307 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3309 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3308 filter->setEnabled(true); 3310 filter->setEnabled(true);
3309 } 3311 }
3310 else filter->setEnabled(false); 3312 else filter->setEnabled(false);
3311 mCalendar->setFilter(filter); 3313 mCalendar->setFilter(filter);
3312 updateView(); 3314 updateView();
3313 } 3315 }
3314} 3316}
3315 3317
3316void CalendarView::filterEdited() 3318void CalendarView::filterEdited()
3317{ 3319{
3318 mFilterView->updateFilters(); 3320 mFilterView->updateFilters();
3319 updateFilter(); 3321 updateFilter();
3320 writeSettings(); 3322 writeSettings();
3321} 3323}
3322 3324
3323 3325
3324void CalendarView::takeOverEvent() 3326void CalendarView::takeOverEvent()
3325{ 3327{
3326 Incidence *incidence = currentSelection(); 3328 Incidence *incidence = currentSelection();
3327 3329
3328 if (!incidence) return; 3330 if (!incidence) return;
3329 3331
3330 incidence->setOrganizer(KOPrefs::instance()->email()); 3332 incidence->setOrganizer(KOPrefs::instance()->email());
3331 incidence->recreate(); 3333 incidence->recreate();
3332 incidence->setReadOnly(false); 3334 incidence->setReadOnly(false);
3333 3335
3334 updateView(); 3336 updateView();
3335} 3337}
3336 3338
3337void CalendarView::takeOverCalendar() 3339void CalendarView::takeOverCalendar()
3338{ 3340{
3339 // TODO: Create Calendar::allIncidences() function and use it here 3341 // TODO: Create Calendar::allIncidences() function and use it here
3340 3342
3341 QPtrList<Event> events = mCalendar->events(); 3343 QPtrList<Event> events = mCalendar->events();
3342 for(uint i=0; i<events.count(); ++i) { 3344 for(uint i=0; i<events.count(); ++i) {
3343 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3345 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3344 events.at(i)->recreate(); 3346 events.at(i)->recreate();
3345 events.at(i)->setReadOnly(false); 3347 events.at(i)->setReadOnly(false);
3346 } 3348 }
3347 3349
3348 QPtrList<Todo> todos = mCalendar->todos(); 3350 QPtrList<Todo> todos = mCalendar->todos();
3349 for(uint i=0; i<todos.count(); ++i) { 3351 for(uint i=0; i<todos.count(); ++i) {
3350 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3352 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3351 todos.at(i)->recreate(); 3353 todos.at(i)->recreate();
3352 todos.at(i)->setReadOnly(false); 3354 todos.at(i)->setReadOnly(false);
3353 } 3355 }
3354 3356
3355 QPtrList<Journal> journals = mCalendar->journals(); 3357 QPtrList<Journal> journals = mCalendar->journals();
3356 for(uint i=0; i<journals.count(); ++i) { 3358 for(uint i=0; i<journals.count(); ++i) {
3357 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3359 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3358 journals.at(i)->recreate(); 3360 journals.at(i)->recreate();
3359 journals.at(i)->setReadOnly(false); 3361 journals.at(i)->setReadOnly(false);
3360 } 3362 }
3361 3363
3362 updateView(); 3364 updateView();
3363} 3365}
3364 3366
3365void CalendarView::showIntro() 3367void CalendarView::showIntro()
3366{ 3368{
3367 kdDebug() << "To be implemented." << endl; 3369 kdDebug() << "To be implemented." << endl;
3368} 3370}
3369 3371
3370QWidgetStack *CalendarView::viewStack() 3372QWidgetStack *CalendarView::viewStack()
3371{ 3373{
3372 return mRightFrame; 3374 return mRightFrame;
3373} 3375}
3374 3376
3375QWidget *CalendarView::leftFrame() 3377QWidget *CalendarView::leftFrame()
3376{ 3378{
3377 return mLeftFrame; 3379 return mLeftFrame;
3378} 3380}
3379 3381
3380DateNavigator *CalendarView::dateNavigator() 3382DateNavigator *CalendarView::dateNavigator()
3381{ 3383{
3382 return mNavigator; 3384 return mNavigator;
3383} 3385}
3384 3386
3385KDateNavigator* CalendarView::dateNavigatorWidget() 3387KDateNavigator* CalendarView::dateNavigatorWidget()
3386{ 3388{
3387 return mDateNavigator; 3389 return mDateNavigator;
3388} 3390}
3389void CalendarView::toggleDateNavigatorWidget() 3391void CalendarView::toggleDateNavigatorWidget()
3390{ 3392{
3391 if (mDateNavigator->isVisible()) 3393 if (mDateNavigator->isVisible())
3392 mDateNavigator->hide(); 3394 mDateNavigator->hide();
3393 else 3395 else
3394 mDateNavigator->show(); 3396 mDateNavigator->show();
3395} 3397}
3396void CalendarView::addView(KOrg::BaseView *view) 3398void CalendarView::addView(KOrg::BaseView *view)
3397{ 3399{
3398 mViewManager->addView(view); 3400 mViewManager->addView(view);
3399} 3401}
3400 3402
3401void CalendarView::showView(KOrg::BaseView *view) 3403void CalendarView::showView(KOrg::BaseView *view)
3402{ 3404{
3403 mViewManager->showView(view, mLeftFrame->isVisible()); 3405 mViewManager->showView(view, mLeftFrame->isVisible());
3404} 3406}
3405 3407
3406Incidence *CalendarView::currentSelection() 3408Incidence *CalendarView::currentSelection()
3407{ 3409{
3408 return mViewManager->currentSelection(); 3410 return mViewManager->currentSelection();
3409} 3411}
3410void CalendarView::toggleAllDaySize() 3412void CalendarView::toggleAllDaySize()
3411{ 3413{
3412 /* 3414 /*
3413 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3415 if ( KOPrefs::instance()->mAllDaySize > 47 )
3414 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3416 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3415 else 3417 else
3416 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3418 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3417 */ 3419 */
3418 viewManager()->agendaView()->toggleAllDay(); 3420 viewManager()->agendaView()->toggleAllDay();
3419} 3421}
3420void CalendarView::toggleExpand() 3422void CalendarView::toggleExpand()
3421{ 3423{
3422 // if ( mLeftFrame->isHidden() ) { 3424 // if ( mLeftFrame->isHidden() ) {
3423 // mLeftFrame->show(); 3425 // mLeftFrame->show();
3424 // emit calendarViewExpanded( false ); 3426 // emit calendarViewExpanded( false );
3425 // } else { 3427 // } else {
3426 // mLeftFrame->hide(); 3428 // mLeftFrame->hide();
3427 // emit calendarViewExpanded( true ); 3429 // emit calendarViewExpanded( true );
3428 // } 3430 // }
3429 3431
3430 globalFlagBlockAgenda = 1; 3432 globalFlagBlockAgenda = 1;
3431 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3433 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3432 globalFlagBlockAgenda = 5; 3434 globalFlagBlockAgenda = 5;
3433 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3435 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3434 //mViewManager->showView( 0, true ); 3436 //mViewManager->showView( 0, true );
3435} 3437}
3436 3438
3437void CalendarView::calendarModified( bool modified, Calendar * ) 3439void CalendarView::calendarModified( bool modified, Calendar * )
3438{ 3440{
3439 setModified( modified ); 3441 setModified( modified );
3440} 3442}
3441 3443
3442Todo *CalendarView::selectedTodo() 3444Todo *CalendarView::selectedTodo()
3443{ 3445{
3444 Incidence *incidence = currentSelection(); 3446 Incidence *incidence = currentSelection();
3445 if ( incidence && incidence->type() == "Todo" ) { 3447 if ( incidence && incidence->type() == "Todo" ) {
3446 return static_cast<Todo *>( incidence ); 3448 return static_cast<Todo *>( incidence );
3447 } 3449 }
3448 3450
3449 incidence = mTodoList->selectedIncidences().first(); 3451 incidence = mTodoList->selectedIncidences().first();
3450 if ( incidence && incidence->type() == "Todo" ) { 3452 if ( incidence && incidence->type() == "Todo" ) {
3451 return static_cast<Todo *>( incidence ); 3453 return static_cast<Todo *>( incidence );
3452 } 3454 }
3453 3455
3454 return 0; 3456 return 0;
3455} 3457}
3456 3458
3457void CalendarView::dialogClosing(Incidence *in) 3459void CalendarView::dialogClosing(Incidence *in)
3458{ 3460{
3459 // mDialogList.remove(in); 3461 // mDialogList.remove(in);
3460} 3462}
3461 3463
3462void CalendarView::showIncidence() 3464void CalendarView::showIncidence()
3463{ 3465{
3464 Incidence *incidence = currentSelection(); 3466 Incidence *incidence = currentSelection();
3465 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3467 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3466 if ( incidence ) { 3468 if ( incidence ) {
3467 ShowIncidenceVisitor v; 3469 ShowIncidenceVisitor v;
3468 v.act( incidence, this ); 3470 v.act( incidence, this );
3469 } 3471 }
3470} 3472}
3471void CalendarView::editIncidenceDescription() 3473void CalendarView::editIncidenceDescription()
3472{ 3474{
3473 mFlagEditDescription = true; 3475 mFlagEditDescription = true;
3474 editIncidence(); 3476 editIncidence();
3475 mFlagEditDescription = false; 3477 mFlagEditDescription = false;
3476} 3478}
3477void CalendarView::editIncidence() 3479void CalendarView::editIncidence()
3478{ 3480{
3479 // qDebug("editIncidence() "); 3481 // qDebug("editIncidence() ");
3480 Incidence *incidence = currentSelection(); 3482 Incidence *incidence = currentSelection();
3481 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3483 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3482 if ( incidence ) { 3484 if ( incidence ) {
3483 EditIncidenceVisitor v; 3485 EditIncidenceVisitor v;
3484 v.act( incidence, this ); 3486 v.act( incidence, this );
3485 } 3487 }
3486} 3488}
3487 3489
3488void CalendarView::deleteIncidence() 3490void CalendarView::deleteIncidence()
3489{ 3491{
3490 Incidence *incidence = currentSelection(); 3492 Incidence *incidence = currentSelection();
3491 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3493 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3492 if ( incidence ) { 3494 if ( incidence ) {
3493 deleteIncidence(incidence); 3495 deleteIncidence(incidence);
3494 } 3496 }
3495} 3497}
3496 3498
3497void CalendarView::showIncidence(Incidence *incidence) 3499void CalendarView::showIncidence(Incidence *incidence)
3498{ 3500{
3499 if ( incidence ) { 3501 if ( incidence ) {
3500 ShowIncidenceVisitor v; 3502 ShowIncidenceVisitor v;
3501 v.act( incidence, this ); 3503 v.act( incidence, this );
3502 } 3504 }
3503} 3505}
3504 3506
3505void CalendarView::editIncidence(Incidence *incidence) 3507void CalendarView::editIncidence(Incidence *incidence)
3506{ 3508{
3507 if ( incidence ) { 3509 if ( incidence ) {
3508 3510
3509 EditIncidenceVisitor v; 3511 EditIncidenceVisitor v;
3510 v.act( incidence, this ); 3512 v.act( incidence, this );
3511 3513
3512 } 3514 }
3513} 3515}
3514 3516
3515void CalendarView::deleteIncidence(Incidence *incidence) 3517void CalendarView::deleteIncidence(Incidence *incidence)
3516{ 3518{
3517 //qDebug(" CalendarView::deleteIncidence "); 3519 //qDebug(" CalendarView::deleteIncidence ");
3518 if ( incidence ) { 3520 if ( incidence ) {
3519 DeleteIncidenceVisitor v; 3521 DeleteIncidenceVisitor v;
3520 v.act( incidence, this ); 3522 v.act( incidence, this );
3521 } 3523 }
3522} 3524}
3523 3525
3524 3526
3525void CalendarView::lookForOutgoingMessages() 3527void CalendarView::lookForOutgoingMessages()
3526{ 3528{
3527 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3529 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3528 ogd->loadMessages(); 3530 ogd->loadMessages();
3529} 3531}
3530 3532
3531void CalendarView::lookForIncomingMessages() 3533void CalendarView::lookForIncomingMessages()
3532{ 3534{
3533 IncomingDialog *icd = mDialogManager->incomingDialog(); 3535 IncomingDialog *icd = mDialogManager->incomingDialog();
3534 icd->retrieve(); 3536 icd->retrieve();
3535} 3537}
3536 3538
3537bool CalendarView::removeCompletedSubTodos( Todo* t ) 3539bool CalendarView::removeCompletedSubTodos( Todo* t )
3538{ 3540{
3539 bool deleteTodo = true; 3541 bool deleteTodo = true;
3540 QPtrList<Incidence> subTodos; 3542 QPtrList<Incidence> subTodos;
3541 Incidence *aTodo; 3543 Incidence *aTodo;
3542 subTodos = t->relations(); 3544 subTodos = t->relations();
3543 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3545 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3544 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3546 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3545 deleteTodo = false; 3547 deleteTodo = false;
3546 } 3548 }
3547 if ( deleteTodo ) { 3549 if ( deleteTodo ) {
3548 if ( t->isCompleted() ) { 3550 if ( t->isCompleted() ) {
3549 checkExternalId( t ); 3551 checkExternalId( t );
3550 mCalendar->deleteTodo( t ); 3552 mCalendar->deleteTodo( t );
3551 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3553 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3552 } 3554 }
3553 else 3555 else
3554 deleteTodo = false; 3556 deleteTodo = false;
3555 } 3557 }
3556 return deleteTodo; 3558 return deleteTodo;
3557 3559
3558} 3560}
3559void CalendarView::purgeCompleted() 3561void CalendarView::purgeCompleted()
3560{ 3562{
3561 int result = KMessageBox::warningContinueCancel(this, 3563 int result = KMessageBox::warningContinueCancel(this,
3562 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3564 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3563 3565
3564 if (result == KMessageBox::Continue) { 3566 if (result == KMessageBox::Continue) {
3565 3567
3566 QPtrList<Todo> todoCal; 3568 QPtrList<Todo> todoCal;
3567 QPtrList<Todo> rootTodos; 3569 QPtrList<Todo> rootTodos;
3568 //QPtrList<Incidence> rel; 3570 //QPtrList<Incidence> rel;
3569 Todo *aTodo;//, *rTodo; 3571 Todo *aTodo;//, *rTodo;
3570 Incidence *rIncidence; 3572 Incidence *rIncidence;
3571 bool childDelete = false; 3573 bool childDelete = false;
3572 bool deletedOne = true; 3574 bool deletedOne = true;
3573 todoCal = calendar()->todos(); 3575 todoCal = calendar()->todos();
3574 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3576 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3575 if ( !aTodo->relatedTo() ) 3577 if ( !aTodo->relatedTo() )
3576 rootTodos.append( aTodo ); 3578 rootTodos.append( aTodo );
3577 } 3579 }
3578 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3580 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3579 removeCompletedSubTodos( aTodo ); 3581 removeCompletedSubTodos( aTodo );
3580 } 3582 }
3581 3583
3582 updateView(); 3584 updateView();
3583 } 3585 }
3584} 3586}
3585 3587
3586void CalendarView::slotCalendarChanged() 3588void CalendarView::slotCalendarChanged()
3587{ 3589{
3588 ; 3590 ;
3589} 3591}
3590 3592
3591NavigatorBar *CalendarView::navigatorBar() 3593NavigatorBar *CalendarView::navigatorBar()
3592{ 3594{
3593 return mNavigatorBar; 3595 return mNavigatorBar;
3594} 3596}
3595 3597
3596 3598
3597 3599
3598void CalendarView::keyPressEvent ( QKeyEvent *e) 3600void CalendarView::keyPressEvent ( QKeyEvent *e)
3599{ 3601{
3600 //qDebug(" alendarView::keyPressEvent "); 3602 //qDebug(" alendarView::keyPressEvent ");
3601 e->ignore(); 3603 e->ignore();
3602} 3604}
3603 3605
3604//#include "calendarview.moc" 3606//#include "calendarview.moc"
3605 3607
3606//#include "calendarviewbase.moc" 3608//#include "calendarviewbase.moc"
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp
index f3bd09f..50e3077 100644
--- a/korganizer/incomingdialog.cpp
+++ b/korganizer/incomingdialog.cpp
@@ -1,527 +1,528 @@
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 <qlistview.h> 20#include <qlistview.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qmap.h> 23#include <qmap.h>
24 24
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kstandarddirs.h> 28#include <kstandarddirs.h>
29#include <kmessagebox.h> 29#include <kmessagebox.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32#include <libkcal/event.h> 32#include <libkcal/event.h>
33#include <libkcal/calendar.h> 33#include <libkcal/calendar.h>
34#include <libkcal/freebusy.h> 34#include <libkcal/freebusy.h>
35#include <libkcal/attendee.h> 35#include <libkcal/attendee.h>
36#include <libkcal/calendarresources.h> 36#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h> 37#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h> 38#include <kresources/resourceselectdialog.h>
39 39
40#ifndef KORG_NOMAIL 40#ifndef KORG_NOMAIL
41#include "mailscheduler.h" 41#include "mailscheduler.h"
42#else 42#else
43#include <libkcal/dummyscheduler.h> 43#include <libkcal/dummyscheduler.h>
44#endif 44#endif
45 45
46 46
47#include "incomingdialog.h" 47#include "incomingdialog.h"
48#include "koeventviewerdialog.h" 48#include "koeventviewerdialog.h"
49#include "kocounterdialog.h" 49#include "kocounterdialog.h"
50#include "koprefs.h" 50#include "koprefs.h"
51 51
52#ifndef KORG_NOKABC 52#ifndef KORG_NOKABC
53#include <kabc/stdaddressbook.h> 53#define KORG_NOKABC
54//#include <kabc/stdaddressbook.h>
54#define size count 55#define size count
55#endif 56#endif
56 57
57 58
58ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, 59ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev,
59 Scheduler::Method method,ScheduleMessage::Status status) 60 Scheduler::Method method,ScheduleMessage::Status status)
60 : QListViewItem(parent) 61 : QListViewItem(parent)
61{ 62{
62 mIncidence = ev; 63 mIncidence = ev;
63 mMethod = method; 64 mMethod = method;
64 mStatus = status; 65 mStatus = status;
65 setText(6,Scheduler::translatedMethodName(mMethod)+" "); 66 setText(6,Scheduler::translatedMethodName(mMethod)+" ");
66 setText(7,ScheduleMessage::statusName(status)); 67 setText(7,ScheduleMessage::statusName(status));
67} 68}
68 69
69 70
70/* Visitor */ 71/* Visitor */
71ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) 72ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item)
72{ 73{
73 mItem = item; 74 mItem = item;
74} 75}
75 76
76ScheduleItemVisitor::~ScheduleItemVisitor() 77ScheduleItemVisitor::~ScheduleItemVisitor()
77{ 78{
78} 79}
79 80
80bool ScheduleItemVisitor::visit(Event *e) 81bool ScheduleItemVisitor::visit(Event *e)
81{ 82{
82 mItem->setText(0,e->summary()); 83 mItem->setText(0,e->summary());
83 mItem->setText(1,e->dtStartDateStr()); 84 mItem->setText(1,e->dtStartDateStr());
84 if (e->doesFloat()) { 85 if (e->doesFloat()) {
85 mItem->setText(2,i18n("no time ")); 86 mItem->setText(2,i18n("no time "));
86 mItem->setText(4,i18n("no time ")); 87 mItem->setText(4,i18n("no time "));
87 } 88 }
88 else { 89 else {
89 mItem->setText(2,e->dtStartTimeStr()); 90 mItem->setText(2,e->dtStartTimeStr());
90 mItem->setText(4,e->dtEndTimeStr()); 91 mItem->setText(4,e->dtEndTimeStr());
91 } 92 }
92 if (e->hasEndDate()) { 93 if (e->hasEndDate()) {
93 mItem->setText(3,e->dtEndDateStr()); 94 mItem->setText(3,e->dtEndDateStr());
94 } 95 }
95 else { 96 else {
96 mItem->setText(3,""); 97 mItem->setText(3,"");
97 } 98 }
98 mItem->setText(5,e->organizer()+" "); 99 mItem->setText(5,e->organizer()+" ");
99 100
100 return true; 101 return true;
101} 102}
102 103
103bool ScheduleItemVisitor::visit(Todo *e) 104bool ScheduleItemVisitor::visit(Todo *e)
104{ 105{
105 mItem->setText(0,e->summary()); 106 mItem->setText(0,e->summary());
106 if (e->hasStartDate()) { 107 if (e->hasStartDate()) {
107 mItem->setText(1,e->dtStartDateStr()); 108 mItem->setText(1,e->dtStartDateStr());
108 if (!e->doesFloat()) { 109 if (!e->doesFloat()) {
109 mItem->setText(2,e->dtStartTimeStr()); 110 mItem->setText(2,e->dtStartTimeStr());
110 } 111 }
111 } 112 }
112 if (e->hasDueDate()) { 113 if (e->hasDueDate()) {
113 mItem->setText(1,e->dtDueDateStr()); 114 mItem->setText(1,e->dtDueDateStr());
114 if (!e->doesFloat()) { 115 if (!e->doesFloat()) {
115 mItem->setText(2,e->dtDueTimeStr()); 116 mItem->setText(2,e->dtDueTimeStr());
116 } 117 }
117 } 118 }
118 mItem->setText(5,e->organizer()+" "); 119 mItem->setText(5,e->organizer()+" ");
119 120
120 return true; 121 return true;
121} 122}
122 123
123bool ScheduleItemVisitor::visit(Journal *) 124bool ScheduleItemVisitor::visit(Journal *)
124{ 125{
125 return false; 126 return false;
126} 127}
127 128
128 129
129/* 130/*
130 * Constructs a IncomingDialog which is a child of 'parent', with the 131 * Constructs a IncomingDialog which is a child of 'parent', with the
131 * name 'name' and widget flags set to 'f' 132 * name 'name' and widget flags set to 'f'
132 * 133 *
133 * The dialog will by default be modeless, unless you set 'modal' to 134 * The dialog will by default be modeless, unless you set 'modal' to
134 * TRUE to construct a modal dialog. 135 * TRUE to construct a modal dialog.
135 */ 136 */
136IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, 137IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing,
137 QWidget* parent,const char* name,bool modal,WFlags fl) : 138 QWidget* parent,const char* name,bool modal,WFlags fl) :
138 IncomingDialog_base(parent,name,modal,fl) 139 IncomingDialog_base(parent,name,modal,fl)
139{ 140{
140 mCalendar = calendar; 141 mCalendar = calendar;
141 mOutgoing = outgoing; 142 mOutgoing = outgoing;
142#ifndef KORG_NOMAIL 143#ifndef KORG_NOMAIL
143 mScheduler = new MailScheduler(mCalendar); 144 mScheduler = new MailScheduler(mCalendar);
144#else 145#else
145 mScheduler = new DummyScheduler(mCalendar); 146 mScheduler = new DummyScheduler(mCalendar);
146#endif 147#endif
147 mMessageListView->setColumnAlignment(1,AlignHCenter); 148 mMessageListView->setColumnAlignment(1,AlignHCenter);
148 mMessageListView->setColumnAlignment(2,AlignHCenter); 149 mMessageListView->setColumnAlignment(2,AlignHCenter);
149 mMessageListView->setColumnAlignment(3,AlignHCenter); 150 mMessageListView->setColumnAlignment(3,AlignHCenter);
150 mMessageListView->setColumnAlignment(4,AlignHCenter); 151 mMessageListView->setColumnAlignment(4,AlignHCenter);
151 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), 152 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)),
152 this,SLOT(showEvent(QListViewItem *))); 153 this,SLOT(showEvent(QListViewItem *)));
153 retrieve(); 154 retrieve();
154} 155}
155 156
156/* 157/*
157 * Destroys the object and frees any allocated resources 158 * Destroys the object and frees any allocated resources
158 */ 159 */
159IncomingDialog::~IncomingDialog() 160IncomingDialog::~IncomingDialog()
160{ 161{
161 // no need to delete child widgets, Qt does it all for us 162 // no need to delete child widgets, Qt does it all for us
162} 163}
163 164
164void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) 165void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing)
165{ 166{
166 mOutgoing = outgoing; 167 mOutgoing = outgoing;
167} 168}
168 169
169void IncomingDialog::retrieve() 170void IncomingDialog::retrieve()
170{ 171{
171 QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); 172 QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions();
172 173
173 ScheduleMessage *message; 174 ScheduleMessage *message;
174 for(message = messages.first();message;message = messages.next()) { 175 for(message = messages.first();message;message = messages.next()) {
175 IncidenceBase *inc = message->event(); 176 IncidenceBase *inc = message->event();
176 Scheduler::Method method = (Scheduler::Method)message->method(); 177 Scheduler::Method method = (Scheduler::Method)message->method();
177 ScheduleMessage::Status status = message->status(); 178 ScheduleMessage::Status status = message->status();
178 179
179 ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); 180 ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status);
180 if(inc->type()!="FreeBusy") { 181 if(inc->type()!="FreeBusy") {
181 Incidence *incidence = static_cast<Incidence *>(inc); 182 Incidence *incidence = static_cast<Incidence *>(inc);
182 ScheduleItemVisitor v(item); 183 ScheduleItemVisitor v(item);
183 if (!incidence->accept(v)) delete item; 184 if (!incidence->accept(v)) delete item;
184 } else { 185 } else {
185 FreeBusy *fb = static_cast<FreeBusy *>(item->event()); 186 FreeBusy *fb = static_cast<FreeBusy *>(item->event());
186 item->setText(0, "FreeBusy"); 187 item->setText(0, "FreeBusy");
187 item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); 188 item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) );
188 item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); 189 item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) );
189 item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); 190 item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) );
190 item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); 191 item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) );
191 item->setText(5, fb->organizer()); 192 item->setText(5, fb->organizer());
192 } 193 }
193 automaticAction(item); 194 automaticAction(item);
194 } 195 }
195 emit numMessagesChanged(mMessageListView->childCount()); 196 emit numMessagesChanged(mMessageListView->childCount());
196} 197}
197 198
198void IncomingDialog::acceptAllMessages() 199void IncomingDialog::acceptAllMessages()
199{ 200{
200 bool success = false; 201 bool success = false;
201 202
202 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); 203 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild();
203 while(item) { 204 while(item) {
204 ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); 205 ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling());
205 if (acceptMessage(item)) success = true; 206 if (acceptMessage(item)) success = true;
206 item = nextitem; 207 item = nextitem;
207 } 208 }
208 209
209 if (success) emit calendarUpdated(); 210 if (success) emit calendarUpdated();
210} 211}
211 212
212void IncomingDialog::acceptMessage() 213void IncomingDialog::acceptMessage()
213{ 214{
214 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); 215 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
215 if (item) { 216 if (item) {
216 if (acceptMessage(item)) emit calendarUpdated(); 217 if (acceptMessage(item)) emit calendarUpdated();
217 } 218 }
218} 219}
219 220
220bool IncomingDialog::acceptMessage(ScheduleItemIn *item) 221bool IncomingDialog::acceptMessage(ScheduleItemIn *item)
221{ 222{
222 switch (item->method()) { 223 switch (item->method()) {
223 case Scheduler::Refresh: 224 case Scheduler::Refresh:
224 return incomeRefresh(item); 225 return incomeRefresh(item);
225 break; 226 break;
226 case Scheduler::Counter: 227 case Scheduler::Counter:
227 return incomeCounter(item); 228 return incomeCounter(item);
228 break; 229 break;
229 case Scheduler::Declinecounter: 230 case Scheduler::Declinecounter:
230 return incomeDeclineCounter(item); 231 return incomeDeclineCounter(item);
231 break; 232 break;
232 case Scheduler::Add: 233 case Scheduler::Add:
233 return incomeAdd(item); 234 return incomeAdd(item);
234 break; 235 break;
235 case Scheduler::Request: 236 case Scheduler::Request:
236 return incomeRequest(item); 237 return incomeRequest(item);
237 break; 238 break;
238 default: 239 default:
239 return incomeDefault(item); 240 return incomeDefault(item);
240 } 241 }
241 return false; 242 return false;
242} 243}
243 244
244void IncomingDialog::rejectMessage() 245void IncomingDialog::rejectMessage()
245{ 246{
246 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); 247 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
247 if (item) { 248 if (item) {
248 mScheduler->deleteTransaction(item->event()); 249 mScheduler->deleteTransaction(item->event());
249 delete item; 250 delete item;
250 emit numMessagesChanged(mMessageListView->childCount()); 251 emit numMessagesChanged(mMessageListView->childCount());
251 } 252 }
252} 253}
253 254
254void IncomingDialog::showEvent(QListViewItem *item) 255void IncomingDialog::showEvent(QListViewItem *item)
255{ 256{
256 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 257 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
257 if( incidence && incidence->type() == "Event" ) { 258 if( incidence && incidence->type() == "Event" ) {
258 Event *event = static_cast<Event *>(incidence); 259 Event *event = static_cast<Event *>(incidence);
259 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); 260 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this);
260 eventViewer->setEvent(event); 261 eventViewer->setEvent(event);
261 eventViewer->show(); 262 eventViewer->show();
262 } 263 }
263} 264}
264 265
265bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) 266bool IncomingDialog::incomeRefresh(ScheduleItemIn *item)
266{ 267{
267 Event *ev = mCalendar->event(item->event()->uid()); 268 Event *ev = mCalendar->event(item->event()->uid());
268 if (ev) { 269 if (ev) {
269 //user interaction before?? 270 //user interaction before??
270 Attendee *att; 271 Attendee *att;
271 QPtrList<Attendee> attlist = ev->attendees(); 272 QPtrList<Attendee> attlist = ev->attendees();
272 for (att=attlist.first(); att; att=attlist.next()) { 273 for (att=attlist.first(); att; att=attlist.next()) {
273 Event *event = new Event(*ev); 274 Event *event = new Event(*ev);
274 mOutgoing->addMessage(event,Scheduler::Request,att->email()); 275 mOutgoing->addMessage(event,Scheduler::Request,att->email());
275 delete(event); 276 delete(event);
276 } 277 }
277 mScheduler->deleteTransaction(item->event()); 278 mScheduler->deleteTransaction(item->event());
278 delete item; 279 delete item;
279 emit numMessagesChanged(mMessageListView->childCount()); 280 emit numMessagesChanged(mMessageListView->childCount());
280 return true; 281 return true;
281 } 282 }
282 mScheduler->deleteTransaction(item->event()); 283 mScheduler->deleteTransaction(item->event());
283 delete item; 284 delete item;
284 emit numMessagesChanged(mMessageListView->childCount()); 285 emit numMessagesChanged(mMessageListView->childCount());
285 return false; 286 return false;
286} 287}
287 288
288bool IncomingDialog::incomeCounter(ScheduleItemIn *item) 289bool IncomingDialog::incomeCounter(ScheduleItemIn *item)
289{ 290{
290 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 291 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
291 // currently only events supportet - attetion at insertion below! 292 // currently only events supportet - attetion at insertion below!
292 if ( incidence->type() != "Event" ) return false; 293 if ( incidence->type() != "Event" ) return false;
293 294
294 Event *counterEvent = static_cast<Event *>( incidence ); 295 Event *counterEvent = static_cast<Event *>( incidence );
295 296
296 Event *even = mCalendar->event(counterEvent->uid()); 297 Event *even = mCalendar->event(counterEvent->uid());
297 298
298 KOCounterDialog *eventViewer = new KOCounterDialog(this); 299 KOCounterDialog *eventViewer = new KOCounterDialog(this);
299 eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); 300 eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>"));
300 eventViewer->addEvent(counterEvent); 301 eventViewer->addEvent(counterEvent);
301 eventViewer->addText("<hr>"); 302 eventViewer->addText("<hr>");
302 eventViewer->addText(i18n("<b>Original event:</b><p>")); 303 eventViewer->addText(i18n("<b>Original event:</b><p>"));
303 if (even) eventViewer->addEvent(even); 304 if (even) eventViewer->addEvent(even);
304 else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); 305 else eventViewer->addText(i18n("A corresponding event is missing in your calendar!"));
305 eventViewer->addText("<hr>"); 306 eventViewer->addText("<hr>");
306 eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); 307 eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event"));
307 eventViewer->show(); 308 eventViewer->show();
308 309
309 eventViewer->exec(); 310 eventViewer->exec();
310 if (eventViewer->result()) { 311 if (eventViewer->result()) {
311 kdDebug() << "IncomingDialog::Counter:Accept" << endl; 312 kdDebug() << "IncomingDialog::Counter:Accept" << endl;
312 int revision = 0; 313 int revision = 0;
313 if (even) { 314 if (even) {
314 revision = even->revision(); 315 revision = even->revision();
315 mCalendar->deleteEvent(even); 316 mCalendar->deleteEvent(even);
316 } 317 }
317 mCalendar->addIncidence(counterEvent); 318 mCalendar->addIncidence(counterEvent);
318 319
319 even = mCalendar->event(item->event()->uid()); 320 even = mCalendar->event(item->event()->uid());
320 if (even) { 321 if (even) {
321 if (revision < even->revision()) 322 if (revision < even->revision())
322 even->setRevision(even->revision()+1); 323 even->setRevision(even->revision()+1);
323 else 324 else
324 even->setRevision(revision+1); 325 even->setRevision(revision+1);
325 Event *ev = new Event(*even); 326 Event *ev = new Event(*even);
326 mOutgoing->addMessage(ev,Scheduler::Request); 327 mOutgoing->addMessage(ev,Scheduler::Request);
327 delete(ev); 328 delete(ev);
328 } 329 }
329 mScheduler->deleteTransaction(item->event()); 330 mScheduler->deleteTransaction(item->event());
330 delete item; 331 delete item;
331 emit numMessagesChanged(mMessageListView->childCount()); 332 emit numMessagesChanged(mMessageListView->childCount());
332 return true; 333 return true;
333 } else { 334 } else {
334 kdDebug() << "IncomingDialog::Counter:Decline" << endl; 335 kdDebug() << "IncomingDialog::Counter:Decline" << endl;
335 //the counter-sender's email is missing... 336 //the counter-sender's email is missing...
336 //now every attendee gets an declinecounter :-( 337 //now every attendee gets an declinecounter :-(
337 mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); 338 mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter);
338 delete item; 339 delete item;
339 emit numMessagesChanged(mMessageListView->childCount()); 340 emit numMessagesChanged(mMessageListView->childCount());
340 mScheduler->deleteTransaction(item->event()); 341 mScheduler->deleteTransaction(item->event());
341 delete item; 342 delete item;
342 emit numMessagesChanged(mMessageListView->childCount()); 343 emit numMessagesChanged(mMessageListView->childCount());
343 return true; 344 return true;
344 } 345 }
345 //mScheduler->deleteTransaction(item->event()); 346 //mScheduler->deleteTransaction(item->event());
346 delete item; 347 delete item;
347 emit numMessagesChanged(mMessageListView->childCount()); 348 emit numMessagesChanged(mMessageListView->childCount());
348 return false; 349 return false;
349} 350}
350 351
351bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) 352bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item)
352{ 353{
353 Event *even = mCalendar->event(item->event()->uid()); 354 Event *even = mCalendar->event(item->event()->uid());
354 if (even) { 355 if (even) {
355 mOutgoing->addMessage(even,Scheduler::Refresh); 356 mOutgoing->addMessage(even,Scheduler::Refresh);
356 mScheduler->deleteTransaction(item->event()); 357 mScheduler->deleteTransaction(item->event());
357 delete item; 358 delete item;
358 emit numMessagesChanged(mMessageListView->childCount()); 359 emit numMessagesChanged(mMessageListView->childCount());
359 return true; 360 return true;
360 } 361 }
361 mScheduler->deleteTransaction(item->event()); 362 mScheduler->deleteTransaction(item->event());
362 delete item; 363 delete item;
363 emit numMessagesChanged(mMessageListView->childCount()); 364 emit numMessagesChanged(mMessageListView->childCount());
364 return false; 365 return false;
365} 366}
366 367
367bool IncomingDialog::incomeAdd(ScheduleItemIn *item) 368bool IncomingDialog::incomeAdd(ScheduleItemIn *item)
368{ 369{
369 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 370 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
370 if (incidence->type() == "Event" ) { 371 if (incidence->type() == "Event" ) {
371 Event *refr = static_cast<Event *>( incidence ); 372 Event *refr = static_cast<Event *>( incidence );
372 mOutgoing->addMessage(refr,Scheduler::Refresh); 373 mOutgoing->addMessage(refr,Scheduler::Refresh);
373 mScheduler->deleteTransaction( incidence ); 374 mScheduler->deleteTransaction( incidence );
374 delete item; 375 delete item;
375 emit numMessagesChanged(mMessageListView->childCount()); 376 emit numMessagesChanged(mMessageListView->childCount());
376 return true; 377 return true;
377 } 378 }
378 else { 379 else {
379 kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; 380 kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl;
380 mScheduler->deleteTransaction( incidence ); 381 mScheduler->deleteTransaction( incidence );
381 delete item; 382 delete item;
382 emit numMessagesChanged(mMessageListView->childCount()); 383 emit numMessagesChanged(mMessageListView->childCount());
383 return false; 384 return false;
384 } 385 }
385} 386}
386 387
387bool IncomingDialog::incomeDefault(ScheduleItemIn *item) 388bool IncomingDialog::incomeDefault(ScheduleItemIn *item)
388{ 389{
389 if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { 390 if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) {
390 delete item; 391 delete item;
391 emit numMessagesChanged(mMessageListView->childCount()); 392 emit numMessagesChanged(mMessageListView->childCount());
392 return true; 393 return true;
393 } 394 }
394 else { 395 else {
395 KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); 396 KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses."));
396 kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; 397 kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl;
397 return false; 398 return false;
398 } 399 }
399 return false; 400 return false;
400} 401}
401 402
402bool IncomingDialog::incomeRequest(ScheduleItemIn *item) 403bool IncomingDialog::incomeRequest(ScheduleItemIn *item)
403{ 404{
404 if (item->event()->type()=="FreeBusy") { 405 if (item->event()->type()=="FreeBusy") {
405 //handel freebusy request 406 //handel freebusy request
406 IncidenceBase *inc = item->event(); 407 IncidenceBase *inc = item->event();
407 QDateTime start = inc->dtStart(); 408 QDateTime start = inc->dtStart();
408 QDateTime end = start.addDays(inc->duration()/86400); 409 QDateTime end = start.addDays(inc->duration()/86400);
409 410
410 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 411 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
411 freebusy->setOrganizer(inc->organizer()); 412 freebusy->setOrganizer(inc->organizer());
412 Attendee *att = new Attendee(KOPrefs::instance()->fullName(), 413 Attendee *att = new Attendee(KOPrefs::instance()->fullName(),
413 KOPrefs::instance()->email()); 414 KOPrefs::instance()->email());
414 freebusy->addAttendee(att); 415 freebusy->addAttendee(att);
415 416
416 kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " 417 kdDebug() << "calendarview: schedule_publish_freebusy: startDate: "
417 << KGlobal::locale()->formatDateTime( start ) << " End Date: " 418 << KGlobal::locale()->formatDateTime( start ) << " End Date: "
418 << KGlobal::locale()->formatDateTime( end ) << endl; 419 << KGlobal::locale()->formatDateTime( end ) << endl;
419 420
420 if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { 421 if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) {
421 delete item; 422 delete item;
422 emit numMessagesChanged(mMessageListView->childCount()); 423 emit numMessagesChanged(mMessageListView->childCount());
423 delete(freebusy); 424 delete(freebusy);
424 return true; 425 return true;
425 } 426 }
426 return false; 427 return false;
427 } else { 428 } else {
428 return incomeDefault(item); 429 return incomeDefault(item);
429 } 430 }
430 return false; 431 return false;
431} 432}
432 433
433bool IncomingDialog::automaticAction(ScheduleItemIn *item) 434bool IncomingDialog::automaticAction(ScheduleItemIn *item)
434{ 435{
435 bool autoAction = false; 436 bool autoAction = false;
436 IncidenceBase *inc = item->event(); 437 IncidenceBase *inc = item->event();
437 Scheduler::Method method = item->method(); 438 Scheduler::Method method = item->method();
438 439
439 if( inc->type()=="FreeBusy" ) { 440 if( inc->type()=="FreeBusy" ) {
440 if ( method==Scheduler::Request ) { 441 if ( method==Scheduler::Request ) {
441 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 442 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
442 // reply freebusy information 443 // reply freebusy information
443 if ( checkOrganizerInAddressbook(inc->organizer()) ) { 444 if ( checkOrganizerInAddressbook(inc->organizer()) ) {
444 incomeRequest(item); 445 incomeRequest(item);
445 } 446 }
446 } else return false; 447 } else return false;
447 } else { 448 } else {
448 449
449 if ( method==Scheduler::Reply ) { 450 if ( method==Scheduler::Reply ) {
450 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 451 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
451 // insert freebusy information 452 // insert freebusy information
452 //if ( checkAttendeesInAddressbook(inc) ) 453 //if ( checkAttendeesInAddressbook(inc) )
453 454
454 } else return false; 455 } else return false;
455 } else { 456 } else {
456 if ( method==Scheduler::Publish) { 457 if ( method==Scheduler::Publish) {
457 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 458 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
458 // insert freebusy information 459 // insert freebusy information
459 //if ( checkOrganizerInAddressbook(inc->organizer()) ) 460 //if ( checkOrganizerInAddressbook(inc->organizer()) )
460 461
461 } 462 }
462 } else return false; 463 } else return false;
463 } 464 }
464 } 465 }
465 } 466 }
466 467
467 if ( inc->type()=="Event" ) { 468 if ( inc->type()=="Event" ) {
468 if ( method==Scheduler::Request || method==Scheduler::Publish ) { 469 if ( method==Scheduler::Request || method==Scheduler::Publish ) {
469 if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { 470 if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) {
470 // insert event 471 // insert event
471 if ( checkOrganizerInAddressbook(inc->organizer()) ) 472 if ( checkOrganizerInAddressbook(inc->organizer()) )
472 autoAction = acceptMessage(item); 473 autoAction = acceptMessage(item);
473 } else return false; 474 } else return false;
474 } else { 475 } else {
475 476
476 if ( method==Scheduler::Reply ) { 477 if ( method==Scheduler::Reply ) {
477 if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { 478 if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) {
478 // update event information 479 // update event information
479 if ( checkAttendeesInAddressbook(inc) ) 480 if ( checkAttendeesInAddressbook(inc) )
480 autoAction = acceptMessage(item); 481 autoAction = acceptMessage(item);
481 } else return false; 482 } else return false;
482 } else { 483 } else {
483 484
484 if ( method==Scheduler::Refresh ) { 485 if ( method==Scheduler::Refresh ) {
485 if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { 486 if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) {
486 // send refresh-information 487 // send refresh-information
487 if ( checkAttendeesInAddressbook(inc) ) 488 if ( checkAttendeesInAddressbook(inc) )
488 autoAction = acceptMessage(item); 489 autoAction = acceptMessage(item);
489 else return false; 490 else return false;
490 } else return false; 491 } else return false;
491 } else return false; 492 } else return false;
492 } 493 }
493 } 494 }
494 } 495 }
495 return autoAction; 496 return autoAction;
496} 497}
497 498
498bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) 499bool IncomingDialog::checkOrganizerInAddressbook(QString organizer)
499{ 500{
500 bool inBook = false; 501 bool inBook = false;
501#ifndef KORG_NOKABC 502#ifndef KORG_NOKABC
502 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 503 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
503 KABC::Addressee::List addressList; 504 KABC::Addressee::List addressList;
504 addressList = add_book->findByEmail(organizer); 505 addressList = add_book->findByEmail(organizer);
505 if ( addressList.size()>0 ) inBook = true; 506 if ( addressList.size()>0 ) inBook = true;
506#endif 507#endif
507 return inBook; 508 return inBook;
508} 509}
509 510
510bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) 511bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc)
511{ 512{
512 bool inBook = false; 513 bool inBook = false;
513#ifndef KORG_NOKABC 514#ifndef KORG_NOKABC
514 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 515 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
515 KABC::Addressee::List addressList; 516 KABC::Addressee::List addressList;
516 QPtrList <Attendee> attendees; 517 QPtrList <Attendee> attendees;
517 Attendee *att; 518 Attendee *att;
518 attendees = inc->attendees(); 519 attendees = inc->attendees();
519 for (att=attendees.first();att;att=attendees.next()) { 520 for (att=attendees.first();att;att=attendees.next()) {
520 addressList = add_book->findByEmail(att->email()); 521 addressList = add_book->findByEmail(att->email());
521 if (addressList.size()>0 ) inBook = true; 522 if (addressList.size()>0 ) inBook = true;
522 } 523 }
523#endif 524#endif
524 return inBook; 525 return inBook;
525} 526}
526 527
527//#include "incomingdialog.moc" 528//#include "incomingdialog.moc"
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro
index 4247838..d841193 100644
--- a/korganizer/korganizerE.pro
+++ b/korganizer/korganizerE.pro
@@ -1,155 +1,157 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = obj/$(PLATFORM) 4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM) 5MOC_DIR = moc/$(PLATFORM)
6DESTDIR=$(QPEDIR)/bin 6DESTDIR=$(QPEDIR)/bin
7 7
8INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include 8INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include
9 9
10DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 10DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
11DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 11DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
12DEFINES += KORG_NOLVALTERNATION 12DEFINES += KORG_NOLVALTERNATION
13#KORG_NOKABC 13#KORG_NOKABC
14LIBS += -lmicrokdepim 14LIBS += -lmicrokdepim
15LIBS += -lmicrokcal 15LIBS += -lmicrokcal
16LIBS += -lmicrokde 16LIBS += -lmicrokde
17LIBS += -lmicroqtcompat 17LIBS += -lmicroqtcompat
18LIBS += -lmicrokabc 18#LIBS += -lmicrokabc
19 19
20#LIBS += $(QPEDIR)/lib/gammu 20#LIBS += $(QPEDIR)/lib/gammu
21#LIBS += -lmicrogammu 21#LIBS += -lmicrogammu
22#LIBS += -lbluetooth 22#LIBS += -lbluetooth
23#LIBS += -lsdp 23#LIBS += -lsdp
24LIBS += $(GCC3EXTRALIB1)
25LIBS += $(GCC3EXTRALIB2)
24 26
25 27
26LIBS += -lqpe 28LIBS += -lqpe
27LIBS += -ljpeg 29LIBS += -ljpeg
28LIBS += $(QTOPIALIB) 30LIBS += $(QTOPIALIB)
29LIBS += -L$(QPEDIR)/lib 31LIBS += -L$(QPEDIR)/lib
30 32
31INTERFACES = kofilterview_base.ui 33INTERFACES = kofilterview_base.ui
32#filteredit_base.ui 34#filteredit_base.ui
33 35
34HEADERS = \ 36HEADERS = \
35 wordsgerman.h \ 37 wordsgerman.h \
36 filteredit_base.h \ 38 filteredit_base.h \
37 alarmclient.h \ 39 alarmclient.h \
38 calendarview.h \ 40 calendarview.h \
39 customlistviewitem.h \ 41 customlistviewitem.h \
40 datenavigator.h \ 42 datenavigator.h \
41 docprefs.h \ 43 docprefs.h \
42 filtereditdialog.h \ 44 filtereditdialog.h \
43 incomingdialog.h \ 45 incomingdialog.h \
44 incomingdialog_base.h \ 46 incomingdialog_base.h \
45 interfaces/korganizer/baseview.h \ 47 interfaces/korganizer/baseview.h \
46 interfaces/korganizer/calendarviewbase.h \ 48 interfaces/korganizer/calendarviewbase.h \
47 journalentry.h \ 49 journalentry.h \
48 kdateedit.h \ 50 kdateedit.h \
49 kdatenavigator.h \ 51 kdatenavigator.h \
50 koagenda.h \ 52 koagenda.h \
51 koagendaitem.h \ 53 koagendaitem.h \
52 koagendaview.h \ 54 koagendaview.h \
53 kocounterdialog.h \ 55 kocounterdialog.h \
54 kodaymatrix.h \ 56 kodaymatrix.h \
55 kodialogmanager.h \ 57 kodialogmanager.h \
56 koeditordetails.h \ 58 koeditordetails.h \
57 koeditorgeneral.h \ 59 koeditorgeneral.h \
58 koeditorgeneralevent.h \ 60 koeditorgeneralevent.h \
59 koeditorgeneraltodo.h \ 61 koeditorgeneraltodo.h \
60 koeditorrecurrence.h \ 62 koeditorrecurrence.h \
61 koeventeditor.h \ 63 koeventeditor.h \
62 koeventpopupmenu.h \ 64 koeventpopupmenu.h \
63 koeventview.h \ 65 koeventview.h \
64 koeventviewer.h \ 66 koeventviewer.h \
65 koeventviewerdialog.h \ 67 koeventviewerdialog.h \
66 kofilterview.h \ 68 kofilterview.h \
67 koglobals.h \ 69 koglobals.h \
68 koincidenceeditor.h \ 70 koincidenceeditor.h \
69 kojournalview.h \ 71 kojournalview.h \
70 kolistview.h \ 72 kolistview.h \
71 kolocationbox.h \ 73 kolocationbox.h \
72 komonthview.h \ 74 komonthview.h \
73 koprefs.h \ 75 koprefs.h \
74 koprefsdialog.h \ 76 koprefsdialog.h \
75 kotimespanview.h \ 77 kotimespanview.h \
76 kotodoeditor.h \ 78 kotodoeditor.h \
77 kotodoview.h \ 79 kotodoview.h \
78 kotodoviewitem.h \ 80 kotodoviewitem.h \
79 koviewmanager.h \ 81 koviewmanager.h \
80 kowhatsnextview.h \ 82 kowhatsnextview.h \
81 ktimeedit.h \ 83 ktimeedit.h \
82 lineview.h \ 84 lineview.h \
83 mainwindow.h \ 85 mainwindow.h \
84 navigatorbar.h \ 86 navigatorbar.h \
85 outgoingdialog.h \ 87 outgoingdialog.h \
86 outgoingdialog_base.h \ 88 outgoingdialog_base.h \
87 publishdialog.h \ 89 publishdialog.h \
88 publishdialog_base.h \ 90 publishdialog_base.h \
89 savetemplatedialog.h \ 91 savetemplatedialog.h \
90 searchdialog.h \ 92 searchdialog.h \
91 simplealarmclient.h \ 93 simplealarmclient.h \
92 statusdialog.h \ 94 statusdialog.h \
93 timeline.h \ 95 timeline.h \
94 timespanview.h \ 96 timespanview.h \
95 version.h \ 97 version.h \
96 ../kalarmd/alarmdialog.h 98 ../kalarmd/alarmdialog.h
97 99
98SOURCES = \ 100SOURCES = \
99 filteredit_base.cpp \ 101 filteredit_base.cpp \
100 calendarview.cpp \ 102 calendarview.cpp \
101 datenavigator.cpp \ 103 datenavigator.cpp \
102 docprefs.cpp \ 104 docprefs.cpp \
103 filtereditdialog.cpp \ 105 filtereditdialog.cpp \
104 incomingdialog.cpp \ 106 incomingdialog.cpp \
105 incomingdialog_base.cpp \ 107 incomingdialog_base.cpp \
106 journalentry.cpp \ 108 journalentry.cpp \
107 kdatenavigator.cpp \ 109 kdatenavigator.cpp \
108 koagenda.cpp \ 110 koagenda.cpp \
109 koagendaitem.cpp \ 111 koagendaitem.cpp \
110 koagendaview.cpp \ 112 koagendaview.cpp \
111 kocounterdialog.cpp \ 113 kocounterdialog.cpp \
112 kodaymatrix.cpp \ 114 kodaymatrix.cpp \
113 kodialogmanager.cpp \ 115 kodialogmanager.cpp \
114 koeditordetails.cpp \ 116 koeditordetails.cpp \
115 koeditorgeneral.cpp \ 117 koeditorgeneral.cpp \
116 koeditorgeneralevent.cpp \ 118 koeditorgeneralevent.cpp \
117 koeditorgeneraltodo.cpp \ 119 koeditorgeneraltodo.cpp \
118 koeditorrecurrence.cpp \ 120 koeditorrecurrence.cpp \
119 koeventeditor.cpp \ 121 koeventeditor.cpp \
120 koeventpopupmenu.cpp \ 122 koeventpopupmenu.cpp \
121 koeventview.cpp \ 123 koeventview.cpp \
122 koeventviewer.cpp \ 124 koeventviewer.cpp \
123 koeventviewerdialog.cpp \ 125 koeventviewerdialog.cpp \
124 kofilterview.cpp \ 126 kofilterview.cpp \
125 koglobals.cpp \ 127 koglobals.cpp \
126 koincidenceeditor.cpp \ 128 koincidenceeditor.cpp \
127 kojournalview.cpp \ 129 kojournalview.cpp \
128 kolistview.cpp \ 130 kolistview.cpp \
129 kolocationbox.cpp \ 131 kolocationbox.cpp \
130 komonthview.cpp \ 132 komonthview.cpp \
131 koprefs.cpp \ 133 koprefs.cpp \
132 koprefsdialog.cpp \ 134 koprefsdialog.cpp \
133 kotimespanview.cpp \ 135 kotimespanview.cpp \
134 kotodoeditor.cpp \ 136 kotodoeditor.cpp \
135 kotodoview.cpp \ 137 kotodoview.cpp \
136 kotodoviewitem.cpp \ 138 kotodoviewitem.cpp \
137 koviewmanager.cpp \ 139 koviewmanager.cpp \
138 kowhatsnextview.cpp \ 140 kowhatsnextview.cpp \
139 ktimeedit.cpp \ 141 ktimeedit.cpp \
140 lineview.cpp \ 142 lineview.cpp \
141 main.cpp \ 143 main.cpp \
142 mainwindow.cpp \ 144 mainwindow.cpp \
143 navigatorbar.cpp \ 145 navigatorbar.cpp \
144 outgoingdialog.cpp \ 146 outgoingdialog.cpp \
145 outgoingdialog_base.cpp \ 147 outgoingdialog_base.cpp \
146 publishdialog.cpp \ 148 publishdialog.cpp \
147 publishdialog_base.cpp \ 149 publishdialog_base.cpp \
148 savetemplatedialog.cpp \ 150 savetemplatedialog.cpp \
149 searchdialog.cpp \ 151 searchdialog.cpp \
150 simplealarmclient.cpp \ 152 simplealarmclient.cpp \
151 statusdialog.cpp \ 153 statusdialog.cpp \
152 timeline.cpp \ 154 timeline.cpp \
153 timespanview.cpp \ 155 timespanview.cpp \
154 ../kalarmd/alarmdialog.cpp 156 ../kalarmd/alarmdialog.cpp
155 157
diff --git a/korganizer/publishdialog.cpp b/korganizer/publishdialog.cpp
index 4323b91..2ae6720 100644
--- a/korganizer/publishdialog.cpp
+++ b/korganizer/publishdialog.cpp
@@ -1,150 +1,151 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <kdebug.h> 25#include <kdebug.h>
26 26
27#include <kglobal.h> 27#include <kglobal.h>
28#include <klocale.h> 28#include <klocale.h>
29#ifndef KORG_NOKABC 29#ifndef KORG_NOKABC
30#include <kabc/addresseedialog.h> 30#define KORG_NOKABC
31//#include <kabc/addresseedialog.h>
31#endif 32#endif
32 33
33#include "koprefs.h" 34#include "koprefs.h"
34#include "publishdialog.h" 35#include "publishdialog.h"
35 36
36PublishDialog::PublishDialog(QWidget* parent, const char* name, 37PublishDialog::PublishDialog(QWidget* parent, const char* name,
37 bool modal, WFlags fl) 38 bool modal, WFlags fl)
38 : PublishDialog_base(parent,name,modal,fl) 39 : PublishDialog_base(parent,name,modal,fl)
39{ 40{
40 setCaption(i18n("Select Addresses")); 41 setCaption(i18n("Select Addresses"));
41 mNameLineEdit->setEnabled(false); 42 mNameLineEdit->setEnabled(false);
42 mEmailLineEdit->setEnabled(false); 43 mEmailLineEdit->setEnabled(false);
43 connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)), 44 connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)),
44 SLOT(updateInput())); 45 SLOT(updateInput()));
45} 46}
46 47
47PublishDialog::~PublishDialog() 48PublishDialog::~PublishDialog()
48{ 49{
49} 50}
50 51
51void PublishDialog::addAttendee(Attendee *attendee) 52void PublishDialog::addAttendee(Attendee *attendee)
52{ 53{
53 mNameLineEdit->setEnabled(true); 54 mNameLineEdit->setEnabled(true);
54 mEmailLineEdit->setEnabled(true); 55 mEmailLineEdit->setEnabled(true);
55 QListViewItem *item = new QListViewItem(mAddressListView); 56 QListViewItem *item = new QListViewItem(mAddressListView);
56 item->setText(0,attendee->name()); 57 item->setText(0,attendee->name());
57 item->setText(1,attendee->email()); 58 item->setText(1,attendee->email());
58 mAddressListView->insertItem(item); 59 mAddressListView->insertItem(item);
59} 60}
60 61
61QString PublishDialog::addresses() 62QString PublishDialog::addresses()
62{ 63{
63 QString to = ""; 64 QString to = "";
64 QListViewItem *item; 65 QListViewItem *item;
65 int i, count; 66 int i, count;
66 count = mAddressListView->childCount(); 67 count = mAddressListView->childCount();
67 for (i=0;i<count;i++) { 68 for (i=0;i<count;i++) {
68 item = mAddressListView->firstChild(); 69 item = mAddressListView->firstChild();
69 mAddressListView->takeItem(item); 70 mAddressListView->takeItem(item);
70 to += item->text(1); 71 to += item->text(1);
71 if (i<count-1) { 72 if (i<count-1) {
72 to += ", "; 73 to += ", ";
73 } 74 }
74 } 75 }
75 return to; 76 return to;
76} 77}
77 78
78void PublishDialog::addItem() 79void PublishDialog::addItem()
79{ 80{
80 mNameLineEdit->setEnabled(true); 81 mNameLineEdit->setEnabled(true);
81 mEmailLineEdit->setEnabled(true); 82 mEmailLineEdit->setEnabled(true);
82 QListViewItem *item = new QListViewItem(mAddressListView); 83 QListViewItem *item = new QListViewItem(mAddressListView);
83 mAddressListView->insertItem(item); 84 mAddressListView->insertItem(item);
84 mAddressListView->setSelected(item,true); 85 mAddressListView->setSelected(item,true);
85 mNameLineEdit->setText(i18n("(EmptyName)")); 86 mNameLineEdit->setText(i18n("(EmptyName)"));
86 mEmailLineEdit->setText(i18n("(EmptyEmail)")); 87 mEmailLineEdit->setText(i18n("(EmptyEmail)"));
87} 88}
88 89
89void PublishDialog::removeItem() 90void PublishDialog::removeItem()
90{ 91{
91 QListViewItem *item; 92 QListViewItem *item;
92 item = mAddressListView->selectedItem(); 93 item = mAddressListView->selectedItem();
93 if (!item) return; 94 if (!item) return;
94 mAddressListView->takeItem(item); 95 mAddressListView->takeItem(item);
95 item = mAddressListView->selectedItem(); 96 item = mAddressListView->selectedItem();
96 if (!item) { 97 if (!item) {
97 mNameLineEdit->setText(""); 98 mNameLineEdit->setText("");
98 mEmailLineEdit->setText(""); 99 mEmailLineEdit->setText("");
99 mNameLineEdit->setEnabled(false); 100 mNameLineEdit->setEnabled(false);
100 mEmailLineEdit->setEnabled(false); 101 mEmailLineEdit->setEnabled(false);
101 } 102 }
102 if (mAddressListView->childCount() == 0) { 103 if (mAddressListView->childCount() == 0) {
103 mNameLineEdit->setEnabled(false); 104 mNameLineEdit->setEnabled(false);
104 mEmailLineEdit->setEnabled(false); 105 mEmailLineEdit->setEnabled(false);
105 } 106 }
106} 107}
107 108
108void PublishDialog::openAddressbook() 109void PublishDialog::openAddressbook()
109{ 110{
110#ifndef KORG_NOKABC 111#ifndef KORG_NOKABC
111 KABC::Addressee::List addressList; 112 KABC::Addressee::List addressList;
112 addressList = KABC::AddresseeDialog::getAddressees(this); 113 addressList = KABC::AddresseeDialog::getAddressees(this);
113 //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); 114 //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
114 KABC::Addressee a = addressList.first(); 115 KABC::Addressee a = addressList.first();
115 if (!a.isEmpty()) { 116 if (!a.isEmpty()) {
116 uint i; 117 uint i;
117 for (i=0;i<addressList.count();i++) { 118 for (i=0;i<addressList.count();i++) {
118 a = addressList[i]; 119 a = addressList[i];
119 mNameLineEdit->setEnabled(true); 120 mNameLineEdit->setEnabled(true);
120 mEmailLineEdit->setEnabled(true); 121 mEmailLineEdit->setEnabled(true);
121 QListViewItem *item = new QListViewItem(mAddressListView); 122 QListViewItem *item = new QListViewItem(mAddressListView);
122 mAddressListView->setSelected(item,true); 123 mAddressListView->setSelected(item,true);
123 mNameLineEdit->setText(a.realName()); 124 mNameLineEdit->setText(a.realName());
124 mEmailLineEdit->setText(a.preferredEmail()); 125 mEmailLineEdit->setText(a.preferredEmail());
125 mAddressListView->insertItem(item); 126 mAddressListView->insertItem(item);
126 } 127 }
127 } 128 }
128#endif 129#endif
129} 130}
130 131
131void PublishDialog::updateItem() 132void PublishDialog::updateItem()
132{ 133{
133 QListViewItem *item; 134 QListViewItem *item;
134 item = mAddressListView->selectedItem(); 135 item = mAddressListView->selectedItem();
135 if (!item) return; 136 if (!item) return;
136 item->setText(0,mNameLineEdit->text()); 137 item->setText(0,mNameLineEdit->text());
137 item->setText(1,mEmailLineEdit->text()); 138 item->setText(1,mEmailLineEdit->text());
138} 139}
139 140
140void PublishDialog::updateInput() 141void PublishDialog::updateInput()
141{ 142{
142 QListViewItem *item; 143 QListViewItem *item;
143 item = mAddressListView->selectedItem(); 144 item = mAddressListView->selectedItem();
144 if (!item) return; 145 if (!item) return;
145 mNameLineEdit->setEnabled(true); 146 mNameLineEdit->setEnabled(true);
146 mEmailLineEdit->setEnabled(true); 147 mEmailLineEdit->setEnabled(true);
147 QString mail = item->text(1); 148 QString mail = item->text(1);
148 mNameLineEdit->setText(item->text(0)); 149 mNameLineEdit->setText(item->text(0));
149 mEmailLineEdit->setText(mail); 150 mEmailLineEdit->setText(mail);
150} 151}
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 060145e..f5de653 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,59 +1,57 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kincidenceformatter.h \ 30 kincidenceformatter.h \
31 kpimprefs.h \ 31 kpimprefs.h \
32 kpimglobalprefs.h \ 32 kpimglobalprefs.h \
33 kprefsdialog.h \ 33 kprefsdialog.h \
34 addresseeview.h \
35 ksyncprofile.h \ 34 ksyncprofile.h \
36 ksyncprefsdialog.h \ 35 ksyncprefsdialog.h \
37 kcmconfigs/kcmkdepimconfig.h \ 36 kcmconfigs/kcmkdepimconfig.h \
38 kcmconfigs/kdepimconfigwidget.h 37 kcmconfigs/kdepimconfigwidget.h
39 38
40SOURCES = \ 39SOURCES = \
41 categoryeditdialog.cpp \ 40 categoryeditdialog.cpp \
42 categoryeditdialog_base.cpp \ 41 categoryeditdialog_base.cpp \
43 categoryselectdialog.cpp \ 42 categoryselectdialog.cpp \
44 categoryselectdialog_base.cpp \ 43 categoryselectdialog_base.cpp \
45 externalapphandler.cpp \ 44 externalapphandler.cpp \
46 kdateedit.cpp \ 45 kdateedit.cpp \
47 kdatepicker.cpp \ 46 kdatepicker.cpp \
48 kinputdialog.cpp \ 47 kinputdialog.cpp \
49 kincidenceformatter.cpp \ 48 kincidenceformatter.cpp \
50 kpimprefs.cpp \ 49 kpimprefs.cpp \
51 kpimglobalprefs.cpp \ 50 kpimglobalprefs.cpp \
52 kprefsdialog.cpp \ 51 kprefsdialog.cpp \
53 addresseeview.cpp \
54 ksyncprofile.cpp \ 52 ksyncprofile.cpp \
55 ksyncprefsdialog.cpp \ 53 ksyncprefsdialog.cpp \
56 kcmconfigs/kcmkdepimconfig.cpp \ 54 kcmconfigs/kcmkdepimconfig.cpp \
57 kcmconfigs/kdepimconfigwidget.cpp 55 kcmconfigs/kdepimconfigwidget.cpp
58 56
59 57
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index b455a3e..102d827 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -1,53 +1,51 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3TARGET = microkdepim 3TARGET = microkdepim
4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include 4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include
5LIBS += -lmicrokde 5LIBS += -lmicrokde
6LIBS += -lmicrokcal 6LIBS += -lmicrokcal
7LIBS += -L$(QPEDIR)/lib 7LIBS += -L$(QPEDIR)/lib
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR=$(QPEDIR)/lib 10DESTDIR=$(QPEDIR)/lib
11 11
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 categoryeditdialog.h \ 16 categoryeditdialog.h \
17 categoryeditdialog_base.h \ 17 categoryeditdialog_base.h \
18 categoryselectdialog.h \ 18 categoryselectdialog.h \
19 categoryselectdialog_base.h \ 19 categoryselectdialog_base.h \
20 externalapphandler.h \ 20 externalapphandler.h \
21 kdateedit.h \ 21 kdateedit.h \
22 kdatepicker.h \ 22 kdatepicker.h \
23 kinputdialog.h \ 23 kinputdialog.h \
24 kincidenceformatter.h \ 24 kincidenceformatter.h \
25 kpimprefs.h \ 25 kpimprefs.h \
26 kpimglobalprefs.h \ 26 kpimglobalprefs.h \
27 kprefsdialog.h \ 27 kprefsdialog.h \
28 addresseeview.h \
29 ksyncprofile.h \ 28 ksyncprofile.h \
30 ksyncprefsdialog.h \ 29 ksyncprefsdialog.h \
31 kcmconfigs/kcmkdepimconfig.h \ 30 kcmconfigs/kcmkdepimconfig.h \
32 kcmconfigs/kdepimconfigwidget.h 31 kcmconfigs/kdepimconfigwidget.h
33 32
34 33
35 34
36SOURCES = \ 35SOURCES = \
37 categoryeditdialog.cpp \ 36 categoryeditdialog.cpp \
38 categoryeditdialog_base.cpp \ 37 categoryeditdialog_base.cpp \
39 categoryselectdialog.cpp \ 38 categoryselectdialog.cpp \
40 categoryselectdialog_base.cpp \ 39 categoryselectdialog_base.cpp \
41 externalapphandler.cpp \ 40 externalapphandler.cpp \
42 kdateedit.cpp \ 41 kdateedit.cpp \
43 kinputdialog.cpp \ 42 kinputdialog.cpp \
44 kdatepicker.cpp \ 43 kdatepicker.cpp \
45 kincidenceformatter.cpp \ 44 kincidenceformatter.cpp \
46 kpimprefs.cpp \ 45 kpimprefs.cpp \
47 kpimglobalprefs.cpp \ 46 kpimglobalprefs.cpp \
48 kprefsdialog.cpp \ 47 kprefsdialog.cpp \
49 addresseeview.cpp \
50 ksyncprofile.cpp \ 48 ksyncprofile.cpp \
51 ksyncprefsdialog.cpp \ 49 ksyncprefsdialog.cpp \
52 kcmconfigs/kcmkdepimconfig.cpp \ 50 kcmconfigs/kcmkdepimconfig.cpp \
53 kcmconfigs/kdepimconfigwidget.cpp 51 kcmconfigs/kdepimconfigwidget.cpp