summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp12
-rw-r--r--kaddressbook/kabcore.cpp22
-rw-r--r--kmicromail/composemail.cpp99
-rw-r--r--kmicromail/composemail.h8
-rw-r--r--kmicromail/main.cpp5
-rw-r--r--kmicromail/mainwindow.cpp2
-rw-r--r--kmicromail/opiemail.cpp1
-rw-r--r--korganizer/koeventviewer.cpp2
8 files changed, 121 insertions, 30 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 9f38f08..ec47a4e 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -1,236 +1,224 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include "resource.h" 29#include "resource.h"
30#include <kresources/manager.h> 30#include <kresources/manager.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kstaticdeleter.h> 33#include <kstaticdeleter.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35 35
36#include "stdaddressbook.h" 36#include "stdaddressbook.h"
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40StdAddressBook *StdAddressBook::mSelf = 0; 40StdAddressBook *StdAddressBook::mSelf = 0;
41bool StdAddressBook::mAutomaticSave = true; 41bool StdAddressBook::mAutomaticSave = true;
42 42
43static KStaticDeleter<StdAddressBook> addressBookDeleter; 43static KStaticDeleter<StdAddressBook> addressBookDeleter;
44 44
45QString StdAddressBook::fileName() 45QString StdAddressBook::fileName()
46{ 46{
47 return locateLocal( "data", "kabc/std.vcf" ); 47 return locateLocal( "data", "kabc/std.vcf" );
48} 48}
49 49
50QString StdAddressBook::directoryName() 50QString StdAddressBook::directoryName()
51{ 51{
52 return locateLocal( "data", "kabc/stdvcf" ); 52 return locateLocal( "data", "kabc/stdvcf" );
53} 53}
54 54
55void StdAddressBook::handleCrash() 55void StdAddressBook::handleCrash()
56{ 56{
57 StdAddressBook::self()->cleanUp(); 57 StdAddressBook::self()->cleanUp();
58} 58}
59 59
60StdAddressBook *StdAddressBook::self() 60StdAddressBook *StdAddressBook::self()
61{ 61{
62 62
63 if ( !mSelf ) 63 if ( !mSelf )
64 { 64 {
65 QString appdir = StdAddressBook::setTempAppDir(); 65 QString appdir = StdAddressBook::setTempAppDir();
66 qDebug("****************************************************** ");
67 qDebug("****************************************************** ");
68 qDebug("****************************************************** ");
69 qDebug("****************************************************** ");
70 qDebug("****************************************************** ");
71// US im am not sure why I have to use the other format here?? 66// US im am not sure why I have to use the other format here??
72#ifdef KAB_EMBEDDED 67#ifdef KAB_EMBEDDED
73 mSelf = addressBookDeleter.setObject( new StdAddressBook ); 68 mSelf = addressBookDeleter.setObject( new StdAddressBook );
74#else //KAB_EMBEDDED 69#else //KAB_EMBEDDED
75 addressBookDeleter.setObject( mSelf, new StdAddressBook ); 70 addressBookDeleter.setObject( mSelf, new StdAddressBook );
76#endif //KAB_EMBEDDED 71#endif //KAB_EMBEDDED
77 KStandardDirs::setAppDir( appdir ); 72 KStandardDirs::setAppDir( appdir );
78 } 73 }
79 74
80 return mSelf; 75 return mSelf;
81} 76}
82 77
83QString StdAddressBook::setTempAppDir() 78QString StdAddressBook::setTempAppDir()
84{ 79{
85 QString appDIR = KStandardDirs::appDir(); 80 QString appDIR = KStandardDirs::appDir();
86#ifdef DESKTOP_VERSION 81#ifdef DESKTOP_VERSION
87 QString appdir = QDir::homeDirPath(); 82 QString appdir = QDir::homeDirPath();
88 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) 83 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
89 appdir += "kaddressbook/"; 84 appdir += "kaddressbook/";
90 else 85 else
91 appdir += "/kaddressbook/"; 86 appdir += "/kaddressbook/";
92 KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); 87 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
93#else 88#else
94 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; 89 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
95 90
96 KStandardDirs::setAppDir( appdir ); 91 KStandardDirs::setAppDir( appdir );
97#endif 92#endif
98 93
99 return appDIR; 94 return appDIR;
100} 95}
101StdAddressBook *StdAddressBook::self( bool onlyFastResources ) 96StdAddressBook *StdAddressBook::self( bool onlyFastResources )
102{ 97{
103 98
104 if ( !mSelf ) 99 if ( !mSelf )
105 { 100 {
106 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
107 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
108 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
109 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
110 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
111 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
112 qDebug("++++++++++++++++++++++++++++++++++++++++++++++++ ");
113 QString appdir =StdAddressBook::setTempAppDir(); 101 QString appdir =StdAddressBook::setTempAppDir();
114#ifdef KAB_EMBEDDED 102#ifdef KAB_EMBEDDED
115 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); 103 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
116#else //KAB_EMBEDDED 104#else //KAB_EMBEDDED
117 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); 105 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
118#endif //KAB_EMBEDDED 106#endif //KAB_EMBEDDED
119 KStandardDirs::setAppDir( appdir ); 107 KStandardDirs::setAppDir( appdir );
120 } 108 }
121 return mSelf; 109 return mSelf;
122} 110}
123 111
124StdAddressBook::StdAddressBook() 112StdAddressBook::StdAddressBook()
125 : AddressBook( "kabcrc" ) 113 : AddressBook( "kabcrc" )
126{ 114{
127 115
128 init( false ); 116 init( false );
129} 117}
130 118
131StdAddressBook::StdAddressBook( bool onlyFastResources ) 119StdAddressBook::StdAddressBook( bool onlyFastResources )
132 : AddressBook( "kabcrc" ) 120 : AddressBook( "kabcrc" )
133{ 121{
134 122
135 init( onlyFastResources ); 123 init( onlyFastResources );
136} 124}
137 125
138StdAddressBook::~StdAddressBook() 126StdAddressBook::~StdAddressBook()
139{ 127{
140 if ( mAutomaticSave ) 128 if ( mAutomaticSave )
141 save(); 129 save();
142} 130}
143 131
144void StdAddressBook::init( bool ) 132void StdAddressBook::init( bool )
145{ 133{
146 KRES::Manager<Resource> *manager = resourceManager(); 134 KRES::Manager<Resource> *manager = resourceManager();
147 KRES::Manager<Resource>::ActiveIterator it; 135 KRES::Manager<Resource>::ActiveIterator it;
148 136
149 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 137 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
150 (*it)->setAddressBook( this ); 138 (*it)->setAddressBook( this );
151 if ( !(*it)->open() ) 139 if ( !(*it)->open() )
152 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 140 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
153 } 141 }
154 142
155 Resource *res = standardResource(); 143 Resource *res = standardResource();
156 if ( !res ) { 144 if ( !res ) {
157 res = manager->createResource( "file" ); 145 res = manager->createResource( "file" );
158 if ( res ) 146 if ( res )
159 { 147 {
160 addResource( res ); 148 addResource( res );
161 } 149 }
162 else 150 else
163 qDebug(" No resource available!!!"); 151 qDebug(" No resource available!!!");
164 } 152 }
165 153
166 setStandardResource( res ); 154 setStandardResource( res );
167 manager->writeConfig(); 155 manager->writeConfig();
168 156
169 load(); 157 load();
170} 158}
171 159
172bool StdAddressBook::save() 160bool StdAddressBook::save()
173{ 161{
174 kdDebug(5700) << "StdAddressBook::save()" << endl; 162 kdDebug(5700) << "StdAddressBook::save()" << endl;
175 163
176 bool ok = true; 164 bool ok = true;
177 AddressBook *ab = self(); 165 AddressBook *ab = self();
178 166
179 ab->deleteRemovedAddressees(); 167 ab->deleteRemovedAddressees();
180 168
181 KRES::Manager<Resource>::ActiveIterator it; 169 KRES::Manager<Resource>::ActiveIterator it;
182 KRES::Manager<Resource> *manager = ab->resourceManager(); 170 KRES::Manager<Resource> *manager = ab->resourceManager();
183 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 171 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
184 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 172 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
185 Ticket *ticket = ab->requestSaveTicket( *it ); 173 Ticket *ticket = ab->requestSaveTicket( *it );
186// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 174// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
187 if ( !ticket ) { 175 if ( !ticket ) {
188 ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) 176 ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
189 .arg( (*it)->resourceName() ) ); 177 .arg( (*it)->resourceName() ) );
190 return false; 178 return false;
191 } 179 }
192 180
193 if ( !ab->save( ticket ) ) 181 if ( !ab->save( ticket ) )
194 ok = false; 182 ok = false;
195 } 183 }
196 } 184 }
197 185
198 return ok; 186 return ok;
199} 187}
200 188
201void StdAddressBook::close() 189void StdAddressBook::close()
202{ 190{
203//US destructObject is not defined on my system???. Is setObject(0) the same ??? 191//US destructObject is not defined on my system???. Is setObject(0) the same ???
204//US addressBookDeleter.destructObject(); 192//US addressBookDeleter.destructObject();
205 addressBookDeleter.setObject(0); 193 addressBookDeleter.setObject(0);
206 194
207} 195}
208 196
209void StdAddressBook::setAutomaticSave( bool enable ) 197void StdAddressBook::setAutomaticSave( bool enable )
210{ 198{
211 mAutomaticSave = enable; 199 mAutomaticSave = enable;
212} 200}
213 201
214bool StdAddressBook::automaticSave() 202bool StdAddressBook::automaticSave()
215{ 203{
216 return mAutomaticSave; 204 return mAutomaticSave;
217} 205}
218 206
219// should get const for 4.X 207// should get const for 4.X
220Addressee StdAddressBook::whoAmI() 208Addressee StdAddressBook::whoAmI()
221{ 209{
222//US KConfig config( "kabcrc" ); 210//US KConfig config( "kabcrc" );
223 KConfig config( locateLocal("config", "kabcrc") ); 211 KConfig config( locateLocal("config", "kabcrc") );
224 config.setGroup( "General" ); 212 config.setGroup( "General" );
225 213
226 return findByUid( config.readEntry( "WhoAmI" ) ); 214 return findByUid( config.readEntry( "WhoAmI" ) );
227} 215}
228 216
229void StdAddressBook::setWhoAmI( const Addressee &addr ) 217void StdAddressBook::setWhoAmI( const Addressee &addr )
230{ 218{
231//US KConfig config( "kabcrc" ); 219//US KConfig config( "kabcrc" );
232 KConfig config( locateLocal("config", "kabcrc") ); 220 KConfig config( locateLocal("config", "kabcrc") );
233 config.setGroup( "General" ); 221 config.setGroup( "General" );
234 222
235 config.writeEntry( "WhoAmI", addr.uid() ); 223 config.writeEntry( "WhoAmI", addr.uid() );
236} 224}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2f9f1df..6522ccc 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2121 +1,2139 @@
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 <libkdepim/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 <qtopia/qcopenvelope_qws.h> 96#include <qtopia/qcopenvelope_qws.h>
97#else 97#else
98 98
99#endif 99#endif
100 100
101#endif // KAB_EMBEDDED 101#endif // KAB_EMBEDDED
102#include "kcmconfigs/kcmkabconfig.h" 102#include "kcmconfigs/kcmkabconfig.h"
103#include "kcmconfigs/kcmkdepimconfig.h" 103#include "kcmconfigs/kcmkdepimconfig.h"
104#include "kpimglobalprefs.h" 104#include "kpimglobalprefs.h"
105#include "externalapphandler.h" 105#include "externalapphandler.h"
106 106
107 107
108#include <kresources/selectdialog.h> 108#include <kresources/selectdialog.h>
109#include <kmessagebox.h> 109#include <kmessagebox.h>
110 110
111#include <picture.h> 111#include <picture.h>
112#include <resource.h> 112#include <resource.h>
113 113
114//US#include <qsplitter.h> 114//US#include <qsplitter.h>
115#include <qmap.h> 115#include <qmap.h>
116#include <qdir.h> 116#include <qdir.h>
117#include <qfile.h> 117#include <qfile.h>
118#include <qvbox.h> 118#include <qvbox.h>
119#include <qlayout.h> 119#include <qlayout.h>
120#include <qclipboard.h> 120#include <qclipboard.h>
121#include <qtextstream.h> 121#include <qtextstream.h>
122 122
123#include <libkdepim/categoryselectdialog.h> 123#include <libkdepim/categoryselectdialog.h>
124#include <kabc/vcardconverter.h> 124#include <kabc/vcardconverter.h>
125 125
126 126
127#include "addresseeutil.h" 127#include "addresseeutil.h"
128#include "undocmds.h" 128#include "undocmds.h"
129#include "addresseeeditordialog.h" 129#include "addresseeeditordialog.h"
130#include "viewmanager.h" 130#include "viewmanager.h"
131#include "details/detailsviewcontainer.h" 131#include "details/detailsviewcontainer.h"
132#include "kabprefs.h" 132#include "kabprefs.h"
133#include "xxportmanager.h" 133#include "xxportmanager.h"
134#include "incsearchwidget.h" 134#include "incsearchwidget.h"
135#include "jumpbuttonbar.h" 135#include "jumpbuttonbar.h"
136#include "extensionmanager.h" 136#include "extensionmanager.h"
137#include "addresseeconfig.h" 137#include "addresseeconfig.h"
138#include <kcmultidialog.h> 138#include <kcmultidialog.h>
139 139
140#ifdef _WIN32_ 140#ifdef _WIN32_
141 141
142#include "kaimportoldialog.h" 142#include "kaimportoldialog.h"
143#endif 143#endif
144 144
145bool pasteWithNewUid = true; 145bool pasteWithNewUid = true;
146 146
147#ifdef KAB_EMBEDDED 147#ifdef KAB_EMBEDDED
148KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 148KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
149 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 149 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
150 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 150 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
151 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 151 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
152#else //KAB_EMBEDDED 152#else //KAB_EMBEDDED
153KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 153KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
154 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 154 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
155 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 155 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
156 mReadWrite( readWrite ), mModified( false ) 156 mReadWrite( readWrite ), mModified( false )
157#endif //KAB_EMBEDDED 157#endif //KAB_EMBEDDED
158{ 158{
159 159
160 mExtensionBarSplitter = 0; 160 mExtensionBarSplitter = 0;
161 mIsPart = !parent->inherits( "KAddressBookMain" ); 161 mIsPart = !parent->inherits( "KAddressBookMain" );
162 162
163 mAddressBook = KABC::StdAddressBook::self(); 163 mAddressBook = KABC::StdAddressBook::self();
164 KABC::StdAddressBook::setAutomaticSave( false ); 164 KABC::StdAddressBook::setAutomaticSave( false );
165 165
166#ifndef KAB_EMBEDDED 166#ifndef KAB_EMBEDDED
167 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 167 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
168#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
169 169
170 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 170 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
171 SLOT( addressBookChanged() ) ); 171 SLOT( addressBookChanged() ) );
172 172
173 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 173 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
174 "X-Department", "KADDRESSBOOK" ); 174 "X-Department", "KADDRESSBOOK" );
175 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 175 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
176 "X-Profession", "KADDRESSBOOK" ); 176 "X-Profession", "KADDRESSBOOK" );
177 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 177 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
178 "X-AssistantsName", "KADDRESSBOOK" ); 178 "X-AssistantsName", "KADDRESSBOOK" );
179 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 179 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
180 "X-ManagersName", "KADDRESSBOOK" ); 180 "X-ManagersName", "KADDRESSBOOK" );
181 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 181 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
182 "X-SpousesName", "KADDRESSBOOK" ); 182 "X-SpousesName", "KADDRESSBOOK" );
183 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 183 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
184 "X-Office", "KADDRESSBOOK" ); 184 "X-Office", "KADDRESSBOOK" );
185 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 185 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
186 "X-IMAddress", "KADDRESSBOOK" ); 186 "X-IMAddress", "KADDRESSBOOK" );
187 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 187 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
188 "X-Anniversary", "KADDRESSBOOK" ); 188 "X-Anniversary", "KADDRESSBOOK" );
189 189
190 //US added this field to become compatible with Opie/qtopia addressbook 190 //US added this field to become compatible with Opie/qtopia addressbook
191 // values can be "female" or "male" or "". An empty field represents undefined. 191 // values can be "female" or "male" or "". An empty field represents undefined.
192 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 192 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
193 "X-Gender", "KADDRESSBOOK" ); 193 "X-Gender", "KADDRESSBOOK" );
194 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 194 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
195 "X-Children", "KADDRESSBOOK" ); 195 "X-Children", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
197 "X-FreeBusyUrl", "KADDRESSBOOK" ); 197 "X-FreeBusyUrl", "KADDRESSBOOK" );
198 198
199 initGUI(); 199 initGUI();
200 200
201 mIncSearchWidget->setFocus(); 201 mIncSearchWidget->setFocus();
202 202
203 203
204 connect( mViewManager, SIGNAL( selected( const QString& ) ), 204 connect( mViewManager, SIGNAL( selected( const QString& ) ),
205 SLOT( setContactSelected( const QString& ) ) ); 205 SLOT( setContactSelected( const QString& ) ) );
206 connect( mViewManager, SIGNAL( executed( const QString& ) ), 206 connect( mViewManager, SIGNAL( executed( const QString& ) ),
207 SLOT( executeContact( const QString& ) ) ); 207 SLOT( executeContact( const QString& ) ) );
208 208
209 connect( mViewManager, SIGNAL( deleteRequest( ) ), 209 connect( mViewManager, SIGNAL( deleteRequest( ) ),
210 SLOT( deleteContacts( ) ) ); 210 SLOT( deleteContacts( ) ) );
211 connect( mViewManager, SIGNAL( modified() ), 211 connect( mViewManager, SIGNAL( modified() ),
212 SLOT( setModified() ) ); 212 SLOT( setModified() ) );
213 213
214 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 214 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
215 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 215 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
216 216
217 connect( mXXPortManager, SIGNAL( modified() ), 217 connect( mXXPortManager, SIGNAL( modified() ),
218 SLOT( setModified() ) ); 218 SLOT( setModified() ) );
219 219
220 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 220 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
221 SLOT( incrementalSearch( const QString& ) ) ); 221 SLOT( incrementalSearch( const QString& ) ) );
222 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 222 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
223 mJumpButtonBar, SLOT( recreateButtons() ) ); 223 mJumpButtonBar, SLOT( recreateButtons() ) );
224 224
225 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 225 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
226 SLOT( sendMail( const QString& ) ) ); 226 SLOT( sendMail( const QString& ) ) );
227 227
228 228
229 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 229 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
230 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&))); 230 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&)));
231 231
232 232
233#ifndef KAB_EMBEDDED 233#ifndef KAB_EMBEDDED
234 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 234 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
235 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 235 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
236 236
237 connect( mDetails, SIGNAL( browse( const QString& ) ), 237 connect( mDetails, SIGNAL( browse( const QString& ) ),
238 SLOT( browse( const QString& ) ) ); 238 SLOT( browse( const QString& ) ) );
239 239
240 240
241 mAddressBookService = new KAddressBookService( this ); 241 mAddressBookService = new KAddressBookService( this );
242 242
243#endif //KAB_EMBEDDED 243#endif //KAB_EMBEDDED
244 mEditorDialog = 0; 244 mEditorDialog = 0;
245 createAddresseeEditorDialog( this ); 245 createAddresseeEditorDialog( this );
246 setModified( false ); 246 setModified( false );
247} 247}
248 248
249KABCore::~KABCore() 249KABCore::~KABCore()
250{ 250{
251 // save(); 251 // save();
252 //saveSettings(); 252 //saveSettings();
253 //KABPrefs::instance()->writeConfig(); 253 //KABPrefs::instance()->writeConfig();
254 delete AddresseeConfig::instance(); 254 delete AddresseeConfig::instance();
255 mAddressBook = 0; 255 mAddressBook = 0;
256 KABC::StdAddressBook::close(); 256 KABC::StdAddressBook::close();
257} 257}
258 258
259void KABCore::restoreSettings() 259void KABCore::restoreSettings()
260{ 260{
261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 261 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
262 262
263 bool state; 263 bool state;
264 264
265 if (mMultipleViewsAtOnce) 265 if (mMultipleViewsAtOnce)
266 state = KABPrefs::instance()->mDetailsPageVisible; 266 state = KABPrefs::instance()->mDetailsPageVisible;
267 else 267 else
268 state = false; 268 state = false;
269 269
270 mActionDetails->setChecked( state ); 270 mActionDetails->setChecked( state );
271 setDetailsVisible( state ); 271 setDetailsVisible( state );
272 272
273 state = KABPrefs::instance()->mJumpButtonBarVisible; 273 state = KABPrefs::instance()->mJumpButtonBarVisible;
274 274
275 mActionJumpBar->setChecked( state ); 275 mActionJumpBar->setChecked( state );
276 setJumpButtonBarVisible( state ); 276 setJumpButtonBarVisible( state );
277/*US 277/*US
278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
279 if ( splitterSize.count() == 0 ) { 279 if ( splitterSize.count() == 0 ) {
280 splitterSize.append( width() / 2 ); 280 splitterSize.append( width() / 2 );
281 splitterSize.append( width() / 2 ); 281 splitterSize.append( width() / 2 );
282 } 282 }
283 mMiniSplitter->setSizes( splitterSize ); 283 mMiniSplitter->setSizes( splitterSize );
284 if ( mExtensionBarSplitter ) { 284 if ( mExtensionBarSplitter ) {
285 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 285 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
286 if ( splitterSize.count() == 0 ) { 286 if ( splitterSize.count() == 0 ) {
287 splitterSize.append( width() / 2 ); 287 splitterSize.append( width() / 2 );
288 splitterSize.append( width() / 2 ); 288 splitterSize.append( width() / 2 );
289 } 289 }
290 mExtensionBarSplitter->setSizes( splitterSize ); 290 mExtensionBarSplitter->setSizes( splitterSize );
291 291
292 } 292 }
293*/ 293*/
294 mViewManager->restoreSettings(); 294 mViewManager->restoreSettings();
295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 295 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
296 mExtensionManager->restoreSettings(); 296 mExtensionManager->restoreSettings();
297 297
298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 298 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
299 if ( splitterSize.count() == 0 ) { 299 if ( splitterSize.count() == 0 ) {
300 splitterSize.append( width() / 2 ); 300 splitterSize.append( width() / 2 );
301 splitterSize.append( width() / 2 ); 301 splitterSize.append( width() / 2 );
302 } 302 }
303 mMiniSplitter->setSizes( splitterSize ); 303 mMiniSplitter->setSizes( splitterSize );
304 if ( mExtensionBarSplitter ) { 304 if ( mExtensionBarSplitter ) {
305 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 305 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
306 if ( splitterSize.count() == 0 ) { 306 if ( splitterSize.count() == 0 ) {
307 splitterSize.append( width() / 2 ); 307 splitterSize.append( width() / 2 );
308 splitterSize.append( width() / 2 ); 308 splitterSize.append( width() / 2 );
309 } 309 }
310 mExtensionBarSplitter->setSizes( splitterSize ); 310 mExtensionBarSplitter->setSizes( splitterSize );
311 311
312 } 312 }
313 313
314 314
315} 315}
316 316
317void KABCore::saveSettings() 317void KABCore::saveSettings()
318{ 318{
319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 319 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
320 if ( mExtensionBarSplitter ) 320 if ( mExtensionBarSplitter )
321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 321 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 322 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 323 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
324#ifndef KAB_EMBEDDED 324#ifndef KAB_EMBEDDED
325 325
326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 326 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 327 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
328#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
329 mExtensionManager->saveSettings(); 329 mExtensionManager->saveSettings();
330 mViewManager->saveSettings(); 330 mViewManager->saveSettings();
331 331
332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 332 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
333} 333}
334 334
335KABC::AddressBook *KABCore::addressBook() const 335KABC::AddressBook *KABCore::addressBook() const
336{ 336{
337 return mAddressBook; 337 return mAddressBook;
338} 338}
339 339
340KConfig *KABCore::config() 340KConfig *KABCore::config()
341{ 341{
342#ifndef KAB_EMBEDDED 342#ifndef KAB_EMBEDDED
343 return KABPrefs::instance()->config(); 343 return KABPrefs::instance()->config();
344#else //KAB_EMBEDDED 344#else //KAB_EMBEDDED
345 return KABPrefs::instance()->getConfig(); 345 return KABPrefs::instance()->getConfig();
346#endif //KAB_EMBEDDED 346#endif //KAB_EMBEDDED
347} 347}
348 348
349KActionCollection *KABCore::actionCollection() const 349KActionCollection *KABCore::actionCollection() const
350{ 350{
351 return mGUIClient->actionCollection(); 351 return mGUIClient->actionCollection();
352} 352}
353 353
354KABC::Field *KABCore::currentSearchField() const 354KABC::Field *KABCore::currentSearchField() const
355{ 355{
356 if (mIncSearchWidget) 356 if (mIncSearchWidget)
357 return mIncSearchWidget->currentField(); 357 return mIncSearchWidget->currentField();
358 else 358 else
359 return 0; 359 return 0;
360} 360}
361 361
362QStringList KABCore::selectedUIDs() const 362QStringList KABCore::selectedUIDs() const
363{ 363{
364 return mViewManager->selectedUids(); 364 return mViewManager->selectedUids();
365} 365}
366 366
367KABC::Resource *KABCore::requestResource( QWidget *parent ) 367KABC::Resource *KABCore::requestResource( QWidget *parent )
368{ 368{
369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 369 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
370 370
371 QPtrList<KRES::Resource> kresResources; 371 QPtrList<KRES::Resource> kresResources;
372 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 372 QPtrListIterator<KABC::Resource> resIt( kabcResources );
373 KABC::Resource *resource; 373 KABC::Resource *resource;
374 while ( ( resource = resIt.current() ) != 0 ) { 374 while ( ( resource = resIt.current() ) != 0 ) {
375 ++resIt; 375 ++resIt;
376 if ( !resource->readOnly() ) { 376 if ( !resource->readOnly() ) {
377 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 377 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
378 if ( res ) 378 if ( res )
379 kresResources.append( res ); 379 kresResources.append( res );
380 } 380 }
381 } 381 }
382 382
383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 383 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
384 return static_cast<KABC::Resource*>( res ); 384 return static_cast<KABC::Resource*>( res );
385} 385}
386 386
387#ifndef KAB_EMBEDDED 387#ifndef KAB_EMBEDDED
388KAboutData *KABCore::createAboutData() 388KAboutData *KABCore::createAboutData()
389#else //KAB_EMBEDDED 389#else //KAB_EMBEDDED
390void KABCore::createAboutData() 390void KABCore::createAboutData()
391#endif //KAB_EMBEDDED 391#endif //KAB_EMBEDDED
392{ 392{
393#ifndef KAB_EMBEDDED 393#ifndef KAB_EMBEDDED
394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 394 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
395 "3.1", I18N_NOOP( "The KDE Address Book" ), 395 "3.1", I18N_NOOP( "The KDE Address Book" ),
396 KAboutData::License_GPL_V2, 396 KAboutData::License_GPL_V2,
397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 397 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 398 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 399 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
400 about->addAuthor( "Cornelius Schumacher", 400 about->addAuthor( "Cornelius Schumacher",
401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 401 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
402 "schumacher@kde.org" ); 402 "schumacher@kde.org" );
403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 403 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
404 "mpilone@slac.com" ); 404 "mpilone@slac.com" );
405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 405 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 406 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 407 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
408 "michel@klaralvdalens-datakonsult.se" ); 408 "michel@klaralvdalens-datakonsult.se" );
409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 409 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
410 "hansen@kde.org" ); 410 "hansen@kde.org" );
411 411
412 return about; 412 return about;
413#endif //KAB_EMBEDDED 413#endif //KAB_EMBEDDED
414 414
415 QString version; 415 QString version;
416#include <../version> 416#include <../version>
417 QMessageBox::about( this, "About KAddressbook/Pi", 417 QMessageBox::about( this, "About KAddressbook/Pi",
418 "KAddressbook/Platform-independent\n" 418 "KAddressbook/Platform-independent\n"
419 "(KA/Pi) " +version + " - " + 419 "(KA/Pi) " +version + " - " +
420#ifdef DESKTOP_VERSION 420#ifdef DESKTOP_VERSION
421 "Desktop Edition\n" 421 "Desktop Edition\n"
422#else 422#else
423 "PDA-Edition\n" 423 "PDA-Edition\n"
424 "for: Zaurus 5500 / 7x0 / 8x0\n" 424 "for: Zaurus 5500 / 7x0 / 8x0\n"
425#endif 425#endif
426 426
427 "(c) 2004 Ulf Schenk\n" 427 "(c) 2004 Ulf Schenk\n"
428 "(c) 2004 Lutz Rogowski\n" 428 "(c) 2004 Lutz Rogowski\n"
429 "(c) 1997-2003, The KDE PIM Team\n" 429 "(c) 1997-2003, The KDE PIM Team\n"
430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 430 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
431 "Don Sanders Original author\n" 431 "Don Sanders Original author\n"
432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 432 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 433 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
434 "Greg Stern DCOP interface\n" 434 "Greg Stern DCOP interface\n"
435 "Mark Westcot Contact pinning\n" 435 "Mark Westcot Contact pinning\n"
436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 436 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 437 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
438#ifdef _WIN32_ 438#ifdef _WIN32_
439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 439 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
440#endif 440#endif
441 ); 441 );
442} 442}
443 443
444void KABCore::setContactSelected( const QString &uid ) 444void KABCore::setContactSelected( const QString &uid )
445{ 445{
446 KABC::Addressee addr = mAddressBook->findByUid( uid ); 446 KABC::Addressee addr = mAddressBook->findByUid( uid );
447 if ( !mDetails->isHidden() ) 447 if ( !mDetails->isHidden() )
448 mDetails->setAddressee( addr ); 448 mDetails->setAddressee( addr );
449 449
450 if ( !addr.isEmpty() ) { 450 if ( !addr.isEmpty() ) {
451 emit contactSelected( addr.formattedName() ); 451 emit contactSelected( addr.formattedName() );
452 KABC::Picture pic = addr.photo(); 452 KABC::Picture pic = addr.photo();
453 if ( pic.isIntern() ) { 453 if ( pic.isIntern() ) {
454//US emit contactSelected( pic.data() ); 454//US emit contactSelected( pic.data() );
455//US instead use: 455//US instead use:
456 QPixmap px; 456 QPixmap px;
457 if (pic.data().isNull() != true) 457 if (pic.data().isNull() != true)
458 { 458 {
459 px.convertFromImage(pic.data()); 459 px.convertFromImage(pic.data());
460 } 460 }
461 461
462 emit contactSelected( px ); 462 emit contactSelected( px );
463 } 463 }
464 } 464 }
465 465
466 466
467 mExtensionManager->setSelectionChanged(); 467 mExtensionManager->setSelectionChanged();
468 468
469 // update the actions 469 // update the actions
470 bool selected = !uid.isEmpty(); 470 bool selected = !uid.isEmpty();
471 471
472 if ( mReadWrite ) { 472 if ( mReadWrite ) {
473 mActionCut->setEnabled( selected ); 473 mActionCut->setEnabled( selected );
474 mActionPaste->setEnabled( selected ); 474 mActionPaste->setEnabled( selected );
475 } 475 }
476 476
477 mActionCopy->setEnabled( selected ); 477 mActionCopy->setEnabled( selected );
478 mActionDelete->setEnabled( selected ); 478 mActionDelete->setEnabled( selected );
479 mActionEditAddressee->setEnabled( selected ); 479 mActionEditAddressee->setEnabled( selected );
480 mActionMail->setEnabled( selected ); 480 mActionMail->setEnabled( selected );
481 mActionMailVCard->setEnabled( selected ); 481 mActionMailVCard->setEnabled( selected );
482 //if (mActionBeam) 482 //if (mActionBeam)
483 //mActionBeam->setEnabled( selected ); 483 //mActionBeam->setEnabled( selected );
484 484
485 if (mActionBeamVCard) 485 if (mActionBeamVCard)
486 mActionBeamVCard->setEnabled( selected ); 486 mActionBeamVCard->setEnabled( selected );
487 487
488 mActionWhoAmI->setEnabled( selected ); 488 mActionWhoAmI->setEnabled( selected );
489 mActionCategories->setEnabled( selected ); 489 mActionCategories->setEnabled( selected );
490} 490}
491 491
492void KABCore::sendMail() 492void KABCore::sendMail()
493{ 493{
494 sendMail( mViewManager->selectedEmails().join( ", " ) ); 494 sendMail( mViewManager->selectedEmails().join( ", " ) );
495} 495}
496 496
497void KABCore::sendMail( const QString& emaillist ) 497void KABCore::sendMail( const QString& emaillist )
498{ 498{
499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 499 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
500 if (emaillist.contains(",") > 0) 500 if (emaillist.contains(",") > 0)
501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 501 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
502 else 502 else
503 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 503 ExternalAppHandler::instance()->mailToOneContact( emaillist );
504} 504}
505 505
506 506
507 507
508void KABCore::mailVCard() 508void KABCore::mailVCard()
509{ 509{
510 QStringList uids = mViewManager->selectedUids(); 510 QStringList uids = mViewManager->selectedUids();
511 if ( !uids.isEmpty() ) 511 if ( !uids.isEmpty() )
512 mailVCard( uids ); 512 mailVCard( uids );
513} 513}
514 514
515void KABCore::mailVCard( const QStringList& uids ) 515void KABCore::mailVCard( const QStringList& uids )
516{ 516{
517 QStringList urls; 517 QStringList urls;
518 518
519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 519// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
520 520
521 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 521 QString dirName = "/tmp/" + KApplication::randomString( 8 );
522 522
523 523
524 524
525 QDir().mkdir( dirName, true ); 525 QDir().mkdir( dirName, true );
526 526
527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
528 KABC::Addressee a = mAddressBook->findByUid( *it ); 528 KABC::Addressee a = mAddressBook->findByUid( *it );
529 529
530 if ( a.isEmpty() ) 530 if ( a.isEmpty() )
531 continue; 531 continue;
532 532
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 533 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 534
535 QString fileName = dirName + "/" + name; 535 QString fileName = dirName + "/" + name;
536 536
537 QFile outFile(fileName); 537 QFile outFile(fileName);
538 538
539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 539 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
540 KABC::VCardConverter converter; 540 KABC::VCardConverter converter;
541 QString vcard; 541 QString vcard;
542 542
543 converter.addresseeToVCard( a, vcard ); 543 converter.addresseeToVCard( a, vcard );
544 544
545 QTextStream t( &outFile ); // use a text stream 545 QTextStream t( &outFile ); // use a text stream
546 t.setEncoding( QTextStream::UnicodeUTF8 ); 546 t.setEncoding( QTextStream::UnicodeUTF8 );
547 t << vcard; 547 t << vcard;
548 548
549 outFile.close(); 549 outFile.close();
550 550
551 urls.append( fileName ); 551 urls.append( fileName );
552 } 552 }
553 } 553 }
554 554
555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 555 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
556 556
557 557
558/*US 558/*US
559 kapp->invokeMailer( QString::null, QString::null, QString::null, 559 kapp->invokeMailer( QString::null, QString::null, QString::null,
560 QString::null, // subject 560 QString::null, // subject
561 QString::null, // body 561 QString::null, // body
562 QString::null, 562 QString::null,
563 urls ); // attachments 563 urls ); // attachments
564*/ 564*/
565 565
566} 566}
567 567
568/** 568/**
569 Beams the "WhoAmI contact. 569 Beams the "WhoAmI contact.
570*/ 570*/
571void KABCore::beamMySelf() 571void KABCore::beamMySelf()
572{ 572{
573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 573 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
574 if (!a.isEmpty()) 574 if (!a.isEmpty())
575 { 575 {
576 QStringList uids; 576 QStringList uids;
577 uids << a.uid(); 577 uids << a.uid();
578 578
579 beamVCard(uids); 579 beamVCard(uids);
580 } else { 580 } else {
581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 581 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
582 582
583 583
584 } 584 }
585} 585}
586 586
587void KABCore::beamVCard() 587void KABCore::beamVCard()
588{ 588{
589 QStringList uids = mViewManager->selectedUids(); 589 QStringList uids = mViewManager->selectedUids();
590 if ( !uids.isEmpty() ) 590 if ( !uids.isEmpty() )
591 beamVCard( uids ); 591 beamVCard( uids );
592} 592}
593 593
594 594
595void KABCore::beamVCard(const QStringList& uids) 595void KABCore::beamVCard(const QStringList& uids)
596{ 596{
597/*US 597/*US
598 QString beamFilename; 598 QString beamFilename;
599 Opie::OPimContact c; 599 Opie::OPimContact c;
600 if ( actionPersonal->isOn() ) { 600 if ( actionPersonal->isOn() ) {
601 beamFilename = addressbookPersonalVCardName(); 601 beamFilename = addressbookPersonalVCardName();
602 if ( !QFile::exists( beamFilename ) ) 602 if ( !QFile::exists( beamFilename ) )
603 return; // can't beam a non-existent file 603 return; // can't beam a non-existent file
604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 604 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
605 beamFilename ); 605 beamFilename );
606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 606 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
607 Opie::OPimContactAccess::List allList = access->allRecords(); 607 Opie::OPimContactAccess::List allList = access->allRecords();
608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 608 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
609 c = *it; 609 c = *it;
610 610
611 delete access; 611 delete access;
612 } else { 612 } else {
613 unlink( beamfile ); // delete if exists 613 unlink( beamfile ); // delete if exists
614 mkdir("/tmp/obex/", 0755); 614 mkdir("/tmp/obex/", 0755);
615 c = m_abView -> currentEntry(); 615 c = m_abView -> currentEntry();
616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 616 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
617 beamfile ); 617 beamfile );
618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 618 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
619 access->add( c ); 619 access->add( c );
620 access->save(); 620 access->save();
621 delete access; 621 delete access;
622 622
623 beamFilename = beamfile; 623 beamFilename = beamfile;
624 } 624 }
625 625
626 owarn << "Beaming: " << beamFilename << oendl; 626 owarn << "Beaming: " << beamFilename << oendl;
627*/ 627*/
628 628
629#if 0 629#if 0
630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 630 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
631 631
632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 632 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
633 633
634 QString name = "contact.vcf"; 634 QString name = "contact.vcf";
635 635
636 QString fileName = dirName + "/" + name; 636 QString fileName = dirName + "/" + name;
637#endif 637#endif
638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 638 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
639 // 639 //
640 QString fileName = "/tmp/kdepimbeamfile"; 640 QString fileName = "/tmp/kdepimbeamfile";
641 641
642 642
643 //QDir().mkdir( dirName, true ); 643 //QDir().mkdir( dirName, true );
644 644
645 QFile outFile(fileName); 645 QFile outFile(fileName);
646 KABC::VCardConverter converter; 646 KABC::VCardConverter converter;
647 QString description; 647 QString description;
648 648
649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 649 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
650 650
651 QTextStream t( &outFile ); // use a text stream 651 QTextStream t( &outFile ); // use a text stream
652 t.setEncoding( QTextStream::UnicodeUTF8 ); 652 t.setEncoding( QTextStream::UnicodeUTF8 );
653 653
654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 654 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
655 KABC::Addressee a = mAddressBook->findByUid( *it ); 655 KABC::Addressee a = mAddressBook->findByUid( *it );
656 656
657 if ( a.isEmpty() ) 657 if ( a.isEmpty() )
658 continue; 658 continue;
659 659
660 if (description.isEmpty()) 660 if (description.isEmpty())
661 description = a.formattedName(); 661 description = a.formattedName();
662 662
663 QString vcard; 663 QString vcard;
664 converter.addresseeToVCard( a, vcard ); 664 converter.addresseeToVCard( a, vcard );
665 t << vcard; 665 t << vcard;
666 666
667 } 667 }
668 } else { 668 } else {
669 qDebug("Error open temp beam file "); 669 qDebug("Error open temp beam file ");
670 return; 670 return;
671 } 671 }
672 672
673 outFile.close(); 673 outFile.close();
674 674
675#ifndef DESKTOP_VERSION 675#ifndef DESKTOP_VERSION
676 Ir *ir = new Ir( this ); 676 Ir *ir = new Ir( this );
677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 677 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
678 ir->send( fileName, description, "text/x-vCard" ); 678 ir->send( fileName, description, "text/x-vCard" );
679#endif 679#endif
680 680
681} 681}
682 682
683void KABCore::beamDone( Ir *ir ) 683void KABCore::beamDone( Ir *ir )
684{ 684{
685#ifndef DESKTOP_VERSION 685#ifndef DESKTOP_VERSION
686 delete ir; 686 delete ir;
687#endif 687#endif
688} 688}
689 689
690 690
691void KABCore::browse( const QString& url ) 691void KABCore::browse( const QString& url )
692{ 692{
693#ifndef KAB_EMBEDDED 693#ifndef KAB_EMBEDDED
694 kapp->invokeBrowser( url ); 694 kapp->invokeBrowser( url );
695#else //KAB_EMBEDDED 695#else //KAB_EMBEDDED
696 qDebug("KABCore::browse must be fixed"); 696 qDebug("KABCore::browse must be fixed");
697#endif //KAB_EMBEDDED 697#endif //KAB_EMBEDDED
698} 698}
699 699
700void KABCore::selectAllContacts() 700void KABCore::selectAllContacts()
701{ 701{
702 mViewManager->setSelected( QString::null, true ); 702 mViewManager->setSelected( QString::null, true );
703} 703}
704 704
705void KABCore::deleteContacts() 705void KABCore::deleteContacts()
706{ 706{
707 QStringList uidList = mViewManager->selectedUids(); 707 QStringList uidList = mViewManager->selectedUids();
708 deleteContacts( uidList ); 708 deleteContacts( uidList );
709} 709}
710 710
711void KABCore::deleteContacts( const QStringList &uids ) 711void KABCore::deleteContacts( const QStringList &uids )
712{ 712{
713 if ( uids.count() > 0 ) { 713 if ( uids.count() > 0 ) {
714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 714 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
715 UndoStack::instance()->push( command ); 715 UndoStack::instance()->push( command );
716 RedoStack::instance()->clear(); 716 RedoStack::instance()->clear();
717 717
718 // now if we deleted anything, refresh 718 // now if we deleted anything, refresh
719 setContactSelected( QString::null ); 719 setContactSelected( QString::null );
720 setModified( true ); 720 setModified( true );
721 } 721 }
722} 722}
723 723
724void KABCore::copyContacts() 724void KABCore::copyContacts()
725{ 725{
726 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 726 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
727 727
728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 728 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
729 729
730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 730 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
731 731
732 QClipboard *cb = QApplication::clipboard(); 732 QClipboard *cb = QApplication::clipboard();
733 cb->setText( clipText ); 733 cb->setText( clipText );
734} 734}
735 735
736void KABCore::cutContacts() 736void KABCore::cutContacts()
737{ 737{
738 QStringList uidList = mViewManager->selectedUids(); 738 QStringList uidList = mViewManager->selectedUids();
739 739
740//US if ( uidList.size() > 0 ) { 740//US if ( uidList.size() > 0 ) {
741 if ( uidList.count() > 0 ) { 741 if ( uidList.count() > 0 ) {
742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 742 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
743 UndoStack::instance()->push( command ); 743 UndoStack::instance()->push( command );
744 RedoStack::instance()->clear(); 744 RedoStack::instance()->clear();
745 745
746 setModified( true ); 746 setModified( true );
747 } 747 }
748} 748}
749 749
750void KABCore::pasteContacts() 750void KABCore::pasteContacts()
751{ 751{
752 QClipboard *cb = QApplication::clipboard(); 752 QClipboard *cb = QApplication::clipboard();
753 753
754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 754 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
755 755
756 pasteContacts( list ); 756 pasteContacts( list );
757} 757}
758 758
759void KABCore::pasteContacts( KABC::Addressee::List &list ) 759void KABCore::pasteContacts( KABC::Addressee::List &list )
760{ 760{
761 KABC::Resource *resource = requestResource( this ); 761 KABC::Resource *resource = requestResource( this );
762 KABC::Addressee::List::Iterator it; 762 KABC::Addressee::List::Iterator it;
763 for ( it = list.begin(); it != list.end(); ++it ) 763 for ( it = list.begin(); it != list.end(); ++it )
764 (*it).setResource( resource ); 764 (*it).setResource( resource );
765 765
766 PwPasteCommand *command = new PwPasteCommand( this, list ); 766 PwPasteCommand *command = new PwPasteCommand( this, list );
767 UndoStack::instance()->push( command ); 767 UndoStack::instance()->push( command );
768 RedoStack::instance()->clear(); 768 RedoStack::instance()->clear();
769 769
770 setModified( true ); 770 setModified( true );
771} 771}
772 772
773void KABCore::setWhoAmI() 773void KABCore::setWhoAmI()
774{ 774{
775 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 775 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
776 776
777 if ( addrList.count() > 1 ) { 777 if ( addrList.count() > 1 ) {
778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
779 return; 779 return;
780 } 780 }
781 781
782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
785} 785}
786 786
787void KABCore::setCategories() 787void KABCore::setCategories()
788{ 788{
789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
790 if ( !dlg.exec() ) 790 if ( !dlg.exec() )
791 return; 791 return;
792 792
793 bool merge = false; 793 bool merge = false;
794 QString msg = i18n( "Merge with existing categories?" ); 794 QString msg = i18n( "Merge with existing categories?" );
795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
796 merge = true; 796 merge = true;
797 797
798 QStringList categories = dlg.selectedCategories(); 798 QStringList categories = dlg.selectedCategories();
799 799
800 QStringList uids = mViewManager->selectedUids(); 800 QStringList uids = mViewManager->selectedUids();
801 QStringList::Iterator it; 801 QStringList::Iterator it;
802 for ( it = uids.begin(); it != uids.end(); ++it ) { 802 for ( it = uids.begin(); it != uids.end(); ++it ) {
803 KABC::Addressee addr = mAddressBook->findByUid( *it ); 803 KABC::Addressee addr = mAddressBook->findByUid( *it );
804 if ( !addr.isEmpty() ) { 804 if ( !addr.isEmpty() ) {
805 if ( !merge ) 805 if ( !merge )
806 addr.setCategories( categories ); 806 addr.setCategories( categories );
807 else { 807 else {
808 QStringList addrCategories = addr.categories(); 808 QStringList addrCategories = addr.categories();
809 QStringList::Iterator catIt; 809 QStringList::Iterator catIt;
810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
811 if ( !addrCategories.contains( *catIt ) ) 811 if ( !addrCategories.contains( *catIt ) )
812 addrCategories.append( *catIt ); 812 addrCategories.append( *catIt );
813 } 813 }
814 addr.setCategories( addrCategories ); 814 addr.setCategories( addrCategories );
815 } 815 }
816 816
817 mAddressBook->insertAddressee( addr ); 817 mAddressBook->insertAddressee( addr );
818 } 818 }
819 } 819 }
820 820
821 if ( uids.count() > 0 ) 821 if ( uids.count() > 0 )
822 setModified( true ); 822 setModified( true );
823} 823}
824 824
825void KABCore::setSearchFields( const KABC::Field::List &fields ) 825void KABCore::setSearchFields( const KABC::Field::List &fields )
826{ 826{
827 mIncSearchWidget->setFields( fields ); 827 mIncSearchWidget->setFields( fields );
828} 828}
829 829
830void KABCore::incrementalSearch( const QString& text ) 830void KABCore::incrementalSearch( const QString& text )
831{ 831{
832 mViewManager->setSelected( QString::null, false ); 832 mViewManager->setSelected( QString::null, false );
833 833
834 if ( !text.isEmpty() ) { 834 if ( !text.isEmpty() ) {
835 KABC::Field *field = mIncSearchWidget->currentField(); 835 KABC::Field *field = mIncSearchWidget->currentField();
836 QString pattern = text.lower()+"*"; 836 QString pattern = text.lower()+"*";
837 QRegExp re; 837 QRegExp re;
838 re.setWildcard(true); // most people understand these better. 838 re.setWildcard(true); // most people understand these better.
839 re.setCaseSensitive(false); 839 re.setCaseSensitive(false);
840 re.setPattern( pattern ); 840 re.setPattern( pattern );
841 QStringList foundUids; 841 QStringList foundUids;
842 if (!re.isValid()) 842 if (!re.isValid())
843 return; 843 return;
844#if 1 //KDE_VERSION >= 319 844#if 1 //KDE_VERSION >= 319
845 KABC::AddresseeList list( mAddressBook->allAddressees() ); 845 KABC::AddresseeList list( mAddressBook->allAddressees() );
846 if ( field ) { 846 if ( field ) {
847 list.sortByField( field ); 847 list.sortByField( field );
848 KABC::AddresseeList::Iterator it; 848 KABC::AddresseeList::Iterator it;
849 for ( it = list.begin(); it != list.end(); ++it ) { 849 for ( it = list.begin(); it != list.end(); ++it ) {
850 850
851#if QT_VERSION >= 300 851#if QT_VERSION >= 300
852 if (re.search(field->value( *it ).lower()) != -1) 852 if (re.search(field->value( *it ).lower()) != -1)
853#else 853#else
854 if (re.match(field->value( *it ).lower()) != -1) 854 if (re.match(field->value( *it ).lower()) != -1)
855#endif 855#endif
856 { 856 {
857 // if ( field->value( *it ).lower().startsWith( pattern ) ) { 857 // if ( field->value( *it ).lower().startsWith( pattern ) ) {
858 //mViewManager->setSelected( (*it).uid(), true ); 858 //mViewManager->setSelected( (*it).uid(), true );
859 foundUids.append( (*it).uid() ); 859 foundUids.append( (*it).uid() );
860 //return; 860 //return;
861 } 861 }
862 } 862 }
863 } else { 863 } else {
864 KABC::AddresseeList::Iterator it; 864 KABC::AddresseeList::Iterator it;
865 for ( it = list.begin(); it != list.end(); ++it ) { 865 for ( it = list.begin(); it != list.end(); ++it ) {
866 KABC::Field::List fieldList = mIncSearchWidget->fields(); 866 KABC::Field::List fieldList = mIncSearchWidget->fields();
867 KABC::Field::List::ConstIterator fieldIt; 867 KABC::Field::List::ConstIterator fieldIt;
868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
869#if QT_VERSION >= 300 869#if QT_VERSION >= 300
870 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 870 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
871#else 871#else
872 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 872 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
873#endif 873#endif
874 { 874 {
875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
876 //mViewManager->setSelected( (*it).uid(), true ); 876 //mViewManager->setSelected( (*it).uid(), true );
877 foundUids.append( (*it).uid() ); 877 foundUids.append( (*it).uid() );
878 //return; 878 //return;
879 } 879 }
880 } 880 }
881 } 881 }
882 } 882 }
883 if ( foundUids.count() > 0 ) 883 if ( foundUids.count() > 0 )
884 mViewManager->setListSelected( foundUids ); 884 mViewManager->setListSelected( foundUids );
885#else 885#else
886 KABC::AddressBook::Iterator it; 886 KABC::AddressBook::Iterator it;
887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
888 if ( field ) { 888 if ( field ) {
889 if ( field->value( *it ).lower().startsWith( pattern ) ) { 889 if ( field->value( *it ).lower().startsWith( pattern ) ) {
890 mViewManager->setSelected( (*it).uid(), true ); 890 mViewManager->setSelected( (*it).uid(), true );
891 return; 891 return;
892 } 892 }
893 } else { 893 } else {
894 KABC::Field::List fieldList = mIncSearchWidget->fields(); 894 KABC::Field::List fieldList = mIncSearchWidget->fields();
895 KABC::Field::List::ConstIterator fieldIt; 895 KABC::Field::List::ConstIterator fieldIt;
896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
898 mViewManager->setSelected( (*it).uid(), true ); 898 mViewManager->setSelected( (*it).uid(), true );
899 return; 899 return;
900 } 900 }
901 } 901 }
902 } 902 }
903 } 903 }
904#endif 904#endif
905 } 905 }
906} 906}
907 907
908void KABCore::setModified() 908void KABCore::setModified()
909{ 909{
910 setModified( true ); 910 setModified( true );
911} 911}
912 912
913void KABCore::setModifiedWOrefresh() 913void KABCore::setModifiedWOrefresh()
914{ 914{
915 // qDebug("KABCore::setModifiedWOrefresh() "); 915 // qDebug("KABCore::setModifiedWOrefresh() ");
916 mModified = true; 916 mModified = true;
917 mActionSave->setEnabled( mModified ); 917 mActionSave->setEnabled( mModified );
918#ifdef DESKTOP_VERSION 918#ifdef DESKTOP_VERSION
919 mDetails->refreshView(); 919 mDetails->refreshView();
920#endif 920#endif
921 921
922} 922}
923void KABCore::setModified( bool modified ) 923void KABCore::setModified( bool modified )
924{ 924{
925 mModified = modified; 925 mModified = modified;
926 mActionSave->setEnabled( mModified ); 926 mActionSave->setEnabled( mModified );
927 927
928 if ( modified ) 928 if ( modified )
929 mJumpButtonBar->recreateButtons(); 929 mJumpButtonBar->recreateButtons();
930 930
931 mViewManager->refreshView(); 931 mViewManager->refreshView();
932 mDetails->refreshView(); 932 mDetails->refreshView();
933 933
934} 934}
935 935
936bool KABCore::modified() const 936bool KABCore::modified() const
937{ 937{
938 return mModified; 938 return mModified;
939} 939}
940 940
941void KABCore::contactModified( const KABC::Addressee &addr ) 941void KABCore::contactModified( const KABC::Addressee &addr )
942{ 942{
943 943
944 Command *command = 0; 944 Command *command = 0;
945 QString uid; 945 QString uid;
946 946
947 // check if it exists already 947 // check if it exists already
948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
949 if ( origAddr.isEmpty() ) 949 if ( origAddr.isEmpty() )
950 command = new PwNewCommand( mAddressBook, addr ); 950 command = new PwNewCommand( mAddressBook, addr );
951 else { 951 else {
952 command = new PwEditCommand( mAddressBook, origAddr, addr ); 952 command = new PwEditCommand( mAddressBook, origAddr, addr );
953 uid = addr.uid(); 953 uid = addr.uid();
954 } 954 }
955 955
956 UndoStack::instance()->push( command ); 956 UndoStack::instance()->push( command );
957 RedoStack::instance()->clear(); 957 RedoStack::instance()->clear();
958 958
959 setModified( true ); 959 setModified( true );
960} 960}
961 961
962void KABCore::newContact() 962void KABCore::newContact()
963{ 963{
964 964
965 965
966 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 966 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
967 967
968 QPtrList<KRES::Resource> kresResources; 968 QPtrList<KRES::Resource> kresResources;
969 QPtrListIterator<KABC::Resource> it( kabcResources ); 969 QPtrListIterator<KABC::Resource> it( kabcResources );
970 KABC::Resource *resource; 970 KABC::Resource *resource;
971 while ( ( resource = it.current() ) != 0 ) { 971 while ( ( resource = it.current() ) != 0 ) {
972 ++it; 972 ++it;
973 if ( !resource->readOnly() ) { 973 if ( !resource->readOnly() ) {
974 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 974 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
975 if ( res ) 975 if ( res )
976 kresResources.append( res ); 976 kresResources.append( res );
977 } 977 }
978 } 978 }
979 979
980 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 980 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
981 resource = static_cast<KABC::Resource*>( res ); 981 resource = static_cast<KABC::Resource*>( res );
982 982
983 if ( resource ) { 983 if ( resource ) {
984 KABC::Addressee addr; 984 KABC::Addressee addr;
985 addr.setResource( resource ); 985 addr.setResource( resource );
986 mEditorDialog->setAddressee( addr ); 986 mEditorDialog->setAddressee( addr );
987 KApplication::execDialog ( mEditorDialog ); 987 KApplication::execDialog ( mEditorDialog );
988 988
989 } else 989 } else
990 return; 990 return;
991 991
992 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 992 // mEditorDict.insert( dialog->addressee().uid(), dialog );
993 993
994 994
995} 995}
996 996
997void KABCore::addEmail( QString aStr ) 997void KABCore::addEmail( QString aStr )
998{ 998{
999#ifndef KAB_EMBEDDED 999#ifndef KAB_EMBEDDED
1000 QString fullName, email; 1000 QString fullName, email;
1001 1001
1002 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1002 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1003 1003
1004 // Try to lookup the addressee matching the email address 1004 // Try to lookup the addressee matching the email address
1005 bool found = false; 1005 bool found = false;
1006 QStringList emailList; 1006 QStringList emailList;
1007 KABC::AddressBook::Iterator it; 1007 KABC::AddressBook::Iterator it;
1008 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1008 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1009 emailList = (*it).emails(); 1009 emailList = (*it).emails();
1010 if ( emailList.contains( email ) > 0 ) { 1010 if ( emailList.contains( email ) > 0 ) {
1011 found = true; 1011 found = true;
1012 (*it).setNameFromString( fullName ); 1012 (*it).setNameFromString( fullName );
1013 editContact( (*it).uid() ); 1013 editContact( (*it).uid() );
1014 } 1014 }
1015 } 1015 }
1016 1016
1017 if ( !found ) { 1017 if ( !found ) {
1018 KABC::Addressee addr; 1018 KABC::Addressee addr;
1019 addr.setNameFromString( fullName ); 1019 addr.setNameFromString( fullName );
1020 addr.insertEmail( email, true ); 1020 addr.insertEmail( email, true );
1021 1021
1022 mAddressBook->insertAddressee( addr ); 1022 mAddressBook->insertAddressee( addr );
1023 mViewManager->refreshView( addr.uid() ); 1023 mViewManager->refreshView( addr.uid() );
1024 editContact( addr.uid() ); 1024 editContact( addr.uid() );
1025 } 1025 }
1026#else //KAB_EMBEDDED 1026#else //KAB_EMBEDDED
1027 qDebug("KABCore::addEmail finsih method"); 1027 qDebug("KABCore::addEmail finsih method");
1028#endif //KAB_EMBEDDED 1028#endif //KAB_EMBEDDED
1029} 1029}
1030 1030
1031void KABCore::importVCard( const KURL &url, bool showPreview ) 1031void KABCore::importVCard( const KURL &url, bool showPreview )
1032{ 1032{
1033 mXXPortManager->importVCard( url, showPreview ); 1033 mXXPortManager->importVCard( url, showPreview );
1034} 1034}
1035void KABCore::importFromOL() 1035void KABCore::importFromOL()
1036{ 1036{
1037#ifdef _WIN32_ 1037#ifdef _WIN32_
1038 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1038 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1039 idgl->exec(); 1039 idgl->exec();
1040 KABC::Addressee::List list = idgl->getAddressList(); 1040 KABC::Addressee::List list = idgl->getAddressList();
1041 if ( list.count() > 0 ) { 1041 if ( list.count() > 0 ) {
1042 KABC::Addressee::List listNew; 1042 KABC::Addressee::List listNew;
1043 KABC::Addressee::List listExisting; 1043 KABC::Addressee::List listExisting;
1044 KABC::Addressee::List::Iterator it; 1044 KABC::Addressee::List::Iterator it;
1045 KABC::AddressBook::Iterator iter; 1045 KABC::AddressBook::Iterator iter;
1046 for ( it = list.begin(); it != list.end(); ++it ) { 1046 for ( it = list.begin(); it != list.end(); ++it ) {
1047 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1047 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1048 listNew.append( (*it) ); 1048 listNew.append( (*it) );
1049 else 1049 else
1050 listExisting.append( (*it) ); 1050 listExisting.append( (*it) );
1051 } 1051 }
1052 if ( listExisting.count() > 0 ) 1052 if ( listExisting.count() > 0 )
1053 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1053 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1054 if ( listNew.count() > 0 ) { 1054 if ( listNew.count() > 0 ) {
1055 pasteWithNewUid = false; 1055 pasteWithNewUid = false;
1056 pasteContacts( listNew ); 1056 pasteContacts( listNew );
1057 pasteWithNewUid = true; 1057 pasteWithNewUid = true;
1058 } 1058 }
1059 } 1059 }
1060 delete idgl; 1060 delete idgl;
1061#endif 1061#endif
1062} 1062}
1063 1063
1064void KABCore::importVCard( const QString &vCard, bool showPreview ) 1064void KABCore::importVCard( const QString &vCard, bool showPreview )
1065{ 1065{
1066 mXXPortManager->importVCard( vCard, showPreview ); 1066 mXXPortManager->importVCard( vCard, showPreview );
1067} 1067}
1068 1068
1069//US added a second method without defaultparameter 1069//US added a second method without defaultparameter
1070void KABCore::editContact2() { 1070void KABCore::editContact2() {
1071 editContact( QString::null ); 1071 editContact( QString::null );
1072} 1072}
1073 1073
1074void KABCore::editContact( const QString &uid ) 1074void KABCore::editContact( const QString &uid )
1075{ 1075{
1076 1076
1077 if ( mExtensionManager->isQuickEditVisible() ) 1077 if ( mExtensionManager->isQuickEditVisible() )
1078 return; 1078 return;
1079 1079
1080 // First, locate the contact entry 1080 // First, locate the contact entry
1081 QString localUID = uid; 1081 QString localUID = uid;
1082 if ( localUID.isNull() ) { 1082 if ( localUID.isNull() ) {
1083 QStringList uidList = mViewManager->selectedUids(); 1083 QStringList uidList = mViewManager->selectedUids();
1084 if ( uidList.count() > 0 ) 1084 if ( uidList.count() > 0 )
1085 localUID = *( uidList.at( 0 ) ); 1085 localUID = *( uidList.at( 0 ) );
1086 } 1086 }
1087 1087
1088 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1088 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1089 if ( !addr.isEmpty() ) { 1089 if ( !addr.isEmpty() ) {
1090 mEditorDialog->setAddressee( addr ); 1090 mEditorDialog->setAddressee( addr );
1091 KApplication::execDialog ( mEditorDialog ); 1091 KApplication::execDialog ( mEditorDialog );
1092 } 1092 }
1093} 1093}
1094 1094
1095/** 1095/**
1096 Shows or edits the detail view for the given uid. If the uid is QString::null, 1096 Shows or edits the detail view for the given uid. If the uid is QString::null,
1097 the method will try to find a selected addressee in the view. 1097 the method will try to find a selected addressee in the view.
1098 */ 1098 */
1099void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1099void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1100{ 1100{
1101 if ( mMultipleViewsAtOnce ) 1101 if ( mMultipleViewsAtOnce )
1102 { 1102 {
1103 editContact( uid ); 1103 editContact( uid );
1104 } 1104 }
1105 else 1105 else
1106 { 1106 {
1107 setDetailsVisible( true ); 1107 setDetailsVisible( true );
1108 mActionDetails->setChecked(true); 1108 mActionDetails->setChecked(true);
1109 } 1109 }
1110 1110
1111} 1111}
1112 1112
1113void KABCore::save() 1113void KABCore::save()
1114{ 1114{
1115 if ( !mModified ) 1115 if ( !mModified )
1116 return; 1116 return;
1117 QString text = i18n( "There was an error while attempting to save\n the " 1117 QString text = i18n( "There was an error while attempting to save\n the "
1118 "address book. Please check that some \nother application is " 1118 "address book. Please check that some \nother application is "
1119 "not using it. " ); 1119 "not using it. " );
1120 statusMessage(i18n("Saving addressbook ... ")); 1120 statusMessage(i18n("Saving addressbook ... "));
1121#ifndef KAB_EMBEDDED 1121#ifndef KAB_EMBEDDED
1122 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1122 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1123 if ( !b || !b->save() ) { 1123 if ( !b || !b->save() ) {
1124 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1124 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1125 } 1125 }
1126#else //KAB_EMBEDDED 1126#else //KAB_EMBEDDED
1127 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1127 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1128 if ( !b || !b->save() ) { 1128 if ( !b || !b->save() ) {
1129 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1129 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1130 } 1130 }
1131#endif //KAB_EMBEDDED 1131#endif //KAB_EMBEDDED
1132 1132
1133 statusMessage(i18n("Addressbook saved!")); 1133 statusMessage(i18n("Addressbook saved!"));
1134 setModified( false ); 1134 setModified( false );
1135} 1135}
1136 1136
1137void KABCore::statusMessage(QString mess , int time ) 1137void KABCore::statusMessage(QString mess , int time )
1138{ 1138{
1139 //topLevelWidget()->setCaption( mess ); 1139 //topLevelWidget()->setCaption( mess );
1140 // pending setting timer to revome message 1140 // pending setting timer to revome message
1141} 1141}
1142void KABCore::undo() 1142void KABCore::undo()
1143{ 1143{
1144 UndoStack::instance()->undo(); 1144 UndoStack::instance()->undo();
1145 1145
1146 // Refresh the view 1146 // Refresh the view
1147 mViewManager->refreshView(); 1147 mViewManager->refreshView();
1148} 1148}
1149 1149
1150void KABCore::redo() 1150void KABCore::redo()
1151{ 1151{
1152 RedoStack::instance()->redo(); 1152 RedoStack::instance()->redo();
1153 1153
1154 // Refresh the view 1154 // Refresh the view
1155 mViewManager->refreshView(); 1155 mViewManager->refreshView();
1156} 1156}
1157 1157
1158void KABCore::setJumpButtonBarVisible( bool visible ) 1158void KABCore::setJumpButtonBarVisible( bool visible )
1159{ 1159{
1160 if (mMultipleViewsAtOnce) 1160 if (mMultipleViewsAtOnce)
1161 { 1161 {
1162 if ( visible ) 1162 if ( visible )
1163 mJumpButtonBar->show(); 1163 mJumpButtonBar->show();
1164 else 1164 else
1165 mJumpButtonBar->hide(); 1165 mJumpButtonBar->hide();
1166 } 1166 }
1167 else 1167 else
1168 { 1168 {
1169 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1169 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1170 if (mViewManager->isVisible()) 1170 if (mViewManager->isVisible())
1171 { 1171 {
1172 if ( visible ) 1172 if ( visible )
1173 mJumpButtonBar->show(); 1173 mJumpButtonBar->show();
1174 else 1174 else
1175 mJumpButtonBar->hide(); 1175 mJumpButtonBar->hide();
1176 } 1176 }
1177 else 1177 else
1178 { 1178 {
1179 mJumpButtonBar->hide(); 1179 mJumpButtonBar->hide();
1180 } 1180 }
1181 } 1181 }
1182} 1182}
1183 1183
1184 1184
1185void KABCore::setDetailsToState() 1185void KABCore::setDetailsToState()
1186{ 1186{
1187 setDetailsVisible( mActionDetails->isChecked() ); 1187 setDetailsVisible( mActionDetails->isChecked() );
1188} 1188}
1189 1189
1190 1190
1191 1191
1192void KABCore::setDetailsVisible( bool visible ) 1192void KABCore::setDetailsVisible( bool visible )
1193{ 1193{
1194 if (visible && mDetails->isHidden()) 1194 if (visible && mDetails->isHidden())
1195 { 1195 {
1196 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1196 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1197 if ( addrList.count() > 0 ) 1197 if ( addrList.count() > 0 )
1198 mDetails->setAddressee( addrList[ 0 ] ); 1198 mDetails->setAddressee( addrList[ 0 ] );
1199 } 1199 }
1200 1200
1201 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1201 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1202 // the listview and the detailview. We do that by changing the splitbar size. 1202 // the listview and the detailview. We do that by changing the splitbar size.
1203 if (mMultipleViewsAtOnce) 1203 if (mMultipleViewsAtOnce)
1204 { 1204 {
1205 if ( visible ) 1205 if ( visible )
1206 mDetails->show(); 1206 mDetails->show();
1207 else 1207 else
1208 mDetails->hide(); 1208 mDetails->hide();
1209 } 1209 }
1210 else 1210 else
1211 { 1211 {
1212 if ( visible ) { 1212 if ( visible ) {
1213 mViewManager->hide(); 1213 mViewManager->hide();
1214 mDetails->show(); 1214 mDetails->show();
1215 } 1215 }
1216 else { 1216 else {
1217 mViewManager->show(); 1217 mViewManager->show();
1218 mDetails->hide(); 1218 mDetails->hide();
1219 } 1219 }
1220 setJumpButtonBarVisible( !visible ); 1220 setJumpButtonBarVisible( !visible );
1221 } 1221 }
1222 1222
1223} 1223}
1224 1224
1225void KABCore::extensionChanged( int id ) 1225void KABCore::extensionChanged( int id )
1226{ 1226{
1227 //change the details view only for non desktop systems 1227 //change the details view only for non desktop systems
1228#ifndef DESKTOP_VERSION 1228#ifndef DESKTOP_VERSION
1229 1229
1230 if (id == 0) 1230 if (id == 0)
1231 { 1231 {
1232 //the user disabled the extension. 1232 //the user disabled the extension.
1233 1233
1234 if (mMultipleViewsAtOnce) 1234 if (mMultipleViewsAtOnce)
1235 { // enable detailsview again 1235 { // enable detailsview again
1236 setDetailsVisible( true ); 1236 setDetailsVisible( true );
1237 mActionDetails->setChecked( true ); 1237 mActionDetails->setChecked( true );
1238 } 1238 }
1239 else 1239 else
1240 { //go back to the listview 1240 { //go back to the listview
1241 setDetailsVisible( false ); 1241 setDetailsVisible( false );
1242 mActionDetails->setChecked( false ); 1242 mActionDetails->setChecked( false );
1243 mActionDetails->setEnabled(true); 1243 mActionDetails->setEnabled(true);
1244 } 1244 }
1245 1245
1246 } 1246 }
1247 else 1247 else
1248 { 1248 {
1249 //the user enabled the extension. 1249 //the user enabled the extension.
1250 setDetailsVisible( false ); 1250 setDetailsVisible( false );
1251 mActionDetails->setChecked( false ); 1251 mActionDetails->setChecked( false );
1252 1252
1253 if (!mMultipleViewsAtOnce) 1253 if (!mMultipleViewsAtOnce)
1254 { 1254 {
1255 mActionDetails->setEnabled(false); 1255 mActionDetails->setEnabled(false);
1256 } 1256 }
1257 1257
1258 mExtensionManager->setSelectionChanged(); 1258 mExtensionManager->setSelectionChanged();
1259 1259
1260 } 1260 }
1261 1261
1262#endif// DESKTOP_VERSION 1262#endif// DESKTOP_VERSION
1263 1263
1264} 1264}
1265 1265
1266 1266
1267void KABCore::extensionModified( const KABC::Addressee::List &list ) 1267void KABCore::extensionModified( const KABC::Addressee::List &list )
1268{ 1268{
1269 1269
1270 if ( list.count() != 0 ) { 1270 if ( list.count() != 0 ) {
1271 KABC::Addressee::List::ConstIterator it; 1271 KABC::Addressee::List::ConstIterator it;
1272 for ( it = list.begin(); it != list.end(); ++it ) 1272 for ( it = list.begin(); it != list.end(); ++it )
1273 mAddressBook->insertAddressee( *it ); 1273 mAddressBook->insertAddressee( *it );
1274 if ( list.count() > 1 ) 1274 if ( list.count() > 1 )
1275 setModified(); 1275 setModified();
1276 else 1276 else
1277 setModifiedWOrefresh(); 1277 setModifiedWOrefresh();
1278 } 1278 }
1279 if ( list.count() == 0 ) 1279 if ( list.count() == 0 )
1280 mViewManager->refreshView(); 1280 mViewManager->refreshView();
1281 else 1281 else
1282 mViewManager->refreshView( list[ 0 ].uid() ); 1282 mViewManager->refreshView( list[ 0 ].uid() );
1283 1283
1284 1284
1285 1285
1286} 1286}
1287 1287
1288QString KABCore::getNameByPhone( const QString &phone ) 1288QString KABCore::getNameByPhone( const QString &phone )
1289{ 1289{
1290#ifndef KAB_EMBEDDED 1290#ifndef KAB_EMBEDDED
1291 QRegExp r( "[/*/-/ ]" ); 1291 QRegExp r( "[/*/-/ ]" );
1292 QString localPhone( phone ); 1292 QString localPhone( phone );
1293 1293
1294 bool found = false; 1294 bool found = false;
1295 QString ownerName = ""; 1295 QString ownerName = "";
1296 KABC::AddressBook::Iterator iter; 1296 KABC::AddressBook::Iterator iter;
1297 KABC::PhoneNumber::List::Iterator phoneIter; 1297 KABC::PhoneNumber::List::Iterator phoneIter;
1298 KABC::PhoneNumber::List phoneList; 1298 KABC::PhoneNumber::List phoneList;
1299 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1299 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1300 phoneList = (*iter).phoneNumbers(); 1300 phoneList = (*iter).phoneNumbers();
1301 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1301 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1302 ++phoneIter) { 1302 ++phoneIter) {
1303 // Get rid of separator chars so just the numbers are compared. 1303 // Get rid of separator chars so just the numbers are compared.
1304 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1304 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1305 ownerName = (*iter).formattedName(); 1305 ownerName = (*iter).formattedName();
1306 found = true; 1306 found = true;
1307 } 1307 }
1308 } 1308 }
1309 } 1309 }
1310 1310
1311 return ownerName; 1311 return ownerName;
1312#else //KAB_EMBEDDED 1312#else //KAB_EMBEDDED
1313 qDebug("KABCore::getNameByPhone finsih method"); 1313 qDebug("KABCore::getNameByPhone finsih method");
1314 return ""; 1314 return "";
1315#endif //KAB_EMBEDDED 1315#endif //KAB_EMBEDDED
1316 1316
1317} 1317}
1318 1318
1319void KABCore::openConfigDialog() 1319void KABCore::openConfigDialog()
1320{ 1320{
1321 KABPrefs* kab_prefs = KABPrefs::instance(); 1321 KABPrefs* kab_prefs = KABPrefs::instance();
1322 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1322 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1323 1323
1324 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1324 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1325 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1325 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1326 ConfigureDialog->addModule(kabcfg ); 1326 ConfigureDialog->addModule(kabcfg );
1327 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1327 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1328 ConfigureDialog->addModule(kdelibcfg ); 1328 ConfigureDialog->addModule(kdelibcfg );
1329 1329
1330 1330
1331 1331
1332 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1332 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1333 this, SLOT( configurationChanged() ) ); 1333 this, SLOT( configurationChanged() ) );
1334 connect( ConfigureDialog, SIGNAL( okClicked() ), 1334 connect( ConfigureDialog, SIGNAL( okClicked() ),
1335 this, SLOT( configurationChanged() ) ); 1335 this, SLOT( configurationChanged() ) );
1336 saveSettings(); 1336 saveSettings();
1337#ifndef DESKTOP_VERSION 1337#ifndef DESKTOP_VERSION
1338 ConfigureDialog->showMaximized(); 1338 ConfigureDialog->showMaximized();
1339#endif 1339#endif
1340 if ( ConfigureDialog->exec() ) 1340 if ( ConfigureDialog->exec() )
1341 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1341 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1342 delete ConfigureDialog; 1342 delete ConfigureDialog;
1343} 1343}
1344 1344
1345void KABCore::openLDAPDialog() 1345void KABCore::openLDAPDialog()
1346{ 1346{
1347#ifndef KAB_EMBEDDED 1347#ifndef KAB_EMBEDDED
1348 if ( !mLdapSearchDialog ) { 1348 if ( !mLdapSearchDialog ) {
1349 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1349 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1350 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1350 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1351 SLOT( refreshView() ) ); 1351 SLOT( refreshView() ) );
1352 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1352 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1353 SLOT( setModified() ) ); 1353 SLOT( setModified() ) );
1354 } else 1354 } else
1355 mLdapSearchDialog->restoreSettings(); 1355 mLdapSearchDialog->restoreSettings();
1356 1356
1357 if ( mLdapSearchDialog->isOK() ) 1357 if ( mLdapSearchDialog->isOK() )
1358 mLdapSearchDialog->exec(); 1358 mLdapSearchDialog->exec();
1359#else //KAB_EMBEDDED 1359#else //KAB_EMBEDDED
1360 qDebug("KABCore::openLDAPDialog() finsih method"); 1360 qDebug("KABCore::openLDAPDialog() finsih method");
1361#endif //KAB_EMBEDDED 1361#endif //KAB_EMBEDDED
1362} 1362}
1363 1363
1364void KABCore::print() 1364void KABCore::print()
1365{ 1365{
1366#ifndef KAB_EMBEDDED 1366#ifndef KAB_EMBEDDED
1367 KPrinter printer; 1367 KPrinter printer;
1368 if ( !printer.setup( this ) ) 1368 if ( !printer.setup( this ) )
1369 return; 1369 return;
1370 1370
1371 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1371 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1372 mViewManager->selectedUids(), this ); 1372 mViewManager->selectedUids(), this );
1373 1373
1374 wizard.exec(); 1374 wizard.exec();
1375#else //KAB_EMBEDDED 1375#else //KAB_EMBEDDED
1376 qDebug("KABCore::print() finsih method"); 1376 qDebug("KABCore::print() finsih method");
1377#endif //KAB_EMBEDDED 1377#endif //KAB_EMBEDDED
1378 1378
1379} 1379}
1380 1380
1381 1381
1382void KABCore::addGUIClient( KXMLGUIClient *client ) 1382void KABCore::addGUIClient( KXMLGUIClient *client )
1383{ 1383{
1384 if ( mGUIClient ) 1384 if ( mGUIClient )
1385 mGUIClient->insertChildClient( client ); 1385 mGUIClient->insertChildClient( client );
1386 else 1386 else
1387 KMessageBox::error( this, "no KXMLGUICLient"); 1387 KMessageBox::error( this, "no KXMLGUICLient");
1388} 1388}
1389 1389
1390 1390
1391void KABCore::configurationChanged() 1391void KABCore::configurationChanged()
1392{ 1392{
1393 mExtensionManager->reconfigure(); 1393 mExtensionManager->reconfigure();
1394} 1394}
1395 1395
1396void KABCore::addressBookChanged() 1396void KABCore::addressBookChanged()
1397{ 1397{
1398/*US 1398/*US
1399 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1399 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1400 while ( it.current() ) { 1400 while ( it.current() ) {
1401 if ( it.current()->dirty() ) { 1401 if ( it.current()->dirty() ) {
1402 QString text = i18n( "Data has been changed externally. Unsaved " 1402 QString text = i18n( "Data has been changed externally. Unsaved "
1403 "changes will be lost." ); 1403 "changes will be lost." );
1404 KMessageBox::information( this, text ); 1404 KMessageBox::information( this, text );
1405 } 1405 }
1406 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1406 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1407 ++it; 1407 ++it;
1408 } 1408 }
1409*/ 1409*/
1410 if (mEditorDialog) 1410 if (mEditorDialog)
1411 { 1411 {
1412 if (mEditorDialog->dirty()) 1412 if (mEditorDialog->dirty())
1413 { 1413 {
1414 QString text = i18n( "Data has been changed externally. Unsaved " 1414 QString text = i18n( "Data has been changed externally. Unsaved "
1415 "changes will be lost." ); 1415 "changes will be lost." );
1416 KMessageBox::information( this, text ); 1416 KMessageBox::information( this, text );
1417 } 1417 }
1418 QString currentuid = mEditorDialog->addressee().uid(); 1418 QString currentuid = mEditorDialog->addressee().uid();
1419 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1419 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1420 } 1420 }
1421 mViewManager->refreshView(); 1421 mViewManager->refreshView();
1422// mDetails->refreshView(); 1422// mDetails->refreshView();
1423 1423
1424 1424
1425} 1425}
1426 1426
1427AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1427AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1428 const char *name ) 1428 const char *name )
1429{ 1429{
1430 1430
1431 if ( mEditorDialog == 0 ) { 1431 if ( mEditorDialog == 0 ) {
1432 mEditorDialog = new AddresseeEditorDialog( this, parent, 1432 mEditorDialog = new AddresseeEditorDialog( this, parent,
1433 name ? name : "editorDialog" ); 1433 name ? name : "editorDialog" );
1434 1434
1435 1435
1436 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1436 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1437 SLOT( contactModified( const KABC::Addressee& ) ) ); 1437 SLOT( contactModified( const KABC::Addressee& ) ) );
1438 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1438 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1439 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1439 // SLOT( slotEditorDestroyed( const QString& ) ) );
1440 } 1440 }
1441 1441
1442 return mEditorDialog; 1442 return mEditorDialog;
1443} 1443}
1444 1444
1445void KABCore::slotEditorDestroyed( const QString &uid ) 1445void KABCore::slotEditorDestroyed( const QString &uid )
1446{ 1446{
1447 //mEditorDict.remove( uid ); 1447 //mEditorDict.remove( uid );
1448} 1448}
1449 1449
1450void KABCore::initGUI() 1450void KABCore::initGUI()
1451{ 1451{
1452#ifndef KAB_EMBEDDED 1452#ifndef KAB_EMBEDDED
1453 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1453 QHBoxLayout *topLayout = new QHBoxLayout( this );
1454 topLayout->setSpacing( KDialogBase::spacingHint() ); 1454 topLayout->setSpacing( KDialogBase::spacingHint() );
1455 1455
1456 mExtensionBarSplitter = new QSplitter( this ); 1456 mExtensionBarSplitter = new QSplitter( this );
1457 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1457 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1458 1458
1459 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1459 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1460 1460
1461 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1461 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1462 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1462 mIncSearchWidget = new IncSearchWidget( viewSpace );
1463 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1463 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1464 SLOT( incrementalSearch( const QString& ) ) ); 1464 SLOT( incrementalSearch( const QString& ) ) );
1465 1465
1466 mViewManager = new ViewManager( this, viewSpace ); 1466 mViewManager = new ViewManager( this, viewSpace );
1467 viewSpace->setStretchFactor( mViewManager, 1 ); 1467 viewSpace->setStretchFactor( mViewManager, 1 );
1468 1468
1469 mDetails = new ViewContainer( mDetailsSplitter ); 1469 mDetails = new ViewContainer( mDetailsSplitter );
1470 1470
1471 mJumpButtonBar = new JumpButtonBar( this, this ); 1471 mJumpButtonBar = new JumpButtonBar( this, this );
1472 1472
1473 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1473 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1474 1474
1475 topLayout->addWidget( mExtensionBarSplitter ); 1475 topLayout->addWidget( mExtensionBarSplitter );
1476 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1476 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1477 topLayout->addWidget( mJumpButtonBar ); 1477 topLayout->addWidget( mJumpButtonBar );
1478 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1478 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1479 1479
1480 mXXPortManager = new XXPortManager( this, this ); 1480 mXXPortManager = new XXPortManager( this, this );
1481 1481
1482#else //KAB_EMBEDDED 1482#else //KAB_EMBEDDED
1483 //US initialize viewMenu before settingup viewmanager. 1483 //US initialize viewMenu before settingup viewmanager.
1484 // Viewmanager needs this menu to plugin submenues. 1484 // Viewmanager needs this menu to plugin submenues.
1485 viewMenu = new QPopupMenu( this ); 1485 viewMenu = new QPopupMenu( this );
1486 settingsMenu = new QPopupMenu( this ); 1486 settingsMenu = new QPopupMenu( this );
1487 //filterMenu = new QPopupMenu( this ); 1487 //filterMenu = new QPopupMenu( this );
1488 ImportMenu = new QPopupMenu( this ); 1488 ImportMenu = new QPopupMenu( this );
1489 ExportMenu = new QPopupMenu( this ); 1489 ExportMenu = new QPopupMenu( this );
1490 1490
1491 changeMenu= new QPopupMenu( this ); 1491 changeMenu= new QPopupMenu( this );
1492 1492
1493//US since we have no splitter for the embedded system, setup 1493//US since we have no splitter for the embedded system, setup
1494// a layout with two frames. One left and one right. 1494// a layout with two frames. One left and one right.
1495 1495
1496 QBoxLayout *topLayout; 1496 QBoxLayout *topLayout;
1497 1497
1498 // = new QHBoxLayout( this ); 1498 // = new QHBoxLayout( this );
1499// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1499// QBoxLayout *topLayout = (QBoxLayout*)layout();
1500 1500
1501// QWidget *mainBox = new QWidget( this ); 1501// QWidget *mainBox = new QWidget( this );
1502// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1502// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1503 1503
1504#ifdef DESKTOP_VERSION 1504#ifdef DESKTOP_VERSION
1505 topLayout = new QHBoxLayout( this ); 1505 topLayout = new QHBoxLayout( this );
1506 1506
1507 1507
1508 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1508 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1509 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1509 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1510 1510
1511 topLayout->addWidget(mMiniSplitter ); 1511 topLayout->addWidget(mMiniSplitter );
1512 1512
1513 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1513 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1514 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1514 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1515 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1515 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1516 mDetails = new ViewContainer( mMiniSplitter ); 1516 mDetails = new ViewContainer( mMiniSplitter );
1517 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1517 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1518#else 1518#else
1519 if ( QApplication::desktop()->width() > 480 ) { 1519 if ( QApplication::desktop()->width() > 480 ) {
1520 topLayout = new QHBoxLayout( this ); 1520 topLayout = new QHBoxLayout( this );
1521 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1521 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1522 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1522 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1523 } else { 1523 } else {
1524 1524
1525 topLayout = new QHBoxLayout( this ); 1525 topLayout = new QHBoxLayout( this );
1526 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1526 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1527 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1527 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1528 } 1528 }
1529 1529
1530 topLayout->addWidget(mMiniSplitter ); 1530 topLayout->addWidget(mMiniSplitter );
1531 mViewManager = new ViewManager( this, mMiniSplitter ); 1531 mViewManager = new ViewManager( this, mMiniSplitter );
1532 mDetails = new ViewContainer( mMiniSplitter ); 1532 mDetails = new ViewContainer( mMiniSplitter );
1533 1533
1534 1534
1535 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1535 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1536#endif 1536#endif
1537 //eh->hide(); 1537 //eh->hide();
1538 // topLayout->addWidget(mExtensionManager ); 1538 // topLayout->addWidget(mExtensionManager );
1539 1539
1540 1540
1541/*US 1541/*US
1542#ifndef KAB_NOSPLITTER 1542#ifndef KAB_NOSPLITTER
1543 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1543 QHBoxLayout *topLayout = new QHBoxLayout( this );
1544//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1544//US topLayout->setSpacing( KDialogBase::spacingHint() );
1545 topLayout->setSpacing( 10 ); 1545 topLayout->setSpacing( 10 );
1546 1546
1547 mDetailsSplitter = new QSplitter( this ); 1547 mDetailsSplitter = new QSplitter( this );
1548 1548
1549 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1549 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1550 1550
1551 mViewManager = new ViewManager( this, viewSpace ); 1551 mViewManager = new ViewManager( this, viewSpace );
1552 viewSpace->setStretchFactor( mViewManager, 1 ); 1552 viewSpace->setStretchFactor( mViewManager, 1 );
1553 1553
1554 mDetails = new ViewContainer( mDetailsSplitter ); 1554 mDetails = new ViewContainer( mDetailsSplitter );
1555 1555
1556 topLayout->addWidget( mDetailsSplitter ); 1556 topLayout->addWidget( mDetailsSplitter );
1557 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1557 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1558#else //KAB_NOSPLITTER 1558#else //KAB_NOSPLITTER
1559 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1559 QHBoxLayout *topLayout = new QHBoxLayout( this );
1560//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1560//US topLayout->setSpacing( KDialogBase::spacingHint() );
1561 topLayout->setSpacing( 10 ); 1561 topLayout->setSpacing( 10 );
1562 1562
1563// mDetailsSplitter = new QSplitter( this ); 1563// mDetailsSplitter = new QSplitter( this );
1564 1564
1565 QVBox *viewSpace = new QVBox( this ); 1565 QVBox *viewSpace = new QVBox( this );
1566 1566
1567 mViewManager = new ViewManager( this, viewSpace ); 1567 mViewManager = new ViewManager( this, viewSpace );
1568 viewSpace->setStretchFactor( mViewManager, 1 ); 1568 viewSpace->setStretchFactor( mViewManager, 1 );
1569 1569
1570 mDetails = new ViewContainer( this ); 1570 mDetails = new ViewContainer( this );
1571 1571
1572 topLayout->addWidget( viewSpace ); 1572 topLayout->addWidget( viewSpace );
1573// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1573// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1574 topLayout->addWidget( mDetails ); 1574 topLayout->addWidget( mDetails );
1575#endif //KAB_NOSPLITTER 1575#endif //KAB_NOSPLITTER
1576*/ 1576*/
1577 1577
1578 1578
1579#endif //KAB_EMBEDDED 1579#endif //KAB_EMBEDDED
1580 initActions(); 1580 initActions();
1581 1581
1582#ifdef KAB_EMBEDDED 1582#ifdef KAB_EMBEDDED
1583 addActionsManually(); 1583 addActionsManually();
1584 //US make sure the export and import menues are initialized before creating the xxPortManager. 1584 //US make sure the export and import menues are initialized before creating the xxPortManager.
1585 mXXPortManager = new XXPortManager( this, this ); 1585 mXXPortManager = new XXPortManager( this, this );
1586 1586
1587 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1587 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1588 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1588 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1589 // mActionQuit->plug ( mMainWindow->toolBar()); 1589 // mActionQuit->plug ( mMainWindow->toolBar());
1590 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1590 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1591 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1591 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1592 // mIncSearchWidget->hide(); 1592 // mIncSearchWidget->hide();
1593 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1593 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1594 SLOT( incrementalSearch( const QString& ) ) ); 1594 SLOT( incrementalSearch( const QString& ) ) );
1595 1595
1596 1596
1597 mJumpButtonBar = new JumpButtonBar( this, this ); 1597 mJumpButtonBar = new JumpButtonBar( this, this );
1598 1598
1599 topLayout->addWidget( mJumpButtonBar ); 1599 topLayout->addWidget( mJumpButtonBar );
1600//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1600//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1601 1601
1602// mMainWindow->getIconToolBar()->raise(); 1602// mMainWindow->getIconToolBar()->raise();
1603 1603
1604#endif //KAB_EMBEDDED 1604#endif //KAB_EMBEDDED
1605 1605
1606} 1606}
1607void KABCore::initActions() 1607void KABCore::initActions()
1608{ 1608{
1609//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1609//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1610 1610
1611#ifndef KAB_EMBEDDED 1611#ifndef KAB_EMBEDDED
1612 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1612 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1613 SLOT( clipboardDataChanged() ) ); 1613 SLOT( clipboardDataChanged() ) );
1614#endif //KAB_EMBEDDED 1614#endif //KAB_EMBEDDED
1615 1615
1616 // file menu 1616 // file menu
1617 if ( mIsPart ) { 1617 if ( mIsPart ) {
1618 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1618 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1619 SLOT( sendMail() ), actionCollection(), 1619 SLOT( sendMail() ), actionCollection(),
1620 "kaddressbook_mail" ); 1620 "kaddressbook_mail" );
1621 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1621 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1622 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1622 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1623 1623
1624 } else { 1624 } else {
1625 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1625 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1626 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1626 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1627 } 1627 }
1628 1628
1629 1629
1630 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1630 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1631 SLOT( save() ), actionCollection(), "file_sync" ); 1631 SLOT( save() ), actionCollection(), "file_sync" );
1632 1632
1633 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1633 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1634 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1634 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1635 1635
1636 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1636 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1637 this, SLOT( mailVCard() ), 1637 this, SLOT( mailVCard() ),
1638 actionCollection(), "file_mail_vcard"); 1638 actionCollection(), "file_mail_vcard");
1639 1639
1640 mActionBeamVCard = 0; 1640 mActionBeamVCard = 0;
1641 mActionBeam = 0; 1641 mActionBeam = 0;
1642 1642
1643#ifndef DESKTOP_VERSION 1643#ifndef DESKTOP_VERSION
1644 if ( Ir::supported() ) { 1644 if ( Ir::supported() ) {
1645 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1645 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1646 SLOT( beamVCard() ), actionCollection(), 1646 SLOT( beamVCard() ), actionCollection(),
1647 "kaddressbook_beam_vcard" ); 1647 "kaddressbook_beam_vcard" );
1648 1648
1649 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1649 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1650 SLOT( beamMySelf() ), actionCollection(), 1650 SLOT( beamMySelf() ), actionCollection(),
1651 "kaddressbook_beam_myself" ); 1651 "kaddressbook_beam_myself" );
1652 } 1652 }
1653#endif 1653#endif
1654 1654
1655 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1655 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1656 this, SLOT( editContact2() ), 1656 this, SLOT( editContact2() ),
1657 actionCollection(), "file_properties" ); 1657 actionCollection(), "file_properties" );
1658 1658
1659#ifdef KAB_EMBEDDED 1659#ifdef KAB_EMBEDDED
1660 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1660 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1661 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1661 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1662 mMainWindow, SLOT( exit() ), 1662 mMainWindow, SLOT( exit() ),
1663 actionCollection(), "quit" ); 1663 actionCollection(), "quit" );
1664#endif //KAB_EMBEDDED 1664#endif //KAB_EMBEDDED
1665 1665
1666 // edit menu 1666 // edit menu
1667 if ( mIsPart ) { 1667 if ( mIsPart ) {
1668 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1668 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1669 SLOT( copyContacts() ), actionCollection(), 1669 SLOT( copyContacts() ), actionCollection(),
1670 "kaddressbook_copy" ); 1670 "kaddressbook_copy" );
1671 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1671 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1672 SLOT( cutContacts() ), actionCollection(), 1672 SLOT( cutContacts() ), actionCollection(),
1673 "kaddressbook_cut" ); 1673 "kaddressbook_cut" );
1674 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1674 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1675 SLOT( pasteContacts() ), actionCollection(), 1675 SLOT( pasteContacts() ), actionCollection(),
1676 "kaddressbook_paste" ); 1676 "kaddressbook_paste" );
1677 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1677 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1678 SLOT( selectAllContacts() ), actionCollection(), 1678 SLOT( selectAllContacts() ), actionCollection(),
1679 "kaddressbook_select_all" ); 1679 "kaddressbook_select_all" );
1680 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1680 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1681 SLOT( undo() ), actionCollection(), 1681 SLOT( undo() ), actionCollection(),
1682 "kaddressbook_undo" ); 1682 "kaddressbook_undo" );
1683 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1683 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1684 this, SLOT( redo() ), actionCollection(), 1684 this, SLOT( redo() ), actionCollection(),
1685 "kaddressbook_redo" ); 1685 "kaddressbook_redo" );
1686 } else { 1686 } else {
1687 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1687 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1688 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1688 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1689 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1689 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1690 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1690 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1691 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1691 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1692 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1692 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1693 } 1693 }
1694 1694
1695 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1695 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1696 Key_Delete, this, SLOT( deleteContacts() ), 1696 Key_Delete, this, SLOT( deleteContacts() ),
1697 actionCollection(), "edit_delete" ); 1697 actionCollection(), "edit_delete" );
1698 1698
1699 mActionUndo->setEnabled( false ); 1699 mActionUndo->setEnabled( false );
1700 mActionRedo->setEnabled( false ); 1700 mActionRedo->setEnabled( false );
1701 1701
1702 // settings menu 1702 // settings menu
1703#ifdef KAB_EMBEDDED 1703#ifdef KAB_EMBEDDED
1704//US special menuentry to configure the addressbook resources. On KDE 1704//US special menuentry to configure the addressbook resources. On KDE
1705// you do that through the control center !!! 1705// you do that through the control center !!!
1706 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1706 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1707 SLOT( configureResources() ), actionCollection(), 1707 SLOT( configureResources() ), actionCollection(),
1708 "kaddressbook_configure_resources" ); 1708 "kaddressbook_configure_resources" );
1709#endif //KAB_EMBEDDED 1709#endif //KAB_EMBEDDED
1710 1710
1711 if ( mIsPart ) { 1711 if ( mIsPart ) {
1712 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1712 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1713 SLOT( openConfigDialog() ), actionCollection(), 1713 SLOT( openConfigDialog() ), actionCollection(),
1714 "kaddressbook_configure" ); 1714 "kaddressbook_configure" );
1715 1715
1716 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1716 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1717 this, SLOT( configureKeyBindings() ), actionCollection(), 1717 this, SLOT( configureKeyBindings() ), actionCollection(),
1718 "kaddressbook_configure_shortcuts" ); 1718 "kaddressbook_configure_shortcuts" );
1719#ifdef KAB_EMBEDDED 1719#ifdef KAB_EMBEDDED
1720 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1720 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1721 mActionConfigureToolbars->setEnabled( false ); 1721 mActionConfigureToolbars->setEnabled( false );
1722#endif //KAB_EMBEDDED 1722#endif //KAB_EMBEDDED
1723 1723
1724 } else { 1724 } else {
1725 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1725 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1726 1726
1727 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1727 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1728 } 1728 }
1729 1729
1730 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1730 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1731 actionCollection(), "options_show_jump_bar" ); 1731 actionCollection(), "options_show_jump_bar" );
1732 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1732 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1733 1733
1734 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1734 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1735 actionCollection(), "options_show_details" ); 1735 actionCollection(), "options_show_details" );
1736 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1736 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1737 1737
1738 // misc 1738 // misc
1739 // only enable LDAP lookup if we can handle the protocol 1739 // only enable LDAP lookup if we can handle the protocol
1740#ifndef KAB_EMBEDDED 1740#ifndef KAB_EMBEDDED
1741 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1741 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1742 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1742 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1743 this, SLOT( openLDAPDialog() ), actionCollection(), 1743 this, SLOT( openLDAPDialog() ), actionCollection(),
1744 "ldap_lookup" ); 1744 "ldap_lookup" );
1745 } 1745 }
1746#else //KAB_EMBEDDED 1746#else //KAB_EMBEDDED
1747 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1747 //qDebug("KABCore::initActions() LDAP has to be implemented");
1748#endif //KAB_EMBEDDED 1748#endif //KAB_EMBEDDED
1749 1749
1750 1750
1751 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1751 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1752 SLOT( setWhoAmI() ), actionCollection(), 1752 SLOT( setWhoAmI() ), actionCollection(),
1753 "set_personal" ); 1753 "set_personal" );
1754 1754
1755 1755
1756 1756
1757 1757
1758 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1758 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1759 SLOT( setCategories() ), actionCollection(), 1759 SLOT( setCategories() ), actionCollection(),
1760 "edit_set_categories" ); 1760 "edit_set_categories" );
1761 1761
1762 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1762 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1763 SLOT( removeVoice() ), actionCollection(), 1763 SLOT( removeVoice() ), actionCollection(),
1764 "remove_voice" ); 1764 "remove_voice" );
1765 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1765 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1766 SLOT( importFromOL() ), actionCollection(), 1766 SLOT( importFromOL() ), actionCollection(),
1767 "import_OL" ); 1767 "import_OL" );
1768#ifdef KAB_EMBEDDED 1768#ifdef KAB_EMBEDDED
1769 mActionLicence = new KAction( i18n( "Licence" ), 0, 1769 mActionLicence = new KAction( i18n( "Licence" ), 0,
1770 this, SLOT( showLicence() ), actionCollection(), 1770 this, SLOT( showLicence() ), actionCollection(),
1771 "licence_about_data" ); 1771 "licence_about_data" );
1772 mActionFaq = new KAction( i18n( "Faq" ), 0, 1772 mActionFaq = new KAction( i18n( "Faq" ), 0,
1773 this, SLOT( faq() ), actionCollection(), 1773 this, SLOT( faq() ), actionCollection(),
1774 "faq_about_data" ); 1774 "faq_about_data" );
1775 1775
1776 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1776 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1777 this, SLOT( createAboutData() ), actionCollection(), 1777 this, SLOT( createAboutData() ), actionCollection(),
1778 "kaddressbook_about_data" ); 1778 "kaddressbook_about_data" );
1779#endif //KAB_EMBEDDED 1779#endif //KAB_EMBEDDED
1780 1780
1781 clipboardDataChanged(); 1781 clipboardDataChanged();
1782 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1782 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1783 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1783 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1784} 1784}
1785 1785
1786//US we need this function, to plug all actions into the correct menues. 1786//US we need this function, to plug all actions into the correct menues.
1787// KDE uses a XML format to plug the actions, but we work her without this overhead. 1787// KDE uses a XML format to plug the actions, but we work her without this overhead.
1788void KABCore::addActionsManually() 1788void KABCore::addActionsManually()
1789{ 1789{
1790//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1790//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1791 1791
1792#ifdef KAB_EMBEDDED 1792#ifdef KAB_EMBEDDED
1793 QPopupMenu *fileMenu = new QPopupMenu( this ); 1793 QPopupMenu *fileMenu = new QPopupMenu( this );
1794 QPopupMenu *editMenu = new QPopupMenu( this ); 1794 QPopupMenu *editMenu = new QPopupMenu( this );
1795 QPopupMenu *helpMenu = new QPopupMenu( this ); 1795 QPopupMenu *helpMenu = new QPopupMenu( this );
1796 1796
1797 KToolBar* tb = mMainWindow->toolBar(); 1797 KToolBar* tb = mMainWindow->toolBar();
1798 1798
1799#ifdef DESKTOP_VERSION 1799#ifdef DESKTOP_VERSION
1800 QMenuBar* mb = mMainWindow->menuBar(); 1800 QMenuBar* mb = mMainWindow->menuBar();
1801 1801
1802 //US setup menubar. 1802 //US setup menubar.
1803 //Disable the following block if you do not want to have a menubar. 1803 //Disable the following block if you do not want to have a menubar.
1804 mb->insertItem( "&File", fileMenu ); 1804 mb->insertItem( "&File", fileMenu );
1805 mb->insertItem( "&Edit", editMenu ); 1805 mb->insertItem( "&Edit", editMenu );
1806 mb->insertItem( "&View", viewMenu ); 1806 mb->insertItem( "&View", viewMenu );
1807 mb->insertItem( "&Settings", settingsMenu ); 1807 mb->insertItem( "&Settings", settingsMenu );
1808 mb->insertItem( "&Change selected", changeMenu ); 1808 mb->insertItem( "&Change selected", changeMenu );
1809 mb->insertItem( "&Help", helpMenu ); 1809 mb->insertItem( "&Help", helpMenu );
1810 mIncSearchWidget = new IncSearchWidget( tb ); 1810 mIncSearchWidget = new IncSearchWidget( tb );
1811 // tb->insertWidget(-1, 0, mIncSearchWidget); 1811 // tb->insertWidget(-1, 0, mIncSearchWidget);
1812 1812
1813#else 1813#else
1814 //US setup toolbar 1814 //US setup toolbar
1815 QMenuBar *menuBarTB = new QMenuBar( tb ); 1815 QMenuBar *menuBarTB = new QMenuBar( tb );
1816 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1816 QPopupMenu *popupBarTB = new QPopupMenu( this );
1817 menuBarTB->insertItem( "ME", popupBarTB); 1817 menuBarTB->insertItem( "ME", popupBarTB);
1818 tb->insertWidget(-1, 0, menuBarTB); 1818 tb->insertWidget(-1, 0, menuBarTB);
1819 mIncSearchWidget = new IncSearchWidget( tb ); 1819 mIncSearchWidget = new IncSearchWidget( tb );
1820 1820
1821 tb->enableMoving(false); 1821 tb->enableMoving(false);
1822 popupBarTB->insertItem( "&File", fileMenu ); 1822 popupBarTB->insertItem( "&File", fileMenu );
1823 popupBarTB->insertItem( "&Edit", editMenu ); 1823 popupBarTB->insertItem( "&Edit", editMenu );
1824 popupBarTB->insertItem( "&View", viewMenu ); 1824 popupBarTB->insertItem( "&View", viewMenu );
1825 popupBarTB->insertItem( "&Settings", settingsMenu ); 1825 popupBarTB->insertItem( "&Settings", settingsMenu );
1826 mViewManager->getFilterAction()->plug ( popupBarTB); 1826 mViewManager->getFilterAction()->plug ( popupBarTB);
1827 popupBarTB->insertItem( "&Change selected", changeMenu ); 1827 popupBarTB->insertItem( "&Change selected", changeMenu );
1828 popupBarTB->insertItem( "&Help", helpMenu ); 1828 popupBarTB->insertItem( "&Help", helpMenu );
1829 if (QApplication::desktop()->width() > 320 ) { 1829 if (QApplication::desktop()->width() > 320 ) {
1830 // mViewManager->getFilterAction()->plug ( tb); 1830 // mViewManager->getFilterAction()->plug ( tb);
1831 } 1831 }
1832#endif 1832#endif
1833 // mActionQuit->plug ( mMainWindow->toolBar()); 1833 // mActionQuit->plug ( mMainWindow->toolBar());
1834 1834
1835 1835
1836 1836
1837 //US Now connect the actions with the menue entries. 1837 //US Now connect the actions with the menue entries.
1838 mActionPrint->plug( fileMenu ); 1838 mActionPrint->plug( fileMenu );
1839 mActionMail->plug( fileMenu ); 1839 mActionMail->plug( fileMenu );
1840 fileMenu->insertSeparator(); 1840 fileMenu->insertSeparator();
1841 1841
1842 mActionNewContact->plug( fileMenu ); 1842 mActionNewContact->plug( fileMenu );
1843 mActionNewContact->plug( tb ); 1843 mActionNewContact->plug( tb );
1844 1844
1845 mActionEditAddressee->plug( fileMenu ); 1845 mActionEditAddressee->plug( fileMenu );
1846 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1846 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1847 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1847 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1848 mActionEditAddressee->plug( tb ); 1848 mActionEditAddressee->plug( tb );
1849 1849
1850 fileMenu->insertSeparator(); 1850 fileMenu->insertSeparator();
1851 mActionSave->plug( fileMenu ); 1851 mActionSave->plug( fileMenu );
1852 fileMenu->insertItem( "&Import", ImportMenu ); 1852 fileMenu->insertItem( "&Import", ImportMenu );
1853 fileMenu->insertItem( "&Emport", ExportMenu ); 1853 fileMenu->insertItem( "&Emport", ExportMenu );
1854 fileMenu->insertSeparator(); 1854 fileMenu->insertSeparator();
1855 mActionMailVCard->plug( fileMenu ); 1855 mActionMailVCard->plug( fileMenu );
1856#ifndef DESKTOP_VERSION 1856#ifndef DESKTOP_VERSION
1857 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1857 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1858 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1858 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1859#endif 1859#endif
1860 fileMenu->insertSeparator(); 1860 fileMenu->insertSeparator();
1861 mActionQuit->plug( fileMenu ); 1861 mActionQuit->plug( fileMenu );
1862#ifdef _WIN32_ 1862#ifdef _WIN32_
1863 mActionImportOL->plug( ImportMenu ); 1863 mActionImportOL->plug( ImportMenu );
1864#endif 1864#endif
1865 // edit menu 1865 // edit menu
1866 mActionUndo->plug( editMenu ); 1866 mActionUndo->plug( editMenu );
1867 mActionRedo->plug( editMenu ); 1867 mActionRedo->plug( editMenu );
1868 editMenu->insertSeparator(); 1868 editMenu->insertSeparator();
1869 mActionCut->plug( editMenu ); 1869 mActionCut->plug( editMenu );
1870 mActionCopy->plug( editMenu ); 1870 mActionCopy->plug( editMenu );
1871 mActionPaste->plug( editMenu ); 1871 mActionPaste->plug( editMenu );
1872 mActionDelete->plug( editMenu ); 1872 mActionDelete->plug( editMenu );
1873 editMenu->insertSeparator(); 1873 editMenu->insertSeparator();
1874 mActionSelectAll->plug( editMenu ); 1874 mActionSelectAll->plug( editMenu );
1875 1875
1876 mActionRemoveVoice->plug( changeMenu ); 1876 mActionRemoveVoice->plug( changeMenu );
1877 // settings menu 1877 // settings menu
1878//US special menuentry to configure the addressbook resources. On KDE 1878//US special menuentry to configure the addressbook resources. On KDE
1879// you do that through the control center !!! 1879// you do that through the control center !!!
1880 mActionConfigResources->plug( settingsMenu ); 1880 mActionConfigResources->plug( settingsMenu );
1881 settingsMenu->insertSeparator(); 1881 settingsMenu->insertSeparator();
1882 1882
1883 mActionConfigKAddressbook->plug( settingsMenu ); 1883 mActionConfigKAddressbook->plug( settingsMenu );
1884 1884
1885 if ( mIsPart ) { 1885 if ( mIsPart ) {
1886 mActionConfigShortcuts->plug( settingsMenu ); 1886 mActionConfigShortcuts->plug( settingsMenu );
1887 mActionConfigureToolbars->plug( settingsMenu ); 1887 mActionConfigureToolbars->plug( settingsMenu );
1888 1888
1889 } else { 1889 } else {
1890 mActionKeyBindings->plug( settingsMenu ); 1890 mActionKeyBindings->plug( settingsMenu );
1891 } 1891 }
1892 1892
1893 settingsMenu->insertSeparator(); 1893 settingsMenu->insertSeparator();
1894 1894
1895 mActionJumpBar->plug( settingsMenu ); 1895 mActionJumpBar->plug( settingsMenu );
1896 mActionDetails->plug( settingsMenu ); 1896 mActionDetails->plug( settingsMenu );
1897 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1897 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1898 mActionDetails->plug( tb ); 1898 mActionDetails->plug( tb );
1899 settingsMenu->insertSeparator(); 1899 settingsMenu->insertSeparator();
1900 1900
1901 mActionWhoAmI->plug( settingsMenu ); 1901 mActionWhoAmI->plug( settingsMenu );
1902 mActionCategories->plug( settingsMenu ); 1902 mActionCategories->plug( settingsMenu );
1903 1903
1904 mActionLicence->plug( helpMenu ); 1904 mActionLicence->plug( helpMenu );
1905 mActionFaq->plug( helpMenu ); 1905 mActionFaq->plug( helpMenu );
1906 mActionAboutKAddressbook->plug( helpMenu ); 1906 mActionAboutKAddressbook->plug( helpMenu );
1907 1907
1908 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1908 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1909 1909
1910 mActionSave->plug( tb ); 1910 mActionSave->plug( tb );
1911 mViewManager->getFilterAction()->plug ( tb); 1911 mViewManager->getFilterAction()->plug ( tb);
1912 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1912 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1913 mActionUndo->plug( tb ); 1913 mActionUndo->plug( tb );
1914 mActionDelete->plug( tb ); 1914 mActionDelete->plug( tb );
1915 mActionRedo->plug( tb ); 1915 mActionRedo->plug( tb );
1916 } 1916 }
1917 } 1917 }
1918 //mActionQuit->plug ( tb ); 1918 //mActionQuit->plug ( tb );
1919 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1919 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1920 1920
1921 //US link the searchwidget first to this. 1921 //US link the searchwidget first to this.
1922 // The real linkage to the toolbar happens later. 1922 // The real linkage to the toolbar happens later.
1923//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1923//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1924//US tb->insertItem( mIncSearchWidget ); 1924//US tb->insertItem( mIncSearchWidget );
1925/*US 1925/*US
1926 mIncSearchWidget = new IncSearchWidget( tb ); 1926 mIncSearchWidget = new IncSearchWidget( tb );
1927 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1927 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1928 SLOT( incrementalSearch( const QString& ) ) ); 1928 SLOT( incrementalSearch( const QString& ) ) );
1929 1929
1930 mJumpButtonBar = new JumpButtonBar( this, this ); 1930 mJumpButtonBar = new JumpButtonBar( this, this );
1931 1931
1932//US topLayout->addWidget( mJumpButtonBar ); 1932//US topLayout->addWidget( mJumpButtonBar );
1933 this->layout()->add( mJumpButtonBar ); 1933 this->layout()->add( mJumpButtonBar );
1934*/ 1934*/
1935 1935
1936#endif //KAB_EMBEDDED 1936#endif //KAB_EMBEDDED
1937} 1937}
1938void KABCore::showLicence() 1938void KABCore::showLicence()
1939{ 1939{
1940 KApplication::showLicence(); 1940 KApplication::showLicence();
1941} 1941}
1942void KABCore::removeVoice() 1942void KABCore::removeVoice()
1943{ 1943{
1944 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 ) 1944 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 )
1945 return; 1945 return;
1946 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1946 KABC::Addressee::List list = mViewManager->selectedAddressees();
1947 KABC::Addressee::List::Iterator it; 1947 KABC::Addressee::List::Iterator it;
1948 for ( it = list.begin(); it != list.end(); ++it ) { 1948 for ( it = list.begin(); it != list.end(); ++it ) {
1949 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1949 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1950 PhoneNumber::List::Iterator phoneIt; 1950 PhoneNumber::List::Iterator phoneIt;
1951 bool found = false; 1951 bool found = false;
1952 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1952 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1953 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1953 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1954 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1954 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1955 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1955 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1956 (*it).insertPhoneNumber( (*phoneIt) ); 1956 (*it).insertPhoneNumber( (*phoneIt) );
1957 found = true; 1957 found = true;
1958 } 1958 }
1959 } 1959 }
1960 1960
1961 } 1961 }
1962 if ( found ) 1962 if ( found )
1963 contactModified((*it) ); 1963 contactModified((*it) );
1964 } 1964 }
1965} 1965}
1966 1966
1967 1967
1968 1968
1969void KABCore::clipboardDataChanged() 1969void KABCore::clipboardDataChanged()
1970{ 1970{
1971 1971
1972 if ( mReadWrite ) 1972 if ( mReadWrite )
1973 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1973 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1974 1974
1975} 1975}
1976 1976
1977void KABCore::updateActionMenu() 1977void KABCore::updateActionMenu()
1978{ 1978{
1979 UndoStack *undo = UndoStack::instance(); 1979 UndoStack *undo = UndoStack::instance();
1980 RedoStack *redo = RedoStack::instance(); 1980 RedoStack *redo = RedoStack::instance();
1981 1981
1982 if ( undo->isEmpty() ) 1982 if ( undo->isEmpty() )
1983 mActionUndo->setText( i18n( "Undo" ) ); 1983 mActionUndo->setText( i18n( "Undo" ) );
1984 else 1984 else
1985 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1985 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1986 1986
1987 mActionUndo->setEnabled( !undo->isEmpty() ); 1987 mActionUndo->setEnabled( !undo->isEmpty() );
1988 1988
1989 if ( !redo->top() ) 1989 if ( !redo->top() )
1990 mActionRedo->setText( i18n( "Redo" ) ); 1990 mActionRedo->setText( i18n( "Redo" ) );
1991 else 1991 else
1992 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1992 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1993 1993
1994 mActionRedo->setEnabled( !redo->isEmpty() ); 1994 mActionRedo->setEnabled( !redo->isEmpty() );
1995} 1995}
1996 1996
1997void KABCore::configureKeyBindings() 1997void KABCore::configureKeyBindings()
1998{ 1998{
1999#ifndef KAB_EMBEDDED 1999#ifndef KAB_EMBEDDED
2000 KKeyDialog::configure( actionCollection(), true ); 2000 KKeyDialog::configure( actionCollection(), true );
2001#else //KAB_EMBEDDED 2001#else //KAB_EMBEDDED
2002 qDebug("KABCore::configureKeyBindings() not implemented"); 2002 qDebug("KABCore::configureKeyBindings() not implemented");
2003#endif //KAB_EMBEDDED 2003#endif //KAB_EMBEDDED
2004} 2004}
2005 2005
2006#ifdef KAB_EMBEDDED 2006#ifdef KAB_EMBEDDED
2007void KABCore::configureResources() 2007void KABCore::configureResources()
2008{ 2008{
2009 KRES::KCMKResources dlg( this, "" , 0 ); 2009 KRES::KCMKResources dlg( this, "" , 0 );
2010 2010
2011 if ( !dlg.exec() ) 2011 if ( !dlg.exec() )
2012 return; 2012 return;
2013 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2013 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2014} 2014}
2015#endif //KAB_EMBEDDED 2015#endif //KAB_EMBEDDED
2016 2016
2017 2017
2018/* this method will be called through the QCop interface from Ko/Pi to select addresses 2018/* this method will be called through the QCop interface from Ko/Pi to select addresses
2019 * for the attendees list of an event. 2019 * for the attendees list of an event.
2020 */ 2020 */
2021void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2021void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2022{ 2022{
2023 QStringList nameList; 2023 QStringList nameList;
2024 QStringList emailList; 2024 QStringList emailList;
2025 QStringList uidList; 2025 QStringList uidList;
2026 2026
2027 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2027 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2028 uint i=0; 2028 uint i=0;
2029 for (i=0; i < list.count(); i++) 2029 for (i=0; i < list.count(); i++)
2030 { 2030 {
2031 nameList.append(list[i].realName()); 2031 nameList.append(list[i].realName());
2032 emailList.append(list[i].preferredEmail()); 2032 emailList.append(list[i].preferredEmail());
2033 uidList.append(list[i].uid()); 2033 uidList.append(list[i].uid());
2034 } 2034 }
2035 2035
2036 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2036 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2037 2037
2038} 2038}
2039 2039
2040/* this method will be called through the QCop interface from other apps to show details of a contact. 2040/* this method will be called through the QCop interface from other apps to show details of a contact.
2041 */ 2041 */
2042void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2042void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2043{ 2043{
2044 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2044 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2045 2045
2046 QString foundUid = QString::null; 2046 QString foundUid = QString::null;
2047 if (uid.isEmpty()) 2047 if ( ! uid.isEmpty() ) {
2048 Addressee adrr = mAddressBook->findByUid( uid );
2049 if ( !adrr.isEmpty() ) {
2050 foundUid = uid;
2051 if ( email == "sendbacklist" ) {
2052 QStringList nameList;
2053 QStringList emailList;
2054 QStringList uidList;
2055 nameList.append(adrr.realName());
2056 emailList = adrr.emails();
2057 uidList.append( adrr.preferredEmail());
2058 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2059 }
2060 }
2061 }
2062
2063 if ( email == "sendback" )
2064 return;
2065 if (foundUid.isEmpty())
2048 { 2066 {
2049 //find the uid of the person first 2067 //find the uid of the person first
2050 Addressee::List namelist; 2068 Addressee::List namelist;
2051 Addressee::List emaillist; 2069 Addressee::List emaillist;
2052 2070
2053 if (!name.isEmpty()) 2071 if (!name.isEmpty())
2054 namelist = mAddressBook->findByName( name ); 2072 namelist = mAddressBook->findByName( name );
2055 2073
2056 if (!email.isEmpty()) 2074 if (!email.isEmpty())
2057 emaillist = mAddressBook->findByEmail( email ); 2075 emaillist = mAddressBook->findByEmail( email );
2058 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2076 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2059 //check if we have a match in Namelist and Emaillist 2077 //check if we have a match in Namelist and Emaillist
2060 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2078 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2061 foundUid = emaillist[0].uid(); 2079 foundUid = emaillist[0].uid();
2062 } 2080 }
2063 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2081 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2064 foundUid = namelist[0].uid(); 2082 foundUid = namelist[0].uid();
2065 else 2083 else
2066 { 2084 {
2067 for (int i = 0; i < namelist.count(); i++) 2085 for (int i = 0; i < namelist.count(); i++)
2068 { 2086 {
2069 for (int j = 0; j < emaillist.count(); j++) 2087 for (int j = 0; j < emaillist.count(); j++)
2070 { 2088 {
2071 if (namelist[i] == emaillist[j]) 2089 if (namelist[i] == emaillist[j])
2072 { 2090 {
2073 foundUid = namelist[i].uid(); 2091 foundUid = namelist[i].uid();
2074 } 2092 }
2075 } 2093 }
2076 } 2094 }
2077 } 2095 }
2078 } 2096 }
2079 else 2097 else
2080 { 2098 {
2081 foundUid = uid; 2099 foundUid = uid;
2082 } 2100 }
2083 2101
2084 if (!foundUid.isEmpty()) 2102 if (!foundUid.isEmpty())
2085 { 2103 {
2086 2104
2087 // raise Ka/Pi if it is in the background 2105 // raise Ka/Pi if it is in the background
2088#ifndef DESKTOP_VERSION 2106#ifndef DESKTOP_VERSION
2089#ifndef KORG_NODCOP 2107#ifndef KORG_NODCOP
2090 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2108 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2091#endif 2109#endif
2092#endif 2110#endif
2093 2111
2094 mMainWindow->showMaximized(); 2112 mMainWindow->showMaximized();
2095 mMainWindow-> raise(); 2113 mMainWindow-> raise();
2096 2114
2097 mViewManager->setSelected( "", false); 2115 mViewManager->setSelected( "", false);
2098 mViewManager->refreshView( "" ); 2116 mViewManager->refreshView( "" );
2099 mViewManager->setSelected( foundUid, true ); 2117 mViewManager->setSelected( foundUid, true );
2100 mViewManager->refreshView( foundUid ); 2118 mViewManager->refreshView( foundUid );
2101 2119
2102 if ( !mMultipleViewsAtOnce ) 2120 if ( !mMultipleViewsAtOnce )
2103 { 2121 {
2104 setDetailsVisible( true ); 2122 setDetailsVisible( true );
2105 mActionDetails->setChecked(true); 2123 mActionDetails->setChecked(true);
2106 } 2124 }
2107 } 2125 }
2108} 2126}
2109 2127
2110 2128
2111void KABCore::faq() 2129void KABCore::faq()
2112{ 2130{
2113 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2131 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2114} 2132}
2115 2133
2116 2134
2117 2135
2118 2136
2119#ifndef KAB_EMBEDDED 2137#ifndef KAB_EMBEDDED
2120#include "kabcore.moc" 2138#include "kabcore.moc"
2121#endif //KAB_EMBEDDED 2139#endif //KAB_EMBEDDED
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 654cfc0..5f446fa 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,376 +1,453 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3#include "composemail.h" 3#include "composemail.h"
4 4
5#include <libmailwrapper/smtpwrapper.h> 5#include <libmailwrapper/smtpwrapper.h>
6#include <libmailwrapper/storemail.h> 6#include <libmailwrapper/storemail.h>
7#include <libmailwrapper/abstractmail.h> 7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9 9
10/* OPIE */ 10/* OPIE */
11//#include <opie2/ofiledialog.h> 11//#include <opie2/ofiledialog.h>
12//#include <opie2/odebug.h> 12//#include <opie2/odebug.h>
13#include <kfiledialog.h> 13#include <kfiledialog.h>
14//#include <qpe/resource.h> 14//#include <qpe/resource.h>
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include <qpe/global.h> 16#include <qpe/global.h>
17//#include <qpe/contact.h> 17//#include <qpe/contact.h>
18 18
19 19
20#include <qcombobox.h> 20#include <qcombobox.h>
21#include <qcheckbox.h> 21#include <qcheckbox.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qmultilineedit.h> 25#include <qmultilineedit.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <kabc/addresseedialog.h> 29#include <kabc/addresseedialog.h>
30#include <kabc/stdaddressbook.h> 30#include <kabc/stdaddressbook.h>
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32 32#ifdef DESKTOP_VERSION
33#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION
33 37
34 38
35//using namespace Opie::Core; 39//using namespace Opie::Core;
36//using namespace Opie::Ui; 40//using namespace Opie::Ui;
37ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 41ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
38 : ComposeMailUI( parent, name, modal, flags ) 42 : ComposeMailUI( parent, name, modal, flags )
39{ 43{
40 44
45 mPickLineEdit = 0;
46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
41 settings = s; 48 settings = s;
42 m_replyid = ""; 49 m_replyid = "";
50 KConfig config( locateLocal("config", "kabcrc") );
51 config.setGroup( "General" );
52 QString whoami_uid = config.readEntry( "WhoAmI" );
53 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
54#ifdef DESKTOP_VERSION
43 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 55 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
44 QStringList mails = con.emails(); 56 QStringList mails = con.emails();
45 QString defmail = con.preferredEmail(); 57 QString defmail = con.preferredEmail();
46 if ( mails.count() == 0) 58 if ( mails.count() == 0)
47 QMessageBox::information( 0, tr( "Hint" ), 59 QMessageBox::information( 0, tr( "Hint" ),
48 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 60 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
49 tr( "Ok" ) ); 61 tr( "Ok" ) );
50 if (defmail.length()!=0) { 62 if (defmail.length()!=0) {
51 fromBox->insertItem(defmail); 63 fromBox->insertItem(defmail);
52 } 64 }
53 QStringList::ConstIterator sit = mails.begin(); 65 QStringList::ConstIterator sit = mails.begin();
54 for (;sit!=mails.end();++sit) { 66 for (;sit!=mails.end();++sit) {
55 if ( (*sit)==defmail) 67 if ( (*sit)==defmail)
56 continue; 68 continue;
57 fromBox->insertItem((*sit)); 69 fromBox->insertItem((*sit));
58 } 70 }
59 senderNameEdit->setText(con.formattedName()); 71 senderNameEdit->setText(con.formattedName());
72#endif
60 Config cfg( "mail" ); 73 Config cfg( "mail" );
61 cfg.setGroup( "Compose" ); 74 cfg.setGroup( "Compose" );
62 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 75 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
63 76
64 attList->addColumn( tr( "Name" ) ); 77 attList->addColumn( tr( "Name" ) );
65 attList->addColumn( tr( "Size" ) ); 78 attList->addColumn( tr( "Size" ) );
66 79
67 QList<Account> accounts = settings->getAccounts(); 80 QList<Account> accounts = settings->getAccounts();
68 81
69 Account *it; 82 Account *it;
70 for ( it = accounts.first(); it; it = accounts.next() ) { 83 for ( it = accounts.first(); it; it = accounts.next() ) {
71 if ( it->getType()==MAILLIB::A_SMTP ) { 84 if ( it->getType()==MAILLIB::A_SMTP ) {
72 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 85 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
73 smtpAccountBox->insertItem( smtp->getAccountName() ); 86 smtpAccountBox->insertItem( smtp->getAccountName() );
74 smtpAccounts.append( smtp ); 87 smtpAccounts.append( smtp );
75 } 88 }
76 } 89 }
77 if ( smtpAccounts.count() > 0 ) { 90 if ( smtpAccounts.count() > 0 ) {
78 fillValues( smtpAccountBox->currentItem() ); 91 fillValues( smtpAccountBox->currentItem() );
79 } else { 92 } else {
80 QMessageBox::information( 0, tr( "Problem" ), 93 QMessageBox::information( 0, tr( "Problem" ),
81 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), 94 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
82 tr( "Ok" ) ); 95 tr( "Ok" ) );
83 return; 96 return;
84 } 97 }
85 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 98 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
86 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 99 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
87 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 100 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
88 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 101 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
89 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 102 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
90 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 103 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
91 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 104 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
92 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 105 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
93 mMail = 0; 106 mMail = 0;
94 warnAttach = true; 107 warnAttach = true;
95 108
96} 109}
110
111
112
97void ComposeMail::saveAsDraft() 113void ComposeMail::saveAsDraft()
98{ 114{
99 115
100 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 116 Opie::Core::OSmartPointer<Mail> mail= new Mail();
101 mail->setMail(fromBox->currentText()); 117 mail->setMail(fromBox->currentText());
102 mail->setTo( toLine->text() ); 118 mail->setTo( toLine->text() );
103 mail->setName(senderNameEdit->text()); 119 mail->setName(senderNameEdit->text());
104 mail->setCC( ccLine->text() ); 120 mail->setCC( ccLine->text() );
105 mail->setBCC( bccLine->text() ); 121 mail->setBCC( bccLine->text() );
106 mail->setReply( replyLine->text() ); 122 mail->setReply( replyLine->text() );
107 mail->setSubject( subjectLine->text() ); 123 mail->setSubject( subjectLine->text() );
108 if (!m_replyid.isEmpty()) { 124 if (!m_replyid.isEmpty()) {
109 QStringList ids; 125 QStringList ids;
110 ids.append(m_replyid); 126 ids.append(m_replyid);
111 mail->setInreply(ids); 127 mail->setInreply(ids);
112 } 128 }
113 QString txt = message->text(); 129 QString txt = message->text();
114 if ( !sigMultiLine->text().isEmpty() ) { 130 if ( !sigMultiLine->text().isEmpty() ) {
115 txt.append( "\n--\n" ); 131 txt.append( "\n--\n" );
116 txt.append( sigMultiLine->text() ); 132 txt.append( sigMultiLine->text() );
117 } 133 }
118 mail->setMessage( txt ); 134 mail->setMessage( txt );
119 135
120 /* only use the default drafts folder name! */ 136 /* only use the default drafts folder name! */
121 Storemail wrapper(AbstractMail::draftFolder()); 137 Storemail wrapper(AbstractMail::draftFolder());
122 wrapper.storeMail(mail); 138 wrapper.storeMail(mail);
123 139
124 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 140 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
125 /* attachments we will ignore! */ 141 /* attachments we will ignore! */
126 if ( it != 0 ) { 142 if ( it != 0 ) {
127 if ( warnAttach ) 143 if ( warnAttach )
128 QMessageBox::warning(0,tr("Store message"), 144 QMessageBox::warning(0,tr("Store message"),
129 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 145 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
130 warnAttach = false; 146 warnAttach = false;
131 } 147 }
132 setStatus( tr("Mail saved as draft!") ); 148 setStatus( tr("Mail saved as draft!") );
133} 149}
134void ComposeMail::clearStatus() 150void ComposeMail::clearStatus()
135{ 151{
136 topLevelWidget()->setCaption( tr("Compose mail") ); 152 topLevelWidget()->setCaption( tr("Compose mail") );
137} 153}
138void ComposeMail::setStatus( QString status ) 154void ComposeMail::setStatus( QString status )
139{ 155{
140 topLevelWidget()->setCaption( status ); 156 topLevelWidget()->setCaption( status );
141 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 157 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
142} 158}
143void ComposeMail::pickAddress( QLineEdit *line ) 159void ComposeMail::pickAddress( )
144{ 160{
161
162 QLineEdit *line = mPickLineEdit;
163 if ( line == 0 )
164 return;
165#ifdef DESKTOP_VERSION
145 //qDebug(" ComposeMail::pickAddress "); 166 //qDebug(" ComposeMail::pickAddress ");
146 QString names ;//= AddressPicker::getNames(); 167 QString names ;//= AddressPicker::getNames();
147 168
148 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 169 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
149 uint i=0; 170 uint i=0;
150 for (i=0; i < list.count(); i++) { 171 for (i=0; i < list.count(); i++) {
151 if ( !list[i].preferredEmail().isEmpty()) { 172 if ( !list[i].preferredEmail().isEmpty()) {
152 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 173 if ( ! names.isEmpty() )
153 if ( i < list.count() -1 )
154 names+= ","; 174 names+= ",";
175 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
176
155 } 177 }
156 } 178 }
157 179
158 180
159 if ( line->text().isEmpty() ) { 181 if ( line->text().isEmpty() ) {
160 line->setText( names ); 182 line->setText( names );
161 } else if ( !names.isEmpty() ) { 183 } else if ( !names.isEmpty() ) {
162 line->setText( line->text() + ", " + names ); 184 line->setText( line->text() + ", " + names );
163 } 185 }
186#else
187 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
188 // the result should now arrive through method insertAttendees
189#endif
190}
191//the map includes name/email pairs, that comes from Ka/Pi
192void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
193{
194 qDebug("ComposeMail::insertAttendees ");
195 raise();
196
197 if ( mPickLineEdit == 0 ) { //whoami received
198
199 QString defmail = uidList[0];
200 if ( emailList.count() == 0 )
201 QMessageBox::information( 0, tr( "Hint" ),
202 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
203 tr( "Ok" ) );
204 if (defmail.length()!=0) {
205 fromBox->insertItem(defmail);
206 }
207 QStringList::ConstIterator sit = emailList.begin();
208 int pref = 0;
209 for (;sit!=emailList.end();++sit) {
210 if ( (*sit)==defmail)
211 continue;
212 fromBox->insertItem((*sit));
213 }
214 senderNameEdit->setText(nameList[0]);
215 return;
216 }
217 QString names ;
218 QLineEdit *line = mPickLineEdit;
219 if (uid == this->name())
220 {
221 for ( int i = 0; i < nameList.count(); i++)
222 {
223 QString _name = nameList[i];
224 QString _email = emailList[i];
225 QString _uid = uidList[i];
226 if ( ! _email.isEmpty() ) {
227 if ( ! names.isEmpty() )
228 names+= ",";
229 names+= "\""+_name +"\"<" +_email +">";
230 }
231 }
232 }
233 if ( line->text().isEmpty() ) {
234 line->setText( names );
235 } else if ( !names.isEmpty() ) {
236 line->setText( line->text() + ", " + names );
237 }
164} 238}
165
166 239
167void ComposeMail::setTo( const QString & to ) 240void ComposeMail::setTo( const QString & to )
168{ 241{
169 toLine->setText( to ); 242 toLine->setText( to );
170} 243}
171 244
172void ComposeMail::setSubject( const QString & subject ) 245void ComposeMail::setSubject( const QString & subject )
173{ 246{
174 subjectLine->setText( subject ); 247 subjectLine->setText( subject );
175} 248}
176 249
177void ComposeMail::setInReplyTo( const QString & messageId ) 250void ComposeMail::setInReplyTo( const QString & messageId )
178{ 251{
179 m_replyid = messageId; 252 m_replyid = messageId;
180} 253}
181 254
182void ComposeMail::setMessage( const QString & text ) 255void ComposeMail::setMessage( const QString & text )
183{ 256{
184 message->setText( text ); 257 message->setText( text );
185} 258}
186 259
187 260
188void ComposeMail::pickAddressTo() 261void ComposeMail::pickAddressTo()
189{ 262{
190 pickAddress( toLine ); 263 mPickLineEdit = toLine;
264 pickAddress( );
191} 265}
192 266
193void ComposeMail::pickAddressCC() 267void ComposeMail::pickAddressCC()
194{ 268{
195 pickAddress( ccLine ); 269 mPickLineEdit = ccLine;
270 pickAddress( );
196} 271}
197 272
198void ComposeMail::pickAddressBCC() 273void ComposeMail::pickAddressBCC()
199{ 274{
200 pickAddress( bccLine ); 275 mPickLineEdit = bccLine;
276 pickAddress( );
201} 277}
202 278
203void ComposeMail::pickAddressReply() 279void ComposeMail::pickAddressReply()
204{ 280{
205 pickAddress( replyLine ); 281 mPickLineEdit = replyLine;
282 pickAddress( );
206} 283}
207 284
208void ComposeMail::fillValues( int ) 285void ComposeMail::fillValues( int )
209{ 286{
210#if 0 287#if 0
211 SMTPaccount *smtp = smtpAccounts.at( current ); 288 SMTPaccount *smtp = smtpAccounts.at( current );
212 ccLine->clear(); 289 ccLine->clear();
213 if ( smtp->getUseCC() ) { 290 if ( smtp->getUseCC() ) {
214 ccLine->setText( smtp->getCC() ); 291 ccLine->setText( smtp->getCC() );
215 } 292 }
216 bccLine->clear(); 293 bccLine->clear();
217 if ( smtp->getUseBCC() ) { 294 if ( smtp->getUseBCC() ) {
218 bccLine->setText( smtp->getBCC() ); 295 bccLine->setText( smtp->getBCC() );
219 } 296 }
220 replyLine->clear(); 297 replyLine->clear();
221 if ( smtp->getUseReply() ) { 298 if ( smtp->getUseReply() ) {
222 replyLine->setText( smtp->getReply() ); 299 replyLine->setText( smtp->getReply() );
223 } 300 }
224 sigMultiLine->setText( smtp->getSignature() ); 301 sigMultiLine->setText( smtp->getSignature() );
225#endif 302#endif
226} 303}
227 304
228void ComposeMail::slotAdjustColumns() 305void ComposeMail::slotAdjustColumns()
229{ 306{
230 int currPage = tabWidget->currentPageIndex(); 307 int currPage = tabWidget->currentPageIndex();
231 308
232 tabWidget->showPage( attachTab ); 309 tabWidget->showPage( attachTab );
233 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 310 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
234 attList->setColumnWidth( 1, 80 ); 311 attList->setColumnWidth( 1, 80 );
235 312
236 tabWidget->setCurrentPage( currPage ); 313 tabWidget->setCurrentPage( currPage );
237} 314}
238 315
239void ComposeMail::addAttachment() 316void ComposeMail::addAttachment()
240{ 317{
241 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 318 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
242 if ( !lnk.isEmpty() ) { 319 if ( !lnk.isEmpty() ) {
243 Attachment *att = new Attachment( lnk ); 320 Attachment *att = new Attachment( lnk );
244 (void) new AttachViewItem( attList, att ); 321 (void) new AttachViewItem( attList, att );
245 } 322 }
246} 323}
247 324
248void ComposeMail::removeAttachment() 325void ComposeMail::removeAttachment()
249{ 326{
250 if ( !attList->currentItem() ) { 327 if ( !attList->currentItem() ) {
251 QMessageBox::information( this, tr( "Error" ), 328 QMessageBox::information( this, tr( "Error" ),
252 tr( "<p>Please select a File.</p>" ), 329 tr( "<p>Please select a File.</p>" ),
253 tr( "Ok" ) ); 330 tr( "Ok" ) );
254 } else { 331 } else {
255 attList->takeItem( attList->currentItem() ); 332 attList->takeItem( attList->currentItem() );
256 } 333 }
257} 334}
258 335
259void ComposeMail::accept() 336void ComposeMail::accept()
260{ 337{
261 if ( smtpAccountBox->count() == 0 ) { 338 if ( smtpAccountBox->count() == 0 ) {
262 339
263 reject(); 340 reject();
264 return; 341 return;
265 } 342 }
266 343
267 if (! checkBoxLater->isChecked() ) { 344 if (! checkBoxLater->isChecked() ) {
268 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 345 int yesno = QMessageBox::warning(0,tr("Stop editing message"),
269 tr("Send this message?"), 346 tr("Send this message?"),
270 tr("Yes"), 347 tr("Yes"),
271 tr("Cancel")); 348 tr("Cancel"));
272 349
273 if (yesno == 1) { 350 if (yesno == 1) {
274 return; 351 return;
275 } 352 }
276 } 353 }
277#if 0 354#if 0
278 odebug << "Sending Mail with " 355 odebug << "Sending Mail with "
279 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 356 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
280#endif 357#endif
281 Opie::Core::OSmartPointer<Mail> mail=new Mail; 358 Opie::Core::OSmartPointer<Mail> mail=new Mail;
282 359
283 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 360 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
284 mail->setMail(fromBox->currentText()); 361 mail->setMail(fromBox->currentText());
285 362
286 if ( !toLine->text().isEmpty() ) { 363 if ( !toLine->text().isEmpty() ) {
287 mail->setTo( toLine->text() ); 364 mail->setTo( toLine->text() );
288 } else { 365 } else {
289 QMessageBox::warning(0,tr("Sending mail"), 366 QMessageBox::warning(0,tr("Sending mail"),
290 tr("No Receiver spezified" ) ); 367 tr("No Receiver spezified" ) );
291 return; 368 return;
292 } 369 }
293 370
294 mail->setName(senderNameEdit->text()); 371 mail->setName(senderNameEdit->text());
295 mail->setCC( ccLine->text() ); 372 mail->setCC( ccLine->text() );
296 mail->setBCC( bccLine->text() ); 373 mail->setBCC( bccLine->text() );
297 mail->setReply( replyLine->text() ); 374 mail->setReply( replyLine->text() );
298 mail->setSubject( subjectLine->text() ); 375 mail->setSubject( subjectLine->text() );
299 if (!m_replyid.isEmpty()) { 376 if (!m_replyid.isEmpty()) {
300 QStringList ids; 377 QStringList ids;
301 ids.append(m_replyid); 378 ids.append(m_replyid);
302 mail->setInreply(ids); 379 mail->setInreply(ids);
303 } 380 }
304 QString txt = message->text(); 381 QString txt = message->text();
305 if ( !sigMultiLine->text().isEmpty() ) { 382 if ( !sigMultiLine->text().isEmpty() ) {
306 txt.append( "\n--\n" ); 383 txt.append( "\n--\n" );
307 txt.append( sigMultiLine->text() ); 384 txt.append( sigMultiLine->text() );
308 } 385 }
309 mail->setMessage( txt ); 386 mail->setMessage( txt );
310 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 387 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
311 while ( it != 0 ) { 388 while ( it != 0 ) {
312 mail->addAttachment( it->getAttachment() ); 389 mail->addAttachment( it->getAttachment() );
313 it = (AttachViewItem *) it->nextSibling(); 390 it = (AttachViewItem *) it->nextSibling();
314 } 391 }
315 392
316 SMTPwrapper wrapper( smtp ); 393 SMTPwrapper wrapper( smtp );
317 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 394 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
318 setStatus( tr ("Mail sent")); 395 setStatus( tr ("Mail sent"));
319 else { 396 else {
320 setStatus( tr ("Error: Something went wrong. Nothing sent")); 397 setStatus( tr ("Error: Something went wrong. Nothing sent"));
321 return; 398 return;
322 } 399 }
323 400
324 401
325 QDialog::accept(); 402 QDialog::accept();
326} 403}
327 404
328void ComposeMail::reject() 405void ComposeMail::reject()
329{ 406{
330 //qDebug("ComposeMail::reject() "); 407 //qDebug("ComposeMail::reject() ");
331 int yesno = QMessageBox::warning(0,tr("Store message?"), 408 int yesno = QMessageBox::warning(0,tr("Store message?"),
332 tr("Store message into drafts?\n"), 409 tr("Store message into drafts?\n"),
333 tr("Yes"), 410 tr("Yes"),
334 tr("No")); 411 tr("No"));
335 412
336 //qDebug("button %d ", yesno); 413 //qDebug("button %d ", yesno);
337 if (yesno == 0) { 414 if (yesno == 0) {
338 if ( toLine->text().isEmpty() ) { 415 if ( toLine->text().isEmpty() ) {
339 QMessageBox::warning(0,tr("Sending mail"), 416 QMessageBox::warning(0,tr("Sending mail"),
340 tr("No Receiver spezified" ) ); 417 tr("No Receiver spezified" ) );
341 return; 418 return;
342 } 419 }
343 saveAsDraft(); 420 saveAsDraft();
344 } 421 }
345 if (yesno == 2) { 422 if (yesno == 2) {
346 qDebug("return "); 423 qDebug("return ");
347 return; 424 return;
348 } 425 }
349 QDialog::reject(); 426 QDialog::reject();
350} 427}
351 428
352ComposeMail::~ComposeMail() 429ComposeMail::~ComposeMail()
353{ 430{
354} 431}
355 432
356void ComposeMail::reEditMail(const RecMailP&current) 433void ComposeMail::reEditMail(const RecMailP&current)
357{ 434{
358 RecMailP data = current; 435 RecMailP data = current;
359 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 436 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
360 subjectLine->setText( data->getSubject()); 437 subjectLine->setText( data->getSubject());
361 toLine->setText(data->To().join(",")); 438 toLine->setText(data->To().join(","));
362 ccLine->setText(data->CC().join(",")); 439 ccLine->setText(data->CC().join(","));
363 bccLine->setText(data->Bcc().join(",")); 440 bccLine->setText(data->Bcc().join(","));
364 replyLine->setText(data->Replyto()); 441 replyLine->setText(data->Replyto());
365} 442}
366 443
367AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 444AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
368 : QListViewItem( parent ) 445 : QListViewItem( parent )
369{ 446{
370 attachment = att; 447 attachment = att;
371 if ( !attachment->getPixmap().isNull() ) 448 if ( !attachment->getPixmap().isNull() )
372 setPixmap( 0,attachment->getPixmap() ); 449 setPixmap( 0,attachment->getPixmap() );
373 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 450 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
374 setText( 1, QString::number( att->getSize() ) ); 451 setText( 1, QString::number( att->getSize() ) );
375} 452}
376 453
diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h
index 876b597..657f665 100644
--- a/kmicromail/composemail.h
+++ b/kmicromail/composemail.h
@@ -1,86 +1,90 @@
1#ifndef COMPOSEMAIL_H 1#ifndef COMPOSEMAIL_H
2#define COMPOSEMAIL_H 2#define COMPOSEMAIL_H
3 3
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "composemailui.h" 7#include "composemailui.h"
8//#include "addresspickerui.h" 8//#include "addresspickerui.h"
9#include <libmailwrapper/settings.h> 9#include <libmailwrapper/settings.h>
10#include <libmailwrapper/mailwrapper.h> 10#include <libmailwrapper/mailwrapper.h>
11 11
12class RecMail; 12class RecMail;
13 13
14#include <opie2/osmartpointer.h> 14#include <opie2/osmartpointer.h>
15#if 0 15#if 0
16class AddressPicker : public AddressPickerUI 16class AddressPicker : public AddressPickerUI
17{ 17{
18 //Q_OBJECT 18 //Q_OBJECT
19 19
20public: 20public:
21 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 21 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
22 static QString getNames(); 22 static QString getNames();
23 23
24protected: 24protected:
25 QString selectedNames; 25 QString selectedNames;
26 void accept(); 26 void accept();
27 27
28}; 28};
29#endif 29#endif
30class RecMail; 30class RecMail;
31 31
32class ComposeMail : public ComposeMailUI 32class ComposeMail : public ComposeMailUI
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37
37 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 38 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
38 virtual ~ComposeMail(); 39 virtual ~ComposeMail();
39 40
40 void reEditMail(const Opie::Core::OSmartPointer<RecMail>&current); 41 void reEditMail(const Opie::Core::OSmartPointer<RecMail>&current);
41 42
42public slots: 43public slots:
43 void slotAdjustColumns(); 44 void slotAdjustColumns();
44 45
45 void setTo( const QString & to ); 46 void setTo( const QString & to );
46 void setSubject( const QString & subject ); 47 void setSubject( const QString & subject );
47 void setInReplyTo( const QString & messageId ); 48 void setInReplyTo( const QString & messageId );
48 void setMessage( const QString & text ); 49 void setMessage( const QString & text );
50 void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist);
51
49 52
50protected slots: 53protected slots:
51 void accept(); 54 void accept();
52 void reject(); 55 void reject();
53 56
54private slots: 57private slots:
55 void fillValues( int current ); 58 void fillValues( int current );
56 void pickAddress( QLineEdit *line ); 59 void pickAddress();
57 void pickAddressTo(); 60 void pickAddressTo();
58 void pickAddressCC(); 61 void pickAddressCC();
59 void pickAddressBCC(); 62 void pickAddressBCC();
60 void pickAddressReply(); 63 void pickAddressReply();
61 void saveAsDraft(); 64 void saveAsDraft();
62 void addAttachment(); 65 void addAttachment();
63 void removeAttachment(); 66 void removeAttachment();
64 void clearStatus(); 67 void clearStatus();
65 void setStatus( QString ); 68 void setStatus( QString );
66 69
67protected: 70protected:
71 QLineEdit* mPickLineEdit;
68 Opie::Core::OSmartPointer<Mail> mMail; 72 Opie::Core::OSmartPointer<Mail> mMail;
69 Settings *settings; 73 Settings *settings;
70 QList<SMTPaccount> smtpAccounts; 74 QList<SMTPaccount> smtpAccounts;
71 QString m_replyid; 75 QString m_replyid;
72 bool warnAttach; 76 bool warnAttach;
73}; 77};
74 78
75class AttachViewItem : public QListViewItem 79class AttachViewItem : public QListViewItem
76{ 80{
77public: 81public:
78 AttachViewItem( QListView *parent, Attachment *att ); 82 AttachViewItem( QListView *parent, Attachment *att );
79 Attachment *getAttachment() { return attachment; } 83 Attachment *getAttachment() { return attachment; }
80 84
81private: 85private:
82 Attachment *attachment; 86 Attachment *attachment;
83 87
84}; 88};
85 89
86#endif 90#endif
diff --git a/kmicromail/main.cpp b/kmicromail/main.cpp
index 22f1200..a3e1b86 100644
--- a/kmicromail/main.cpp
+++ b/kmicromail/main.cpp
@@ -1,58 +1,61 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3
3#ifndef DESKTOP_VERSION 4#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 5#include <qpe/qpeapplication.h>
6#include <libkdepim/externalapphandler.h>
5#include <stdlib.h> 7#include <stdlib.h>
6#else 8#else
7#include <qapplication.h> 9#include <qapplication.h>
8#include <qstring.h> 10#include <qstring.h>
9#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
10#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
11#include <qsgistyle.h> 13#include <qsgistyle.h>
12#endif 14#endif
13#include "opiemail.h" 15#include "opiemail.h"
14#include <qdir.h> 16#include <qdir.h>
15#include <kstandarddirs.h> 17#include <kstandarddirs.h>
16#include <kglobal.h> 18#include <kglobal.h>
17#include <stdio.h> 19#include <stdio.h>
18#include "mainwindow.h" 20#include "mainwindow.h"
19 21
20using namespace Opie::Core; 22using namespace Opie::Core;
21int main( int argc, char **argv ) { 23int main( int argc, char **argv ) {
22 24
23#ifndef DESKTOP_VERSION 25#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 26 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 27 a.setKeepRunning ();
26#else 28#else
27 QApplication a( argc, argv ); 29 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 30 QApplication::setStyle( new QPlatinumStyle ());
29#endif 31#endif
30 32
31 KGlobal::setAppName( "kmicromail" ); 33 KGlobal::setAppName( "kmicromail" );
32 QString fileName ; 34 QString fileName ;
33#ifndef DESKTOP_VERSION 35#ifndef DESKTOP_VERSION
34 fileName = getenv("QPEDIR"); 36 fileName = getenv("QPEDIR");
35 if ( QApplication::desktop()->width() > 320 ) 37 if ( QApplication::desktop()->width() > 320 )
36 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/icons22/"); 38 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/icons22/");
37 else 39 else
38 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/"); 40 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kmicromail/");
39#else 41#else
40 fileName = qApp->applicationDirPath () + "/kdepim/kmicromail/"; 42 fileName = qApp->applicationDirPath () + "/kdepim/kmicromail/";
41 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 43 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
42#endif 44#endif
43 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kmicromail"))); 45 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kmicromail")));
44 OpieMail mw; 46 OpieMail mw;
45#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
46 //qDebug("CONNECT "); 48 //qDebug("CONNECT ");
47 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); 49 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& )));
50 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
48 a.showMainWidget(&mw ); 51 a.showMainWidget(&mw );
49#else 52#else
50 a.setMainWidget(&mw ); 53 a.setMainWidget(&mw );
51 mw.show(); 54 mw.show();
52 //m.resize( 800, 600 ); 55 //m.resize( 800, 600 );
53 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 56 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
54#endif 57#endif
55 int rv = a.exec(); 58 int rv = a.exec();
56 return rv; 59 return rv;
57 60
58} 61}
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 704a9ab..6df95c6 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,292 +1,292 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qvbox.h> 4#include <qvbox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlayout.h> 7#include <qlayout.h>
8#include <kdialog.h> 8#include <kdialog.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10#include <kapplication.h> 10#include <kapplication.h>
11 11
12#ifndef DESKTOP_VERSION 12#ifndef DESKTOP_VERSION
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#endif 14#endif
15#include "defines.h" 15#include "defines.h"
16#include "mainwindow.h" 16#include "mainwindow.h"
17#include <KDGanttMinimizeSplitter.h> 17#include <KDGanttMinimizeSplitter.h>
18 18
19 19
20#include <kabc/stdaddressbook.h> 20#include <kabc/stdaddressbook.h>
21 21
22MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 22MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
23 : QMainWindow( parent, name ) //, flags ) 23 : QMainWindow( parent, name ) //, flags )
24{ 24{
25 setCaption( tr( "KOpieMail/Pi" ) ); 25 setCaption( tr( "KOpieMail/Pi" ) );
26 setToolBarsMovable( false ); 26 setToolBarsMovable( false );
27 KABC::StdAddressBook::self(); 27 //KABC::StdAddressBook::self();
28 toolBar = new QToolBar( this ); 28 toolBar = new QToolBar( this );
29 menuBar = new QMenuBar( toolBar ); 29 menuBar = new QMenuBar( toolBar );
30 mailMenu = new QPopupMenu( menuBar ); 30 mailMenu = new QPopupMenu( menuBar );
31 menuBar->insertItem( tr( "Mail" ), mailMenu ); 31 menuBar->insertItem( tr( "Mail" ), mailMenu );
32 settingsMenu = new QPopupMenu( menuBar ); 32 settingsMenu = new QPopupMenu( menuBar );
33 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 33 menuBar->insertItem( tr( "Settings" ), settingsMenu );
34 34
35 addToolBar( toolBar ); 35 addToolBar( toolBar );
36 toolBar->setHorizontalStretchable( true ); 36 toolBar->setHorizontalStretchable( true );
37 37
38 38
39 39
40 composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"), 40 composeMail = new QAction( tr( "Compose new mail" ), SmallIcon("composemail"),
41 0, 0, this ); 41 0, 0, this );
42 composeMail->addTo( toolBar ); 42 composeMail->addTo( toolBar );
43 composeMail->addTo( mailMenu ); 43 composeMail->addTo( mailMenu );
44 44
45 sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") , 45 sendQueued = new QAction( tr( "Send queued mails" ), SmallIcon("sendqueued") ,
46 0, 0, this ); 46 0, 0, this );
47 sendQueued->addTo( toolBar ); 47 sendQueued->addTo( toolBar );
48 sendQueued->addTo( mailMenu ); 48 sendQueued->addTo( mailMenu );
49 49
50 /* 50 /*
51 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 51 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
52 0, 0, this ); 52 0, 0, this );
53 syncFolders->addTo( toolBar ); 53 syncFolders->addTo( toolBar );
54 syncFolders->addTo( mailMenu ); 54 syncFolders->addTo( mailMenu );
55 */ 55 */
56 56
57 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") , 57 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") ,
58 0, 0, this, 0, true ); 58 0, 0, this, 0, true );
59 showFolders->addTo( toolBar ); 59 showFolders->addTo( toolBar );
60 showFolders->addTo( mailMenu ); 60 showFolders->addTo( mailMenu );
61 showFolders->setOn( true ); 61 showFolders->setOn( true );
62 connect(showFolders, SIGNAL( toggled(bool) ), 62 connect(showFolders, SIGNAL( toggled(bool) ),
63 SLOT( slotShowFolders(bool) ) ); 63 SLOT( slotShowFolders(bool) ) );
64 64
65 /* 65 /*
66 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), 66 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ),
67 0, 0, this ); 67 0, 0, this );
68 searchMails->addTo( toolBar ); 68 searchMails->addTo( toolBar );
69 searchMails->addTo( mailMenu ); 69 searchMails->addTo( mailMenu );
70 */ 70 */
71 71
72 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); 72 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this);
73 deleteMails->addTo( toolBar ); 73 deleteMails->addTo( toolBar );
74 deleteMails->addTo( mailMenu ); 74 deleteMails->addTo( mailMenu );
75 connect( deleteMails, SIGNAL( activated() ), 75 connect( deleteMails, SIGNAL( activated() ),
76 SLOT( slotDeleteMail() ) ); 76 SLOT( slotDeleteMail() ) );
77 77
78 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , 78 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") ,
79 0, 0, this ); 79 0, 0, this );
80 editSettings->addTo( settingsMenu ); 80 editSettings->addTo( settingsMenu );
81 connect( editSettings, SIGNAL( activated() ), 81 connect( editSettings, SIGNAL( activated() ),
82 SLOT( slotEditSettings() ) ); 82 SLOT( slotEditSettings() ) );
83 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , 83 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") ,
84 0, 0, this ); 84 0, 0, this );
85 editAccounts->addTo( settingsMenu ); 85 editAccounts->addTo( settingsMenu );
86 86
87 //setCentralWidget( view ); 87 //setCentralWidget( view );
88 88
89 QVBox* wrapperBox = new QVBox( this ); 89 QVBox* wrapperBox = new QVBox( this );
90 setCentralWidget( wrapperBox ); 90 setCentralWidget( wrapperBox );
91 91
92 // QWidget *view = new QWidget( wrapperBox ); 92 // QWidget *view = new QWidget( wrapperBox );
93 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 93 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
94 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 94 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
95 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 95 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
96 96
97 folderView = new AccountView( split ); 97 folderView = new AccountView( split );
98 folderView->header()->hide(); 98 folderView->header()->hide();
99 folderView->setRootIsDecorated( false ); 99 folderView->setRootIsDecorated( false );
100 folderView->addColumn( tr( "Mailbox" ) ); 100 folderView->addColumn( tr( "Mailbox" ) );
101 101
102 //layout->addWidget( folderView ); 102 //layout->addWidget( folderView );
103 103
104 mailView = new QListView( split ); 104 mailView = new QListView( split );
105 mailView->addColumn( tr( " " ) ); 105 mailView->addColumn( tr( " " ) );
106 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 106 mailView->addColumn( tr( "Subject" ),QListView::Manual );
107 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 107 mailView->addColumn( tr( "Sender" ),QListView::Manual );
108 mailView->addColumn( tr( "Size" ),QListView::Manual); 108 mailView->addColumn( tr( "Size" ),QListView::Manual);
109 mailView->addColumn( tr( "Date" ),QListView::Manual); 109 mailView->addColumn( tr( "Date" ),QListView::Manual);
110 mailView->setAllColumnsShowFocus(true); 110 mailView->setAllColumnsShowFocus(true);
111 //mailView->setSorting(-1); 111 //mailView->setSorting(-1);
112 mailView->setRootIsDecorated( false ); 112 mailView->setRootIsDecorated( false );
113 statusWidget = new StatusWidget( wrapperBox ); 113 statusWidget = new StatusWidget( wrapperBox );
114 statusWidget->hide(); 114 statusWidget->hide();
115 115
116 //layout->addWidget( mailView ); 116 //layout->addWidget( mailView );
117 //layout->setStretchFactor( folderView, 1 ); 117 //layout->setStretchFactor( folderView, 1 );
118 //layout->setStretchFactor( mailView, 2 ); 118 //layout->setStretchFactor( mailView, 2 );
119 119
120 slotAdjustLayout(); 120 slotAdjustLayout();
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
124#endif 124#endif
125 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 125 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
126 SLOT( mailLeftClicked(QListViewItem*) ) ); 126 SLOT( mailLeftClicked(QListViewItem*) ) );
127 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 127 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
128 SLOT( mailLeftClicked(QListViewItem*) ) ); 128 SLOT( mailLeftClicked(QListViewItem*) ) );
129 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 129 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
130 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 130 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
131 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 131 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
132 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 132 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
133 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 133 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
134 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 134 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
135// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 135// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
136 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 136 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
137 //mailView->setMultiSelection ( true ); 137 //mailView->setMultiSelection ( true );
138 mailView->setSelectionMode( QListView::Extended ); 138 mailView->setSelectionMode( QListView::Extended );
139 QValueList<int> list; 139 QValueList<int> list;
140 int fw = 100; 140 int fw = 100;
141 if ( QApplication::desktop()->width() > 320 ) 141 if ( QApplication::desktop()->width() > 320 )
142 fw = 50; 142 fw = 50;
143 list.append( fw ); 143 list.append( fw );
144 list.append( 100 ); 144 list.append( 100 );
145 split->setSizes( list ); 145 split->setSizes( list );
146 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 146 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
147 mailView->setShowSortIndicator ( true ); 147 mailView->setShowSortIndicator ( true );
148 QLabel *spacer = new QLabel( toolBar ); 148 QLabel *spacer = new QLabel( toolBar );
149 spacer->setBackgroundMode( QWidget::PaletteButton ); 149 spacer->setBackgroundMode( QWidget::PaletteButton );
150 toolBar->setStretchableWidget( spacer ); 150 toolBar->setStretchableWidget( spacer );
151 151
152 QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this); 152 QAction* closeMail = new QAction(tr("Close"),SmallIcon("exit"), 0, 0, this);
153 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 153 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
154 closeMail->addTo(toolBar); 154 closeMail->addTo(toolBar);
155 closeMail->addTo(mailMenu); 155 closeMail->addTo(mailMenu);
156 156
157 157
158 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 158 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
159 menuBar->insertItem( tr( "Help" ), helpMenu ); 159 menuBar->insertItem( tr( "Help" ), helpMenu );
160 QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this); 160 QAction* li = new QAction(tr("About"), QPixmap(), 0, 0, this);
161 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 161 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
162 li->addTo(helpMenu); 162 li->addTo(helpMenu);
163 li = new QAction(tr("Licence"),QPixmap(), 0, 0, this); 163 li = new QAction(tr("Licence"),QPixmap(), 0, 0, this);
164 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 164 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
165 li->addTo(helpMenu); 165 li->addTo(helpMenu);
166 li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this); 166 li = new QAction(tr("LibEtPan Licence"), QPixmap(), 0, 0, this);
167 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 167 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
168 li->addTo(helpMenu); 168 li->addTo(helpMenu);
169} 169}
170 170
171MainWindow::~MainWindow() 171MainWindow::~MainWindow()
172{ 172{
173} 173}
174 174
175void MainWindow::showLicence() 175void MainWindow::showLicence()
176{ 176{
177 KApplication::showLicence(); 177 KApplication::showLicence();
178} 178}
179void MainWindow::showAbout() 179void MainWindow::showAbout()
180{ 180{
181 QString version; 181 QString version;
182#include <../version> 182#include <../version>
183 183
184 QString cap = "About KOpieMail/Pi"; 184 QString cap = "About KOpieMail/Pi";
185 QString text =i18n("KOpieMail/Platform-independent\n") + 185 QString text =i18n("KOpieMail/Platform-independent\n") +
186 "(OM/Pi) " + version + " - " 186 "(OM/Pi) " + version + " - "
187 187
188#ifdef DESKTOP_VERSION 188#ifdef DESKTOP_VERSION
189 "Desktop Edition\n" 189 "Desktop Edition\n"
190#else 190#else
191 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 191 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
192#endif 192#endif
193 "www.pi-sync.net\n\n" 193 "www.pi-sync.net\n\n"
194 194
195 195
196 196
197"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 197"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
198 "KOpieMail/Pi is based on Opie Mail\n" 198 "KOpieMail/Pi is based on Opie Mail\n"
199 "Copyright (c) Rajko Albrecht and the Opie team\n" 199 "Copyright (c) Rajko Albrecht and the Opie team\n"
200 "KOpieMail/Pi is licensed under the GPL\n" 200 "KOpieMail/Pi is licensed under the GPL\n"
201 "\n" 201 "\n"
202 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 202 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
203 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 203 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
204 "libEtPan has its own licence - see LibEtPan licence\n"; 204 "libEtPan has its own licence - see LibEtPan licence\n";
205 205
206 KApplication::showText( cap, text ); 206 KApplication::showText( cap, text );
207} 207}
208void MainWindow::showEtpanLicence() 208void MainWindow::showEtpanLicence()
209{ 209{
210 KApplication::showFile( "LibEtPan licence", "kdepim/kmicromail/COPYRIGHTlibetpan" ); 210 KApplication::showFile( "LibEtPan licence", "kdepim/kmicromail/COPYRIGHTlibetpan" );
211 211
212} 212}
213void MainWindow::appMessage(const QCString &, const QByteArray &) 213void MainWindow::appMessage(const QCString &, const QByteArray &)
214{ 214{
215 qDebug("appMessage implemented by subclass"); 215 qDebug("appMessage implemented by subclass");
216} 216}
217 217
218void MainWindow::slotAdjustLayout() { 218void MainWindow::slotAdjustLayout() {
219 219
220 /* 220 /*
221 QWidget *d = QApplication::desktop(); 221 QWidget *d = QApplication::desktop();
222 222
223 if ( d->width() < d->height() ) { 223 if ( d->width() < d->height() ) {
224 layout->setDirection( QBoxLayout::TopToBottom ); 224 layout->setDirection( QBoxLayout::TopToBottom );
225 } else { 225 } else {
226 layout->setDirection( QBoxLayout::LeftToRight ); 226 layout->setDirection( QBoxLayout::LeftToRight );
227 } 227 }
228 */ 228 */
229} 229}
230 230
231void MainWindow::slotAdjustColumns() 231void MainWindow::slotAdjustColumns()
232{ 232{
233 bool hidden = folderView->isHidden(); 233 bool hidden = folderView->isHidden();
234 if ( hidden ) folderView->show(); 234 if ( hidden ) folderView->show();
235 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 235 folderView->setColumnWidth( 0, folderView->visibleWidth() );
236 if ( hidden ) folderView->hide(); 236 if ( hidden ) folderView->hide();
237 237
238 mailView->setColumnWidth( 0, 10 ); 238 mailView->setColumnWidth( 0, 10 );
239 mailView->setColumnWidth( 1, 100 ); 239 mailView->setColumnWidth( 1, 100 );
240 mailView->setColumnWidth( 2, 100 ); 240 mailView->setColumnWidth( 2, 100 );
241 mailView->setColumnWidth( 3, 50 ); 241 mailView->setColumnWidth( 3, 50 );
242 mailView->setColumnWidth( 4, 120 ); 242 mailView->setColumnWidth( 4, 120 );
243} 243}
244 244
245void MainWindow::slotEditSettings() 245void MainWindow::slotEditSettings()
246{ 246{
247} 247}
248 248
249void MainWindow::slotShowFolders( bool ) 249void MainWindow::slotShowFolders( bool )
250{ 250{
251 qDebug("not implemented: "); 251 qDebug("not implemented: ");
252} 252}
253 253
254void MainWindow::refreshMailView(const QValueList<RecMailP>&) 254void MainWindow::refreshMailView(const QValueList<RecMailP>&)
255{ 255{
256 qDebug("not implemented: "); 256 qDebug("not implemented: ");
257} 257}
258 258
259void MainWindow::mailLeftClicked(QListViewItem * ) 259void MainWindow::mailLeftClicked(QListViewItem * )
260{ 260{
261 qDebug("not implemented: "); 261 qDebug("not implemented: ");
262} 262}
263 263
264void MainWindow::displayMail() 264void MainWindow::displayMail()
265{ 265{
266 qDebug("not implemented: "); 266 qDebug("not implemented: ");
267} 267}
268 268
269void MainWindow::slotDeleteMail() 269void MainWindow::slotDeleteMail()
270{ 270{
271 qDebug("not implemented: "); 271 qDebug("not implemented: ");
272} 272}
273 273
274void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 274void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
275{ 275{
276 qDebug("not implemented: "); 276 qDebug("not implemented: ");
277} 277}
278 278
279void MainWindow::slotSendQueued() 279void MainWindow::slotSendQueued()
280{ 280{
281 qDebug("not implemented: "); 281 qDebug("not implemented: ");
282} 282}
283 283
284void MainWindow::slotEditAccounts() 284void MainWindow::slotEditAccounts()
285{ 285{
286 qDebug("not implemented: "); 286 qDebug("not implemented: ");
287} 287}
288 288
289void MainWindow::slotComposeMail() 289void MainWindow::slotComposeMail()
290{ 290{
291 qDebug("not implemented: "); 291 qDebug("not implemented: ");
292} 292}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 251f15a..3e560c5 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,421 +1,422 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "settingsdialog.h" 4#include "settingsdialog.h"
5#include "opiemail.h" 5#include "opiemail.h"
6#include "editaccounts.h" 6#include "editaccounts.h"
7#include "composemail.h" 7#include "composemail.h"
8#include "mailistviewitem.h" 8#include "mailistviewitem.h"
9#include "viewmail.h" 9#include "viewmail.h"
10#include "selectstore.h" 10#include "selectstore.h"
11#include "selectsmtp.h" 11#include "selectsmtp.h"
12 12
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
17#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
18#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
19/* OPIE */ 19/* OPIE */
20//#include <qpe/resource.h> 20//#include <qpe/resource.h>
21//#include <qpe/qpeapplication.h> 21//#include <qpe/qpeapplication.h>
22 22
23/* QT */ 23/* QT */
24 24
25using namespace Opie::Core; 25using namespace Opie::Core;
26 26
27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
28 : MainWindow( parent, name) //, WStyle_ContextHelp ) 28 : MainWindow( parent, name) //, WStyle_ContextHelp )
29{ 29{
30 settings = new Settings(); 30 settings = new Settings();
31 31
32 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
33 33
34} 34}
35 35
36OpieMail::~OpieMail() 36OpieMail::~OpieMail()
37{ 37{
38 if (settings) delete settings; 38 if (settings) delete settings;
39} 39}
40 40
41void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 41void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
42{ 42{
43 43
44} 44}
45#include <stdlib.h> 45#include <stdlib.h>
46void OpieMail::message(const QCString &msg, const QByteArray &data) 46void OpieMail::message(const QCString &msg, const QByteArray &data)
47{ 47{
48 // copied from old mail2 48 // copied from old mail2
49 static int ii = 0; 49 static int ii = 0;
50 50
51 // block second call 51 // block second call
52 if ( ii < 2 ) { 52 if ( ii < 2 ) {
53 ++ii; 53 ++ii;
54 if ( ii > 1 ) { 54 if ( ii > 1 ) {
55 qDebug("qcop call blocked "); 55 qDebug("qcop call blocked ");
56 return; 56 return;
57 } 57 }
58 } 58 }
59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
60 if (msg == "writeMail(QString,QString)") 60 if (msg == "writeMail(QString,QString)")
61 { 61 {
62 QDataStream stream(data,IO_ReadOnly); 62 QDataStream stream(data,IO_ReadOnly);
63 QString name, email; 63 QString name, email;
64 stream >> name >> email; 64 stream >> name >> email;
65 // removing the whitespaces at beginning and end is needed! 65 // removing the whitespaces at beginning and end is needed!
66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
67 } 67 }
68 else if (msg == "newMail()") 68 else if (msg == "newMail()")
69 { 69 {
70 slotComposeMail(); 70 slotComposeMail();
71 } 71 }
72 else if (msg == "newMail(QString)") 72 else if (msg == "newMail(QString)")
73 { 73 {
74 QDataStream stream(data,IO_ReadOnly); 74 QDataStream stream(data,IO_ReadOnly);
75 QString nameemail; 75 QString nameemail;
76 stream >> nameemail; 76 stream >> nameemail;
77 // the format is 77 // the format is
78 // NAME <EMAIL>:SUBJECT 78 // NAME <EMAIL>:SUBJECT
79 //qDebug("message %s ", nameemail.latin1()); 79 //qDebug("message %s ", nameemail.latin1());
80 80
81 slotwriteMail2( nameemail ); 81 slotwriteMail2( nameemail );
82 } 82 }
83} 83}
84void OpieMail::slotwriteMail2(const QString& namemail ) 84void OpieMail::slotwriteMail2(const QString& namemail )
85{ 85{
86 // qDebug("OpieMail::slotwriteMail2 "); 86 // qDebug("OpieMail::slotwriteMail2 ");
87 qApp->processEvents(); 87 qApp->processEvents();
88 ComposeMail compose( settings, this, 0, true ); 88 ComposeMail compose( settings, this, 0, true );
89 if ( !namemail.isEmpty() ) { 89 if ( !namemail.isEmpty() ) {
90 QString to = namemail; 90 QString to = namemail;
91 if ( namemail.find( " <") > 1 ) { 91 if ( namemail.find( " <") > 1 ) {
92 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 92 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
93 } else 93 } else
94 if ( namemail.find( "<") > 1 ) { 94 if ( namemail.find( "<") > 1 ) {
95 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 95 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
96 } 96 }
97 int sub = to.find( ">:"); 97 int sub = to.find( ">:");
98 if ( sub > 0 ) { 98 if ( sub > 0 ) {
99 compose.setTo( to.left(sub+1) ); 99 compose.setTo( to.left(sub+1) );
100 compose.setSubject( to.mid(sub+2) ); 100 compose.setSubject( to.mid(sub+2) );
101 } else 101 } else
102 compose.setTo( to ); 102 compose.setTo( to );
103 } 103 }
104 compose.slotAdjustColumns(); 104 compose.slotAdjustColumns();
105 compose.showMaximized(); 105 compose.showMaximized();
106 compose.exec(); 106 compose.exec();
107 raise();
107 //qDebug("retttich "); 108 //qDebug("retttich ");
108} 109}
109void OpieMail::slotwriteMail(const QString&name,const QString&email) 110void OpieMail::slotwriteMail(const QString&name,const QString&email)
110{ 111{
111 // qDebug("OpieMail::slotwriteMail "); 112 // qDebug("OpieMail::slotwriteMail ");
112 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 113 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
113 if (!email.isEmpty()) 114 if (!email.isEmpty())
114 { 115 {
115 if (!name.isEmpty()) 116 if (!name.isEmpty())
116 { 117 {
117 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 118 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
118 } 119 }
119 else 120 else
120 { 121 {
121 compose.setTo(email); 122 compose.setTo(email);
122 } 123 }
123 } 124 }
124 compose.slotAdjustColumns(); 125 compose.slotAdjustColumns();
125 compose.showMaximized(); 126 compose.showMaximized();
126 compose.exec(); 127 compose.exec();
127} 128}
128 129
129void OpieMail::slotComposeMail() 130void OpieMail::slotComposeMail()
130{ 131{
131 slotwriteMail2( QString () ); 132 slotwriteMail2( QString () );
132 //slotwriteMail(0l,0l); 133 //slotwriteMail(0l,0l);
133} 134}
134 135
135void OpieMail::slotSendQueued() 136void OpieMail::slotSendQueued()
136{ 137{
137 SMTPaccount *smtp = 0; 138 SMTPaccount *smtp = 0;
138 139
139 QList<Account> list = settings->getAccounts(); 140 QList<Account> list = settings->getAccounts();
140 QList<SMTPaccount> smtpList; 141 QList<SMTPaccount> smtpList;
141 smtpList.setAutoDelete(false); 142 smtpList.setAutoDelete(false);
142 Account *it; 143 Account *it;
143 for ( it = list.first(); it; it = list.next() ) 144 for ( it = list.first(); it; it = list.next() )
144 { 145 {
145 if ( it->getType() == MAILLIB::A_SMTP ) 146 if ( it->getType() == MAILLIB::A_SMTP )
146 { 147 {
147 smtp = static_cast<SMTPaccount *>(it); 148 smtp = static_cast<SMTPaccount *>(it);
148 smtpList.append(smtp); 149 smtpList.append(smtp);
149 } 150 }
150 } 151 }
151 if (smtpList.count()==0) 152 if (smtpList.count()==0)
152 { 153 {
153 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); 154 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
154 return; 155 return;
155 } 156 }
156 if (smtpList.count()==1) 157 if (smtpList.count()==1)
157 { 158 {
158 smtp = smtpList.at(0); 159 smtp = smtpList.at(0);
159 } 160 }
160 else 161 else
161 { 162 {
162 smtp = 0; 163 smtp = 0;
163 selectsmtp selsmtp; 164 selectsmtp selsmtp;
164 selsmtp.setSelectionlist(&smtpList); 165 selsmtp.setSelectionlist(&smtpList);
165 selsmtp.showMaximized(); 166 selsmtp.showMaximized();
166 if ( selsmtp.exec() == QDialog::Accepted ) 167 if ( selsmtp.exec() == QDialog::Accepted )
167 { 168 {
168 smtp = selsmtp.selected_smtp(); 169 smtp = selsmtp.selected_smtp();
169 } 170 }
170 } 171 }
171 if (smtp) 172 if (smtp)
172 { 173 {
173 SMTPwrapper * wrap = new SMTPwrapper(smtp); 174 SMTPwrapper * wrap = new SMTPwrapper(smtp);
174 if ( wrap->flushOutbox() ) 175 if ( wrap->flushOutbox() )
175 { 176 {
176 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 177 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
177 } 178 }
178 delete wrap; 179 delete wrap;
179 } 180 }
180} 181}
181 182
182void OpieMail::slotSearchMails() 183void OpieMail::slotSearchMails()
183{ 184{
184 qDebug("OpieMail::slotSearchMails():not implemented "); 185 qDebug("OpieMail::slotSearchMails():not implemented ");
185} 186}
186 187
187void OpieMail::slotEditSettings() 188void OpieMail::slotEditSettings()
188{ 189{
189 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 190 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
190 settingsDialog.showMaximized(); 191 settingsDialog.showMaximized();
191 settingsDialog.exec(); 192 settingsDialog.exec();
192} 193}
193 194
194void OpieMail::slotEditAccounts() 195void OpieMail::slotEditAccounts()
195{ 196{
196 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 197 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
197 eaDialog.slotAdjustColumns(); 198 eaDialog.slotAdjustColumns();
198 eaDialog.showMaximized(); 199 eaDialog.showMaximized();
199 eaDialog.exec(); 200 eaDialog.exec();
200 if ( settings ) delete settings; 201 if ( settings ) delete settings;
201 settings = new Settings(); 202 settings = new Settings();
202 203
203 folderView->populate( settings->getAccounts() ); 204 folderView->populate( settings->getAccounts() );
204} 205}
205 206
206void OpieMail::displayMail() 207void OpieMail::displayMail()
207{ 208{
208 QListViewItem*item = mailView->currentItem(); 209 QListViewItem*item = mailView->currentItem();
209 if (!item) return; 210 if (!item) return;
210 RecMailP mail = ((MailListViewItem*)item)->data(); 211 RecMailP mail = ((MailListViewItem*)item)->data();
211 RecBodyP body = folderView->fetchBody(mail); 212 RecBodyP body = folderView->fetchBody(mail);
212 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 213 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
213 readMail.setBody( body ); 214 readMail.setBody( body );
214 readMail.setMail( mail ); 215 readMail.setMail( mail );
215 readMail.showMaximized(); 216 readMail.showMaximized();
216 readMail.exec(); 217 readMail.exec();
217 218
218 if ( readMail.deleted ) 219 if ( readMail.deleted )
219 { 220 {
220 folderView->refreshCurrent(); 221 folderView->refreshCurrent();
221 } 222 }
222 else 223 else
223 { 224 {
224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 225 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
225 } 226 }
226} 227}
227 228
228void OpieMail::slotDeleteMail() 229void OpieMail::slotDeleteMail()
229{ 230{
230 if (!mailView->currentItem()) return; 231 if (!mailView->currentItem()) return;
231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 232 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
232 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 233 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
233 { 234 {
234 mail->Wrapper()->deleteMail( mail ); 235 mail->Wrapper()->deleteMail( mail );
235 folderView->refreshCurrent(); 236 folderView->refreshCurrent();
236 } 237 }
237} 238}
238void OpieMail::slotDeleteAllMail() 239void OpieMail::slotDeleteAllMail()
239{ 240{
240 241
241 QValueList<RecMailP> t; 242 QValueList<RecMailP> t;
242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 243 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
243 { 244 {
244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 245 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
245 while ( item ) { 246 while ( item ) {
246 if ( item->isSelected() ) { 247 if ( item->isSelected() ) {
247 t.append( item->data() ); 248 t.append( item->data() );
248 } 249 }
249 item = (MailListViewItem*)item->nextSibling(); 250 item = (MailListViewItem*)item->nextSibling();
250 } 251 }
251 } 252 }
252 else 253 else
253 return; 254 return;
254 if ( t.count() == 0 ) 255 if ( t.count() == 0 )
255 return; 256 return;
256 RecMailP mail = t.first(); 257 RecMailP mail = t.first();
257 mail->Wrapper()->deleteMailList(t); 258 mail->Wrapper()->deleteMailList(t);
258 folderView->refreshCurrent(); 259 folderView->refreshCurrent();
259 260
260 261
261} 262}
262void OpieMail::clearSelection() 263void OpieMail::clearSelection()
263{ 264{
264 mailView->clearSelection(); 265 mailView->clearSelection();
265 266
266} 267}
267 268
268void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 269void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
269{ 270{
270 if (!mailView->currentItem()) return; 271 if (!mailView->currentItem()) return;
271 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 272 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
272 /* just the RIGHT button - or hold on pda */ 273 /* just the RIGHT button - or hold on pda */
273 if (button!=2) {return;} 274 if (button!=2) {return;}
274 if (!item) return; 275 if (!item) return;
275 QPopupMenu *m = new QPopupMenu(0); 276 QPopupMenu *m = new QPopupMenu(0);
276 if (m) 277 if (m)
277 { 278 {
278 if (mailtype==MAILLIB::A_NNTP) { 279 if (mailtype==MAILLIB::A_NNTP) {
279 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 280 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
280// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 281// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
281 } else { 282 } else {
282 if (folderView->currentisDraft()) { 283 if (folderView->currentisDraft()) {
283 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 284 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
284 } 285 }
285 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 286 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
286 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 287 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
287 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 288 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
288 m->insertSeparator(); 289 m->insertSeparator();
289 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 290 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
290 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 291 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
291 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 292 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
292 } 293 }
293 m->setFocus(); 294 m->setFocus();
294 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 295 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
295 delete m; 296 delete m;
296 } 297 }
297} 298}
298 299
299void OpieMail::slotShowFolders( bool show ) 300void OpieMail::slotShowFolders( bool show )
300{ 301{
301 if ( show && folderView->isHidden() ) 302 if ( show && folderView->isHidden() )
302 { 303 {
303 folderView->show(); 304 folderView->show();
304 } 305 }
305 else if ( !show && !folderView->isHidden() ) 306 else if ( !show && !folderView->isHidden() )
306 { 307 {
307 folderView->hide(); 308 folderView->hide();
308 } 309 }
309} 310}
310 311
311void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 312void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
312{ 313{
313 MailListViewItem*item = 0; 314 MailListViewItem*item = 0;
314 mailView->clear(); 315 mailView->clear();
315 316
316 QValueList<RecMailP>::ConstIterator it; 317 QValueList<RecMailP>::ConstIterator it;
317 for (it = list.begin(); it != list.end();++it) 318 for (it = list.begin(); it != list.end();++it)
318 { 319 {
319 item = new MailListViewItem(mailView,item); 320 item = new MailListViewItem(mailView,item);
320 item->storeData((*it)); 321 item->storeData((*it));
321 item->showEntry(); 322 item->showEntry();
322 } 323 }
323} 324}
324 325
325void OpieMail::mailLeftClicked( QListViewItem *item ) 326void OpieMail::mailLeftClicked( QListViewItem *item )
326{ 327{
327 mailView->clearSelection(); 328 mailView->clearSelection();
328 /* just LEFT button - or tap with stylus on pda */ 329 /* just LEFT button - or tap with stylus on pda */
329 //if (button!=1) return; 330 //if (button!=1) return;
330 if (!item) return; 331 if (!item) return;
331 if (folderView->currentisDraft()) { 332 if (folderView->currentisDraft()) {
332 reEditMail(); 333 reEditMail();
333 } else { 334 } else {
334 displayMail(); 335 displayMail();
335 } 336 }
336} 337}
337 338
338void OpieMail::slotMoveCopyMail() 339void OpieMail::slotMoveCopyMail()
339{ 340{
340 if (!mailView->currentItem()) return; 341 if (!mailView->currentItem()) return;
341 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 342 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
342 AbstractMail*targetMail = 0; 343 AbstractMail*targetMail = 0;
343 QString targetFolder = ""; 344 QString targetFolder = "";
344 Selectstore sels; 345 Selectstore sels;
345 folderView->setupFolderselect(&sels); 346 folderView->setupFolderselect(&sels);
346 if (!sels.exec()) return; 347 if (!sels.exec()) return;
347 targetMail = sels.currentMail(); 348 targetMail = sels.currentMail();
348 targetFolder = sels.currentFolder(); 349 targetFolder = sels.currentFolder();
349 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 350 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
350 targetFolder.isEmpty()) 351 targetFolder.isEmpty())
351 { 352 {
352 return; 353 return;
353 } 354 }
354 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 355 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
355 { 356 {
356 QMessageBox::critical(0,tr("Error creating new Folder"), 357 QMessageBox::critical(0,tr("Error creating new Folder"),
357 tr("<center>Error while creating<br>new folder - breaking.</center>")); 358 tr("<center>Error while creating<br>new folder - breaking.</center>"));
358 return; 359 return;
359 } 360 }
360 sels.hide(); 361 sels.hide();
361 qApp->processEvents(); 362 qApp->processEvents();
362 // qDebug("hiding sels "); 363 // qDebug("hiding sels ");
363 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 364 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
364 folderView->refreshCurrent(); 365 folderView->refreshCurrent();
365} 366}
366 367
367void OpieMail::slotMoveCopyAllMail() 368void OpieMail::slotMoveCopyAllMail()
368{ 369{
369 370
370 if (!mailView->currentItem()) return; 371 if (!mailView->currentItem()) return;
371 QValueList<RecMailP> t; 372 QValueList<RecMailP> t;
372 // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 373 // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
373 { 374 {
374 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 375 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
375 while ( item ) { 376 while ( item ) {
376 if ( item->isSelected() ) { 377 if ( item->isSelected() ) {
377 t.append( item->data() ); 378 t.append( item->data() );
378 } 379 }
379 item = (MailListViewItem*)item->nextSibling(); 380 item = (MailListViewItem*)item->nextSibling();
380 } 381 }
381 } 382 }
382 // else 383 // else
383 // return; 384 // return;
384 if ( t.count() == 0 ) 385 if ( t.count() == 0 )
385 return; 386 return;
386 RecMailP mail = t.first(); 387 RecMailP mail = t.first();
387 AbstractMail*targetMail = 0; 388 AbstractMail*targetMail = 0;
388 QString targetFolder = ""; 389 QString targetFolder = "";
389 Selectstore sels; 390 Selectstore sels;
390 folderView->setupFolderselect(&sels); 391 folderView->setupFolderselect(&sels);
391 if (!sels.exec()) return; 392 if (!sels.exec()) return;
392 targetMail = sels.currentMail(); 393 targetMail = sels.currentMail();
393 targetFolder = sels.currentFolder(); 394 targetFolder = sels.currentFolder();
394 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 395 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
395 targetFolder.isEmpty()) 396 targetFolder.isEmpty())
396 { 397 {
397 return; 398 return;
398 } 399 }
399 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 400 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
400 { 401 {
401 QMessageBox::critical(0,tr("Error creating new Folder"), 402 QMessageBox::critical(0,tr("Error creating new Folder"),
402 tr("<center>Error while creating<br>new folder - breaking.</center>")); 403 tr("<center>Error while creating<br>new folder - breaking.</center>"));
403 return; 404 return;
404 } 405 }
405 sels.hide(); 406 sels.hide();
406 qApp->processEvents(); 407 qApp->processEvents();
407 //qDebug("hiding sels "); 408 //qDebug("hiding sels ");
408 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 409 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
409 folderView->refreshCurrent(); 410 folderView->refreshCurrent();
410} 411}
411 412
412void OpieMail::reEditMail() 413void OpieMail::reEditMail()
413{ 414{
414 if (!mailView->currentItem()) return; 415 if (!mailView->currentItem()) return;
415 416
416 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 417 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
417 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 418 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
418 compose.slotAdjustColumns(); 419 compose.slotAdjustColumns();
419 compose.showMaximized(); 420 compose.showMaximized();
420 compose.exec(); 421 compose.exec();
421} 422}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 0866939..2f538c4 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,575 +1,575 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53 53
54#ifdef DESKTOP_VERSION 54#ifdef DESKTOP_VERSION
55#include <kabc/addresseedialog.h> 55#include <kabc/addresseedialog.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KPIM::AddresseeView av ( &dia ); 90 KPIM::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 97
98 } 98 }
99 dia.exec(); 99 dia.exec();
100 break; 100 break;
101 } 101 }
102 } 102 }
103 return; 103 return;
104 } 104 }
105#else 105#else
106 { 106 {
107 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 107 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
108 if (attendees.count()) { 108 if (attendees.count()) {
109 Attendee *a; 109 Attendee *a;
110 for(a=attendees.first();a;a=attendees.next()) { 110 for(a=attendees.first();a;a=attendees.next()) {
111 if ( "uid:"+a->uid() == n ) { 111 if ( "uid:"+a->uid() == n ) {
112 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), ""); 112 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
113 return; 113 return;
114 } 114 }
115 } 115 }
116 } 116 }
117 return; 117 return;
118 } 118 }
119 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 119 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
120 // the result should now arrive through method insertAttendees 120 // the result should now arrive through method insertAttendees
121 //QString uid = "uid:"+(*it).uid(); 121 //QString uid = "uid:"+(*it).uid();
122#endif 122#endif
123 if ( n.left(6) == "mailto" ) { 123 if ( n.left(6) == "mailto" ) {
124 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 124 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
125#ifndef DESKTOP_VERSION 125#ifndef DESKTOP_VERSION
126 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 126 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
127 e << n.mid(7); 127 e << n.mid(7);
128#endif 128#endif
129 129
130 } 130 }
131 131
132 132
133#ifndef KORG_NODCOP 133#ifndef KORG_NODCOP
134 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 134 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
135 QString tmpStr; 135 QString tmpStr;
136 if (n.startsWith("mailto:")) { 136 if (n.startsWith("mailto:")) {
137 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 137 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
138 //emit showIncidence(n); 138 //emit showIncidence(n);
139 return; 139 return;
140 } else if (n.startsWith("uid:")) { 140 } else if (n.startsWith("uid:")) {
141 DCOPClient *client = KApplication::kApplication()->dcopClient(); 141 DCOPClient *client = KApplication::kApplication()->dcopClient();
142 const QByteArray noParamData; 142 const QByteArray noParamData;
143 const QByteArray paramData; 143 const QByteArray paramData;
144 QByteArray replyData; 144 QByteArray replyData;
145 QCString replyTypeStr; 145 QCString replyTypeStr;
146#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 146#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
147 bool foundAbbrowser = PING_ABBROWSER; 147 bool foundAbbrowser = PING_ABBROWSER;
148 148
149 if (foundAbbrowser) { 149 if (foundAbbrowser) {
150 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 150 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
151 //client->send("kaddressbook","KAddressBookIface", 151 //client->send("kaddressbook","KAddressBookIface",
152 QDataStream arg(paramData, IO_WriteOnly); 152 QDataStream arg(paramData, IO_WriteOnly);
153 arg << n.mid(6); 153 arg << n.mid(6);
154 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 154 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
155 return; 155 return;
156 } else { 156 } else {
157 /* 157 /*
158 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 158 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
159 We start it without its main interface 159 We start it without its main interface
160 */ 160 */
161 KIconLoader* iconLoader = new KIconLoader(); 161 KIconLoader* iconLoader = new KIconLoader();
162 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 162 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
163 ActionManager::setStartedKAddressBook(true); 163 ActionManager::setStartedKAddressBook(true);
164 tmpStr = "kaddressbook --editor-only --uid "; 164 tmpStr = "kaddressbook --editor-only --uid ";
165 tmpStr += KProcess::quote(n.mid(6)); 165 tmpStr += KProcess::quote(n.mid(6));
166 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 166 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
167 return; 167 return;
168 } 168 }
169 } else { 169 } else {
170 //QTextBrowser::setSource(n); 170 //QTextBrowser::setSource(n);
171 } 171 }
172#endif 172#endif
173} 173}
174 174
175void KOEventViewer::addTag(const QString & tag,const QString & text) 175void KOEventViewer::addTag(const QString & tag,const QString & text)
176{ 176{
177 int number=text.contains("\n"); 177 int number=text.contains("\n");
178 QString str = "<" + tag + ">"; 178 QString str = "<" + tag + ">";
179 QString tmpText=text; 179 QString tmpText=text;
180 QString tmpStr=str; 180 QString tmpStr=str;
181 if(number !=-1) 181 if(number !=-1)
182 { 182 {
183 if (number > 0) { 183 if (number > 0) {
184 int pos=0; 184 int pos=0;
185 QString tmp; 185 QString tmp;
186 for(int i=0;i<=number;i++) { 186 for(int i=0;i<=number;i++) {
187 pos=tmpText.find("\n"); 187 pos=tmpText.find("\n");
188 tmp=tmpText.left(pos); 188 tmp=tmpText.left(pos);
189 tmpText=tmpText.right(tmpText.length()-pos-1); 189 tmpText=tmpText.right(tmpText.length()-pos-1);
190 tmpStr+=tmp+"<br>"; 190 tmpStr+=tmp+"<br>";
191 } 191 }
192 } 192 }
193 else tmpStr += tmpText; 193 else tmpStr += tmpText;
194 tmpStr+="</" + tag + ">"; 194 tmpStr+="</" + tag + ">";
195 mText.append(tmpStr); 195 mText.append(tmpStr);
196 } 196 }
197 else 197 else
198 { 198 {
199 str += text + "</" + tag + ">"; 199 str += text + "</" + tag + ">";
200 mText.append(str); 200 mText.append(str);
201 } 201 }
202} 202}
203 203
204void KOEventViewer::setColorMode( int m ) 204void KOEventViewer::setColorMode( int m )
205{ 205{
206 mColorMode = m; 206 mColorMode = m;
207} 207}
208void KOEventViewer::appendEvent(Event *event, int mode ) 208void KOEventViewer::appendEvent(Event *event, int mode )
209{ 209{
210 mMailSubject = ""; 210 mMailSubject = "";
211 mCurrentIncidence = event; 211 mCurrentIncidence = event;
212 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 212 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
213 topLevelWidget()->setCaption(i18n("Event Viewer")); 213 topLevelWidget()->setCaption(i18n("Event Viewer"));
214 if ( mode == 0 ) { 214 if ( mode == 0 ) {
215 addTag("h2",event->summary()); 215 addTag("h2",event->summary());
216 } 216 }
217 else { 217 else {
218 if ( mColorMode == 1 ) { 218 if ( mColorMode == 1 ) {
219 mText +="<font color=\"#00A000\">"; 219 mText +="<font color=\"#00A000\">";
220 } 220 }
221 if ( mColorMode == 2 ) { 221 if ( mColorMode == 2 ) {
222 mText +="<font color=\"#C00000\">"; 222 mText +="<font color=\"#C00000\">";
223 } 223 }
224 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 224 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
225 if ( mode == 1 ) { 225 if ( mode == 1 ) {
226 addTag("h2",i18n( "Local: " ) +event->summary()); 226 addTag("h2",i18n( "Local: " ) +event->summary());
227 } else { 227 } else {
228 addTag("h2",i18n( "Remote: " ) +event->summary()); 228 addTag("h2",i18n( "Remote: " ) +event->summary());
229 } 229 }
230 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 230 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
231 if ( mColorMode ) 231 if ( mColorMode )
232 mText += "</font>"; 232 mText += "</font>";
233 } 233 }
234 mMailSubject += i18n( "Meeting " )+ event->summary(); 234 mMailSubject += i18n( "Meeting " )+ event->summary();
235 if (event->cancelled ()) { 235 if (event->cancelled ()) {
236 mText +="<font color=\"#B00000\">"; 236 mText +="<font color=\"#B00000\">";
237 addTag("i",i18n("This event has been cancelled!")); 237 addTag("i",i18n("This event has been cancelled!"));
238 mText.append("<br>"); 238 mText.append("<br>");
239 mText += "</font>"; 239 mText += "</font>";
240 mMailSubject += i18n("(cancelled)"); 240 mMailSubject += i18n("(cancelled)");
241 } 241 }
242 if (!event->location().isEmpty()) { 242 if (!event->location().isEmpty()) {
243 addTag("b",i18n("Location: ")); 243 addTag("b",i18n("Location: "));
244 mText.append(event->location()+"<br>"); 244 mText.append(event->location()+"<br>");
245 mMailSubject += i18n(" at ") + event->location(); 245 mMailSubject += i18n(" at ") + event->location();
246 } 246 }
247 if (event->doesFloat()) { 247 if (event->doesFloat()) {
248 if (event->isMultiDay()) { 248 if (event->isMultiDay()) {
249 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 249 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
250 .arg(event->dtStartDateStr(shortDate)) 250 .arg(event->dtStartDateStr(shortDate))
251 .arg(event->dtEndDateStr(shortDate))); 251 .arg(event->dtEndDateStr(shortDate)));
252 } else { 252 } else {
253 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 253 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
254 } 254 }
255 } else { 255 } else {
256 if (event->isMultiDay()) { 256 if (event->isMultiDay()) {
257 mText.append(i18n("<p><b>From:</b> %1</p> ") 257 mText.append(i18n("<p><b>From:</b> %1</p> ")
258 .arg(event->dtStartStr( shortDate))); 258 .arg(event->dtStartStr( shortDate)));
259 mText.append(i18n("<p><b>To:</b> %1</p>") 259 mText.append(i18n("<p><b>To:</b> %1</p>")
260 .arg(event->dtEndStr(shortDate))); 260 .arg(event->dtEndStr(shortDate)));
261 } else { 261 } else {
262 mText.append(i18n("<p><b>On:</b> %1</p> ") 262 mText.append(i18n("<p><b>On:</b> %1</p> ")
263 .arg(event->dtStartDateStr( shortDate ))); 263 .arg(event->dtStartDateStr( shortDate )));
264 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 264 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
265 .arg(event->dtStartTimeStr()) 265 .arg(event->dtStartTimeStr())
266 .arg(event->dtEndTimeStr())); 266 .arg(event->dtEndTimeStr()));
267 } 267 }
268 } 268 }
269 269
270 if (event->recurrence()->doesRecur()) { 270 if (event->recurrence()->doesRecur()) {
271 271
272 QString recurText = event->recurrence()->recurrenceText(); 272 QString recurText = event->recurrence()->recurrenceText();
273 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 273 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
274 bool last; 274 bool last;
275 QDate start = QDate::currentDate(); 275 QDate start = QDate::currentDate();
276 QDate next; 276 QDate next;
277 next = event->recurrence()->getPreviousDate( start , &last ); 277 next = event->recurrence()->getPreviousDate( start , &last );
278 if ( !last ) { 278 if ( !last ) {
279 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 279 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
280 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 280 addTag("p",i18n("<b>Next recurrence is on:</b>") );
281 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 281 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
282 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 282 QDateTime nextdt = QDateTime( next, event->dtStart().time());
283 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 283 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
284 284
285 } else { 285 } else {
286 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 286 addTag("p",i18n("<b>Last recurrence was on:</b>") );
287 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 287 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
288 } 288 }
289 } else { 289 } else {
290 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 290 mMailSubject += i18n(" - " )+event->dtStartStr( true );
291 291
292 } 292 }
293 293
294 294
295 if (event->isAlarmEnabled()) { 295 if (event->isAlarmEnabled()) {
296 Alarm *alarm =event->alarms().first() ; 296 Alarm *alarm =event->alarms().first() ;
297 QDateTime t = alarm->time(); 297 QDateTime t = alarm->time();
298 int min = t.secsTo( event->dtStart() )/60; 298 int min = t.secsTo( event->dtStart() )/60;
299 QString s =i18n("( %1 min before )").arg( min ); 299 QString s =i18n("( %1 min before )").arg( min );
300 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 300 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
301 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 301 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
302 //addTag("p",s); 302 //addTag("p",s);
303 } 303 }
304 304
305 addTag("b",i18n("Access: ")); 305 addTag("b",i18n("Access: "));
306 mText.append(event->secrecyStr()+"<br>"); 306 mText.append(event->secrecyStr()+"<br>");
307 if (!event->description().isEmpty()) { 307 if (!event->description().isEmpty()) {
308 addTag("p",i18n("<b>Details: </b>")); 308 addTag("p",i18n("<b>Details: </b>"));
309 addTag("p",event->description()); 309 addTag("p",event->description());
310 } 310 }
311 311
312 formatCategories(event); 312 formatCategories(event);
313 313
314 formatReadOnly(event); 314 formatReadOnly(event);
315 formatAttendees(event); 315 formatAttendees(event);
316 316
317 setText(mText); 317 setText(mText);
318 //QWhatsThis::add(this,mText); 318 //QWhatsThis::add(this,mText);
319 319
320} 320}
321 321
322void KOEventViewer::appendTodo(Todo *event, int mode ) 322void KOEventViewer::appendTodo(Todo *event, int mode )
323{ 323{
324 mMailSubject = ""; 324 mMailSubject = "";
325 mCurrentIncidence = event; 325 mCurrentIncidence = event;
326 topLevelWidget()->setCaption(i18n("Todo Viewer")); 326 topLevelWidget()->setCaption(i18n("Todo Viewer"));
327 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 327 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
328 if (mode == 0 ) 328 if (mode == 0 )
329 addTag("h2",event->summary()); 329 addTag("h2",event->summary());
330 else { 330 else {
331 if ( mColorMode == 1 ) { 331 if ( mColorMode == 1 ) {
332 mText +="<font color=\"#00A000\">"; 332 mText +="<font color=\"#00A000\">";
333 } 333 }
334 if ( mColorMode == 2 ) { 334 if ( mColorMode == 2 ) {
335 mText +="<font color=\"#B00000\">"; 335 mText +="<font color=\"#B00000\">";
336 } 336 }
337 if ( mode == 1 ) { 337 if ( mode == 1 ) {
338 addTag("h2",i18n( "Local: " ) +event->summary()); 338 addTag("h2",i18n( "Local: " ) +event->summary());
339 } else { 339 } else {
340 addTag("h2",i18n( "Remote: " ) +event->summary()); 340 addTag("h2",i18n( "Remote: " ) +event->summary());
341 } 341 }
342 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 342 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
343 if ( mColorMode ) 343 if ( mColorMode )
344 mText += "</font>"; 344 mText += "</font>";
345 } 345 }
346 mMailSubject += i18n( "Todo " )+ event->summary(); 346 mMailSubject += i18n( "Todo " )+ event->summary();
347 if (event->cancelled ()) { 347 if (event->cancelled ()) {
348 mText +="<font color=\"#B00000\">"; 348 mText +="<font color=\"#B00000\">";
349 addTag("i",i18n("This todo has been cancelled!")); 349 addTag("i",i18n("This todo has been cancelled!"));
350 mText.append("<br>"); 350 mText.append("<br>");
351 mText += "</font>"; 351 mText += "</font>";
352 mMailSubject += i18n("(cancelled)"); 352 mMailSubject += i18n("(cancelled)");
353 } 353 }
354 354
355 if (!event->location().isEmpty()) { 355 if (!event->location().isEmpty()) {
356 addTag("b",i18n("Location: ")); 356 addTag("b",i18n("Location: "));
357 mText.append(event->location()+"<br>"); 357 mText.append(event->location()+"<br>");
358 mMailSubject += i18n(" at ") + event->location(); 358 mMailSubject += i18n(" at ") + event->location();
359 } 359 }
360 if (event->hasDueDate()) { 360 if (event->hasDueDate()) {
361 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 361 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
362 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 362 mMailSubject += i18n(" - " )+event->dtDueStr( true );
363 } 363 }
364 addTag("b",i18n("Access: ")); 364 addTag("b",i18n("Access: "));
365 mText.append(event->secrecyStr()+"<br>"); 365 mText.append(event->secrecyStr()+"<br>");
366 if (!event->description().isEmpty()) { 366 if (!event->description().isEmpty()) {
367 addTag("p",i18n("<b>Details: </b>")); 367 addTag("p",i18n("<b>Details: </b>"));
368 addTag("p",event->description()); 368 addTag("p",event->description());
369 } 369 }
370 370
371 formatCategories(event); 371 formatCategories(event);
372 372
373 mText.append(i18n("<p><b>Priority:</b> %2</p>") 373 mText.append(i18n("<p><b>Priority:</b> %2</p>")
374 .arg(QString::number(event->priority()))); 374 .arg(QString::number(event->priority())));
375 375
376 mText.append(i18n("<p><i>%1 % completed</i></p>") 376 mText.append(i18n("<p><i>%1 % completed</i></p>")
377 .arg(event->percentComplete())); 377 .arg(event->percentComplete()));
378 378
379 formatReadOnly(event); 379 formatReadOnly(event);
380 formatAttendees(event); 380 formatAttendees(event);
381 381
382 setText(mText); 382 setText(mText);
383} 383}
384 384
385void KOEventViewer::formatCategories(Incidence *event) 385void KOEventViewer::formatCategories(Incidence *event)
386{ 386{
387 if (!event->categoriesStr().isEmpty()) { 387 if (!event->categoriesStr().isEmpty()) {
388 if (event->categories().count() == 1) { 388 if (event->categories().count() == 1) {
389 addTag("h3",i18n("Category")); 389 addTag("h3",i18n("Category"));
390 } else { 390 } else {
391 addTag("h3",i18n("Categories")); 391 addTag("h3",i18n("Categories"));
392 } 392 }
393 addTag("p",event->categoriesStr()); 393 addTag("p",event->categoriesStr());
394 } 394 }
395} 395}
396void KOEventViewer::formatAttendees(Incidence *event) 396void KOEventViewer::formatAttendees(Incidence *event)
397{ 397{
398 QPtrList<Attendee> attendees = event->attendees(); 398 QPtrList<Attendee> attendees = event->attendees();
399 if (attendees.count()) { 399 if (attendees.count()) {
400 400
401 401
402 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 402 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
403 addTag("h3",i18n("Organizer")); 403 addTag("h3",i18n("Organizer"));
404 mText.append("<ul><li>"); 404 mText.append("<ul><li>");
405#ifndef KORG_NOKABC 405#ifndef KORG_NOKABC
406 406
407#ifdef DESKTOP_VERSION 407#ifdef DESKTOP_VERSION
408 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 408 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
409 KABC::Addressee::List addressList; 409 KABC::Addressee::List addressList;
410 addressList = add_book->findByEmail(event->organizer()); 410 addressList = add_book->findByEmail(event->organizer());
411 KABC::Addressee o = addressList.first(); 411 KABC::Addressee o = addressList.first();
412 if (!o.isEmpty() && addressList.size()<2) { 412 if (!o.isEmpty() && addressList.size()<2) {
413 mText += "<a href=\"uid:" + o.uid() + "\">"; 413 mText += "<a href=\"uid:" + o.uid() + "\">";
414 mText += o.formattedName(); 414 mText += o.formattedName();
415 mText += "</a>\n"; 415 mText += "</a>\n";
416 } else { 416 } else {
417 mText.append(event->organizer()); 417 mText.append(event->organizer());
418 } 418 }
419#else //DESKTOP_VERSION 419#else //DESKTOP_VERSION
420 mText.append(event->organizer()); 420 mText.append(event->organizer());
421#endif //DESKTOP_VERSION 421#endif //DESKTOP_VERSION
422 422
423 423
424#else 424#else
425 mText.append(event->organizer()); 425 mText.append(event->organizer());
426#endif 426#endif
427 427
428 if (iconPath) { 428 if (iconPath) {
429 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 429 mText += " <a href=\"mailto:" + event->organizer() + "\">";
430 mText += "<IMG src=\"" + iconPath + "\">"; 430 mText += "<IMG src=\"" + iconPath + "\">";
431 mText += "</a>\n"; 431 mText += "</a>\n";
432 } 432 }
433 mText.append("</li></ul>"); 433 mText.append("</li></ul>");
434 434
435 addTag("h3",i18n("Attendees")); 435 addTag("h3",i18n("Attendees"));
436 Attendee *a; 436 Attendee *a;
437 mText.append("<ul>"); 437 mText.append("<ul>");
438 for(a=attendees.first();a;a=attendees.next()) { 438 for(a=attendees.first();a;a=attendees.next()) {
439#ifndef KORG_NOKABC 439#ifndef KORG_NOKABC
440#ifdef DESKTOP_VERSION 440#ifdef DESKTOP_VERSION
441 if (a->name().isEmpty()) { 441 if (a->name().isEmpty()) {
442 addressList = add_book->findByEmail(a->email()); 442 addressList = add_book->findByEmail(a->email());
443 KABC::Addressee o = addressList.first(); 443 KABC::Addressee o = addressList.first();
444 if (!o.isEmpty() && addressList.size()<2) { 444 if (!o.isEmpty() && addressList.size()<2) {
445 mText += "<a href=\"uid:" + o.uid() + "\">"; 445 mText += "<a href=\"uid:" + o.uid() + "\">";
446 mText += o.formattedName(); 446 mText += o.formattedName();
447 mText += "</a>\n"; 447 mText += "</a>\n";
448 } else { 448 } else {
449 mText += "<li>"; 449 mText += "<li>";
450 mText.append(a->email()); 450 mText.append(a->email());
451 mText += "\n"; 451 mText += "\n";
452 } 452 }
453 } else { 453 } else {
454 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 454 mText += "<li><a href=\"uid:" + a->uid() + "\">";
455 if (!a->name().isEmpty()) mText += a->name(); 455 if (!a->name().isEmpty()) mText += a->name();
456 else mText += a->email(); 456 else mText += a->email();
457 mText += "</a>\n"; 457 mText += "</a>\n";
458 } 458 }
459#else //DESKTOP_VERSION 459#else //DESKTOP_VERSION
460 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 460 mText += "<li><a href=\"uid:" + a->uid() + "\">";
461 if (!a->name().isEmpty()) mText += a->name(); 461 if (!a->name().isEmpty()) mText += a->name();
462 else mText += a->email(); 462 else mText += a->email();
463 mText += "</a>\n"; 463 mText += "</a>\n";
464#endif //DESKTOP_VERSION 464#endif //DESKTOP_VERSION
465#else 465#else
466 //qDebug("nokabc "); 466 //qDebug("nokabc ");
467 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 467 mText += "<li><a href=\"uid:" + a->uid() + "\">";
468 if (!a->name().isEmpty()) mText += a->name(); 468 if (!a->name().isEmpty()) mText += a->name();
469 else mText += a->email(); 469 else mText += a->email();
470 mText += "</a>\n"; 470 mText += "</a>\n";
471#endif 471#endif
472 472
473 473
474 if (!a->email().isEmpty()) { 474 if (!a->email().isEmpty()) {
475 if (iconPath) { 475 if (iconPath) {
476 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 476 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
477 mText += "<IMG src=\"" + iconPath + "\">"; 477 mText += "<IMG src=\"" + iconPath + "\">";
478 mText += "</a>\n"; 478 mText += "</a>\n";
479 } 479 }
480 } 480 }
481 if (a->status() != Attendee::NeedsAction ) 481 if (a->status() != Attendee::NeedsAction )
482 mText +="[" + a->statusStr() + "] "; 482 mText +="[" + a->statusStr() + "] ";
483 if (a->role() == Attendee::Chair ) 483 if (a->role() == Attendee::Chair )
484 mText +="(" + a->roleStr().left(1) + ".)"; 484 mText +="(" + a->roleStr().left(1) + ".)";
485 } 485 }
486 mText.append("</li></ul>"); 486 mText.append("</li></ul>");
487 } 487 }
488 488
489} 489}
490void KOEventViewer::appendJournal(Journal *jour, int mode ) 490void KOEventViewer::appendJournal(Journal *jour, int mode )
491{ 491{
492 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 492 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
493 if (mode == 0 ) 493 if (mode == 0 )
494 addTag("h2",i18n("Journal from: ")); 494 addTag("h2",i18n("Journal from: "));
495 else { 495 else {
496 if ( mode == 1 ) { 496 if ( mode == 1 ) {
497 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 497 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
498 } else { 498 } else {
499 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 499 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
500 } 500 }
501 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 501 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
502 } 502 }
503 topLevelWidget()->setCaption("Journal Viewer"); 503 topLevelWidget()->setCaption("Journal Viewer");
504 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 504 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
505 if (!jour->description().isEmpty()) { 505 if (!jour->description().isEmpty()) {
506 addTag("p",jour->description()); 506 addTag("p",jour->description());
507 } 507 }
508 setText(mText); 508 setText(mText);
509} 509}
510 510
511void KOEventViewer::formatReadOnly(Incidence *event) 511void KOEventViewer::formatReadOnly(Incidence *event)
512{ 512{
513 if (event->isReadOnly()) { 513 if (event->isReadOnly()) {
514 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 514 addTag("p","<em>(" + i18n("read-only") + ")</em>");
515 } 515 }
516} 516}
517void KOEventViewer::setSyncMode( bool b ) 517void KOEventViewer::setSyncMode( bool b )
518{ 518{
519 mSyncMode = b; 519 mSyncMode = b;
520} 520}
521 521
522 522
523void KOEventViewer::setTodo(Todo *event, bool clearV ) 523void KOEventViewer::setTodo(Todo *event, bool clearV )
524{ 524{
525 if ( clearV ) 525 if ( clearV )
526 clearEvents(); 526 clearEvents();
527 if ( mSyncMode ) { 527 if ( mSyncMode ) {
528 if ( clearV ) 528 if ( clearV )
529 appendTodo(event,1 ); 529 appendTodo(event,1 );
530 else 530 else
531 appendTodo(event,2); 531 appendTodo(event,2);
532 } else 532 } else
533 appendTodo(event); 533 appendTodo(event);
534} 534}
535void KOEventViewer::setJournal(Journal *event, bool clearV ) 535void KOEventViewer::setJournal(Journal *event, bool clearV )
536{ 536{
537 if ( clearV ) 537 if ( clearV )
538 clearEvents(); 538 clearEvents();
539 if ( mSyncMode ) { 539 if ( mSyncMode ) {
540 if ( clearV ) 540 if ( clearV )
541 appendJournal(event, 1); 541 appendJournal(event, 1);
542 else 542 else
543 appendJournal(event, 2); 543 appendJournal(event, 2);
544 } else 544 } else
545 appendJournal(event); 545 appendJournal(event);
546} 546}
547 547
548void KOEventViewer::setEvent(Event *event) 548void KOEventViewer::setEvent(Event *event)
549{ 549{
550 clearEvents(); 550 clearEvents();
551 if ( mSyncMode ) 551 if ( mSyncMode )
552 appendEvent(event, 1); 552 appendEvent(event, 1);
553 else 553 else
554 appendEvent(event); 554 appendEvent(event);
555} 555}
556 556
557void KOEventViewer::addEvent(Event *event) 557void KOEventViewer::addEvent(Event *event)
558{ 558{
559 if ( mSyncMode ) 559 if ( mSyncMode )
560 appendEvent(event, 2); 560 appendEvent(event, 2);
561 else 561 else
562 appendEvent(event); 562 appendEvent(event);
563} 563}
564 564
565void KOEventViewer::clearEvents(bool now) 565void KOEventViewer::clearEvents(bool now)
566{ 566{
567 mText = ""; 567 mText = "";
568 if (now) setText(mText); 568 if (now) setText(mText);
569} 569}
570 570
571void KOEventViewer::addText(QString text) 571void KOEventViewer::addText(QString text)
572{ 572{
573 mText.append(text); 573 mText.append(text);
574 setText(mText); 574 setText(mText);
575} 575}