summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-08 11:34:38 (UTC)
committer zautrix <zautrix>2004-09-08 11:34:38 (UTC)
commit1fcec858408b88bb412af18fbf853b49b6970d8a (patch) (unidiff)
tree702e94a74f0bb90335b9b193d28e31c1dc392c03
parentcdff4506a9148c47406af86968da73c0dbfca0ba (diff)
downloadkdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.zip
kdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.tar.gz
kdepimpi-1fcec858408b88bb412af18fbf853b49b6970d8a.tar.bz2
Fixed QCOP call problem of kopiemail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp4
-rw-r--r--kmicromail/composemail.cpp11
-rw-r--r--kmicromail/opiemail.cpp62
-rw-r--r--kmicromail/opiemail.h2
4 files changed, 49 insertions, 30 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d1d385c..74e5cf7 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2154 +1,2154 @@
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/kapibeamfile.vcf"; 640 QString fileName = "/tmp/kapibeamfile.vcf";
641 641
642 642
643 //QDir().mkdir( dirName, true ); 643 //QDir().mkdir( dirName, true );
644 644
645 645
646 KABC::VCardConverter converter; 646 KABC::VCardConverter converter;
647 QString description; 647 QString description;
648 QString datastream; 648 QString datastream;
649 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 649 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
650 KABC::Addressee a = mAddressBook->findByUid( *it ); 650 KABC::Addressee a = mAddressBook->findByUid( *it );
651 651
652 if ( a.isEmpty() ) 652 if ( a.isEmpty() )
653 continue; 653 continue;
654 654
655 if (description.isEmpty()) 655 if (description.isEmpty())
656 description = a.formattedName(); 656 description = a.formattedName();
657 657
658 QString vcard; 658 QString vcard;
659 converter.addresseeToVCard( a, vcard ); 659 converter.addresseeToVCard( a, vcard );
660 int start = 0; 660 int start = 0;
661 int next; 661 int next;
662 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 662 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
663 int semi = vcard.find(";", next); 663 int semi = vcard.find(";", next);
664 int dopp = vcard.find(":", next); 664 int dopp = vcard.find(":", next);
665 int sep; 665 int sep;
666 if ( semi < dopp && semi >= 0 ) 666 if ( semi < dopp && semi >= 0 )
667 sep = semi ; 667 sep = semi ;
668 else 668 else
669 sep = dopp; 669 sep = dopp;
670 datastream +=vcard.mid( start, next - start); 670 datastream +=vcard.mid( start, next - start);
671 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 671 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
672 start = sep; 672 start = sep;
673 } 673 }
674 datastream += vcard.mid( start,vcard.length() ); 674 datastream += vcard.mid( start,vcard.length() );
675 } 675 }
676#ifndef DESKTOP_VERSION 676#ifndef DESKTOP_VERSION
677 QFile outFile(fileName); 677 QFile outFile(fileName);
678 if ( outFile.open(IO_WriteOnly) ) { 678 if ( outFile.open(IO_WriteOnly) ) {
679 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 679 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
680 QTextStream t( &outFile ); // use a text stream 680 QTextStream t( &outFile ); // use a text stream
681 t.setEncoding( QTextStream::UnicodeUTF8 ); 681 t.setEncoding( QTextStream::UnicodeUTF8 );
682 t <<datastream; 682 t <<datastream;
683 outFile.close(); 683 outFile.close();
684 Ir *ir = new Ir( this ); 684 Ir *ir = new Ir( this );
685 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 685 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
686 ir->send( fileName, description, "text/x-vCard" ); 686 ir->send( fileName, description, "text/x-vCard" );
687 } else { 687 } else {
688 qDebug("Error open temp beam file "); 688 qDebug("Error open temp beam file ");
689 return; 689 return;
690 } 690 }
691#endif 691#endif
692 692
693} 693}
694 694
695void KABCore::beamDone( Ir *ir ) 695void KABCore::beamDone( Ir *ir )
696{ 696{
697#ifndef DESKTOP_VERSION 697#ifndef DESKTOP_VERSION
698 delete ir; 698 delete ir;
699#endif 699#endif
700} 700}
701 701
702 702
703void KABCore::browse( const QString& url ) 703void KABCore::browse( const QString& url )
704{ 704{
705#ifndef KAB_EMBEDDED 705#ifndef KAB_EMBEDDED
706 kapp->invokeBrowser( url ); 706 kapp->invokeBrowser( url );
707#else //KAB_EMBEDDED 707#else //KAB_EMBEDDED
708 qDebug("KABCore::browse must be fixed"); 708 qDebug("KABCore::browse must be fixed");
709#endif //KAB_EMBEDDED 709#endif //KAB_EMBEDDED
710} 710}
711 711
712void KABCore::selectAllContacts() 712void KABCore::selectAllContacts()
713{ 713{
714 mViewManager->setSelected( QString::null, true ); 714 mViewManager->setSelected( QString::null, true );
715} 715}
716 716
717void KABCore::deleteContacts() 717void KABCore::deleteContacts()
718{ 718{
719 QStringList uidList = mViewManager->selectedUids(); 719 QStringList uidList = mViewManager->selectedUids();
720 deleteContacts( uidList ); 720 deleteContacts( uidList );
721} 721}
722 722
723void KABCore::deleteContacts( const QStringList &uids ) 723void KABCore::deleteContacts( const QStringList &uids )
724{ 724{
725 if ( uids.count() > 0 ) { 725 if ( uids.count() > 0 ) {
726 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 726 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
727 UndoStack::instance()->push( command ); 727 UndoStack::instance()->push( command );
728 RedoStack::instance()->clear(); 728 RedoStack::instance()->clear();
729 729
730 // now if we deleted anything, refresh 730 // now if we deleted anything, refresh
731 setContactSelected( QString::null ); 731 setContactSelected( QString::null );
732 setModified( true ); 732 setModified( true );
733 } 733 }
734} 734}
735 735
736void KABCore::copyContacts() 736void KABCore::copyContacts()
737{ 737{
738 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 738 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
739 739
740 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 740 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
741 741
742 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 742 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
743 743
744 QClipboard *cb = QApplication::clipboard(); 744 QClipboard *cb = QApplication::clipboard();
745 cb->setText( clipText ); 745 cb->setText( clipText );
746} 746}
747 747
748void KABCore::cutContacts() 748void KABCore::cutContacts()
749{ 749{
750 QStringList uidList = mViewManager->selectedUids(); 750 QStringList uidList = mViewManager->selectedUids();
751 751
752//US if ( uidList.size() > 0 ) { 752//US if ( uidList.size() > 0 ) {
753 if ( uidList.count() > 0 ) { 753 if ( uidList.count() > 0 ) {
754 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 754 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
755 UndoStack::instance()->push( command ); 755 UndoStack::instance()->push( command );
756 RedoStack::instance()->clear(); 756 RedoStack::instance()->clear();
757 757
758 setModified( true ); 758 setModified( true );
759 } 759 }
760} 760}
761 761
762void KABCore::pasteContacts() 762void KABCore::pasteContacts()
763{ 763{
764 QClipboard *cb = QApplication::clipboard(); 764 QClipboard *cb = QApplication::clipboard();
765 765
766 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 766 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
767 767
768 pasteContacts( list ); 768 pasteContacts( list );
769} 769}
770 770
771void KABCore::pasteContacts( KABC::Addressee::List &list ) 771void KABCore::pasteContacts( KABC::Addressee::List &list )
772{ 772{
773 KABC::Resource *resource = requestResource( this ); 773 KABC::Resource *resource = requestResource( this );
774 KABC::Addressee::List::Iterator it; 774 KABC::Addressee::List::Iterator it;
775 for ( it = list.begin(); it != list.end(); ++it ) 775 for ( it = list.begin(); it != list.end(); ++it )
776 (*it).setResource( resource ); 776 (*it).setResource( resource );
777 777
778 PwPasteCommand *command = new PwPasteCommand( this, list ); 778 PwPasteCommand *command = new PwPasteCommand( this, list );
779 UndoStack::instance()->push( command ); 779 UndoStack::instance()->push( command );
780 RedoStack::instance()->clear(); 780 RedoStack::instance()->clear();
781 781
782 setModified( true ); 782 setModified( true );
783} 783}
784 784
785void KABCore::setWhoAmI() 785void KABCore::setWhoAmI()
786{ 786{
787 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 787 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
788 788
789 if ( addrList.count() > 1 ) { 789 if ( addrList.count() > 1 ) {
790 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 790 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
791 return; 791 return;
792 } 792 }
793 793
794 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 794 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
795 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
796 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 796 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
797} 797}
798 798
799void KABCore::setCategories() 799void KABCore::setCategories()
800{ 800{
801 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 801 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
802 if ( !dlg.exec() ) 802 if ( !dlg.exec() )
803 return; 803 return;
804 804
805 bool merge = false; 805 bool merge = false;
806 QString msg = i18n( "Merge with existing categories?" ); 806 QString msg = i18n( "Merge with existing categories?" );
807 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 807 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
808 merge = true; 808 merge = true;
809 809
810 QStringList categories = dlg.selectedCategories(); 810 QStringList categories = dlg.selectedCategories();
811 811
812 QStringList uids = mViewManager->selectedUids(); 812 QStringList uids = mViewManager->selectedUids();
813 QStringList::Iterator it; 813 QStringList::Iterator it;
814 for ( it = uids.begin(); it != uids.end(); ++it ) { 814 for ( it = uids.begin(); it != uids.end(); ++it ) {
815 KABC::Addressee addr = mAddressBook->findByUid( *it ); 815 KABC::Addressee addr = mAddressBook->findByUid( *it );
816 if ( !addr.isEmpty() ) { 816 if ( !addr.isEmpty() ) {
817 if ( !merge ) 817 if ( !merge )
818 addr.setCategories( categories ); 818 addr.setCategories( categories );
819 else { 819 else {
820 QStringList addrCategories = addr.categories(); 820 QStringList addrCategories = addr.categories();
821 QStringList::Iterator catIt; 821 QStringList::Iterator catIt;
822 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 822 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
823 if ( !addrCategories.contains( *catIt ) ) 823 if ( !addrCategories.contains( *catIt ) )
824 addrCategories.append( *catIt ); 824 addrCategories.append( *catIt );
825 } 825 }
826 addr.setCategories( addrCategories ); 826 addr.setCategories( addrCategories );
827 } 827 }
828 828
829 mAddressBook->insertAddressee( addr ); 829 mAddressBook->insertAddressee( addr );
830 } 830 }
831 } 831 }
832 832
833 if ( uids.count() > 0 ) 833 if ( uids.count() > 0 )
834 setModified( true ); 834 setModified( true );
835} 835}
836 836
837void KABCore::setSearchFields( const KABC::Field::List &fields ) 837void KABCore::setSearchFields( const KABC::Field::List &fields )
838{ 838{
839 mIncSearchWidget->setFields( fields ); 839 mIncSearchWidget->setFields( fields );
840} 840}
841 841
842void KABCore::incrementalSearch( const QString& text ) 842void KABCore::incrementalSearch( const QString& text )
843{ 843{
844 mViewManager->setSelected( QString::null, false ); 844 mViewManager->setSelected( QString::null, false );
845 845
846 if ( !text.isEmpty() ) { 846 if ( !text.isEmpty() ) {
847 KABC::Field *field = mIncSearchWidget->currentField(); 847 KABC::Field *field = mIncSearchWidget->currentField();
848 QString pattern = text.lower()+"*"; 848 QString pattern = text.lower()+"*";
849 QRegExp re; 849 QRegExp re;
850 re.setWildcard(true); // most people understand these better. 850 re.setWildcard(true); // most people understand these better.
851 re.setCaseSensitive(false); 851 re.setCaseSensitive(false);
852 re.setPattern( pattern ); 852 re.setPattern( pattern );
853 QStringList foundUids; 853 QStringList foundUids;
854 if (!re.isValid()) 854 if (!re.isValid())
855 return; 855 return;
856#if 1 //KDE_VERSION >= 319 856#if 1 //KDE_VERSION >= 319
857 KABC::AddresseeList list( mAddressBook->allAddressees() ); 857 KABC::AddresseeList list( mAddressBook->allAddressees() );
858 if ( field ) { 858 if ( field ) {
859 list.sortByField( field ); 859 list.sortByField( field );
860 KABC::AddresseeList::Iterator it; 860 KABC::AddresseeList::Iterator it;
861 for ( it = list.begin(); it != list.end(); ++it ) { 861 for ( it = list.begin(); it != list.end(); ++it ) {
862 862
863#if QT_VERSION >= 300 863#if QT_VERSION >= 300
864 if (re.search(field->value( *it ).lower()) != -1) 864 if (re.search(field->value( *it ).lower()) != -1)
865#else 865#else
866 if (re.match(field->value( *it ).lower()) != -1) 866 if (re.match(field->value( *it ).lower()) != -1)
867#endif 867#endif
868 { 868 {
869 // if ( field->value( *it ).lower().startsWith( pattern ) ) { 869 // if ( field->value( *it ).lower().startsWith( pattern ) ) {
870 //mViewManager->setSelected( (*it).uid(), true ); 870 //mViewManager->setSelected( (*it).uid(), true );
871 foundUids.append( (*it).uid() ); 871 foundUids.append( (*it).uid() );
872 //return; 872 //return;
873 } 873 }
874 } 874 }
875 } else { 875 } else {
876 KABC::AddresseeList::Iterator it; 876 KABC::AddresseeList::Iterator it;
877 for ( it = list.begin(); it != list.end(); ++it ) { 877 for ( it = list.begin(); it != list.end(); ++it ) {
878 KABC::Field::List fieldList = mIncSearchWidget->fields(); 878 KABC::Field::List fieldList = mIncSearchWidget->fields();
879 KABC::Field::List::ConstIterator fieldIt; 879 KABC::Field::List::ConstIterator fieldIt;
880 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 880 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
881#if QT_VERSION >= 300 881#if QT_VERSION >= 300
882 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 882 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
883#else 883#else
884 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 884 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
885#endif 885#endif
886 { 886 {
887 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 887 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
888 //mViewManager->setSelected( (*it).uid(), true ); 888 //mViewManager->setSelected( (*it).uid(), true );
889 foundUids.append( (*it).uid() ); 889 foundUids.append( (*it).uid() );
890 //return; 890 //return;
891 } 891 }
892 } 892 }
893 } 893 }
894 } 894 }
895 if ( foundUids.count() > 0 ) 895 if ( foundUids.count() > 0 )
896 mViewManager->setListSelected( foundUids ); 896 mViewManager->setListSelected( foundUids );
897#else 897#else
898 KABC::AddressBook::Iterator it; 898 KABC::AddressBook::Iterator it;
899 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 899 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
900 if ( field ) { 900 if ( field ) {
901 if ( field->value( *it ).lower().startsWith( pattern ) ) { 901 if ( field->value( *it ).lower().startsWith( pattern ) ) {
902 mViewManager->setSelected( (*it).uid(), true ); 902 mViewManager->setSelected( (*it).uid(), true );
903 return; 903 return;
904 } 904 }
905 } else { 905 } else {
906 KABC::Field::List fieldList = mIncSearchWidget->fields(); 906 KABC::Field::List fieldList = mIncSearchWidget->fields();
907 KABC::Field::List::ConstIterator fieldIt; 907 KABC::Field::List::ConstIterator fieldIt;
908 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 908 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
909 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 909 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
910 mViewManager->setSelected( (*it).uid(), true ); 910 mViewManager->setSelected( (*it).uid(), true );
911 return; 911 return;
912 } 912 }
913 } 913 }
914 } 914 }
915 } 915 }
916#endif 916#endif
917 } 917 }
918} 918}
919 919
920void KABCore::setModified() 920void KABCore::setModified()
921{ 921{
922 setModified( true ); 922 setModified( true );
923} 923}
924 924
925void KABCore::setModifiedWOrefresh() 925void KABCore::setModifiedWOrefresh()
926{ 926{
927 // qDebug("KABCore::setModifiedWOrefresh() "); 927 // qDebug("KABCore::setModifiedWOrefresh() ");
928 mModified = true; 928 mModified = true;
929 mActionSave->setEnabled( mModified ); 929 mActionSave->setEnabled( mModified );
930#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
931 mDetails->refreshView(); 931 mDetails->refreshView();
932#endif 932#endif
933 933
934} 934}
935void KABCore::setModified( bool modified ) 935void KABCore::setModified( bool modified )
936{ 936{
937 mModified = modified; 937 mModified = modified;
938 mActionSave->setEnabled( mModified ); 938 mActionSave->setEnabled( mModified );
939 939
940 if ( modified ) 940 if ( modified )
941 mJumpButtonBar->recreateButtons(); 941 mJumpButtonBar->recreateButtons();
942 942
943 mViewManager->refreshView(); 943 mViewManager->refreshView();
944 mDetails->refreshView(); 944 mDetails->refreshView();
945 945
946} 946}
947 947
948bool KABCore::modified() const 948bool KABCore::modified() const
949{ 949{
950 return mModified; 950 return mModified;
951} 951}
952 952
953void KABCore::contactModified( const KABC::Addressee &addr ) 953void KABCore::contactModified( const KABC::Addressee &addr )
954{ 954{
955 955
956 Command *command = 0; 956 Command *command = 0;
957 QString uid; 957 QString uid;
958 958
959 // check if it exists already 959 // check if it exists already
960 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 960 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
961 if ( origAddr.isEmpty() ) 961 if ( origAddr.isEmpty() )
962 command = new PwNewCommand( mAddressBook, addr ); 962 command = new PwNewCommand( mAddressBook, addr );
963 else { 963 else {
964 command = new PwEditCommand( mAddressBook, origAddr, addr ); 964 command = new PwEditCommand( mAddressBook, origAddr, addr );
965 uid = addr.uid(); 965 uid = addr.uid();
966 } 966 }
967 967
968 UndoStack::instance()->push( command ); 968 UndoStack::instance()->push( command );
969 RedoStack::instance()->clear(); 969 RedoStack::instance()->clear();
970 970
971 setModified( true ); 971 setModified( true );
972} 972}
973 973
974void KABCore::newContact() 974void KABCore::newContact()
975{ 975{
976 976
977 977
978 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 978 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
979 979
980 QPtrList<KRES::Resource> kresResources; 980 QPtrList<KRES::Resource> kresResources;
981 QPtrListIterator<KABC::Resource> it( kabcResources ); 981 QPtrListIterator<KABC::Resource> it( kabcResources );
982 KABC::Resource *resource; 982 KABC::Resource *resource;
983 while ( ( resource = it.current() ) != 0 ) { 983 while ( ( resource = it.current() ) != 0 ) {
984 ++it; 984 ++it;
985 if ( !resource->readOnly() ) { 985 if ( !resource->readOnly() ) {
986 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 986 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
987 if ( res ) 987 if ( res )
988 kresResources.append( res ); 988 kresResources.append( res );
989 } 989 }
990 } 990 }
991 991
992 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 992 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
993 resource = static_cast<KABC::Resource*>( res ); 993 resource = static_cast<KABC::Resource*>( res );
994 994
995 if ( resource ) { 995 if ( resource ) {
996 KABC::Addressee addr; 996 KABC::Addressee addr;
997 addr.setResource( resource ); 997 addr.setResource( resource );
998 mEditorDialog->setAddressee( addr ); 998 mEditorDialog->setAddressee( addr );
999 KApplication::execDialog ( mEditorDialog ); 999 KApplication::execDialog ( mEditorDialog );
1000 1000
1001 } else 1001 } else
1002 return; 1002 return;
1003 1003
1004 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1004 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1005 1005
1006 1006
1007} 1007}
1008 1008
1009void KABCore::addEmail( QString aStr ) 1009void KABCore::addEmail( QString aStr )
1010{ 1010{
1011#ifndef KAB_EMBEDDED 1011#ifndef KAB_EMBEDDED
1012 QString fullName, email; 1012 QString fullName, email;
1013 1013
1014 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1014 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1015 1015
1016 // Try to lookup the addressee matching the email address 1016 // Try to lookup the addressee matching the email address
1017 bool found = false; 1017 bool found = false;
1018 QStringList emailList; 1018 QStringList emailList;
1019 KABC::AddressBook::Iterator it; 1019 KABC::AddressBook::Iterator it;
1020 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1020 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1021 emailList = (*it).emails(); 1021 emailList = (*it).emails();
1022 if ( emailList.contains( email ) > 0 ) { 1022 if ( emailList.contains( email ) > 0 ) {
1023 found = true; 1023 found = true;
1024 (*it).setNameFromString( fullName ); 1024 (*it).setNameFromString( fullName );
1025 editContact( (*it).uid() ); 1025 editContact( (*it).uid() );
1026 } 1026 }
1027 } 1027 }
1028 1028
1029 if ( !found ) { 1029 if ( !found ) {
1030 KABC::Addressee addr; 1030 KABC::Addressee addr;
1031 addr.setNameFromString( fullName ); 1031 addr.setNameFromString( fullName );
1032 addr.insertEmail( email, true ); 1032 addr.insertEmail( email, true );
1033 1033
1034 mAddressBook->insertAddressee( addr ); 1034 mAddressBook->insertAddressee( addr );
1035 mViewManager->refreshView( addr.uid() ); 1035 mViewManager->refreshView( addr.uid() );
1036 editContact( addr.uid() ); 1036 editContact( addr.uid() );
1037 } 1037 }
1038#else //KAB_EMBEDDED 1038#else //KAB_EMBEDDED
1039 qDebug("KABCore::addEmail finsih method"); 1039 qDebug("KABCore::addEmail finsih method");
1040#endif //KAB_EMBEDDED 1040#endif //KAB_EMBEDDED
1041} 1041}
1042 1042
1043void KABCore::importVCard( const KURL &url, bool showPreview ) 1043void KABCore::importVCard( const KURL &url, bool showPreview )
1044{ 1044{
1045 mXXPortManager->importVCard( url, showPreview ); 1045 mXXPortManager->importVCard( url, showPreview );
1046} 1046}
1047void KABCore::importFromOL() 1047void KABCore::importFromOL()
1048{ 1048{
1049#ifdef _WIN32_ 1049#ifdef _WIN32_
1050 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1050 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1051 idgl->exec(); 1051 idgl->exec();
1052 KABC::Addressee::List list = idgl->getAddressList(); 1052 KABC::Addressee::List list = idgl->getAddressList();
1053 if ( list.count() > 0 ) { 1053 if ( list.count() > 0 ) {
1054 KABC::Addressee::List listNew; 1054 KABC::Addressee::List listNew;
1055 KABC::Addressee::List listExisting; 1055 KABC::Addressee::List listExisting;
1056 KABC::Addressee::List::Iterator it; 1056 KABC::Addressee::List::Iterator it;
1057 KABC::AddressBook::Iterator iter; 1057 KABC::AddressBook::Iterator iter;
1058 for ( it = list.begin(); it != list.end(); ++it ) { 1058 for ( it = list.begin(); it != list.end(); ++it ) {
1059 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1059 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1060 listNew.append( (*it) ); 1060 listNew.append( (*it) );
1061 else 1061 else
1062 listExisting.append( (*it) ); 1062 listExisting.append( (*it) );
1063 } 1063 }
1064 if ( listExisting.count() > 0 ) 1064 if ( listExisting.count() > 0 )
1065 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1065 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1066 if ( listNew.count() > 0 ) { 1066 if ( listNew.count() > 0 ) {
1067 pasteWithNewUid = false; 1067 pasteWithNewUid = false;
1068 pasteContacts( listNew ); 1068 pasteContacts( listNew );
1069 pasteWithNewUid = true; 1069 pasteWithNewUid = true;
1070 } 1070 }
1071 } 1071 }
1072 delete idgl; 1072 delete idgl;
1073#endif 1073#endif
1074} 1074}
1075 1075
1076void KABCore::importVCard( const QString &vCard, bool showPreview ) 1076void KABCore::importVCard( const QString &vCard, bool showPreview )
1077{ 1077{
1078 mXXPortManager->importVCard( vCard, showPreview ); 1078 mXXPortManager->importVCard( vCard, showPreview );
1079} 1079}
1080 1080
1081//US added a second method without defaultparameter 1081//US added a second method without defaultparameter
1082void KABCore::editContact2() { 1082void KABCore::editContact2() {
1083 editContact( QString::null ); 1083 editContact( QString::null );
1084} 1084}
1085 1085
1086void KABCore::editContact( const QString &uid ) 1086void KABCore::editContact( const QString &uid )
1087{ 1087{
1088 1088
1089 if ( mExtensionManager->isQuickEditVisible() ) 1089 if ( mExtensionManager->isQuickEditVisible() )
1090 return; 1090 return;
1091 1091
1092 // First, locate the contact entry 1092 // First, locate the contact entry
1093 QString localUID = uid; 1093 QString localUID = uid;
1094 if ( localUID.isNull() ) { 1094 if ( localUID.isNull() ) {
1095 QStringList uidList = mViewManager->selectedUids(); 1095 QStringList uidList = mViewManager->selectedUids();
1096 if ( uidList.count() > 0 ) 1096 if ( uidList.count() > 0 )
1097 localUID = *( uidList.at( 0 ) ); 1097 localUID = *( uidList.at( 0 ) );
1098 } 1098 }
1099 1099
1100 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1100 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1101 if ( !addr.isEmpty() ) { 1101 if ( !addr.isEmpty() ) {
1102 mEditorDialog->setAddressee( addr ); 1102 mEditorDialog->setAddressee( addr );
1103 KApplication::execDialog ( mEditorDialog ); 1103 KApplication::execDialog ( mEditorDialog );
1104 } 1104 }
1105} 1105}
1106 1106
1107/** 1107/**
1108 Shows or edits the detail view for the given uid. If the uid is QString::null, 1108 Shows or edits the detail view for the given uid. If the uid is QString::null,
1109 the method will try to find a selected addressee in the view. 1109 the method will try to find a selected addressee in the view.
1110 */ 1110 */
1111void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1111void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1112{ 1112{
1113 if ( mMultipleViewsAtOnce ) 1113 if ( mMultipleViewsAtOnce )
1114 { 1114 {
1115 editContact( uid ); 1115 editContact( uid );
1116 } 1116 }
1117 else 1117 else
1118 { 1118 {
1119 setDetailsVisible( true ); 1119 setDetailsVisible( true );
1120 mActionDetails->setChecked(true); 1120 mActionDetails->setChecked(true);
1121 } 1121 }
1122 1122
1123} 1123}
1124 1124
1125void KABCore::save() 1125void KABCore::save()
1126{ 1126{
1127 if ( !mModified ) 1127 if ( !mModified )
1128 return; 1128 return;
1129 QString text = i18n( "There was an error while attempting to save\n the " 1129 QString text = i18n( "There was an error while attempting to save\n the "
1130 "address book. Please check that some \nother application is " 1130 "address book. Please check that some \nother application is "
1131 "not using it. " ); 1131 "not using it. " );
1132 statusMessage(i18n("Saving addressbook ... ")); 1132 statusMessage(i18n("Saving addressbook ... "));
1133#ifndef KAB_EMBEDDED 1133#ifndef KAB_EMBEDDED
1134 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1134 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1135 if ( !b || !b->save() ) { 1135 if ( !b || !b->save() ) {
1136 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1136 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1137 } 1137 }
1138#else //KAB_EMBEDDED 1138#else //KAB_EMBEDDED
1139 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1139 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1140 if ( !b || !b->save() ) { 1140 if ( !b || !b->save() ) {
1141 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1141 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1142 } 1142 }
1143#endif //KAB_EMBEDDED 1143#endif //KAB_EMBEDDED
1144 1144
1145 statusMessage(i18n("Addressbook saved!")); 1145 statusMessage(i18n("Addressbook saved!"));
1146 setModified( false ); 1146 setModified( false );
1147} 1147}
1148 1148
1149void KABCore::statusMessage(QString mess , int time ) 1149void KABCore::statusMessage(QString mess , int time )
1150{ 1150{
1151 //topLevelWidget()->setCaption( mess ); 1151 //topLevelWidget()->setCaption( mess );
1152 // pending setting timer to revome message 1152 // pending setting timer to revome message
1153} 1153}
1154void KABCore::undo() 1154void KABCore::undo()
1155{ 1155{
1156 UndoStack::instance()->undo(); 1156 UndoStack::instance()->undo();
1157 1157
1158 // Refresh the view 1158 // Refresh the view
1159 mViewManager->refreshView(); 1159 mViewManager->refreshView();
1160} 1160}
1161 1161
1162void KABCore::redo() 1162void KABCore::redo()
1163{ 1163{
1164 RedoStack::instance()->redo(); 1164 RedoStack::instance()->redo();
1165 1165
1166 // Refresh the view 1166 // Refresh the view
1167 mViewManager->refreshView(); 1167 mViewManager->refreshView();
1168} 1168}
1169 1169
1170void KABCore::setJumpButtonBarVisible( bool visible ) 1170void KABCore::setJumpButtonBarVisible( bool visible )
1171{ 1171{
1172 if (mMultipleViewsAtOnce) 1172 if (mMultipleViewsAtOnce)
1173 { 1173 {
1174 if ( visible ) 1174 if ( visible )
1175 mJumpButtonBar->show(); 1175 mJumpButtonBar->show();
1176 else 1176 else
1177 mJumpButtonBar->hide(); 1177 mJumpButtonBar->hide();
1178 } 1178 }
1179 else 1179 else
1180 { 1180 {
1181 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1181 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1182 if (mViewManager->isVisible()) 1182 if (mViewManager->isVisible())
1183 { 1183 {
1184 if ( visible ) 1184 if ( visible )
1185 mJumpButtonBar->show(); 1185 mJumpButtonBar->show();
1186 else 1186 else
1187 mJumpButtonBar->hide(); 1187 mJumpButtonBar->hide();
1188 } 1188 }
1189 else 1189 else
1190 { 1190 {
1191 mJumpButtonBar->hide(); 1191 mJumpButtonBar->hide();
1192 } 1192 }
1193 } 1193 }
1194} 1194}
1195 1195
1196 1196
1197void KABCore::setDetailsToState() 1197void KABCore::setDetailsToState()
1198{ 1198{
1199 setDetailsVisible( mActionDetails->isChecked() ); 1199 setDetailsVisible( mActionDetails->isChecked() );
1200} 1200}
1201 1201
1202 1202
1203 1203
1204void KABCore::setDetailsVisible( bool visible ) 1204void KABCore::setDetailsVisible( bool visible )
1205{ 1205{
1206 if (visible && mDetails->isHidden()) 1206 if (visible && mDetails->isHidden())
1207 { 1207 {
1208 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1208 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1209 if ( addrList.count() > 0 ) 1209 if ( addrList.count() > 0 )
1210 mDetails->setAddressee( addrList[ 0 ] ); 1210 mDetails->setAddressee( addrList[ 0 ] );
1211 } 1211 }
1212 1212
1213 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1213 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1214 // the listview and the detailview. We do that by changing the splitbar size. 1214 // the listview and the detailview. We do that by changing the splitbar size.
1215 if (mMultipleViewsAtOnce) 1215 if (mMultipleViewsAtOnce)
1216 { 1216 {
1217 if ( visible ) 1217 if ( visible )
1218 mDetails->show(); 1218 mDetails->show();
1219 else 1219 else
1220 mDetails->hide(); 1220 mDetails->hide();
1221 } 1221 }
1222 else 1222 else
1223 { 1223 {
1224 if ( visible ) { 1224 if ( visible ) {
1225 mViewManager->hide(); 1225 mViewManager->hide();
1226 mDetails->show(); 1226 mDetails->show();
1227 } 1227 }
1228 else { 1228 else {
1229 mViewManager->show(); 1229 mViewManager->show();
1230 mDetails->hide(); 1230 mDetails->hide();
1231 } 1231 }
1232 setJumpButtonBarVisible( !visible ); 1232 setJumpButtonBarVisible( !visible );
1233 } 1233 }
1234 1234
1235} 1235}
1236 1236
1237void KABCore::extensionChanged( int id ) 1237void KABCore::extensionChanged( int id )
1238{ 1238{
1239 //change the details view only for non desktop systems 1239 //change the details view only for non desktop systems
1240#ifndef DESKTOP_VERSION 1240#ifndef DESKTOP_VERSION
1241 1241
1242 if (id == 0) 1242 if (id == 0)
1243 { 1243 {
1244 //the user disabled the extension. 1244 //the user disabled the extension.
1245 1245
1246 if (mMultipleViewsAtOnce) 1246 if (mMultipleViewsAtOnce)
1247 { // enable detailsview again 1247 { // enable detailsview again
1248 setDetailsVisible( true ); 1248 setDetailsVisible( true );
1249 mActionDetails->setChecked( true ); 1249 mActionDetails->setChecked( true );
1250 } 1250 }
1251 else 1251 else
1252 { //go back to the listview 1252 { //go back to the listview
1253 setDetailsVisible( false ); 1253 setDetailsVisible( false );
1254 mActionDetails->setChecked( false ); 1254 mActionDetails->setChecked( false );
1255 mActionDetails->setEnabled(true); 1255 mActionDetails->setEnabled(true);
1256 } 1256 }
1257 1257
1258 } 1258 }
1259 else 1259 else
1260 { 1260 {
1261 //the user enabled the extension. 1261 //the user enabled the extension.
1262 setDetailsVisible( false ); 1262 setDetailsVisible( false );
1263 mActionDetails->setChecked( false ); 1263 mActionDetails->setChecked( false );
1264 1264
1265 if (!mMultipleViewsAtOnce) 1265 if (!mMultipleViewsAtOnce)
1266 { 1266 {
1267 mActionDetails->setEnabled(false); 1267 mActionDetails->setEnabled(false);
1268 } 1268 }
1269 1269
1270 mExtensionManager->setSelectionChanged(); 1270 mExtensionManager->setSelectionChanged();
1271 1271
1272 } 1272 }
1273 1273
1274#endif// DESKTOP_VERSION 1274#endif// DESKTOP_VERSION
1275 1275
1276} 1276}
1277 1277
1278 1278
1279void KABCore::extensionModified( const KABC::Addressee::List &list ) 1279void KABCore::extensionModified( const KABC::Addressee::List &list )
1280{ 1280{
1281 1281
1282 if ( list.count() != 0 ) { 1282 if ( list.count() != 0 ) {
1283 KABC::Addressee::List::ConstIterator it; 1283 KABC::Addressee::List::ConstIterator it;
1284 for ( it = list.begin(); it != list.end(); ++it ) 1284 for ( it = list.begin(); it != list.end(); ++it )
1285 mAddressBook->insertAddressee( *it ); 1285 mAddressBook->insertAddressee( *it );
1286 if ( list.count() > 1 ) 1286 if ( list.count() > 1 )
1287 setModified(); 1287 setModified();
1288 else 1288 else
1289 setModifiedWOrefresh(); 1289 setModifiedWOrefresh();
1290 } 1290 }
1291 if ( list.count() == 0 ) 1291 if ( list.count() == 0 )
1292 mViewManager->refreshView(); 1292 mViewManager->refreshView();
1293 else 1293 else
1294 mViewManager->refreshView( list[ 0 ].uid() ); 1294 mViewManager->refreshView( list[ 0 ].uid() );
1295 1295
1296 1296
1297 1297
1298} 1298}
1299 1299
1300QString KABCore::getNameByPhone( const QString &phone ) 1300QString KABCore::getNameByPhone( const QString &phone )
1301{ 1301{
1302#ifndef KAB_EMBEDDED 1302#ifndef KAB_EMBEDDED
1303 QRegExp r( "[/*/-/ ]" ); 1303 QRegExp r( "[/*/-/ ]" );
1304 QString localPhone( phone ); 1304 QString localPhone( phone );
1305 1305
1306 bool found = false; 1306 bool found = false;
1307 QString ownerName = ""; 1307 QString ownerName = "";
1308 KABC::AddressBook::Iterator iter; 1308 KABC::AddressBook::Iterator iter;
1309 KABC::PhoneNumber::List::Iterator phoneIter; 1309 KABC::PhoneNumber::List::Iterator phoneIter;
1310 KABC::PhoneNumber::List phoneList; 1310 KABC::PhoneNumber::List phoneList;
1311 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1311 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1312 phoneList = (*iter).phoneNumbers(); 1312 phoneList = (*iter).phoneNumbers();
1313 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1313 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1314 ++phoneIter) { 1314 ++phoneIter) {
1315 // Get rid of separator chars so just the numbers are compared. 1315 // Get rid of separator chars so just the numbers are compared.
1316 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1316 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1317 ownerName = (*iter).formattedName(); 1317 ownerName = (*iter).formattedName();
1318 found = true; 1318 found = true;
1319 } 1319 }
1320 } 1320 }
1321 } 1321 }
1322 1322
1323 return ownerName; 1323 return ownerName;
1324#else //KAB_EMBEDDED 1324#else //KAB_EMBEDDED
1325 qDebug("KABCore::getNameByPhone finsih method"); 1325 qDebug("KABCore::getNameByPhone finsih method");
1326 return ""; 1326 return "";
1327#endif //KAB_EMBEDDED 1327#endif //KAB_EMBEDDED
1328 1328
1329} 1329}
1330 1330
1331void KABCore::openConfigDialog() 1331void KABCore::openConfigDialog()
1332{ 1332{
1333 KABPrefs* kab_prefs = KABPrefs::instance(); 1333 KABPrefs* kab_prefs = KABPrefs::instance();
1334 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1334 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1335 1335
1336 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1336 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1337 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1337 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1338 ConfigureDialog->addModule(kabcfg ); 1338 ConfigureDialog->addModule(kabcfg );
1339 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1339 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1340 ConfigureDialog->addModule(kdelibcfg ); 1340 ConfigureDialog->addModule(kdelibcfg );
1341 1341
1342 1342
1343 1343
1344 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1344 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1345 this, SLOT( configurationChanged() ) ); 1345 this, SLOT( configurationChanged() ) );
1346 connect( ConfigureDialog, SIGNAL( okClicked() ), 1346 connect( ConfigureDialog, SIGNAL( okClicked() ),
1347 this, SLOT( configurationChanged() ) ); 1347 this, SLOT( configurationChanged() ) );
1348 saveSettings(); 1348 saveSettings();
1349#ifndef DESKTOP_VERSION 1349#ifndef DESKTOP_VERSION
1350 ConfigureDialog->showMaximized(); 1350 ConfigureDialog->showMaximized();
1351#endif 1351#endif
1352 if ( ConfigureDialog->exec() ) 1352 if ( ConfigureDialog->exec() )
1353 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1353 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1354 delete ConfigureDialog; 1354 delete ConfigureDialog;
1355} 1355}
1356 1356
1357void KABCore::openLDAPDialog() 1357void KABCore::openLDAPDialog()
1358{ 1358{
1359#ifndef KAB_EMBEDDED 1359#ifndef KAB_EMBEDDED
1360 if ( !mLdapSearchDialog ) { 1360 if ( !mLdapSearchDialog ) {
1361 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1361 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1362 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1362 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1363 SLOT( refreshView() ) ); 1363 SLOT( refreshView() ) );
1364 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1364 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1365 SLOT( setModified() ) ); 1365 SLOT( setModified() ) );
1366 } else 1366 } else
1367 mLdapSearchDialog->restoreSettings(); 1367 mLdapSearchDialog->restoreSettings();
1368 1368
1369 if ( mLdapSearchDialog->isOK() ) 1369 if ( mLdapSearchDialog->isOK() )
1370 mLdapSearchDialog->exec(); 1370 mLdapSearchDialog->exec();
1371#else //KAB_EMBEDDED 1371#else //KAB_EMBEDDED
1372 qDebug("KABCore::openLDAPDialog() finsih method"); 1372 qDebug("KABCore::openLDAPDialog() finsih method");
1373#endif //KAB_EMBEDDED 1373#endif //KAB_EMBEDDED
1374} 1374}
1375 1375
1376void KABCore::print() 1376void KABCore::print()
1377{ 1377{
1378#ifndef KAB_EMBEDDED 1378#ifndef KAB_EMBEDDED
1379 KPrinter printer; 1379 KPrinter printer;
1380 if ( !printer.setup( this ) ) 1380 if ( !printer.setup( this ) )
1381 return; 1381 return;
1382 1382
1383 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1383 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1384 mViewManager->selectedUids(), this ); 1384 mViewManager->selectedUids(), this );
1385 1385
1386 wizard.exec(); 1386 wizard.exec();
1387#else //KAB_EMBEDDED 1387#else //KAB_EMBEDDED
1388 qDebug("KABCore::print() finsih method"); 1388 qDebug("KABCore::print() finsih method");
1389#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1390 1390
1391} 1391}
1392 1392
1393 1393
1394void KABCore::addGUIClient( KXMLGUIClient *client ) 1394void KABCore::addGUIClient( KXMLGUIClient *client )
1395{ 1395{
1396 if ( mGUIClient ) 1396 if ( mGUIClient )
1397 mGUIClient->insertChildClient( client ); 1397 mGUIClient->insertChildClient( client );
1398 else 1398 else
1399 KMessageBox::error( this, "no KXMLGUICLient"); 1399 KMessageBox::error( this, "no KXMLGUICLient");
1400} 1400}
1401 1401
1402 1402
1403void KABCore::configurationChanged() 1403void KABCore::configurationChanged()
1404{ 1404{
1405 mExtensionManager->reconfigure(); 1405 mExtensionManager->reconfigure();
1406} 1406}
1407 1407
1408void KABCore::addressBookChanged() 1408void KABCore::addressBookChanged()
1409{ 1409{
1410/*US 1410/*US
1411 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1411 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1412 while ( it.current() ) { 1412 while ( it.current() ) {
1413 if ( it.current()->dirty() ) { 1413 if ( it.current()->dirty() ) {
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 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1418 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1419 ++it; 1419 ++it;
1420 } 1420 }
1421*/ 1421*/
1422 if (mEditorDialog) 1422 if (mEditorDialog)
1423 { 1423 {
1424 if (mEditorDialog->dirty()) 1424 if (mEditorDialog->dirty())
1425 { 1425 {
1426 QString text = i18n( "Data has been changed externally. Unsaved " 1426 QString text = i18n( "Data has been changed externally. Unsaved "
1427 "changes will be lost." ); 1427 "changes will be lost." );
1428 KMessageBox::information( this, text ); 1428 KMessageBox::information( this, text );
1429 } 1429 }
1430 QString currentuid = mEditorDialog->addressee().uid(); 1430 QString currentuid = mEditorDialog->addressee().uid();
1431 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1431 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1432 } 1432 }
1433 mViewManager->refreshView(); 1433 mViewManager->refreshView();
1434// mDetails->refreshView(); 1434// mDetails->refreshView();
1435 1435
1436 1436
1437} 1437}
1438 1438
1439AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1439AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1440 const char *name ) 1440 const char *name )
1441{ 1441{
1442 1442
1443 if ( mEditorDialog == 0 ) { 1443 if ( mEditorDialog == 0 ) {
1444 mEditorDialog = new AddresseeEditorDialog( this, parent, 1444 mEditorDialog = new AddresseeEditorDialog( this, parent,
1445 name ? name : "editorDialog" ); 1445 name ? name : "editorDialog" );
1446 1446
1447 1447
1448 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1448 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1449 SLOT( contactModified( const KABC::Addressee& ) ) ); 1449 SLOT( contactModified( const KABC::Addressee& ) ) );
1450 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1450 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1451 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1451 // SLOT( slotEditorDestroyed( const QString& ) ) );
1452 } 1452 }
1453 1453
1454 return mEditorDialog; 1454 return mEditorDialog;
1455} 1455}
1456 1456
1457void KABCore::slotEditorDestroyed( const QString &uid ) 1457void KABCore::slotEditorDestroyed( const QString &uid )
1458{ 1458{
1459 //mEditorDict.remove( uid ); 1459 //mEditorDict.remove( uid );
1460} 1460}
1461 1461
1462void KABCore::initGUI() 1462void KABCore::initGUI()
1463{ 1463{
1464#ifndef KAB_EMBEDDED 1464#ifndef KAB_EMBEDDED
1465 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1465 QHBoxLayout *topLayout = new QHBoxLayout( this );
1466 topLayout->setSpacing( KDialogBase::spacingHint() ); 1466 topLayout->setSpacing( KDialogBase::spacingHint() );
1467 1467
1468 mExtensionBarSplitter = new QSplitter( this ); 1468 mExtensionBarSplitter = new QSplitter( this );
1469 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1469 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1470 1470
1471 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1471 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1472 1472
1473 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1473 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1474 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1474 mIncSearchWidget = new IncSearchWidget( viewSpace );
1475 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1475 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1476 SLOT( incrementalSearch( const QString& ) ) ); 1476 SLOT( incrementalSearch( const QString& ) ) );
1477 1477
1478 mViewManager = new ViewManager( this, viewSpace ); 1478 mViewManager = new ViewManager( this, viewSpace );
1479 viewSpace->setStretchFactor( mViewManager, 1 ); 1479 viewSpace->setStretchFactor( mViewManager, 1 );
1480 1480
1481 mDetails = new ViewContainer( mDetailsSplitter ); 1481 mDetails = new ViewContainer( mDetailsSplitter );
1482 1482
1483 mJumpButtonBar = new JumpButtonBar( this, this ); 1483 mJumpButtonBar = new JumpButtonBar( this, this );
1484 1484
1485 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1485 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1486 1486
1487 topLayout->addWidget( mExtensionBarSplitter ); 1487 topLayout->addWidget( mExtensionBarSplitter );
1488 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1488 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1489 topLayout->addWidget( mJumpButtonBar ); 1489 topLayout->addWidget( mJumpButtonBar );
1490 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1490 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1491 1491
1492 mXXPortManager = new XXPortManager( this, this ); 1492 mXXPortManager = new XXPortManager( this, this );
1493 1493
1494#else //KAB_EMBEDDED 1494#else //KAB_EMBEDDED
1495 //US initialize viewMenu before settingup viewmanager. 1495 //US initialize viewMenu before settingup viewmanager.
1496 // Viewmanager needs this menu to plugin submenues. 1496 // Viewmanager needs this menu to plugin submenues.
1497 viewMenu = new QPopupMenu( this ); 1497 viewMenu = new QPopupMenu( this );
1498 settingsMenu = new QPopupMenu( this ); 1498 settingsMenu = new QPopupMenu( this );
1499 //filterMenu = new QPopupMenu( this ); 1499 //filterMenu = new QPopupMenu( this );
1500 ImportMenu = new QPopupMenu( this ); 1500 ImportMenu = new QPopupMenu( this );
1501 ExportMenu = new QPopupMenu( this ); 1501 ExportMenu = new QPopupMenu( this );
1502 1502
1503 changeMenu= new QPopupMenu( this ); 1503 changeMenu= new QPopupMenu( this );
1504 1504
1505//US since we have no splitter for the embedded system, setup 1505//US since we have no splitter for the embedded system, setup
1506// a layout with two frames. One left and one right. 1506// a layout with two frames. One left and one right.
1507 1507
1508 QBoxLayout *topLayout; 1508 QBoxLayout *topLayout;
1509 1509
1510 // = new QHBoxLayout( this ); 1510 // = new QHBoxLayout( this );
1511// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1511// QBoxLayout *topLayout = (QBoxLayout*)layout();
1512 1512
1513// QWidget *mainBox = new QWidget( this ); 1513// QWidget *mainBox = new QWidget( this );
1514// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1514// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1515 1515
1516#ifdef DESKTOP_VERSION 1516#ifdef DESKTOP_VERSION
1517 topLayout = new QHBoxLayout( this ); 1517 topLayout = new QHBoxLayout( this );
1518 1518
1519 1519
1520 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1520 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1521 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1521 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1522 1522
1523 topLayout->addWidget(mMiniSplitter ); 1523 topLayout->addWidget(mMiniSplitter );
1524 1524
1525 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1525 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1526 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1526 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1527 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1527 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1528 mDetails = new ViewContainer( mMiniSplitter ); 1528 mDetails = new ViewContainer( mMiniSplitter );
1529 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1529 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1530#else 1530#else
1531 if ( QApplication::desktop()->width() > 480 ) { 1531 if ( QApplication::desktop()->width() > 480 ) {
1532 topLayout = new QHBoxLayout( this ); 1532 topLayout = new QHBoxLayout( this );
1533 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1533 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1534 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1534 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1535 } else { 1535 } else {
1536 1536
1537 topLayout = new QHBoxLayout( this ); 1537 topLayout = new QHBoxLayout( this );
1538 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1538 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1539 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1539 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1540 } 1540 }
1541 1541
1542 topLayout->addWidget(mMiniSplitter ); 1542 topLayout->addWidget(mMiniSplitter );
1543 mViewManager = new ViewManager( this, mMiniSplitter ); 1543 mViewManager = new ViewManager( this, mMiniSplitter );
1544 mDetails = new ViewContainer( mMiniSplitter ); 1544 mDetails = new ViewContainer( mMiniSplitter );
1545 1545
1546 1546
1547 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1547 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1548#endif 1548#endif
1549 //eh->hide(); 1549 //eh->hide();
1550 // topLayout->addWidget(mExtensionManager ); 1550 // topLayout->addWidget(mExtensionManager );
1551 1551
1552 1552
1553/*US 1553/*US
1554#ifndef KAB_NOSPLITTER 1554#ifndef KAB_NOSPLITTER
1555 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1555 QHBoxLayout *topLayout = new QHBoxLayout( this );
1556//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1556//US topLayout->setSpacing( KDialogBase::spacingHint() );
1557 topLayout->setSpacing( 10 ); 1557 topLayout->setSpacing( 10 );
1558 1558
1559 mDetailsSplitter = new QSplitter( this ); 1559 mDetailsSplitter = new QSplitter( this );
1560 1560
1561 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1561 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1562 1562
1563 mViewManager = new ViewManager( this, viewSpace ); 1563 mViewManager = new ViewManager( this, viewSpace );
1564 viewSpace->setStretchFactor( mViewManager, 1 ); 1564 viewSpace->setStretchFactor( mViewManager, 1 );
1565 1565
1566 mDetails = new ViewContainer( mDetailsSplitter ); 1566 mDetails = new ViewContainer( mDetailsSplitter );
1567 1567
1568 topLayout->addWidget( mDetailsSplitter ); 1568 topLayout->addWidget( mDetailsSplitter );
1569 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1569 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1570#else //KAB_NOSPLITTER 1570#else //KAB_NOSPLITTER
1571 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1571 QHBoxLayout *topLayout = new QHBoxLayout( this );
1572//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1572//US topLayout->setSpacing( KDialogBase::spacingHint() );
1573 topLayout->setSpacing( 10 ); 1573 topLayout->setSpacing( 10 );
1574 1574
1575// mDetailsSplitter = new QSplitter( this ); 1575// mDetailsSplitter = new QSplitter( this );
1576 1576
1577 QVBox *viewSpace = new QVBox( this ); 1577 QVBox *viewSpace = new QVBox( this );
1578 1578
1579 mViewManager = new ViewManager( this, viewSpace ); 1579 mViewManager = new ViewManager( this, viewSpace );
1580 viewSpace->setStretchFactor( mViewManager, 1 ); 1580 viewSpace->setStretchFactor( mViewManager, 1 );
1581 1581
1582 mDetails = new ViewContainer( this ); 1582 mDetails = new ViewContainer( this );
1583 1583
1584 topLayout->addWidget( viewSpace ); 1584 topLayout->addWidget( viewSpace );
1585// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1585// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1586 topLayout->addWidget( mDetails ); 1586 topLayout->addWidget( mDetails );
1587#endif //KAB_NOSPLITTER 1587#endif //KAB_NOSPLITTER
1588*/ 1588*/
1589 1589
1590 1590
1591#endif //KAB_EMBEDDED 1591#endif //KAB_EMBEDDED
1592 initActions(); 1592 initActions();
1593 1593
1594#ifdef KAB_EMBEDDED 1594#ifdef KAB_EMBEDDED
1595 addActionsManually(); 1595 addActionsManually();
1596 //US make sure the export and import menues are initialized before creating the xxPortManager. 1596 //US make sure the export and import menues are initialized before creating the xxPortManager.
1597 mXXPortManager = new XXPortManager( this, this ); 1597 mXXPortManager = new XXPortManager( this, this );
1598 1598
1599 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1599 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1600 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1600 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1601 // mActionQuit->plug ( mMainWindow->toolBar()); 1601 // mActionQuit->plug ( mMainWindow->toolBar());
1602 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1602 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1603 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1603 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1604 // mIncSearchWidget->hide(); 1604 // mIncSearchWidget->hide();
1605 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1605 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1606 SLOT( incrementalSearch( const QString& ) ) ); 1606 SLOT( incrementalSearch( const QString& ) ) );
1607 1607
1608 1608
1609 mJumpButtonBar = new JumpButtonBar( this, this ); 1609 mJumpButtonBar = new JumpButtonBar( this, this );
1610 1610
1611 topLayout->addWidget( mJumpButtonBar ); 1611 topLayout->addWidget( mJumpButtonBar );
1612//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1612//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1613 1613
1614// mMainWindow->getIconToolBar()->raise(); 1614// mMainWindow->getIconToolBar()->raise();
1615 1615
1616#endif //KAB_EMBEDDED 1616#endif //KAB_EMBEDDED
1617 1617
1618} 1618}
1619void KABCore::initActions() 1619void KABCore::initActions()
1620{ 1620{
1621//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1621//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1622 1622
1623#ifndef KAB_EMBEDDED 1623#ifndef KAB_EMBEDDED
1624 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1624 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1625 SLOT( clipboardDataChanged() ) ); 1625 SLOT( clipboardDataChanged() ) );
1626#endif //KAB_EMBEDDED 1626#endif //KAB_EMBEDDED
1627 1627
1628 // file menu 1628 // file menu
1629 if ( mIsPart ) { 1629 if ( mIsPart ) {
1630 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1630 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1631 SLOT( sendMail() ), actionCollection(), 1631 SLOT( sendMail() ), actionCollection(),
1632 "kaddressbook_mail" ); 1632 "kaddressbook_mail" );
1633 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1633 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1634 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1634 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1635 1635
1636 } else { 1636 } else {
1637 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1637 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1638 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1638 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1639 } 1639 }
1640 1640
1641 1641
1642 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1642 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1643 SLOT( save() ), actionCollection(), "file_sync" ); 1643 SLOT( save() ), actionCollection(), "file_sync" );
1644 1644
1645 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1645 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1646 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1646 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1647 1647
1648 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1648 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1649 this, SLOT( mailVCard() ), 1649 this, SLOT( mailVCard() ),
1650 actionCollection(), "file_mail_vcard"); 1650 actionCollection(), "file_mail_vcard");
1651 1651
1652 mActionBeamVCard = 0; 1652 mActionBeamVCard = 0;
1653 mActionBeam = 0; 1653 mActionBeam = 0;
1654 1654
1655#ifndef DESKTOP_VERSION 1655#ifndef DESKTOP_VERSION
1656 if ( Ir::supported() ) { 1656 if ( Ir::supported() ) {
1657 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1657 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1658 SLOT( beamVCard() ), actionCollection(), 1658 SLOT( beamVCard() ), actionCollection(),
1659 "kaddressbook_beam_vcard" ); 1659 "kaddressbook_beam_vcard" );
1660 1660
1661 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1661 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1662 SLOT( beamMySelf() ), actionCollection(), 1662 SLOT( beamMySelf() ), actionCollection(),
1663 "kaddressbook_beam_myself" ); 1663 "kaddressbook_beam_myself" );
1664 } 1664 }
1665#endif 1665#endif
1666 1666
1667 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1667 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1668 this, SLOT( editContact2() ), 1668 this, SLOT( editContact2() ),
1669 actionCollection(), "file_properties" ); 1669 actionCollection(), "file_properties" );
1670 1670
1671#ifdef KAB_EMBEDDED 1671#ifdef KAB_EMBEDDED
1672 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1672 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1673 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1673 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1674 mMainWindow, SLOT( exit() ), 1674 mMainWindow, SLOT( exit() ),
1675 actionCollection(), "quit" ); 1675 actionCollection(), "quit" );
1676#endif //KAB_EMBEDDED 1676#endif //KAB_EMBEDDED
1677 1677
1678 // edit menu 1678 // edit menu
1679 if ( mIsPart ) { 1679 if ( mIsPart ) {
1680 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1680 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1681 SLOT( copyContacts() ), actionCollection(), 1681 SLOT( copyContacts() ), actionCollection(),
1682 "kaddressbook_copy" ); 1682 "kaddressbook_copy" );
1683 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1683 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1684 SLOT( cutContacts() ), actionCollection(), 1684 SLOT( cutContacts() ), actionCollection(),
1685 "kaddressbook_cut" ); 1685 "kaddressbook_cut" );
1686 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1686 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1687 SLOT( pasteContacts() ), actionCollection(), 1687 SLOT( pasteContacts() ), actionCollection(),
1688 "kaddressbook_paste" ); 1688 "kaddressbook_paste" );
1689 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1689 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1690 SLOT( selectAllContacts() ), actionCollection(), 1690 SLOT( selectAllContacts() ), actionCollection(),
1691 "kaddressbook_select_all" ); 1691 "kaddressbook_select_all" );
1692 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1692 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1693 SLOT( undo() ), actionCollection(), 1693 SLOT( undo() ), actionCollection(),
1694 "kaddressbook_undo" ); 1694 "kaddressbook_undo" );
1695 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1695 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1696 this, SLOT( redo() ), actionCollection(), 1696 this, SLOT( redo() ), actionCollection(),
1697 "kaddressbook_redo" ); 1697 "kaddressbook_redo" );
1698 } else { 1698 } else {
1699 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1699 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1700 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1700 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1701 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1701 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1702 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1702 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1703 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1703 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1704 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1704 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1705 } 1705 }
1706 1706
1707 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1707 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1708 Key_Delete, this, SLOT( deleteContacts() ), 1708 Key_Delete, this, SLOT( deleteContacts() ),
1709 actionCollection(), "edit_delete" ); 1709 actionCollection(), "edit_delete" );
1710 1710
1711 mActionUndo->setEnabled( false ); 1711 mActionUndo->setEnabled( false );
1712 mActionRedo->setEnabled( false ); 1712 mActionRedo->setEnabled( false );
1713 1713
1714 // settings menu 1714 // settings menu
1715#ifdef KAB_EMBEDDED 1715#ifdef KAB_EMBEDDED
1716//US special menuentry to configure the addressbook resources. On KDE 1716//US special menuentry to configure the addressbook resources. On KDE
1717// you do that through the control center !!! 1717// you do that through the control center !!!
1718 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1718 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1719 SLOT( configureResources() ), actionCollection(), 1719 SLOT( configureResources() ), actionCollection(),
1720 "kaddressbook_configure_resources" ); 1720 "kaddressbook_configure_resources" );
1721#endif //KAB_EMBEDDED 1721#endif //KAB_EMBEDDED
1722 1722
1723 if ( mIsPart ) { 1723 if ( mIsPart ) {
1724 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1724 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1725 SLOT( openConfigDialog() ), actionCollection(), 1725 SLOT( openConfigDialog() ), actionCollection(),
1726 "kaddressbook_configure" ); 1726 "kaddressbook_configure" );
1727 1727
1728 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1728 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1729 this, SLOT( configureKeyBindings() ), actionCollection(), 1729 this, SLOT( configureKeyBindings() ), actionCollection(),
1730 "kaddressbook_configure_shortcuts" ); 1730 "kaddressbook_configure_shortcuts" );
1731#ifdef KAB_EMBEDDED 1731#ifdef KAB_EMBEDDED
1732 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1732 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1733 mActionConfigureToolbars->setEnabled( false ); 1733 mActionConfigureToolbars->setEnabled( false );
1734#endif //KAB_EMBEDDED 1734#endif //KAB_EMBEDDED
1735 1735
1736 } else { 1736 } else {
1737 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1737 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1738 1738
1739 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1739 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1740 } 1740 }
1741 1741
1742 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1742 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1743 actionCollection(), "options_show_jump_bar" ); 1743 actionCollection(), "options_show_jump_bar" );
1744 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1744 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1745 1745
1746 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1746 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1747 actionCollection(), "options_show_details" ); 1747 actionCollection(), "options_show_details" );
1748 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1748 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1749 1749
1750 // misc 1750 // misc
1751 // only enable LDAP lookup if we can handle the protocol 1751 // only enable LDAP lookup if we can handle the protocol
1752#ifndef KAB_EMBEDDED 1752#ifndef KAB_EMBEDDED
1753 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1753 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1754 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1754 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1755 this, SLOT( openLDAPDialog() ), actionCollection(), 1755 this, SLOT( openLDAPDialog() ), actionCollection(),
1756 "ldap_lookup" ); 1756 "ldap_lookup" );
1757 } 1757 }
1758#else //KAB_EMBEDDED 1758#else //KAB_EMBEDDED
1759 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1759 //qDebug("KABCore::initActions() LDAP has to be implemented");
1760#endif //KAB_EMBEDDED 1760#endif //KAB_EMBEDDED
1761 1761
1762 1762
1763 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1763 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1764 SLOT( setWhoAmI() ), actionCollection(), 1764 SLOT( setWhoAmI() ), actionCollection(),
1765 "set_personal" ); 1765 "set_personal" );
1766 1766
1767 1767
1768 1768
1769 1769
1770 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1770 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1771 SLOT( setCategories() ), actionCollection(), 1771 SLOT( setCategories() ), actionCollection(),
1772 "edit_set_categories" ); 1772 "edit_set_categories" );
1773 1773
1774 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1774 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1775 SLOT( removeVoice() ), actionCollection(), 1775 SLOT( removeVoice() ), actionCollection(),
1776 "remove_voice" ); 1776 "remove_voice" );
1777 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1777 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1778 SLOT( importFromOL() ), actionCollection(), 1778 SLOT( importFromOL() ), actionCollection(),
1779 "import_OL" ); 1779 "import_OL" );
1780#ifdef KAB_EMBEDDED 1780#ifdef KAB_EMBEDDED
1781 mActionLicence = new KAction( i18n( "Licence" ), 0, 1781 mActionLicence = new KAction( i18n( "Licence" ), 0,
1782 this, SLOT( showLicence() ), actionCollection(), 1782 this, SLOT( showLicence() ), actionCollection(),
1783 "licence_about_data" ); 1783 "licence_about_data" );
1784 mActionFaq = new KAction( i18n( "Faq" ), 0, 1784 mActionFaq = new KAction( i18n( "Faq" ), 0,
1785 this, SLOT( faq() ), actionCollection(), 1785 this, SLOT( faq() ), actionCollection(),
1786 "faq_about_data" ); 1786 "faq_about_data" );
1787 1787
1788 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1788 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1789 this, SLOT( createAboutData() ), actionCollection(), 1789 this, SLOT( createAboutData() ), actionCollection(),
1790 "kaddressbook_about_data" ); 1790 "kaddressbook_about_data" );
1791#endif //KAB_EMBEDDED 1791#endif //KAB_EMBEDDED
1792 1792
1793 clipboardDataChanged(); 1793 clipboardDataChanged();
1794 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1794 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1795 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1795 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1796} 1796}
1797 1797
1798//US we need this function, to plug all actions into the correct menues. 1798//US we need this function, to plug all actions into the correct menues.
1799// KDE uses a XML format to plug the actions, but we work her without this overhead. 1799// KDE uses a XML format to plug the actions, but we work her without this overhead.
1800void KABCore::addActionsManually() 1800void KABCore::addActionsManually()
1801{ 1801{
1802//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1802//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1803 1803
1804#ifdef KAB_EMBEDDED 1804#ifdef KAB_EMBEDDED
1805 QPopupMenu *fileMenu = new QPopupMenu( this ); 1805 QPopupMenu *fileMenu = new QPopupMenu( this );
1806 QPopupMenu *editMenu = new QPopupMenu( this ); 1806 QPopupMenu *editMenu = new QPopupMenu( this );
1807 QPopupMenu *helpMenu = new QPopupMenu( this ); 1807 QPopupMenu *helpMenu = new QPopupMenu( this );
1808 1808
1809 KToolBar* tb = mMainWindow->toolBar(); 1809 KToolBar* tb = mMainWindow->toolBar();
1810 1810
1811#ifdef DESKTOP_VERSION 1811#ifdef DESKTOP_VERSION
1812 QMenuBar* mb = mMainWindow->menuBar(); 1812 QMenuBar* mb = mMainWindow->menuBar();
1813 1813
1814 //US setup menubar. 1814 //US setup menubar.
1815 //Disable the following block if you do not want to have a menubar. 1815 //Disable the following block if you do not want to have a menubar.
1816 mb->insertItem( "&File", fileMenu ); 1816 mb->insertItem( "&File", fileMenu );
1817 mb->insertItem( "&Edit", editMenu ); 1817 mb->insertItem( "&Edit", editMenu );
1818 mb->insertItem( "&View", viewMenu ); 1818 mb->insertItem( "&View", viewMenu );
1819 mb->insertItem( "&Settings", settingsMenu ); 1819 mb->insertItem( "&Settings", settingsMenu );
1820 mb->insertItem( "&Change selected", changeMenu ); 1820 mb->insertItem( "&Change selected", changeMenu );
1821 mb->insertItem( "&Help", helpMenu ); 1821 mb->insertItem( "&Help", helpMenu );
1822 mIncSearchWidget = new IncSearchWidget( tb ); 1822 mIncSearchWidget = new IncSearchWidget( tb );
1823 // tb->insertWidget(-1, 0, mIncSearchWidget); 1823 // tb->insertWidget(-1, 0, mIncSearchWidget);
1824 1824
1825#else 1825#else
1826 //US setup toolbar 1826 //US setup toolbar
1827 QMenuBar *menuBarTB = new QMenuBar( tb ); 1827 QMenuBar *menuBarTB = new QMenuBar( tb );
1828 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1828 QPopupMenu *popupBarTB = new QPopupMenu( this );
1829 menuBarTB->insertItem( "ME", popupBarTB); 1829 menuBarTB->insertItem( "ME", popupBarTB);
1830 tb->insertWidget(-1, 0, menuBarTB); 1830 tb->insertWidget(-1, 0, menuBarTB);
1831 mIncSearchWidget = new IncSearchWidget( tb ); 1831 mIncSearchWidget = new IncSearchWidget( tb );
1832 1832
1833 tb->enableMoving(false); 1833 tb->enableMoving(false);
1834 popupBarTB->insertItem( "&File", fileMenu ); 1834 popupBarTB->insertItem( "&File", fileMenu );
1835 popupBarTB->insertItem( "&Edit", editMenu ); 1835 popupBarTB->insertItem( "&Edit", editMenu );
1836 popupBarTB->insertItem( "&View", viewMenu ); 1836 popupBarTB->insertItem( "&View", viewMenu );
1837 popupBarTB->insertItem( "&Settings", settingsMenu ); 1837 popupBarTB->insertItem( "&Settings", settingsMenu );
1838 mViewManager->getFilterAction()->plug ( popupBarTB); 1838 mViewManager->getFilterAction()->plug ( popupBarTB);
1839 popupBarTB->insertItem( "&Change selected", changeMenu ); 1839 popupBarTB->insertItem( "&Change selected", changeMenu );
1840 popupBarTB->insertItem( "&Help", helpMenu ); 1840 popupBarTB->insertItem( "&Help", helpMenu );
1841 if (QApplication::desktop()->width() > 320 ) { 1841 if (QApplication::desktop()->width() > 320 ) {
1842 // mViewManager->getFilterAction()->plug ( tb); 1842 // mViewManager->getFilterAction()->plug ( tb);
1843 } 1843 }
1844#endif 1844#endif
1845 // mActionQuit->plug ( mMainWindow->toolBar()); 1845 // mActionQuit->plug ( mMainWindow->toolBar());
1846 1846
1847 1847
1848 1848
1849 //US Now connect the actions with the menue entries. 1849 //US Now connect the actions with the menue entries.
1850 mActionPrint->plug( fileMenu ); 1850 mActionPrint->plug( fileMenu );
1851 mActionMail->plug( fileMenu ); 1851 mActionMail->plug( fileMenu );
1852 fileMenu->insertSeparator(); 1852 fileMenu->insertSeparator();
1853 1853
1854 mActionNewContact->plug( fileMenu ); 1854 mActionNewContact->plug( fileMenu );
1855 mActionNewContact->plug( tb ); 1855 mActionNewContact->plug( tb );
1856 1856
1857 mActionEditAddressee->plug( fileMenu ); 1857 mActionEditAddressee->plug( fileMenu );
1858 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1858 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1859 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1859 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1860 mActionEditAddressee->plug( tb ); 1860 mActionEditAddressee->plug( tb );
1861 1861
1862 fileMenu->insertSeparator(); 1862 fileMenu->insertSeparator();
1863 mActionSave->plug( fileMenu ); 1863 mActionSave->plug( fileMenu );
1864 fileMenu->insertItem( "&Import", ImportMenu ); 1864 fileMenu->insertItem( "&Import", ImportMenu );
1865 fileMenu->insertItem( "&Emport", ExportMenu ); 1865 fileMenu->insertItem( "&Emport", ExportMenu );
1866 fileMenu->insertSeparator(); 1866 fileMenu->insertSeparator();
1867 mActionMailVCard->plug( fileMenu ); 1867 mActionMailVCard->plug( fileMenu );
1868#ifndef DESKTOP_VERSION 1868#ifndef DESKTOP_VERSION
1869 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1869 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1870 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1870 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1871#endif 1871#endif
1872 fileMenu->insertSeparator(); 1872 fileMenu->insertSeparator();
1873 mActionQuit->plug( fileMenu ); 1873 mActionQuit->plug( fileMenu );
1874#ifdef _WIN32_ 1874#ifdef _WIN32_
1875 mActionImportOL->plug( ImportMenu ); 1875 mActionImportOL->plug( ImportMenu );
1876#endif 1876#endif
1877 // edit menu 1877 // edit menu
1878 mActionUndo->plug( editMenu ); 1878 mActionUndo->plug( editMenu );
1879 mActionRedo->plug( editMenu ); 1879 mActionRedo->plug( editMenu );
1880 editMenu->insertSeparator(); 1880 editMenu->insertSeparator();
1881 mActionCut->plug( editMenu ); 1881 mActionCut->plug( editMenu );
1882 mActionCopy->plug( editMenu ); 1882 mActionCopy->plug( editMenu );
1883 mActionPaste->plug( editMenu ); 1883 mActionPaste->plug( editMenu );
1884 mActionDelete->plug( editMenu ); 1884 mActionDelete->plug( editMenu );
1885 editMenu->insertSeparator(); 1885 editMenu->insertSeparator();
1886 mActionSelectAll->plug( editMenu ); 1886 mActionSelectAll->plug( editMenu );
1887 1887
1888 mActionRemoveVoice->plug( changeMenu ); 1888 mActionRemoveVoice->plug( changeMenu );
1889 // settings menu 1889 // settings menu
1890//US special menuentry to configure the addressbook resources. On KDE 1890//US special menuentry to configure the addressbook resources. On KDE
1891// you do that through the control center !!! 1891// you do that through the control center !!!
1892 mActionConfigResources->plug( settingsMenu ); 1892 mActionConfigResources->plug( settingsMenu );
1893 settingsMenu->insertSeparator(); 1893 settingsMenu->insertSeparator();
1894 1894
1895 mActionConfigKAddressbook->plug( settingsMenu ); 1895 mActionConfigKAddressbook->plug( settingsMenu );
1896 1896
1897 if ( mIsPart ) { 1897 if ( mIsPart ) {
1898 mActionConfigShortcuts->plug( settingsMenu ); 1898 mActionConfigShortcuts->plug( settingsMenu );
1899 mActionConfigureToolbars->plug( settingsMenu ); 1899 mActionConfigureToolbars->plug( settingsMenu );
1900 1900
1901 } else { 1901 } else {
1902 mActionKeyBindings->plug( settingsMenu ); 1902 mActionKeyBindings->plug( settingsMenu );
1903 } 1903 }
1904 1904
1905 settingsMenu->insertSeparator(); 1905 settingsMenu->insertSeparator();
1906 1906
1907 mActionJumpBar->plug( settingsMenu ); 1907 mActionJumpBar->plug( settingsMenu );
1908 mActionDetails->plug( settingsMenu ); 1908 mActionDetails->plug( settingsMenu );
1909 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1909 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1910 mActionDetails->plug( tb ); 1910 mActionDetails->plug( tb );
1911 settingsMenu->insertSeparator(); 1911 settingsMenu->insertSeparator();
1912 1912
1913 mActionWhoAmI->plug( settingsMenu ); 1913 mActionWhoAmI->plug( settingsMenu );
1914 mActionCategories->plug( settingsMenu ); 1914 mActionCategories->plug( settingsMenu );
1915 1915
1916 mActionLicence->plug( helpMenu ); 1916 mActionLicence->plug( helpMenu );
1917 mActionFaq->plug( helpMenu ); 1917 mActionFaq->plug( helpMenu );
1918 mActionAboutKAddressbook->plug( helpMenu ); 1918 mActionAboutKAddressbook->plug( helpMenu );
1919 1919
1920 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1920 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1921 1921
1922 mActionSave->plug( tb ); 1922 mActionSave->plug( tb );
1923 mViewManager->getFilterAction()->plug ( tb); 1923 mViewManager->getFilterAction()->plug ( tb);
1924 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1924 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1925 mActionUndo->plug( tb ); 1925 mActionUndo->plug( tb );
1926 mActionDelete->plug( tb ); 1926 mActionDelete->plug( tb );
1927 mActionRedo->plug( tb ); 1927 mActionRedo->plug( tb );
1928 } 1928 }
1929 } 1929 }
1930 //mActionQuit->plug ( tb ); 1930 //mActionQuit->plug ( tb );
1931 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1931 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1932 1932
1933 //US link the searchwidget first to this. 1933 //US link the searchwidget first to this.
1934 // The real linkage to the toolbar happens later. 1934 // The real linkage to the toolbar happens later.
1935//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1935//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1936//US tb->insertItem( mIncSearchWidget ); 1936//US tb->insertItem( mIncSearchWidget );
1937/*US 1937/*US
1938 mIncSearchWidget = new IncSearchWidget( tb ); 1938 mIncSearchWidget = new IncSearchWidget( tb );
1939 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1939 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1940 SLOT( incrementalSearch( const QString& ) ) ); 1940 SLOT( incrementalSearch( const QString& ) ) );
1941 1941
1942 mJumpButtonBar = new JumpButtonBar( this, this ); 1942 mJumpButtonBar = new JumpButtonBar( this, this );
1943 1943
1944//US topLayout->addWidget( mJumpButtonBar ); 1944//US topLayout->addWidget( mJumpButtonBar );
1945 this->layout()->add( mJumpButtonBar ); 1945 this->layout()->add( mJumpButtonBar );
1946*/ 1946*/
1947 1947
1948#endif //KAB_EMBEDDED 1948#endif //KAB_EMBEDDED
1949} 1949}
1950void KABCore::showLicence() 1950void KABCore::showLicence()
1951{ 1951{
1952 KApplication::showLicence(); 1952 KApplication::showLicence();
1953} 1953}
1954void KABCore::removeVoice() 1954void KABCore::removeVoice()
1955{ 1955{
1956 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 ) 1956 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 )
1957 return; 1957 return;
1958 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1958 KABC::Addressee::List list = mViewManager->selectedAddressees();
1959 KABC::Addressee::List::Iterator it; 1959 KABC::Addressee::List::Iterator it;
1960 for ( it = list.begin(); it != list.end(); ++it ) { 1960 for ( it = list.begin(); it != list.end(); ++it ) {
1961 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1961 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1962 PhoneNumber::List::Iterator phoneIt; 1962 PhoneNumber::List::Iterator phoneIt;
1963 bool found = false; 1963 bool found = false;
1964 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1964 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1965 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1965 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1966 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1966 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1967 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1967 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1968 (*it).insertPhoneNumber( (*phoneIt) ); 1968 (*it).insertPhoneNumber( (*phoneIt) );
1969 found = true; 1969 found = true;
1970 } 1970 }
1971 } 1971 }
1972 1972
1973 } 1973 }
1974 if ( found ) 1974 if ( found )
1975 contactModified((*it) ); 1975 contactModified((*it) );
1976 } 1976 }
1977} 1977}
1978 1978
1979 1979
1980 1980
1981void KABCore::clipboardDataChanged() 1981void KABCore::clipboardDataChanged()
1982{ 1982{
1983 1983
1984 if ( mReadWrite ) 1984 if ( mReadWrite )
1985 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1985 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1986 1986
1987} 1987}
1988 1988
1989void KABCore::updateActionMenu() 1989void KABCore::updateActionMenu()
1990{ 1990{
1991 UndoStack *undo = UndoStack::instance(); 1991 UndoStack *undo = UndoStack::instance();
1992 RedoStack *redo = RedoStack::instance(); 1992 RedoStack *redo = RedoStack::instance();
1993 1993
1994 if ( undo->isEmpty() ) 1994 if ( undo->isEmpty() )
1995 mActionUndo->setText( i18n( "Undo" ) ); 1995 mActionUndo->setText( i18n( "Undo" ) );
1996 else 1996 else
1997 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1997 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1998 1998
1999 mActionUndo->setEnabled( !undo->isEmpty() ); 1999 mActionUndo->setEnabled( !undo->isEmpty() );
2000 2000
2001 if ( !redo->top() ) 2001 if ( !redo->top() )
2002 mActionRedo->setText( i18n( "Redo" ) ); 2002 mActionRedo->setText( i18n( "Redo" ) );
2003 else 2003 else
2004 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2004 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2005 2005
2006 mActionRedo->setEnabled( !redo->isEmpty() ); 2006 mActionRedo->setEnabled( !redo->isEmpty() );
2007} 2007}
2008 2008
2009void KABCore::configureKeyBindings() 2009void KABCore::configureKeyBindings()
2010{ 2010{
2011#ifndef KAB_EMBEDDED 2011#ifndef KAB_EMBEDDED
2012 KKeyDialog::configure( actionCollection(), true ); 2012 KKeyDialog::configure( actionCollection(), true );
2013#else //KAB_EMBEDDED 2013#else //KAB_EMBEDDED
2014 qDebug("KABCore::configureKeyBindings() not implemented"); 2014 qDebug("KABCore::configureKeyBindings() not implemented");
2015#endif //KAB_EMBEDDED 2015#endif //KAB_EMBEDDED
2016} 2016}
2017 2017
2018#ifdef KAB_EMBEDDED 2018#ifdef KAB_EMBEDDED
2019void KABCore::configureResources() 2019void KABCore::configureResources()
2020{ 2020{
2021 KRES::KCMKResources dlg( this, "" , 0 ); 2021 KRES::KCMKResources dlg( this, "" , 0 );
2022 2022
2023 if ( !dlg.exec() ) 2023 if ( !dlg.exec() )
2024 return; 2024 return;
2025 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2025 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2026} 2026}
2027#endif //KAB_EMBEDDED 2027#endif //KAB_EMBEDDED
2028 2028
2029 2029
2030/* this method will be called through the QCop interface from Ko/Pi to select addresses 2030/* this method will be called through the QCop interface from Ko/Pi to select addresses
2031 * for the attendees list of an event. 2031 * for the attendees list of an event.
2032 */ 2032 */
2033void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2033void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2034{ 2034{
2035 QStringList nameList; 2035 QStringList nameList;
2036 QStringList emailList; 2036 QStringList emailList;
2037 QStringList uidList; 2037 QStringList uidList;
2038 2038
2039 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2039 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2040 uint i=0; 2040 uint i=0;
2041 for (i=0; i < list.count(); i++) 2041 for (i=0; i < list.count(); i++)
2042 { 2042 {
2043 nameList.append(list[i].realName()); 2043 nameList.append(list[i].realName());
2044 emailList.append(list[i].preferredEmail()); 2044 emailList.append(list[i].preferredEmail());
2045 uidList.append(list[i].uid()); 2045 uidList.append(list[i].uid());
2046 } 2046 }
2047 2047
2048 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2048 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2049 2049
2050} 2050}
2051 2051
2052/* this method will be called through the QCop interface from other apps to show details of a contact. 2052/* this method will be called through the QCop interface from other apps to show details of a contact.
2053 */ 2053 */
2054void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2054void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2055{ 2055{
2056 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2056 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2057 2057
2058 QString foundUid = QString::null; 2058 QString foundUid = QString::null;
2059 if ( ! uid.isEmpty() ) { 2059 if ( ! uid.isEmpty() ) {
2060 Addressee adrr = mAddressBook->findByUid( uid ); 2060 Addressee adrr = mAddressBook->findByUid( uid );
2061 if ( !adrr.isEmpty() ) { 2061 if ( !adrr.isEmpty() ) {
2062 foundUid = uid; 2062 foundUid = uid;
2063 } 2063 }
2064 if ( email == "sendbacklist" ) { 2064 if ( email == "sendbacklist" ) {
2065 qDebug("ssssssssssssssssssssssend "); 2065 //qDebug("ssssssssssssssssssssssend ");
2066 QStringList nameList; 2066 QStringList nameList;
2067 QStringList emailList; 2067 QStringList emailList;
2068 QStringList uidList; 2068 QStringList uidList;
2069 nameList.append(adrr.realName()); 2069 nameList.append(adrr.realName());
2070 emailList = adrr.emails(); 2070 emailList = adrr.emails();
2071 uidList.append( adrr.preferredEmail()); 2071 uidList.append( adrr.preferredEmail());
2072 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2072 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2073 return; 2073 return;
2074 } 2074 }
2075 2075
2076 } 2076 }
2077 2077
2078 if ( email == "sendback" ) 2078 if ( email == "sendbacklist" )
2079 return; 2079 return;
2080 if (foundUid.isEmpty()) 2080 if (foundUid.isEmpty())
2081 { 2081 {
2082 //find the uid of the person first 2082 //find the uid of the person first
2083 Addressee::List namelist; 2083 Addressee::List namelist;
2084 Addressee::List emaillist; 2084 Addressee::List emaillist;
2085 2085
2086 if (!name.isEmpty()) 2086 if (!name.isEmpty())
2087 namelist = mAddressBook->findByName( name ); 2087 namelist = mAddressBook->findByName( name );
2088 2088
2089 if (!email.isEmpty()) 2089 if (!email.isEmpty())
2090 emaillist = mAddressBook->findByEmail( email ); 2090 emaillist = mAddressBook->findByEmail( email );
2091 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2091 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2092 //check if we have a match in Namelist and Emaillist 2092 //check if we have a match in Namelist and Emaillist
2093 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2093 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2094 foundUid = emaillist[0].uid(); 2094 foundUid = emaillist[0].uid();
2095 } 2095 }
2096 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2096 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2097 foundUid = namelist[0].uid(); 2097 foundUid = namelist[0].uid();
2098 else 2098 else
2099 { 2099 {
2100 for (int i = 0; i < namelist.count(); i++) 2100 for (int i = 0; i < namelist.count(); i++)
2101 { 2101 {
2102 for (int j = 0; j < emaillist.count(); j++) 2102 for (int j = 0; j < emaillist.count(); j++)
2103 { 2103 {
2104 if (namelist[i] == emaillist[j]) 2104 if (namelist[i] == emaillist[j])
2105 { 2105 {
2106 foundUid = namelist[i].uid(); 2106 foundUid = namelist[i].uid();
2107 } 2107 }
2108 } 2108 }
2109 } 2109 }
2110 } 2110 }
2111 } 2111 }
2112 else 2112 else
2113 { 2113 {
2114 foundUid = uid; 2114 foundUid = uid;
2115 } 2115 }
2116 2116
2117 if (!foundUid.isEmpty()) 2117 if (!foundUid.isEmpty())
2118 { 2118 {
2119 2119
2120 // raise Ka/Pi if it is in the background 2120 // raise Ka/Pi if it is in the background
2121#ifndef DESKTOP_VERSION 2121#ifndef DESKTOP_VERSION
2122#ifndef KORG_NODCOP 2122#ifndef KORG_NODCOP
2123 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2123 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2124#endif 2124#endif
2125#endif 2125#endif
2126 2126
2127 mMainWindow->showMaximized(); 2127 mMainWindow->showMaximized();
2128 mMainWindow-> raise(); 2128 mMainWindow-> raise();
2129 2129
2130 mViewManager->setSelected( "", false); 2130 mViewManager->setSelected( "", false);
2131 mViewManager->refreshView( "" ); 2131 mViewManager->refreshView( "" );
2132 mViewManager->setSelected( foundUid, true ); 2132 mViewManager->setSelected( foundUid, true );
2133 mViewManager->refreshView( foundUid ); 2133 mViewManager->refreshView( foundUid );
2134 2134
2135 if ( !mMultipleViewsAtOnce ) 2135 if ( !mMultipleViewsAtOnce )
2136 { 2136 {
2137 setDetailsVisible( true ); 2137 setDetailsVisible( true );
2138 mActionDetails->setChecked(true); 2138 mActionDetails->setChecked(true);
2139 } 2139 }
2140 } 2140 }
2141} 2141}
2142 2142
2143 2143
2144void KABCore::faq() 2144void KABCore::faq()
2145{ 2145{
2146 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2146 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2147} 2147}
2148 2148
2149 2149
2150 2150
2151 2151
2152#ifndef KAB_EMBEDDED 2152#ifndef KAB_EMBEDDED
2153#include "kabcore.moc" 2153#include "kabcore.moc"
2154#endif //KAB_EMBEDDED 2154#endif //KAB_EMBEDDED
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 01dd406..9efa932 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,459 +1,460 @@
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#ifdef DESKTOP_VERSION 32#ifdef DESKTOP_VERSION
33#include <kabc/addresseedialog.h> 33#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION 34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h> 35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION 36#endif //DESKTOP_VERSION
37 37
38 38
39//using namespace Opie::Core; 39//using namespace Opie::Core;
40//using namespace Opie::Ui; 40//using namespace Opie::Ui;
41ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 41ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal )
42 : ComposeMailUI( parent, name, modal ) 42 : ComposeMailUI( parent, name, modal )
43{ 43{
44 44
45 mPickLineEdit = 0; 45 mPickLineEdit = 0;
46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 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&))); 47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
48 settings = s; 48 settings = s;
49 m_replyid = ""; 49 m_replyid = "";
50 KConfig config( locateLocal("config", "kabcrc") ); 50 KConfig config( locateLocal("config", "kabcrc") );
51 config.setGroup( "General" ); 51 config.setGroup( "General" );
52 QString whoami_uid = config.readEntry( "WhoAmI" ); 52 QString whoami_uid = config.readEntry( "WhoAmI" );
53
53 if ( whoami_uid.isEmpty() ) { 54 if ( whoami_uid.isEmpty() ) {
54 QMessageBox::information( 0, tr( "Hint" ), 55 QMessageBox::information( 0, tr( "Hint" ),
55 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 56 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
56 tr( "Ok" ) ); 57 tr( "Ok" ) );
57 58
58 } else 59 } else
59 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 60 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
61
62
60#ifdef DESKTOP_VERSION 63#ifdef DESKTOP_VERSION
61 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 64 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
62 QStringList mails = con.emails(); 65 QStringList mails = con.emails();
63 QString defmail = con.preferredEmail(); 66 QString defmail = con.preferredEmail();
64 if ( mails.count() == 0) 67 if ( mails.count() == 0)
65 QMessageBox::information( 0, tr( "Hint" ), 68 QMessageBox::information( 0, tr( "Hint" ),
66 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 69 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
67 tr( "Ok" ) ); 70 tr( "Ok" ) );
68 if (defmail.length()!=0) { 71 if (defmail.length()!=0) {
69 fromBox->insertItem(defmail); 72 fromBox->insertItem(defmail);
70 } 73 }
71 QStringList::ConstIterator sit = mails.begin(); 74 QStringList::ConstIterator sit = mails.begin();
72 for (;sit!=mails.end();++sit) { 75 for (;sit!=mails.end();++sit) {
73 if ( (*sit)==defmail) 76 if ( (*sit)==defmail)
74 continue; 77 continue;
75 fromBox->insertItem((*sit)); 78 fromBox->insertItem((*sit));
76 } 79 }
77 senderNameEdit->setText(con.formattedName()); 80 senderNameEdit->setText(con.formattedName());
78#endif 81#endif
79 Config cfg( "mail" ); 82 Config cfg( "mail" );
80 cfg.setGroup( "Compose" ); 83 cfg.setGroup( "Compose" );
81 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 84 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
82 85
83 attList->addColumn( tr( "Name" ) ); 86 attList->addColumn( tr( "Name" ) );
84 attList->addColumn( tr( "Size" ) ); 87 attList->addColumn( tr( "Size" ) );
85
86 QList<Account> accounts = settings->getAccounts(); 88 QList<Account> accounts = settings->getAccounts();
87 89
88 Account *it; 90 Account *it;
89 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
90 if ( it->getType()==MAILLIB::A_SMTP ) { 92 if ( it->getType()==MAILLIB::A_SMTP ) {
91 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 93 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
92 smtpAccountBox->insertItem( smtp->getAccountName() ); 94 smtpAccountBox->insertItem( smtp->getAccountName() );
93 smtpAccounts.append( smtp ); 95 smtpAccounts.append( smtp );
94 } 96 }
95 } 97 }
96 if ( smtpAccounts.count() > 0 ) { 98 if ( smtpAccounts.count() > 0 ) {
97 fillValues( smtpAccountBox->currentItem() ); 99 fillValues( smtpAccountBox->currentItem() );
98 } else { 100 } else {
99 QMessageBox::information( 0, tr( "Problem" ), 101 QMessageBox::information( 0, tr( "Problem" ),
100 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), 102 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
101 tr( "Ok" ) ); 103 tr( "Ok" ) );
102 return; 104 return;
103 } 105 }
104 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 106 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 107 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 108 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 109 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 110 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 111 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 112 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 113 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
112 mMail = 0; 114 mMail = 0;
113 warnAttach = true; 115 warnAttach = true;
114 116
115} 117}
116 118
117 119
118 120
119void ComposeMail::saveAsDraft() 121void ComposeMail::saveAsDraft()
120{ 122{
121 123
122 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 124 Opie::Core::OSmartPointer<Mail> mail= new Mail();
123 mail->setMail(fromBox->currentText()); 125 mail->setMail(fromBox->currentText());
124 mail->setTo( toLine->text() ); 126 mail->setTo( toLine->text() );
125 mail->setName(senderNameEdit->text()); 127 mail->setName(senderNameEdit->text());
126 mail->setCC( ccLine->text() ); 128 mail->setCC( ccLine->text() );
127 mail->setBCC( bccLine->text() ); 129 mail->setBCC( bccLine->text() );
128 mail->setReply( replyLine->text() ); 130 mail->setReply( replyLine->text() );
129 mail->setSubject( subjectLine->text() ); 131 mail->setSubject( subjectLine->text() );
130 if (!m_replyid.isEmpty()) { 132 if (!m_replyid.isEmpty()) {
131 QStringList ids; 133 QStringList ids;
132 ids.append(m_replyid); 134 ids.append(m_replyid);
133 mail->setInreply(ids); 135 mail->setInreply(ids);
134 } 136 }
135 QString txt = message->text(); 137 QString txt = message->text();
136 if ( !sigMultiLine->text().isEmpty() ) { 138 if ( !sigMultiLine->text().isEmpty() ) {
137 txt.append( "\n--\n" ); 139 txt.append( "\n--\n" );
138 txt.append( sigMultiLine->text() ); 140 txt.append( sigMultiLine->text() );
139 } 141 }
140 mail->setMessage( txt ); 142 mail->setMessage( txt );
141 143
142 /* only use the default drafts folder name! */ 144 /* only use the default drafts folder name! */
143 Storemail wrapper(AbstractMail::draftFolder()); 145 Storemail wrapper(AbstractMail::draftFolder());
144 wrapper.storeMail(mail); 146 wrapper.storeMail(mail);
145 147
146 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 148 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
147 /* attachments we will ignore! */ 149 /* attachments we will ignore! */
148 if ( it != 0 ) { 150 if ( it != 0 ) {
149 if ( warnAttach ) 151 if ( warnAttach )
150 QMessageBox::warning(0,tr("Store message"), 152 QMessageBox::warning(0,tr("Store message"),
151 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 153 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
152 warnAttach = false; 154 warnAttach = false;
153 } 155 }
154 setStatus( tr("Mail saved as draft!") ); 156 setStatus( tr("Mail saved as draft!") );
155} 157}
156void ComposeMail::clearStatus() 158void ComposeMail::clearStatus()
157{ 159{
158 topLevelWidget()->setCaption( tr("Compose mail") ); 160 topLevelWidget()->setCaption( tr("Compose mail") );
159} 161}
160void ComposeMail::setStatus( QString status ) 162void ComposeMail::setStatus( QString status )
161{ 163{
162 topLevelWidget()->setCaption( status ); 164 topLevelWidget()->setCaption( status );
163 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 165 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
164} 166}
165void ComposeMail::pickAddress( ) 167void ComposeMail::pickAddress( )
166{ 168{
167 169
168 QLineEdit *line = mPickLineEdit; 170 QLineEdit *line = mPickLineEdit;
169 if ( line == 0 ) 171 if ( line == 0 )
170 return; 172 return;
171#ifdef DESKTOP_VERSION 173#ifdef DESKTOP_VERSION
172 //qDebug(" ComposeMail::pickAddress "); 174 //qDebug(" ComposeMail::pickAddress ");
173 QString names ;//= AddressPicker::getNames(); 175 QString names ;//= AddressPicker::getNames();
174 176
175 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 177 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
176 uint i=0; 178 uint i=0;
177 for (i=0; i < list.count(); i++) { 179 for (i=0; i < list.count(); i++) {
178 if ( !list[i].preferredEmail().isEmpty()) { 180 if ( !list[i].preferredEmail().isEmpty()) {
179 if ( ! names.isEmpty() ) 181 if ( ! names.isEmpty() )
180 names+= ","; 182 names+= ",";
181 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 183 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
182 184
183 } 185 }
184 } 186 }
185 187
186 188
187 if ( line->text().isEmpty() ) { 189 if ( line->text().isEmpty() ) {
188 line->setText( names ); 190 line->setText( names );
189 } else if ( !names.isEmpty() ) { 191 } else if ( !names.isEmpty() ) {
190 line->setText( line->text() + ", " + names ); 192 line->setText( line->text() + ", " + names );
191 } 193 }
192#else 194#else
193 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); 195 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/);
194 // the result should now arrive through method insertAttendees 196 // the result should now arrive through method insertAttendees
195#endif 197#endif
196} 198}
197//the map includes name/email pairs, that comes from Ka/Pi 199//the map includes name/email pairs, that comes from Ka/Pi
198void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 200void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
199{ 201{
200 qDebug("ComposeMail::insertAttendees "); 202 //qDebug("ComposeMail::insertAttendees ");
201 raise(); 203 raise();
202 204
203 if ( mPickLineEdit == 0 ) { //whoami received 205 if ( mPickLineEdit == 0 ) { //whoami received
204 qDebug("returnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn ");
205 QString defmail = uidList[0]; 206 QString defmail = uidList[0];
206 if ( emailList.count() == 0 ) 207 if ( emailList.count() == 0 )
207 QMessageBox::information( 0, tr( "Hint" ), 208 QMessageBox::information( 0, tr( "Hint" ),
208 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 209 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
209 tr( "Ok" ) ); 210 tr( "Ok" ) );
210 if (defmail.length()!=0) { 211 if (defmail.length()!=0) {
211 fromBox->insertItem(defmail); 212 fromBox->insertItem(defmail);
212 } 213 }
213 QStringList::ConstIterator sit = emailList.begin(); 214 QStringList::ConstIterator sit = emailList.begin();
214 int pref = 0; 215 int pref = 0;
215 for (;sit!=emailList.end();++sit) { 216 for (;sit!=emailList.end();++sit) {
216 if ( (*sit)==defmail) 217 if ( (*sit)==defmail)
217 continue; 218 continue;
218 fromBox->insertItem((*sit)); 219 fromBox->insertItem((*sit));
219 } 220 }
220 senderNameEdit->setText(nameList[0]); 221 senderNameEdit->setText(nameList[0]);
221 return; 222 return;
222 } 223 }
223 QString names ; 224 QString names ;
224 QLineEdit *line = mPickLineEdit; 225 QLineEdit *line = mPickLineEdit;
225 if (uid == this->name()) 226 if (uid == this->name())
226 { 227 {
227 for ( int i = 0; i < nameList.count(); i++) 228 for ( int i = 0; i < nameList.count(); i++)
228 { 229 {
229 QString _name = nameList[i]; 230 QString _name = nameList[i];
230 QString _email = emailList[i]; 231 QString _email = emailList[i];
231 QString _uid = uidList[i]; 232 QString _uid = uidList[i];
232 if ( ! _email.isEmpty() ) { 233 if ( ! _email.isEmpty() ) {
233 if ( ! names.isEmpty() ) 234 if ( ! names.isEmpty() )
234 names+= ","; 235 names+= ",";
235 names+= "\""+_name +"\"<" +_email +">"; 236 names+= "\""+_name +"\"<" +_email +">";
236 } 237 }
237 } 238 }
238 } 239 }
239 if ( line->text().isEmpty() ) { 240 if ( line->text().isEmpty() ) {
240 line->setText( names ); 241 line->setText( names );
241 } else if ( !names.isEmpty() ) { 242 } else if ( !names.isEmpty() ) {
242 line->setText( line->text() + ", " + names ); 243 line->setText( line->text() + ", " + names );
243 } 244 }
244} 245}
245 246
246void ComposeMail::setTo( const QString & to ) 247void ComposeMail::setTo( const QString & to )
247{ 248{
248 toLine->setText( to ); 249 toLine->setText( to );
249} 250}
250 251
251void ComposeMail::setSubject( const QString & subject ) 252void ComposeMail::setSubject( const QString & subject )
252{ 253{
253 subjectLine->setText( subject ); 254 subjectLine->setText( subject );
254} 255}
255 256
256void ComposeMail::setInReplyTo( const QString & messageId ) 257void ComposeMail::setInReplyTo( const QString & messageId )
257{ 258{
258 m_replyid = messageId; 259 m_replyid = messageId;
259} 260}
260 261
261void ComposeMail::setMessage( const QString & text ) 262void ComposeMail::setMessage( const QString & text )
262{ 263{
263 message->setText( text ); 264 message->setText( text );
264} 265}
265 266
266 267
267void ComposeMail::pickAddressTo() 268void ComposeMail::pickAddressTo()
268{ 269{
269 mPickLineEdit = toLine; 270 mPickLineEdit = toLine;
270 pickAddress( ); 271 pickAddress( );
271} 272}
272 273
273void ComposeMail::pickAddressCC() 274void ComposeMail::pickAddressCC()
274{ 275{
275 mPickLineEdit = ccLine; 276 mPickLineEdit = ccLine;
276 pickAddress( ); 277 pickAddress( );
277} 278}
278 279
279void ComposeMail::pickAddressBCC() 280void ComposeMail::pickAddressBCC()
280{ 281{
281 mPickLineEdit = bccLine; 282 mPickLineEdit = bccLine;
282 pickAddress( ); 283 pickAddress( );
283} 284}
284 285
285void ComposeMail::pickAddressReply() 286void ComposeMail::pickAddressReply()
286{ 287{
287 mPickLineEdit = replyLine; 288 mPickLineEdit = replyLine;
288 pickAddress( ); 289 pickAddress( );
289} 290}
290 291
291void ComposeMail::fillValues( int ) 292void ComposeMail::fillValues( int )
292{ 293{
293#if 0 294#if 0
294 SMTPaccount *smtp = smtpAccounts.at( current ); 295 SMTPaccount *smtp = smtpAccounts.at( current );
295 ccLine->clear(); 296 ccLine->clear();
296 if ( smtp->getUseCC() ) { 297 if ( smtp->getUseCC() ) {
297 ccLine->setText( smtp->getCC() ); 298 ccLine->setText( smtp->getCC() );
298 } 299 }
299 bccLine->clear(); 300 bccLine->clear();
300 if ( smtp->getUseBCC() ) { 301 if ( smtp->getUseBCC() ) {
301 bccLine->setText( smtp->getBCC() ); 302 bccLine->setText( smtp->getBCC() );
302 } 303 }
303 replyLine->clear(); 304 replyLine->clear();
304 if ( smtp->getUseReply() ) { 305 if ( smtp->getUseReply() ) {
305 replyLine->setText( smtp->getReply() ); 306 replyLine->setText( smtp->getReply() );
306 } 307 }
307 sigMultiLine->setText( smtp->getSignature() ); 308 sigMultiLine->setText( smtp->getSignature() );
308#endif 309#endif
309} 310}
310 311
311void ComposeMail::slotAdjustColumns() 312void ComposeMail::slotAdjustColumns()
312{ 313{
313 int currPage = tabWidget->currentPageIndex(); 314 int currPage = tabWidget->currentPageIndex();
314 315
315 tabWidget->showPage( attachTab ); 316 tabWidget->showPage( attachTab );
316 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 317 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
317 attList->setColumnWidth( 1, 80 ); 318 attList->setColumnWidth( 1, 80 );
318 319
319 tabWidget->setCurrentPage( currPage ); 320 tabWidget->setCurrentPage( currPage );
320} 321}
321 322
322void ComposeMail::addAttachment() 323void ComposeMail::addAttachment()
323{ 324{
324 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 325 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
325 if ( !lnk.isEmpty() ) { 326 if ( !lnk.isEmpty() ) {
326 Attachment *att = new Attachment( lnk ); 327 Attachment *att = new Attachment( lnk );
327 (void) new AttachViewItem( attList, att ); 328 (void) new AttachViewItem( attList, att );
328 } 329 }
329} 330}
330 331
331void ComposeMail::removeAttachment() 332void ComposeMail::removeAttachment()
332{ 333{
333 if ( !attList->currentItem() ) { 334 if ( !attList->currentItem() ) {
334 QMessageBox::information( this, tr( "Error" ), 335 QMessageBox::information( this, tr( "Error" ),
335 tr( "<p>Please select a File.</p>" ), 336 tr( "<p>Please select a File.</p>" ),
336 tr( "Ok" ) ); 337 tr( "Ok" ) );
337 } else { 338 } else {
338 attList->takeItem( attList->currentItem() ); 339 attList->takeItem( attList->currentItem() );
339 } 340 }
340} 341}
341 342
342void ComposeMail::accept() 343void ComposeMail::accept()
343{ 344{
344 if ( smtpAccountBox->count() == 0 ) { 345 if ( smtpAccountBox->count() == 0 ) {
345 346
346 reject(); 347 reject();
347 return; 348 return;
348 } 349 }
349 350
350 if (! checkBoxLater->isChecked() ) { 351 if (! checkBoxLater->isChecked() ) {
351 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 352 int yesno = QMessageBox::warning(0,tr("Stop editing message"),
352 tr("Send this message?"), 353 tr("Send this message?"),
353 tr("Yes"), 354 tr("Yes"),
354 tr("Cancel")); 355 tr("Cancel"));
355 356
356 if (yesno == 1) { 357 if (yesno == 1) {
357 return; 358 return;
358 } 359 }
359 } 360 }
360#if 0 361#if 0
361 odebug << "Sending Mail with " 362 odebug << "Sending Mail with "
362 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 363 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
363#endif 364#endif
364 Opie::Core::OSmartPointer<Mail> mail=new Mail; 365 Opie::Core::OSmartPointer<Mail> mail=new Mail;
365 366
366 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 367 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
367 mail->setMail(fromBox->currentText()); 368 mail->setMail(fromBox->currentText());
368 369
369 if ( !toLine->text().isEmpty() ) { 370 if ( !toLine->text().isEmpty() ) {
370 mail->setTo( toLine->text() ); 371 mail->setTo( toLine->text() );
371 } else { 372 } else {
372 QMessageBox::warning(0,tr("Sending mail"), 373 QMessageBox::warning(0,tr("Sending mail"),
373 tr("No Receiver spezified" ) ); 374 tr("No Receiver spezified" ) );
374 return; 375 return;
375 } 376 }
376 377
377 mail->setName(senderNameEdit->text()); 378 mail->setName(senderNameEdit->text());
378 mail->setCC( ccLine->text() ); 379 mail->setCC( ccLine->text() );
379 mail->setBCC( bccLine->text() ); 380 mail->setBCC( bccLine->text() );
380 mail->setReply( replyLine->text() ); 381 mail->setReply( replyLine->text() );
381 mail->setSubject( subjectLine->text() ); 382 mail->setSubject( subjectLine->text() );
382 if (!m_replyid.isEmpty()) { 383 if (!m_replyid.isEmpty()) {
383 QStringList ids; 384 QStringList ids;
384 ids.append(m_replyid); 385 ids.append(m_replyid);
385 mail->setInreply(ids); 386 mail->setInreply(ids);
386 } 387 }
387 QString txt = message->text(); 388 QString txt = message->text();
388 if ( !sigMultiLine->text().isEmpty() ) { 389 if ( !sigMultiLine->text().isEmpty() ) {
389 txt.append( "\n--\n" ); 390 txt.append( "\n--\n" );
390 txt.append( sigMultiLine->text() ); 391 txt.append( sigMultiLine->text() );
391 } 392 }
392 mail->setMessage( txt ); 393 mail->setMessage( txt );
393 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 394 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
394 while ( it != 0 ) { 395 while ( it != 0 ) {
395 mail->addAttachment( it->getAttachment() ); 396 mail->addAttachment( it->getAttachment() );
396 it = (AttachViewItem *) it->nextSibling(); 397 it = (AttachViewItem *) it->nextSibling();
397 } 398 }
398 399
399 SMTPwrapper wrapper( smtp ); 400 SMTPwrapper wrapper( smtp );
400 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 401 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
401 setStatus( tr ("Mail sent")); 402 setStatus( tr ("Mail sent"));
402 else { 403 else {
403 setStatus( tr ("Error: Something went wrong. Nothing sent")); 404 setStatus( tr ("Error: Something went wrong. Nothing sent"));
404 return; 405 return;
405 } 406 }
406 407
407 408
408 QDialog::accept(); 409 QDialog::accept();
409} 410}
410 411
411void ComposeMail::reject() 412void ComposeMail::reject()
412{ 413{
413 //qDebug("ComposeMail::reject() "); 414 //qDebug("ComposeMail::reject() ");
414 int yesno = QMessageBox::warning(0,tr("Store message?"), 415 int yesno = QMessageBox::warning(0,tr("Store message?"),
415 tr("Store message into drafts?\n"), 416 tr("Store message into drafts?\n"),
416 tr("Yes"), 417 tr("Yes"),
417 tr("No")); 418 tr("No"));
418 419
419 //qDebug("button %d ", yesno); 420 //qDebug("button %d ", yesno);
420 if (yesno == 0) { 421 if (yesno == 0) {
421 if ( toLine->text().isEmpty() ) { 422 if ( toLine->text().isEmpty() ) {
422 QMessageBox::warning(0,tr("Sending mail"), 423 QMessageBox::warning(0,tr("Sending mail"),
423 tr("No Receiver spezified" ) ); 424 tr("No Receiver spezified" ) );
424 return; 425 return;
425 } 426 }
426 saveAsDraft(); 427 saveAsDraft();
427 } 428 }
428 if (yesno == 2) { 429 if (yesno == 2) {
429 qDebug("return "); 430 qDebug("return ");
430 return; 431 return;
431 } 432 }
432 QDialog::reject(); 433 QDialog::reject();
433} 434}
434 435
435ComposeMail::~ComposeMail() 436ComposeMail::~ComposeMail()
436{ 437{
437} 438}
438 439
439void ComposeMail::reEditMail(const RecMailP&current) 440void ComposeMail::reEditMail(const RecMailP&current)
440{ 441{
441 RecMailP data = current; 442 RecMailP data = current;
442 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 443 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
443 subjectLine->setText( data->getSubject()); 444 subjectLine->setText( data->getSubject());
444 toLine->setText(data->To().join(",")); 445 toLine->setText(data->To().join(","));
445 ccLine->setText(data->CC().join(",")); 446 ccLine->setText(data->CC().join(","));
446 bccLine->setText(data->Bcc().join(",")); 447 bccLine->setText(data->Bcc().join(","));
447 replyLine->setText(data->Replyto()); 448 replyLine->setText(data->Replyto());
448} 449}
449 450
450AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 451AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
451 : QListViewItem( parent ) 452 : QListViewItem( parent )
452{ 453{
453 attachment = att; 454 attachment = att;
454 if ( !attachment->getPixmap().isNull() ) 455 if ( !attachment->getPixmap().isNull() )
455 setPixmap( 0,attachment->getPixmap() ); 456 setPixmap( 0,attachment->getPixmap() );
456 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 457 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
457 setText( 1, QString::number( att->getSize() ) ); 458 setText( 1, QString::number( att->getSize() ) );
458} 459}
459 460
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 0c581c0..b2119e6 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,425 +1,441 @@
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#include <qtimer.h>
14#include <libkdepim/externalapphandler.h> 15#include <libkdepim/externalapphandler.h>
15 16
16#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
17#include <libmailwrapper/smtpwrapper.h> 18#include <libmailwrapper/smtpwrapper.h>
18#include <libmailwrapper/mailtypes.h> 19#include <libmailwrapper/mailtypes.h>
19#include <libmailwrapper/abstractmail.h> 20#include <libmailwrapper/abstractmail.h>
20/* OPIE */ 21/* OPIE */
21//#include <qpe/resource.h> 22//#include <qpe/resource.h>
22//#include <qpe/qpeapplication.h> 23//#include <qpe/qpeapplication.h>
23 24
24/* QT */ 25/* QT */
25 26
26//using namespace Opie::Core; 27//using namespace Opie::Core;
27 28
28OpieMail::OpieMail( QWidget *parent, const char *name ) 29OpieMail::OpieMail( QWidget *parent, const char *name )
29 : MainWindow( parent, name) //, WStyle_ContextHelp ) 30 : MainWindow( parent, name) //, WStyle_ContextHelp )
30{ 31{
31 settings = new Settings(); 32 settings = new Settings();
32 33
33 folderView->populate( settings->getAccounts() ); 34 folderView->populate( settings->getAccounts() );
34 35
35} 36}
36 37
37OpieMail::~OpieMail() 38OpieMail::~OpieMail()
38{ 39{
39 if (settings) delete settings; 40 if (settings) delete settings;
40} 41}
41 42
42void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 43void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
43{ 44{
44 45
45} 46}
46#include <stdlib.h> 47#include <stdlib.h>
47void OpieMail::message(const QCString &msg, const QByteArray &data) 48void OpieMail::message(const QCString &msg, const QByteArray &data)
48{ 49{
49 // copied from old mail2 50 // copied from old mail2
50 static int ii = 0; 51 static int ii = 0;
51 qDebug("call ############################# %d ", ii); 52 //qDebug("QCOP CALL ############################# %d ", ii);
52 // block second call 53 //QString mess ( msg );
53 if ( ii < 2 ) { 54 //qDebug("Message = %s ",mess.latin1());
54 //++ii;
55 if ( ii > 1 ) {
56 qDebug("qcop call blocked ");
57 //return;
58 }
59 }
60 ++ii; 55 ++ii;
61 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 56 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
57
58 mPendingEmail = QString::null;
59 mPendingName = QString::null;
62 if (msg == "writeMail(QString,QString)") 60 if (msg == "writeMail(QString,QString)")
63 { 61 {
62 //qDebug("writeMail(QString,QString) ");
64 QDataStream stream(data,IO_ReadOnly); 63 QDataStream stream(data,IO_ReadOnly);
65 QString name, email; 64 stream >> mPendingName >> mPendingEmail;
66 stream >> name >> email;
67 // removing the whitespaces at beginning and end is needed! 65 // removing the whitespaces at beginning and end is needed!
68 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 66 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
69 } 67 }
70 else if (msg == "newMail()") 68 else if (msg == "newMail()")
71 { 69 {
72 slotComposeMail(); 70 //qDebug("slotComposeMail() ");
71 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
72 // and a QCOP call does not like a processevents in his execution
73 // with the Qtimer we call slotComposeMail() after we reached the main event loop
74 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
75 // slotComposeMail();
73 } 76 }
74 else if (msg == "newMail(QString)") 77 else if (msg == "newMail(QString)")
75 { 78 {
79 //qDebug(" newMail(QString)");
76 QDataStream stream(data,IO_ReadOnly); 80 QDataStream stream(data,IO_ReadOnly);
77 QString nameemail; 81 stream >> mPendingName;
78 stream >> nameemail;
79 // the format is 82 // the format is
80 // NAME <EMAIL>:SUBJECT 83 // NAME <EMAIL>:SUBJECT
81 //qDebug("message %s ", nameemail.latin1()); 84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
82 85 } else {
83 slotwriteMail2( nameemail ); 86 if ( ii == 1 ) {
84 } else 87 qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported ");
85 ExternalAppHandler::instance()->appMessage ( msg, data); 88 return;
89 }
90 ExternalAppHandler::instance()->appMessage ( msg, data);
91 }
92
93 //qDebug("END OpieMail::message ");
86} 94}
87void OpieMail::slotwriteMail2(const QString& namemail ) 95void OpieMail::slotwriteMail2(const QString& namemail )
88{ 96{
89 // qDebug("OpieMail::slotwriteMail2 "); 97 //qDebug("OpieMail::slotwriteMail2 ");
90 qApp->processEvents(); 98 //qApp->processEvents();
91 ComposeMail compose( settings, this, 0, true ); 99 ComposeMail compose( settings, this, 0, true );
92 if ( !namemail.isEmpty() ) { 100 if ( !namemail.isEmpty() ) {
93 QString to = namemail; 101 QString to = namemail;
94 if ( namemail.find( " <") > 1 ) { 102 if ( namemail.find( " <") > 1 ) {
95 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 103 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
96 } else 104 } else
97 if ( namemail.find( "<") > 1 ) { 105 if ( namemail.find( "<") > 1 ) {
98 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 106 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
99 } 107 }
100 int sub = to.find( ">:"); 108 int sub = to.find( ">:");
101 if ( sub > 0 ) { 109 if ( sub > 0 ) {
102 compose.setTo( to.left(sub+1) ); 110 compose.setTo( to.left(sub+1) );
103 compose.setSubject( to.mid(sub+2) ); 111 compose.setSubject( to.mid(sub+2) );
104 } else 112 } else
105 compose.setTo( to ); 113 compose.setTo( to );
106 } 114 }
107 compose.slotAdjustColumns(); 115 compose.slotAdjustColumns();
108 compose.showMaximized(); 116 compose.showMaximized();
109 compose.exec(); 117 compose.exec();
110 raise(); 118 raise();
111 //qDebug("retttich "); 119 //qDebug("retttich ");
112} 120}
113void OpieMail::slotwriteMail(const QString&name,const QString&email) 121void OpieMail::slotwriteMail(const QString&name,const QString&email)
114{ 122{
115 // qDebug("OpieMail::slotwriteMail "); 123 // qDebug("OpieMail::slotwriteMail ");
116 ComposeMail compose( settings, this, 0, true ); 124 ComposeMail compose( settings, this, 0, true );
117 if (!email.isEmpty()) 125 if (!email.isEmpty())
118 { 126 {
119 if (!name.isEmpty()) 127 if (!name.isEmpty())
120 { 128 {
121 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 129 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
122 } 130 }
123 else 131 else
124 { 132 {
125 compose.setTo(email); 133 compose.setTo(email);
126 } 134 }
127 } 135 }
128 compose.slotAdjustColumns(); 136 compose.slotAdjustColumns();
129 compose.showMaximized(); 137 compose.showMaximized();
130 compose.exec(); 138 compose.exec();
139 raise();
131} 140}
132 141
133void OpieMail::slotComposeMail() 142void OpieMail::slotComposeMail()
134{ 143{
135 slotwriteMail2( QString () ); 144 if ( mPendingEmail == QString::null && mPendingName == QString::null)
145 slotwriteMail2( QString () );
146 else {
147 if ( mPendingEmail == QString::null )
148 slotwriteMail2( mPendingName );
149 else
150 slotwriteMail( mPendingName, mPendingEmail );
151 }
136 //slotwriteMail(0l,0l); 152 //slotwriteMail(0l,0l);
137} 153}
138 154
139void OpieMail::slotSendQueued() 155void OpieMail::slotSendQueued()
140{ 156{
141 SMTPaccount *smtp = 0; 157 SMTPaccount *smtp = 0;
142 158
143 QList<Account> list = settings->getAccounts(); 159 QList<Account> list = settings->getAccounts();
144 QList<SMTPaccount> smtpList; 160 QList<SMTPaccount> smtpList;
145 smtpList.setAutoDelete(false); 161 smtpList.setAutoDelete(false);
146 Account *it; 162 Account *it;
147 for ( it = list.first(); it; it = list.next() ) 163 for ( it = list.first(); it; it = list.next() )
148 { 164 {
149 if ( it->getType() == MAILLIB::A_SMTP ) 165 if ( it->getType() == MAILLIB::A_SMTP )
150 { 166 {
151 smtp = static_cast<SMTPaccount *>(it); 167 smtp = static_cast<SMTPaccount *>(it);
152 smtpList.append(smtp); 168 smtpList.append(smtp);
153 } 169 }
154 } 170 }
155 if (smtpList.count()==0) 171 if (smtpList.count()==0)
156 { 172 {
157 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); 173 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
158 return; 174 return;
159 } 175 }
160 if (smtpList.count()==1) 176 if (smtpList.count()==1)
161 { 177 {
162 smtp = smtpList.at(0); 178 smtp = smtpList.at(0);
163 } 179 }
164 else 180 else
165 { 181 {
166 smtp = 0; 182 smtp = 0;
167 selectsmtp selsmtp; 183 selectsmtp selsmtp;
168 selsmtp.setSelectionlist(&smtpList); 184 selsmtp.setSelectionlist(&smtpList);
169 selsmtp.showMaximized(); 185 selsmtp.showMaximized();
170 if ( selsmtp.exec() == QDialog::Accepted ) 186 if ( selsmtp.exec() == QDialog::Accepted )
171 { 187 {
172 smtp = selsmtp.selected_smtp(); 188 smtp = selsmtp.selected_smtp();
173 } 189 }
174 } 190 }
175 if (smtp) 191 if (smtp)
176 { 192 {
177 SMTPwrapper * wrap = new SMTPwrapper(smtp); 193 SMTPwrapper * wrap = new SMTPwrapper(smtp);
178 if ( wrap->flushOutbox() ) 194 if ( wrap->flushOutbox() )
179 { 195 {
180 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 196 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
181 } 197 }
182 delete wrap; 198 delete wrap;
183 } 199 }
184} 200}
185 201
186void OpieMail::slotSearchMails() 202void OpieMail::slotSearchMails()
187{ 203{
188 qDebug("OpieMail::slotSearchMails():not implemented "); 204 qDebug("OpieMail::slotSearchMails():not implemented ");
189} 205}
190 206
191void OpieMail::slotEditSettings() 207void OpieMail::slotEditSettings()
192{ 208{
193 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 209 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
194 settingsDialog.showMaximized(); 210 settingsDialog.showMaximized();
195 settingsDialog.exec(); 211 settingsDialog.exec();
196} 212}
197 213
198void OpieMail::slotEditAccounts() 214void OpieMail::slotEditAccounts()
199{ 215{
200 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 216 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
201 eaDialog.slotAdjustColumns(); 217 eaDialog.slotAdjustColumns();
202 eaDialog.showMaximized(); 218 eaDialog.showMaximized();
203 eaDialog.exec(); 219 eaDialog.exec();
204 if ( settings ) delete settings; 220 if ( settings ) delete settings;
205 settings = new Settings(); 221 settings = new Settings();
206 222
207 folderView->populate( settings->getAccounts() ); 223 folderView->populate( settings->getAccounts() );
208} 224}
209 225
210void OpieMail::displayMail() 226void OpieMail::displayMail()
211{ 227{
212 QListViewItem*item = mailView->currentItem(); 228 QListViewItem*item = mailView->currentItem();
213 if (!item) return; 229 if (!item) return;
214 RecMailP mail = ((MailListViewItem*)item)->data(); 230 RecMailP mail = ((MailListViewItem*)item)->data();
215 RecBodyP body = folderView->fetchBody(mail); 231 RecBodyP body = folderView->fetchBody(mail);
216 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 232 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
217 readMail.setBody( body ); 233 readMail.setBody( body );
218 readMail.setMail( mail ); 234 readMail.setMail( mail );
219 readMail.showMaximized(); 235 readMail.showMaximized();
220 readMail.exec(); 236 readMail.exec();
221 237
222 if ( readMail.deleted ) 238 if ( readMail.deleted )
223 { 239 {
224 folderView->refreshCurrent(); 240 folderView->refreshCurrent();
225 } 241 }
226 else 242 else
227 { 243 {
228 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 244 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
229 } 245 }
230} 246}
231 247
232void OpieMail::slotDeleteMail() 248void OpieMail::slotDeleteMail()
233{ 249{
234 if (!mailView->currentItem()) return; 250 if (!mailView->currentItem()) return;
235 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 251 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
236 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 ) 252 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 )
237 { 253 {
238 mail->Wrapper()->deleteMail( mail ); 254 mail->Wrapper()->deleteMail( mail );
239 folderView->refreshCurrent(); 255 folderView->refreshCurrent();
240 } 256 }
241} 257}
242void OpieMail::slotDeleteAllMail() 258void OpieMail::slotDeleteAllMail()
243{ 259{
244 260
245 QValueList<RecMailP> t; 261 QValueList<RecMailP> t;
246 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 262 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
247 { 263 {
248 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 264 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
249 while ( item ) { 265 while ( item ) {
250 if ( item->isSelected() ) { 266 if ( item->isSelected() ) {
251 t.append( item->data() ); 267 t.append( item->data() );
252 } 268 }
253 item = (MailListViewItem*)item->nextSibling(); 269 item = (MailListViewItem*)item->nextSibling();
254 } 270 }
255 } 271 }
256 else 272 else
257 return; 273 return;
258 if ( t.count() == 0 ) 274 if ( t.count() == 0 )
259 return; 275 return;
260 RecMailP mail = t.first(); 276 RecMailP mail = t.first();
261 mail->Wrapper()->deleteMailList(t); 277 mail->Wrapper()->deleteMailList(t);
262 folderView->refreshCurrent(); 278 folderView->refreshCurrent();
263 279
264 280
265} 281}
266void OpieMail::clearSelection() 282void OpieMail::clearSelection()
267{ 283{
268 mailView->clearSelection(); 284 mailView->clearSelection();
269 285
270} 286}
271 287
272void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 288void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
273{ 289{
274 if (!mailView->currentItem()) return; 290 if (!mailView->currentItem()) return;
275 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 291 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
276 /* just the RIGHT button - or hold on pda */ 292 /* just the RIGHT button - or hold on pda */
277 if (button!=2) {return;} 293 if (button!=2) {return;}
278 if (!item) return; 294 if (!item) return;
279 QPopupMenu *m = new QPopupMenu(0); 295 QPopupMenu *m = new QPopupMenu(0);
280 if (m) 296 if (m)
281 { 297 {
282 if (mailtype==MAILLIB::A_NNTP) { 298 if (mailtype==MAILLIB::A_NNTP) {
283 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 299 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
284// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 300// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
285 } else { 301 } else {
286 if (folderView->currentisDraft()) { 302 if (folderView->currentisDraft()) {
287 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 303 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
288 } 304 }
289 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 305 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
290 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 306 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
291 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 307 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
292 m->insertSeparator(); 308 m->insertSeparator();
293 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 309 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
294 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 310 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
295 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 311 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
296 } 312 }
297 m->setFocus(); 313 m->setFocus();
298 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 314 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
299 delete m; 315 delete m;
300 } 316 }
301} 317}
302 318
303void OpieMail::slotShowFolders( bool show ) 319void OpieMail::slotShowFolders( bool show )
304{ 320{
305 if ( show && folderView->isHidden() ) 321 if ( show && folderView->isHidden() )
306 { 322 {
307 folderView->show(); 323 folderView->show();
308 } 324 }
309 else if ( !show && !folderView->isHidden() ) 325 else if ( !show && !folderView->isHidden() )
310 { 326 {
311 folderView->hide(); 327 folderView->hide();
312 } 328 }
313} 329}
314 330
315void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 331void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
316{ 332{
317 MailListViewItem*item = 0; 333 MailListViewItem*item = 0;
318 mailView->clear(); 334 mailView->clear();
319 335
320 QValueList<RecMailP>::ConstIterator it; 336 QValueList<RecMailP>::ConstIterator it;
321 for (it = list.begin(); it != list.end();++it) 337 for (it = list.begin(); it != list.end();++it)
322 { 338 {
323 item = new MailListViewItem(mailView,item); 339 item = new MailListViewItem(mailView,item);
324 item->storeData((*it)); 340 item->storeData((*it));
325 item->showEntry(); 341 item->showEntry();
326 } 342 }
327} 343}
328 344
329void OpieMail::mailLeftClicked( QListViewItem *item ) 345void OpieMail::mailLeftClicked( QListViewItem *item )
330{ 346{
331 mailView->clearSelection(); 347 mailView->clearSelection();
332 /* just LEFT button - or tap with stylus on pda */ 348 /* just LEFT button - or tap with stylus on pda */
333 //if (button!=1) return; 349 //if (button!=1) return;
334 if (!item) return; 350 if (!item) return;
335 if (folderView->currentisDraft()) { 351 if (folderView->currentisDraft()) {
336 reEditMail(); 352 reEditMail();
337 } else { 353 } else {
338 displayMail(); 354 displayMail();
339 } 355 }
340} 356}
341 357
342void OpieMail::slotMoveCopyMail() 358void OpieMail::slotMoveCopyMail()
343{ 359{
344 if (!mailView->currentItem()) return; 360 if (!mailView->currentItem()) return;
345 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 361 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
346 AbstractMail*targetMail = 0; 362 AbstractMail*targetMail = 0;
347 QString targetFolder = ""; 363 QString targetFolder = "";
348 Selectstore sels; 364 Selectstore sels;
349 folderView->setupFolderselect(&sels); 365 folderView->setupFolderselect(&sels);
350 if (!sels.exec()) return; 366 if (!sels.exec()) return;
351 targetMail = sels.currentMail(); 367 targetMail = sels.currentMail();
352 targetFolder = sels.currentFolder(); 368 targetFolder = sels.currentFolder();
353 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 369 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
354 targetFolder.isEmpty()) 370 targetFolder.isEmpty())
355 { 371 {
356 return; 372 return;
357 } 373 }
358 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 374 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
359 { 375 {
360 QMessageBox::critical(0,tr("Error creating new Folder"), 376 QMessageBox::critical(0,tr("Error creating new Folder"),
361 tr("<center>Error while creating<br>new folder - breaking.</center>")); 377 tr("<center>Error while creating<br>new folder - breaking.</center>"));
362 return; 378 return;
363 } 379 }
364 sels.hide(); 380 sels.hide();
365 qApp->processEvents(); 381 qApp->processEvents();
366 // qDebug("hiding sels "); 382 // qDebug("hiding sels ");
367 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 383 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
368 folderView->refreshCurrent(); 384 folderView->refreshCurrent();
369} 385}
370 386
371void OpieMail::slotMoveCopyAllMail() 387void OpieMail::slotMoveCopyAllMail()
372{ 388{
373 389
374 if (!mailView->currentItem()) return; 390 if (!mailView->currentItem()) return;
375 QValueList<RecMailP> t; 391 QValueList<RecMailP> t;
376 // 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 ) 392 // 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 )
377 { 393 {
378 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 394 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
379 while ( item ) { 395 while ( item ) {
380 if ( item->isSelected() ) { 396 if ( item->isSelected() ) {
381 t.append( item->data() ); 397 t.append( item->data() );
382 } 398 }
383 item = (MailListViewItem*)item->nextSibling(); 399 item = (MailListViewItem*)item->nextSibling();
384 } 400 }
385 } 401 }
386 // else 402 // else
387 // return; 403 // return;
388 if ( t.count() == 0 ) 404 if ( t.count() == 0 )
389 return; 405 return;
390 RecMailP mail = t.first(); 406 RecMailP mail = t.first();
391 AbstractMail*targetMail = 0; 407 AbstractMail*targetMail = 0;
392 QString targetFolder = ""; 408 QString targetFolder = "";
393 Selectstore sels; 409 Selectstore sels;
394 folderView->setupFolderselect(&sels); 410 folderView->setupFolderselect(&sels);
395 if (!sels.exec()) return; 411 if (!sels.exec()) return;
396 targetMail = sels.currentMail(); 412 targetMail = sels.currentMail();
397 targetFolder = sels.currentFolder(); 413 targetFolder = sels.currentFolder();
398 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 414 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
399 targetFolder.isEmpty()) 415 targetFolder.isEmpty())
400 { 416 {
401 return; 417 return;
402 } 418 }
403 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 419 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
404 { 420 {
405 QMessageBox::critical(0,tr("Error creating new Folder"), 421 QMessageBox::critical(0,tr("Error creating new Folder"),
406 tr("<center>Error while creating<br>new folder - breaking.</center>")); 422 tr("<center>Error while creating<br>new folder - breaking.</center>"));
407 return; 423 return;
408 } 424 }
409 sels.hide(); 425 sels.hide();
410 qApp->processEvents(); 426 qApp->processEvents();
411 //qDebug("hiding sels "); 427 //qDebug("hiding sels ");
412 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 428 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
413 folderView->refreshCurrent(); 429 folderView->refreshCurrent();
414} 430}
415 431
416void OpieMail::reEditMail() 432void OpieMail::reEditMail()
417{ 433{
418 if (!mailView->currentItem()) return; 434 if (!mailView->currentItem()) return;
419 435
420 ComposeMail compose( settings, this, 0, true ); 436 ComposeMail compose( settings, this, 0, true );
421 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 437 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
422 compose.slotAdjustColumns(); 438 compose.slotAdjustColumns();
423 compose.showMaximized(); 439 compose.showMaximized();
424 compose.exec(); 440 compose.exec();
425} 441}
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h
index 7434e59..1de5f6b 100644
--- a/kmicromail/opiemail.h
+++ b/kmicromail/opiemail.h
@@ -1,48 +1,50 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#ifndef OPIEMAIL_H 2#ifndef OPIEMAIL_H
3#define OPIEMAIL_H 3#define OPIEMAIL_H
4 4
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7 7
8#include <opie2/osmartpointer.h> 8#include <opie2/osmartpointer.h>
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10 10
11class OpieMail : public MainWindow 11class OpieMail : public MainWindow
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 OpieMail( QWidget *parent = 0, const char *name = 0 ); 16 OpieMail( QWidget *parent = 0, const char *name = 0 );
17 virtual ~OpieMail(); 17 virtual ~OpieMail();
18 static QString appName() { return QString::fromLatin1("kopiemail"); } 18 static QString appName() { return QString::fromLatin1("kopiemail"); }
19 19
20public slots: 20public slots:
21 virtual void slotwriteMail(const QString&name,const QString&email); 21 virtual void slotwriteMail(const QString&name,const QString&email);
22 virtual void slotwriteMail2(const QString&nameemail); 22 virtual void slotwriteMail2(const QString&nameemail);
23 virtual void slotComposeMail(); 23 virtual void slotComposeMail();
24 virtual void appMessage(const QCString &msg, const QByteArray &data); 24 virtual void appMessage(const QCString &msg, const QByteArray &data);
25 virtual void message(const QCString &msg, const QByteArray &data); 25 virtual void message(const QCString &msg, const QByteArray &data);
26protected slots: 26protected slots:
27 virtual void slotSendQueued(); 27 virtual void slotSendQueued();
28 virtual void slotSearchMails(); 28 virtual void slotSearchMails();
29 virtual void slotEditSettings(); 29 virtual void slotEditSettings();
30 virtual void slotEditAccounts(); 30 virtual void slotEditAccounts();
31 virtual void displayMail(); 31 virtual void displayMail();
32 virtual void slotDeleteMail(); 32 virtual void slotDeleteMail();
33 virtual void slotDeleteAllMail(); 33 virtual void slotDeleteAllMail();
34 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 34 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
35 virtual void slotShowFolders( bool show ); 35 virtual void slotShowFolders( bool show );
36 virtual void refreshMailView(const QValueList<RecMailP>&); 36 virtual void refreshMailView(const QValueList<RecMailP>&);
37 virtual void mailLeftClicked( QListViewItem * ); 37 virtual void mailLeftClicked( QListViewItem * );
38 virtual void slotMoveCopyMail(); 38 virtual void slotMoveCopyMail();
39 virtual void slotMoveCopyAllMail(); 39 virtual void slotMoveCopyAllMail();
40 virtual void reEditMail(); 40 virtual void reEditMail();
41 void clearSelection(); 41 void clearSelection();
42 42
43private: 43private:
44 QString mPendingEmail;
45 QString mPendingName;
44 Settings *settings; 46 Settings *settings;
45 47
46}; 48};
47 49
48#endif 50#endif