summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-08-23 20:09:28 (UTC)
committer zautrix <zautrix>2005-08-23 20:09:28 (UTC)
commit6f5464760f5fb1e4c13027464cfe4943b85d29a0 (patch) (unidiff)
tree3c074b7e313d965516b60b9ba97fe27a7ee774a1
parent13a736b71dec27ef7ffef06b91f34d220d89cce6 (diff)
downloadkdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.zip
kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.gz
kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.bz2
fixx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--kaddressbook/kaddressbookmain.cpp2
-rw-r--r--kmicromail/accountview.cpp2
-rw-r--r--microkde/kdeui/kmainwindow.cpp11
-rw-r--r--microkde/kdeui/kmainwindow.h2
5 files changed, 12 insertions, 11 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 77321aa..af12f2b 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3481 +1,3481 @@
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 Async a special exception, permission is given to link this program 19 Async 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/*s 24/*s
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#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 306 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 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&))); 375 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&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 408}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 410{
411 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 412 mCStringMess = cmsg;
413 mByteData = data; 413 mByteData = data;
414} 414}
415 415
416void KABCore::loadDataAfterStart() 416void KABCore::loadDataAfterStart()
417{ 417{
418 qDebug("KABCore::loadDataAfterStart() "); 418 //qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 419 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 420 mViewManager->refreshView();
421 421
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 424
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 426 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 428#endif
429 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 430 setCaptionBack();
431} 431}
432void KABCore::updateToolBar() 432void KABCore::updateToolBar()
433{ 433{
434 static int iii = 0; 434 static int iii = 0;
435 ++iii; 435 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 436 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 437 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 439}
440KABCore::~KABCore() 440KABCore::~KABCore()
441{ 441{
442 // save(); 442 // save();
443 //saveSettings(); 443 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 444 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 445 delete AddresseeConfig::instance();
446 mAddressBook = 0; 446 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 447 KABC::StdAddressBook::close();
448 448
449 delete syncManager; 449 delete syncManager;
450#ifndef DESKTOP_VERSION 450#ifndef DESKTOP_VERSION
451 if ( infrared ) 451 if ( infrared )
452 delete infrared; 452 delete infrared;
453#endif 453#endif
454} 454}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 455void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 456{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 457 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 458 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 459 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 460 QString fileName;
461 stream >> fileName; 461 stream >> fileName;
462 recieve( fileName ); 462 recieve( fileName );
463 return; 463 return;
464 } 464 }
465} 465}
466void KABCore::toggleBeamReceive( ) 466void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 qDebug("KA: KABCore::saveSettings() "); 615 qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 mMainWindow->update(); 847 mMainWindow->update();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) 851 if ( !mMiniSplitter )
852 return; 852 return;
853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
854 if ( e->oldSize().width() != e->size().width() ) 854 if ( e->oldSize().width() != e->size().width() )
855 if ( QApplication::desktop()->width() >= 480 ) { 855 if ( QApplication::desktop()->width() >= 480 ) {
856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
857 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 857 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
858 mMiniSplitter->setOrientation( Qt::Horizontal); 858 mMiniSplitter->setOrientation( Qt::Horizontal);
859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
860 } 860 }
861 if ( QApplication::desktop()->width() <= 640 ) { 861 if ( QApplication::desktop()->width() <= 640 ) {
862 mMainWindow->showMinimized(); 862 mMainWindow->showMinimized();
863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
864 mViewManager->getFilterAction()->setComboWidth( 150 ); 864 mViewManager->getFilterAction()->setComboWidth( 150 );
865 if ( mIncSearchWidget ) 865 if ( mIncSearchWidget )
866 mIncSearchWidget->setSize(); 866 mIncSearchWidget->setSize();
867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
868 } 868 }
869 869
870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
872 mMiniSplitter->setOrientation( Qt::Vertical ); 872 mMiniSplitter->setOrientation( Qt::Vertical );
873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
874 } 874 }
875 if ( QApplication::desktop()->width() <= 640 ) { 875 if ( QApplication::desktop()->width() <= 640 ) {
876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
877 mMainWindow->showMinimized(); 877 mMainWindow->showMinimized();
878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
879 if ( mIncSearchWidget ) { 879 if ( mIncSearchWidget ) {
880 mIncSearchWidget->setSize(); 880 mIncSearchWidget->setSize();
881 } 881 }
882 } else { 882 } else {
883 mViewManager->getFilterAction()->setComboWidth( 0 ); 883 mViewManager->getFilterAction()->setComboWidth( 0 );
884 } 884 }
885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
886 } 886 }
887 } 887 }
888 } 888 }
889 QWidget::resizeEvent( e ); 889 QWidget::resizeEvent( e );
890 890
891} 891}
892void KABCore::export2phone() 892void KABCore::export2phone()
893{ 893{
894 894
895 QStringList uids; 895 QStringList uids;
896 XXPortSelectDialog dlg( this, false, this ); 896 XXPortSelectDialog dlg( this, false, this );
897 if ( dlg.exec() ) 897 if ( dlg.exec() )
898 uids = dlg.uids(); 898 uids = dlg.uids();
899 else 899 else
900 return; 900 return;
901 if ( uids.isEmpty() ) 901 if ( uids.isEmpty() )
902 return; 902 return;
903 // qDebug("count %d ", uids.count()); 903 // qDebug("count %d ", uids.count());
904 904
905 KAex2phonePrefs ex2phone; 905 KAex2phonePrefs ex2phone;
906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
909 909
910 if ( !ex2phone.exec() ) { 910 if ( !ex2phone.exec() ) {
911 return; 911 return;
912 } 912 }
913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
916 916
917 917
918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
919 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 919 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
920 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 920 KPimGlobalPrefs::instance()->mEx2PhoneModel );
921 921
922 QString fileName = getPhoneFile(); 922 QString fileName = getPhoneFile();
923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
924 return; 924 return;
925 925
926 message(i18n("Exporting to phone...")); 926 message(i18n("Exporting to phone..."));
927 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 927 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
928 928
929} 929}
930QString KABCore::getPhoneFile() 930QString KABCore::getPhoneFile()
931{ 931{
932#ifdef DESKTOP_VERSION 932#ifdef DESKTOP_VERSION
933 return locateLocal("tmp", "phonefile.vcf"); 933 return locateLocal("tmp", "phonefile.vcf");
934#else 934#else
935 return "/tmp/phonefile.vcf"; 935 return "/tmp/phonefile.vcf";
936#endif 936#endif
937 937
938} 938}
939void KABCore::writeToPhone( ) 939void KABCore::writeToPhone( )
940{ 940{
941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
942 message(i18n("Export to phone finished!")); 942 message(i18n("Export to phone finished!"));
943 else 943 else
944 qDebug(i18n("KA: Error exporting to phone")); 944 qDebug(i18n("KA: Error exporting to phone"));
945} 945}
946void KABCore::beamVCard() 946void KABCore::beamVCard()
947{ 947{
948 QStringList uids; 948 QStringList uids;
949 XXPortSelectDialog dlg( this, false, this ); 949 XXPortSelectDialog dlg( this, false, this );
950 if ( dlg.exec() ) 950 if ( dlg.exec() )
951 uids = dlg.uids(); 951 uids = dlg.uids();
952 else 952 else
953 return; 953 return;
954 if ( uids.isEmpty() ) 954 if ( uids.isEmpty() )
955 return; 955 return;
956 beamVCard( uids ); 956 beamVCard( uids );
957} 957}
958 958
959 959
960void KABCore::beamVCard(const QStringList& uids) 960void KABCore::beamVCard(const QStringList& uids)
961{ 961{
962 962
963 // LR: we should use the /tmp dir on the Zaurus, 963 // LR: we should use the /tmp dir on the Zaurus,
964 // because: /tmp = RAM, (HOME)/kdepim = flash memory 964 // because: /tmp = RAM, (HOME)/kdepim = flash memory
965 965
966#ifdef DESKTOP_VERSION 966#ifdef DESKTOP_VERSION
967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
968#else 968#else
969 QString fileName = "/tmp/kapibeamfile.vcf"; 969 QString fileName = "/tmp/kapibeamfile.vcf";
970#endif 970#endif
971 971
972 KABC::VCardConverter converter; 972 KABC::VCardConverter converter;
973 QString description; 973 QString description;
974 QString datastream; 974 QString datastream;
975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
976 KABC::Addressee a = mAddressBook->findByUid( *it ); 976 KABC::Addressee a = mAddressBook->findByUid( *it );
977 977
978 if ( a.isEmpty() ) 978 if ( a.isEmpty() )
979 continue; 979 continue;
980 980
981 if (description.isEmpty()) 981 if (description.isEmpty())
982 description = a.formattedName(); 982 description = a.formattedName();
983 983
984 QString vcard; 984 QString vcard;
985 converter.addresseeToVCard( a, vcard ); 985 converter.addresseeToVCard( a, vcard );
986 int start = 0; 986 int start = 0;
987 int next; 987 int next;
988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
989 int semi = vcard.find(";", next); 989 int semi = vcard.find(";", next);
990 int dopp = vcard.find(":", next); 990 int dopp = vcard.find(":", next);
991 int sep; 991 int sep;
992 if ( semi < dopp && semi >= 0 ) 992 if ( semi < dopp && semi >= 0 )
993 sep = semi ; 993 sep = semi ;
994 else 994 else
995 sep = dopp; 995 sep = dopp;
996 datastream +=vcard.mid( start, next - start); 996 datastream +=vcard.mid( start, next - start);
997 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 997 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
998 start = sep; 998 start = sep;
999 } 999 }
1000 datastream += vcard.mid( start,vcard.length() ); 1000 datastream += vcard.mid( start,vcard.length() );
1001 } 1001 }
1002#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
1003 QFile outFile(fileName); 1003 QFile outFile(fileName);
1004 if ( outFile.open(IO_WriteOnly) ) { 1004 if ( outFile.open(IO_WriteOnly) ) {
1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1006 QTextStream t( &outFile ); // use a text stream 1006 QTextStream t( &outFile ); // use a text stream
1007 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1007 //t.setEncoding( QTextStream::UnicodeUTF8 );
1008 t.setEncoding( QTextStream::Latin1 ); 1008 t.setEncoding( QTextStream::Latin1 );
1009 t <<datastream.latin1(); 1009 t <<datastream.latin1();
1010 outFile.close(); 1010 outFile.close();
1011 Ir *ir = new Ir( this ); 1011 Ir *ir = new Ir( this );
1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1013 ir->send( fileName, description, "text/x-vCard" ); 1013 ir->send( fileName, description, "text/x-vCard" );
1014 } else { 1014 } else {
1015 qDebug("KA: Error open temp beam file "); 1015 qDebug("KA: Error open temp beam file ");
1016 return; 1016 return;
1017 } 1017 }
1018#endif 1018#endif
1019 1019
1020} 1020}
1021 1021
1022void KABCore::beamDone( Ir *ir ) 1022void KABCore::beamDone( Ir *ir )
1023{ 1023{
1024#ifndef DESKTOP_VERSION 1024#ifndef DESKTOP_VERSION
1025 delete ir; 1025 delete ir;
1026#endif 1026#endif
1027 topLevelWidget()->raise(); 1027 topLevelWidget()->raise();
1028 message( i18n("Beaming finished!") ); 1028 message( i18n("Beaming finished!") );
1029} 1029}
1030 1030
1031 1031
1032void KABCore::browse( const QString& url ) 1032void KABCore::browse( const QString& url )
1033{ 1033{
1034#ifndef KAB_EMBEDDED 1034#ifndef KAB_EMBEDDED
1035 kapp->invokeBrowser( url ); 1035 kapp->invokeBrowser( url );
1036#else //KAB_EMBEDDED 1036#else //KAB_EMBEDDED
1037 qDebug("KABCore::browse must be fixed"); 1037 qDebug("KABCore::browse must be fixed");
1038#endif //KAB_EMBEDDED 1038#endif //KAB_EMBEDDED
1039} 1039}
1040 1040
1041void KABCore::selectAllContacts() 1041void KABCore::selectAllContacts()
1042{ 1042{
1043 mViewManager->setSelected( QString::null, true ); 1043 mViewManager->setSelected( QString::null, true );
1044} 1044}
1045 1045
1046void KABCore::deleteContacts() 1046void KABCore::deleteContacts()
1047{ 1047{
1048 QStringList uidList = mViewManager->selectedUids(); 1048 QStringList uidList = mViewManager->selectedUids();
1049 deleteContacts( uidList ); 1049 deleteContacts( uidList );
1050} 1050}
1051 1051
1052void KABCore::deleteContacts( const QStringList &uids ) 1052void KABCore::deleteContacts( const QStringList &uids )
1053{ 1053{
1054 1054
1055 if ( uids.count() > 0 ) { 1055 if ( uids.count() > 0 ) {
1056 1056
1057 if ( KABPrefs::instance()->mAskForDelete ) { 1057 if ( KABPrefs::instance()->mAskForDelete ) {
1058 int count = uids.count(); 1058 int count = uids.count();
1059 if ( count > 5 ) count = 5; 1059 if ( count > 5 ) count = 5;
1060 QString cNames; 1060 QString cNames;
1061 int i; 1061 int i;
1062 for ( i = 0; i < count ; ++i ) { 1062 for ( i = 0; i < count ; ++i ) {
1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1064 } 1064 }
1065 if ( uids.count() > 5 ) 1065 if ( uids.count() > 5 )
1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1069 return; 1069 return;
1070 } 1070 }
1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1072 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1073 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1074 1074
1075 // now if we deleted anything, refresh 1075 // now if we deleted anything, refresh
1076 setContactSelected( QString::null ); 1076 setContactSelected( QString::null );
1077 setModified( true ); 1077 setModified( true );
1078 } 1078 }
1079} 1079}
1080 1080
1081void KABCore::copyContacts() 1081void KABCore::copyContacts()
1082{ 1082{
1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1084 1084
1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1086 1086
1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1088 1088
1089 QClipboard *cb = QApplication::clipboard(); 1089 QClipboard *cb = QApplication::clipboard();
1090 cb->setText( clipText ); 1090 cb->setText( clipText );
1091} 1091}
1092 1092
1093void KABCore::cutContacts() 1093void KABCore::cutContacts()
1094{ 1094{
1095 QStringList uidList = mViewManager->selectedUids(); 1095 QStringList uidList = mViewManager->selectedUids();
1096 1096
1097//US if ( uidList.size() > 0 ) { 1097//US if ( uidList.size() > 0 ) {
1098 if ( uidList.count() > 0 ) { 1098 if ( uidList.count() > 0 ) {
1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1100 UndoStack::instance()->push( command ); 1100 UndoStack::instance()->push( command );
1101 RedoStack::instance()->clear(); 1101 RedoStack::instance()->clear();
1102 1102
1103 setModified( true ); 1103 setModified( true );
1104 } 1104 }
1105} 1105}
1106 1106
1107void KABCore::pasteContacts() 1107void KABCore::pasteContacts()
1108{ 1108{
1109 QClipboard *cb = QApplication::clipboard(); 1109 QClipboard *cb = QApplication::clipboard();
1110 1110
1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1112 1112
1113 pasteContacts( list ); 1113 pasteContacts( list );
1114} 1114}
1115 1115
1116void KABCore::pasteContacts( KABC::Addressee::List &list ) 1116void KABCore::pasteContacts( KABC::Addressee::List &list )
1117{ 1117{
1118 KABC::Resource *resource = requestResource( this ); 1118 KABC::Resource *resource = requestResource( this );
1119 KABC::Addressee::List::Iterator it; 1119 KABC::Addressee::List::Iterator it;
1120 for ( it = list.begin(); it != list.end(); ++it ) 1120 for ( it = list.begin(); it != list.end(); ++it )
1121 (*it).setResource( resource ); 1121 (*it).setResource( resource );
1122 1122
1123 PwPasteCommand *command = new PwPasteCommand( this, list ); 1123 PwPasteCommand *command = new PwPasteCommand( this, list );
1124 UndoStack::instance()->push( command ); 1124 UndoStack::instance()->push( command );
1125 RedoStack::instance()->clear(); 1125 RedoStack::instance()->clear();
1126 1126
1127 setModified( true ); 1127 setModified( true );
1128} 1128}
1129 1129
1130void KABCore::setWhoAmI() 1130void KABCore::setWhoAmI()
1131{ 1131{
1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1133 1133
1134 if ( addrList.count() > 1 ) { 1134 if ( addrList.count() > 1 ) {
1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1136 return; 1136 return;
1137 } 1137 }
1138 1138
1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1142} 1142}
1143void KABCore::editCategories() 1143void KABCore::editCategories()
1144{ 1144{
1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1146 dlg.exec(); 1146 dlg.exec();
1147} 1147}
1148void KABCore::setCategories() 1148void KABCore::setCategories()
1149{ 1149{
1150 1150
1151 QStringList uids; 1151 QStringList uids;
1152 XXPortSelectDialog dlgx( this, false, this ); 1152 XXPortSelectDialog dlgx( this, false, this );
1153 if ( dlgx.exec() ) 1153 if ( dlgx.exec() )
1154 uids = dlgx.uids(); 1154 uids = dlgx.uids();
1155 else 1155 else
1156 return; 1156 return;
1157 if ( uids.isEmpty() ) 1157 if ( uids.isEmpty() )
1158 return; 1158 return;
1159 // qDebug("count %d ", uids.count()); 1159 // qDebug("count %d ", uids.count());
1160 1160
1161 1161
1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1163 if ( !dlg.exec() ) { 1163 if ( !dlg.exec() ) {
1164 message( i18n("Setting categories cancelled") ); 1164 message( i18n("Setting categories cancelled") );
1165 return; 1165 return;
1166 } 1166 }
1167 bool merge = false; 1167 bool merge = false;
1168 QString msg = i18n( "Merge with existing categories?" ); 1168 QString msg = i18n( "Merge with existing categories?" );
1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1170 merge = true; 1170 merge = true;
1171 1171
1172 message( i18n("Setting categories ... please wait!") ); 1172 message( i18n("Setting categories ... please wait!") );
1173 QStringList categories = dlg.selectedCategories(); 1173 QStringList categories = dlg.selectedCategories();
1174 1174
1175 //QStringList uids = mViewManager->selectedUids(); 1175 //QStringList uids = mViewManager->selectedUids();
1176 QStringList::Iterator it; 1176 QStringList::Iterator it;
1177 for ( it = uids.begin(); it != uids.end(); ++it ) { 1177 for ( it = uids.begin(); it != uids.end(); ++it ) {
1178 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1178 KABC::Addressee addr = mAddressBook->findByUid( *it );
1179 if ( !addr.isEmpty() ) { 1179 if ( !addr.isEmpty() ) {
1180 if ( !merge ) 1180 if ( !merge )
1181 addr.setCategories( categories ); 1181 addr.setCategories( categories );
1182 else { 1182 else {
1183 QStringList addrCategories = addr.categories(); 1183 QStringList addrCategories = addr.categories();
1184 QStringList::Iterator catIt; 1184 QStringList::Iterator catIt;
1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1186 if ( !addrCategories.contains( *catIt ) ) 1186 if ( !addrCategories.contains( *catIt ) )
1187 addrCategories.append( *catIt ); 1187 addrCategories.append( *catIt );
1188 } 1188 }
1189 addr.setCategories( addrCategories ); 1189 addr.setCategories( addrCategories );
1190 } 1190 }
1191 mAddressBook->insertAddressee( addr ); 1191 mAddressBook->insertAddressee( addr );
1192 } 1192 }
1193 } 1193 }
1194 1194
1195 if ( uids.count() > 0 ) 1195 if ( uids.count() > 0 )
1196 setModified( true ); 1196 setModified( true );
1197 message( i18n("Setting categories completed!") ); 1197 message( i18n("Setting categories completed!") );
1198} 1198}
1199 1199
1200void KABCore::setSearchFields( const KABC::Field::List &fields ) 1200void KABCore::setSearchFields( const KABC::Field::List &fields )
1201{ 1201{
1202 mIncSearchWidget->setFields( fields ); 1202 mIncSearchWidget->setFields( fields );
1203} 1203}
1204 1204
1205void KABCore::incrementalSearch( const QString& text ) 1205void KABCore::incrementalSearch( const QString& text )
1206{ 1206{
1207 QString stext; 1207 QString stext;
1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1209 stext = "*" + text; 1209 stext = "*" + text;
1210 } else { 1210 } else {
1211 stext = text; 1211 stext = text;
1212 } 1212 }
1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1214} 1214}
1215void KABCore::incrementalSearchJump( const QString& text ) 1215void KABCore::incrementalSearchJump( const QString& text )
1216{ 1216{
1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1218} 1218}
1219 1219
1220void KABCore::setModified() 1220void KABCore::setModified()
1221{ 1221{
1222 setModified( true ); 1222 setModified( true );
1223} 1223}
1224 1224
1225void KABCore::setModifiedWOrefresh() 1225void KABCore::setModifiedWOrefresh()
1226{ 1226{
1227 // qDebug("KABCore::setModifiedWOrefresh() "); 1227 // qDebug("KABCore::setModifiedWOrefresh() ");
1228 mModified = true; 1228 mModified = true;
1229 mActionSave->setEnabled( mModified ); 1229 mActionSave->setEnabled( mModified );
1230 1230
1231 1231
1232} 1232}
1233void KABCore::setModified( bool modified ) 1233void KABCore::setModified( bool modified )
1234{ 1234{
1235 mModified = modified; 1235 mModified = modified;
1236 mActionSave->setEnabled( mModified ); 1236 mActionSave->setEnabled( mModified );
1237 1237
1238 if ( modified ) 1238 if ( modified )
1239 mJumpButtonBar->recreateButtons(); 1239 mJumpButtonBar->recreateButtons();
1240 1240
1241 mViewManager->refreshView(); 1241 mViewManager->refreshView();
1242 1242
1243} 1243}
1244 1244
1245bool KABCore::modified() const 1245bool KABCore::modified() const
1246{ 1246{
1247 return mModified; 1247 return mModified;
1248} 1248}
1249 1249
1250void KABCore::contactModified( const KABC::Addressee &addr ) 1250void KABCore::contactModified( const KABC::Addressee &addr )
1251{ 1251{
1252 addrModified( addr ); 1252 addrModified( addr );
1253#if 0 // debug only 1253#if 0 // debug only
1254 KABC::Addressee ad = addr; 1254 KABC::Addressee ad = addr;
1255 ad.computeCsum( "123"); 1255 ad.computeCsum( "123");
1256#endif 1256#endif
1257} 1257}
1258 1258
1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1260{ 1260{
1261 1261
1262 Command *command = 0; 1262 Command *command = 0;
1263 QString uid; 1263 QString uid;
1264 1264
1265 // check if it exists already 1265 // check if it exists already
1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1267 if ( origAddr.isEmpty() ) 1267 if ( origAddr.isEmpty() )
1268 command = new PwNewCommand( mAddressBook, addr ); 1268 command = new PwNewCommand( mAddressBook, addr );
1269 else { 1269 else {
1270 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1270 command = new PwEditCommand( mAddressBook, origAddr, addr );
1271 uid = addr.uid(); 1271 uid = addr.uid();
1272 } 1272 }
1273 1273
1274 UndoStack::instance()->push( command ); 1274 UndoStack::instance()->push( command );
1275 RedoStack::instance()->clear(); 1275 RedoStack::instance()->clear();
1276 if ( updateDetails ) 1276 if ( updateDetails )
1277 mDetails->setAddressee( addr ); 1277 mDetails->setAddressee( addr );
1278 setModified( true ); 1278 setModified( true );
1279} 1279}
1280 1280
1281void KABCore::newContact() 1281void KABCore::newContact()
1282{ 1282{
1283 1283
1284 1284
1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1286 1286
1287 QPtrList<KRES::Resource> kresResources; 1287 QPtrList<KRES::Resource> kresResources;
1288 QPtrListIterator<KABC::Resource> it( kabcResources ); 1288 QPtrListIterator<KABC::Resource> it( kabcResources );
1289 KABC::Resource *resource; 1289 KABC::Resource *resource;
1290 while ( ( resource = it.current() ) != 0 ) { 1290 while ( ( resource = it.current() ) != 0 ) {
1291 ++it; 1291 ++it;
1292 if ( !resource->readOnly() ) { 1292 if ( !resource->readOnly() ) {
1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1294 if ( res ) 1294 if ( res )
1295 kresResources.append( res ); 1295 kresResources.append( res );
1296 } 1296 }
1297 } 1297 }
1298 1298
1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1300 resource = static_cast<KABC::Resource*>( res ); 1300 resource = static_cast<KABC::Resource*>( res );
1301 1301
1302 if ( resource ) { 1302 if ( resource ) {
1303 KABC::Addressee addr; 1303 KABC::Addressee addr;
1304 addr.setResource( resource ); 1304 addr.setResource( resource );
1305 mEditorDialog->setAddressee( addr ); 1305 mEditorDialog->setAddressee( addr );
1306 mEditorDialog->setCaption( i18n("Edit new contact")); 1306 mEditorDialog->setCaption( i18n("Edit new contact"));
1307 KApplication::execDialog ( mEditorDialog ); 1307 KApplication::execDialog ( mEditorDialog );
1308 1308
1309 } else 1309 } else
1310 return; 1310 return;
1311 1311
1312 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1312 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1313 1313
1314 1314
1315} 1315}
1316 1316
1317void KABCore::addEmail( QString aStr ) 1317void KABCore::addEmail( QString aStr )
1318{ 1318{
1319#ifndef KAB_EMBEDDED 1319#ifndef KAB_EMBEDDED
1320 QString fullName, email; 1320 QString fullName, email;
1321 1321
1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1323 1323
1324 // Try to lookup the addressee matching the email address 1324 // Try to lookup the addressee matching the email address
1325 bool found = false; 1325 bool found = false;
1326 QStringList emailList; 1326 QStringList emailList;
1327 KABC::AddressBook::Iterator it; 1327 KABC::AddressBook::Iterator it;
1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1329 emailList = (*it).emails(); 1329 emailList = (*it).emails();
1330 if ( emailList.contains( email ) > 0 ) { 1330 if ( emailList.contains( email ) > 0 ) {
1331 found = true; 1331 found = true;
1332 (*it).setNameFromString( fullName ); 1332 (*it).setNameFromString( fullName );
1333 editContact( (*it).uid() ); 1333 editContact( (*it).uid() );
1334 } 1334 }
1335 } 1335 }
1336 1336
1337 if ( !found ) { 1337 if ( !found ) {
1338 KABC::Addressee addr; 1338 KABC::Addressee addr;
1339 addr.setNameFromString( fullName ); 1339 addr.setNameFromString( fullName );
1340 addr.insertEmail( email, true ); 1340 addr.insertEmail( email, true );
1341 1341
1342 mAddressBook->insertAddressee( addr ); 1342 mAddressBook->insertAddressee( addr );
1343 mViewManager->refreshView( addr.uid() ); 1343 mViewManager->refreshView( addr.uid() );
1344 editContact( addr.uid() ); 1344 editContact( addr.uid() );
1345 } 1345 }
1346#else //KAB_EMBEDDED 1346#else //KAB_EMBEDDED
1347 qDebug("KABCore::addEmail finsih method"); 1347 qDebug("KABCore::addEmail finsih method");
1348#endif //KAB_EMBEDDED 1348#endif //KAB_EMBEDDED
1349} 1349}
1350 1350
1351void KABCore::importVCard( const KURL &url, bool showPreview ) 1351void KABCore::importVCard( const KURL &url, bool showPreview )
1352{ 1352{
1353 mXXPortManager->importVCard( url, showPreview ); 1353 mXXPortManager->importVCard( url, showPreview );
1354} 1354}
1355void KABCore::importFromOL() 1355void KABCore::importFromOL()
1356{ 1356{
1357#ifdef _OL_IMPORT_ 1357#ifdef _OL_IMPORT_
1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1359 idgl->exec(); 1359 idgl->exec();
1360 KABC::Addressee::List list = idgl->getAddressList(); 1360 KABC::Addressee::List list = idgl->getAddressList();
1361 if ( list.count() > 0 ) { 1361 if ( list.count() > 0 ) {
1362 KABC::Addressee::List listNew; 1362 KABC::Addressee::List listNew;
1363 KABC::Addressee::List listExisting; 1363 KABC::Addressee::List listExisting;
1364 KABC::Addressee::List::Iterator it; 1364 KABC::Addressee::List::Iterator it;
1365 KABC::AddressBook::Iterator iter; 1365 KABC::AddressBook::Iterator iter;
1366 for ( it = list.begin(); it != list.end(); ++it ) { 1366 for ( it = list.begin(); it != list.end(); ++it ) {
1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1368 listNew.append( (*it) ); 1368 listNew.append( (*it) );
1369 else 1369 else
1370 listExisting.append( (*it) ); 1370 listExisting.append( (*it) );
1371 } 1371 }
1372 if ( listExisting.count() > 0 ) 1372 if ( listExisting.count() > 0 )
1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1374 if ( listNew.count() > 0 ) { 1374 if ( listNew.count() > 0 ) {
1375 pasteWithNewUid = false; 1375 pasteWithNewUid = false;
1376 pasteContacts( listNew ); 1376 pasteContacts( listNew );
1377 pasteWithNewUid = true; 1377 pasteWithNewUid = true;
1378 } 1378 }
1379 } 1379 }
1380 delete idgl; 1380 delete idgl;
1381#endif 1381#endif
1382} 1382}
1383 1383
1384void KABCore::importVCard( const QString &vCard, bool showPreview ) 1384void KABCore::importVCard( const QString &vCard, bool showPreview )
1385{ 1385{
1386 mXXPortManager->importVCard( vCard, showPreview ); 1386 mXXPortManager->importVCard( vCard, showPreview );
1387} 1387}
1388 1388
1389//US added a second method without defaultparameter 1389//US added a second method without defaultparameter
1390void KABCore::editContact2() { 1390void KABCore::editContact2() {
1391 editContact( QString::null ); 1391 editContact( QString::null );
1392} 1392}
1393 1393
1394void KABCore::editContact( const QString &uid ) 1394void KABCore::editContact( const QString &uid )
1395{ 1395{
1396 1396
1397 if ( mExtensionManager->isQuickEditVisible() ) 1397 if ( mExtensionManager->isQuickEditVisible() )
1398 return; 1398 return;
1399 1399
1400 // First, locate the contact entry 1400 // First, locate the contact entry
1401 QString localUID = uid; 1401 QString localUID = uid;
1402 if ( localUID.isNull() ) { 1402 if ( localUID.isNull() ) {
1403 QStringList uidList = mViewManager->selectedUids(); 1403 QStringList uidList = mViewManager->selectedUids();
1404 if ( uidList.count() > 0 ) 1404 if ( uidList.count() > 0 )
1405 localUID = *( uidList.at( 0 ) ); 1405 localUID = *( uidList.at( 0 ) );
1406 } 1406 }
1407 1407
1408 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1408 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1409 if ( !addr.isEmpty() ) { 1409 if ( !addr.isEmpty() ) {
1410 mEditorDialog->setAddressee( addr ); 1410 mEditorDialog->setAddressee( addr );
1411 KApplication::execDialog ( mEditorDialog ); 1411 KApplication::execDialog ( mEditorDialog );
1412 } 1412 }
1413} 1413}
1414 1414
1415/** 1415/**
1416 Shows or edits the detail view for the given uid. If the uid is QString::null, 1416 Shows or edits the detail view for the given uid. If the uid is QString::null,
1417 the method will try to find a selected addressee in the view. 1417 the method will try to find a selected addressee in the view.
1418 */ 1418 */
1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1420{ 1420{
1421 if ( mMultipleViewsAtOnce ) 1421 if ( mMultipleViewsAtOnce )
1422 { 1422 {
1423 editContact( uid ); 1423 editContact( uid );
1424 } 1424 }
1425 else 1425 else
1426 { 1426 {
1427 setDetailsVisible( true ); 1427 setDetailsVisible( true );
1428 mActionDetails->setChecked(true); 1428 mActionDetails->setChecked(true);
1429 } 1429 }
1430 1430
1431} 1431}
1432 1432
1433void KABCore::save() 1433void KABCore::save()
1434{ 1434{
1435 if (syncManager->blockSave()) 1435 if (syncManager->blockSave())
1436 return; 1436 return;
1437 if ( !mModified ) 1437 if ( !mModified )
1438 return; 1438 return;
1439 1439
1440 syncManager->setBlockSave(true); 1440 syncManager->setBlockSave(true);
1441 QString text = i18n( "There was an error while attempting to save\n the " 1441 QString text = i18n( "There was an error while attempting to save\n the "
1442 "address book. Please check that some \nother application is " 1442 "address book. Please check that some \nother application is "
1443 "not using it. " ); 1443 "not using it. " );
1444 message(i18n("Saving ... please wait! "), false); 1444 message(i18n("Saving ... please wait! "), false);
1445 //qApp->processEvents(); 1445 //qApp->processEvents();
1446#ifndef KAB_EMBEDDED 1446#ifndef KAB_EMBEDDED
1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1448 if ( !b || !b->save() ) { 1448 if ( !b || !b->save() ) {
1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1450 } 1450 }
1451#else //KAB_EMBEDDED 1451#else //KAB_EMBEDDED
1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1453 if ( !b || !b->save() ) { 1453 if ( !b || !b->save() ) {
1454 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1454 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1455 } 1455 }
1456#endif //KAB_EMBEDDED 1456#endif //KAB_EMBEDDED
1457 1457
1458 message(i18n("Addressbook saved!")); 1458 message(i18n("Addressbook saved!"));
1459 setModified( false ); 1459 setModified( false );
1460 syncManager->setBlockSave(false); 1460 syncManager->setBlockSave(false);
1461} 1461}
1462 1462
1463 1463
1464void KABCore::undo() 1464void KABCore::undo()
1465{ 1465{
1466 UndoStack::instance()->undo(); 1466 UndoStack::instance()->undo();
1467 1467
1468 // Refresh the view 1468 // Refresh the view
1469 mViewManager->refreshView(); 1469 mViewManager->refreshView();
1470} 1470}
1471 1471
1472void KABCore::redo() 1472void KABCore::redo()
1473{ 1473{
1474 RedoStack::instance()->redo(); 1474 RedoStack::instance()->redo();
1475 1475
1476 // Refresh the view 1476 // Refresh the view
1477 mViewManager->refreshView(); 1477 mViewManager->refreshView();
1478} 1478}
1479void KABCore::setJumpButtonBar( bool visible ) 1479void KABCore::setJumpButtonBar( bool visible )
1480{ 1480{
1481 setJumpButtonBarVisible(visible ); 1481 setJumpButtonBarVisible(visible );
1482 saveSettings(); 1482 saveSettings();
1483} 1483}
1484void KABCore::setJumpButtonBarVisible( bool visible ) 1484void KABCore::setJumpButtonBarVisible( bool visible )
1485{ 1485{
1486 if (mMultipleViewsAtOnce) 1486 if (mMultipleViewsAtOnce)
1487 { 1487 {
1488 if ( visible ) 1488 if ( visible )
1489 mJumpButtonBar->show(); 1489 mJumpButtonBar->show();
1490 else 1490 else
1491 mJumpButtonBar->hide(); 1491 mJumpButtonBar->hide();
1492 } 1492 }
1493 else 1493 else
1494 { 1494 {
1495 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1495 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1496 if (mViewManager->isVisible()) 1496 if (mViewManager->isVisible())
1497 { 1497 {
1498 if ( visible ) 1498 if ( visible )
1499 mJumpButtonBar->show(); 1499 mJumpButtonBar->show();
1500 else 1500 else
1501 mJumpButtonBar->hide(); 1501 mJumpButtonBar->hide();
1502 } 1502 }
1503 else 1503 else
1504 { 1504 {
1505 mJumpButtonBar->hide(); 1505 mJumpButtonBar->hide();
1506 } 1506 }
1507 } 1507 }
1508 if ( visible ) { 1508 if ( visible ) {
1509 if ( mIncSearchWidget->currentItem() == 0 ) { 1509 if ( mIncSearchWidget->currentItem() == 0 ) {
1510 message( i18n("Change search field enable jump bar") ); 1510 message( i18n("Change search field enable jump bar") );
1511 } 1511 }
1512 } 1512 }
1513} 1513}
1514 1514
1515 1515
1516void KABCore::setDetailsToState() 1516void KABCore::setDetailsToState()
1517{ 1517{
1518 setDetailsVisible( mActionDetails->isChecked() ); 1518 setDetailsVisible( mActionDetails->isChecked() );
1519} 1519}
1520void KABCore::setDetailsToggle() 1520void KABCore::setDetailsToggle()
1521{ 1521{
1522 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1522 mActionDetails->setChecked( !mActionDetails->isChecked() );
1523 setDetailsToState(); 1523 setDetailsToState();
1524} 1524}
1525 1525
1526 1526
1527 1527
1528void KABCore::setDetailsVisible( bool visible ) 1528void KABCore::setDetailsVisible( bool visible )
1529{ 1529{
1530 if (visible && mDetails->isHidden()) 1530 if (visible && mDetails->isHidden())
1531 { 1531 {
1532 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1532 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1533 if ( addrList.count() > 0 ) 1533 if ( addrList.count() > 0 )
1534 mDetails->setAddressee( addrList[ 0 ] ); 1534 mDetails->setAddressee( addrList[ 0 ] );
1535 } 1535 }
1536 1536
1537 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1537 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1538 // the listview and the detailview. We do that by changing the splitbar size. 1538 // the listview and the detailview. We do that by changing the splitbar size.
1539 if (mMultipleViewsAtOnce) 1539 if (mMultipleViewsAtOnce)
1540 { 1540 {
1541 if ( visible ) 1541 if ( visible )
1542 mDetails->show(); 1542 mDetails->show();
1543 else 1543 else
1544 mDetails->hide(); 1544 mDetails->hide();
1545 } 1545 }
1546 else 1546 else
1547 { 1547 {
1548 if ( visible ) { 1548 if ( visible ) {
1549 mViewManager->hide(); 1549 mViewManager->hide();
1550 mDetails->show(); 1550 mDetails->show();
1551 mIncSearchWidget->setFocus(); 1551 mIncSearchWidget->setFocus();
1552 } 1552 }
1553 else { 1553 else {
1554 mViewManager->show(); 1554 mViewManager->show();
1555 mDetails->hide(); 1555 mDetails->hide();
1556 mViewManager->setFocusAV(); 1556 mViewManager->setFocusAV();
1557 } 1557 }
1558 setJumpButtonBarVisible( !visible ); 1558 setJumpButtonBarVisible( !visible );
1559 } 1559 }
1560 1560
1561} 1561}
1562 1562
1563void KABCore::extensionChanged( int id ) 1563void KABCore::extensionChanged( int id )
1564{ 1564{
1565 //change the details view only for non desktop systems 1565 //change the details view only for non desktop systems
1566#ifndef DESKTOP_VERSION 1566#ifndef DESKTOP_VERSION
1567 1567
1568 if (id == 0) 1568 if (id == 0)
1569 { 1569 {
1570 //the user disabled the extension. 1570 //the user disabled the extension.
1571 1571
1572 if (mMultipleViewsAtOnce) 1572 if (mMultipleViewsAtOnce)
1573 { // enable detailsview again 1573 { // enable detailsview again
1574 setDetailsVisible( true ); 1574 setDetailsVisible( true );
1575 mActionDetails->setChecked( true ); 1575 mActionDetails->setChecked( true );
1576 } 1576 }
1577 else 1577 else
1578 { //go back to the listview 1578 { //go back to the listview
1579 setDetailsVisible( false ); 1579 setDetailsVisible( false );
1580 mActionDetails->setChecked( false ); 1580 mActionDetails->setChecked( false );
1581 mActionDetails->setEnabled(true); 1581 mActionDetails->setEnabled(true);
1582 } 1582 }
1583 1583
1584 } 1584 }
1585 else 1585 else
1586 { 1586 {
1587 //the user enabled the extension. 1587 //the user enabled the extension.
1588 setDetailsVisible( false ); 1588 setDetailsVisible( false );
1589 mActionDetails->setChecked( false ); 1589 mActionDetails->setChecked( false );
1590 1590
1591 if (!mMultipleViewsAtOnce) 1591 if (!mMultipleViewsAtOnce)
1592 { 1592 {
1593 mActionDetails->setEnabled(false); 1593 mActionDetails->setEnabled(false);
1594 } 1594 }
1595 1595
1596 mExtensionManager->setSelectionChanged(); 1596 mExtensionManager->setSelectionChanged();
1597 1597
1598 } 1598 }
1599 1599
1600#endif// DESKTOP_VERSION 1600#endif// DESKTOP_VERSION
1601 1601
1602} 1602}
1603 1603
1604 1604
1605void KABCore::extensionModified( const KABC::Addressee::List &list ) 1605void KABCore::extensionModified( const KABC::Addressee::List &list )
1606{ 1606{
1607 1607
1608 if ( list.count() != 0 ) { 1608 if ( list.count() != 0 ) {
1609 KABC::Addressee::List::ConstIterator it; 1609 KABC::Addressee::List::ConstIterator it;
1610 for ( it = list.begin(); it != list.end(); ++it ) 1610 for ( it = list.begin(); it != list.end(); ++it )
1611 mAddressBook->insertAddressee( *it ); 1611 mAddressBook->insertAddressee( *it );
1612 if ( list.count() > 1 ) 1612 if ( list.count() > 1 )
1613 setModified(); 1613 setModified();
1614 else 1614 else
1615 setModifiedWOrefresh(); 1615 setModifiedWOrefresh();
1616 } 1616 }
1617 if ( list.count() == 0 ) 1617 if ( list.count() == 0 )
1618 mViewManager->refreshView(); 1618 mViewManager->refreshView();
1619 else 1619 else
1620 mViewManager->refreshView( list[ 0 ].uid() ); 1620 mViewManager->refreshView( list[ 0 ].uid() );
1621 1621
1622 1622
1623 1623
1624} 1624}
1625 1625
1626QString KABCore::getNameByPhone( const QString &phone ) 1626QString KABCore::getNameByPhone( const QString &phone )
1627{ 1627{
1628#ifndef KAB_EMBEDDED 1628#ifndef KAB_EMBEDDED
1629 QRegExp r( "[/*/-/ ]" ); 1629 QRegExp r( "[/*/-/ ]" );
1630 QString localPhone( phone ); 1630 QString localPhone( phone );
1631 1631
1632 bool found = false; 1632 bool found = false;
1633 QString ownerName = ""; 1633 QString ownerName = "";
1634 KABC::AddressBook::Iterator iter; 1634 KABC::AddressBook::Iterator iter;
1635 KABC::PhoneNumber::List::Iterator phoneIter; 1635 KABC::PhoneNumber::List::Iterator phoneIter;
1636 KABC::PhoneNumber::List phoneList; 1636 KABC::PhoneNumber::List phoneList;
1637 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1637 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1638 phoneList = (*iter).phoneNumbers(); 1638 phoneList = (*iter).phoneNumbers();
1639 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1639 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1640 ++phoneIter) { 1640 ++phoneIter) {
1641 // Get rid of separator chars so just the numbers are compared. 1641 // Get rid of separator chars so just the numbers are compared.
1642 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1642 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1643 ownerName = (*iter).formattedName(); 1643 ownerName = (*iter).formattedName();
1644 found = true; 1644 found = true;
1645 } 1645 }
1646 } 1646 }
1647 } 1647 }
1648 1648
1649 return ownerName; 1649 return ownerName;
1650#else //KAB_EMBEDDED 1650#else //KAB_EMBEDDED
1651 qDebug("KABCore::getNameByPhone finsih method"); 1651 qDebug("KABCore::getNameByPhone finsih method");
1652 return ""; 1652 return "";
1653#endif //KAB_EMBEDDED 1653#endif //KAB_EMBEDDED
1654 1654
1655} 1655}
1656void KABCore::openConfigGlobalDialog() 1656void KABCore::openConfigGlobalDialog()
1657{ 1657{
1658 KPimPrefsGlobalDialog gc ( this ); 1658 KPimPrefsGlobalDialog gc ( this );
1659 gc.exec(); 1659 gc.exec();
1660} 1660}
1661void KABCore::openConfigDialog() 1661void KABCore::openConfigDialog()
1662{ 1662{
1663 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1663 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1664 1664
1665 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1665 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1666 ConfigureDialog->setMainWidget( kabcfg ); 1666 ConfigureDialog->setMainWidget( kabcfg );
1667 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1667 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1668 this, SLOT( configurationChanged() ) ); 1668 this, SLOT( configurationChanged() ) );
1669 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1669 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1670 kabcfg, SLOT( save() ) ); 1670 kabcfg, SLOT( save() ) );
1671 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1671 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1672 this, SLOT( configurationChanged() ) ); 1672 this, SLOT( configurationChanged() ) );
1673 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1673 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1674 kabcfg, SLOT( save() ) ); 1674 kabcfg, SLOT( save() ) );
1675 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1675 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1676 kabcfg, SLOT( defaults() ) ); 1676 kabcfg, SLOT( defaults() ) );
1677 saveSettings(); 1677 saveSettings();
1678 kabcfg->load(); 1678 kabcfg->load();
1679#ifndef DESKTOP_VERSION 1679#ifndef DESKTOP_VERSION
1680 if ( QApplication::desktop()->height() <= 480 ) 1680 if ( QApplication::desktop()->height() <= 480 )
1681 ConfigureDialog->hideButtons(); 1681 ConfigureDialog->hideButtons();
1682 ConfigureDialog->showMaximized(); 1682 ConfigureDialog->showMaximized();
1683#endif 1683#endif
1684 if ( ConfigureDialog->exec() ) 1684 if ( ConfigureDialog->exec() )
1685 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1685 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1686 delete ConfigureDialog; 1686 delete ConfigureDialog;
1687} 1687}
1688 1688
1689void KABCore::openLDAPDialog() 1689void KABCore::openLDAPDialog()
1690{ 1690{
1691#ifndef KAB_EMBEDDED 1691#ifndef KAB_EMBEDDED
1692 if ( !mLdapSearchDialog ) { 1692 if ( !mLdapSearchDialog ) {
1693 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1693 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1694 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1694 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1695 SLOT( refreshView() ) ); 1695 SLOT( refreshView() ) );
1696 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1696 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1697 SLOT( setModified() ) ); 1697 SLOT( setModified() ) );
1698 } else 1698 } else
1699 mLdapSearchDialog->restoreSettings(); 1699 mLdapSearchDialog->restoreSettings();
1700 1700
1701 if ( mLdapSearchDialog->isOK() ) 1701 if ( mLdapSearchDialog->isOK() )
1702 mLdapSearchDialog->exec(); 1702 mLdapSearchDialog->exec();
1703#else //KAB_EMBEDDED 1703#else //KAB_EMBEDDED
1704 qDebug("KABCore::openLDAPDialog() finsih method"); 1704 qDebug("KABCore::openLDAPDialog() finsih method");
1705#endif //KAB_EMBEDDED 1705#endif //KAB_EMBEDDED
1706} 1706}
1707 1707
1708void KABCore::print() 1708void KABCore::print()
1709{ 1709{
1710#ifndef KAB_EMBEDDED 1710#ifndef KAB_EMBEDDED
1711 KPrinter printer; 1711 KPrinter printer;
1712 if ( !printer.setup( this ) ) 1712 if ( !printer.setup( this ) )
1713 return; 1713 return;
1714 1714
1715 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1715 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1716 mViewManager->selectedUids(), this ); 1716 mViewManager->selectedUids(), this );
1717 1717
1718 wizard.exec(); 1718 wizard.exec();
1719#else //KAB_EMBEDDED 1719#else //KAB_EMBEDDED
1720 qDebug("KABCore::print() finsih method"); 1720 qDebug("KABCore::print() finsih method");
1721#endif //KAB_EMBEDDED 1721#endif //KAB_EMBEDDED
1722 1722
1723} 1723}
1724 1724
1725 1725
1726void KABCore::addGUIClient( KXMLGUIClient *client ) 1726void KABCore::addGUIClient( KXMLGUIClient *client )
1727{ 1727{
1728 if ( mGUIClient ) 1728 if ( mGUIClient )
1729 mGUIClient->insertChildClient( client ); 1729 mGUIClient->insertChildClient( client );
1730 else 1730 else
1731 KMessageBox::error( this, "no KXMLGUICLient"); 1731 KMessageBox::error( this, "no KXMLGUICLient");
1732} 1732}
1733 1733
1734 1734
1735void KABCore::configurationChanged() 1735void KABCore::configurationChanged()
1736{ 1736{
1737 mExtensionManager->reconfigure(); 1737 mExtensionManager->reconfigure();
1738} 1738}
1739 1739
1740void KABCore::addressBookChanged() 1740void KABCore::addressBookChanged()
1741{ 1741{
1742/*US 1742/*US
1743 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1743 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1744 while ( it.current() ) { 1744 while ( it.current() ) {
1745 if ( it.current()->dirty() ) { 1745 if ( it.current()->dirty() ) {
1746 QString text = i18n( "Data has been changed externally. Unsaved " 1746 QString text = i18n( "Data has been changed externally. Unsaved "
1747 "changes will be lost." ); 1747 "changes will be lost." );
1748 KMessageBox::information( this, text ); 1748 KMessageBox::information( this, text );
1749 } 1749 }
1750 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1750 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1751 ++it; 1751 ++it;
1752 } 1752 }
1753*/ 1753*/
1754 if (mEditorDialog) 1754 if (mEditorDialog)
1755 { 1755 {
1756 if (mEditorDialog->dirty()) 1756 if (mEditorDialog->dirty())
1757 { 1757 {
1758 QString text = i18n( "Data has been changed externally. Unsaved " 1758 QString text = i18n( "Data has been changed externally. Unsaved "
1759 "changes will be lost." ); 1759 "changes will be lost." );
1760 KMessageBox::information( this, text ); 1760 KMessageBox::information( this, text );
1761 } 1761 }
1762 QString currentuid = mEditorDialog->addressee().uid(); 1762 QString currentuid = mEditorDialog->addressee().uid();
1763 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1763 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1764 } 1764 }
1765 mViewManager->refreshView(); 1765 mViewManager->refreshView();
1766 1766
1767 1767
1768} 1768}
1769 1769
1770AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1770AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1771 const char *name ) 1771 const char *name )
1772{ 1772{
1773 1773
1774 if ( mEditorDialog == 0 ) { 1774 if ( mEditorDialog == 0 ) {
1775 mEditorDialog = new AddresseeEditorDialog( this, parent, 1775 mEditorDialog = new AddresseeEditorDialog( this, parent,
1776 name ? name : "editorDialog" ); 1776 name ? name : "editorDialog" );
1777 1777
1778 1778
1779 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1779 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1780 SLOT( contactModified( const KABC::Addressee& ) ) ); 1780 SLOT( contactModified( const KABC::Addressee& ) ) );
1781 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1781 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1782 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1782 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1783 } 1783 }
1784 1784
1785 return mEditorDialog; 1785 return mEditorDialog;
1786} 1786}
1787 1787
1788void KABCore::slotEditorDestroyed( const QString &uid ) 1788void KABCore::slotEditorDestroyed( const QString &uid )
1789{ 1789{
1790 //mEditorDict.remove( uid ); 1790 //mEditorDict.remove( uid );
1791} 1791}
1792 1792
1793void KABCore::initGUI() 1793void KABCore::initGUI()
1794{ 1794{
1795#ifndef KAB_EMBEDDED 1795#ifndef KAB_EMBEDDED
1796 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1796 QHBoxLayout *topLayout = new QHBoxLayout( this );
1797 topLayout->setSpacing( KDialogBase::spacingHint() ); 1797 topLayout->setSpacing( KDialogBase::spacingHint() );
1798 1798
1799 mExtensionBarSplitter = new QSplitter( this ); 1799 mExtensionBarSplitter = new QSplitter( this );
1800 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1800 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1801 1801
1802 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1802 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1803 1803
1804 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1804 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1805 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1805 mIncSearchWidget = new IncSearchWidget( viewSpace );
1806 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1806 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1807 SLOT( incrementalSearch( const QString& ) ) ); 1807 SLOT( incrementalSearch( const QString& ) ) );
1808 1808
1809 mViewManager = new ViewManager( this, viewSpace ); 1809 mViewManager = new ViewManager( this, viewSpace );
1810 viewSpace->setStretchFactor( mViewManager, 1 ); 1810 viewSpace->setStretchFactor( mViewManager, 1 );
1811 1811
1812 mDetails = new ViewContainer( mDetailsSplitter ); 1812 mDetails = new ViewContainer( mDetailsSplitter );
1813 1813
1814 mJumpButtonBar = new JumpButtonBar( this, this ); 1814 mJumpButtonBar = new JumpButtonBar( this, this );
1815 1815
1816 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1816 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1817 1817
1818 topLayout->addWidget( mExtensionBarSplitter ); 1818 topLayout->addWidget( mExtensionBarSplitter );
1819 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1819 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1820 topLayout->addWidget( mJumpButtonBar ); 1820 topLayout->addWidget( mJumpButtonBar );
1821 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1821 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1822 1822
1823 mXXPortManager = new XXPortManager( this, this ); 1823 mXXPortManager = new XXPortManager( this, this );
1824 1824
1825#else //KAB_EMBEDDED 1825#else //KAB_EMBEDDED
1826 //US initialize viewMenu before settingup viewmanager. 1826 //US initialize viewMenu before settingup viewmanager.
1827 // Viewmanager needs this menu to plugin submenues. 1827 // Viewmanager needs this menu to plugin submenues.
1828 viewMenu = new QPopupMenu( this ); 1828 viewMenu = new QPopupMenu( this );
1829 settingsMenu = new QPopupMenu( this ); 1829 settingsMenu = new QPopupMenu( this );
1830 //filterMenu = new QPopupMenu( this ); 1830 //filterMenu = new QPopupMenu( this );
1831 ImportMenu = new QPopupMenu( this ); 1831 ImportMenu = new QPopupMenu( this );
1832 ExportMenu = new QPopupMenu( this ); 1832 ExportMenu = new QPopupMenu( this );
1833 syncMenu = new QPopupMenu( this ); 1833 syncMenu = new QPopupMenu( this );
1834 changeMenu= new QPopupMenu( this ); 1834 changeMenu= new QPopupMenu( this );
1835 beamMenu= new QPopupMenu( this ); 1835 beamMenu= new QPopupMenu( this );
1836 1836
1837//US since we have no splitter for the embedded system, setup 1837//US since we have no splitter for the embedded system, setup
1838// a layout with two frames. One left and one right. 1838// a layout with two frames. One left and one right.
1839 1839
1840 QBoxLayout *topLayout; 1840 QBoxLayout *topLayout;
1841 1841
1842 // = new QHBoxLayout( this ); 1842 // = new QHBoxLayout( this );
1843// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1843// QBoxLayout *topLayout = (QBoxLayout*)layout();
1844 1844
1845// QWidget *mainBox = new QWidget( this ); 1845// QWidget *mainBox = new QWidget( this );
1846// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1846// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1847 1847
1848#ifdef DESKTOP_VERSION 1848#ifdef DESKTOP_VERSION
1849 topLayout = new QHBoxLayout( this ); 1849 topLayout = new QHBoxLayout( this );
1850 1850
1851 1851
1852 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1852 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1853 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1853 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1854 1854
1855 topLayout->addWidget(mMiniSplitter ); 1855 topLayout->addWidget(mMiniSplitter );
1856 1856
1857 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1857 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1858 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1858 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1859 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1859 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1860 mDetails = new ViewContainer( mMiniSplitter ); 1860 mDetails = new ViewContainer( mMiniSplitter );
1861 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1861 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1862#else 1862#else
1863 if ( QApplication::desktop()->width() > 480 ) { 1863 if ( QApplication::desktop()->width() > 480 ) {
1864 topLayout = new QHBoxLayout( this ); 1864 topLayout = new QHBoxLayout( this );
1865 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1865 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1866 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1866 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1867 } else { 1867 } else {
1868 1868
1869 topLayout = new QHBoxLayout( this ); 1869 topLayout = new QHBoxLayout( this );
1870 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1870 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1871 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1871 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1872 } 1872 }
1873 1873
1874 topLayout->addWidget(mMiniSplitter ); 1874 topLayout->addWidget(mMiniSplitter );
1875 mViewManager = new ViewManager( this, mMiniSplitter ); 1875 mViewManager = new ViewManager( this, mMiniSplitter );
1876 mDetails = new ViewContainer( mMiniSplitter ); 1876 mDetails = new ViewContainer( mMiniSplitter );
1877 1877
1878 1878
1879 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1879 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1880#endif 1880#endif
1881 //eh->hide(); 1881 //eh->hide();
1882 // topLayout->addWidget(mExtensionManager ); 1882 // topLayout->addWidget(mExtensionManager );
1883 1883
1884 1884
1885/*US 1885/*US
1886#ifndef KAB_NOSPLITTER 1886#ifndef KAB_NOSPLITTER
1887 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1887 QHBoxLayout *topLayout = new QHBoxLayout( this );
1888//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1888//US topLayout->setSpacing( KDialogBase::spacingHint() );
1889 topLayout->setSpacing( 10 ); 1889 topLayout->setSpacing( 10 );
1890 1890
1891 mDetailsSplitter = new QSplitter( this ); 1891 mDetailsSplitter = new QSplitter( this );
1892 1892
1893 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1893 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1894 1894
1895 mViewManager = new ViewManager( this, viewSpace ); 1895 mViewManager = new ViewManager( this, viewSpace );
1896 viewSpace->setStretchFactor( mViewManager, 1 ); 1896 viewSpace->setStretchFactor( mViewManager, 1 );
1897 1897
1898 mDetails = new ViewContainer( mDetailsSplitter ); 1898 mDetails = new ViewContainer( mDetailsSplitter );
1899 1899
1900 topLayout->addWidget( mDetailsSplitter ); 1900 topLayout->addWidget( mDetailsSplitter );
1901 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1901 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1902#else //KAB_NOSPLITTER 1902#else //KAB_NOSPLITTER
1903 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1903 QHBoxLayout *topLayout = new QHBoxLayout( this );
1904//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1904//US topLayout->setSpacing( KDialogBase::spacingHint() );
1905 topLayout->setSpacing( 10 ); 1905 topLayout->setSpacing( 10 );
1906 1906
1907// mDetailsSplitter = new QSplitter( this ); 1907// mDetailsSplitter = new QSplitter( this );
1908 1908
1909 QVBox *viewSpace = new QVBox( this ); 1909 QVBox *viewSpace = new QVBox( this );
1910 1910
1911 mViewManager = new ViewManager( this, viewSpace ); 1911 mViewManager = new ViewManager( this, viewSpace );
1912 viewSpace->setStretchFactor( mViewManager, 1 ); 1912 viewSpace->setStretchFactor( mViewManager, 1 );
1913 1913
1914 mDetails = new ViewContainer( this ); 1914 mDetails = new ViewContainer( this );
1915 1915
1916 topLayout->addWidget( viewSpace ); 1916 topLayout->addWidget( viewSpace );
1917// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1917// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1918 topLayout->addWidget( mDetails ); 1918 topLayout->addWidget( mDetails );
1919#endif //KAB_NOSPLITTER 1919#endif //KAB_NOSPLITTER
1920*/ 1920*/
1921 1921
1922 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1922 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1923 syncManager->setBlockSave(false); 1923 syncManager->setBlockSave(false);
1924 1924
1925 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1925 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1926 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1926 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1927 QString sync_file = sentSyncFile(); 1927 QString sync_file = sentSyncFile();
1928 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1928 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1929 syncManager->setDefaultFileName( sync_file ); 1929 syncManager->setDefaultFileName( sync_file );
1930 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1930 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1931 1931
1932#endif //KAB_EMBEDDED 1932#endif //KAB_EMBEDDED
1933 initActions(); 1933 initActions();
1934 1934
1935#ifdef KAB_EMBEDDED 1935#ifdef KAB_EMBEDDED
1936 addActionsManually(); 1936 addActionsManually();
1937 //US make sure the export and import menues are initialized before creating the xxPortManager. 1937 //US make sure the export and import menues are initialized before creating the xxPortManager.
1938 mXXPortManager = new XXPortManager( this, this ); 1938 mXXPortManager = new XXPortManager( this, this );
1939 1939
1940 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1940 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1941 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1941 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1942 // mActionQuit->plug ( mMainWindow->toolBar()); 1942 // mActionQuit->plug ( mMainWindow->toolBar());
1943 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1943 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1944 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1944 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1945 // mIncSearchWidget->hide(); 1945 // mIncSearchWidget->hide();
1946 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1946 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1947 SLOT( incrementalSearch( const QString& ) ) ); 1947 SLOT( incrementalSearch( const QString& ) ) );
1948 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1948 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1949 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1949 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1950 1950
1951 mJumpButtonBar = new JumpButtonBar( this, this ); 1951 mJumpButtonBar = new JumpButtonBar( this, this );
1952 1952
1953 topLayout->addWidget( mJumpButtonBar ); 1953 topLayout->addWidget( mJumpButtonBar );
1954//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1954//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1955 1955
1956// mMainWindow->getIconToolBar()->raise(); 1956// mMainWindow->getIconToolBar()->raise();
1957 1957
1958#endif //KAB_EMBEDDED 1958#endif //KAB_EMBEDDED
1959 1959
1960} 1960}
1961void KABCore::initActions() 1961void KABCore::initActions()
1962{ 1962{
1963//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1963//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1964 1964
1965#ifndef KAB_EMBEDDED 1965#ifndef KAB_EMBEDDED
1966 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1966 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1967 SLOT( clipboardDataChanged() ) ); 1967 SLOT( clipboardDataChanged() ) );
1968#endif //KAB_EMBEDDED 1968#endif //KAB_EMBEDDED
1969 1969
1970 // file menu 1970 // file menu
1971 1971
1972 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1972 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1973 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1973 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1974 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1974 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1975 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1975 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1976 1976
1977 1977
1978 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1978 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1979 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1979 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1980 1980
1981 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1981 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1982 SLOT( save() ), actionCollection(), "file_sync" ); 1982 SLOT( save() ), actionCollection(), "file_sync" );
1983 1983
1984 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1984 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1985 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1985 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1986 1986
1987 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1987 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1988 this, SLOT( mailVCard() ), 1988 this, SLOT( mailVCard() ),
1989 actionCollection(), "file_mail_vcard"); 1989 actionCollection(), "file_mail_vcard");
1990 1990
1991 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1991 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1992 SLOT( export2phone() ), actionCollection(), 1992 SLOT( export2phone() ), actionCollection(),
1993 "kaddressbook_ex2phone" ); 1993 "kaddressbook_ex2phone" );
1994 1994
1995 mActionBeamVCard = 0; 1995 mActionBeamVCard = 0;
1996 mActionBeam = 0; 1996 mActionBeam = 0;
1997 1997
1998#ifndef DESKTOP_VERSION 1998#ifndef DESKTOP_VERSION
1999 if ( Ir::supported() ) { 1999 if ( Ir::supported() ) {
2000 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2000 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2001 SLOT( beamVCard() ), actionCollection(), 2001 SLOT( beamVCard() ), actionCollection(),
2002 "kaddressbook_beam_vcard" ); 2002 "kaddressbook_beam_vcard" );
2003 2003
2004 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2004 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2005 SLOT( beamMySelf() ), actionCollection(), 2005 SLOT( beamMySelf() ), actionCollection(),
2006 "kaddressbook_beam_myself" ); 2006 "kaddressbook_beam_myself" );
2007 } 2007 }
2008#endif 2008#endif
2009 2009
2010 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2010 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2011 this, SLOT( editContact2() ), 2011 this, SLOT( editContact2() ),
2012 actionCollection(), "file_properties" ); 2012 actionCollection(), "file_properties" );
2013 2013
2014#ifdef KAB_EMBEDDED 2014#ifdef KAB_EMBEDDED
2015 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2015 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2016 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2016 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2017 mMainWindow, SLOT( exit() ), 2017 mMainWindow, SLOT( exit() ),
2018 actionCollection(), "quit" ); 2018 actionCollection(), "quit" );
2019#endif //KAB_EMBEDDED 2019#endif //KAB_EMBEDDED
2020 2020
2021 // edit menu 2021 // edit menu
2022 if ( mIsPart ) { 2022 if ( mIsPart ) {
2023 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2023 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2024 SLOT( copyContacts() ), actionCollection(), 2024 SLOT( copyContacts() ), actionCollection(),
2025 "kaddressbook_copy" ); 2025 "kaddressbook_copy" );
2026 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2026 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2027 SLOT( cutContacts() ), actionCollection(), 2027 SLOT( cutContacts() ), actionCollection(),
2028 "kaddressbook_cut" ); 2028 "kaddressbook_cut" );
2029 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2029 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2030 SLOT( pasteContacts() ), actionCollection(), 2030 SLOT( pasteContacts() ), actionCollection(),
2031 "kaddressbook_paste" ); 2031 "kaddressbook_paste" );
2032 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2032 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2033 SLOT( selectAllContacts() ), actionCollection(), 2033 SLOT( selectAllContacts() ), actionCollection(),
2034 "kaddressbook_select_all" ); 2034 "kaddressbook_select_all" );
2035 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2035 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2036 SLOT( undo() ), actionCollection(), 2036 SLOT( undo() ), actionCollection(),
2037 "kaddressbook_undo" ); 2037 "kaddressbook_undo" );
2038 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2038 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2039 this, SLOT( redo() ), actionCollection(), 2039 this, SLOT( redo() ), actionCollection(),
2040 "kaddressbook_redo" ); 2040 "kaddressbook_redo" );
2041 } else { 2041 } else {
2042 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2042 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2043 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2043 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2044 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2044 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2045 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2045 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2046 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2046 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2047 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2047 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2048 } 2048 }
2049 2049
2050 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2050 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2051 Key_Delete, this, SLOT( deleteContacts() ), 2051 Key_Delete, this, SLOT( deleteContacts() ),
2052 actionCollection(), "edit_delete" ); 2052 actionCollection(), "edit_delete" );
2053 2053
2054 mActionUndo->setEnabled( false ); 2054 mActionUndo->setEnabled( false );
2055 mActionRedo->setEnabled( false ); 2055 mActionRedo->setEnabled( false );
2056 2056
2057 // settings menu 2057 // settings menu
2058#ifdef KAB_EMBEDDED 2058#ifdef KAB_EMBEDDED
2059//US special menuentry to configure the addressbook resources. On KDE 2059//US special menuentry to configure the addressbook resources. On KDE
2060// you do that through the control center !!! 2060// you do that through the control center !!!
2061 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2061 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2062 SLOT( configureResources() ), actionCollection(), 2062 SLOT( configureResources() ), actionCollection(),
2063 "kaddressbook_configure_resources" ); 2063 "kaddressbook_configure_resources" );
2064#endif //KAB_EMBEDDED 2064#endif //KAB_EMBEDDED
2065 2065
2066 if ( mIsPart ) { 2066 if ( mIsPart ) {
2067 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2067 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2068 SLOT( openConfigDialog() ), actionCollection(), 2068 SLOT( openConfigDialog() ), actionCollection(),
2069 "kaddressbook_configure" ); 2069 "kaddressbook_configure" );
2070 2070
2071 //US not implemented yet 2071 //US not implemented yet
2072 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2072 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2073 // this, SLOT( configureKeyBindings() ), actionCollection(), 2073 // this, SLOT( configureKeyBindings() ), actionCollection(),
2074 // "kaddressbook_configure_shortcuts" ); 2074 // "kaddressbook_configure_shortcuts" );
2075#ifdef KAB_EMBEDDED 2075#ifdef KAB_EMBEDDED
2076 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2076 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2077 mActionConfigureToolbars->setEnabled( false ); 2077 mActionConfigureToolbars->setEnabled( false );
2078#endif //KAB_EMBEDDED 2078#endif //KAB_EMBEDDED
2079 2079
2080 } else { 2080 } else {
2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2082 SLOT( openConfigDialog() ), actionCollection(), 2082 SLOT( openConfigDialog() ), actionCollection(),
2083 "kaddressbook_configure" ); 2083 "kaddressbook_configure" );
2084 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2084 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2085 SLOT( openConfigGlobalDialog() ), actionCollection(), 2085 SLOT( openConfigGlobalDialog() ), actionCollection(),
2086 "kaddressbook_configure" ); 2086 "kaddressbook_configure" );
2087 } 2087 }
2088 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2088 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2089 actionCollection(), "options_show_jump_bar" ); 2089 actionCollection(), "options_show_jump_bar" );
2090 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2090 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2091 2091
2092 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2092 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2093 actionCollection(), "options_show_details" ); 2093 actionCollection(), "options_show_details" );
2094 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2094 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2095 2095
2096 2096
2097 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2097 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2098 SLOT( toggleBeamReceive() ), actionCollection(), 2098 SLOT( toggleBeamReceive() ), actionCollection(),
2099 "kaddressbook_beam_rec" ); 2099 "kaddressbook_beam_rec" );
2100 2100
2101 2101
2102 // misc 2102 // misc
2103 // only enable LDAP lookup if we can handle the protocol 2103 // only enable LDAP lookup if we can handle the protocol
2104#ifndef KAB_EMBEDDED 2104#ifndef KAB_EMBEDDED
2105 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2105 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2106 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2106 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2107 this, SLOT( openLDAPDialog() ), actionCollection(), 2107 this, SLOT( openLDAPDialog() ), actionCollection(),
2108 "ldap_lookup" ); 2108 "ldap_lookup" );
2109 } 2109 }
2110#else //KAB_EMBEDDED 2110#else //KAB_EMBEDDED
2111 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2111 //qDebug("KABCore::initActions() LDAP has to be implemented");
2112#endif //KAB_EMBEDDED 2112#endif //KAB_EMBEDDED
2113 2113
2114 2114
2115 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2115 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2116 SLOT( setWhoAmI() ), actionCollection(), 2116 SLOT( setWhoAmI() ), actionCollection(),
2117 "set_personal" ); 2117 "set_personal" );
2118 2118
2119 2119
2120 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2120 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2121 SLOT( setCategories() ), actionCollection(), 2121 SLOT( setCategories() ), actionCollection(),
2122 "edit_set_categories" ); 2122 "edit_set_categories" );
2123 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2123 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2124 SLOT( editCategories() ), actionCollection(), 2124 SLOT( editCategories() ), actionCollection(),
2125 "edit__categories" ); 2125 "edit__categories" );
2126 2126
2127 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2127 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2128 SLOT( removeVoice() ), actionCollection(), 2128 SLOT( removeVoice() ), actionCollection(),
2129 "remove_voice" ); 2129 "remove_voice" );
2130 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2130 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2131 SLOT( setFormattedName() ), actionCollection(), 2131 SLOT( setFormattedName() ), actionCollection(),
2132 "set_formatted" ); 2132 "set_formatted" );
2133 2133
2134 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2134 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2135 SLOT( manageCategories() ), actionCollection(), 2135 SLOT( manageCategories() ), actionCollection(),
2136 "remove_voice" ); 2136 "remove_voice" );
2137 2137
2138 2138
2139 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2139 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2140 SLOT( importFromOL() ), actionCollection(), 2140 SLOT( importFromOL() ), actionCollection(),
2141 "import_OL" ); 2141 "import_OL" );
2142#ifdef KAB_EMBEDDED 2142#ifdef KAB_EMBEDDED
2143 mActionLicence = new KAction( i18n( "Licence" ), 0, 2143 mActionLicence = new KAction( i18n( "Licence" ), 0,
2144 this, SLOT( showLicence() ), actionCollection(), 2144 this, SLOT( showLicence() ), actionCollection(),
2145 "licence_about_data" ); 2145 "licence_about_data" );
2146 mActionFaq = new KAction( i18n( "Faq" ), 0, 2146 mActionFaq = new KAction( i18n( "Faq" ), 0,
2147 this, SLOT( faq() ), actionCollection(), 2147 this, SLOT( faq() ), actionCollection(),
2148 "faq_about_data" ); 2148 "faq_about_data" );
2149 mActionWN = new KAction( i18n( "What's New?" ), 0, 2149 mActionWN = new KAction( i18n( "What's New?" ), 0,
2150 this, SLOT( whatsnew() ), actionCollection(), 2150 this, SLOT( whatsnew() ), actionCollection(),
2151 "wn" ); 2151 "wn" );
2152 2152
2153 2153
2154 2154
2155 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2155 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2156 this, SLOT( storagehowto() ), actionCollection(), 2156 this, SLOT( storagehowto() ), actionCollection(),
2157 "storage" ); 2157 "storage" );
2158 2158
2159 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2159 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2160 this, SLOT( synchowto() ), actionCollection(), 2160 this, SLOT( synchowto() ), actionCollection(),
2161 "sync" ); 2161 "sync" );
2162 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2162 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2163 this, SLOT( kdesynchowto() ), actionCollection(), 2163 this, SLOT( kdesynchowto() ), actionCollection(),
2164 "kdesync" ); 2164 "kdesync" );
2165 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2165 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2166 this, SLOT( multisynchowto() ), actionCollection(), 2166 this, SLOT( multisynchowto() ), actionCollection(),
2167 "multisync" ); 2167 "multisync" );
2168 2168
2169 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2169 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2170 this, SLOT( createAboutData() ), actionCollection(), 2170 this, SLOT( createAboutData() ), actionCollection(),
2171 "kaddressbook_about_data" ); 2171 "kaddressbook_about_data" );
2172#endif //KAB_EMBEDDED 2172#endif //KAB_EMBEDDED
2173 2173
2174 clipboardDataChanged(); 2174 clipboardDataChanged();
2175 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2175 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2176 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2176 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2177} 2177}
2178 2178
2179//US we need this function, to plug all actions into the correct menues. 2179//US we need this function, to plug all actions into the correct menues.
2180// KDE uses a XML format to plug the actions, but we work her without this overhead. 2180// KDE uses a XML format to plug the actions, but we work her without this overhead.
2181void KABCore::addActionsManually() 2181void KABCore::addActionsManually()
2182{ 2182{
2183//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2183//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2184 2184
2185#ifdef KAB_EMBEDDED 2185#ifdef KAB_EMBEDDED
2186 QPopupMenu *fileMenu = new QPopupMenu( this ); 2186 QPopupMenu *fileMenu = new QPopupMenu( this );
2187 QPopupMenu *editMenu = new QPopupMenu( this ); 2187 QPopupMenu *editMenu = new QPopupMenu( this );
2188 QPopupMenu *helpMenu = new QPopupMenu( this ); 2188 QPopupMenu *helpMenu = new QPopupMenu( this );
2189 2189
2190 KToolBar* tb = mMainWindow->toolBar(); 2190 KToolBar* tb = mMainWindow->toolBar();
2191 mMainWindow->setToolBarsMovable (false ); 2191 mMainWindow->setToolBarsMovable (false );
2192#ifndef DESKTOP_VERSION 2192#ifndef DESKTOP_VERSION
2193 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2193 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2194#endif 2194#endif
2195 QMenuBar* mb = mMainWindow->menuBar(); 2195 QMenuBar* mb = mMainWindow->menuBar();
2196 2196
2197 //US setup menubar. 2197 //US setup menubar.
2198 //Disable the following block if you do not want to have a menubar. 2198 //Disable the following block if you do not want to have a menubar.
2199 mb->insertItem( i18n("&File"), fileMenu ); 2199 mb->insertItem( i18n("&File"), fileMenu );
2200 mb->insertItem( i18n("&Edit"), editMenu ); 2200 mb->insertItem( i18n("&Edit"), editMenu );
2201 mb->insertItem( i18n("&View"), viewMenu ); 2201 mb->insertItem( i18n("&View"), viewMenu );
2202 mb->insertItem( i18n("&Settings"), settingsMenu ); 2202 mb->insertItem( i18n("&Settings"), settingsMenu );
2203#ifdef DESKTOP_VERSION 2203#ifdef DESKTOP_VERSION
2204 mb->insertItem( i18n("Synchronize"), syncMenu ); 2204 mb->insertItem( i18n("Synchronize"), syncMenu );
2205#else 2205#else
2206 mb->insertItem( i18n("Sync"), syncMenu ); 2206 mb->insertItem( i18n("Sync"), syncMenu );
2207#endif 2207#endif
2208 //mb->insertItem( i18n("&Change"), changeMenu ); 2208 //mb->insertItem( i18n("&Change"), changeMenu );
2209 mb->insertItem( i18n("&Help"), helpMenu ); 2209 mb->insertItem( i18n("&Help"), helpMenu );
2210 mIncSearchWidget = new IncSearchWidget( tb ); 2210 mIncSearchWidget = new IncSearchWidget( tb );
2211 // tb->insertWidget(-1, 0, mIncSearchWidget); 2211 // tb->insertWidget(-1, 0, mIncSearchWidget);
2212#ifndef DESKTOP_VERSION 2212#ifndef DESKTOP_VERSION
2213 } else { 2213 } else {
2214 //US setup toolbar 2214 //US setup toolbar
2215 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2215 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2216 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2216 QPopupMenu *popupBarTB = new QPopupMenu( this );
2217 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2217 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2218 tb->insertWidget(-1, 0, menuBarTB); 2218 tb->insertWidget(-1, 0, menuBarTB);
2219 mIncSearchWidget = new IncSearchWidget( tb ); 2219 mIncSearchWidget = new IncSearchWidget( tb );
2220 tb->enableMoving(false); 2220 tb->enableMoving(false);
2221 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2221 popupBarTB->insertItem( i18n("&File"), fileMenu );
2222 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2222 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2223 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2223 popupBarTB->insertItem( i18n("&View"), viewMenu );
2224 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2224 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2225 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2225 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2226 mViewManager->getFilterAction()->plug ( popupBarTB); 2226 mViewManager->getFilterAction()->plug ( popupBarTB);
2227 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2227 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2228 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2228 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2229 if (QApplication::desktop()->width() > 320 ) { 2229 if (QApplication::desktop()->width() > 320 ) {
2230 // mViewManager->getFilterAction()->plug ( tb); 2230 // mViewManager->getFilterAction()->plug ( tb);
2231 } 2231 }
2232 } 2232 }
2233#endif 2233#endif
2234 mIncSearchWidget->setSize(); 2234 mIncSearchWidget->setSize();
2235 // mActionQuit->plug ( mMainWindow->toolBar()); 2235 // mActionQuit->plug ( mMainWindow->toolBar());
2236 2236
2237 2237
2238 2238
2239 //US Now connect the actions with the menue entries. 2239 //US Now connect the actions with the menue entries.
2240#ifdef DESKTOP_VERSION 2240#ifdef DESKTOP_VERSION
2241 mActionPrint->plug( fileMenu ); 2241 mActionPrint->plug( fileMenu );
2242 mActionPrintDetails->plug( fileMenu ); 2242 mActionPrintDetails->plug( fileMenu );
2243 fileMenu->insertSeparator(); 2243 fileMenu->insertSeparator();
2244#endif 2244#endif
2245 mActionMail->plug( fileMenu ); 2245 mActionMail->plug( fileMenu );
2246 fileMenu->insertSeparator(); 2246 fileMenu->insertSeparator();
2247 2247
2248 mActionNewContact->plug( editMenu ); 2248 mActionNewContact->plug( editMenu );
2249 mActionNewContact->plug( tb ); 2249 mActionNewContact->plug( tb );
2250 2250
2251 mActionEditAddressee->plug( editMenu ); 2251 mActionEditAddressee->plug( editMenu );
2252 editMenu->insertSeparator(); 2252 editMenu->insertSeparator();
2253 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2253 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2254 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2254 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2255 mActionEditAddressee->plug( tb ); 2255 mActionEditAddressee->plug( tb );
2256 2256
2257 // fileMenu->insertSeparator(); 2257 // fileMenu->insertSeparator();
2258 mActionSave->plug( fileMenu ); 2258 mActionSave->plug( fileMenu );
2259 fileMenu->insertItem( "&Import", ImportMenu ); 2259 fileMenu->insertItem( "&Import", ImportMenu );
2260 fileMenu->insertItem( "&Export", ExportMenu ); 2260 fileMenu->insertItem( "&Export", ExportMenu );
2261 editMenu->insertItem( i18n("&Change"), changeMenu ); 2261 editMenu->insertItem( i18n("&Change"), changeMenu );
2262 editMenu->insertSeparator(); 2262 editMenu->insertSeparator();
2263#ifndef DESKTOP_VERSION 2263#ifndef DESKTOP_VERSION
2264 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2264 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2265#endif 2265#endif
2266#if 0 2266#if 0
2267 // PENDING fix MailVCard 2267 // PENDING fix MailVCard
2268 fileMenu->insertSeparator(); 2268 fileMenu->insertSeparator();
2269 mActionMailVCard->plug( fileMenu ); 2269 mActionMailVCard->plug( fileMenu );
2270#endif 2270#endif
2271#ifndef DESKTOP_VERSION 2271#ifndef DESKTOP_VERSION
2272 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2272 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2273 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2273 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2274 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2274 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2275#endif 2275#endif
2276 fileMenu->insertSeparator(); 2276 fileMenu->insertSeparator();
2277 mActionQuit->plug( fileMenu ); 2277 mActionQuit->plug( fileMenu );
2278#ifdef _OL_IMPORT_ 2278#ifdef _OL_IMPORT_
2279 mActionImportOL->plug( ImportMenu ); 2279 mActionImportOL->plug( ImportMenu );
2280#endif 2280#endif
2281 // edit menu 2281 // edit menu
2282 mActionUndo->plug( editMenu ); 2282 mActionUndo->plug( editMenu );
2283 mActionRedo->plug( editMenu ); 2283 mActionRedo->plug( editMenu );
2284 editMenu->insertSeparator(); 2284 editMenu->insertSeparator();
2285 mActionCut->plug( editMenu ); 2285 mActionCut->plug( editMenu );
2286 mActionCopy->plug( editMenu ); 2286 mActionCopy->plug( editMenu );
2287 mActionPaste->plug( editMenu ); 2287 mActionPaste->plug( editMenu );
2288 mActionDelete->plug( editMenu ); 2288 mActionDelete->plug( editMenu );
2289 editMenu->insertSeparator(); 2289 editMenu->insertSeparator();
2290 mActionSelectAll->plug( editMenu ); 2290 mActionSelectAll->plug( editMenu );
2291 2291
2292 mActionSetFormattedName->plug( changeMenu ); 2292 mActionSetFormattedName->plug( changeMenu );
2293 mActionRemoveVoice->plug( changeMenu ); 2293 mActionRemoveVoice->plug( changeMenu );
2294 // settingsmings menu 2294 // settingsmings menu
2295//US special menuentry to configure the addressbook resources. On KDE 2295//US special menuentry to configure the addressbook resources. On KDE
2296// you do that through the control center !!! 2296// you do that through the control center !!!
2297 // settingsMenu->insertSeparator(); 2297 // settingsMenu->insertSeparator();
2298 2298
2299 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2299 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2300 mActionConfigGlobal->plug( settingsMenu, 1 ); 2300 mActionConfigGlobal->plug( settingsMenu, 1 );
2301 mActionConfigResources->plug( settingsMenu,2 ); 2301 mActionConfigResources->plug( settingsMenu,2 );
2302 settingsMenu->insertSeparator(3); 2302 settingsMenu->insertSeparator(3);
2303 2303
2304 if ( mIsPart ) { 2304 if ( mIsPart ) {
2305 //US not implemented yet 2305 //US not implemented yet
2306 //mActionConfigShortcuts->plug( settingsMenu ); 2306 //mActionConfigShortcuts->plug( settingsMenu );
2307 //mActionConfigureToolbars->plug( settingsMenu ); 2307 //mActionConfigureToolbars->plug( settingsMenu );
2308 2308
2309 } else { 2309 } else {
2310 //US not implemented yet 2310 //US not implemented yet
2311 //mActionKeyBindings->plug( settingsMenu ); 2311 //mActionKeyBindings->plug( settingsMenu );
2312 } 2312 }
2313 2313
2314 mActionEditCategories->plug( settingsMenu ); 2314 mActionEditCategories->plug( settingsMenu );
2315 mActionManageCategories->plug( settingsMenu ); 2315 mActionManageCategories->plug( settingsMenu );
2316 mActionJumpBar->plug( viewMenu,0 ); 2316 mActionJumpBar->plug( viewMenu,0 );
2317 mActionDetails->plug( viewMenu,0 ); 2317 mActionDetails->plug( viewMenu,0 );
2318 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2318 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2319 mActionDetails->plug( tb ); 2319 mActionDetails->plug( tb );
2320 settingsMenu->insertSeparator(); 2320 settingsMenu->insertSeparator();
2321#ifndef DESKTOP_VERSION 2321#ifndef DESKTOP_VERSION
2322 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2322 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2323 settingsMenu->insertSeparator(); 2323 settingsMenu->insertSeparator();
2324#endif 2324#endif
2325 2325
2326 mActionWhoAmI->plug( settingsMenu ); 2326 mActionWhoAmI->plug( settingsMenu );
2327 //mActionEditCategories->plug( changeMenu ); 2327 //mActionEditCategories->plug( changeMenu );
2328 mActionCategories->plug( changeMenu ); 2328 mActionCategories->plug( changeMenu );
2329 //mActionManageCategories->plug( changeMenu ); 2329 //mActionManageCategories->plug( changeMenu );
2330 2330
2331 //mActionCategories->plug( settingsMenu ); 2331 //mActionCategories->plug( settingsMenu );
2332 2332
2333 2333
2334 mActionWN->plug( helpMenu ); 2334 mActionWN->plug( helpMenu );
2335 mActionStorageHowto->plug( helpMenu ); 2335 mActionStorageHowto->plug( helpMenu );
2336 mActionSyncHowto->plug( helpMenu ); 2336 mActionSyncHowto->plug( helpMenu );
2337 mActionKdeSyncHowto->plug( helpMenu ); 2337 mActionKdeSyncHowto->plug( helpMenu );
2338 mActionMultiSyncHowto->plug( helpMenu ); 2338 mActionMultiSyncHowto->plug( helpMenu );
2339 mActionFaq->plug( helpMenu ); 2339 mActionFaq->plug( helpMenu );
2340 mActionLicence->plug( helpMenu ); 2340 mActionLicence->plug( helpMenu );
2341 mActionAboutKAddressbook->plug( helpMenu ); 2341 mActionAboutKAddressbook->plug( helpMenu );
2342 2342
2343 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2343 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2344 2344
2345 mActionSave->plug( tb ); 2345 mActionSave->plug( tb );
2346 mViewManager->getFilterAction()->plug ( tb); 2346 mViewManager->getFilterAction()->plug ( tb);
2347 //LR hide filteraction on started in 480x640 2347 //LR hide filteraction on started in 480x640
2348 if (QApplication::desktop()->width() == 480 ) { 2348 if (QApplication::desktop()->width() == 480 ) {
2349 mViewManager->getFilterAction()->setComboWidth( 0 ); 2349 mViewManager->getFilterAction()->setComboWidth( 0 );
2350 } 2350 }
2351 mActionUndo->plug( tb ); 2351 mActionUndo->plug( tb );
2352 mActionDelete->plug( tb ); 2352 mActionDelete->plug( tb );
2353 mActionRedo->plug( tb ); 2353 mActionRedo->plug( tb );
2354 } else { 2354 } else {
2355 mActionSave->plug( tb ); 2355 mActionSave->plug( tb );
2356 tb->enableMoving(false); 2356 tb->enableMoving(false);
2357 } 2357 }
2358 //mActionQuit->plug ( tb ); 2358 //mActionQuit->plug ( tb );
2359 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2359 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2360 2360
2361 //US link the searchwidget first to this. 2361 //US link the searchwidget first to this.
2362 // The real linkage to the toolbar happens later. 2362 // The real linkage to the toolbar happens later.
2363//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2363//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2364//US tb->insertItem( mIncSearchWidget ); 2364//US tb->insertItem( mIncSearchWidget );
2365/*US 2365/*US
2366 mIncSearchWidget = new IncSearchWidget( tb ); 2366 mIncSearchWidget = new IncSearchWidget( tb );
2367 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2367 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2368 SLOT( incrementalSearch( const QString& ) ) ); 2368 SLOT( incrementalSearch( const QString& ) ) );
2369 2369
2370 mJumpButtonBar = new JumpButtonBar( this, this ); 2370 mJumpButtonBar = new JumpButtonBar( this, this );
2371 2371
2372//US topLayout->addWidget( mJumpButtonBar ); 2372//US topLayout->addWidget( mJumpButtonBar );
2373 this->layout()->add( mJumpButtonBar ); 2373 this->layout()->add( mJumpButtonBar );
2374*/ 2374*/
2375 2375
2376#endif //KAB_EMBEDDED 2376#endif //KAB_EMBEDDED
2377 2377
2378 mActionExport2phone->plug( ExportMenu ); 2378 mActionExport2phone->plug( ExportMenu );
2379 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2379 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2380 syncManager->fillSyncMenu(); 2380 syncManager->fillSyncMenu();
2381 2381
2382} 2382}
2383void KABCore::showLicence() 2383void KABCore::showLicence()
2384{ 2384{
2385 KApplication::showLicence(); 2385 KApplication::showLicence();
2386} 2386}
2387 2387
2388void KABCore::manageCategories( ) 2388void KABCore::manageCategories( )
2389{ 2389{
2390 KABCatPrefs* cp = new KABCatPrefs(); 2390 KABCatPrefs* cp = new KABCatPrefs();
2391 cp->show(); 2391 cp->show();
2392 int w =cp->sizeHint().width() ; 2392 int w =cp->sizeHint().width() ;
2393 int h = cp->sizeHint().height() ; 2393 int h = cp->sizeHint().height() ;
2394 int dw = QApplication::desktop()->width(); 2394 int dw = QApplication::desktop()->width();
2395 int dh = QApplication::desktop()->height(); 2395 int dh = QApplication::desktop()->height();
2396 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2396 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2397 if ( !cp->exec() ) { 2397 if ( !cp->exec() ) {
2398 delete cp; 2398 delete cp;
2399 return; 2399 return;
2400 } 2400 }
2401 int count = 0; 2401 int count = 0;
2402 int cc = 0; 2402 int cc = 0;
2403 message( i18n("Please wait, processing categories...")); 2403 message( i18n("Please wait, processing categories..."));
2404 if ( cp->addCat() ) { 2404 if ( cp->addCat() ) {
2405 KABC::AddressBook::Iterator it; 2405 KABC::AddressBook::Iterator it;
2406 QStringList catList = KABPrefs::instance()->mCustomCategories; 2406 QStringList catList = KABPrefs::instance()->mCustomCategories;
2407 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2407 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2408 ++cc; 2408 ++cc;
2409 if ( cc %10 == 0) 2409 if ( cc %10 == 0)
2410 message(i18n("Processing contact #%1").arg(cc)); 2410 message(i18n("Processing contact #%1").arg(cc));
2411 QStringList catIncList = (*it).categories(); 2411 QStringList catIncList = (*it).categories();
2412 int i; 2412 int i;
2413 for( i = 0; i< catIncList.count(); ++i ) { 2413 for( i = 0; i< catIncList.count(); ++i ) {
2414 if ( !catList.contains (catIncList[i])) { 2414 if ( !catList.contains (catIncList[i])) {
2415 catList.append( catIncList[i] ); 2415 catList.append( catIncList[i] );
2416 //qDebug("add cat %s ", catIncList[i].latin1()); 2416 //qDebug("add cat %s ", catIncList[i].latin1());
2417 ++count; 2417 ++count;
2418 } 2418 }
2419 } 2419 }
2420 } 2420 }
2421 catList.sort(); 2421 catList.sort();
2422 KABPrefs::instance()->mCustomCategories = catList; 2422 KABPrefs::instance()->mCustomCategories = catList;
2423 KABPrefs::instance()->writeConfig(); 2423 KABPrefs::instance()->writeConfig();
2424 message(QString::number( count )+ i18n(" categories added to list! ")); 2424 message(QString::number( count )+ i18n(" categories added to list! "));
2425 } else { 2425 } else {
2426 QStringList catList = KABPrefs::instance()->mCustomCategories; 2426 QStringList catList = KABPrefs::instance()->mCustomCategories;
2427 QStringList catIncList; 2427 QStringList catIncList;
2428 QStringList newCatList; 2428 QStringList newCatList;
2429 KABC::AddressBook::Iterator it; 2429 KABC::AddressBook::Iterator it;
2430 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2430 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2431 ++cc; 2431 ++cc;
2432 if ( cc %10 == 0) 2432 if ( cc %10 == 0)
2433 message(i18n("Processing contact #%1").arg(cc)); 2433 message(i18n("Processing contact #%1").arg(cc));
2434 QStringList catIncList = (*it).categories(); 2434 QStringList catIncList = (*it).categories();
2435 int i; 2435 int i;
2436 if ( catIncList.count() ) { 2436 if ( catIncList.count() ) {
2437 newCatList.clear(); 2437 newCatList.clear();
2438 for( i = 0; i< catIncList.count(); ++i ) { 2438 for( i = 0; i< catIncList.count(); ++i ) {
2439 if ( catList.contains (catIncList[i])) { 2439 if ( catList.contains (catIncList[i])) {
2440 newCatList.append( catIncList[i] ); 2440 newCatList.append( catIncList[i] );
2441 } 2441 }
2442 } 2442 }
2443 newCatList.sort(); 2443 newCatList.sort();
2444 (*it).setCategories( newCatList ); 2444 (*it).setCategories( newCatList );
2445 mAddressBook->insertAddressee( (*it) ); 2445 mAddressBook->insertAddressee( (*it) );
2446 } 2446 }
2447 } 2447 }
2448 setModified( true ); 2448 setModified( true );
2449 mViewManager->refreshView(); 2449 mViewManager->refreshView();
2450 message( i18n("Removing categories done!")); 2450 message( i18n("Removing categories done!"));
2451 } 2451 }
2452 delete cp; 2452 delete cp;
2453} 2453}
2454void KABCore::removeVoice() 2454void KABCore::removeVoice()
2455{ 2455{
2456 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 ) 2456 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 )
2457 return; 2457 return;
2458 XXPortSelectDialog dlg( this, false, this ); 2458 XXPortSelectDialog dlg( this, false, this );
2459 if ( !dlg.exec() ) 2459 if ( !dlg.exec() )
2460 return; 2460 return;
2461 mAddressBook->setUntagged(); 2461 mAddressBook->setUntagged();
2462 dlg.tagSelected(); 2462 dlg.tagSelected();
2463 message(i18n("Removing voice..."), false ); 2463 message(i18n("Removing voice..."), false );
2464 KABC::AddressBook::Iterator it; 2464 KABC::AddressBook::Iterator it;
2465 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2465 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2466 if ( (*it).tagged() ) { 2466 if ( (*it).tagged() ) {
2467 (*it).removeVoice(); 2467 (*it).removeVoice();
2468 } 2468 }
2469 } 2469 }
2470 message(i18n("Refreshing view...") ); 2470 message(i18n("Refreshing view...") );
2471 mViewManager->refreshView( "" ); 2471 mViewManager->refreshView( "" );
2472 Addressee add; 2472 Addressee add;
2473 mDetails->setAddressee( add ); 2473 mDetails->setAddressee( add );
2474 message(i18n("Remove voice completed!") ); 2474 message(i18n("Remove voice completed!") );
2475 2475
2476 2476
2477 2477
2478} 2478}
2479 2479
2480void KABCore::setFormattedName() 2480void KABCore::setFormattedName()
2481{ 2481{
2482 KABFormatPrefs setpref; 2482 KABFormatPrefs setpref;
2483 if ( !setpref.exec() ) { 2483 if ( !setpref.exec() ) {
2484 return; 2484 return;
2485 } 2485 }
2486 XXPortSelectDialog dlg( this, false, this ); 2486 XXPortSelectDialog dlg( this, false, this );
2487 if ( !dlg.exec() ) 2487 if ( !dlg.exec() )
2488 return; 2488 return;
2489 mAddressBook->setUntagged(); 2489 mAddressBook->setUntagged();
2490 dlg.tagSelected(); 2490 dlg.tagSelected();
2491 int count = 0; 2491 int count = 0;
2492 KABC::AddressBook::Iterator it; 2492 KABC::AddressBook::Iterator it;
2493 bool modified = false; 2493 bool modified = false;
2494 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2494 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2495 if ( (*it).tagged() ) { 2495 if ( (*it).tagged() ) {
2496 if ( (*it).uid().left( 2 ) == "la" ) 2496 if ( (*it).uid().left( 2 ) == "la" )
2497 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2497 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2498 continue; 2498 continue;
2499 ++count; 2499 ++count;
2500 if ( count %10 == 0 ) 2500 if ( count %10 == 0 )
2501 message(i18n("Changing contact #%1").arg( count ) ); 2501 message(i18n("Changing contact #%1").arg( count ) );
2502 QString fName; 2502 QString fName;
2503 if ( setpref.simple->isChecked() ) 2503 if ( setpref.simple->isChecked() )
2504 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2504 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2505 else if ( setpref.full->isChecked() ) 2505 else if ( setpref.full->isChecked() )
2506 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2506 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2507 else if ( setpref.reverse->isChecked() ) 2507 else if ( setpref.reverse->isChecked() )
2508 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2508 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2509 else 2509 else
2510 fName = (*it).organization(); 2510 fName = (*it).organization();
2511 if ( setpref.setCompany->isChecked() ) 2511 if ( setpref.setCompany->isChecked() )
2512 if ( fName.isEmpty() || fName =="," ) 2512 if ( fName.isEmpty() || fName =="," )
2513 fName = (*it).organization(); 2513 fName = (*it).organization();
2514 (*it).setFormattedName( fName ); 2514 (*it).setFormattedName( fName );
2515 (*it).setChanged( true ); 2515 (*it).setChanged( true );
2516 modified = true; 2516 modified = true;
2517 (*it).setRevision( QDateTime::currentDateTime() ); 2517 (*it).setRevision( QDateTime::currentDateTime() );
2518 } 2518 }
2519 } 2519 }
2520 message(i18n("Refreshing view...") ); 2520 message(i18n("Refreshing view...") );
2521 if ( modified ) 2521 if ( modified )
2522 setModified( true ); 2522 setModified( true );
2523 Addressee add; 2523 Addressee add;
2524 mDetails->setAddressee( add ); 2524 mDetails->setAddressee( add );
2525 if ( count == 0 ) 2525 if ( count == 0 )
2526 message(i18n("No contact changed!") ); 2526 message(i18n("No contact changed!") );
2527 else 2527 else
2528 message(i18n("%1 contacts changed!").arg( count ) ); 2528 message(i18n("%1 contacts changed!").arg( count ) );
2529} 2529}
2530 2530
2531void KABCore::clipboardDataChanged() 2531void KABCore::clipboardDataChanged()
2532{ 2532{
2533 2533
2534 if ( mReadWrite ) 2534 if ( mReadWrite )
2535 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2535 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2536 2536
2537} 2537}
2538 2538
2539void KABCore::updateActionMenu() 2539void KABCore::updateActionMenu()
2540{ 2540{
2541 UndoStack *undo = UndoStack::instance(); 2541 UndoStack *undo = UndoStack::instance();
2542 RedoStack *redo = RedoStack::instance(); 2542 RedoStack *redo = RedoStack::instance();
2543 2543
2544 if ( undo->isEmpty() ) 2544 if ( undo->isEmpty() )
2545 mActionUndo->setText( i18n( "Undo" ) ); 2545 mActionUndo->setText( i18n( "Undo" ) );
2546 else 2546 else
2547 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2547 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2548 2548
2549 mActionUndo->setEnabled( !undo->isEmpty() ); 2549 mActionUndo->setEnabled( !undo->isEmpty() );
2550 2550
2551 if ( !redo->top() ) 2551 if ( !redo->top() )
2552 mActionRedo->setText( i18n( "Redo" ) ); 2552 mActionRedo->setText( i18n( "Redo" ) );
2553 else 2553 else
2554 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2554 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2555 2555
2556 mActionRedo->setEnabled( !redo->isEmpty() ); 2556 mActionRedo->setEnabled( !redo->isEmpty() );
2557} 2557}
2558 2558
2559void KABCore::configureKeyBindings() 2559void KABCore::configureKeyBindings()
2560{ 2560{
2561#ifndef KAB_EMBEDDED 2561#ifndef KAB_EMBEDDED
2562 KKeyDialog::configure( actionCollection(), true ); 2562 KKeyDialog::configure( actionCollection(), true );
2563#else //KAB_EMBEDDED 2563#else //KAB_EMBEDDED
2564 qDebug("KABCore::configureKeyBindings() not implemented"); 2564 qDebug("KABCore::configureKeyBindings() not implemented");
2565#endif //KAB_EMBEDDED 2565#endif //KAB_EMBEDDED
2566} 2566}
2567 2567
2568#ifdef KAB_EMBEDDED 2568#ifdef KAB_EMBEDDED
2569void KABCore::configureResources() 2569void KABCore::configureResources()
2570{ 2570{
2571 KRES::KCMKResources dlg( this, "" , 0 ); 2571 KRES::KCMKResources dlg( this, "" , 0 );
2572 2572
2573 if ( !dlg.exec() ) 2573 if ( !dlg.exec() )
2574 return; 2574 return;
2575 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2575 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2576} 2576}
2577#endif //KAB_EMBEDDED 2577#endif //KAB_EMBEDDED
2578 2578
2579 2579
2580/* this method will be called through the QCop interface from Ko/Pi to select addresses 2580/* this method will be called through the QCop interface from Ko/Pi to select addresses
2581 * for the attendees list of an event. 2581 * for the attendees list of an event.
2582 */ 2582 */
2583void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2583void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2584{ 2584{
2585 qDebug("KABCore::requestForNameEmailUidList "); 2585 qDebug("KABCore::requestForNameEmailUidList ");
2586 bool ok = false; 2586 bool ok = false;
2587 mEmailSourceChannel = sourceChannel; 2587 mEmailSourceChannel = sourceChannel;
2588 mEmailSourceUID = uid; 2588 mEmailSourceUID = uid;
2589 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2589 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2590 //callContactdialog(); 2590 //callContactdialog();
2591#if 0 2591#if 0
2592 int wid = uid.toInt( &ok ); 2592 int wid = uid.toInt( &ok );
2593 qDebug("UID %s ", uid.latin1()); 2593 qDebug("UID %s ", uid.latin1());
2594 if ( ok ) { 2594 if ( ok ) {
2595 if ( wid != QApplication::desktop()->width() ) { 2595 if ( wid != QApplication::desktop()->width() ) {
2596 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2596 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2597 message( i18n("Resizing, please wait...") ); 2597 message( i18n("Resizing, please wait...") );
2598 mMainWindow->showMinimized(); 2598 mMainWindow->showMinimized();
2599 /* 2599 /*
2600 { 2600 {
2601 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2601 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2602 } 2602 }
2603 */ 2603 */
2604 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2604 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2605 return; 2605 return;
2606 } 2606 }
2607 2607
2608 } else { 2608 } else {
2609 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2609 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2610 } 2610 }
2611 callContactdialog(); 2611 callContactdialog();
2612 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2612 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2613#endif 2613#endif
2614} 2614}
2615void KABCore::resizeAndCallContactdialog() 2615void KABCore::resizeAndCallContactdialog()
2616{ 2616{
2617 updateMainWindow(); 2617 updateMainWindow();
2618 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2618 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2619} 2619}
2620 2620
2621void KABCore::doRingSync() 2621void KABCore::doRingSync()
2622{ 2622{
2623 topLevelWidget()->raise(); 2623 topLevelWidget()->raise();
2624 syncManager->multiSync( false ); 2624 syncManager->multiSync( false );
2625} 2625}
2626void KABCore::callContactdialog() 2626void KABCore::callContactdialog()
2627{ 2627{
2628 static bool running = false; 2628 static bool running = false;
2629 if (running) return; 2629 if (running) return;
2630 running = true; 2630 running = true;
2631 QStringList nameList; 2631 QStringList nameList;
2632 QStringList emailList; 2632 QStringList emailList;
2633 QStringList uidList; 2633 QStringList uidList;
2634 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2634 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2635 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2635 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2636 uint i=0; 2636 uint i=0;
2637 for (i=0; i < list.count(); i++) 2637 for (i=0; i < list.count(); i++)
2638 { 2638 {
2639 nameList.append(list[i].realName()); 2639 nameList.append(list[i].realName());
2640 emailList.append(list[i].preferredEmail()); 2640 emailList.append(list[i].preferredEmail());
2641 uidList.append(list[i].uid()); 2641 uidList.append(list[i].uid());
2642 } 2642 }
2643 QString uid = mEmailSourceUID; 2643 QString uid = mEmailSourceUID;
2644 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2644 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2645 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2645 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2646 running = false; 2646 running = false;
2647} 2647}
2648/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2648/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2649 * to put them into the calendar. 2649 * to put them into the calendar.
2650 */ 2650 */
2651void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2651void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2652{ 2652{
2653 // qDebug("KABCore::requestForBirthdayList"); 2653 // qDebug("KABCore::requestForBirthdayList");
2654 QStringList birthdayList; 2654 QStringList birthdayList;
2655 QStringList anniversaryList; 2655 QStringList anniversaryList;
2656 QStringList realNameList; 2656 QStringList realNameList;
2657 QStringList preferredEmailList; 2657 QStringList preferredEmailList;
2658 QStringList assembledNameList; 2658 QStringList assembledNameList;
2659 QStringList uidList; 2659 QStringList uidList;
2660 2660
2661 KABC::AddressBook::Iterator it; 2661 KABC::AddressBook::Iterator it;
2662 2662
2663 int count = 0; 2663 int count = 0;
2664 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2664 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2665 ++count; 2665 ++count;
2666 } 2666 }
2667 QProgressBar bar(count,0 ); 2667 QProgressBar bar(count,0 );
2668 int w = 300; 2668 int w = 300;
2669 if ( QApplication::desktop()->width() < 320 ) 2669 if ( QApplication::desktop()->width() < 320 )
2670 w = 220; 2670 w = 220;
2671 int h = bar.sizeHint().height() ; 2671 int h = bar.sizeHint().height() ;
2672 int dw = QApplication::desktop()->width(); 2672 int dw = QApplication::desktop()->width();
2673 int dh = QApplication::desktop()->height(); 2673 int dh = QApplication::desktop()->height();
2674 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2674 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2675 bar.show(); 2675 bar.show();
2676 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2676 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2677 qApp->processEvents(); 2677 qApp->processEvents();
2678 2678
2679 QDate bday; 2679 QDate bday;
2680 QString anni; 2680 QString anni;
2681 QString formattedbday; 2681 QString formattedbday;
2682 2682
2683 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2683 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2684 { 2684 {
2685 if ( ! bar.isVisible() ) 2685 if ( ! bar.isVisible() )
2686 return; 2686 return;
2687 bar.setProgress( count++ ); 2687 bar.setProgress( count++ );
2688 qApp->processEvents(); 2688 qApp->processEvents();
2689 bday = (*it).birthday().date(); 2689 bday = (*it).birthday().date();
2690 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2690 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2691 2691
2692 if ( bday.isValid() || !anni.isEmpty()) 2692 if ( bday.isValid() || !anni.isEmpty())
2693 { 2693 {
2694 if (bday.isValid()) 2694 if (bday.isValid())
2695 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2695 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2696 else 2696 else
2697 formattedbday = "NOTVALID"; 2697 formattedbday = "NOTVALID";
2698 if (anni.isEmpty()) 2698 if (anni.isEmpty())
2699 anni = "INVALID"; 2699 anni = "INVALID";
2700 2700
2701 birthdayList.append(formattedbday); 2701 birthdayList.append(formattedbday);
2702 anniversaryList.append(anni); //should be ISODate 2702 anniversaryList.append(anni); //should be ISODate
2703 realNameList.append((*it).realName()); 2703 realNameList.append((*it).realName());
2704 preferredEmailList.append((*it).preferredEmail()); 2704 preferredEmailList.append((*it).preferredEmail());
2705 assembledNameList.append((*it).realName()); 2705 assembledNameList.append((*it).realName());
2706 uidList.append((*it).uid()); 2706 uidList.append((*it).uid());
2707 2707
2708 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2708 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2709 } 2709 }
2710 } 2710 }
2711 2711
2712 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2712 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2713 2713
2714} 2714}
2715 2715
2716/* this method will be called through the QCop interface from other apps to show details of a contact. 2716/* this method will be called through the QCop interface from other apps to show details of a contact.
2717 */ 2717 */
2718void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2718void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2719{ 2719{
2720 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2720 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2721 2721
2722 QString foundUid = QString::null; 2722 QString foundUid = QString::null;
2723 if ( ! uid.isEmpty() ) { 2723 if ( ! uid.isEmpty() ) {
2724 Addressee adrr = mAddressBook->findByUid( uid ); 2724 Addressee adrr = mAddressBook->findByUid( uid );
2725 if ( !adrr.isEmpty() ) { 2725 if ( !adrr.isEmpty() ) {
2726 foundUid = uid; 2726 foundUid = uid;
2727 } 2727 }
2728 if ( email == "sendbacklist" ) { 2728 if ( email == "sendbacklist" ) {
2729 //qDebug("ssssssssssssssssssssssend "); 2729 //qDebug("ssssssssssssssssssssssend ");
2730 QStringList nameList; 2730 QStringList nameList;
2731 QStringList emailList; 2731 QStringList emailList;
2732 QStringList uidList; 2732 QStringList uidList;
2733 nameList.append(adrr.realName()); 2733 nameList.append(adrr.realName());
2734 emailList = adrr.emails(); 2734 emailList = adrr.emails();
2735 uidList.append( adrr.preferredEmail()); 2735 uidList.append( adrr.preferredEmail());
2736 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2736 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2737 return; 2737 return;
2738 } 2738 }
2739 2739
2740 } 2740 }
2741 2741
2742 if ( email == "sendbacklist" ) 2742 if ( email == "sendbacklist" )
2743 return; 2743 return;
2744 if (foundUid.isEmpty()) 2744 if (foundUid.isEmpty())
2745 { 2745 {
2746 //find the uid of the person first 2746 //find the uid of the person first
2747 Addressee::List namelist; 2747 Addressee::List namelist;
2748 Addressee::List emaillist; 2748 Addressee::List emaillist;
2749 2749
2750 if (!name.isEmpty()) 2750 if (!name.isEmpty())
2751 namelist = mAddressBook->findByName( name ); 2751 namelist = mAddressBook->findByName( name );
2752 2752
2753 if (!email.isEmpty()) 2753 if (!email.isEmpty())
2754 emaillist = mAddressBook->findByEmail( email ); 2754 emaillist = mAddressBook->findByEmail( email );
2755 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2755 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2756 //check if we have a match in Namelist and Emaillist 2756 //check if we have a match in Namelist and Emaillist
2757 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2757 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2758 foundUid = emaillist[0].uid(); 2758 foundUid = emaillist[0].uid();
2759 } 2759 }
2760 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2760 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2761 foundUid = namelist[0].uid(); 2761 foundUid = namelist[0].uid();
2762 else 2762 else
2763 { 2763 {
2764 for (int i = 0; i < namelist.count(); i++) 2764 for (int i = 0; i < namelist.count(); i++)
2765 { 2765 {
2766 for (int j = 0; j < emaillist.count(); j++) 2766 for (int j = 0; j < emaillist.count(); j++)
2767 { 2767 {
2768 if (namelist[i] == emaillist[j]) 2768 if (namelist[i] == emaillist[j])
2769 { 2769 {
2770 foundUid = namelist[i].uid(); 2770 foundUid = namelist[i].uid();
2771 } 2771 }
2772 } 2772 }
2773 } 2773 }
2774 } 2774 }
2775 } 2775 }
2776 else 2776 else
2777 { 2777 {
2778 foundUid = uid; 2778 foundUid = uid;
2779 } 2779 }
2780 2780
2781 if (!foundUid.isEmpty()) 2781 if (!foundUid.isEmpty())
2782 { 2782 {
2783 2783
2784 // raise Ka/Pi if it is in the background 2784 // raise Ka/Pi if it is in the background
2785#ifndef DESKTOP_VERSION 2785#ifndef DESKTOP_VERSION
2786#ifndef KORG_NODCOP 2786#ifndef KORG_NODCOP
2787 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2787 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2788#endif 2788#endif
2789#endif 2789#endif
2790 2790
2791 mMainWindow->showMaximized(); 2791 mMainWindow->showMaximized();
2792 mMainWindow-> raise(); 2792 mMainWindow-> raise();
2793 2793
2794 mViewManager->setSelected( "", false); 2794 mViewManager->setSelected( "", false);
2795 mViewManager->refreshView( "" ); 2795 mViewManager->refreshView( "" );
2796 mViewManager->setSelected( foundUid, true ); 2796 mViewManager->setSelected( foundUid, true );
2797 mViewManager->refreshView( foundUid ); 2797 mViewManager->refreshView( foundUid );
2798 2798
2799 if ( !mMultipleViewsAtOnce ) 2799 if ( !mMultipleViewsAtOnce )
2800 { 2800 {
2801 setDetailsVisible( true ); 2801 setDetailsVisible( true );
2802 mActionDetails->setChecked(true); 2802 mActionDetails->setChecked(true);
2803 } 2803 }
2804 } 2804 }
2805} 2805}
2806void KABCore::storagehowto() 2806void KABCore::storagehowto()
2807{ 2807{
2808 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2808 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2809} 2809}
2810void KABCore::whatsnew() 2810void KABCore::whatsnew()
2811{ 2811{
2812 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2812 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2813} 2813}
2814void KABCore::synchowto() 2814void KABCore::synchowto()
2815{ 2815{
2816 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2816 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2817} 2817}
2818void KABCore::kdesynchowto() 2818void KABCore::kdesynchowto()
2819{ 2819{
2820 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2820 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2821} 2821}
2822void KABCore::multisynchowto() 2822void KABCore::multisynchowto()
2823{ 2823{
2824 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2824 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2825} 2825}
2826void KABCore::faq() 2826void KABCore::faq()
2827{ 2827{
2828 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2828 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2829} 2829}
2830 2830
2831#include <libkcal/syncdefines.h> 2831#include <libkcal/syncdefines.h>
2832 2832
2833KABC::Addressee KABCore::getLastSyncAddressee() 2833KABC::Addressee KABCore::getLastSyncAddressee()
2834{ 2834{
2835 Addressee lse; 2835 Addressee lse;
2836 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2837 2837
2838 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2838 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2839 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2839 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2840 if (lse.isEmpty()) { 2840 if (lse.isEmpty()) {
2841 qDebug("KA: Creating new last-syncAddressee "); 2841 qDebug("KA: Creating new last-syncAddressee ");
2842 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2842 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2843 QString sum = ""; 2843 QString sum = "";
2844 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2844 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2845 sum = "E: "; 2845 sum = "E: ";
2846 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2846 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2847 lse.setRevision( mLastAddressbookSync ); 2847 lse.setRevision( mLastAddressbookSync );
2848 lse.setCategories( i18n("SyncEvent") ); 2848 lse.setCategories( i18n("SyncEvent") );
2849 mAddressBook->insertAddressee( lse ); 2849 mAddressBook->insertAddressee( lse );
2850 } 2850 }
2851 return lse; 2851 return lse;
2852} 2852}
2853int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2853int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2854{ 2854{
2855 2855
2856 //void setZaurusId(int id); 2856 //void setZaurusId(int id);
2857 // int zaurusId() const; 2857 // int zaurusId() const;
2858 // void setZaurusUid(int id); 2858 // void setZaurusUid(int id);
2859 // int zaurusUid() const; 2859 // int zaurusUid() const;
2860 // void setZaurusStat(int id); 2860 // void setZaurusStat(int id);
2861 // int zaurusStat() const; 2861 // int zaurusStat() const;
2862 // 0 equal 2862 // 0 equal
2863 // 1 take local 2863 // 1 take local
2864 // 2 take remote 2864 // 2 take remote
2865 // 3 cancel 2865 // 3 cancel
2866 QDateTime lastSync = mLastAddressbookSync; 2866 QDateTime lastSync = mLastAddressbookSync;
2867 QDateTime localMod = local->revision(); 2867 QDateTime localMod = local->revision();
2868 QDateTime remoteMod = remote->revision(); 2868 QDateTime remoteMod = remote->revision();
2869 2869
2870 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2870 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2871 2871
2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2873 bool remCh, locCh; 2873 bool remCh, locCh;
2874 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2874 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2875 //if ( remCh ) 2875 //if ( remCh )
2876 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2876 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2877 locCh = ( localMod > mLastAddressbookSync ); 2877 locCh = ( localMod > mLastAddressbookSync );
2878 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2878 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2879 if ( !remCh && ! locCh ) { 2879 if ( !remCh && ! locCh ) {
2880 //qDebug("both not changed "); 2880 //qDebug("both not changed ");
2881 lastSync = localMod.addDays(1); 2881 lastSync = localMod.addDays(1);
2882 if ( mode <= SYNC_PREF_ASK ) 2882 if ( mode <= SYNC_PREF_ASK )
2883 return 0; 2883 return 0;
2884 } else { 2884 } else {
2885 if ( locCh ) { 2885 if ( locCh ) {
2886 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2886 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2887 lastSync = localMod.addDays( -1 ); 2887 lastSync = localMod.addDays( -1 );
2888 if ( !remCh ) 2888 if ( !remCh )
2889 remoteMod =( lastSync.addDays( -1 ) ); 2889 remoteMod =( lastSync.addDays( -1 ) );
2890 } else { 2890 } else {
2891 //qDebug(" not loc changed "); 2891 //qDebug(" not loc changed ");
2892 lastSync = localMod.addDays( 1 ); 2892 lastSync = localMod.addDays( 1 );
2893 if ( remCh ) { 2893 if ( remCh ) {
2894 //qDebug("rem changed "); 2894 //qDebug("rem changed ");
2895 remoteMod =( lastSync.addDays( 1 ) ); 2895 remoteMod =( lastSync.addDays( 1 ) );
2896 } 2896 }
2897 2897
2898 } 2898 }
2899 } 2899 }
2900 full = true; 2900 full = true;
2901 if ( mode < SYNC_PREF_ASK ) 2901 if ( mode < SYNC_PREF_ASK )
2902 mode = SYNC_PREF_ASK; 2902 mode = SYNC_PREF_ASK;
2903 } else { 2903 } else {
2904 if ( localMod == remoteMod ) 2904 if ( localMod == remoteMod )
2905 return 0; 2905 return 0;
2906 2906
2907 } 2907 }
2908 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2908 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2909 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2909 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2910 //full = true; //debug only 2910 //full = true; //debug only
2911 if ( full ) { 2911 if ( full ) {
2912 bool equ = ( (*local) == (*remote) ); 2912 bool equ = ( (*local) == (*remote) );
2913 if ( equ ) { 2913 if ( equ ) {
2914 //qDebug("equal "); 2914 //qDebug("equal ");
2915 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2915 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2916 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2916 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2917 } 2917 }
2918 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2918 if ( mode < SYNC_PREF_FORCE_LOCAL )
2919 return 0; 2919 return 0;
2920 2920
2921 }//else //debug only 2921 }//else //debug only
2922 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2922 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2923 } 2923 }
2924 int result; 2924 int result;
2925 bool localIsNew; 2925 bool localIsNew;
2926 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2926 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2927 2927
2928 if ( full && mode < SYNC_PREF_NEWEST ) 2928 if ( full && mode < SYNC_PREF_NEWEST )
2929 mode = SYNC_PREF_ASK; 2929 mode = SYNC_PREF_ASK;
2930 2930
2931 switch( mode ) { 2931 switch( mode ) {
2932 case SYNC_PREF_LOCAL: 2932 case SYNC_PREF_LOCAL:
2933 if ( lastSync > remoteMod ) 2933 if ( lastSync > remoteMod )
2934 return 1; 2934 return 1;
2935 if ( lastSync > localMod ) 2935 if ( lastSync > localMod )
2936 return 2; 2936 return 2;
2937 return 1; 2937 return 1;
2938 break; 2938 break;
2939 case SYNC_PREF_REMOTE: 2939 case SYNC_PREF_REMOTE:
2940 if ( lastSync > localMod ) 2940 if ( lastSync > localMod )
2941 return 2; 2941 return 2;
2942 if ( lastSync > remoteMod ) 2942 if ( lastSync > remoteMod )
2943 return 1; 2943 return 1;
2944 return 2; 2944 return 2;
2945 break; 2945 break;
2946 case SYNC_PREF_NEWEST: 2946 case SYNC_PREF_NEWEST:
2947 if ( localMod > remoteMod ) 2947 if ( localMod > remoteMod )
2948 return 1; 2948 return 1;
2949 else 2949 else
2950 return 2; 2950 return 2;
2951 break; 2951 break;
2952 case SYNC_PREF_ASK: 2952 case SYNC_PREF_ASK:
2953 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2953 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2954 if ( lastSync > remoteMod && lastSync > localMod) 2954 if ( lastSync > remoteMod && lastSync > localMod)
2955 return 0; 2955 return 0;
2956 if ( lastSync > remoteMod ) 2956 if ( lastSync > remoteMod )
2957 return 1; 2957 return 1;
2958 if ( lastSync > localMod ) { 2958 if ( lastSync > localMod ) {
2959 return 2; 2959 return 2;
2960 } 2960 }
2961 localIsNew = localMod >= remoteMod; 2961 localIsNew = localMod >= remoteMod;
2962 //qDebug("conflict! ************************************** "); 2962 //qDebug("conflict! ************************************** ");
2963 { 2963 {
2964 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2964 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2965 result = acd.executeD(localIsNew); 2965 result = acd.executeD(localIsNew);
2966 return result; 2966 return result;
2967 } 2967 }
2968 break; 2968 break;
2969 case SYNC_PREF_FORCE_LOCAL: 2969 case SYNC_PREF_FORCE_LOCAL:
2970 return 1; 2970 return 1;
2971 break; 2971 break;
2972 case SYNC_PREF_FORCE_REMOTE: 2972 case SYNC_PREF_FORCE_REMOTE:
2973 return 2; 2973 return 2;
2974 break; 2974 break;
2975 2975
2976 default: 2976 default:
2977 // SYNC_PREF_TAKE_BOTH not implemented 2977 // SYNC_PREF_TAKE_BOTH not implemented
2978 break; 2978 break;
2979 } 2979 }
2980 return 0; 2980 return 0;
2981} 2981}
2982 2982
2983 2983
2984bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2984bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2985{ 2985{
2986 bool syncOK = true; 2986 bool syncOK = true;
2987 int addedAddressee = 0; 2987 int addedAddressee = 0;
2988 int addedAddresseeR = 0; 2988 int addedAddresseeR = 0;
2989 int deletedAddresseeR = 0; 2989 int deletedAddresseeR = 0;
2990 int deletedAddresseeL = 0; 2990 int deletedAddresseeL = 0;
2991 int changedLocal = 0; 2991 int changedLocal = 0;
2992 int changedRemote = 0; 2992 int changedRemote = 0;
2993 int filteredIN = 0; 2993 int filteredIN = 0;
2994 int filteredOUT = 0; 2994 int filteredOUT = 0;
2995 2995
2996 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2996 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2997 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2997 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2998 2998
2999 //QPtrList<Addressee> el = local->rawAddressees(); 2999 //QPtrList<Addressee> el = local->rawAddressees();
3000 Addressee addresseeR; 3000 Addressee addresseeR;
3001 QString uid; 3001 QString uid;
3002 int take; 3002 int take;
3003 Addressee addresseeL; 3003 Addressee addresseeL;
3004 Addressee addresseeRSync; 3004 Addressee addresseeRSync;
3005 Addressee addresseeLSync; 3005 Addressee addresseeLSync;
3006 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3006 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3007 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3007 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3008 bool fullDateRange = false; 3008 bool fullDateRange = false;
3009 local->resetTempSyncStat(); 3009 local->resetTempSyncStat();
3010 mLastAddressbookSync = QDateTime::currentDateTime(); 3010 mLastAddressbookSync = QDateTime::currentDateTime();
3011 if ( syncManager->syncWithDesktop() ) { 3011 if ( syncManager->syncWithDesktop() ) {
3012 // remote->removeSyncInfo( QString());//remove all info 3012 // remote->removeSyncInfo( QString());//remove all info
3013 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3013 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3014 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3014 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3015 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3015 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3016 } else { 3016 } else {
3017 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3017 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3018 } 3018 }
3019 } 3019 }
3020 QDateTime modifiedCalendar = mLastAddressbookSync; 3020 QDateTime modifiedCalendar = mLastAddressbookSync;
3021 addresseeLSync = getLastSyncAddressee(); 3021 addresseeLSync = getLastSyncAddressee();
3022 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3022 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3023 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3023 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3024 if ( !addresseeR.isEmpty() ) { 3024 if ( !addresseeR.isEmpty() ) {
3025 addresseeRSync = addresseeR; 3025 addresseeRSync = addresseeR;
3026 remote->removeAddressee(addresseeR ); 3026 remote->removeAddressee(addresseeR );
3027 3027
3028 } else { 3028 } else {
3029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3030 addresseeRSync = addresseeLSync ; 3030 addresseeRSync = addresseeLSync ;
3031 } else { 3031 } else {
3032 //qDebug("FULLDATE 1"); 3032 //qDebug("FULLDATE 1");
3033 fullDateRange = true; 3033 fullDateRange = true;
3034 Addressee newAdd; 3034 Addressee newAdd;
3035 addresseeRSync = newAdd; 3035 addresseeRSync = newAdd;
3036 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3036 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3037 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3037 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3038 addresseeRSync.setRevision( mLastAddressbookSync ); 3038 addresseeRSync.setRevision( mLastAddressbookSync );
3039 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3039 addresseeRSync.setCategories( i18n("SyncAddressee") );
3040 } 3040 }
3041 } 3041 }
3042 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3042 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3043 // qDebug("FULLDATE 2"); 3043 // qDebug("FULLDATE 2");
3044 fullDateRange = true; 3044 fullDateRange = true;
3045 } 3045 }
3046 if ( ! fullDateRange ) { 3046 if ( ! fullDateRange ) {
3047 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3047 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3048 3048
3049 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3049 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3050 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3050 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3051 fullDateRange = true; 3051 fullDateRange = true;
3052 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3052 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3053 } 3053 }
3054 } 3054 }
3055 // fullDateRange = true; // debug only! 3055 // fullDateRange = true; // debug only!
3056 if ( fullDateRange ) 3056 if ( fullDateRange )
3057 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3057 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3058 else 3058 else
3059 mLastAddressbookSync = addresseeLSync.revision(); 3059 mLastAddressbookSync = addresseeLSync.revision();
3060 // for resyncing if own file has changed 3060 // for resyncing if own file has changed
3061 // PENDING fixme later when implemented 3061 // PENDING fixme later when implemented
3062#if 0 3062#if 0
3063 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3063 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3064 mLastAddressbookSync = loadedFileVersion; 3064 mLastAddressbookSync = loadedFileVersion;
3065 qDebug("setting mLastAddressbookSync "); 3065 qDebug("setting mLastAddressbookSync ");
3066 } 3066 }
3067#endif 3067#endif
3068 3068
3069 3069
3070 // ********** setting filters **************** 3070 // ********** setting filters ****************
3071 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3071 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3072 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3072 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3073 3073
3074 //qDebug("*************************** "); 3074 //qDebug("*************************** ");
3075 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3075 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3076 QStringList er = remote->uidList(); 3076 QStringList er = remote->uidList();
3077 Addressee inR ;//= er.first(); 3077 Addressee inR ;//= er.first();
3078 Addressee inL; 3078 Addressee inL;
3079 3079
3080 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3080 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3081 3081
3082 int modulo = (er.count()/10)+1; 3082 int modulo = (er.count()/10)+1;
3083 int incCounter = 0; 3083 int incCounter = 0;
3084 while ( incCounter < er.count()) { 3084 while ( incCounter < er.count()) {
3085 if (syncManager->isProgressBarCanceled()) 3085 if (syncManager->isProgressBarCanceled())
3086 return false; 3086 return false;
3087 if ( incCounter % modulo == 0 ) 3087 if ( incCounter % modulo == 0 )
3088 syncManager->showProgressBar(incCounter); 3088 syncManager->showProgressBar(incCounter);
3089 3089
3090 uid = er[ incCounter ]; 3090 uid = er[ incCounter ];
3091 bool skipIncidence = false; 3091 bool skipIncidence = false;
3092 if ( uid.left(19) == QString("last-syncAddressee-") ) 3092 if ( uid.left(19) == QString("last-syncAddressee-") )
3093 skipIncidence = true; 3093 skipIncidence = true;
3094 QString idS,OidS; 3094 QString idS,OidS;
3095 qApp->processEvents(); 3095 qApp->processEvents();
3096 if ( !skipIncidence ) { 3096 if ( !skipIncidence ) {
3097 inL = local->findByUid( uid ); 3097 inL = local->findByUid( uid );
3098 inR = remote->findByUid( uid ); 3098 inR = remote->findByUid( uid );
3099 //inL.setResource( 0 ); 3099 //inL.setResource( 0 );
3100 //inR.setResource( 0 ); 3100 //inR.setResource( 0 );
3101 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3101 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3102 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3102 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3103 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3103 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3104 //qDebug("take %d %s ", take, inL.summary().latin1()); 3104 //qDebug("take %d %s ", take, inL.summary().latin1());
3105 if ( take == 3 ) 3105 if ( take == 3 )
3106 return false; 3106 return false;
3107 if ( take == 1 ) {// take local ********************** 3107 if ( take == 1 ) {// take local **********************
3108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3109 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3109 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3110 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3110 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3111 local->insertAddressee( inL, false ); 3111 local->insertAddressee( inL, false );
3112 idS = inR.externalUID(); 3112 idS = inR.externalUID();
3113 OidS = inR.originalExternalUID(); 3113 OidS = inR.originalExternalUID();
3114 } 3114 }
3115 else 3115 else
3116 idS = inR.IDStr(); 3116 idS = inR.IDStr();
3117 remote->removeAddressee( inR ); 3117 remote->removeAddressee( inR );
3118 inR = inL; 3118 inR = inL;
3119 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3119 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3120 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3120 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3121 inR.setOriginalExternalUID( OidS ); 3121 inR.setOriginalExternalUID( OidS );
3122 inR.setExternalUID( idS ); 3122 inR.setExternalUID( idS );
3123 if ( syncManager->syncWithDesktop() ) { 3123 if ( syncManager->syncWithDesktop() ) {
3124 inR.setIDStr("changed" ); 3124 inR.setIDStr("changed" );
3125 } 3125 }
3126 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3126 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3127 } else { 3127 } else {
3128 inR.setIDStr( idS ); 3128 inR.setIDStr( idS );
3129 } 3129 }
3130 inR.setResource( 0 ); 3130 inR.setResource( 0 );
3131 remote->insertAddressee( inR , false); 3131 remote->insertAddressee( inR , false);
3132 ++changedRemote; 3132 ++changedRemote;
3133 } else { // take == 2 take remote ********************** 3133 } else { // take == 2 take remote **********************
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 if ( inR.revision().date().year() < 2004 ) 3135 if ( inR.revision().date().year() < 2004 )
3136 inR.setRevision( modifiedCalendar ); 3136 inR.setRevision( modifiedCalendar );
3137 } 3137 }
3138 idS = inL.IDStr(); 3138 idS = inL.IDStr();
3139 local->removeAddressee( inL ); 3139 local->removeAddressee( inL );
3140 inL = inR; 3140 inL = inR;
3141 inL.setIDStr( idS ); 3141 inL.setIDStr( idS );
3142 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3142 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3143 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3143 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3144 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3144 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3145 } 3145 }
3146 inL.setResource( 0 ); 3146 inL.setResource( 0 );
3147 local->insertAddressee( inL , false ); 3147 local->insertAddressee( inL , false );
3148 ++changedLocal; 3148 ++changedLocal;
3149 } 3149 }
3150 } 3150 }
3151 } 3151 }
3152 } else { // no conflict ********** add or delete remote 3152 } else { // no conflict ********** add or delete remote
3153 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3153 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3154 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3154 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3155 QString des = addresseeLSync.note(); 3155 QString des = addresseeLSync.note();
3156 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3156 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3157 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3157 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3158 remote->insertAddressee( inR, false ); 3158 remote->insertAddressee( inR, false );
3159 ++deletedAddresseeR; 3159 ++deletedAddresseeR;
3160 } else { 3160 } else {
3161 inR.setRevision( modifiedCalendar ); 3161 inR.setRevision( modifiedCalendar );
3162 remote->insertAddressee( inR, false ); 3162 remote->insertAddressee( inR, false );
3163 inL = inR; 3163 inL = inR;
3164 inL.setIDStr( ":" ); 3164 inL.setIDStr( ":" );
3165 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3165 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3166 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3166 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3167 inL.setResource( 0 ); 3167 inL.setResource( 0 );
3168 local->insertAddressee( inL , false); 3168 local->insertAddressee( inL , false);
3169 ++addedAddressee; 3169 ++addedAddressee;
3170 } 3170 }
3171 } else { 3171 } else {
3172 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3172 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3173 inR.setRevision( modifiedCalendar ); 3173 inR.setRevision( modifiedCalendar );
3174 remote->insertAddressee( inR, false ); 3174 remote->insertAddressee( inR, false );
3175 inR.setResource( 0 ); 3175 inR.setResource( 0 );
3176 local->insertAddressee( inR, false ); 3176 local->insertAddressee( inR, false );
3177 ++addedAddressee; 3177 ++addedAddressee;
3178 } else { 3178 } else {
3179 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3179 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3180 remote->removeAddressee( inR ); 3180 remote->removeAddressee( inR );
3181 ++deletedAddresseeR; 3181 ++deletedAddresseeR;
3182 } 3182 }
3183 } 3183 }
3184 } else { 3184 } else {
3185 ++filteredIN; 3185 ++filteredIN;
3186 } 3186 }
3187 } 3187 }
3188 } 3188 }
3189 ++incCounter; 3189 ++incCounter;
3190 } 3190 }
3191 er.clear(); 3191 er.clear();
3192 QStringList el = local->uidList(); 3192 QStringList el = local->uidList();
3193 modulo = (el.count()/10)+1; 3193 modulo = (el.count()/10)+1;
3194 3194
3195 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3195 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3196 incCounter = 0; 3196 incCounter = 0;
3197 while ( incCounter < el.count()) { 3197 while ( incCounter < el.count()) {
3198 qApp->processEvents(); 3198 qApp->processEvents();
3199 if (syncManager->isProgressBarCanceled()) 3199 if (syncManager->isProgressBarCanceled())
3200 return false; 3200 return false;
3201 if ( incCounter % modulo == 0 ) 3201 if ( incCounter % modulo == 0 )
3202 syncManager->showProgressBar(incCounter); 3202 syncManager->showProgressBar(incCounter);
3203 uid = el[ incCounter ]; 3203 uid = el[ incCounter ];
3204 bool skipIncidence = false; 3204 bool skipIncidence = false;
3205 if ( uid.left(19) == QString("last-syncAddressee-") ) 3205 if ( uid.left(19) == QString("last-syncAddressee-") )
3206 skipIncidence = true; 3206 skipIncidence = true;
3207 if ( !skipIncidence ) { 3207 if ( !skipIncidence ) {
3208 inL = local->findByUid( uid ); 3208 inL = local->findByUid( uid );
3209 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3209 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3210 inR = remote->findByUid( uid ); 3210 inR = remote->findByUid( uid );
3211 if ( inR.isEmpty() ){ 3211 if ( inR.isEmpty() ){
3212 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3212 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3213 // no conflict ********** add or delete local 3213 // no conflict ********** add or delete local
3214 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3214 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3215 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3215 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3216 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3216 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3217 local->removeAddressee( inL ); 3217 local->removeAddressee( inL );
3218 ++deletedAddresseeL; 3218 ++deletedAddresseeL;
3219 } else { 3219 } else {
3220 if ( ! syncManager->mWriteBackExistingOnly ) { 3220 if ( ! syncManager->mWriteBackExistingOnly ) {
3221 inL.removeID(mCurrentSyncDevice ); 3221 inL.removeID(mCurrentSyncDevice );
3222 ++addedAddresseeR; 3222 ++addedAddresseeR;
3223 inL.setRevision( modifiedCalendar ); 3223 inL.setRevision( modifiedCalendar );
3224 local->insertAddressee( inL, false ); 3224 local->insertAddressee( inL, false );
3225 inR = inL; 3225 inR = inL;
3226 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3226 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3227 inR.setResource( 0 ); 3227 inR.setResource( 0 );
3228 remote->insertAddressee( inR, false ); 3228 remote->insertAddressee( inR, false );
3229 } 3229 }
3230 } 3230 }
3231 } else { 3231 } else {
3232 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3232 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3233 //qDebug("data %s ", inL.revision().toString().latin1()); 3233 //qDebug("data %s ", inL.revision().toString().latin1());
3234 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3234 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3235 local->removeAddressee( inL ); 3235 local->removeAddressee( inL );
3236 ++deletedAddresseeL; 3236 ++deletedAddresseeL;
3237 } else { 3237 } else {
3238 if ( ! syncManager->mWriteBackExistingOnly ) { 3238 if ( ! syncManager->mWriteBackExistingOnly ) {
3239 ++addedAddresseeR; 3239 ++addedAddresseeR;
3240 inL.setRevision( modifiedCalendar ); 3240 inL.setRevision( modifiedCalendar );
3241 local->insertAddressee( inL, false ); 3241 local->insertAddressee( inL, false );
3242 inR = inL; 3242 inR = inL;
3243 inR.setIDStr( ":" ); 3243 inR.setIDStr( ":" );
3244 inR.setResource( 0 ); 3244 inR.setResource( 0 );
3245 remote->insertAddressee( inR, false ); 3245 remote->insertAddressee( inR, false );
3246 } 3246 }
3247 } 3247 }
3248 } 3248 }
3249 } else { 3249 } else {
3250 ++filteredOUT; 3250 ++filteredOUT;
3251 } 3251 }
3252 } 3252 }
3253 } 3253 }
3254 } 3254 }
3255 ++incCounter; 3255 ++incCounter;
3256 } 3256 }
3257 el.clear(); 3257 el.clear();
3258 syncManager->hideProgressBar(); 3258 syncManager->hideProgressBar();
3259 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3259 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3260 // get rid of micro seconds 3260 // get rid of micro seconds
3261 QTime t = mLastAddressbookSync.time(); 3261 QTime t = mLastAddressbookSync.time();
3262 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3262 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3263 addresseeLSync.setRevision( mLastAddressbookSync ); 3263 addresseeLSync.setRevision( mLastAddressbookSync );
3264 addresseeRSync.setRevision( mLastAddressbookSync ); 3264 addresseeRSync.setRevision( mLastAddressbookSync );
3265 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3265 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3266 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3266 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3267 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3267 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3268 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3268 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3269 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3269 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3270 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3270 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3271 addresseeRSync.setNote( "" ) ; 3271 addresseeRSync.setNote( "" ) ;
3272 addresseeLSync.setNote( "" ); 3272 addresseeLSync.setNote( "" );
3273 3273
3274 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3274 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3275 remote->insertAddressee( addresseeRSync, false ); 3275 remote->insertAddressee( addresseeRSync, false );
3276 local->insertAddressee( addresseeLSync, false ); 3276 local->insertAddressee( addresseeLSync, false );
3277 QString mes; 3277 QString mes;
3278 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3278 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3279 qDebug( mes ); 3279 qDebug( mes );
3280 mes = i18n("Local addressbook changed!\n") +mes; 3280 mes = i18n("Local addressbook changed!\n") +mes;
3281 if ( syncManager->mShowSyncSummary ) { 3281 if ( syncManager->mShowSyncSummary ) {
3282 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3282 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3283 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3283 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3284 qDebug("KA: WB cancelled "); 3284 qDebug("KA: WB cancelled ");
3285 syncManager->mWriteBackFile = false; 3285 syncManager->mWriteBackFile = false;
3286 return syncOK; 3286 return syncOK;
3287 } 3287 }
3288 } 3288 }
3289 return syncOK; 3289 return syncOK;
3290} 3290}
3291 3291
3292 3292
3293//this is a overwritten callbackmethods from the syncinterface 3293//this is a overwritten callbackmethods from the syncinterface
3294bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3294bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3295{ 3295{
3296 3296
3297 //pending prepare addresseeview for output 3297 //pending prepare addresseeview for output
3298 //pending detect, if remote file has REV field. if not switch to external sync 3298 //pending detect, if remote file has REV field. if not switch to external sync
3299 mGlobalSyncMode = SYNC_MODE_NORMAL; 3299 mGlobalSyncMode = SYNC_MODE_NORMAL;
3300 if ( manager != syncManager ) 3300 if ( manager != syncManager )
3301 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3301 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3302 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3302 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3303 3303
3304 AddressBook abLocal(filename,"syncContact"); 3304 AddressBook abLocal(filename,"syncContact");
3305 bool syncOK = false; 3305 bool syncOK = false;
3306 if ( abLocal.load() ) { 3306 if ( abLocal.load() ) {
3307 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3307 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3308 bool external = false; 3308 bool external = false;
3309 bool isXML = false; 3309 bool isXML = false;
3310 if ( filename.right(4) == ".xml") { 3310 if ( filename.right(4) == ".xml") {
3311 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3311 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3312 isXML = true; 3312 isXML = true;
3313 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3313 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3314 } else { 3314 } else {
3315 external = !manager->mIsKapiFile; 3315 external = !manager->mIsKapiFile;
3316 if ( external ) { 3316 if ( external ) {
3317 qDebug("KA: Sync::Setting vcf mode to external "); 3317 qDebug("KA: Sync::Setting vcf mode to external ");
3318 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3318 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3319 AddressBook::Iterator it; 3319 AddressBook::Iterator it;
3320 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3320 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3321 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3321 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3322 (*it).computeCsum( mCurrentSyncDevice ); 3322 (*it).computeCsum( mCurrentSyncDevice );
3323 } 3323 }
3324 } 3324 }
3325 } 3325 }
3326 //AddressBook::Iterator it; 3326 //AddressBook::Iterator it;
3327 //QStringList vcards; 3327 //QStringList vcards;
3328 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3328 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3329 // qDebug("Name %s ", (*it).familyName().latin1()); 3329 // qDebug("Name %s ", (*it).familyName().latin1());
3330 //} 3330 //}
3331 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3331 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3332 syncManager->hideProgressBar(); 3332 syncManager->hideProgressBar();
3333 if ( syncOK ) { 3333 if ( syncOK ) {
3334 if ( syncManager->mWriteBackFile ) 3334 if ( syncManager->mWriteBackFile )
3335 { 3335 {
3336 if ( external ) 3336 if ( external )
3337 abLocal.removeSyncAddressees( !isXML); 3337 abLocal.removeSyncAddressees( !isXML);
3338 qDebug("KA: Sync::Saving remote AB "); 3338 qDebug("KA: Sync::Saving remote AB ");
3339 if ( ! abLocal.saveAB()) 3339 if ( ! abLocal.saveAB())
3340 qDebug("KA: sync::Error writing back AB to file "); 3340 qDebug("KA: sync::Error writing back AB to file ");
3341 if ( external ) { 3341 if ( external ) {
3342 // afterwrite processing 3342 // afterwrite processing
3343 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3343 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3344 } 3344 }
3345 } 3345 }
3346 } 3346 }
3347 setModified(); 3347 setModified();
3348 3348
3349 } 3349 }
3350 abLocal.removeResources(); 3350 abLocal.removeResources();
3351 if ( syncOK ) 3351 if ( syncOK )
3352 mViewManager->refreshView(); 3352 mViewManager->refreshView();
3353 return syncOK; 3353 return syncOK;
3354 3354
3355} 3355}
3356void KABCore::removeSyncInfo( QString syncProfile) 3356void KABCore::removeSyncInfo( QString syncProfile)
3357{ 3357{
3358 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3358 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3359 mAddressBook->removeSyncInfo( syncProfile ); 3359 mAddressBook->removeSyncInfo( syncProfile );
3360 setModified(); 3360 setModified();
3361} 3361}
3362 3362
3363 3363
3364//this is a overwritten callbackmethods from the syncinterface 3364//this is a overwritten callbackmethods from the syncinterface
3365bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3365bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3366{ 3366{
3367 if ( resource == "phone" ) 3367 if ( resource == "phone" )
3368 return syncPhone(); 3368 return syncPhone();
3369 disableBR( true ); 3369 disableBR( true );
3370 if ( manager != syncManager ) 3370 if ( manager != syncManager )
3371 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3371 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3372 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3372 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3373 3373
3374 AddressBook abLocal( resource,"syncContact"); 3374 AddressBook abLocal( resource,"syncContact");
3375 bool syncOK = false; 3375 bool syncOK = false;
3376 message(i18n("Loading DTM address data..."), false); 3376 message(i18n("Loading DTM address data..."), false);
3377 if ( abLocal.load() ) { 3377 if ( abLocal.load() ) {
3378 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3378 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3379 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3379 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3380 message(i18n("Sync preprocessing..."),false); 3380 message(i18n("Sync preprocessing..."),false);
3381 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3381 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3382 message(i18n("Synchronizing..."),false); 3382 message(i18n("Synchronizing..."),false);
3383 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3383 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3384 syncManager->hideProgressBar(); 3384 syncManager->hideProgressBar();
3385 if ( syncOK ) { 3385 if ( syncOK ) {
3386 if ( syncManager->mWriteBackFile ) { 3386 if ( syncManager->mWriteBackFile ) {
3387 abLocal.removeSyncAddressees( false ); 3387 abLocal.removeSyncAddressees( false );
3388 message(i18n("Saving DTM address data..."),false); 3388 message(i18n("Saving DTM address data..."),false);
3389 abLocal.saveAB(); 3389 abLocal.saveAB();
3390 message(i18n("Sync postprocessing..."),false); 3390 message(i18n("Sync postprocessing..."),false);
3391 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3391 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3392 } 3392 }
3393 } else 3393 } else
3394 message( i18n("Sync cancelled or failed.") ); 3394 message( i18n("Sync cancelled or failed.") );
3395 setModified(); 3395 setModified();
3396 } 3396 }
3397 abLocal.removeResources(); 3397 abLocal.removeResources();
3398 if ( syncOK ) { 3398 if ( syncOK ) {
3399 mViewManager->refreshView(); 3399 mViewManager->refreshView();
3400 message(i18n("DTM syncing finished.")); 3400 message(i18n("DTM syncing finished."));
3401 } 3401 }
3402 disableBR( false ); 3402 disableBR( false );
3403 return syncOK; 3403 return syncOK;
3404 3404
3405} 3405}
3406void KABCore::message( QString m, bool startTimer) 3406void KABCore::message( QString m, bool startTimer)
3407{ 3407{
3408 topLevelWidget()->setCaption( m ); 3408 topLevelWidget()->setCaption( m );
3409 qApp->processEvents(); 3409 qApp->processEvents();
3410 if ( startTimer ) 3410 if ( startTimer )
3411 mMessageTimer->start( 15000, true ); 3411 mMessageTimer->start( 15000, true );
3412 else 3412 else
3413 mMessageTimer->stop(); 3413 mMessageTimer->stop();
3414} 3414}
3415bool KABCore::syncPhone() 3415bool KABCore::syncPhone()
3416{ 3416{
3417 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3417 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3418 QString fileName = getPhoneFile(); 3418 QString fileName = getPhoneFile();
3419 if ( !PhoneAccess::readFromPhone( fileName) ) { 3419 if ( !PhoneAccess::readFromPhone( fileName) ) {
3420 message(i18n("Phone access failed!")); 3420 message(i18n("Phone access failed!"));
3421 return false; 3421 return false;
3422 } 3422 }
3423 AddressBook abLocal( fileName,"syncContact"); 3423 AddressBook abLocal( fileName,"syncContact");
3424 bool syncOK = false; 3424 bool syncOK = false;
3425 { 3425 {
3426 abLocal.importFromFile( fileName ); 3426 abLocal.importFromFile( fileName );
3427 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3427 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3428 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3428 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3429 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3429 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3430 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3430 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3431 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3431 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3432 syncManager->hideProgressBar(); 3432 syncManager->hideProgressBar();
3433 if ( syncOK ) { 3433 if ( syncOK ) {
3434 if ( syncManager->mWriteBackFile ) { 3434 if ( syncManager->mWriteBackFile ) {
3435 abLocal.removeSyncAddressees( true ); 3435 abLocal.removeSyncAddressees( true );
3436 abLocal.saveABphone( fileName ); 3436 abLocal.saveABphone( fileName );
3437 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3437 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3438 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3438 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3439 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3439 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3440 } 3440 }
3441 } 3441 }
3442 setModified(); 3442 setModified();
3443 } 3443 }
3444 abLocal.removeResources(); 3444 abLocal.removeResources();
3445 if ( syncOK ) 3445 if ( syncOK )
3446 mViewManager->refreshView(); 3446 mViewManager->refreshView();
3447 return syncOK; 3447 return syncOK;
3448} 3448}
3449void KABCore::getFile( bool success ) 3449void KABCore::getFile( bool success )
3450{ 3450{
3451 if ( ! success ) { 3451 if ( ! success ) {
3452 message( i18n("Error receiving file. Nothing changed!") ); 3452 message( i18n("Error receiving file. Nothing changed!") );
3453 return; 3453 return;
3454 } 3454 }
3455 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3455 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3456 if ( count ) 3456 if ( count )
3457 setModified( true ); 3457 setModified( true );
3458 message( i18n("Pi-Sync successful!") ); 3458 message( i18n("Pi-Sync successful!") );
3459 mViewManager->refreshView(); 3459 mViewManager->refreshView();
3460} 3460}
3461void KABCore::syncFileRequest() 3461void KABCore::syncFileRequest()
3462{ 3462{
3463 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3463 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3464 syncManager->slotSyncMenu( 999 ); 3464 syncManager->slotSyncMenu( 999 );
3465 } 3465 }
3466 mAddressBook->export2File( sentSyncFile() ); 3466 mAddressBook->export2File( sentSyncFile() );
3467} 3467}
3468QString KABCore::sentSyncFile() 3468QString KABCore::sentSyncFile()
3469{ 3469{
3470#ifdef DESKTOP_VERSION 3470#ifdef DESKTOP_VERSION
3471 return locateLocal( "tmp", "copysyncab.vcf" ); 3471 return locateLocal( "tmp", "copysyncab.vcf" );
3472#else 3472#else
3473 return QString( "/tmp/copysyncab.vcf" ); 3473 return QString( "/tmp/copysyncab.vcf" );
3474#endif 3474#endif
3475} 3475}
3476 3476
3477void KABCore::setCaptionBack() 3477void KABCore::setCaptionBack()
3478{ 3478{
3479 mMessageTimer->stop(); 3479 mMessageTimer->stop();
3480 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3480 topLevelWidget()->setCaption( i18n("KA/Pi") );
3481} 3481}
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index 8fe3ee0..c417226 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,241 +1,241 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@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#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 setIcon(SmallIcon( "ka24" ) ); 50 setIcon(SmallIcon( "ka24" ) );
51#if 0 51#if 0
52 //US for embedded systems, create the toolbar before we initiate KABCore. 52 //US for embedded systems, create the toolbar before we initiate KABCore.
53 // KABCore will fill the toolbar with menues and icons 53 // KABCore will fill the toolbar with menues and icons
54 QMainWindow::ToolBarDock tbd; 54 QMainWindow::ToolBarDock tbd;
55 tbd = Top; 55 tbd = Top;
56 iconToolBar = new QToolBar( this ); 56 iconToolBar = new QToolBar( this );
57 addToolBar (iconToolBar , tbd ); 57 addToolBar (iconToolBar , tbd );
58 iconToolBar->setHorizontalStretchable(true); 58 iconToolBar->setHorizontalStretchable(true);
59//US iconToolBar->setWidth(300); 59//US iconToolBar->setWidth(300);
60#endif // 0 60#endif // 0
61 61
62 mCore = new KABCore( this, true, this ); 62 mCore = new KABCore( this, true, this );
63 63
64#ifdef KAB_EMBEDDED 64#ifdef KAB_EMBEDDED
65 setCaption( i18n( "KAddressbook/Pi" ) ); 65 setCaption( i18n( "KAddressbook/Pi" ) );
66#else //KAB_EMBEDDED 66#else //KAB_EMBEDDED
67 setCaption( i18n( "Address Book Browser" ) ); 67 setCaption( i18n( "Address Book Browser" ) );
68#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
69 69
70 //mCore->restoreSettings(); 70 //mCore->restoreSettings();
71 71
72 initActions(); 72 initActions();
73 73
74 setCentralWidget( mCore ); 74 setCentralWidget( mCore );
75 75
76//US statusBar()->show(); 76//US statusBar()->show();
77 77
78#ifndef KAB_EMBEDDED 78#ifndef KAB_EMBEDDED
79 setStandardToolBarMenuEnabled(true); 79 setStandardToolBarMenuEnabled(true);
80 80
81 createGUI( "kaddressbookui.rc", false ); 81 createGUI( "kaddressbookui.rc", false );
82 82
83 83
84#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
85 setAutoSaveSettings(); 85 setAutoSaveSettings();
86 mCore->restoreSettings(); 86 mCore->restoreSettings();
87#ifndef DESKTOP_VERSION 87#ifndef DESKTOP_VERSION
88 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), mCore, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 88 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), mCore, SLOT (receiveStart ( const QCString &, const QByteArray & )));
89#endif 89#endif
90} 90}
91 91
92KAddressBookMain::~KAddressBookMain() 92KAddressBookMain::~KAddressBookMain()
93{ 93{
94 // mCore->saveSettings(); 94 // mCore->saveSettings();
95} 95}
96 96
97void KAddressBookMain::showMinimized () 97void KAddressBookMain::showMinimized ()
98{ 98{
99 QWidget::showMinimized () ; 99 QWidget::showMinimized () ;
100} 100}
101void KAddressBookMain::addEmail( QString addr ) 101void KAddressBookMain::addEmail( QString addr )
102{ 102{
103 mCore->addEmail( addr ); 103 mCore->addEmail( addr );
104} 104}
105 105
106#ifndef KAB_EMBEDDED 106#ifndef KAB_EMBEDDED
107ASYNC KAddressBookMain::showContactEditor( QString uid ) 107ASYNC KAddressBookMain::showContactEditor( QString uid )
108{ 108{
109 mCore->editContact( uid ); 109 mCore->editContact( uid );
110} 110}
111#endif //KAB_EMBEDDED 111#endif //KAB_EMBEDDED
112void KAddressBookMain::newContact() 112void KAddressBookMain::newContact()
113{ 113{
114 mCore->newContact(); 114 mCore->newContact();
115} 115}
116 116
117QString KAddressBookMain::getNameByPhone( QString phone ) 117QString KAddressBookMain::getNameByPhone( QString phone )
118{ 118{
119 return mCore->getNameByPhone( phone ); 119 return mCore->getNameByPhone( phone );
120} 120}
121 121
122void KAddressBookMain::save() 122void KAddressBookMain::save()
123{ 123{
124 mCore->save(); 124 mCore->save();
125} 125}
126 126
127void KAddressBookMain::exit() 127void KAddressBookMain::exit()
128{ 128{
129 close( ); 129 close( );
130} 130}
131 131
132void KAddressBookMain::saveProperties( KConfig* ) 132void KAddressBookMain::saveProperties( KConfig* )
133{ 133{
134} 134}
135 135
136void KAddressBookMain::readProperties( KConfig* ) 136void KAddressBookMain::readProperties( KConfig* )
137{ 137{
138} 138}
139 139
140void KAddressBookMain::initActions() 140void KAddressBookMain::initActions()
141{ 141{
142#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
143 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 143 KStdAction::quit( this, SLOT( close() ), actionCollection() );
144 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 144 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
145#else //KAB_EMBEDDED 145#else //KAB_EMBEDDED
146 //US: transfered the setup of the actions into KABCore 146 //US: transfered the setup of the actions into KABCore
147#endif //KAB_EMBEDDED 147#endif //KAB_EMBEDDED
148 148
149 149
150} 150}
151 151
152//US new method to setup menues and toolbars on embedded systems 152//US new method to setup menues and toolbars on embedded systems
153#ifdef KAB_EMBEDDED 153#ifdef KAB_EMBEDDED
154/* 154/*
155QToolBar * KAddressBookMain::getIconToolBar() 155QToolBar * KAddressBookMain::getIconToolBar()
156{ 156{
157 return iconToolBar; 157 return iconToolBar;
158} 158}
159*/ 159*/
160 160
161void KAddressBookMain::createGUI() 161void KAddressBookMain::createGUI()
162{ 162{
163 163
164 164
165 165
166} 166}
167#endif //KAB_EMBEDDED 167#endif //KAB_EMBEDDED
168 168
169void KAddressBookMain::configureToolbars() 169void KAddressBookMain::configureToolbars()
170{ 170{
171#ifndef KAB_EMBEDDED 171#ifndef KAB_EMBEDDED
172 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 172 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
173 173
174 KEditToolbar dlg( factory() ); 174 KEditToolbar dlg( factory() );
175 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 175 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
176 176
177 dlg.exec(); 177 dlg.exec();
178#else //KAB_EMBEDDED 178#else //KAB_EMBEDDED
179 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 179 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
180#endif //KAB_EMBEDDED 180#endif //KAB_EMBEDDED
181} 181}
182 182
183void KAddressBookMain::slotNewToolbarConfig() 183void KAddressBookMain::slotNewToolbarConfig()
184{ 184{
185#ifndef KAB_EMBEDDED 185#ifndef KAB_EMBEDDED
186 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 186 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
187#else //KAB_EMBEDDED 187#else //KAB_EMBEDDED
188 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 188 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
189#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
190} 190}
191 191
192void KAddressBookMain::configureKeys() 192void KAddressBookMain::configureKeys()
193{ 193{
194#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
195 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 195 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 197 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
198#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
199} 199}
200 200
201void KAddressBookMain::closeEvent( QCloseEvent* ce ) 201void KAddressBookMain::closeEvent( QCloseEvent* ce )
202{ 202{
203 bool mModified = mCore->modified(); 203 bool mModified = mCore->modified();
204 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 204 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
205 205
206 QString mess = i18n( "Close KA/Pi?"); 206 QString mess = i18n( "Close KA/Pi?");
207 if ( mModified == true ) 207 if ( mModified == true )
208 mess += i18n( "\nChanges will be saved!"); 208 mess += i18n( "\nChanges will be saved!");
209 else 209 else
210 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 210 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
211 211
212 bool mQuit = true; 212 bool mQuit = true;
213 213
214 214
215 if (mAskForQuit) 215 if (mAskForQuit)
216 { 216 {
217 217
218 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 218 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
219 if (res == 0) 219 if (res == 0)
220 mQuit = true; 220 mQuit = true;
221 else 221 else
222 mQuit = false; 222 mQuit = false;
223 } 223 }
224 224
225 if (mQuit == false) 225 if (mQuit == false)
226 return; 226 return;
227 227
228 if (mModified == true) 228 if (mModified == true)
229 { 229 {
230 save(); 230 save();
231 mCore->saveSettings(); 231 mCore->saveSettings();
232 //KABPrefs::instance()->writeConfig(); 232 //KABPrefs::instance()->writeConfig();
233 } 233 }
234 234
235 ce->accept(); 235 ce->accept();
236} 236}
237 237
238#ifndef KAB_EMBEDDED 238#ifndef KAB_EMBEDDED
239#include "kaddressbookmain.moc" 239#include "kaddressbookmain.moc"
240#endif //KAB_EMBEDDED 240#endif //KAB_EMBEDDED
241 241
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp
index 4879d57..d1d4f7e 100644
--- a/kmicromail/accountview.cpp
+++ b/kmicromail/accountview.cpp
@@ -1,263 +1,263 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6#include <libmailwrapper/settings.h> 6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 7#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10 10
11/* OPIE */ 11/* OPIE */
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qpopupmenu.h> 16#include <qpopupmenu.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qtimer.h> 18#include <qtimer.h>
19#include <qspinbox.h> 19#include <qspinbox.h>
20#include <klocale.h> 20#include <klocale.h>
21#include <kmessagebox.h> 21#include <kmessagebox.h>
22 22
23using namespace Opie::Core; 23using namespace Opie::Core;
24AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 24AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
25 : QListView( parent, name, flags ) 25 : QListView( parent, name, flags )
26{ 26{
27 //connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 27 //connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
28 // SLOT( refresh(QListViewItem*) ) ); 28 // SLOT( refresh(QListViewItem*) ) );
29 connect( this, SIGNAL( clicked(QListViewItem*) ), 29 connect( this, SIGNAL( clicked(QListViewItem*) ),
30 SLOT( refresh(QListViewItem*) ) ); 30 SLOT( refresh(QListViewItem*) ) );
31 connect( this, SIGNAL( returnPressed(QListViewItem*) ), 31 connect( this, SIGNAL( returnPressed(QListViewItem*) ),
32 SLOT( refresh(QListViewItem*) ) ); 32 SLOT( refresh(QListViewItem*) ) );
33 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 33 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
34 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 34 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
35 setSorting(0); 35 setSorting(0);
36} 36}
37 37
38AccountView::~AccountView() 38AccountView::~AccountView()
39{ 39{
40 imapAccounts.clear(); 40 imapAccounts.clear();
41 mhAccounts.clear(); 41 mhAccounts.clear();
42} 42}
43 43
44void AccountView::slotContextMenu(int id) 44void AccountView::slotContextMenu(int id)
45{ 45{
46 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 46 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
47 if (!view) return; 47 if (!view) return;
48 view->contextMenuSelected(id); 48 view->contextMenuSelected(id);
49} 49}
50 50
51void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 51void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
52{ 52{
53 if (button==1) {return;} 53 if (button==1) {return;}
54 if (!item) return; 54 if (!item) return;
55 AccountViewItem *view = static_cast<AccountViewItem *>(item); 55 AccountViewItem *view = static_cast<AccountViewItem *>(item);
56 QPopupMenu*m = view->getContextMenu(); 56 QPopupMenu*m = view->getContextMenu();
57 if (!m) return; 57 if (!m) return;
58 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 58 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
59 m->setFocus(); 59 m->setFocus();
60 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 60 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
61 delete m; 61 delete m;
62} 62}
63 63
64void AccountView::populate( QList<Account> list ) 64void AccountView::populate( QList<Account> list )
65{ 65{
66 clear(); 66 clear();
67 67
68 imapAccounts.clear(); 68 imapAccounts.clear();
69 mhAccounts.clear(); 69 mhAccounts.clear();
70 70
71 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 71 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
72 72
73 Account *it; 73 Account *it;
74 for ( it = list.first(); it; it = list.next() ) 74 for ( it = list.first(); it; it = list.next() )
75 { 75 {
76 if ( it->getType() == MAILLIB::A_IMAP ) 76 if ( it->getType() == MAILLIB::A_IMAP )
77 { 77 {
78 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 78 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
79 imapAccounts.append(new IMAPviewItem( imap, this )); 79 imapAccounts.append(new IMAPviewItem( imap, this ));
80 } 80 }
81 else if ( it->getType() == MAILLIB::A_POP3 ) 81 else if ( it->getType() == MAILLIB::A_POP3 )
82 { 82 {
83 POP3account *pop3 = static_cast<POP3account *>(it); 83 POP3account *pop3 = static_cast<POP3account *>(it);
84 /* must not be hold 'cause it isn't required */ 84 /* must not be hold 'cause it isn't required */
85 (void) new POP3viewItem( pop3, this ); 85 (void) new POP3viewItem( pop3, this );
86 } 86 }
87 else if ( it->getType() == MAILLIB::A_NNTP ) 87 else if ( it->getType() == MAILLIB::A_NNTP )
88 { 88 {
89 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 89 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
90 /* must not be hold 'cause it isn't required */ 90 /* must not be hold 'cause it isn't required */
91 (void) new NNTPviewItem( nntp, this ); 91 (void) new NNTPviewItem( nntp, this );
92 } 92 }
93 } 93 }
94} 94}
95 95
96void AccountView::refresh(QListViewItem *item) 96void AccountView::refresh(QListViewItem *item)
97{ 97{
98 if ( item ) 98 if ( item )
99 { 99 {
100 bool ask = true; 100 bool ask = true;
101 qDebug("text -%s- ",item->text( 0 ).latin1() ); 101 //qDebug("text -%s- ",item->text( 0 ).latin1() );
102 if ( item->text( 0 ) == i18n (" Local Mailfolders") ) 102 if ( item->text( 0 ) == i18n (" Local Mailfolders") )
103 ask = false; 103 ask = false;
104 else { 104 else {
105 if ( item->parent() ) 105 if ( item->parent() )
106 if ( item->parent()->text( 0 ) == i18n (" Local Mailfolders") ) 106 if ( item->parent()->text( 0 ) == i18n (" Local Mailfolders") )
107 ask = false; 107 ask = false;
108 } 108 }
109 if ( ask ) { 109 if ( ask ) {
110 int result = KMessageBox::warningContinueCancel(this, 110 int result = KMessageBox::warningContinueCancel(this,
111 i18n("Refresh\n%1\n?").arg( item->text(0) ), 111 i18n("Refresh\n%1\n?").arg( item->text(0) ),
112 i18n("Refresh"),i18n("Refresh"),i18n("Cancel"), 112 i18n("Refresh"),i18n("Refresh"),i18n("Cancel"),
113 true); 113 true);
114 if (result != KMessageBox::Continue) return; 114 if (result != KMessageBox::Continue) return;
115 } 115 }
116 m_currentItem = item; 116 m_currentItem = item;
117 topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; 117 topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ;
118 QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); 118 QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) );
119 119
120 } 120 }
121} 121}
122void AccountView::refreshOutgoing() 122void AccountView::refreshOutgoing()
123{ 123{
124 m_currentItem = currentItem(); 124 m_currentItem = currentItem();
125 if ( !m_currentItem ) return; 125 if ( !m_currentItem ) return;
126 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 126 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
127 if ( !view->getFolder() ) 127 if ( !view->getFolder() )
128 return; 128 return;
129 QString bName = view->getFolder()->getDisplayName(); 129 QString bName = view->getFolder()->getDisplayName();
130 if (bName.startsWith("/")&&bName.length()>1) 130 if (bName.startsWith("/")&&bName.length()>1)
131 { 131 {
132 bName.replace(0,1,""); 132 bName.replace(0,1,"");
133 } 133 }
134 int pos = bName.findRev("/"); 134 int pos = bName.findRev("/");
135 if (pos > 0) 135 if (pos > 0)
136 { 136 {
137 bName.replace(0,pos+1,""); 137 bName.replace(0,pos+1,"");
138 } 138 }
139 //qDebug("name *%s* ",bName.lower().latin1() ); 139 //qDebug("name *%s* ",bName.lower().latin1() );
140 if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { 140 if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) {
141 refreshCurrent(); 141 refreshCurrent();
142 // qDebug("refresh "); 142 // qDebug("refresh ");
143 } 143 }
144} 144}
145void AccountView::refreshCurrentSelected() 145void AccountView::refreshCurrentSelected()
146{ 146{
147 if ( !m_currentItem ) return; 147 if ( !m_currentItem ) return;
148 QValueList<RecMailP> headerlist; 148 QValueList<RecMailP> headerlist;
149 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 149 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
150 view->refresh(headerlist); 150 view->refresh(headerlist);
151 emit refreshMailview(headerlist); 151 emit refreshMailview(headerlist);
152 topLevelWidget()->setCaption( i18n ( "KOpieMail/Pi" ) ) ; 152 topLevelWidget()->setCaption( i18n ( "KOpieMail/Pi" ) ) ;
153} 153}
154 154
155void AccountView::refreshCurrent() 155void AccountView::refreshCurrent()
156{ 156{
157 m_currentItem = currentItem(); 157 m_currentItem = currentItem();
158 if ( !m_currentItem ) return; 158 if ( !m_currentItem ) return;
159 topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ; 159 topLevelWidget()->setCaption( i18n ( "Refreshing %1 ... please wait" ). arg ( m_currentItem->text( 0 ) ) ) ;
160 QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) ); 160 QTimer::singleShot( 500, this, SLOT ( refreshCurrentSelected() ) );
161} 161}
162 162
163void AccountView::refreshAll() 163void AccountView::refreshAll()
164{ 164{
165} 165}
166 166
167RecBodyP AccountView::fetchBody(const RecMailP&aMail) 167RecBodyP AccountView::fetchBody(const RecMailP&aMail)
168{ 168{
169 QListViewItem*item = selectedItem (); 169 QListViewItem*item = selectedItem ();
170 if (!item) return new RecBody(); 170 if (!item) return new RecBody();
171 AccountViewItem *view = static_cast<AccountViewItem *>(item); 171 AccountViewItem *view = static_cast<AccountViewItem *>(item);
172 return view->fetchBody(aMail); 172 return view->fetchBody(aMail);
173} 173}
174 174
175void AccountView::setupFolderselect(Selectstore*sels) 175void AccountView::setupFolderselect(Selectstore*sels)
176{ 176{
177 177
178#ifndef DESKTOP_VERSION 178#ifndef DESKTOP_VERSION
179 sels->showMaximized(); 179 sels->showMaximized();
180#else 180#else
181 sels->show(); 181 sels->show();
182#endif 182#endif
183 QStringList sFolders; 183 QStringList sFolders;
184 unsigned int i = 0; 184 unsigned int i = 0;
185 for (i=0; i < mhAccounts.count();++i) 185 for (i=0; i < mhAccounts.count();++i)
186 { 186 {
187 mhAccounts[i]->refresh(false); 187 mhAccounts[i]->refresh(false);
188 sFolders = mhAccounts[i]->subFolders(); 188 sFolders = mhAccounts[i]->subFolders();
189 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 189 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
190 } 190 }
191 for (i=0; i < imapAccounts.count();++i) 191 for (i=0; i < imapAccounts.count();++i)
192 { 192 {
193 if (imapAccounts[i]->offline()) 193 if (imapAccounts[i]->offline())
194 continue; 194 continue;
195 imapAccounts[i]->refreshFolders(false); 195 imapAccounts[i]->refreshFolders(false);
196 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 196 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
197 } 197 }
198} 198}
199void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) 199void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper)
200{ 200{
201#if 0 201#if 0
202 AbstractMail*targetMail = 0; 202 AbstractMail*targetMail = 0;
203 QString targetFolder = ""; 203 QString targetFolder = "";
204 Selectstore sels; 204 Selectstore sels;
205 setupFolderselect(&sels); 205 setupFolderselect(&sels);
206 if (!sels.exec()) return; 206 if (!sels.exec()) return;
207 targetMail = sels.currentMail(); 207 targetMail = sels.currentMail();
208 targetFolder = sels.currentFolder(); 208 targetFolder = sels.currentFolder();
209 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 209 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
210 targetFolder.isEmpty()) 210 targetFolder.isEmpty())
211 { 211 {
212 return; 212 return;
213 } 213 }
214 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 214 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
215 { 215 {
216 QMessageBox::critical(0,i18n("Error creating new Folder"), 216 QMessageBox::critical(0,i18n("Error creating new Folder"),
217 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 217 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
218 return; 218 return;
219 } 219 }
220 int maxsize = 0; 220 int maxsize = 0;
221 if ( sels.useSize->isChecked()) 221 if ( sels.useSize->isChecked())
222 maxsize = sels.sizeSpinBox->value(); 222 maxsize = sels.sizeSpinBox->value();
223 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 223 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
224#endif 224#endif
225 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper()); 225 fromWrapper->downloadNewMails( fromFolder, mhAccounts[0]->getWrapper());
226 refreshCurrent(); 226 refreshCurrent();
227 227
228} 228}
229 229
230void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 230void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
231{ 231{
232 AbstractMail*targetMail = 0; 232 AbstractMail*targetMail = 0;
233 QString targetFolder = ""; 233 QString targetFolder = "";
234 Selectstore sels; 234 Selectstore sels;
235 setupFolderselect(&sels); 235 setupFolderselect(&sels);
236 if (!sels.exec()) return; 236 if (!sels.exec()) return;
237 targetMail = sels.currentMail(); 237 targetMail = sels.currentMail();
238 targetFolder = sels.currentFolder(); 238 targetFolder = sels.currentFolder();
239 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 239 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
240 targetFolder.isEmpty()) 240 targetFolder.isEmpty())
241 { 241 {
242 return; 242 return;
243 } 243 }
244 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 244 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
245 { 245 {
246 QMessageBox::critical(0,i18n("Error creating new Folder"), 246 QMessageBox::critical(0,i18n("Error creating new Folder"),
247 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 247 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
248 return; 248 return;
249 } 249 }
250 int maxsize = 0; 250 int maxsize = 0;
251 if ( sels.useSize->isChecked()) 251 if ( sels.useSize->isChecked())
252 maxsize = sels.sizeSpinBox->value(); 252 maxsize = sels.sizeSpinBox->value();
253 253
254 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize); 254 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails(), maxsize);
255 refreshCurrent(); 255 refreshCurrent();
256} 256}
257 257
258bool AccountView::currentisDraft() 258bool AccountView::currentisDraft()
259{ 259{
260 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 260 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
261 if (!view) return false; 261 if (!view) return false;
262 return view->isDraftfolder(); 262 return view->isDraftfolder();
263} 263}
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index 3ae4c87..fa678f2 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -1,995 +1,996 @@
1 /* This file is part of the KDE libraries 1 /* This file is part of the KDE libraries
2 Copyright 2 Copyright
3 (C) 2000 Reginald Stadlbauer (reggie@kde.org) 3 (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4 (C) 1997 Stephan Kulow (coolo@kde.org) 4 (C) 1997 Stephan Kulow (coolo@kde.org)
5 (C) 1997-2000 Sven Radej (radej@kde.org) 5 (C) 1997-2000 Sven Radej (radej@kde.org)
6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999 Chris Schlaeger (cs@kde.org) 7 (C) 1999 Chris Schlaeger (cs@kde.org)
8 (C) 2002 Joseph Wenninger (jowenn@kde.org) 8 (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23 */ 23 */
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qstatusbar.h> 28#include <qstatusbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31 31
32#include "kdebug.h" 32#include "kdebug.h"
33#include "kmainwindow.h" 33#include "kmainwindow.h"
34#include "kglobalsettings.h" 34#include "kglobalsettings.h"
35#include "kactioncollection.h" 35#include "kactioncollection.h"
36 36
37class KMainWindowPrivate { 37class KMainWindowPrivate {
38public: 38public:
39//US bool showHelpMenu:1; 39//US bool showHelpMenu:1;
40 40
41 bool autoSaveSettings:1; 41 bool autoSaveSettings:1;
42 bool settingsDirty:1; 42 bool settingsDirty:1;
43 bool autoSaveWindowSize:1; 43 bool autoSaveWindowSize:1;
44 bool care_about_geometry:1; 44 bool care_about_geometry:1;
45 QString autoSaveGroup; 45 QString autoSaveGroup;
46//US KAccel * kaccel; 46//US KAccel * kaccel;
47//US KMainWindowInterface *m_interface; 47//US KMainWindowInterface *m_interface;
48 KDEPrivate::ToolBarHandler *toolBarHandler; 48 KDEPrivate::ToolBarHandler *toolBarHandler;
49 QTimer* settingsTimer; 49 QTimer* settingsTimer;
50 KToggleAction *showStatusBarAction; 50 KToggleAction *showStatusBarAction;
51 QRect defaultWindowSize; 51 QRect defaultWindowSize;
52}; 52};
53 53
54static bool no_query_exit = false; 54static bool no_query_exit = false;
55 55
56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) 56KMainWindow::KMainWindow( QWidget* parent, const char *name )
57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ 57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
58{ 58{
59 mQToolBar = 0; 59 mQToolBar = 0;
60 initKMainWindow(name); 60 initKMainWindow(name);
61} 61}
62 62
63void KMainWindow::parseGeometry(bool parsewidth) 63void KMainWindow::parseGeometry(bool parsewidth)
64{ 64{
65//US the following code is not getting used in the embedded version !! So disable it for now 65//US the following code is not getting used in the embedded version !! So disable it for now
66/*US 66/*US
67 67
68 assert ( !kapp->geometryArgument().isNull() ); 68 assert ( !kapp->geometryArgument().isNull() );
69 assert ( d->care_about_geometry ); 69 assert ( d->care_about_geometry );
70 70
71#ifndef Q_WS_QWS 71#ifndef Q_WS_QWS
72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) 72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
73 int x, y; 73 int x, y;
74 int w, h; 74 int w, h;
75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); 75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
76 if (parsewidth) { 76 if (parsewidth) {
77 QSize minSize = minimumSize(); 77 QSize minSize = minimumSize();
78 QSize maxSize = maximumSize(); 78 QSize maxSize = maximumSize();
79 if ( (m & WidthValue) == 0 ) 79 if ( (m & WidthValue) == 0 )
80 w = width(); 80 w = width();
81 if ( (m & HeightValue) == 0 ) 81 if ( (m & HeightValue) == 0 )
82 h = height(); 82 h = height();
83 w = QMIN(w,maxSize.width()); 83 w = QMIN(w,maxSize.width());
84 h = QMIN(h,maxSize.height()); 84 h = QMIN(h,maxSize.height());
85 w = QMAX(w,minSize.width()); 85 w = QMAX(w,minSize.width());
86 h = QMAX(h,minSize.height()); 86 h = QMAX(h,minSize.height());
87 resize(w, h); 87 resize(w, h);
88 } else { 88 } else {
89 if ( parsewidth && (m & XValue) == 0 ) 89 if ( parsewidth && (m & XValue) == 0 )
90 x = geometry().x(); 90 x = geometry().x();
91 if ( parsewidth && (m & YValue) == 0 ) 91 if ( parsewidth && (m & YValue) == 0 )
92 y = geometry().y(); 92 y = geometry().y();
93 if ( (m & XNegative) ) 93 if ( (m & XNegative) )
94 x = KApplication::desktop()->width() + x - w; 94 x = KApplication::desktop()->width() + x - w;
95 if ( (m & YNegative) ) 95 if ( (m & YNegative) )
96 y = KApplication::desktop()->height() + y - h; 96 y = KApplication::desktop()->height() + y - h;
97 move(x, y); 97 move(x, y);
98 } 98 }
99#endif 99#endif
100*/ 100*/
101} 101}
102 102
103KMainWindow::~KMainWindow() 103KMainWindow::~KMainWindow()
104{ 104{
105 delete d->settingsTimer; 105 delete d->settingsTimer;
106 QMenuBar* mb = internalMenuBar(); 106 QMenuBar* mb = internalMenuBar();
107 delete mb; 107 delete mb;
108//US delete d->m_interface; 108//US delete d->m_interface;
109 109
110 delete d; 110 delete d;
111//US memberList->remove( this ); 111//US memberList->remove( this );
112} 112}
113 113
114void KMainWindow::initKMainWindow(const char *name) 114void KMainWindow::initKMainWindow(const char *name)
115{ 115{
116 setDockMenuEnabled( FALSE ); 116 setDockMenuEnabled( FALSE );
117//US mHelpMenu = 0; 117//US mHelpMenu = 0;
118 118
119//US kapp->setTopWidget( this ); 119//US kapp->setTopWidget( this );
120 actionCollection()->setWidget( this ); 120 actionCollection()->setWidget( this );
121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
122//US if( !memberList ) 122//US if( !memberList )
123//US memberList = new QPtrList<KMainWindow>; 123//US memberList = new QPtrList<KMainWindow>;
124/*US 124/*US
125 125
126 if ( !ksm ) 126 if ( !ksm )
127 ksm = ksmd.setObject(new KMWSessionManaged()); 127 ksm = ksmd.setObject(new KMWSessionManaged());
128 // set a unique object name. Required by session management. 128 // set a unique object name. Required by session management.
129 QCString objname; 129 QCString objname;
130 QCString s; 130 QCString s;
131 int unusedNumber; 131 int unusedNumber;
132 if ( !name ) 132 if ( !name )
133 { // no name given 133 { // no name given
134 objname = kapp->instanceName() + "-mainwindow#"; 134 objname = kapp->instanceName() + "-mainwindow#";
135 s = objname + '1'; // start adding number immediately 135 s = objname + '1'; // start adding number immediately
136 unusedNumber = 1; 136 unusedNumber = 1;
137 } 137 }
138 else if( name[ strlen( name ) - 1 ] == '#' ) 138 else if( name[ strlen( name ) - 1 ] == '#' )
139 { // trailing # - always add a number 139 { // trailing # - always add a number
140 objname = name; 140 objname = name;
141 s = objname + '1'; // start adding number immediately 141 s = objname + '1'; // start adding number immediately
142 unusedNumber = 1; 142 unusedNumber = 1;
143 } 143 }
144 else 144 else
145 { 145 {
146 objname = name; 146 objname = name;
147 s = objname; 147 s = objname;
148 unusedNumber = 0; // add numbers only when needed 148 unusedNumber = 0; // add numbers only when needed
149 } 149 }
150 for(;;) { 150 for(;;) {
151 QWidgetList* list = kapp->topLevelWidgets(); 151 QWidgetList* list = kapp->topLevelWidgets();
152 QWidgetListIt it( *list ); 152 QWidgetListIt it( *list );
153 bool found = false; 153 bool found = false;
154 for( QWidget* w = it.current(); 154 for( QWidget* w = it.current();
155 w != NULL; 155 w != NULL;
156 ++it, w = it.current()) 156 ++it, w = it.current())
157 if( w != this && w->name() == s ) 157 if( w != this && w->name() == s )
158 { 158 {
159 found = true; 159 found = true;
160 break; 160 break;
161 } 161 }
162 delete list; 162 delete list;
163 if( !found ) 163 if( !found )
164 break; 164 break;
165 s.setNum( ++unusedNumber ); 165 s.setNum( ++unusedNumber );
166 s = objname + s; 166 s = objname + s;
167 } 167 }
168 setName( s ); 168 setName( s );
169 memberList->append( this ); 169 memberList->append( this );
170*/ 170*/
171 171
172 d = new KMainWindowPrivate; 172 d = new KMainWindowPrivate;
173//US d->showHelpMenu = true; 173//US d->showHelpMenu = true;
174 d->settingsDirty = false; 174 d->settingsDirty = false;
175 d->autoSaveSettings = false; 175 d->autoSaveSettings = false;
176 d->autoSaveWindowSize = true; // for compatibility 176 d->autoSaveWindowSize = true; // for compatibility
177//US d->kaccel = actionCollection()->kaccel(); 177//US d->kaccel = actionCollection()->kaccel();
178 d->toolBarHandler = 0; 178 d->toolBarHandler = 0;
179 d->settingsTimer = 0; 179 d->settingsTimer = 0;
180 d->showStatusBarAction = NULL; 180 d->showStatusBarAction = NULL;
181/*US 181/*US
182 if ((d->care_about_geometry == beeing_first)) { 182 if ((d->care_about_geometry == beeing_first)) {
183 beeing_first = false; 183 beeing_first = false;
184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater 184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
185 d->care_about_geometry = false; 185 d->care_about_geometry = false;
186 else 186 else
187 parseGeometry(false); 187 parseGeometry(false);
188 } 188 }
189*/ 189*/
190 d->care_about_geometry = false; 190 d->care_about_geometry = false;
191 191
192//US setCaption( kapp->caption() ); 192//US setCaption( kapp->caption() );
193 // attach dcop interface 193 // attach dcop interface
194//US d->m_interface = new KMainWindowInterface(this); 194//US d->m_interface = new KMainWindowInterface(this);
195 195
196//US if (!kapp->authorize("movable_toolbars")) 196//US if (!kapp->authorize("movable_toolbars"))
197//US setDockWindowsMovable(false); 197//US setDockWindowsMovable(false);
198} 198}
199 199
200KAction *KMainWindow::toolBarMenuAction() 200KAction *KMainWindow::toolBarMenuAction()
201{ 201{
202 if ( !d->toolBarHandler ) 202 if ( !d->toolBarHandler )
203 return 0; 203 return 0;
204 204
205 return d->toolBarHandler->toolBarMenuAction(); 205 return d->toolBarHandler->toolBarMenuAction();
206} 206}
207 207
208bool KMainWindow::canBeRestored( int number ) 208bool KMainWindow::canBeRestored( int number )
209{ 209{
210/*US we do not have and want to save sessioninformation. Use info from the default 210/*US we do not have and want to save sessioninformation. Use info from the default
211application config. 211application config.
212*/ 212*/
213//US if ( !kapp->isRestored() ) 213//US if ( !kapp->isRestored() )
214//US return FALSE; 214//US return FALSE;
215//US KConfig *config = kapp->sessionConfig(); 215//US KConfig *config = kapp->sessionConfig();
216 KConfig *config = KGlobal::config(); 216 KConfig *config = KGlobal::config();
217 if ( !config ) 217 if ( !config )
218 return FALSE; 218 return FALSE;
219 config->setGroup( QString::fromLatin1("Number") ); 219 config->setGroup( QString::fromLatin1("Number") );
220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); 220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 );
221 return number >= 1 && number <= n; 221 return number >= 1 && number <= n;
222 222
223} 223}
224 224
225const QString KMainWindow::classNameOfToplevel( int number ) 225const QString KMainWindow::classNameOfToplevel( int number )
226{ 226{
227/*US we do not have and want to save sessioninformation. Use info from the default 227/*US we do not have and want to save sessioninformation. Use info from the default
228application config. 228application config.
229*/ 229*/
230//US if ( !kapp->isRestored() ) 230//US if ( !kapp->isRestored() )
231//US return QString::null; 231//US return QString::null;
232//US KConfig *config = kapp->sessionConfig(); 232//US KConfig *config = kapp->sessionConfig();
233 KConfig *config = KGlobal::config(); 233 KConfig *config = KGlobal::config();
234 if ( !config ) 234 if ( !config )
235 return QString::null; 235 return QString::null;
236 QString s; 236 QString s;
237 s.setNum( number ); 237 s.setNum( number );
238 s.prepend( QString::fromLatin1("WindowProperties") ); 238 s.prepend( QString::fromLatin1("WindowProperties") );
239 config->setGroup( s ); 239 config->setGroup( s );
240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) 240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) )
241 return QString::null; 241 return QString::null;
242 else 242 else
243 return config->readEntry( QString::fromLatin1("ClassName") ); 243 return config->readEntry( QString::fromLatin1("ClassName") );
244} 244}
245 245
246bool KMainWindow::restore( int number, bool show ) 246bool KMainWindow::restore( int number, bool show )
247{ 247{
248/*US we do not have and want to save sessioninformation. Use info from the default 248/*US we do not have and want to save sessioninformation. Use info from the default
249application config. 249application config.
250*/ 250*/
251 if ( !canBeRestored( number ) ) 251 if ( !canBeRestored( number ) )
252 return FALSE; 252 return FALSE;
253//US KConfig *config = kapp->sessionConfig(); 253//US KConfig *config = kapp->sessionConfig();
254 KConfig *config = KGlobal::config(); 254 KConfig *config = KGlobal::config();
255 255
256 if ( readPropertiesInternal( config, number ) ){ 256 if ( readPropertiesInternal( config, number ) ){
257 if ( show ) 257 if ( show )
258 KMainWindow::show(); 258 KMainWindow::show();
259 return FALSE; 259 return FALSE;
260 } 260 }
261 return FALSE; 261 return FALSE;
262 262
263} 263}
264 264
265void KMainWindow::setCaption( const QString &caption ) 265void KMainWindow::setCaption( const QString &caption )
266{ 266{
267//US setPlainCaption( kapp->makeStdCaption(caption) ); 267//US setPlainCaption( kapp->makeStdCaption(caption) );
268 setPlainCaption( caption ); 268 setPlainCaption( caption );
269} 269}
270 270
271void KMainWindow::setCaption( const QString &caption, bool modified ) 271void KMainWindow::setCaption( const QString &caption, bool modified )
272{ 272{
273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); 273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
274 setPlainCaption( caption + "modified:" ); 274 setPlainCaption( caption + "modified:" );
275} 275}
276 276
277void KMainWindow::setPlainCaption( const QString &caption ) 277void KMainWindow::setPlainCaption( const QString &caption )
278{ 278{
279 QMainWindow::setCaption( caption ); 279 QMainWindow::setCaption( caption );
280#ifndef Q_WS_QWS 280#ifndef Q_WS_QWS
281//US the following is disabled for the embedded version 281//US the following is disabled for the embedded version
282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); 282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
283//US info.setName( caption.utf8().data() ); 283//US info.setName( caption.utf8().data() );
284#endif 284#endif
285} 285}
286 286
287void KMainWindow::slotStateChanged(const QString &newstate) 287void KMainWindow::slotStateChanged(const QString &newstate)
288{ 288{
289 stateChanged(newstate, KXMLGUIClient::StateNoReverse); 289 stateChanged(newstate, KXMLGUIClient::StateNoReverse);
290} 290}
291 291
292/* 292/*
293 * Get rid of this for KDE 4.0 293 * Get rid of this for KDE 4.0
294 */ 294 */
295void KMainWindow::slotStateChanged(const QString &newstate, 295void KMainWindow::slotStateChanged(const QString &newstate,
296 KXMLGUIClient::ReverseStateChange reverse) 296 KXMLGUIClient::ReverseStateChange reverse)
297{ 297{
298 stateChanged(newstate, reverse); 298 stateChanged(newstate, reverse);
299} 299}
300 300
301void KMainWindow::closeEvent ( QCloseEvent *e ) 301void KMainWindow::closeEvent ( QCloseEvent *e )
302{ 302{
303 //qDebug("MainWindow::closeEvent "); 303 //qDebug("MainWindow::closeEvent ");
304 // Save settings if auto-save is enabled, and settings have changed 304 // Save settings if auto-save is enabled, and settings have changed
305 if (d->settingsDirty && d->autoSaveSettings) 305 if (d->settingsDirty && d->autoSaveSettings)
306 saveAutoSaveSettings(); 306 saveAutoSaveSettings();
307 307
308 if (queryClose()) { 308 if (queryClose()) {
309 e->accept(); 309 e->accept();
310 310
311 int not_withdrawn = 0; 311 int not_withdrawn = 0;
312/*US 312/*US
313 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); 313 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
314 for (it.toFirst(); it.current(); ++it){ 314 for (it.toFirst(); it.current(); ++it){
315 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) 315 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
316 not_withdrawn++; 316 not_withdrawn++;
317 } 317 }
318*/ 318*/
319 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? 319 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
320/*US 320/*US
321 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? 321 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app?
322 // don't call queryExit() twice 322 // don't call queryExit() twice
323 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 323 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
324 kapp->deref(); // ...and quit aplication. 324 kapp->deref(); // ...and quit aplication.
325 } else { 325 } else {
326 // cancel closing, it's stupid to end up with no windows at all.... 326 // cancel closing, it's stupid to end up with no windows at all....
327 e->ignore(); 327 e->ignore();
328 } 328 }
329*/ 329*/
330//US we have no sessionmanagement. Simply close app. 330//US we have no sessionmanagement. Simply close app.
331 if ( queryExit() ) { // Yes, Quit app? 331 if ( queryExit() ) { // Yes, Quit app?
332 qDebug("KMainWindow::closeEvent: Exit application ???"); 332 qDebug("KMainWindow::closeEvent: Exit application ???");
333 // don't call queryExit() twice 333 // don't call queryExit() twice
334//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 334//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
335 } 335 }
336 336
337 } 337 }
338 } 338 }
339} 339}
340 340
341bool KMainWindow::queryExit() 341bool KMainWindow::queryExit()
342{ 342{
343 return TRUE; 343 return TRUE;
344} 344}
345 345
346bool KMainWindow::queryClose() 346bool KMainWindow::queryClose()
347{ 347{
348 return TRUE; 348 return TRUE;
349} 349}
350 350
351void KMainWindow::saveGlobalProperties( KConfig* ) 351void KMainWindow::saveGlobalProperties( KConfig* )
352{ 352{
353} 353}
354 354
355void KMainWindow::readGlobalProperties( KConfig* ) 355void KMainWindow::readGlobalProperties( KConfig* )
356{ 356{
357} 357}
358 358
359void KMainWindow::savePropertiesInternal( KConfig *config, int number ) 359void KMainWindow::savePropertiesInternal( KConfig *config, int number )
360{ 360{
361 bool oldASWS = d->autoSaveWindowSize; 361 bool oldASWS = d->autoSaveWindowSize;
362 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size 362 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
363 363
364 QString s; 364 QString s;
365 s.setNum(number); 365 s.setNum(number);
366 s.prepend(QString::fromLatin1("WindowProperties")); 366 s.prepend(QString::fromLatin1("WindowProperties"));
367 config->setGroup(s); 367 config->setGroup(s);
368 368
369 // store objectName, className, Width and Height for later restoring 369 // store objectName, className, Width and Height for later restoring
370 // (Only useful for session management) 370 // (Only useful for session management)
371 config->writeEntry(QString::fromLatin1("ObjectName"), name()); 371 config->writeEntry(QString::fromLatin1("ObjectName"), name());
372 config->writeEntry(QString::fromLatin1("ClassName"), className()); 372 config->writeEntry(QString::fromLatin1("ClassName"), className());
373 373
374 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. 374 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
375 375
376 s.setNum(number); 376 s.setNum(number);
377 config->setGroup(s); 377 config->setGroup(s);
378 saveProperties(config); 378 saveProperties(config);
379 379
380 d->autoSaveWindowSize = oldASWS; 380 d->autoSaveWindowSize = oldASWS;
381} 381}
382 382
383void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) 383void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
384{ 384{
385 if ( enable ) 385 if ( enable )
386 { 386 {
387 if ( d->toolBarHandler ) 387 if ( d->toolBarHandler )
388 return; 388 return;
389 389
390 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); 390 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
391 391
392/*US if ( factory() ) 392/*US if ( factory() )
393 factory()->addClient( d->toolBarHandler ); 393 factory()->addClient( d->toolBarHandler );
394*/ 394*/
395 } 395 }
396 else 396 else
397 { 397 {
398 if ( !d->toolBarHandler ) 398 if ( !d->toolBarHandler )
399 return; 399 return;
400/*US 400/*US
401 if ( factory() ) 401 if ( factory() )
402 factory()->removeClient( d->toolBarHandler ); 402 factory()->removeClient( d->toolBarHandler );
403*/ 403*/
404 delete d->toolBarHandler; 404 delete d->toolBarHandler;
405 d->toolBarHandler = 0; 405 d->toolBarHandler = 0;
406 } 406 }
407 407
408} 408}
409 409
410bool KMainWindow::isStandardToolBarMenuEnabled() const 410bool KMainWindow::isStandardToolBarMenuEnabled() const
411{ 411{
412 return ( d->toolBarHandler != 0 ); 412 return ( d->toolBarHandler != 0 );
413} 413}
414 414
415void KMainWindow::createStandardStatusBarAction(){ 415void KMainWindow::createStandardStatusBarAction(){
416 if(!d->showStatusBarAction){ 416 if(!d->showStatusBarAction){
417 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); 417 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
418 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); 418 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
419 if(internalStatusBar()) 419 if(internalStatusBar())
420 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); 420 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
421 } 421 }
422} 422}
423 423
424QToolBar *KMainWindow::tBar( ) 424QToolBar *KMainWindow::tBar( )
425{ 425{
426 if ( ! mQToolBar ) 426 if ( ! mQToolBar )
427 mQToolBar = new QToolBar( this ); 427 mQToolBar = new QToolBar( this );
428 return mQToolBar; 428 return mQToolBar;
429} 429}
430 430
431KToolBar *KMainWindow::toolBar( const char * name ) 431KToolBar *KMainWindow::toolBar( const char * name )
432{ 432{
433 433
434 if (!name) 434 if (!name)
435 name = "mainToolBar"; 435 name = "mainToolBar";
436 KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); 436 KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
437 if ( tb ) 437 if ( tb )
438 return tb; 438 return tb;
439 bool honor_mode = (name == "mainToolBar"); 439 bool honor_mode = (name == "mainToolBar");
440 440
441/*US 441/*US
442 if ( builderClient() ) 442 if ( builderClient() )
443 return new KToolBar(this, name, honor_mode); // XMLGUI constructor 443 return new KToolBar(this, name, honor_mode); // XMLGUI constructor
444 else 444 else
445*/ 445*/
446 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI 446 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI
447} 447}
448 448
449QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() 449QPtrListIterator<KToolBar> KMainWindow::toolBarIterator()
450{ 450{
451 toolbarList.clear(); 451 toolbarList.clear();
452 QPtrList<QToolBar> lst; 452 QPtrList<QToolBar> lst;
453 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { 453 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) {
454 lst = toolBars( (ToolBarDock)i ); 454 lst = toolBars( (ToolBarDock)i );
455 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { 455 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) {
456 if ( !tb->inherits( "KToolBar" ) ) 456 if ( !tb->inherits( "KToolBar" ) )
457 continue; 457 continue;
458 toolbarList.append( (KToolBar*)tb ); 458 toolbarList.append( (KToolBar*)tb );
459 } 459 }
460 } 460 }
461 return QPtrListIterator<KToolBar>( toolbarList ); 461 return QPtrListIterator<KToolBar>( toolbarList );
462} 462}
463 463
464void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) 464void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize )
465{ 465{
466 d->autoSaveSettings = true; 466 d->autoSaveSettings = true;
467 d->autoSaveGroup = groupName; 467 d->autoSaveGroup = groupName;
468 d->autoSaveWindowSize = saveWindowSize; 468 d->autoSaveWindowSize = saveWindowSize;
469 // Get notified when the user moves a toolbar around 469 // Get notified when the user moves a toolbar around
470//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), 470//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ),
471//US this, SLOT( setSettingsDirty() ) ); 471//US this, SLOT( setSettingsDirty() ) );
472 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), 472 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ),
473 this, SLOT( setSettingsDirty() ) ); 473 this, SLOT( setSettingsDirty() ) );
474 474
475 475
476 // Get default values 476 // Get default values
477//US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 477//US int scnum = QApplication::desktop()->screenNumber(parentWidget());
478//US QRect desk = QApplication::desktop()->screenGeometry(scnum); 478//US QRect desk = QApplication::desktop()->screenGeometry(scnum);
479 QRect desk = KGlobalSettings::desktopGeometry(0); 479 QRect desk = KGlobalSettings::desktopGeometry(0);
480 480
481 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); 481 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height());
482 // Now read the previously saved settings 482 // Now read the previously saved settings
483 applyMainWindowSettings( KGlobal::config(), groupName ); 483 applyMainWindowSettings( KGlobal::config(), groupName );
484} 484}
485 485
486 486
487void KMainWindow::resetAutoSaveSettings() 487void KMainWindow::resetAutoSaveSettings()
488{ 488{
489 d->autoSaveSettings = false; 489 d->autoSaveSettings = false;
490 if ( d->settingsTimer ) 490 if ( d->settingsTimer )
491 d->settingsTimer->stop(); 491 d->settingsTimer->stop();
492} 492}
493 493
494bool KMainWindow::autoSaveSettings() const 494bool KMainWindow::autoSaveSettings() const
495{ 495{
496 return d->autoSaveSettings; 496 return d->autoSaveSettings;
497} 497}
498 498
499QString KMainWindow::autoSaveGroup() const 499QString KMainWindow::autoSaveGroup() const
500{ 500{
501 return d->autoSaveGroup; 501 return d->autoSaveGroup;
502} 502}
503 503
504void KMainWindow::saveAutoSaveSettings() 504void KMainWindow::saveAutoSaveSettings()
505{ 505{
506 ASSERT( d->autoSaveSettings ); 506 ASSERT( d->autoSaveSettings );
507 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; 507 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
508 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); 508 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
509 KGlobal::config()->sync(); 509 KGlobal::config()->sync();
510 d->settingsDirty = false; 510 d->settingsDirty = false;
511 if ( d->settingsTimer ) 511 if ( d->settingsTimer )
512 d->settingsTimer->stop(); 512 d->settingsTimer->stop();
513} 513}
514 514
515void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) 515void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
516{ 516{
517 // disabling the updates prevents unnecessary redraws 517 // disabling the updates prevents unnecessary redraws
518 setUpdatesEnabled( false ); 518 setUpdatesEnabled( false );
519 519
520 // just in case we are rebuilding, let's remove our old client 520 // just in case we are rebuilding, let's remove our old client
521//US guiFactory()->removeClient( this ); 521//US guiFactory()->removeClient( this );
522 522
523 // make sure to have an empty GUI 523 // make sure to have an empty GUI
524 QMenuBar* mb = internalMenuBar(); 524 QMenuBar* mb = internalMenuBar();
525 if ( mb ) 525 if ( mb )
526 mb->clear(); 526 mb->clear();
527 527
528 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date 528 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date
529 toolbarList.setAutoDelete( true ); 529 toolbarList.setAutoDelete( true );
530 toolbarList.clear(); 530 toolbarList.clear();
531 toolbarList.setAutoDelete( false ); 531 toolbarList.setAutoDelete( false );
532/*US 532/*US
533 // don't build a help menu unless the user ask for it 533 // don't build a help menu unless the user ask for it
534 if (d->showHelpMenu) { 534 if (d->showHelpMenu) {
535 // we always want a help menu 535 // we always want a help menu
536 if (helpMenu2 == 0) 536 if (helpMenu2 == 0)
537 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, 537 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true,
538 actionCollection()); 538 actionCollection());
539 } 539 }
540 540
541 // we always want to load in our global standards file 541 // we always want to load in our global standards file
542 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); 542 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
543 543
544 // now, merge in our local xml file. if this is null, then that 544 // now, merge in our local xml file. if this is null, then that
545 // means that we will be only using the global file 545 // means that we will be only using the global file
546 if ( !xmlfile.isNull() ) { 546 if ( !xmlfile.isNull() ) {
547 setXMLFile( xmlfile, true ); 547 setXMLFile( xmlfile, true );
548 } else { 548 } else {
549 QString auto_file(instance()->instanceName() + "ui.rc"); 549 QString auto_file(instance()->instanceName() + "ui.rc");
550 setXMLFile( auto_file, true ); 550 setXMLFile( auto_file, true );
551 } 551 }
552 552
553 // make sure we don't have any state saved already 553 // make sure we don't have any state saved already
554 setXMLGUIBuildDocument( QDomDocument() ); 554 setXMLGUIBuildDocument( QDomDocument() );
555 555
556 // do the actual GUI building 556 // do the actual GUI building
557 guiFactory()->addClient( this ); 557 guiFactory()->addClient( this );
558 558
559 // try and get back *some* of our memory 559 // try and get back *some* of our memory
560 if ( _conserveMemory ) 560 if ( _conserveMemory )
561 { 561 {
562 // before freeing the memory allocated by the DOM document we also 562 // before freeing the memory allocated by the DOM document we also
563 // free all memory allocated internally in the KXMLGUIFactory for 563 // free all memory allocated internally in the KXMLGUIFactory for
564 // the menubar and the toolbars . This however implies that we 564 // the menubar and the toolbars . This however implies that we
565 // have to take care of deleting those widgets ourselves. For 565 // have to take care of deleting those widgets ourselves. For
566 // destruction this is no problem, but when rebuilding we have 566 // destruction this is no problem, but when rebuilding we have
567 // to take care of that (and we want to rebuild the GUI when 567 // to take care of that (and we want to rebuild the GUI when
568 // using stuff like the toolbar editor ). 568 // using stuff like the toolbar editor ).
569 // In addition we have to take care of not removing containers 569 // In addition we have to take care of not removing containers
570 // like popupmenus, defined in the XML document. 570 // like popupmenus, defined in the XML document.
571 // this code should probably go into a separate method in KMainWindow. 571 // this code should probably go into a separate method in KMainWindow.
572 // there's just one problem: I'm bad in finding names ;-) , so 572 // there's just one problem: I'm bad in finding names ;-) , so
573 // I skipped this ;-) 573 // I skipped this ;-)
574 574
575 QDomDocument doc = domDocument(); 575 QDomDocument doc = domDocument();
576 576
577 QDomElement e = doc.documentElement().firstChild().toElement(); 577 QDomElement e = doc.documentElement().firstChild().toElement();
578 for (; !e.isNull(); e = e.nextSibling().toElement() ) { 578 for (; !e.isNull(); e = e.nextSibling().toElement() ) {
579 if ( e.tagName().lower() == "toolbar" ) 579 if ( e.tagName().lower() == "toolbar" )
580 factory_->resetContainer( e.attribute( "name" ) ); 580 factory_->resetContainer( e.attribute( "name" ) );
581 else if ( e.tagName().lower() == "menubar" ) 581 else if ( e.tagName().lower() == "menubar" )
582 factory_->resetContainer( e.tagName(), true ); 582 factory_->resetContainer( e.tagName(), true );
583 } 583 }
584 584
585 conserveMemory(); 585 conserveMemory();
586 } 586 }
587*/ 587*/
588 setUpdatesEnabled( true ); 588 setUpdatesEnabled( true );
589 updateGeometry(); 589 updateGeometry();
590} 590}
591 591
592void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) 592void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup)
593{ 593{
594 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; 594 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl;
595//US QStrList entryList; 595//US QStrList entryList;
596 QStringList entryList; 596 QStringList entryList;
597 QString oldGroup; 597 QString oldGroup;
598 598
599 if (!configGroup.isEmpty()) 599 if (!configGroup.isEmpty())
600 { 600 {
601 oldGroup = config->group(); 601 oldGroup = config->group();
602 config->setGroup(configGroup); 602 config->setGroup(configGroup);
603 } 603 }
604 604
605 // Called by session management - or if we want to save the window size anyway 605 // Called by session management - or if we want to save the window size anyway
606 if ( d->autoSaveWindowSize ) 606 if ( d->autoSaveWindowSize )
607 saveWindowSize( config ); 607 saveWindowSize( config );
608 608
609 QStatusBar* sb = internalStatusBar(); 609 QStatusBar* sb = internalStatusBar();
610 if (sb) { 610 if (sb) {
611 entryList.clear(); 611 entryList.clear();
612 if ( sb->isHidden() ) 612 if ( sb->isHidden() )
613 entryList.append("Disabled"); 613 entryList.append("Disabled");
614 else 614 else
615 entryList.append("Enabled"); 615 entryList.append("Enabled");
616 616
617 if(sb->isHidden()) 617 if(sb->isHidden())
618 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); 618 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';');
619 config->writeEntry(QString::fromLatin1("StatusBar"), entryList); 619 config->writeEntry(QString::fromLatin1("StatusBar"), entryList);
620 else 620 else
621 config->deleteEntry(QString::fromLatin1("StatusBar")); 621 config->deleteEntry(QString::fromLatin1("StatusBar"));
622 } 622 }
623 623
624 QMenuBar* mb = internalMenuBar(); 624 QMenuBar* mb = internalMenuBar();
625 if (mb) { 625 if (mb) {
626 entryList.clear(); 626 entryList.clear();
627 if ( mb->isHidden() ) 627 if ( mb->isHidden() )
628 entryList.append("Disabled"); 628 entryList.append("Disabled");
629 else 629 else
630 entryList.append("Enabled"); 630 entryList.append("Enabled");
631 631
632 // By default we don't hide. 632 // By default we don't hide.
633 if(mb->isHidden()) 633 if(mb->isHidden())
634 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); 634 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';');
635 config->writeEntry(QString::fromLatin1("MenuBar"), entryList); 635 config->writeEntry(QString::fromLatin1("MenuBar"), entryList);
636 else 636 else
637 config->deleteEntry(QString::fromLatin1("MenuBar")); 637 config->deleteEntry(QString::fromLatin1("MenuBar"));
638 } 638 }
639 639
640 int n = 1; // Toolbar counter. toolbars are counted from 1, 640 int n = 1; // Toolbar counter. toolbars are counted from 1,
641 KToolBar *toolbar = 0; 641 KToolBar *toolbar = 0;
642 QPtrListIterator<KToolBar> it( toolBarIterator() ); 642 QPtrListIterator<KToolBar> it( toolBarIterator() );
643 while ( ( toolbar = it.current() ) ) { 643 while ( ( toolbar = it.current() ) ) {
644 ++it; 644 ++it;
645 QString group; 645 QString group;
646 if (!configGroup.isEmpty()) 646 if (!configGroup.isEmpty())
647 { 647 {
648 // Give a number to the toolbar, but prefer a name if there is one, 648 // Give a number to the toolbar, but prefer a name if there is one,
649 // because there's no real guarantee on the ordering of toolbars 649 // because there's no real guarantee on the ordering of toolbars
650 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); 650 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
651 group.prepend(" Toolbar"); 651 group.prepend(" Toolbar");
652 group.prepend(configGroup); 652 group.prepend(configGroup);
653 } 653 }
654 toolbar->saveSettings(config, group); 654 toolbar->saveSettings(config, group);
655 n++; 655 n++;
656 } 656 }
657 if (!configGroup.isEmpty()) 657 if (!configGroup.isEmpty())
658 config->setGroup(oldGroup); 658 config->setGroup(oldGroup);
659} 659}
660 660
661bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) 661bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
662{ 662{
663 if ( number == 1 ) 663 if ( number == 1 )
664 readGlobalProperties( config ); 664 readGlobalProperties( config );
665 665
666 // in order they are in toolbar list 666 // in order they are in toolbar list
667 QString s; 667 QString s;
668 s.setNum(number); 668 s.setNum(number);
669 s.prepend(QString::fromLatin1("WindowProperties")); 669 s.prepend(QString::fromLatin1("WindowProperties"));
670 670
671 config->setGroup(s); 671 config->setGroup(s);
672 672
673 // restore the object name (window role) 673 // restore the object name (window role)
674 if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) 674 if ( config->hasKey(QString::fromLatin1("ObjectName" )) )
675 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here 675 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here
676 676
677 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. 677 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings.
678 678
679 s.setNum(number); 679 s.setNum(number);
680 config->setGroup(s); 680 config->setGroup(s);
681 readProperties(config); 681 readProperties(config);
682 return true; 682 return true;
683} 683}
684 684
685void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) 685void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup)
686{ 686{
687 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; 687 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl;
688 QString entry; 688 QString entry;
689//US QStrList entryList; 689//US QStrList entryList;
690 QStringList entryList; 690 QStringList entryList;
691 int i = 0; // Number of entries in list 691 int i = 0; // Number of entries in list
692 692
693 if (!configGroup.isEmpty()) 693 if (!configGroup.isEmpty())
694 config->setGroup(configGroup); 694 config->setGroup(configGroup);
695 695
696 restoreWindowSize(config); 696 restoreWindowSize(config);
697 697
698 QStatusBar* sb = internalStatusBar(); 698 QStatusBar* sb = internalStatusBar();
699 if (sb) { 699 if (sb) {
700 entryList.clear(); 700 entryList.clear();
701//US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); 701//US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';');
702 entryList = config->readListEntry (QString::fromLatin1("StatusBar")); 702 entryList = config->readListEntry (QString::fromLatin1("StatusBar"));
703 entry = entryList.first(); 703 entry = entryList.first();
704 if (entry == QString::fromLatin1("Disabled")) 704 if (entry == QString::fromLatin1("Disabled"))
705 sb->hide(); 705 sb->hide();
706 else 706 else
707 sb->show(); 707 sb->show();
708 if(d->showStatusBarAction) 708 if(d->showStatusBarAction)
709 d->showStatusBarAction->setChecked(!sb->isHidden()); 709 d->showStatusBarAction->setChecked(!sb->isHidden());
710 } 710 }
711 711
712 QMenuBar* mb = internalMenuBar(); 712 QMenuBar* mb = internalMenuBar();
713 if (mb) { 713 if (mb) {
714 entryList.clear(); 714 entryList.clear();
715//US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); 715//US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';');
716 entryList = config->readListEntry (QString::fromLatin1("MenuBar")); 716 entryList = config->readListEntry (QString::fromLatin1("MenuBar"));
717 entry = entryList.first(); 717 entry = entryList.first();
718 if (entry==QString::fromLatin1("Disabled")) 718 if (entry==QString::fromLatin1("Disabled"))
719 { 719 {
720 mb->hide(); 720 mb->hide();
721 } else 721 } else
722 { 722 {
723 mb->show(); 723 mb->show();
724 } 724 }
725 } 725 }
726 726
727 int n = 1; // Toolbar counter. toolbars are counted from 1, 727 int n = 1; // Toolbar counter. toolbars are counted from 1,
728 KToolBar *toolbar; 728 KToolBar *toolbar;
729 QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator 729 QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator
730 730
731 for ( ; it.current(); ++it) { 731 for ( ; it.current(); ++it) {
732 toolbar= it.current(); 732 toolbar= it.current();
733 QString group; 733 QString group;
734 if (!configGroup.isEmpty()) 734 if (!configGroup.isEmpty())
735 { 735 {
736 // Give a number to the toolbar, but prefer a name if there is one, 736 // Give a number to the toolbar, but prefer a name if there is one,
737 // because there's no real guarantee on the ordering of toolbars 737 // because there's no real guarantee on the ordering of toolbars
738 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); 738 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
739 group.prepend(" Toolbar"); 739 group.prepend(" Toolbar");
740 group.prepend(configGroup); 740 group.prepend(configGroup);
741 } 741 }
742 toolbar->applySettings(config, group); 742 toolbar->applySettings(config, group);
743 n++; 743 n++;
744 } 744 }
745 745
746 finalizeGUI( true ); 746 finalizeGUI( true );
747 } 747 }
748 748
749void KMainWindow::finalizeGUI( bool force ) 749void KMainWindow::finalizeGUI( bool force )
750{ 750{
751 //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; 751 //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl;
752 // The whole reason for this is that moveToolBar relies on the indexes 752 // The whole reason for this is that moveToolBar relies on the indexes
753 // of the other toolbars, so in theory it should be called only once per 753 // of the other toolbars, so in theory it should be called only once per
754 // toolbar, but in increasing order of indexes. 754 // toolbar, but in increasing order of indexes.
755 // Since we can't do that immediately, we move them, and _then_ 755 // Since we can't do that immediately, we move them, and _then_
756 // we call positionYourself again for each of them, but this time 756 // we call positionYourself again for each of them, but this time
757 // the toolbariterator should give them in the proper order. 757 // the toolbariterator should give them in the proper order.
758 // Both the XMLGUI and applySettings call this, hence "force" for the latter. 758 // Both the XMLGUI and applySettings call this, hence "force" for the latter.
759 QPtrListIterator<KToolBar> it( toolBarIterator() ); 759 QPtrListIterator<KToolBar> it( toolBarIterator() );
760 for ( ; it.current() ; ++ it ) 760 for ( ; it.current() ; ++ it )
761 it.current()->positionYourself( force ); 761 it.current()->positionYourself( force );
762 762
763 d->settingsDirty = false; 763 d->settingsDirty = false;
764} 764}
765 765
766void KMainWindow::saveWindowSize( KConfig * config ) const 766void KMainWindow::saveWindowSize( KConfig * config ) const
767{ 767{
768/*US 768/*US
769 int scnum = QApplication::desktop()->screenNumber(parentWidget()); 769 int scnum = QApplication::desktop()->screenNumber(parentWidget());
770 QRect desk = QApplication::desktop()->screenGeometry(scnum); 770 QRect desk = QApplication::desktop()->screenGeometry(scnum);
771*/ 771*/
772 QRect desk = KGlobalSettings::desktopGeometry(0); 772 QRect desk = KGlobalSettings::desktopGeometry(0);
773 773
774 QRect size( desk.width(), width(), desk.height(), height() ); 774 QRect size( desk.width(), width(), desk.height(), height() );
775 if(size != d->defaultWindowSize){ 775 if(size != d->defaultWindowSize){
776 config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); 776 config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() );
777 config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); 777 config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() );
778 } 778 }
779 else{ 779 else{
780 config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); 780 config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width()));
781 config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); 781 config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height()));
782 } 782 }
783} 783}
784 784
785void KMainWindow::restoreWindowSize( KConfig * config ) 785void KMainWindow::restoreWindowSize( KConfig * config )
786{ 786{
787 if (d->care_about_geometry) { 787 if (d->care_about_geometry) {
788 parseGeometry(true); 788 parseGeometry(true);
789 } else { 789 } else {
790 // restore the size 790 // restore the size
791/*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 791/*US int scnum = QApplication::desktop()->screenNumber(parentWidget());
792 QRect desk = QApplication::desktop()->screenGeometry(scnum); 792 QRect desk = QApplication::desktop()->screenGeometry(scnum);
793*/ 793*/
794 QRect desk = KGlobalSettings::desktopGeometry(0); 794 QRect desk = KGlobalSettings::desktopGeometry(0);
795 795
796 QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), 796 QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ),
797 config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); 797 config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) );
798 if (size.isEmpty()) { 798 if (size.isEmpty()) {
799 // try the KDE 2.0 way 799 // try the KDE 2.0 way
800 size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), 800 size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ),
801 config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); 801 config->readNumEntry( QString::fromLatin1("Height"), 0 ) );
802 if (!size.isEmpty()) { 802 if (!size.isEmpty()) {
803 // make sure the other resolutions don't get old settings 803 // make sure the other resolutions don't get old settings
804 config->writeEntry( QString::fromLatin1("Width"), 0 ); 804 config->writeEntry( QString::fromLatin1("Width"), 0 );
805 config->writeEntry( QString::fromLatin1("Height"), 0 ); 805 config->writeEntry( QString::fromLatin1("Height"), 0 );
806 } 806 }
807 } 807 }
808 if ( !size.isEmpty() ) 808 if ( !size.isEmpty() )
809 resize( size ); 809 resize( size );
810 } 810 }
811} 811}
812 812
813bool KMainWindow::initialGeometrySet() const 813bool KMainWindow::initialGeometrySet() const
814{ 814{
815 return d->care_about_geometry; 815 return d->care_about_geometry;
816} 816}
817 817
818void KMainWindow::ignoreInitialGeometry() 818void KMainWindow::ignoreInitialGeometry()
819{ 819{
820 d->care_about_geometry = false; 820 d->care_about_geometry = false;
821} 821}
822 822
823void KMainWindow::setSettingsDirty() 823void KMainWindow::setSettingsDirty()
824{ 824{
825 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; 825 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl;
826 d->settingsDirty = true; 826 d->settingsDirty = true;
827 if ( d->autoSaveSettings ) 827 if ( d->autoSaveSettings )
828 { 828 {
829 // Use a timer to save "immediately" user-wise, but not too immediately 829 // Use a timer to save "immediately" user-wise, but not too immediately
830 // (to compress calls and save only once, in case of multiple changes) 830 // (to compress calls and save only once, in case of multiple changes)
831 if ( !d->settingsTimer ) 831 if ( !d->settingsTimer )
832 { 832 {
833 d->settingsTimer = new QTimer( this ); 833 d->settingsTimer = new QTimer( this );
834 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); 834 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) );
835 } 835 }
836 d->settingsTimer->start( 500, true ); 836 d->settingsTimer->start( 500, true );
837 } 837 }
838} 838}
839 839
840bool KMainWindow::settingsDirty() const 840bool KMainWindow::settingsDirty() const
841{ 841{
842 return d->settingsDirty; 842 return d->settingsDirty;
843} 843}
844 844
845QString KMainWindow::settingsGroup() const 845QString KMainWindow::settingsGroup() const
846{ 846{
847 return d->autoSaveGroup; 847 return d->autoSaveGroup;
848} 848}
849 849
850void KMainWindow::resizeEvent( QResizeEvent * ) 850void KMainWindow::resizeEvent( QResizeEvent * e)
851{ 851{
852 if ( d->autoSaveWindowSize ) 852 if ( d->autoSaveWindowSize )
853 setSettingsDirty(); 853 setSettingsDirty();
854 QMainWindow::resizeEvent( e );
854} 855}
855 856
856bool KMainWindow::hasMenuBar() 857bool KMainWindow::hasMenuBar()
857{ 858{
858 return (internalMenuBar()); 859 return (internalMenuBar());
859} 860}
860 861
861//US KMenuBar *KMainWindow::menuBar() 862//US KMenuBar *KMainWindow::menuBar()
862QMenuBar *KMainWindow::menuBar() 863QMenuBar *KMainWindow::menuBar()
863{ 864{
864//US KMenuBar * mb = internalMenuBar(); 865//US KMenuBar * mb = internalMenuBar();
865 QMenuBar * mb = internalMenuBar(); 866 QMenuBar * mb = internalMenuBar();
866 if ( !mb ) { 867 if ( !mb ) {
867//US mb = new KMenuBar( this ); 868//US mb = new KMenuBar( this );
868 mb = new QMenuBar( this ); 869 mb = new QMenuBar( this );
869 // trigger a re-layout and trigger a call to the private 870 // trigger a re-layout and trigger a call to the private
870 // setMenuBar method. 871 // setMenuBar method.
871 QMainWindow::menuBar(); 872 QMainWindow::menuBar();
872 } 873 }
873 return mb; 874 return mb;
874} 875}
875 876
876//US KStatusBar *KMainWindow::statusBar() 877//US KStatusBar *KMainWindow::statusBar()
877QStatusBar *KMainWindow::statusBar() 878QStatusBar *KMainWindow::statusBar()
878{ 879{
879//US KStatusBar * sb = internalStatusBar(); 880//US KStatusBar * sb = internalStatusBar();
880 QStatusBar * sb = internalStatusBar(); 881 QStatusBar * sb = internalStatusBar();
881 if ( !sb ) { 882 if ( !sb ) {
882//US sb = new KStatusBar( this ); 883//US sb = new KStatusBar( this );
883 sb = new QStatusBar( this ); 884 sb = new QStatusBar( this );
884 // trigger a re-layout and trigger a call to the private 885 // trigger a re-layout and trigger a call to the private
885 // setStatusBar method. 886 // setStatusBar method.
886 QMainWindow::statusBar(); 887 QMainWindow::statusBar();
887 } 888 }
888 return sb; 889 return sb;
889} 890}
890 891
891void KMainWindow::shuttingDown() 892void KMainWindow::shuttingDown()
892{ 893{
893 // Needed for Qt <= 3.0.3 at least to prevent reentrancy 894 // Needed for Qt <= 3.0.3 at least to prevent reentrancy
894 // when queryExit() shows a dialog. Check before removing! 895 // when queryExit() shows a dialog. Check before removing!
895 static bool reentrancy_protection = false; 896 static bool reentrancy_protection = false;
896 if (!reentrancy_protection) 897 if (!reentrancy_protection)
897 { 898 {
898 reentrancy_protection = true; 899 reentrancy_protection = true;
899 // call the virtual queryExit 900 // call the virtual queryExit
900 queryExit(); 901 queryExit();
901 reentrancy_protection = false; 902 reentrancy_protection = false;
902 } 903 }
903 904
904} 905}
905 906
906//US KMenuBar *KMainWindow::internalMenuBar() 907//US KMenuBar *KMainWindow::internalMenuBar()
907QMenuBar *KMainWindow::internalMenuBar() 908QMenuBar *KMainWindow::internalMenuBar()
908{ 909{
909//US QObjectList *l = queryList( "KMenuBar", 0, false, false ); 910//US QObjectList *l = queryList( "KMenuBar", 0, false, false );
910 QObjectList *l = queryList( "QMenuBar", 0, false, false ); 911 QObjectList *l = queryList( "QMenuBar", 0, false, false );
911 if ( !l || !l->first() ) { 912 if ( !l || !l->first() ) {
912 delete l; 913 delete l;
913 return 0; 914 return 0;
914 } 915 }
915 916
916//US KMenuBar *m = (KMenuBar*)l->first(); 917//US KMenuBar *m = (KMenuBar*)l->first();
917 QMenuBar *m = (QMenuBar*)l->first(); 918 QMenuBar *m = (QMenuBar*)l->first();
918 delete l; 919 delete l;
919 return m; 920 return m;
920} 921}
921 922
922//US KStatusBar *KMainWindow::internalStatusBar() 923//US KStatusBar *KMainWindow::internalStatusBar()
923QStatusBar *KMainWindow::internalStatusBar() 924QStatusBar *KMainWindow::internalStatusBar()
924{ 925{
925//US QObjectList *l = queryList( "KStatusBar", 0, false, false ); 926//US QObjectList *l = queryList( "KStatusBar", 0, false, false );
926 QObjectList *l = queryList( "QStatusBar", 0, false, false ); 927 QObjectList *l = queryList( "QStatusBar", 0, false, false );
927 if ( !l || !l->first() ) { 928 if ( !l || !l->first() ) {
928 delete l; 929 delete l;
929 return 0; 930 return 0;
930 } 931 }
931 932
932//US KStatusBar *s = (KStatusBar*)l->first(); 933//US KStatusBar *s = (KStatusBar*)l->first();
933 QStatusBar *s = (QStatusBar*)l->first(); 934 QStatusBar *s = (QStatusBar*)l->first();
934 delete l; 935 delete l;
935 return s; 936 return s;
936} 937}
937 938
938void KMainWindow::childEvent( QChildEvent* e) 939void KMainWindow::childEvent( QChildEvent* e)
939{ 940{
940 QMainWindow::childEvent( e ); 941 QMainWindow::childEvent( e );
941} 942}
942 943
943void KMainWindow::paintEvent( QPaintEvent * ) 944void KMainWindow::paintEvent( QPaintEvent * e)
944{ 945{
945 // do nothing 946 QMainWindow::paintEvent( e );
946} 947}
947 948
948QSize KMainWindow::sizeForCentralWidgetSize(QSize size) 949QSize KMainWindow::sizeForCentralWidgetSize(QSize size)
949{ 950{
950 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); 951 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" );
951 if (tb && !tb->isHidden()) { 952 if (tb && !tb->isHidden()) {
952 switch( tb->barPos() ) 953 switch( tb->barPos() )
953 { 954 {
954 case KToolBar::Top: 955 case KToolBar::Top:
955 case KToolBar::Bottom: 956 case KToolBar::Bottom:
956 size += QSize(0, tb->sizeHint().height()); 957 size += QSize(0, tb->sizeHint().height());
957 break; 958 break;
958 959
959 case KToolBar::Left: 960 case KToolBar::Left:
960 case KToolBar::Right: 961 case KToolBar::Right:
961 size += QSize(toolBar()->sizeHint().width(), 0); 962 size += QSize(toolBar()->sizeHint().width(), 0);
962 break; 963 break;
963 964
964 case KToolBar::Flat: 965 case KToolBar::Flat:
965//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 966//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
966 size += QSize(0, tb->sizeHint().height()); 967 size += QSize(0, tb->sizeHint().height());
967 break; 968 break;
968 969
969 default: 970 default:
970 break; 971 break;
971 } 972 }
972 } 973 }
973//US KMenuBar *mb = menuBar(); 974//US KMenuBar *mb = menuBar();
974 QMenuBar *mb = menuBar(); 975 QMenuBar *mb = menuBar();
975 if (!mb->isHidden()) { 976 if (!mb->isHidden()) {
976 size += QSize(0,mb->heightForWidth(size.width())); 977 size += QSize(0,mb->heightForWidth(size.width()));
977/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) 978/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this))
978 size += QSize( 0, dockWindowsMovable() ? 1 : 2); 979 size += QSize( 0, dockWindowsMovable() ? 1 : 2);
979*/ 980*/
980 size += QSize( 0, 2); 981 size += QSize( 0, 2);
981 } 982 }
982 QStatusBar *sb = internalStatusBar(); 983 QStatusBar *sb = internalStatusBar();
983 if( sb && !sb->isHidden() ) 984 if( sb && !sb->isHidden() )
984 size += QSize(0, sb->sizeHint().height()); 985 size += QSize(0, sb->sizeHint().height());
985 986
986 return size; 987 return size;
987} 988}
988 989
989// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 990// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
990void KMainWindow::finalizeGUI( KXMLGUIClient *client ) 991void KMainWindow::finalizeGUI( KXMLGUIClient *client )
991{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ } 992{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ }
992 993
993void KMainWindow::virtual_hook( int id, void* data ) 994void KMainWindow::virtual_hook( int id, void* data )
994{ /*US KXMLGUIBuilder::virtual_hook( id, data );*/ 995{ /*US KXMLGUIBuilder::virtual_hook( id, data );*/
995 KXMLGUIClient::virtual_hook( id, data ); } 996 KXMLGUIClient::virtual_hook( id, data ); }
diff --git a/microkde/kdeui/kmainwindow.h b/microkde/kdeui/kmainwindow.h
index 2aafb9d..2dc8033 100644
--- a/microkde/kdeui/kmainwindow.h
+++ b/microkde/kdeui/kmainwindow.h
@@ -1,777 +1,777 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17 17
18 $Id$ 18 $Id$
19 19
20*/ 20*/
21 21
22 22
23 23
24#ifndef KMAINWINDOW_H 24#ifndef KMAINWINDOW_H
25#define KMAINWINDOW_H 25#define KMAINWINDOW_H
26 26
27/*US 27/*US
28#include "kxmlguifactory.h" 28#include "kxmlguifactory.h"
29#include "kxmlguiclient.h" 29#include "kxmlguiclient.h"
30#include "kxmlguibuilder.h" 30#include "kxmlguibuilder.h"
31#include <qmetaobject.h> 31#include <qmetaobject.h>
32 32
33class KPopupMenu; 33class KPopupMenu;
34class KXMLGUIFactory; 34class KXMLGUIFactory;
35class KConfig; 35class KConfig;
36class KHelpMenu; 36class KHelpMenu;
37class KStatusBar; 37class KStatusBar;
38class QStatusBar; 38class QStatusBar;
39class KMenuBar; 39class KMenuBar;
40class KMWSessionManaged; 40class KMWSessionManaged;
41class KAccel; 41class KAccel;
42class KToolBarMenuAction; 42class KToolBarMenuAction;
43*/ 43*/
44 44
45class QMenuBar; 45class QMenuBar;
46class QStatusBar; 46class QStatusBar;
47class KMainWindowPrivate; 47class KMainWindowPrivate;
48class KAction; 48class KAction;
49 49
50#include <ktoolbar.h> 50#include <ktoolbar.h>
51#include <ktoolbarhandler.h> 51#include <ktoolbarhandler.h>
52#include <kxmlguiclient.h> 52#include <kxmlguiclient.h>
53#include <qmainwindow.h> 53#include <qmainwindow.h>
54#include <qptrlist.h> 54#include <qptrlist.h>
55 55
56class KActionCollection; 56class KActionCollection;
57 57
58class KMainWindow : public QMainWindow, virtual public KXMLGUIClient 58class KMainWindow : public QMainWindow, virtual public KXMLGUIClient
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62private: 62private:
63//US create private defaultconstructor 63//US create private defaultconstructor
64 KMainWindow() {;}; 64 KMainWindow() {;};
65 65
66 66
67public: 67public:
68 /** 68 /**
69 * Construct a main window. 69 * Construct a main window.
70 * 70 *
71 * @param parent The widget parent. This is usually 0 but it may also be the window 71 * @param parent The widget parent. This is usually 0 but it may also be the window
72 * group leader. In that case, the KMainWindow becomes sort of a 72 * group leader. In that case, the KMainWindow becomes sort of a
73 * secondary window. 73 * secondary window.
74 * 74 *
75 * @param name The object name. For session management and window management to work 75 * @param name The object name. For session management and window management to work
76 * properly, all main windows in the application should have a 76 * properly, all main windows in the application should have a
77 * different name. When passing 0 (the default), KMainWindow will create 77 * different name. When passing 0 (the default), KMainWindow will create
78 * a unique name, but it's recommended to explicitly pass a window name that will 78 * a unique name, but it's recommended to explicitly pass a window name that will
79 * also describe the type of the window. If there can be several windows of the same 79 * also describe the type of the window. If there can be several windows of the same
80 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make 80 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make
81 * the names unique. For example, for a mail client which has one main window showing 81 * the names unique. For example, for a mail client which has one main window showing
82 * the mails and folders, and which can also have one or more windows for composing 82 * the mails and folders, and which can also have one or more windows for composing
83 * mails, the name for the folders window should be e.g. "mainwindow" and 83 * mails, the name for the folders window should be e.g. "mainwindow" and
84 * for the composer windows "composer#". 84 * for the composer windows "composer#".
85 * 85 *
86 * @param f Specify the widget flags. The default is 86 * @param f Specify the widget flags. The default is
87 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a 87 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a
88 * main window is a toplevel window, regardless of whether it has a 88 * main window is a toplevel window, regardless of whether it has a
89 * parent or not. DestructiveClose indicates that a main window is 89 * parent or not. DestructiveClose indicates that a main window is
90 * automatically destroyed when its window is closed. Pass 0 if 90 * automatically destroyed when its window is closed. Pass 0 if
91 * you do not want this behavior. 91 * you do not want this behavior.
92 * 92 *
93 * KMainWindows must be created on the heap with 'new', like: 93 * KMainWindows must be created on the heap with 'new', like:
94 * <pre> KMainWindow *kmw = new KMainWindow (...</pre> 94 * <pre> KMainWindow *kmw = new KMainWindow (...</pre>
95 **/ 95 **/
96 //LR remove WDestructiveClose 96 //LR remove WDestructiveClose
97 KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ); 97 KMainWindow( QWidget* parent = 0, const char *name = 0 ); //, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ;
98 98
99 99
100 /** 100 /**
101 * Destructor. 101 * Destructor.
102 * 102 *
103 * Will also destroy the toolbars, and menubar if 103 * Will also destroy the toolbars, and menubar if
104 * needed. 104 * needed.
105 */ 105 */
106 virtual ~KMainWindow(); 106 virtual ~KMainWindow();
107 107
108 /** 108 /**
109 * Retrieve the standard help menu. 109 * Retrieve the standard help menu.
110 * 110 *
111 * It contains entires for the 111 * It contains entires for the
112 * help system (activated by F1), an optional "What's This?" entry 112 * help system (activated by F1), an optional "What's This?" entry
113 * (activated by Shift F1), an application specific dialog box, 113 * (activated by Shift F1), an application specific dialog box,
114 * and an "About KDE" dialog box. 114 * and an "About KDE" dialog box.
115 * 115 *
116 * Example (adding a standard help menu to your application): 116 * Example (adding a standard help menu to your application):
117 * <pre> 117 * <pre>
118 * KPopupMenu *help = helpMenu( <myTextString> ); 118 * KPopupMenu *help = helpMenu( <myTextString> );
119 * menuBar()->insertItem( i18n("&Help"), help ); 119 * menuBar()->insertItem( i18n("&Help"), help );
120 * </pre> 120 * </pre>
121 * 121 *
122 * @param aboutAppText The string that is used in the application 122 * @param aboutAppText The string that is used in the application
123 * specific dialog box. If you leave this string empty the 123 * specific dialog box. If you leave this string empty the
124 * information in the global @ref KAboutData of the 124 * information in the global @ref KAboutData of the
125 * application will be used to make a standard dialog box. 125 * application will be used to make a standard dialog box.
126 * 126 *
127 * @param showWhatsThis Set this to false if you do not want to include 127 * @param showWhatsThis Set this to false if you do not want to include
128 * the "What's This" menu entry. 128 * the "What's This" menu entry.
129 * 129 *
130 * @return A standard help menu. 130 * @return A standard help menu.
131 */ 131 */
132//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, 132//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
133//US bool showWhatsThis = TRUE ); 133//US bool showWhatsThis = TRUE );
134 134
135 /** 135 /**
136 * Returns the help menu. Creates a standard help menu if none exists yet. 136 * Returns the help menu. Creates a standard help menu if none exists yet.
137 * 137 *
138 * It contains entries for the 138 * It contains entries for the
139 * help system (activated by F1), an optional "What's This?" entry 139 * help system (activated by F1), an optional "What's This?" entry
140 * (activated by Shift F1), an application specific dialog box, 140 * (activated by Shift F1), an application specific dialog box,
141 * and an "About KDE" dialog box. You must create the application 141 * and an "About KDE" dialog box. You must create the application
142 * specific dialog box yourself. When the "About application" 142 * specific dialog box yourself. When the "About application"
143 * menu entry is activated, a signal will trigger the 143 * menu entry is activated, a signal will trigger the
144 * @ref showAboutApplication slot. See @ref showAboutApplication for more 144 * @ref showAboutApplication slot. See @ref showAboutApplication for more
145 * information. 145 * information.
146 * 146 *
147 * Example (adding a help menu to your application): 147 * Example (adding a help menu to your application):
148 * <pre> 148 * <pre>
149 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); 149 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() );
150 * </pre> 150 * </pre>
151 * 151 *
152 * @param showWhatsThis Set this to @p false if you do not want to include 152 * @param showWhatsThis Set this to @p false if you do not want to include
153 * the "What's This" menu entry. 153 * the "What's This" menu entry.
154 * 154 *
155 * @return A standard help menu. 155 * @return A standard help menu.
156 */ 156 */
157//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); 157//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE );
158 158
159 /** 159 /**
160 * @sect Session Management 160 * @sect Session Management
161 * 161 *
162 * Try to restore the toplevel widget as defined by the number (1..X). 162 * Try to restore the toplevel widget as defined by the number (1..X).
163 * 163 *
164 * If the session did not contain so high a number, the configuration 164 * If the session did not contain so high a number, the configuration
165 * is not changed and @p false returned. 165 * is not changed and @p false returned.
166 * 166 *
167 * That means clients could simply do the following: 167 * That means clients could simply do the following:
168 * <pre> 168 * <pre>
169 * if (kapp->isRestored()){ 169 * if (kapp->isRestored()){
170 * int n = 1; 170 * int n = 1;
171 * while (KMainWindow::canBeRestored(n)){ 171 * while (KMainWindow::canBeRestored(n)){
172 * (new childMW)->restore(n); 172 * (new childMW)->restore(n);
173 * n++; 173 * n++;
174 * } 174 * }
175 * } else { 175 * } else {
176 * // create default application as usual 176 * // create default application as usual
177 * } 177 * }
178 * </pre> 178 * </pre>
179 * Note that @ref QWidget::show() is called implicitly in restore. 179 * Note that @ref QWidget::show() is called implicitly in restore.
180 * 180 *
181 * With this you can easily restore all toplevel windows of your 181 * With this you can easily restore all toplevel windows of your
182 * application. 182 * application.
183 * 183 *
184 * If your application uses different kinds of toplevel 184 * If your application uses different kinds of toplevel
185 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) 185 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n)
186 * to determine the exact type before calling the childMW 186 * to determine the exact type before calling the childMW
187 * constructor in the example from above. 187 * constructor in the example from above.
188 * 188 *
189 * If your client has only one kind of toplevel widgets (which 189 * If your client has only one kind of toplevel widgets (which
190 * should be pretty usual) then you should use the RESTORE-macro 190 * should be pretty usual) then you should use the RESTORE-macro
191 * for backwards compatibility with 3.1 and 3.0 branches: 191 * for backwards compatibility with 3.1 and 3.0 branches:
192 * 192 *
193 * <pre> 193 * <pre>
194 * if (kapp->isRestored()) 194 * if (kapp->isRestored())
195 * RESTORE(childMW) 195 * RESTORE(childMW)
196 * else { 196 * else {
197 * // create default application as usual 197 * // create default application as usual
198 * } 198 * }
199 * </pre> 199 * </pre>
200 * 200 *
201 * The macro expands to the term above but is easier to use and 201 * The macro expands to the term above but is easier to use and
202 * less code to write. 202 * less code to write.
203 * 203 *
204 * For new code or if you have more than one kind of toplevel 204 * For new code or if you have more than one kind of toplevel
205 * widget (each derived from @ref KMainWindow, of course), you can 205 * widget (each derived from @ref KMainWindow, of course), you can
206 * use the templated @ref kRestoreMainWindows global functions: 206 * use the templated @ref kRestoreMainWindows global functions:
207 * 207 *
208 * <pre> 208 * <pre>
209 * if (kapp->isRestored()) 209 * if (kapp->isRestored())
210 * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); 210 * kRestoreMainWindows< childMW1, childMW2, childMW3 >();
211 * else { 211 * else {
212 * // create default application as usual 212 * // create default application as usual
213 * } 213 * }
214 * </pre> 214 * </pre>
215 * 215 *
216 * Currently, these functions are provided for up to three 216 * Currently, these functions are provided for up to three
217 * template arguments. If you need more, tell us. To help you in 217 * template arguments. If you need more, tell us. To help you in
218 * deciding whether or not you can use @ref kRestoreMainWindows, a 218 * deciding whether or not you can use @ref kRestoreMainWindows, a
219 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. 219 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.
220 * 220 *
221 * @see restore() 221 * @see restore()
222 * @see classNameOfToplevel() 222 * @see classNameOfToplevel()
223 * 223 *
224 **/ 224 **/
225 static bool canBeRestored( int number ); 225 static bool canBeRestored( int number );
226 226
227 /** 227 /**
228 * Returns the @ref className() of the @p number of the toplevel window which 228 * Returns the @ref className() of the @p number of the toplevel window which
229 * should be restored. 229 * should be restored.
230 * 230 *
231 * This is only useful if your application uses 231 * This is only useful if your application uses
232 * different kinds of toplevel windows. 232 * different kinds of toplevel windows.
233 */ 233 */
234 static const QString classNameOfToplevel( int number ); 234 static const QString classNameOfToplevel( int number );
235 235
236 /** 236 /**
237 * Restore the session specified by @p number. 237 * Restore the session specified by @p number.
238 * 238 *
239 * Returns @p false if this 239 * Returns @p false if this
240 * fails, otherwise returns @p true and shows the window. 240 * fails, otherwise returns @p true and shows the window.
241 * You should call @ref canBeRestored() first. 241 * You should call @ref canBeRestored() first.
242 * If @p show is true (default), this widget will be shown automatically. 242 * If @p show is true (default), this widget will be shown automatically.
243 */ 243 */
244 bool restore( int number, bool show = TRUE ); 244 bool restore( int number, bool show = TRUE );
245 245
246//US virtual KXMLGUIFactory *guiFactory(); 246//US virtual KXMLGUIFactory *guiFactory();
247 247
248 /** 248 /**
249 * Create a GUI given a local XML file. 249 * Create a GUI given a local XML file.
250 * 250 *
251 * If @p xmlfile is NULL, 251 * If @p xmlfile is NULL,
252 * then it will try to construct a local XML filename like 252 * then it will try to construct a local XML filename like
253 * appnameui.rc where 'appname' is your app's name. If that file 253 * appnameui.rc where 'appname' is your app's name. If that file
254 * does not exist, then the XML UI code will only use the global 254 * does not exist, then the XML UI code will only use the global
255 * (standard) XML file for the layout purposes. 255 * (standard) XML file for the layout purposes.
256 * 256 *
257 * Note that when passing true for the conserveMemory argument subsequent 257 * Note that when passing true for the conserveMemory argument subsequent
258 * calls to guiFactory()->addClient/removeClient may not work as expected. 258 * calls to guiFactory()->addClient/removeClient may not work as expected.
259 * Also retrieving references to containers like popup menus or toolbars using 259 * Also retrieving references to containers like popup menus or toolbars using
260 * the container method will not work. 260 * the container method will not work.
261 * 261 *
262 * @param xmlfile The local xmlfile (relative or absolute) 262 * @param xmlfile The local xmlfile (relative or absolute)
263 * @param _conserveMemory Specify whether createGUI() should call 263 * @param _conserveMemory Specify whether createGUI() should call
264 * @ref KXMLGuiClient::conserveMemory() to free all memory 264 * @ref KXMLGuiClient::conserveMemory() to free all memory
265 * allocated by the @ref QDomDocument and by the KXMLGUIFactory. 265 * allocated by the @ref QDomDocument and by the KXMLGUIFactory.
266 */ 266 */
267 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); 267 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE );
268 268
269 /** 269 /**
270 * Enables the build of a standard help menu when calling createGUI(). 270 * Enables the build of a standard help menu when calling createGUI().
271 * 271 *
272 * The default behavior is to build one, you must call this function 272 * The default behavior is to build one, you must call this function
273 * to disable it 273 * to disable it
274 */ 274 */
275 void setHelpMenuEnabled(bool showHelpMenu = true); 275 void setHelpMenuEnabled(bool showHelpMenu = true);
276 276
277 /** 277 /**
278 * Return @p true when the help menu is enabled 278 * Return @p true when the help menu is enabled
279 */ 279 */
280 bool isHelpMenuEnabled(); 280 bool isHelpMenuEnabled();
281 281
282 282
283 /** 283 /**
284 * Returns true, if there is a menubar 284 * Returns true, if there is a menubar
285 * @since 3.1 285 * @since 3.1
286 */ 286 */
287 bool hasMenuBar(); 287 bool hasMenuBar();
288 288
289 /** 289 /**
290 * Returns a pointer to the menu bar. 290 * Returns a pointer to the menu bar.
291 * 291 *
292 * If there is no menu bar yet one will be created. 292 * If there is no menu bar yet one will be created.
293 **/ 293 **/
294//US KMenuBar *menuBar(); 294//US KMenuBar *menuBar();
295 QMenuBar *menuBar(); 295 QMenuBar *menuBar();
296 296
297 /** 297 /**
298 * Returns a pointer to the status bar. 298 * Returns a pointer to the status bar.
299 * 299 *
300 * If there is no 300 * If there is no
301 * status bar yet one will be created. 301 * status bar yet one will be created.
302 */ 302 */
303//US KStatusBar *statusBar(); 303//US KStatusBar *statusBar();
304 QStatusBar *statusBar(); 304 QStatusBar *statusBar();
305 305
306 /** 306 /**
307 * List of members of KMainWindow class. 307 * List of members of KMainWindow class.
308 */ 308 */
309//US static QPtrList<KMainWindow>* memberList; 309//US static QPtrList<KMainWindow>* memberList;
310 310
311 /** 311 /**
312 * Returns a pointer to the toolbar with the specified name. 312 * Returns a pointer to the toolbar with the specified name.
313 * This refers to toolbars created dynamically from the XML UI 313 * This refers to toolbars created dynamically from the XML UI
314 * framework. If the toolbar does not exist one will be created. 314 * framework. If the toolbar does not exist one will be created.
315 * 315 *
316 * @param name The internal name of the toolbar. If no name is 316 * @param name The internal name of the toolbar. If no name is
317 * specified "mainToolBar" is assumed. 317 * specified "mainToolBar" is assumed.
318 * 318 *
319 * @return A pointer to the toolbar 319 * @return A pointer to the toolbar
320 **/ 320 **/
321 KToolBar *toolBar( const char *name=0 ); 321 KToolBar *toolBar( const char *name=0 );
322 // method for getting rid of KDE-Crap 322 // method for getting rid of KDE-Crap
323 QToolBar *tBar( ); 323 QToolBar *tBar( );
324 324
325 /** 325 /**
326 * @return An iterator over the list of all toolbars for this window. 326 * @return An iterator over the list of all toolbars for this window.
327 */ 327 */
328 QPtrListIterator<KToolBar> toolBarIterator(); 328 QPtrListIterator<KToolBar> toolBarIterator();
329 329
330 /** 330 /**
331 * @return A KAccel instance bound to this mainwindow. Used automatically 331 * @return A KAccel instance bound to this mainwindow. Used automatically
332 * by KAction to make keybindings work in all cases. 332 * by KAction to make keybindings work in all cases.
333 */ 333 */
334 KAccel *accel(); 334 KAccel *accel();
335 335
336 void setFrameBorderWidth( int ) {} 336 void setFrameBorderWidth( int ) {}
337 337
338 /** 338 /**
339 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings 339 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings
340 * (and optionally window size). 340 * (and optionally window size).
341 * If the *bars were moved around/shown/hidden when the window is closed, 341 * If the *bars were moved around/shown/hidden when the window is closed,
342 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. 342 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called.
343 * 343 *
344 * @param groupName a name that identifies this "type of window". 344 * @param groupName a name that identifies this "type of window".
345 * You can have several types of window in the same application. 345 * You can have several types of window in the same application.
346 * 346 *
347 * @param saveWindowSize set it to true to include the window size 347 * @param saveWindowSize set it to true to include the window size
348 * when saving. 348 * when saving.
349 * 349 *
350 * Typically, you will call setAutoSaveSettings() in your 350 * Typically, you will call setAutoSaveSettings() in your
351 * KMainWindow-inherited class constructor, and it will take care 351 * KMainWindow-inherited class constructor, and it will take care
352 * of restoring and saving automatically. Make sure you call this 352 * of restoring and saving automatically. Make sure you call this
353 * _after all_ your *bars have been created. 353 * _after all_ your *bars have been created.
354 */ 354 */
355 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), 355 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
356 bool saveWindowSize = true ); 356 bool saveWindowSize = true );
357 357
358 /** 358 /**
359 * Disable the auto-save-settings feature. 359 * Disable the auto-save-settings feature.
360 * You don't normally need to call this, ever. 360 * You don't normally need to call this, ever.
361 */ 361 */
362 void resetAutoSaveSettings(); 362 void resetAutoSaveSettings();
363 363
364 /** 364 /**
365 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, 365 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called,
366 * false by default or if resetAutoSaveSettings() was called. 366 * false by default or if resetAutoSaveSettings() was called.
367 * @since 3.1 367 * @since 3.1
368 */ 368 */
369 bool autoSaveSettings() const; 369 bool autoSaveSettings() const;
370 370
371 /** 371 /**
372 * @return the group used for setting-autosaving. 372 * @return the group used for setting-autosaving.
373 * Only meaningful if setAutoSaveSettings() was called. 373 * Only meaningful if setAutoSaveSettings() was called.
374 * This can be useful for forcing a save or an apply, e.g. before and after 374 * This can be useful for forcing a save or an apply, e.g. before and after
375 * using KEditToolbar. 375 * using KEditToolbar.
376 * @since 3.1 376 * @since 3.1
377 */ 377 */
378 QString autoSaveGroup() const; 378 QString autoSaveGroup() const;
379 379
380 /** 380 /**
381 * Read settings for statusbar, menubar and toolbar from their respective 381 * Read settings for statusbar, menubar and toolbar from their respective
382 * groups in the config file and apply them. 382 * groups in the config file and apply them.
383 * 383 *
384 * @param config Config file to read the settings from. 384 * @param config Config file to read the settings from.
385 * @param groupName Group name to use. If not specified, the last used 385 * @param groupName Group name to use. If not specified, the last used
386 * group name is used. 386 * group name is used.
387 */ 387 */
388 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 388 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
389 389
390 /** 390 /**
391 * Save settings for statusbar, menubar and toolbar to their respective 391 * Save settings for statusbar, menubar and toolbar to their respective
392 * groups in the config file @p config. 392 * groups in the config file @p config.
393 * 393 *
394 * @param config Config file to save the settings to. 394 * @param config Config file to save the settings to.
395 * @param groupName Group name to use. If not specified, the last used 395 * @param groupName Group name to use. If not specified, the last used
396 * group name is used 396 * group name is used
397 */ 397 */
398 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 398 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
399 399
400 /** 400 /**
401 * Sets whether KMainWindow should provide a menu that allows showing/hiding 401 * Sets whether KMainWindow should provide a menu that allows showing/hiding
402 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there 402 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there
403 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item 403 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item
404 * is shown. 404 * is shown.
405 * 405 *
406 * The menu / menu item is implemented using xmlgui. It will be inserted in your 406 * The menu / menu item is implemented using xmlgui. It will be inserted in your
407 * menu structure in the 'Settings' menu. 407 * menu structure in the 'Settings' menu.
408 * 408 *
409 * If your application uses a non-standard xmlgui resource file then you can 409 * If your application uses a non-standard xmlgui resource file then you can
410 * specify the exact position of the menu / menu item by adding a 410 * specify the exact position of the menu / menu item by adding a
411 * &lt;Merge name="StandardToolBarMenuHandler" /&gt; 411 * &lt;Merge name="StandardToolBarMenuHandler" /&gt;
412 * line to the settings menu section of your resource file ( usually appname.rc ). 412 * line to the settings menu section of your resource file ( usually appname.rc ).
413 * 413 *
414 * Note that you should enable this feature before calling createGUI() ( or similar ) . 414 * Note that you should enable this feature before calling createGUI() ( or similar ) .
415 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. 415 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI.
416 * @since 3.1 416 * @since 3.1
417 */ 417 */
418 void setStandardToolBarMenuEnabled( bool enable ); 418 void setStandardToolBarMenuEnabled( bool enable );
419 /// @since 3.1 419 /// @since 3.1
420 bool isStandardToolBarMenuEnabled() const; 420 bool isStandardToolBarMenuEnabled() const;
421 421
422 422
423 /** 423 /**
424 * Sets whether KMainWindow should provide a menu that allows showing/hiding 424 * Sets whether KMainWindow should provide a menu that allows showing/hiding
425 * of the statusbar ( using @ref KToggleStatusBarAction ). 425 * of the statusbar ( using @ref KToggleStatusBarAction ).
426 * 426 *
427 * The menu / menu item is implemented using xmlgui. It will be inserted 427 * The menu / menu item is implemented using xmlgui. It will be inserted
428 * in your menu structure in the 'Settings' menu. 428 * in your menu structure in the 'Settings' menu.
429 * 429 *
430 * Note that you should enable this feature before calling createGUI() 430 * Note that you should enable this feature before calling createGUI()
431 * ( or similar ). 431 * ( or similar ).
432 * 432 *
433 * If an application maintains the action on its own (i.e. never calls 433 * If an application maintains the action on its own (i.e. never calls
434 * this function) a connection needs to be made to let KMainWindow 434 * this function) a connection needs to be made to let KMainWindow
435 * know when that status (hidden/shown) of the statusbar has changed. 435 * know when that status (hidden/shown) of the statusbar has changed.
436 * For example: 436 * For example:
437 * connect(action, SIGNAL(activated()), 437 * connect(action, SIGNAL(activated()),
438 * kmainwindow, SLOT(setSettingsDirty())); 438 * kmainwindow, SLOT(setSettingsDirty()));
439 * Otherwise the status (hidden/show) of the statusbar might not be saved 439 * Otherwise the status (hidden/show) of the statusbar might not be saved
440 * by KMainWindow. 440 * by KMainWindow.
441 * @since 3.2 441 * @since 3.2
442 */ 442 */
443 void createStandardStatusBarAction(); 443 void createStandardStatusBarAction();
444 444
445 445
446 /** 446 /**
447 * Returns a pointer to the mainwindows action responsible for the toolbars menu 447 * Returns a pointer to the mainwindows action responsible for the toolbars menu
448 * @since 3.1 448 * @since 3.1
449 */ 449 */
450 KAction *toolBarMenuAction(); 450 KAction *toolBarMenuAction();
451 451
452 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 452 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
453 /// @since 3.1 453 /// @since 3.1
454 virtual void finalizeGUI( KXMLGUIClient *client ); 454 virtual void finalizeGUI( KXMLGUIClient *client );
455 455
456 /** 456 /**
457 * @internal 457 * @internal
458 */ 458 */
459 void finalizeGUI( bool force ); 459 void finalizeGUI( bool force );
460 460
461 /** 461 /**
462 * @return true if a -geometry argument was given on the command line, 462 * @return true if a -geometry argument was given on the command line,
463 * and this is the first window created (the one on which this option applies) 463 * and this is the first window created (the one on which this option applies)
464 */ 464 */
465 bool initialGeometrySet() const; 465 bool initialGeometrySet() const;
466 466
467 /** 467 /**
468 * @internal 468 * @internal
469 * Used from Konqueror when reusing the main window. 469 * Used from Konqueror when reusing the main window.
470 */ 470 */
471 void ignoreInitialGeometry(); 471 void ignoreInitialGeometry();
472 472
473 /** 473 /**
474 * @return the size the mainwindow should have so that the central 474 * @return the size the mainwindow should have so that the central
475 * widget will be of @p size. 475 * widget will be of @p size.
476 */ 476 */
477 QSize sizeForCentralWidgetSize(QSize size); 477 QSize sizeForCentralWidgetSize(QSize size);
478 478
479public slots: 479public slots:
480 /** 480 /**
481 * Makes a KDE compliant caption. 481 * Makes a KDE compliant caption.
482 * 482 *
483 * @param caption Your caption. @em Do @em not include the application name 483 * @param caption Your caption. @em Do @em not include the application name
484 * in this string. It will be added automatically according to the KDE 484 * in this string. It will be added automatically according to the KDE
485 * standard. 485 * standard.
486 */ 486 */
487 virtual void setCaption( const QString &caption ); 487 virtual void setCaption( const QString &caption );
488 /** 488 /**
489 * Makes a KDE compliant caption. 489 * Makes a KDE compliant caption.
490 * 490 *
491 * @param caption Your caption. @em Do @em not include the application name 491 * @param caption Your caption. @em Do @em not include the application name
492 * in this string. It will be added automatically according to the KDE 492 * in this string. It will be added automatically according to the KDE
493 * standard. 493 * standard.
494 * @param modified Specify whether the document is modified. This displays 494 * @param modified Specify whether the document is modified. This displays
495 * an additional sign in the title bar, usually "**". 495 * an additional sign in the title bar, usually "**".
496 */ 496 */
497 virtual void setCaption( const QString &caption, bool modified ); 497 virtual void setCaption( const QString &caption, bool modified );
498 498
499 /** 499 /**
500 * Make a plain caption without any modifications. 500 * Make a plain caption without any modifications.
501 * 501 *
502 * @param caption Your caption. This is the string that will be 502 * @param caption Your caption. This is the string that will be
503 * displayed in the window title. 503 * displayed in the window title.
504 */ 504 */
505 virtual void setPlainCaption( const QString &caption ); 505 virtual void setPlainCaption( const QString &caption );
506 506
507 /** 507 /**
508 * Open the help page for the application. 508 * Open the help page for the application.
509 * 509 *
510 * The application name is 510 * The application name is
511 * used as a key to determine what to display and the system will attempt 511 * used as a key to determine what to display and the system will attempt
512 * to open <appName>/index.html. 512 * to open <appName>/index.html.
513 * 513 *
514 * This method is intended for use by a help button in the toolbar or 514 * This method is intended for use by a help button in the toolbar or
515 * components outside the regular help menu. Use @ref helpMenu() when you 515 * components outside the regular help menu. Use @ref helpMenu() when you
516 * want to provide access to the help system from the help menu. 516 * want to provide access to the help system from the help menu.
517 * 517 *
518 * Example (adding a help button to the first toolbar): 518 * Example (adding a help button to the first toolbar):
519 * 519 *
520 * <pre> 520 * <pre>
521 * KIconLoader &loader = *KGlobal::iconLoader(); 521 * KIconLoader &loader = *KGlobal::iconLoader();
522 * QPixmap pixmap = loader.loadIcon( "help" ); 522 * QPixmap pixmap = loader.loadIcon( "help" );
523 * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()), 523 * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()),
524 * this, SLOT(appHelpActivated()), true, i18n("Help") ); 524 * this, SLOT(appHelpActivated()), true, i18n("Help") );
525 * </pre> 525 * </pre>
526 * 526 *
527 */ 527 */
528//US void appHelpActivated( void ); 528//US void appHelpActivated( void );
529 529
530 /** 530 /**
531 * Apply a state change 531 * Apply a state change
532 * 532 *
533 * Enable and disable actions as defined in the XML rc file 533 * Enable and disable actions as defined in the XML rc file
534 * @since 3.1 534 * @since 3.1
535 */ 535 */
536 virtual void slotStateChanged(const QString &newstate); 536 virtual void slotStateChanged(const QString &newstate);
537 537
538 /** 538 /**
539 * Apply a state change 539 * Apply a state change
540 * 540 *
541 * Enable and disable actions as defined in the XML rc file, 541 * Enable and disable actions as defined in the XML rc file,
542 * can "reverse" the state (disable the actions which should be 542 * can "reverse" the state (disable the actions which should be
543 * enabled, and vice-versa) if specified. 543 * enabled, and vice-versa) if specified.
544 * @since 3.1 544 * @since 3.1
545 */ 545 */
546 void slotStateChanged(const QString &newstate, 546 void slotStateChanged(const QString &newstate,
547 KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this 547 KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this
548 548
549 549
550 /** 550 /**
551 * Apply a state change 551 * Apply a state change
552 * 552 *
553 * Enable and disable actions as defined in the XML rc file, 553 * Enable and disable actions as defined in the XML rc file,
554 * can "reverse" the state (disable the actions which should be 554 * can "reverse" the state (disable the actions which should be
555 * enabled, and vice-versa) if specified. 555 * enabled, and vice-versa) if specified.
556 */ 556 */
557// void slotStateChanged(const QString &newstate, 557// void slotStateChanged(const QString &newstate,
558// bool reverse); // KDE 4.0: enable this 558// bool reverse); // KDE 4.0: enable this
559 559
560 /** 560 /**
561 * Tell the main window that it should save its settings when being closed. 561 * Tell the main window that it should save its settings when being closed.
562 * This is part of the auto-save-settings feature. 562 * This is part of the auto-save-settings feature.
563 * For everything related to toolbars this happens automatically, 563 * For everything related to toolbars this happens automatically,
564 * but you have to call setSettingsDirty() in the slot that toggles 564 * but you have to call setSettingsDirty() in the slot that toggles
565 * the visibility of the statusbar. 565 * the visibility of the statusbar.
566 */ 566 */
567 void setSettingsDirty(); 567 void setSettingsDirty();
568 568
569protected: 569protected:
570 void paintEvent( QPaintEvent* e ); 570 void paintEvent( QPaintEvent* e );
571 void childEvent( QChildEvent* e); 571 void childEvent( QChildEvent* e);
572 void resizeEvent( QResizeEvent* e); 572 void resizeEvent( QResizeEvent* e);
573 /** 573 /**
574 * Reimplemented to call the queryClose() and queryExit() handlers. 574 * Reimplemented to call the queryClose() and queryExit() handlers.
575 * 575 *
576 * We recommend that you reimplement the handlers rather than @ref closeEvent(). 576 * We recommend that you reimplement the handlers rather than @ref closeEvent().
577 * If you do it anyway, ensure to call the base implementation to keep 577 * If you do it anyway, ensure to call the base implementation to keep
578 * @ref queryExit() running. 578 * @ref queryExit() running.
579 */ 579 */
580 virtual void closeEvent ( QCloseEvent *); 580 virtual void closeEvent ( QCloseEvent *);
581 581
582 // KDE4 This seems to be flawed to me. Either the app has only one 582 // KDE4 This seems to be flawed to me. Either the app has only one
583 // mainwindow, so queryClose() is enough, or if it can have more of them, 583 // mainwindow, so queryClose() is enough, or if it can have more of them,
584 // then the windows should take care of themselves, and queryExit() 584 // then the windows should take care of themselves, and queryExit()
585 // would be useful only for the annoying 'really quit' dialog, which 585 // would be useful only for the annoying 'really quit' dialog, which
586 // also doesn't make sense in apps with multiple mainwindows. 586 // also doesn't make sense in apps with multiple mainwindows.
587 // And saving configuration in something called queryExit()? IMHO 587 // And saving configuration in something called queryExit()? IMHO
588 // one can e.g. use KApplication::shutDown(), which if nothing else 588 // one can e.g. use KApplication::shutDown(), which if nothing else
589 // has at least better fitting name. 589 // has at least better fitting name.
590 // See also KApplication::sessionSaving(). 590 // See also KApplication::sessionSaving().
591 // This stuff should get changed somehow, so that it at least doesn't 591 // This stuff should get changed somehow, so that it at least doesn't
592 // mess with session management. 592 // mess with session management.
593 /** 593 /**
594 Called before the very last window is closed, either by the 594 Called before the very last window is closed, either by the
595 user or indirectly by the session manager. 595 user or indirectly by the session manager.
596 596
597 It is not recommended to do any user interaction in this 597 It is not recommended to do any user interaction in this
598 function other than indicating severe errors. Better ask the 598 function other than indicating severe errors. Better ask the
599 user on @ref queryClose() (see below). 599 user on @ref queryClose() (see below).
600 600
601 A typical usage of @ref queryExit() is to write configuration data back. 601 A typical usage of @ref queryExit() is to write configuration data back.
602 Note that the application may continue to run after @ref queryExit() 602 Note that the application may continue to run after @ref queryExit()
603 (the user may have cancelled a shutdown), so you should not do any cleanups 603 (the user may have cancelled a shutdown), so you should not do any cleanups
604 here. The purpose of @ref queryExit() is purely to prepare the application 604 here. The purpose of @ref queryExit() is purely to prepare the application
605 (with possible user interaction) so it can safely be closed later (without 605 (with possible user interaction) so it can safely be closed later (without
606 user interaction). 606 user interaction).
607 607
608 If you need to do serious things on exit (like shutting a 608 If you need to do serious things on exit (like shutting a
609 dial-up connection down), connect to the signal 609 dial-up connection down), connect to the signal
610 @ref KApplication::shutDown(). 610 @ref KApplication::shutDown().
611 611
612 Default implementation returns @p true. Returning @p false will 612 Default implementation returns @p true. Returning @p false will
613 cancel the exiting. In the latter case, the last window will 613 cancel the exiting. In the latter case, the last window will
614 remain visible. If KApplication::sessionSaving() is true, refusing 614 remain visible. If KApplication::sessionSaving() is true, refusing
615 the exit will also cancel KDE logout. 615 the exit will also cancel KDE logout.
616 616
617 @see queryClose() 617 @see queryClose()
618 @see KApplication::sessionSaving() 618 @see KApplication::sessionSaving()
619 */ 619 */
620 virtual bool queryExit(); 620 virtual bool queryExit();
621 621
622 /** 622 /**
623 Called before the window is closed, either by the user or indirectly by 623 Called before the window is closed, either by the user or indirectly by
624 the session manager. 624 the session manager.
625 625
626 The purpose of this function is to prepare the window in a way that it is 626 The purpose of this function is to prepare the window in a way that it is
627 safe to close it, i.e. without the user losing some data. 627 safe to close it, i.e. without the user losing some data.
628 628
629 Default implementation returns true. Returning @p false will cancel 629 Default implementation returns true. Returning @p false will cancel
630 the closing, and, if KApplication::sessionSaving() is true, it will also 630 the closing, and, if KApplication::sessionSaving() is true, it will also
631 cancel KDE logout. 631 cancel KDE logout.
632 632
633 Reimplement this function to prevent the user from losing data. 633 Reimplement this function to prevent the user from losing data.
634 Example: 634 Example:
635 <pre> 635 <pre>
636 636
637 switch ( KMessageBox::warningYesNoCancel( this, 637 switch ( KMessageBox::warningYesNoCancel( this,
638 i18n("Save changes to document foo?")) ) { 638 i18n("Save changes to document foo?")) ) {
639 case KMessageBox::Yes : 639 case KMessageBox::Yes :
640 // save document here. If saving fails, return FALSE; 640 // save document here. If saving fails, return FALSE;
641 return TRUE; 641 return TRUE;
642 case KMessageBox::No : 642 case KMessageBox::No :
643 return TRUE; 643 return TRUE;
644 default: // cancel 644 default: // cancel
645 return FALSE; 645 return FALSE;
646 646
647 </pre> 647 </pre>
648 648
649 @see queryExit() 649 @see queryExit()
650 @see KApplication::sessionSaving() 650 @see KApplication::sessionSaving()
651 651
652 */ 652 */
653 virtual bool queryClose(); 653 virtual bool queryClose();
654 /** 654 /**
655 * Save your instance-specific properties. The function is 655 * Save your instance-specific properties. The function is
656 * invoked when the session manager requests your application 656 * invoked when the session manager requests your application
657 * to save its state. 657 * to save its state.
658 * 658 *
659 * You @em must @em not change the group of the @p kconfig object, since 659 * You @em must @em not change the group of the @p kconfig object, since
660 * KMainWindow uses one group for each window. Please 660 * KMainWindow uses one group for each window. Please
661 * reimplement these function in childclasses. 661 * reimplement these function in childclasses.
662 * 662 *
663 * Note: No user interaction is allowed 663 * Note: No user interaction is allowed
664 * in this function! 664 * in this function!
665 * 665 *
666 */ 666 */
667 virtual void saveProperties( KConfig* ) {} 667 virtual void saveProperties( KConfig* ) {}
668 668
669 /** 669 /**
670 * Read your instance-specific properties. 670 * Read your instance-specific properties.
671 */ 671 */
672 virtual void readProperties( KConfig* ) {} 672 virtual void readProperties( KConfig* ) {}
673 673
674 /** 674 /**
675 * Save your application-wide properties. The function is 675 * Save your application-wide properties. The function is
676 * invoked when the session manager requests your application 676 * invoked when the session manager requests your application
677 * to save its state. 677 * to save its state.
678 * 678 *
679 * This function is similar to @ref saveProperties() but is only called for 679 * This function is similar to @ref saveProperties() but is only called for
680 * the very first main window, regardless how many main window are open. 680 * the very first main window, regardless how many main window are open.
681 681
682 * Override it if you need to save other data about your documents on 682 * Override it if you need to save other data about your documents on
683 * session end. sessionConfig is a config to which that data should be 683 * session end. sessionConfig is a config to which that data should be
684 * saved. Normally, you don't need this function. But if you want to save 684 * saved. Normally, you don't need this function. But if you want to save
685 * data about your documents that are not in opened windows you might need 685 * data about your documents that are not in opened windows you might need
686 * it. 686 * it.
687 * 687 *
688 * Default implementation does nothing. 688 * Default implementation does nothing.
689 */ 689 */
690 virtual void saveGlobalProperties( KConfig* sessionConfig ); 690 virtual void saveGlobalProperties( KConfig* sessionConfig );
691 691
692 /** 692 /**
693 * The counterpart of @ref saveGlobalProperties(). 693 * The counterpart of @ref saveGlobalProperties().
694 * 694 *
695 * Read the application-specific properties in again. 695 * Read the application-specific properties in again.
696 */ 696 */
697 virtual void readGlobalProperties( KConfig* sessionConfig ); 697 virtual void readGlobalProperties( KConfig* sessionConfig );
698 void savePropertiesInternal( KConfig*, int ); 698 void savePropertiesInternal( KConfig*, int );
699 bool readPropertiesInternal( KConfig*, int ); 699 bool readPropertiesInternal( KConfig*, int );
700 700
701 /** 701 /**
702 * For inherited classes 702 * For inherited classes
703 */ 703 */
704 bool settingsDirty() const; 704 bool settingsDirty() const;
705 /** 705 /**
706 * For inherited classes 706 * For inherited classes
707 */ 707 */
708 QString settingsGroup() const; 708 QString settingsGroup() const;
709 /** 709 /**
710 * For inherited classes 710 * For inherited classes
711 * Note that the group must be set before calling 711 * Note that the group must be set before calling
712 */ 712 */
713 void saveWindowSize( KConfig * config ) const; 713 void saveWindowSize( KConfig * config ) const;
714 /** 714 /**
715 * For inherited classes 715 * For inherited classes
716 * Note that the group must be set before calling, and that 716 * Note that the group must be set before calling, and that
717 * a -geometry on the command line has priority. 717 * a -geometry on the command line has priority.
718 */ 718 */
719 void restoreWindowSize( KConfig * config ); 719 void restoreWindowSize( KConfig * config );
720 720
721 /// parse the geometry from the geometry command line argument 721 /// parse the geometry from the geometry command line argument
722 void parseGeometry(bool parsewidth); 722 void parseGeometry(bool parsewidth);
723 723
724protected slots: 724protected slots:
725 725
726 /** 726 /**
727 * This slot does nothing. 727 * This slot does nothing.
728 * 728 *
729 * It must be reimplemented if you want 729 * It must be reimplemented if you want
730 * to use a custom About Application dialog box. This slot is 730 * to use a custom About Application dialog box. This slot is
731 * connected to the About Application entry in the menu returned 731 * connected to the About Application entry in the menu returned
732 * by @ref customHelpMenu. 732 * by @ref customHelpMenu.
733 * 733 *
734 * Example: 734 * Example:
735 * <pre> 735 * <pre>
736 * 736 *
737 * void MyMainLevel::setupInterface() 737 * void MyMainLevel::setupInterface()
738 * { 738 * {
739 * .. 739 * ..
740 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); 740 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() );
741 * .. 741 * ..
742 * } 742 * }
743 * 743 *
744 * void MyMainLevel::showAboutApplication() 744 * void MyMainLevel::showAboutApplication()
745 * { 745 * {
746 * <activate your custom dialog> 746 * <activate your custom dialog>
747 * } 747 * }
748 * </pre> 748 * </pre>
749 */ 749 */
750//US virtual void showAboutApplication(); 750//US virtual void showAboutApplication();
751 751
752private slots: 752private slots:
753 /** 753 /**
754 * Called when the app is shutting down. 754 * Called when the app is shutting down.
755 */ 755 */
756 void shuttingDown(); 756 void shuttingDown();
757 757
758 void saveAutoSaveSettings(); 758 void saveAutoSaveSettings();
759 759
760private: 760private:
761 QToolBar * mQToolBar; 761 QToolBar * mQToolBar;
762//US KMenuBar *internalMenuBar(); 762//US KMenuBar *internalMenuBar();
763 QMenuBar *internalMenuBar(); 763 QMenuBar *internalMenuBar();
764//US KStatusBar *internalStatusBar(); 764//US KStatusBar *internalStatusBar();
765 QStatusBar *internalStatusBar(); 765 QStatusBar *internalStatusBar();
766 766
767 KMainWindowPrivate *d; 767 KMainWindowPrivate *d;
768 void initKMainWindow(const char *name); 768 void initKMainWindow(const char *name);
769 769
770 QPtrList<KToolBar> toolbarList; 770 QPtrList<KToolBar> toolbarList;
771 771
772protected: 772protected:
773 virtual void virtual_hook( int id, void* data ); 773 virtual void virtual_hook( int id, void* data );
774 774
775}; 775};
776 776
777#endif 777#endif