summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp4
-rw-r--r--kaddressbook/viewmanager.cpp9
-rw-r--r--kaddressbook/viewmanager.h1
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
4 files changed, 10 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a480baf..9526f23 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3276 +1,3276 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*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 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h" 154#include "nameeditdialog.h"
155#include <kcmultidialog.h> 155#include <kcmultidialog.h>
156 156
157#ifdef _WIN32_ 157#ifdef _WIN32_
158 158
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#else 160#else
161#include <unistd.h> 161#include <unistd.h>
162#endif 162#endif
163// sync includes 163// sync includes
164#include <libkdepim/ksyncprofile.h> 164#include <libkdepim/ksyncprofile.h>
165#include <libkdepim/ksyncprefsdialog.h> 165#include <libkdepim/ksyncprefsdialog.h>
166 166
167 167
168class KABCatPrefs : public QDialog 168class KABCatPrefs : public QDialog
169{ 169{
170 public: 170 public:
171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
172 QDialog( parent, name, true ) 172 QDialog( parent, name, true )
173 { 173 {
174 setCaption( i18n("Manage new Categories") ); 174 setCaption( i18n("Manage new Categories") );
175 QVBoxLayout* lay = new QVBoxLayout( this ); 175 QVBoxLayout* lay = new QVBoxLayout( this );
176 lay->setSpacing( 3 ); 176 lay->setSpacing( 3 );
177 lay->setMargin( 3 ); 177 lay->setMargin( 3 );
178 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 ); 178 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 );
179 lay->addWidget( lab ); 179 lay->addWidget( lab );
180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
181 lay->addWidget( format ); 181 lay->addWidget( format );
182 format->setExclusive ( true ) ; 182 format->setExclusive ( true ) ;
183 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 183 addCatBut = new QRadioButton(i18n("Add to category list"), format );
184 new QRadioButton(i18n("Remove from addressees"), format ); 184 new QRadioButton(i18n("Remove from addressees"), format );
185 addCatBut->setChecked( true ); 185 addCatBut->setChecked( true );
186 QPushButton * ok = new QPushButton( i18n("OK"), this ); 186 QPushButton * ok = new QPushButton( i18n("OK"), this );
187 lay->addWidget( ok ); 187 lay->addWidget( ok );
188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
189 lay->addWidget( cancel ); 189 lay->addWidget( cancel );
190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
192 resize( 200, 200 ); 192 resize( 200, 200 );
193 } 193 }
194 194
195 bool addCat() { return addCatBut->isChecked(); } 195 bool addCat() { return addCatBut->isChecked(); }
196private: 196private:
197 QRadioButton* addCatBut; 197 QRadioButton* addCatBut;
198}; 198};
199 199
200class KABFormatPrefs : public QDialog 200class KABFormatPrefs : public QDialog
201{ 201{
202 public: 202 public:
203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
204 QDialog( parent, name, true ) 204 QDialog( parent, name, true )
205 { 205 {
206 setCaption( i18n("Set formatted name") ); 206 setCaption( i18n("Set formatted name") );
207 QVBoxLayout* lay = new QVBoxLayout( this ); 207 QVBoxLayout* lay = new QVBoxLayout( this );
208 lay->setSpacing( 3 ); 208 lay->setSpacing( 3 );
209 lay->setMargin( 3 ); 209 lay->setMargin( 3 );
210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
211 lay->addWidget( lab ); 211 lay->addWidget( lab );
212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
213 lay->addWidget( format ); 213 lay->addWidget( format );
214 format->setExclusive ( true ) ; 214 format->setExclusive ( true ) ;
215 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 215 simple = new QRadioButton(i18n("Simple: James Bond"), format );
216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
218 company = new QRadioButton(i18n("Organization: MI6"), format ); 218 company = new QRadioButton(i18n("Organization: MI6"), format );
219 simple->setChecked( true ); 219 simple->setChecked( true );
220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
221 lay->addWidget( setCompany ); 221 lay->addWidget( setCompany );
222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
223 lay->addWidget( ok ); 223 lay->addWidget( ok );
224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
225 lay->addWidget( cancel ); 225 lay->addWidget( cancel );
226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
228 resize( 200, 200 ); 228 resize( 200, 200 );
229 } 229 }
230public: 230public:
231 QRadioButton* simple, *full, *reverse, *company; 231 QRadioButton* simple, *full, *reverse, *company;
232 QCheckBox* setCompany; 232 QCheckBox* setCompany;
233}; 233};
234 234
235 235
236 236
237class KAex2phonePrefs : public QDialog 237class KAex2phonePrefs : public QDialog
238{ 238{
239 public: 239 public:
240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
241 QDialog( parent, name, true ) 241 QDialog( parent, name, true )
242 { 242 {
243 setCaption( i18n("Export to phone options") ); 243 setCaption( i18n("Export to phone options") );
244 QVBoxLayout* lay = new QVBoxLayout( this ); 244 QVBoxLayout* lay = new QVBoxLayout( this );
245 lay->setSpacing( 3 ); 245 lay->setSpacing( 3 );
246 lay->setMargin( 3 ); 246 lay->setMargin( 3 );
247 QLabel *lab; 247 QLabel *lab;
248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
249 lab->setAlignment (AlignHCenter ); 249 lab->setAlignment (AlignHCenter );
250 QHBox* temphb; 250 QHBox* temphb;
251 temphb = new QHBox( this ); 251 temphb = new QHBox( this );
252 new QLabel( i18n("I/O device: "), temphb ); 252 new QLabel( i18n("I/O device: "), temphb );
253 mPhoneDevice = new QLineEdit( temphb); 253 mPhoneDevice = new QLineEdit( temphb);
254 lay->addWidget( temphb ); 254 lay->addWidget( temphb );
255 temphb = new QHBox( this ); 255 temphb = new QHBox( this );
256 new QLabel( i18n("Connection: "), temphb ); 256 new QLabel( i18n("Connection: "), temphb );
257 mPhoneConnection = new QLineEdit( temphb); 257 mPhoneConnection = new QLineEdit( temphb);
258 lay->addWidget( temphb ); 258 lay->addWidget( temphb );
259 temphb = new QHBox( this ); 259 temphb = new QHBox( this );
260 new QLabel( i18n("Model(opt.): "), temphb ); 260 new QLabel( i18n("Model(opt.): "), temphb );
261 mPhoneModel = new QLineEdit( temphb); 261 mPhoneModel = new QLineEdit( temphb);
262 lay->addWidget( temphb ); 262 lay->addWidget( temphb );
263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
264 // lay->addWidget( mWriteToSim ); 264 // lay->addWidget( mWriteToSim );
265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
266 lab->setAlignment (AlignHCenter); 266 lab->setAlignment (AlignHCenter);
267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
268 lay->addWidget( ok ); 268 lay->addWidget( ok );
269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
270 lay->addWidget( cancel ); 270 lay->addWidget( cancel );
271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
273 resize( 220, 240 ); 273 resize( 220, 240 );
274 274
275 } 275 }
276 276
277public: 277public:
278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
279 QCheckBox* mWriteToSim; 279 QCheckBox* mWriteToSim;
280}; 280};
281 281
282 282
283bool pasteWithNewUid = true; 283bool pasteWithNewUid = true;
284 284
285#ifdef KAB_EMBEDDED 285#ifdef KAB_EMBEDDED
286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
290#else //KAB_EMBEDDED 290#else //KAB_EMBEDDED
291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
294 mReadWrite( readWrite ), mModified( false ) 294 mReadWrite( readWrite ), mModified( false )
295#endif //KAB_EMBEDDED 295#endif //KAB_EMBEDDED
296{ 296{
297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
298 // syncManager->setBlockSave(false); 298 // syncManager->setBlockSave(false);
299 mMiniSplitter = 0; 299 mMiniSplitter = 0;
300 mExtensionBarSplitter = 0; 300 mExtensionBarSplitter = 0;
301 mIsPart = !parent->inherits( "KAddressBookMain" ); 301 mIsPart = !parent->inherits( "KAddressBookMain" );
302 mAddressBook = KABC::StdAddressBook::self(); 302 mAddressBook = KABC::StdAddressBook::self();
303 KABC::StdAddressBook::setAutomaticSave( false ); 303 KABC::StdAddressBook::setAutomaticSave( false );
304 304
305#ifndef KAB_EMBEDDED 305#ifndef KAB_EMBEDDED
306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
307#endif //KAB_EMBEDDED 307#endif //KAB_EMBEDDED
308 308
309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
310 SLOT( addressBookChanged() ) ); 310 SLOT( addressBookChanged() ) );
311 311
312#if 0 312#if 0
313 // LP moved to addressbook init method 313 // LP moved to addressbook init method
314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
315 "X-Department", "KADDRESSBOOK" ); 315 "X-Department", "KADDRESSBOOK" );
316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
317 "X-Profession", "KADDRESSBOOK" ); 317 "X-Profession", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
319 "X-AssistantsName", "KADDRESSBOOK" ); 319 "X-AssistantsName", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
321 "X-ManagersName", "KADDRESSBOOK" ); 321 "X-ManagersName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
323 "X-SpousesName", "KADDRESSBOOK" ); 323 "X-SpousesName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
325 "X-Office", "KADDRESSBOOK" ); 325 "X-Office", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
327 "X-IMAddress", "KADDRESSBOOK" ); 327 "X-IMAddress", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
329 "X-Anniversary", "KADDRESSBOOK" ); 329 "X-Anniversary", "KADDRESSBOOK" );
330 330
331 //US added this field to become compatible with Opie/qtopia addressbook 331 //US added this field to become compatible with Opie/qtopia addressbook
332 // values can be "female" or "male" or "". An empty field represents undefined. 332 // values can be "female" or "male" or "". An empty field represents undefined.
333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
334 "X-Gender", "KADDRESSBOOK" ); 334 "X-Gender", "KADDRESSBOOK" );
335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
336 "X-Children", "KADDRESSBOOK" ); 336 "X-Children", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
338 "X-FreeBusyUrl", "KADDRESSBOOK" ); 338 "X-FreeBusyUrl", "KADDRESSBOOK" );
339#endif 339#endif
340 initGUI(); 340 initGUI();
341 341
342 mIncSearchWidget->setFocus(); 342 mIncSearchWidget->setFocus();
343 343
344 344
345 connect( mViewManager, SIGNAL( selected( const QString& ) ), 345 connect( mViewManager, SIGNAL( selected( const QString& ) ),
346 SLOT( setContactSelected( const QString& ) ) ); 346 SLOT( setContactSelected( const QString& ) ) );
347 connect( mViewManager, SIGNAL( executed( const QString& ) ), 347 connect( mViewManager, SIGNAL( executed( const QString& ) ),
348 SLOT( executeContact( const QString& ) ) ); 348 SLOT( executeContact( const QString& ) ) );
349 349
350 connect( mViewManager, SIGNAL( deleteRequest( ) ), 350 connect( mViewManager, SIGNAL( deleteRequest( ) ),
351 SLOT( deleteContacts( ) ) ); 351 SLOT( deleteContacts( ) ) );
352 connect( mViewManager, SIGNAL( modified() ), 352 connect( mViewManager, SIGNAL( modified() ),
353 SLOT( setModified() ) ); 353 SLOT( setModified() ) );
354 354
355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
356 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 356 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
357 357
358 connect( mXXPortManager, SIGNAL( modified() ), 358 connect( mXXPortManager, SIGNAL( modified() ),
359 SLOT( setModified() ) ); 359 SLOT( setModified() ) );
360 360
361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
362 SLOT( incrementalSearch( const QString& ) ) ); 362 SLOT( incrementalSearch( const QString& ) ) );
363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
364 mJumpButtonBar, SLOT( recreateButtons() ) ); 364 mJumpButtonBar, SLOT( recreateButtons() ) );
365 365
366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
367 SLOT( sendMail( const QString& ) ) ); 367 SLOT( sendMail( const QString& ) ) );
368 368
369 369
370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
371 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&))); 371 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&)));
372 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 372 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
373 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 373 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
374 374
375 375
376#ifndef KAB_EMBEDDED 376#ifndef KAB_EMBEDDED
377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
378 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 378 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
379 379
380 connect( mDetails, SIGNAL( browse( const QString& ) ), 380 connect( mDetails, SIGNAL( browse( const QString& ) ),
381 SLOT( browse( const QString& ) ) ); 381 SLOT( browse( const QString& ) ) );
382 382
383 383
384 mAddressBookService = new KAddressBookService( this ); 384 mAddressBookService = new KAddressBookService( this );
385 385
386#endif //KAB_EMBEDDED 386#endif //KAB_EMBEDDED
387 387
388 mMessageTimer = new QTimer( this ); 388 mMessageTimer = new QTimer( this );
389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
390 mEditorDialog = 0; 390 mEditorDialog = 0;
391 createAddresseeEditorDialog( this ); 391 createAddresseeEditorDialog( this );
392 setModified( false ); 392 setModified( false );
393 mBRdisabled = false; 393 mBRdisabled = false;
394#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
395 infrared = 0; 395 infrared = 0;
396#endif 396#endif
397 //toggleBeamReceive( ); 397 //toggleBeamReceive( );
398 //mMainWindow->toolBar()->show(); 398 //mMainWindow->toolBar()->show();
399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
400 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 400 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
401} 401}
402 402
403void KABCore::updateToolBar() 403void KABCore::updateToolBar()
404{ 404{
405 static int iii = 0; 405 static int iii = 0;
406 ++iii; 406 ++iii;
407 mMainWindow->toolBar()->repaintMe(); 407 mMainWindow->toolBar()->repaintMe();
408 if ( iii < 5 ) 408 if ( iii < 3 )
409 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 409 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
410} 410}
411KABCore::~KABCore() 411KABCore::~KABCore()
412{ 412{
413 // save(); 413 // save();
414 //saveSettings(); 414 //saveSettings();
415 //KABPrefs::instance()->writeConfig(); 415 //KABPrefs::instance()->writeConfig();
416 delete AddresseeConfig::instance(); 416 delete AddresseeConfig::instance();
417 mAddressBook = 0; 417 mAddressBook = 0;
418 KABC::StdAddressBook::close(); 418 KABC::StdAddressBook::close();
419 419
420 delete syncManager; 420 delete syncManager;
421#ifndef DESKTOP_VERSION 421#ifndef DESKTOP_VERSION
422 if ( infrared ) 422 if ( infrared )
423 delete infrared; 423 delete infrared;
424#endif 424#endif
425} 425}
426void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 426void KABCore::receive( const QCString& cmsg, const QByteArray& data )
427{ 427{
428 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 428 qDebug("KA: QCOP message received: %s ", cmsg.data() );
429 if ( cmsg == "setDocument(QString)" ) { 429 if ( cmsg == "setDocument(QString)" ) {
430 QDataStream stream( data, IO_ReadOnly ); 430 QDataStream stream( data, IO_ReadOnly );
431 QString fileName; 431 QString fileName;
432 stream >> fileName; 432 stream >> fileName;
433 recieve( fileName ); 433 recieve( fileName );
434 return; 434 return;
435 } 435 }
436} 436}
437void KABCore::toggleBeamReceive( ) 437void KABCore::toggleBeamReceive( )
438{ 438{
439 if ( mBRdisabled ) 439 if ( mBRdisabled )
440 return; 440 return;
441#ifndef DESKTOP_VERSION 441#ifndef DESKTOP_VERSION
442 if ( infrared ) { 442 if ( infrared ) {
443 qDebug("AB disable BeamReceive "); 443 qDebug("AB disable BeamReceive ");
444 delete infrared; 444 delete infrared;
445 infrared = 0; 445 infrared = 0;
446 mActionBR->setChecked(false); 446 mActionBR->setChecked(false);
447 return; 447 return;
448 } 448 }
449 qDebug("AB enable BeamReceive "); 449 qDebug("AB enable BeamReceive ");
450 mActionBR->setChecked(true); 450 mActionBR->setChecked(true);
451 451
452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
453 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 453 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
454#endif 454#endif
455} 455}
456 456
457 457
458void KABCore::disableBR(bool b) 458void KABCore::disableBR(bool b)
459{ 459{
460#ifndef DESKTOP_VERSION 460#ifndef DESKTOP_VERSION
461 if ( b ) { 461 if ( b ) {
462 if ( infrared ) { 462 if ( infrared ) {
463 toggleBeamReceive( ); 463 toggleBeamReceive( );
464 } 464 }
465 mBRdisabled = true; 465 mBRdisabled = true;
466 } else { 466 } else {
467 if ( mBRdisabled ) { 467 if ( mBRdisabled ) {
468 mBRdisabled = false; 468 mBRdisabled = false;
469 //toggleBeamReceive( ); 469 //toggleBeamReceive( );
470 } 470 }
471 } 471 }
472#endif 472#endif
473 473
474} 474}
475void KABCore::recieve( QString fn ) 475void KABCore::recieve( QString fn )
476{ 476{
477 //qDebug("KABCore::recieve "); 477 //qDebug("KABCore::recieve ");
478 int count = mAddressBook->importFromFile( fn, true ); 478 int count = mAddressBook->importFromFile( fn, true );
479 if ( count ) 479 if ( count )
480 setModified( true ); 480 setModified( true );
481 mViewManager->refreshView(); 481 mViewManager->refreshView();
482 message(i18n("%1 contact(s) received!").arg( count )); 482 message(i18n("%1 contact(s) received!").arg( count ));
483 topLevelWidget()->showMaximized(); 483 topLevelWidget()->showMaximized();
484 topLevelWidget()->raise(); 484 topLevelWidget()->raise();
485} 485}
486void KABCore::restoreSettings() 486void KABCore::restoreSettings()
487{ 487{
488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
489 489
490 bool state; 490 bool state;
491 491
492 if (mMultipleViewsAtOnce) 492 if (mMultipleViewsAtOnce)
493 state = KABPrefs::instance()->mDetailsPageVisible; 493 state = KABPrefs::instance()->mDetailsPageVisible;
494 else 494 else
495 state = false; 495 state = false;
496 496
497 mActionDetails->setChecked( state ); 497 mActionDetails->setChecked( state );
498 setDetailsVisible( state ); 498 setDetailsVisible( state );
499 499
500 state = KABPrefs::instance()->mJumpButtonBarVisible; 500 state = KABPrefs::instance()->mJumpButtonBarVisible;
501 501
502 mActionJumpBar->setChecked( state ); 502 mActionJumpBar->setChecked( state );
503 setJumpButtonBarVisible( state ); 503 setJumpButtonBarVisible( state );
504/*US 504/*US
505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
506 if ( splitterSize.count() == 0 ) { 506 if ( splitterSize.count() == 0 ) {
507 splitterSize.append( width() / 2 ); 507 splitterSize.append( width() / 2 );
508 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
509 } 509 }
510 mMiniSplitter->setSizes( splitterSize ); 510 mMiniSplitter->setSizes( splitterSize );
511 if ( mExtensionBarSplitter ) { 511 if ( mExtensionBarSplitter ) {
512 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 512 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
513 if ( splitterSize.count() == 0 ) { 513 if ( splitterSize.count() == 0 ) {
514 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
515 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
516 } 516 }
517 mExtensionBarSplitter->setSizes( splitterSize ); 517 mExtensionBarSplitter->setSizes( splitterSize );
518 518
519 } 519 }
520*/ 520*/
521 mViewManager->restoreSettings(); 521 mViewManager->restoreSettings();
522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
523 mExtensionManager->restoreSettings(); 523 mExtensionManager->restoreSettings();
524#ifdef DESKTOP_VERSION 524#ifdef DESKTOP_VERSION
525 int wid = width(); 525 int wid = width();
526 if ( wid < 10 ) 526 if ( wid < 10 )
527 wid = 400; 527 wid = 400;
528#else 528#else
529 int wid = QApplication::desktop()->width(); 529 int wid = QApplication::desktop()->width();
530 if ( wid < 640 ) 530 if ( wid < 640 )
531 wid = QApplication::desktop()->height(); 531 wid = QApplication::desktop()->height();
532#endif 532#endif
533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
534 if ( true /*splitterSize.count() == 0*/ ) { 534 if ( true /*splitterSize.count() == 0*/ ) {
535 splitterSize.append( wid / 2 ); 535 splitterSize.append( wid / 2 );
536 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
537 } 537 }
538 mMiniSplitter->setSizes( splitterSize ); 538 mMiniSplitter->setSizes( splitterSize );
539 if ( mExtensionBarSplitter ) { 539 if ( mExtensionBarSplitter ) {
540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
541 if ( true /*splitterSize.count() == 0*/ ) { 541 if ( true /*splitterSize.count() == 0*/ ) {
542 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
543 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
544 } 544 }
545 mExtensionBarSplitter->setSizes( splitterSize ); 545 mExtensionBarSplitter->setSizes( splitterSize );
546 546
547 } 547 }
548 548
549 549
550} 550}
551 551
552void KABCore::saveSettings() 552void KABCore::saveSettings()
553{ 553{
554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
555 if ( mExtensionBarSplitter ) 555 if ( mExtensionBarSplitter )
556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
559#ifndef KAB_EMBEDDED 559#ifndef KAB_EMBEDDED
560 560
561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
563#endif //KAB_EMBEDDED 563#endif //KAB_EMBEDDED
564 mExtensionManager->saveSettings(); 564 mExtensionManager->saveSettings();
565 mViewManager->saveSettings(); 565 mViewManager->saveSettings();
566 566
567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
568 KABPrefs::instance()->writeConfig(); 568 KABPrefs::instance()->writeConfig();
569 qDebug("KABPrefs::instance()->writeConfig() "); 569 qDebug("KABCore::saveSettings() ");
570} 570}
571 571
572KABC::AddressBook *KABCore::addressBook() const 572KABC::AddressBook *KABCore::addressBook() const
573{ 573{
574 return mAddressBook; 574 return mAddressBook;
575} 575}
576 576
577KConfig *KABCore::config() 577KConfig *KABCore::config()
578{ 578{
579#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
580 return KABPrefs::instance()->config(); 580 return KABPrefs::instance()->config();
581#else //KAB_EMBEDDED 581#else //KAB_EMBEDDED
582 return KABPrefs::instance()->getConfig(); 582 return KABPrefs::instance()->getConfig();
583#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
584} 584}
585 585
586KActionCollection *KABCore::actionCollection() const 586KActionCollection *KABCore::actionCollection() const
587{ 587{
588 return mGUIClient->actionCollection(); 588 return mGUIClient->actionCollection();
589} 589}
590 590
591KABC::Field *KABCore::currentSearchField() const 591KABC::Field *KABCore::currentSearchField() const
592{ 592{
593 if (mIncSearchWidget) 593 if (mIncSearchWidget)
594 return mIncSearchWidget->currentField(); 594 return mIncSearchWidget->currentField();
595 else 595 else
596 return 0; 596 return 0;
597} 597}
598 598
599QStringList KABCore::selectedUIDs() const 599QStringList KABCore::selectedUIDs() const
600{ 600{
601 return mViewManager->selectedUids(); 601 return mViewManager->selectedUids();
602} 602}
603 603
604KABC::Resource *KABCore::requestResource( QWidget *parent ) 604KABC::Resource *KABCore::requestResource( QWidget *parent )
605{ 605{
606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 606 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
607 607
608 QPtrList<KRES::Resource> kresResources; 608 QPtrList<KRES::Resource> kresResources;
609 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 609 QPtrListIterator<KABC::Resource> resIt( kabcResources );
610 KABC::Resource *resource; 610 KABC::Resource *resource;
611 while ( ( resource = resIt.current() ) != 0 ) { 611 while ( ( resource = resIt.current() ) != 0 ) {
612 ++resIt; 612 ++resIt;
613 if ( !resource->readOnly() ) { 613 if ( !resource->readOnly() ) {
614 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 614 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
615 if ( res ) 615 if ( res )
616 kresResources.append( res ); 616 kresResources.append( res );
617 } 617 }
618 } 618 }
619 619
620 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 620 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
621 return static_cast<KABC::Resource*>( res ); 621 return static_cast<KABC::Resource*>( res );
622} 622}
623 623
624#ifndef KAB_EMBEDDED 624#ifndef KAB_EMBEDDED
625KAboutData *KABCore::createAboutData() 625KAboutData *KABCore::createAboutData()
626#else //KAB_EMBEDDED 626#else //KAB_EMBEDDED
627void KABCore::createAboutData() 627void KABCore::createAboutData()
628#endif //KAB_EMBEDDED 628#endif //KAB_EMBEDDED
629{ 629{
630#ifndef KAB_EMBEDDED 630#ifndef KAB_EMBEDDED
631 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 631 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
632 "3.1", I18N_NOOP( "The KDE Address Book" ), 632 "3.1", I18N_NOOP( "The KDE Address Book" ),
633 KAboutData::License_GPL_V2, 633 KAboutData::License_GPL_V2,
634 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 634 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
635 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 635 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
636 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 636 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
637 about->addAuthor( "Cornelius Schumacher", 637 about->addAuthor( "Cornelius Schumacher",
638 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 638 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
639 "schumacher@kde.org" ); 639 "schumacher@kde.org" );
640 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 640 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
641 "mpilone@slac.com" ); 641 "mpilone@slac.com" );
642 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 642 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
643 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 643 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
644 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 644 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
645 "michel@klaralvdalens-datakonsult.se" ); 645 "michel@klaralvdalens-datakonsult.se" );
646 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 646 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
647 "hansen@kde.org" ); 647 "hansen@kde.org" );
648 648
649 return about; 649 return about;
650#endif //KAB_EMBEDDED 650#endif //KAB_EMBEDDED
651 651
652 QString version; 652 QString version;
653#include <../version> 653#include <../version>
654 QMessageBox::about( this, "About KAddressbook/Pi", 654 QMessageBox::about( this, "About KAddressbook/Pi",
655 "KAddressbook/Platform-independent\n" 655 "KAddressbook/Platform-independent\n"
656 "(KA/Pi) " +version + " - " + 656 "(KA/Pi) " +version + " - " +
657#ifdef DESKTOP_VERSION 657#ifdef DESKTOP_VERSION
658 "Desktop Edition\n" 658 "Desktop Edition\n"
659#else 659#else
660 "PDA-Edition\n" 660 "PDA-Edition\n"
661 "for: Zaurus 5500 / 7x0 / 8x0\n" 661 "for: Zaurus 5500 / 7x0 / 8x0\n"
662#endif 662#endif
663 663
664 "(c) 2004 Ulf Schenk\n" 664 "(c) 2004 Ulf Schenk\n"
665 "(c) 2004 Lutz Rogowski\n" 665 "(c) 2004 Lutz Rogowski\n"
666 "(c) 1997-2003, The KDE PIM Team\n" 666 "(c) 1997-2003, The KDE PIM Team\n"
667 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 667 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
668 "Don Sanders Original author\n" 668 "Don Sanders Original author\n"
669 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 669 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
670 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 670 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
671 "Greg Stern DCOP interface\n" 671 "Greg Stern DCOP interface\n"
672 "Mark Westcot Contact pinning\n" 672 "Mark Westcot Contact pinning\n"
673 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 673 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
674 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 674 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
675#ifdef _WIN32_ 675#ifdef _WIN32_
676 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 676 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
677#endif 677#endif
678 ); 678 );
679} 679}
680 680
681void KABCore::setContactSelected( const QString &uid ) 681void KABCore::setContactSelected( const QString &uid )
682{ 682{
683 KABC::Addressee addr = mAddressBook->findByUid( uid ); 683 KABC::Addressee addr = mAddressBook->findByUid( uid );
684 if ( !mDetails->isHidden() ) 684 if ( !mDetails->isHidden() )
685 mDetails->setAddressee( addr ); 685 mDetails->setAddressee( addr );
686 686
687 if ( !addr.isEmpty() ) { 687 if ( !addr.isEmpty() ) {
688 emit contactSelected( addr.formattedName() ); 688 emit contactSelected( addr.formattedName() );
689 KABC::Picture pic = addr.photo(); 689 KABC::Picture pic = addr.photo();
690 if ( pic.isIntern() ) { 690 if ( pic.isIntern() ) {
691//US emit contactSelected( pic.data() ); 691//US emit contactSelected( pic.data() );
692//US instead use: 692//US instead use:
693 QPixmap px; 693 QPixmap px;
694 if (pic.data().isNull() != true) 694 if (pic.data().isNull() != true)
695 { 695 {
696 px.convertFromImage(pic.data()); 696 px.convertFromImage(pic.data());
697 } 697 }
698 698
699 emit contactSelected( px ); 699 emit contactSelected( px );
700 } 700 }
701 } 701 }
702 702
703 703
704 mExtensionManager->setSelectionChanged(); 704 mExtensionManager->setSelectionChanged();
705 705
706 // update the actions 706 // update the actions
707 bool selected = !uid.isEmpty(); 707 bool selected = !uid.isEmpty();
708 708
709 if ( mReadWrite ) { 709 if ( mReadWrite ) {
710 mActionCut->setEnabled( selected ); 710 mActionCut->setEnabled( selected );
711 mActionPaste->setEnabled( selected ); 711 mActionPaste->setEnabled( selected );
712 } 712 }
713 713
714 mActionCopy->setEnabled( selected ); 714 mActionCopy->setEnabled( selected );
715 mActionDelete->setEnabled( selected ); 715 mActionDelete->setEnabled( selected );
716 mActionEditAddressee->setEnabled( selected ); 716 mActionEditAddressee->setEnabled( selected );
717 mActionMail->setEnabled( selected ); 717 mActionMail->setEnabled( selected );
718 mActionMailVCard->setEnabled( selected ); 718 mActionMailVCard->setEnabled( selected );
719 //if (mActionBeam) 719 //if (mActionBeam)
720 //mActionBeam->setEnabled( selected ); 720 //mActionBeam->setEnabled( selected );
721 mActionWhoAmI->setEnabled( selected ); 721 mActionWhoAmI->setEnabled( selected );
722} 722}
723 723
724void KABCore::sendMail() 724void KABCore::sendMail()
725{ 725{
726 sendMail( mViewManager->selectedEmails().join( ", " ) ); 726 sendMail( mViewManager->selectedEmails().join( ", " ) );
727} 727}
728 728
729void KABCore::sendMail( const QString& emaillist ) 729void KABCore::sendMail( const QString& emaillist )
730{ 730{
731 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 731 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
732 if (emaillist.contains(",") > 0) 732 if (emaillist.contains(",") > 0)
733 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 733 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
734 else 734 else
735 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 735 ExternalAppHandler::instance()->mailToOneContact( emaillist );
736} 736}
737 737
738 738
739 739
740void KABCore::mailVCard() 740void KABCore::mailVCard()
741{ 741{
742 QStringList uids = mViewManager->selectedUids(); 742 QStringList uids = mViewManager->selectedUids();
743 if ( !uids.isEmpty() ) 743 if ( !uids.isEmpty() )
744 mailVCard( uids ); 744 mailVCard( uids );
745} 745}
746 746
747void KABCore::mailVCard( const QStringList& uids ) 747void KABCore::mailVCard( const QStringList& uids )
748{ 748{
749 QStringList urls; 749 QStringList urls;
750 750
751// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 751// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
752 752
753 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 753 QString dirName = "/tmp/" + KApplication::randomString( 8 );
754 754
755 755
756 756
757 QDir().mkdir( dirName, true ); 757 QDir().mkdir( dirName, true );
758 758
759 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 759 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
760 KABC::Addressee a = mAddressBook->findByUid( *it ); 760 KABC::Addressee a = mAddressBook->findByUid( *it );
761 761
762 if ( a.isEmpty() ) 762 if ( a.isEmpty() )
763 continue; 763 continue;
764 764
765 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 765 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
766 766
767 QString fileName = dirName + "/" + name; 767 QString fileName = dirName + "/" + name;
768 768
769 QFile outFile(fileName); 769 QFile outFile(fileName);
770 770
771 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 771 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
772 KABC::VCardConverter converter; 772 KABC::VCardConverter converter;
773 QString vcard; 773 QString vcard;
774 774
775 converter.addresseeToVCard( a, vcard ); 775 converter.addresseeToVCard( a, vcard );
776 776
777 QTextStream t( &outFile ); // use a text stream 777 QTextStream t( &outFile ); // use a text stream
778 t.setEncoding( QTextStream::UnicodeUTF8 ); 778 t.setEncoding( QTextStream::UnicodeUTF8 );
779 t << vcard; 779 t << vcard;
780 780
781 outFile.close(); 781 outFile.close();
782 782
783 urls.append( fileName ); 783 urls.append( fileName );
784 } 784 }
785 } 785 }
786 786
787 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 787 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
788 788
789 789
790/*US 790/*US
791 kapp->invokeMailer( QString::null, QString::null, QString::null, 791 kapp->invokeMailer( QString::null, QString::null, QString::null,
792 QString::null, // subject 792 QString::null, // subject
793 QString::null, // body 793 QString::null, // body
794 QString::null, 794 QString::null,
795 urls ); // attachments 795 urls ); // attachments
796*/ 796*/
797 797
798} 798}
799 799
800/** 800/**
801 Beams the "WhoAmI contact. 801 Beams the "WhoAmI contact.
802*/ 802*/
803void KABCore::beamMySelf() 803void KABCore::beamMySelf()
804{ 804{
805 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 805 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
806 if (!a.isEmpty()) 806 if (!a.isEmpty())
807 { 807 {
808 QStringList uids; 808 QStringList uids;
809 uids << a.uid(); 809 uids << a.uid();
810 810
811 beamVCard(uids); 811 beamVCard(uids);
812 } else { 812 } else {
813 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 813 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
814 814
815 815
816 } 816 }
817} 817}
818void KABCore::updateMainWindow() 818void KABCore::updateMainWindow()
819{ 819{
820 820
821 mMainWindow->showMaximized(); 821 mMainWindow->showMaximized();
822 mMainWindow->update(); 822 mMainWindow->update();
823} 823}
824void KABCore::resizeEvent(QResizeEvent* e ) 824void KABCore::resizeEvent(QResizeEvent* e )
825{ 825{
826 if ( !mMiniSplitter ) 826 if ( !mMiniSplitter )
827 return; 827 return;
828 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 828 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
829 if ( QApplication::desktop()->width() >= 480 ) { 829 if ( QApplication::desktop()->width() >= 480 ) {
830 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 830 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
831 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 831 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
832 mMiniSplitter->setOrientation( Qt::Horizontal); 832 mMiniSplitter->setOrientation( Qt::Horizontal);
833 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 833 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
834 if ( QApplication::desktop()->width() <= 640 ) { 834 if ( QApplication::desktop()->width() <= 640 ) {
835 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 835 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
836 mViewManager->getFilterAction()->setComboWidth( 150 ); 836 mViewManager->getFilterAction()->setComboWidth( 150 );
837 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 837 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
838 } 838 }
839 } 839 }
840 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 840 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
841 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 841 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
842 mMiniSplitter->setOrientation( Qt::Vertical ); 842 mMiniSplitter->setOrientation( Qt::Vertical );
843 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 843 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
844 if ( QApplication::desktop()->width() <= 640 ) { 844 if ( QApplication::desktop()->width() <= 640 ) {
845 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 845 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
846 mMainWindow->showMinimized(); 846 mMainWindow->showMinimized();
847 mViewManager->getFilterAction()->setComboWidth( 0 ); 847 mViewManager->getFilterAction()->setComboWidth( 0 );
848 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 848 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
849 } 849 }
850 } 850 }
851 } 851 }
852 } 852 }
853 853
854} 854}
855void KABCore::export2phone() 855void KABCore::export2phone()
856{ 856{
857 857
858 QStringList uids; 858 QStringList uids;
859 XXPortSelectDialog dlg( this, false, this ); 859 XXPortSelectDialog dlg( this, false, this );
860 if ( dlg.exec() ) 860 if ( dlg.exec() )
861 uids = dlg.uids(); 861 uids = dlg.uids();
862 else 862 else
863 return; 863 return;
864 if ( uids.isEmpty() ) 864 if ( uids.isEmpty() )
865 return; 865 return;
866 // qDebug("count %d ", uids.count()); 866 // qDebug("count %d ", uids.count());
867 867
868 KAex2phonePrefs ex2phone; 868 KAex2phonePrefs ex2phone;
869 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 869 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
870 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 870 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
871 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 871 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
872 872
873 if ( !ex2phone.exec() ) { 873 if ( !ex2phone.exec() ) {
874 return; 874 return;
875 } 875 }
876 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 876 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
877 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 877 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
878 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 878 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
879 879
880 880
881 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 881 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
882 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 882 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
883 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 883 KPimGlobalPrefs::instance()->mEx2PhoneModel );
884 884
885 QString fileName = getPhoneFile(); 885 QString fileName = getPhoneFile();
886 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 886 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
887 return; 887 return;
888 888
889 message(i18n("Exporting to phone...")); 889 message(i18n("Exporting to phone..."));
890 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 890 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
891 891
892} 892}
893QString KABCore::getPhoneFile() 893QString KABCore::getPhoneFile()
894{ 894{
895#ifdef DESKTOP_VERSION 895#ifdef DESKTOP_VERSION
896 return locateLocal("tmp", "phonefile.vcf"); 896 return locateLocal("tmp", "phonefile.vcf");
897#else 897#else
898 return "/tmp/phonefile.vcf"; 898 return "/tmp/phonefile.vcf";
899#endif 899#endif
900 900
901} 901}
902void KABCore::writeToPhone( ) 902void KABCore::writeToPhone( )
903{ 903{
904 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 904 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
905 message(i18n("Export to phone finished!")); 905 message(i18n("Export to phone finished!"));
906 else 906 else
907 qDebug(i18n("Error exporting to phone")); 907 qDebug(i18n("Error exporting to phone"));
908} 908}
909void KABCore::beamVCard() 909void KABCore::beamVCard()
910{ 910{
911 QStringList uids; 911 QStringList uids;
912 XXPortSelectDialog dlg( this, false, this ); 912 XXPortSelectDialog dlg( this, false, this );
913 if ( dlg.exec() ) 913 if ( dlg.exec() )
914 uids = dlg.uids(); 914 uids = dlg.uids();
915 else 915 else
916 return; 916 return;
917 if ( uids.isEmpty() ) 917 if ( uids.isEmpty() )
918 return; 918 return;
919 beamVCard( uids ); 919 beamVCard( uids );
920} 920}
921 921
922 922
923void KABCore::beamVCard(const QStringList& uids) 923void KABCore::beamVCard(const QStringList& uids)
924{ 924{
925 925
926 // LR: we should use the /tmp dir on the Zaurus, 926 // LR: we should use the /tmp dir on the Zaurus,
927 // because: /tmp = RAM, (HOME)/kdepim = flash memory 927 // because: /tmp = RAM, (HOME)/kdepim = flash memory
928 928
929#ifdef DESKTOP_VERSION 929#ifdef DESKTOP_VERSION
930 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 930 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
931#else 931#else
932 QString fileName = "/tmp/kapibeamfile.vcf"; 932 QString fileName = "/tmp/kapibeamfile.vcf";
933#endif 933#endif
934 934
935 KABC::VCardConverter converter; 935 KABC::VCardConverter converter;
936 QString description; 936 QString description;
937 QString datastream; 937 QString datastream;
938 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 938 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
939 KABC::Addressee a = mAddressBook->findByUid( *it ); 939 KABC::Addressee a = mAddressBook->findByUid( *it );
940 940
941 if ( a.isEmpty() ) 941 if ( a.isEmpty() )
942 continue; 942 continue;
943 943
944 if (description.isEmpty()) 944 if (description.isEmpty())
945 description = a.formattedName(); 945 description = a.formattedName();
946 946
947 QString vcard; 947 QString vcard;
948 converter.addresseeToVCard( a, vcard ); 948 converter.addresseeToVCard( a, vcard );
949 int start = 0; 949 int start = 0;
950 int next; 950 int next;
951 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 951 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
952 int semi = vcard.find(";", next); 952 int semi = vcard.find(";", next);
953 int dopp = vcard.find(":", next); 953 int dopp = vcard.find(":", next);
954 int sep; 954 int sep;
955 if ( semi < dopp && semi >= 0 ) 955 if ( semi < dopp && semi >= 0 )
956 sep = semi ; 956 sep = semi ;
957 else 957 else
958 sep = dopp; 958 sep = dopp;
959 datastream +=vcard.mid( start, next - start); 959 datastream +=vcard.mid( start, next - start);
960 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 960 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
961 start = sep; 961 start = sep;
962 } 962 }
963 datastream += vcard.mid( start,vcard.length() ); 963 datastream += vcard.mid( start,vcard.length() );
964 } 964 }
965#ifndef DESKTOP_VERSION 965#ifndef DESKTOP_VERSION
966 QFile outFile(fileName); 966 QFile outFile(fileName);
967 if ( outFile.open(IO_WriteOnly) ) { 967 if ( outFile.open(IO_WriteOnly) ) {
968 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 968 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
969 QTextStream t( &outFile ); // use a text stream 969 QTextStream t( &outFile ); // use a text stream
970 //t.setEncoding( QTextStream::UnicodeUTF8 ); 970 //t.setEncoding( QTextStream::UnicodeUTF8 );
971 t.setEncoding( QTextStream::Latin1 ); 971 t.setEncoding( QTextStream::Latin1 );
972 t <<datastream.latin1(); 972 t <<datastream.latin1();
973 outFile.close(); 973 outFile.close();
974 Ir *ir = new Ir( this ); 974 Ir *ir = new Ir( this );
975 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 975 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
976 ir->send( fileName, description, "text/x-vCard" ); 976 ir->send( fileName, description, "text/x-vCard" );
977 } else { 977 } else {
978 qDebug("Error open temp beam file "); 978 qDebug("Error open temp beam file ");
979 return; 979 return;
980 } 980 }
981#endif 981#endif
982 982
983} 983}
984 984
985void KABCore::beamDone( Ir *ir ) 985void KABCore::beamDone( Ir *ir )
986{ 986{
987#ifndef DESKTOP_VERSION 987#ifndef DESKTOP_VERSION
988 delete ir; 988 delete ir;
989#endif 989#endif
990 topLevelWidget()->raise(); 990 topLevelWidget()->raise();
991 message( i18n("Beaming finished!") ); 991 message( i18n("Beaming finished!") );
992} 992}
993 993
994 994
995void KABCore::browse( const QString& url ) 995void KABCore::browse( const QString& url )
996{ 996{
997#ifndef KAB_EMBEDDED 997#ifndef KAB_EMBEDDED
998 kapp->invokeBrowser( url ); 998 kapp->invokeBrowser( url );
999#else //KAB_EMBEDDED 999#else //KAB_EMBEDDED
1000 qDebug("KABCore::browse must be fixed"); 1000 qDebug("KABCore::browse must be fixed");
1001#endif //KAB_EMBEDDED 1001#endif //KAB_EMBEDDED
1002} 1002}
1003 1003
1004void KABCore::selectAllContacts() 1004void KABCore::selectAllContacts()
1005{ 1005{
1006 mViewManager->setSelected( QString::null, true ); 1006 mViewManager->setSelected( QString::null, true );
1007} 1007}
1008 1008
1009void KABCore::deleteContacts() 1009void KABCore::deleteContacts()
1010{ 1010{
1011 QStringList uidList = mViewManager->selectedUids(); 1011 QStringList uidList = mViewManager->selectedUids();
1012 deleteContacts( uidList ); 1012 deleteContacts( uidList );
1013} 1013}
1014 1014
1015void KABCore::deleteContacts( const QStringList &uids ) 1015void KABCore::deleteContacts( const QStringList &uids )
1016{ 1016{
1017 if ( uids.count() > 0 ) { 1017 if ( uids.count() > 0 ) {
1018 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1018 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1019 UndoStack::instance()->push( command ); 1019 UndoStack::instance()->push( command );
1020 RedoStack::instance()->clear(); 1020 RedoStack::instance()->clear();
1021 1021
1022 // now if we deleted anything, refresh 1022 // now if we deleted anything, refresh
1023 setContactSelected( QString::null ); 1023 setContactSelected( QString::null );
1024 setModified( true ); 1024 setModified( true );
1025 } 1025 }
1026} 1026}
1027 1027
1028void KABCore::copyContacts() 1028void KABCore::copyContacts()
1029{ 1029{
1030 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1030 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1031 1031
1032 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1032 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1033 1033
1034 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1034 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1035 1035
1036 QClipboard *cb = QApplication::clipboard(); 1036 QClipboard *cb = QApplication::clipboard();
1037 cb->setText( clipText ); 1037 cb->setText( clipText );
1038} 1038}
1039 1039
1040void KABCore::cutContacts() 1040void KABCore::cutContacts()
1041{ 1041{
1042 QStringList uidList = mViewManager->selectedUids(); 1042 QStringList uidList = mViewManager->selectedUids();
1043 1043
1044//US if ( uidList.size() > 0 ) { 1044//US if ( uidList.size() > 0 ) {
1045 if ( uidList.count() > 0 ) { 1045 if ( uidList.count() > 0 ) {
1046 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1046 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1047 UndoStack::instance()->push( command ); 1047 UndoStack::instance()->push( command );
1048 RedoStack::instance()->clear(); 1048 RedoStack::instance()->clear();
1049 1049
1050 setModified( true ); 1050 setModified( true );
1051 } 1051 }
1052} 1052}
1053 1053
1054void KABCore::pasteContacts() 1054void KABCore::pasteContacts()
1055{ 1055{
1056 QClipboard *cb = QApplication::clipboard(); 1056 QClipboard *cb = QApplication::clipboard();
1057 1057
1058 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1058 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1059 1059
1060 pasteContacts( list ); 1060 pasteContacts( list );
1061} 1061}
1062 1062
1063void KABCore::pasteContacts( KABC::Addressee::List &list ) 1063void KABCore::pasteContacts( KABC::Addressee::List &list )
1064{ 1064{
1065 KABC::Resource *resource = requestResource( this ); 1065 KABC::Resource *resource = requestResource( this );
1066 KABC::Addressee::List::Iterator it; 1066 KABC::Addressee::List::Iterator it;
1067 for ( it = list.begin(); it != list.end(); ++it ) 1067 for ( it = list.begin(); it != list.end(); ++it )
1068 (*it).setResource( resource ); 1068 (*it).setResource( resource );
1069 1069
1070 PwPasteCommand *command = new PwPasteCommand( this, list ); 1070 PwPasteCommand *command = new PwPasteCommand( this, list );
1071 UndoStack::instance()->push( command ); 1071 UndoStack::instance()->push( command );
1072 RedoStack::instance()->clear(); 1072 RedoStack::instance()->clear();
1073 1073
1074 setModified( true ); 1074 setModified( true );
1075} 1075}
1076 1076
1077void KABCore::setWhoAmI() 1077void KABCore::setWhoAmI()
1078{ 1078{
1079 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1079 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1080 1080
1081 if ( addrList.count() > 1 ) { 1081 if ( addrList.count() > 1 ) {
1082 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1082 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1083 return; 1083 return;
1084 } 1084 }
1085 1085
1086 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1086 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1087 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1087 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1088 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1088 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1089} 1089}
1090void KABCore::editCategories() 1090void KABCore::editCategories()
1091{ 1091{
1092 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1092 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1093 dlg.exec(); 1093 dlg.exec();
1094} 1094}
1095void KABCore::setCategories() 1095void KABCore::setCategories()
1096{ 1096{
1097 1097
1098 QStringList uids; 1098 QStringList uids;
1099 XXPortSelectDialog dlgx( this, false, this ); 1099 XXPortSelectDialog dlgx( this, false, this );
1100 if ( dlgx.exec() ) 1100 if ( dlgx.exec() )
1101 uids = dlgx.uids(); 1101 uids = dlgx.uids();
1102 else 1102 else
1103 return; 1103 return;
1104 if ( uids.isEmpty() ) 1104 if ( uids.isEmpty() )
1105 return; 1105 return;
1106 // qDebug("count %d ", uids.count()); 1106 // qDebug("count %d ", uids.count());
1107 1107
1108 1108
1109 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1109 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1110 if ( !dlg.exec() ) { 1110 if ( !dlg.exec() ) {
1111 message( i18n("Setting categories cancelled") ); 1111 message( i18n("Setting categories cancelled") );
1112 return; 1112 return;
1113 } 1113 }
1114 bool merge = false; 1114 bool merge = false;
1115 QString msg = i18n( "Merge with existing categories?" ); 1115 QString msg = i18n( "Merge with existing categories?" );
1116 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1116 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1117 merge = true; 1117 merge = true;
1118 1118
1119 message( i18n("Setting categories ... please wait!") ); 1119 message( i18n("Setting categories ... please wait!") );
1120 QStringList categories = dlg.selectedCategories(); 1120 QStringList categories = dlg.selectedCategories();
1121 1121
1122 //QStringList uids = mViewManager->selectedUids(); 1122 //QStringList uids = mViewManager->selectedUids();
1123 QStringList::Iterator it; 1123 QStringList::Iterator it;
1124 for ( it = uids.begin(); it != uids.end(); ++it ) { 1124 for ( it = uids.begin(); it != uids.end(); ++it ) {
1125 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1125 KABC::Addressee addr = mAddressBook->findByUid( *it );
1126 if ( !addr.isEmpty() ) { 1126 if ( !addr.isEmpty() ) {
1127 if ( !merge ) 1127 if ( !merge )
1128 addr.setCategories( categories ); 1128 addr.setCategories( categories );
1129 else { 1129 else {
1130 QStringList addrCategories = addr.categories(); 1130 QStringList addrCategories = addr.categories();
1131 QStringList::Iterator catIt; 1131 QStringList::Iterator catIt;
1132 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1132 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1133 if ( !addrCategories.contains( *catIt ) ) 1133 if ( !addrCategories.contains( *catIt ) )
1134 addrCategories.append( *catIt ); 1134 addrCategories.append( *catIt );
1135 } 1135 }
1136 addr.setCategories( addrCategories ); 1136 addr.setCategories( addrCategories );
1137 } 1137 }
1138 mAddressBook->insertAddressee( addr ); 1138 mAddressBook->insertAddressee( addr );
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 if ( uids.count() > 0 ) 1142 if ( uids.count() > 0 )
1143 setModified( true ); 1143 setModified( true );
1144 message( i18n("Setting categories completed!") ); 1144 message( i18n("Setting categories completed!") );
1145} 1145}
1146 1146
1147void KABCore::setSearchFields( const KABC::Field::List &fields ) 1147void KABCore::setSearchFields( const KABC::Field::List &fields )
1148{ 1148{
1149 mIncSearchWidget->setFields( fields ); 1149 mIncSearchWidget->setFields( fields );
1150} 1150}
1151 1151
1152void KABCore::incrementalSearch( const QString& text ) 1152void KABCore::incrementalSearch( const QString& text )
1153{ 1153{
1154 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1154 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1155} 1155}
1156 1156
1157void KABCore::setModified() 1157void KABCore::setModified()
1158{ 1158{
1159 setModified( true ); 1159 setModified( true );
1160} 1160}
1161 1161
1162void KABCore::setModifiedWOrefresh() 1162void KABCore::setModifiedWOrefresh()
1163{ 1163{
1164 // qDebug("KABCore::setModifiedWOrefresh() "); 1164 // qDebug("KABCore::setModifiedWOrefresh() ");
1165 mModified = true; 1165 mModified = true;
1166 mActionSave->setEnabled( mModified ); 1166 mActionSave->setEnabled( mModified );
1167 1167
1168 1168
1169} 1169}
1170void KABCore::setModified( bool modified ) 1170void KABCore::setModified( bool modified )
1171{ 1171{
1172 mModified = modified; 1172 mModified = modified;
1173 mActionSave->setEnabled( mModified ); 1173 mActionSave->setEnabled( mModified );
1174 1174
1175 if ( modified ) 1175 if ( modified )
1176 mJumpButtonBar->recreateButtons(); 1176 mJumpButtonBar->recreateButtons();
1177 1177
1178 mViewManager->refreshView(); 1178 mViewManager->refreshView();
1179 1179
1180} 1180}
1181 1181
1182bool KABCore::modified() const 1182bool KABCore::modified() const
1183{ 1183{
1184 return mModified; 1184 return mModified;
1185} 1185}
1186 1186
1187void KABCore::contactModified( const KABC::Addressee &addr ) 1187void KABCore::contactModified( const KABC::Addressee &addr )
1188{ 1188{
1189 addrModified( addr ); 1189 addrModified( addr );
1190} 1190}
1191 1191
1192void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1192void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1193{ 1193{
1194 1194
1195 Command *command = 0; 1195 Command *command = 0;
1196 QString uid; 1196 QString uid;
1197 1197
1198 // check if it exists already 1198 // check if it exists already
1199 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1199 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1200 if ( origAddr.isEmpty() ) 1200 if ( origAddr.isEmpty() )
1201 command = new PwNewCommand( mAddressBook, addr ); 1201 command = new PwNewCommand( mAddressBook, addr );
1202 else { 1202 else {
1203 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1203 command = new PwEditCommand( mAddressBook, origAddr, addr );
1204 uid = addr.uid(); 1204 uid = addr.uid();
1205 } 1205 }
1206 1206
1207 UndoStack::instance()->push( command ); 1207 UndoStack::instance()->push( command );
1208 RedoStack::instance()->clear(); 1208 RedoStack::instance()->clear();
1209 if ( updateDetails ) 1209 if ( updateDetails )
1210 mDetails->setAddressee( addr ); 1210 mDetails->setAddressee( addr );
1211 setModified( true ); 1211 setModified( true );
1212} 1212}
1213 1213
1214void KABCore::newContact() 1214void KABCore::newContact()
1215{ 1215{
1216 1216
1217 1217
1218 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1218 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1219 1219
1220 QPtrList<KRES::Resource> kresResources; 1220 QPtrList<KRES::Resource> kresResources;
1221 QPtrListIterator<KABC::Resource> it( kabcResources ); 1221 QPtrListIterator<KABC::Resource> it( kabcResources );
1222 KABC::Resource *resource; 1222 KABC::Resource *resource;
1223 while ( ( resource = it.current() ) != 0 ) { 1223 while ( ( resource = it.current() ) != 0 ) {
1224 ++it; 1224 ++it;
1225 if ( !resource->readOnly() ) { 1225 if ( !resource->readOnly() ) {
1226 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1226 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1227 if ( res ) 1227 if ( res )
1228 kresResources.append( res ); 1228 kresResources.append( res );
1229 } 1229 }
1230 } 1230 }
1231 1231
1232 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1232 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1233 resource = static_cast<KABC::Resource*>( res ); 1233 resource = static_cast<KABC::Resource*>( res );
1234 1234
1235 if ( resource ) { 1235 if ( resource ) {
1236 KABC::Addressee addr; 1236 KABC::Addressee addr;
1237 addr.setResource( resource ); 1237 addr.setResource( resource );
1238 mEditorDialog->setAddressee( addr ); 1238 mEditorDialog->setAddressee( addr );
1239 KApplication::execDialog ( mEditorDialog ); 1239 KApplication::execDialog ( mEditorDialog );
1240 1240
1241 } else 1241 } else
1242 return; 1242 return;
1243 1243
1244 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1244 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1245 1245
1246 1246
1247} 1247}
1248 1248
1249void KABCore::addEmail( QString aStr ) 1249void KABCore::addEmail( QString aStr )
1250{ 1250{
1251#ifndef KAB_EMBEDDED 1251#ifndef KAB_EMBEDDED
1252 QString fullName, email; 1252 QString fullName, email;
1253 1253
1254 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1254 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1255 1255
1256 // Try to lookup the addressee matching the email address 1256 // Try to lookup the addressee matching the email address
1257 bool found = false; 1257 bool found = false;
1258 QStringList emailList; 1258 QStringList emailList;
1259 KABC::AddressBook::Iterator it; 1259 KABC::AddressBook::Iterator it;
1260 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1260 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1261 emailList = (*it).emails(); 1261 emailList = (*it).emails();
1262 if ( emailList.contains( email ) > 0 ) { 1262 if ( emailList.contains( email ) > 0 ) {
1263 found = true; 1263 found = true;
1264 (*it).setNameFromString( fullName ); 1264 (*it).setNameFromString( fullName );
1265 editContact( (*it).uid() ); 1265 editContact( (*it).uid() );
1266 } 1266 }
1267 } 1267 }
1268 1268
1269 if ( !found ) { 1269 if ( !found ) {
1270 KABC::Addressee addr; 1270 KABC::Addressee addr;
1271 addr.setNameFromString( fullName ); 1271 addr.setNameFromString( fullName );
1272 addr.insertEmail( email, true ); 1272 addr.insertEmail( email, true );
1273 1273
1274 mAddressBook->insertAddressee( addr ); 1274 mAddressBook->insertAddressee( addr );
1275 mViewManager->refreshView( addr.uid() ); 1275 mViewManager->refreshView( addr.uid() );
1276 editContact( addr.uid() ); 1276 editContact( addr.uid() );
1277 } 1277 }
1278#else //KAB_EMBEDDED 1278#else //KAB_EMBEDDED
1279 qDebug("KABCore::addEmail finsih method"); 1279 qDebug("KABCore::addEmail finsih method");
1280#endif //KAB_EMBEDDED 1280#endif //KAB_EMBEDDED
1281} 1281}
1282 1282
1283void KABCore::importVCard( const KURL &url, bool showPreview ) 1283void KABCore::importVCard( const KURL &url, bool showPreview )
1284{ 1284{
1285 mXXPortManager->importVCard( url, showPreview ); 1285 mXXPortManager->importVCard( url, showPreview );
1286} 1286}
1287void KABCore::importFromOL() 1287void KABCore::importFromOL()
1288{ 1288{
1289#ifdef _WIN32_ 1289#ifdef _WIN32_
1290 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1290 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1291 idgl->exec(); 1291 idgl->exec();
1292 KABC::Addressee::List list = idgl->getAddressList(); 1292 KABC::Addressee::List list = idgl->getAddressList();
1293 if ( list.count() > 0 ) { 1293 if ( list.count() > 0 ) {
1294 KABC::Addressee::List listNew; 1294 KABC::Addressee::List listNew;
1295 KABC::Addressee::List listExisting; 1295 KABC::Addressee::List listExisting;
1296 KABC::Addressee::List::Iterator it; 1296 KABC::Addressee::List::Iterator it;
1297 KABC::AddressBook::Iterator iter; 1297 KABC::AddressBook::Iterator iter;
1298 for ( it = list.begin(); it != list.end(); ++it ) { 1298 for ( it = list.begin(); it != list.end(); ++it ) {
1299 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1299 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1300 listNew.append( (*it) ); 1300 listNew.append( (*it) );
1301 else 1301 else
1302 listExisting.append( (*it) ); 1302 listExisting.append( (*it) );
1303 } 1303 }
1304 if ( listExisting.count() > 0 ) 1304 if ( listExisting.count() > 0 )
1305 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1305 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1306 if ( listNew.count() > 0 ) { 1306 if ( listNew.count() > 0 ) {
1307 pasteWithNewUid = false; 1307 pasteWithNewUid = false;
1308 pasteContacts( listNew ); 1308 pasteContacts( listNew );
1309 pasteWithNewUid = true; 1309 pasteWithNewUid = true;
1310 } 1310 }
1311 } 1311 }
1312 delete idgl; 1312 delete idgl;
1313#endif 1313#endif
1314} 1314}
1315 1315
1316void KABCore::importVCard( const QString &vCard, bool showPreview ) 1316void KABCore::importVCard( const QString &vCard, bool showPreview )
1317{ 1317{
1318 mXXPortManager->importVCard( vCard, showPreview ); 1318 mXXPortManager->importVCard( vCard, showPreview );
1319} 1319}
1320 1320
1321//US added a second method without defaultparameter 1321//US added a second method without defaultparameter
1322void KABCore::editContact2() { 1322void KABCore::editContact2() {
1323 editContact( QString::null ); 1323 editContact( QString::null );
1324} 1324}
1325 1325
1326void KABCore::editContact( const QString &uid ) 1326void KABCore::editContact( const QString &uid )
1327{ 1327{
1328 1328
1329 if ( mExtensionManager->isQuickEditVisible() ) 1329 if ( mExtensionManager->isQuickEditVisible() )
1330 return; 1330 return;
1331 1331
1332 // First, locate the contact entry 1332 // First, locate the contact entry
1333 QString localUID = uid; 1333 QString localUID = uid;
1334 if ( localUID.isNull() ) { 1334 if ( localUID.isNull() ) {
1335 QStringList uidList = mViewManager->selectedUids(); 1335 QStringList uidList = mViewManager->selectedUids();
1336 if ( uidList.count() > 0 ) 1336 if ( uidList.count() > 0 )
1337 localUID = *( uidList.at( 0 ) ); 1337 localUID = *( uidList.at( 0 ) );
1338 } 1338 }
1339 1339
1340 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1340 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1341 if ( !addr.isEmpty() ) { 1341 if ( !addr.isEmpty() ) {
1342 mEditorDialog->setAddressee( addr ); 1342 mEditorDialog->setAddressee( addr );
1343 KApplication::execDialog ( mEditorDialog ); 1343 KApplication::execDialog ( mEditorDialog );
1344 } 1344 }
1345} 1345}
1346 1346
1347/** 1347/**
1348 Shows or edits the detail view for the given uid. If the uid is QString::null, 1348 Shows or edits the detail view for the given uid. If the uid is QString::null,
1349 the method will try to find a selected addressee in the view. 1349 the method will try to find a selected addressee in the view.
1350 */ 1350 */
1351void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1351void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1352{ 1352{
1353 if ( mMultipleViewsAtOnce ) 1353 if ( mMultipleViewsAtOnce )
1354 { 1354 {
1355 editContact( uid ); 1355 editContact( uid );
1356 } 1356 }
1357 else 1357 else
1358 { 1358 {
1359 setDetailsVisible( true ); 1359 setDetailsVisible( true );
1360 mActionDetails->setChecked(true); 1360 mActionDetails->setChecked(true);
1361 } 1361 }
1362 1362
1363} 1363}
1364 1364
1365void KABCore::save() 1365void KABCore::save()
1366{ 1366{
1367 if (syncManager->blockSave()) 1367 if (syncManager->blockSave())
1368 return; 1368 return;
1369 if ( !mModified ) 1369 if ( !mModified )
1370 return; 1370 return;
1371 1371
1372 syncManager->setBlockSave(true); 1372 syncManager->setBlockSave(true);
1373 QString text = i18n( "There was an error while attempting to save\n the " 1373 QString text = i18n( "There was an error while attempting to save\n the "
1374 "address book. Please check that some \nother application is " 1374 "address book. Please check that some \nother application is "
1375 "not using it. " ); 1375 "not using it. " );
1376 message(i18n("Saving addressbook ... ")); 1376 message(i18n("Saving addressbook ... "));
1377#ifndef KAB_EMBEDDED 1377#ifndef KAB_EMBEDDED
1378 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1378 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1379 if ( !b || !b->save() ) { 1379 if ( !b || !b->save() ) {
1380 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1380 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1381 } 1381 }
1382#else //KAB_EMBEDDED 1382#else //KAB_EMBEDDED
1383 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1383 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1384 if ( !b || !b->save() ) { 1384 if ( !b || !b->save() ) {
1385 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1385 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1386 } 1386 }
1387#endif //KAB_EMBEDDED 1387#endif //KAB_EMBEDDED
1388 1388
1389 message(i18n("Addressbook saved!")); 1389 message(i18n("Addressbook saved!"));
1390 setModified( false ); 1390 setModified( false );
1391 syncManager->setBlockSave(false); 1391 syncManager->setBlockSave(false);
1392} 1392}
1393 1393
1394 1394
1395void KABCore::undo() 1395void KABCore::undo()
1396{ 1396{
1397 UndoStack::instance()->undo(); 1397 UndoStack::instance()->undo();
1398 1398
1399 // Refresh the view 1399 // Refresh the view
1400 mViewManager->refreshView(); 1400 mViewManager->refreshView();
1401} 1401}
1402 1402
1403void KABCore::redo() 1403void KABCore::redo()
1404{ 1404{
1405 RedoStack::instance()->redo(); 1405 RedoStack::instance()->redo();
1406 1406
1407 // Refresh the view 1407 // Refresh the view
1408 mViewManager->refreshView(); 1408 mViewManager->refreshView();
1409} 1409}
1410 1410
1411void KABCore::setJumpButtonBarVisible( bool visible ) 1411void KABCore::setJumpButtonBarVisible( bool visible )
1412{ 1412{
1413 if (mMultipleViewsAtOnce) 1413 if (mMultipleViewsAtOnce)
1414 { 1414 {
1415 if ( visible ) 1415 if ( visible )
1416 mJumpButtonBar->show(); 1416 mJumpButtonBar->show();
1417 else 1417 else
1418 mJumpButtonBar->hide(); 1418 mJumpButtonBar->hide();
1419 } 1419 }
1420 else 1420 else
1421 { 1421 {
1422 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1422 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1423 if (mViewManager->isVisible()) 1423 if (mViewManager->isVisible())
1424 { 1424 {
1425 if ( visible ) 1425 if ( visible )
1426 mJumpButtonBar->show(); 1426 mJumpButtonBar->show();
1427 else 1427 else
1428 mJumpButtonBar->hide(); 1428 mJumpButtonBar->hide();
1429 } 1429 }
1430 else 1430 else
1431 { 1431 {
1432 mJumpButtonBar->hide(); 1432 mJumpButtonBar->hide();
1433 } 1433 }
1434 } 1434 }
1435} 1435}
1436 1436
1437 1437
1438void KABCore::setDetailsToState() 1438void KABCore::setDetailsToState()
1439{ 1439{
1440 setDetailsVisible( mActionDetails->isChecked() ); 1440 setDetailsVisible( mActionDetails->isChecked() );
1441} 1441}
1442void KABCore::setDetailsToggle() 1442void KABCore::setDetailsToggle()
1443{ 1443{
1444 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1444 mActionDetails->setChecked( !mActionDetails->isChecked() );
1445 setDetailsToState(); 1445 setDetailsToState();
1446} 1446}
1447 1447
1448 1448
1449 1449
1450void KABCore::setDetailsVisible( bool visible ) 1450void KABCore::setDetailsVisible( bool visible )
1451{ 1451{
1452 if (visible && mDetails->isHidden()) 1452 if (visible && mDetails->isHidden())
1453 { 1453 {
1454 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1454 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1455 if ( addrList.count() > 0 ) 1455 if ( addrList.count() > 0 )
1456 mDetails->setAddressee( addrList[ 0 ] ); 1456 mDetails->setAddressee( addrList[ 0 ] );
1457 } 1457 }
1458 1458
1459 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1459 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1460 // the listview and the detailview. We do that by changing the splitbar size. 1460 // the listview and the detailview. We do that by changing the splitbar size.
1461 if (mMultipleViewsAtOnce) 1461 if (mMultipleViewsAtOnce)
1462 { 1462 {
1463 if ( visible ) 1463 if ( visible )
1464 mDetails->show(); 1464 mDetails->show();
1465 else 1465 else
1466 mDetails->hide(); 1466 mDetails->hide();
1467 } 1467 }
1468 else 1468 else
1469 { 1469 {
1470 if ( visible ) { 1470 if ( visible ) {
1471 mViewManager->hide(); 1471 mViewManager->hide();
1472 mDetails->show(); 1472 mDetails->show();
1473 mIncSearchWidget->setFocus(); 1473 mIncSearchWidget->setFocus();
1474 } 1474 }
1475 else { 1475 else {
1476 mViewManager->show(); 1476 mViewManager->show();
1477 mDetails->hide(); 1477 mDetails->hide();
1478 mViewManager->setFocusAV(); 1478 mViewManager->setFocusAV();
1479 } 1479 }
1480 setJumpButtonBarVisible( !visible ); 1480 setJumpButtonBarVisible( !visible );
1481 } 1481 }
1482 1482
1483} 1483}
1484 1484
1485void KABCore::extensionChanged( int id ) 1485void KABCore::extensionChanged( int id )
1486{ 1486{
1487 //change the details view only for non desktop systems 1487 //change the details view only for non desktop systems
1488#ifndef DESKTOP_VERSION 1488#ifndef DESKTOP_VERSION
1489 1489
1490 if (id == 0) 1490 if (id == 0)
1491 { 1491 {
1492 //the user disabled the extension. 1492 //the user disabled the extension.
1493 1493
1494 if (mMultipleViewsAtOnce) 1494 if (mMultipleViewsAtOnce)
1495 { // enable detailsview again 1495 { // enable detailsview again
1496 setDetailsVisible( true ); 1496 setDetailsVisible( true );
1497 mActionDetails->setChecked( true ); 1497 mActionDetails->setChecked( true );
1498 } 1498 }
1499 else 1499 else
1500 { //go back to the listview 1500 { //go back to the listview
1501 setDetailsVisible( false ); 1501 setDetailsVisible( false );
1502 mActionDetails->setChecked( false ); 1502 mActionDetails->setChecked( false );
1503 mActionDetails->setEnabled(true); 1503 mActionDetails->setEnabled(true);
1504 } 1504 }
1505 1505
1506 } 1506 }
1507 else 1507 else
1508 { 1508 {
1509 //the user enabled the extension. 1509 //the user enabled the extension.
1510 setDetailsVisible( false ); 1510 setDetailsVisible( false );
1511 mActionDetails->setChecked( false ); 1511 mActionDetails->setChecked( false );
1512 1512
1513 if (!mMultipleViewsAtOnce) 1513 if (!mMultipleViewsAtOnce)
1514 { 1514 {
1515 mActionDetails->setEnabled(false); 1515 mActionDetails->setEnabled(false);
1516 } 1516 }
1517 1517
1518 mExtensionManager->setSelectionChanged(); 1518 mExtensionManager->setSelectionChanged();
1519 1519
1520 } 1520 }
1521 1521
1522#endif// DESKTOP_VERSION 1522#endif// DESKTOP_VERSION
1523 1523
1524} 1524}
1525 1525
1526 1526
1527void KABCore::extensionModified( const KABC::Addressee::List &list ) 1527void KABCore::extensionModified( const KABC::Addressee::List &list )
1528{ 1528{
1529 1529
1530 if ( list.count() != 0 ) { 1530 if ( list.count() != 0 ) {
1531 KABC::Addressee::List::ConstIterator it; 1531 KABC::Addressee::List::ConstIterator it;
1532 for ( it = list.begin(); it != list.end(); ++it ) 1532 for ( it = list.begin(); it != list.end(); ++it )
1533 mAddressBook->insertAddressee( *it ); 1533 mAddressBook->insertAddressee( *it );
1534 if ( list.count() > 1 ) 1534 if ( list.count() > 1 )
1535 setModified(); 1535 setModified();
1536 else 1536 else
1537 setModifiedWOrefresh(); 1537 setModifiedWOrefresh();
1538 } 1538 }
1539 if ( list.count() == 0 ) 1539 if ( list.count() == 0 )
1540 mViewManager->refreshView(); 1540 mViewManager->refreshView();
1541 else 1541 else
1542 mViewManager->refreshView( list[ 0 ].uid() ); 1542 mViewManager->refreshView( list[ 0 ].uid() );
1543 1543
1544 1544
1545 1545
1546} 1546}
1547 1547
1548QString KABCore::getNameByPhone( const QString &phone ) 1548QString KABCore::getNameByPhone( const QString &phone )
1549{ 1549{
1550#ifndef KAB_EMBEDDED 1550#ifndef KAB_EMBEDDED
1551 QRegExp r( "[/*/-/ ]" ); 1551 QRegExp r( "[/*/-/ ]" );
1552 QString localPhone( phone ); 1552 QString localPhone( phone );
1553 1553
1554 bool found = false; 1554 bool found = false;
1555 QString ownerName = ""; 1555 QString ownerName = "";
1556 KABC::AddressBook::Iterator iter; 1556 KABC::AddressBook::Iterator iter;
1557 KABC::PhoneNumber::List::Iterator phoneIter; 1557 KABC::PhoneNumber::List::Iterator phoneIter;
1558 KABC::PhoneNumber::List phoneList; 1558 KABC::PhoneNumber::List phoneList;
1559 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1559 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1560 phoneList = (*iter).phoneNumbers(); 1560 phoneList = (*iter).phoneNumbers();
1561 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1561 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1562 ++phoneIter) { 1562 ++phoneIter) {
1563 // Get rid of separator chars so just the numbers are compared. 1563 // Get rid of separator chars so just the numbers are compared.
1564 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1564 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1565 ownerName = (*iter).formattedName(); 1565 ownerName = (*iter).formattedName();
1566 found = true; 1566 found = true;
1567 } 1567 }
1568 } 1568 }
1569 } 1569 }
1570 1570
1571 return ownerName; 1571 return ownerName;
1572#else //KAB_EMBEDDED 1572#else //KAB_EMBEDDED
1573 qDebug("KABCore::getNameByPhone finsih method"); 1573 qDebug("KABCore::getNameByPhone finsih method");
1574 return ""; 1574 return "";
1575#endif //KAB_EMBEDDED 1575#endif //KAB_EMBEDDED
1576 1576
1577} 1577}
1578 1578
1579void KABCore::openConfigDialog() 1579void KABCore::openConfigDialog()
1580{ 1580{
1581 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1581 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1582 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1582 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1583 ConfigureDialog->addModule(kabcfg ); 1583 ConfigureDialog->addModule(kabcfg );
1584 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1584 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1585 ConfigureDialog->addModule(kdelibcfg ); 1585 ConfigureDialog->addModule(kdelibcfg );
1586 1586
1587 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1587 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1588 this, SLOT( configurationChanged() ) ); 1588 this, SLOT( configurationChanged() ) );
1589 connect( ConfigureDialog, SIGNAL( okClicked() ), 1589 connect( ConfigureDialog, SIGNAL( okClicked() ),
1590 this, SLOT( configurationChanged() ) ); 1590 this, SLOT( configurationChanged() ) );
1591 saveSettings(); 1591 saveSettings();
1592#ifndef DESKTOP_VERSION 1592#ifndef DESKTOP_VERSION
1593 ConfigureDialog->showMaximized(); 1593 ConfigureDialog->showMaximized();
1594#endif 1594#endif
1595 if ( ConfigureDialog->exec() ) 1595 if ( ConfigureDialog->exec() )
1596 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1596 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1597 delete ConfigureDialog; 1597 delete ConfigureDialog;
1598} 1598}
1599 1599
1600void KABCore::openLDAPDialog() 1600void KABCore::openLDAPDialog()
1601{ 1601{
1602#ifndef KAB_EMBEDDED 1602#ifndef KAB_EMBEDDED
1603 if ( !mLdapSearchDialog ) { 1603 if ( !mLdapSearchDialog ) {
1604 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1604 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1605 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1605 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1606 SLOT( refreshView() ) ); 1606 SLOT( refreshView() ) );
1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1608 SLOT( setModified() ) ); 1608 SLOT( setModified() ) );
1609 } else 1609 } else
1610 mLdapSearchDialog->restoreSettings(); 1610 mLdapSearchDialog->restoreSettings();
1611 1611
1612 if ( mLdapSearchDialog->isOK() ) 1612 if ( mLdapSearchDialog->isOK() )
1613 mLdapSearchDialog->exec(); 1613 mLdapSearchDialog->exec();
1614#else //KAB_EMBEDDED 1614#else //KAB_EMBEDDED
1615 qDebug("KABCore::openLDAPDialog() finsih method"); 1615 qDebug("KABCore::openLDAPDialog() finsih method");
1616#endif //KAB_EMBEDDED 1616#endif //KAB_EMBEDDED
1617} 1617}
1618 1618
1619void KABCore::print() 1619void KABCore::print()
1620{ 1620{
1621#ifndef KAB_EMBEDDED 1621#ifndef KAB_EMBEDDED
1622 KPrinter printer; 1622 KPrinter printer;
1623 if ( !printer.setup( this ) ) 1623 if ( !printer.setup( this ) )
1624 return; 1624 return;
1625 1625
1626 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1626 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1627 mViewManager->selectedUids(), this ); 1627 mViewManager->selectedUids(), this );
1628 1628
1629 wizard.exec(); 1629 wizard.exec();
1630#else //KAB_EMBEDDED 1630#else //KAB_EMBEDDED
1631 qDebug("KABCore::print() finsih method"); 1631 qDebug("KABCore::print() finsih method");
1632#endif //KAB_EMBEDDED 1632#endif //KAB_EMBEDDED
1633 1633
1634} 1634}
1635 1635
1636 1636
1637void KABCore::addGUIClient( KXMLGUIClient *client ) 1637void KABCore::addGUIClient( KXMLGUIClient *client )
1638{ 1638{
1639 if ( mGUIClient ) 1639 if ( mGUIClient )
1640 mGUIClient->insertChildClient( client ); 1640 mGUIClient->insertChildClient( client );
1641 else 1641 else
1642 KMessageBox::error( this, "no KXMLGUICLient"); 1642 KMessageBox::error( this, "no KXMLGUICLient");
1643} 1643}
1644 1644
1645 1645
1646void KABCore::configurationChanged() 1646void KABCore::configurationChanged()
1647{ 1647{
1648 mExtensionManager->reconfigure(); 1648 mExtensionManager->reconfigure();
1649} 1649}
1650 1650
1651void KABCore::addressBookChanged() 1651void KABCore::addressBookChanged()
1652{ 1652{
1653/*US 1653/*US
1654 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1654 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1655 while ( it.current() ) { 1655 while ( it.current() ) {
1656 if ( it.current()->dirty() ) { 1656 if ( it.current()->dirty() ) {
1657 QString text = i18n( "Data has been changed externally. Unsaved " 1657 QString text = i18n( "Data has been changed externally. Unsaved "
1658 "changes will be lost." ); 1658 "changes will be lost." );
1659 KMessageBox::information( this, text ); 1659 KMessageBox::information( this, text );
1660 } 1660 }
1661 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1661 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1662 ++it; 1662 ++it;
1663 } 1663 }
1664*/ 1664*/
1665 if (mEditorDialog) 1665 if (mEditorDialog)
1666 { 1666 {
1667 if (mEditorDialog->dirty()) 1667 if (mEditorDialog->dirty())
1668 { 1668 {
1669 QString text = i18n( "Data has been changed externally. Unsaved " 1669 QString text = i18n( "Data has been changed externally. Unsaved "
1670 "changes will be lost." ); 1670 "changes will be lost." );
1671 KMessageBox::information( this, text ); 1671 KMessageBox::information( this, text );
1672 } 1672 }
1673 QString currentuid = mEditorDialog->addressee().uid(); 1673 QString currentuid = mEditorDialog->addressee().uid();
1674 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1674 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1675 } 1675 }
1676 mViewManager->refreshView(); 1676 mViewManager->refreshView();
1677 1677
1678 1678
1679} 1679}
1680 1680
1681AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1681AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1682 const char *name ) 1682 const char *name )
1683{ 1683{
1684 1684
1685 if ( mEditorDialog == 0 ) { 1685 if ( mEditorDialog == 0 ) {
1686 mEditorDialog = new AddresseeEditorDialog( this, parent, 1686 mEditorDialog = new AddresseeEditorDialog( this, parent,
1687 name ? name : "editorDialog" ); 1687 name ? name : "editorDialog" );
1688 1688
1689 1689
1690 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1690 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1691 SLOT( contactModified( const KABC::Addressee& ) ) ); 1691 SLOT( contactModified( const KABC::Addressee& ) ) );
1692 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1692 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1693 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1693 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1694 } 1694 }
1695 1695
1696 return mEditorDialog; 1696 return mEditorDialog;
1697} 1697}
1698 1698
1699void KABCore::slotEditorDestroyed( const QString &uid ) 1699void KABCore::slotEditorDestroyed( const QString &uid )
1700{ 1700{
1701 //mEditorDict.remove( uid ); 1701 //mEditorDict.remove( uid );
1702} 1702}
1703 1703
1704void KABCore::initGUI() 1704void KABCore::initGUI()
1705{ 1705{
1706#ifndef KAB_EMBEDDED 1706#ifndef KAB_EMBEDDED
1707 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1707 QHBoxLayout *topLayout = new QHBoxLayout( this );
1708 topLayout->setSpacing( KDialogBase::spacingHint() ); 1708 topLayout->setSpacing( KDialogBase::spacingHint() );
1709 1709
1710 mExtensionBarSplitter = new QSplitter( this ); 1710 mExtensionBarSplitter = new QSplitter( this );
1711 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1711 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1712 1712
1713 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1713 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1714 1714
1715 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1715 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1716 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1716 mIncSearchWidget = new IncSearchWidget( viewSpace );
1717 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1717 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1718 SLOT( incrementalSearch( const QString& ) ) ); 1718 SLOT( incrementalSearch( const QString& ) ) );
1719 1719
1720 mViewManager = new ViewManager( this, viewSpace ); 1720 mViewManager = new ViewManager( this, viewSpace );
1721 viewSpace->setStretchFactor( mViewManager, 1 ); 1721 viewSpace->setStretchFactor( mViewManager, 1 );
1722 1722
1723 mDetails = new ViewContainer( mDetailsSplitter ); 1723 mDetails = new ViewContainer( mDetailsSplitter );
1724 1724
1725 mJumpButtonBar = new JumpButtonBar( this, this ); 1725 mJumpButtonBar = new JumpButtonBar( this, this );
1726 1726
1727 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1727 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1728 1728
1729 topLayout->addWidget( mExtensionBarSplitter ); 1729 topLayout->addWidget( mExtensionBarSplitter );
1730 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1730 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1731 topLayout->addWidget( mJumpButtonBar ); 1731 topLayout->addWidget( mJumpButtonBar );
1732 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1732 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1733 1733
1734 mXXPortManager = new XXPortManager( this, this ); 1734 mXXPortManager = new XXPortManager( this, this );
1735 1735
1736#else //KAB_EMBEDDED 1736#else //KAB_EMBEDDED
1737 //US initialize viewMenu before settingup viewmanager. 1737 //US initialize viewMenu before settingup viewmanager.
1738 // Viewmanager needs this menu to plugin submenues. 1738 // Viewmanager needs this menu to plugin submenues.
1739 viewMenu = new QPopupMenu( this ); 1739 viewMenu = new QPopupMenu( this );
1740 settingsMenu = new QPopupMenu( this ); 1740 settingsMenu = new QPopupMenu( this );
1741 //filterMenu = new QPopupMenu( this ); 1741 //filterMenu = new QPopupMenu( this );
1742 ImportMenu = new QPopupMenu( this ); 1742 ImportMenu = new QPopupMenu( this );
1743 ExportMenu = new QPopupMenu( this ); 1743 ExportMenu = new QPopupMenu( this );
1744 syncMenu = new QPopupMenu( this ); 1744 syncMenu = new QPopupMenu( this );
1745 changeMenu= new QPopupMenu( this ); 1745 changeMenu= new QPopupMenu( this );
1746 beamMenu= new QPopupMenu( this ); 1746 beamMenu= new QPopupMenu( this );
1747 1747
1748//US since we have no splitter for the embedded system, setup 1748//US since we have no splitter for the embedded system, setup
1749// a layout with two frames. One left and one right. 1749// a layout with two frames. One left and one right.
1750 1750
1751 QBoxLayout *topLayout; 1751 QBoxLayout *topLayout;
1752 1752
1753 // = new QHBoxLayout( this ); 1753 // = new QHBoxLayout( this );
1754// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1754// QBoxLayout *topLayout = (QBoxLayout*)layout();
1755 1755
1756// QWidget *mainBox = new QWidget( this ); 1756// QWidget *mainBox = new QWidget( this );
1757// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1757// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1758 1758
1759#ifdef DESKTOP_VERSION 1759#ifdef DESKTOP_VERSION
1760 topLayout = new QHBoxLayout( this ); 1760 topLayout = new QHBoxLayout( this );
1761 1761
1762 1762
1763 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1763 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1764 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1764 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1765 1765
1766 topLayout->addWidget(mMiniSplitter ); 1766 topLayout->addWidget(mMiniSplitter );
1767 1767
1768 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1768 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1769 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1769 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1770 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1770 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1771 mDetails = new ViewContainer( mMiniSplitter ); 1771 mDetails = new ViewContainer( mMiniSplitter );
1772 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1772 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1773#else 1773#else
1774 if ( QApplication::desktop()->width() > 480 ) { 1774 if ( QApplication::desktop()->width() > 480 ) {
1775 topLayout = new QHBoxLayout( this ); 1775 topLayout = new QHBoxLayout( this );
1776 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1776 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1777 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1777 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1778 } else { 1778 } else {
1779 1779
1780 topLayout = new QHBoxLayout( this ); 1780 topLayout = new QHBoxLayout( this );
1781 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1781 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1782 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1782 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1783 } 1783 }
1784 1784
1785 topLayout->addWidget(mMiniSplitter ); 1785 topLayout->addWidget(mMiniSplitter );
1786 mViewManager = new ViewManager( this, mMiniSplitter ); 1786 mViewManager = new ViewManager( this, mMiniSplitter );
1787 mDetails = new ViewContainer( mMiniSplitter ); 1787 mDetails = new ViewContainer( mMiniSplitter );
1788 1788
1789 1789
1790 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1790 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1791#endif 1791#endif
1792 //eh->hide(); 1792 //eh->hide();
1793 // topLayout->addWidget(mExtensionManager ); 1793 // topLayout->addWidget(mExtensionManager );
1794 1794
1795 1795
1796/*US 1796/*US
1797#ifndef KAB_NOSPLITTER 1797#ifndef KAB_NOSPLITTER
1798 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1798 QHBoxLayout *topLayout = new QHBoxLayout( this );
1799//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1799//US topLayout->setSpacing( KDialogBase::spacingHint() );
1800 topLayout->setSpacing( 10 ); 1800 topLayout->setSpacing( 10 );
1801 1801
1802 mDetailsSplitter = new QSplitter( this ); 1802 mDetailsSplitter = new QSplitter( this );
1803 1803
1804 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1804 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1805 1805
1806 mViewManager = new ViewManager( this, viewSpace ); 1806 mViewManager = new ViewManager( this, viewSpace );
1807 viewSpace->setStretchFactor( mViewManager, 1 ); 1807 viewSpace->setStretchFactor( mViewManager, 1 );
1808 1808
1809 mDetails = new ViewContainer( mDetailsSplitter ); 1809 mDetails = new ViewContainer( mDetailsSplitter );
1810 1810
1811 topLayout->addWidget( mDetailsSplitter ); 1811 topLayout->addWidget( mDetailsSplitter );
1812 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1812 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1813#else //KAB_NOSPLITTER 1813#else //KAB_NOSPLITTER
1814 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1814 QHBoxLayout *topLayout = new QHBoxLayout( this );
1815//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1815//US topLayout->setSpacing( KDialogBase::spacingHint() );
1816 topLayout->setSpacing( 10 ); 1816 topLayout->setSpacing( 10 );
1817 1817
1818// mDetailsSplitter = new QSplitter( this ); 1818// mDetailsSplitter = new QSplitter( this );
1819 1819
1820 QVBox *viewSpace = new QVBox( this ); 1820 QVBox *viewSpace = new QVBox( this );
1821 1821
1822 mViewManager = new ViewManager( this, viewSpace ); 1822 mViewManager = new ViewManager( this, viewSpace );
1823 viewSpace->setStretchFactor( mViewManager, 1 ); 1823 viewSpace->setStretchFactor( mViewManager, 1 );
1824 1824
1825 mDetails = new ViewContainer( this ); 1825 mDetails = new ViewContainer( this );
1826 1826
1827 topLayout->addWidget( viewSpace ); 1827 topLayout->addWidget( viewSpace );
1828// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1828// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1829 topLayout->addWidget( mDetails ); 1829 topLayout->addWidget( mDetails );
1830#endif //KAB_NOSPLITTER 1830#endif //KAB_NOSPLITTER
1831*/ 1831*/
1832 1832
1833 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1833 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1834 syncManager->setBlockSave(false); 1834 syncManager->setBlockSave(false);
1835 1835
1836 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1836 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1837 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1837 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1838 QString sync_file = sentSyncFile(); 1838 QString sync_file = sentSyncFile();
1839 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1839 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1840 syncManager->setDefaultFileName( sync_file ); 1840 syncManager->setDefaultFileName( sync_file );
1841 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1841 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1842 1842
1843#endif //KAB_EMBEDDED 1843#endif //KAB_EMBEDDED
1844 initActions(); 1844 initActions();
1845 1845
1846#ifdef KAB_EMBEDDED 1846#ifdef KAB_EMBEDDED
1847 addActionsManually(); 1847 addActionsManually();
1848 //US make sure the export and import menues are initialized before creating the xxPortManager. 1848 //US make sure the export and import menues are initialized before creating the xxPortManager.
1849 mXXPortManager = new XXPortManager( this, this ); 1849 mXXPortManager = new XXPortManager( this, this );
1850 1850
1851 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1851 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1852 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1852 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1853 // mActionQuit->plug ( mMainWindow->toolBar()); 1853 // mActionQuit->plug ( mMainWindow->toolBar());
1854 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1854 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1855 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1855 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1856 // mIncSearchWidget->hide(); 1856 // mIncSearchWidget->hide();
1857 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1857 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1858 SLOT( incrementalSearch( const QString& ) ) ); 1858 SLOT( incrementalSearch( const QString& ) ) );
1859 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1859 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1860 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1860 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1861 1861
1862 mJumpButtonBar = new JumpButtonBar( this, this ); 1862 mJumpButtonBar = new JumpButtonBar( this, this );
1863 1863
1864 topLayout->addWidget( mJumpButtonBar ); 1864 topLayout->addWidget( mJumpButtonBar );
1865//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1865//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1866 1866
1867// mMainWindow->getIconToolBar()->raise(); 1867// mMainWindow->getIconToolBar()->raise();
1868 1868
1869#endif //KAB_EMBEDDED 1869#endif //KAB_EMBEDDED
1870 1870
1871} 1871}
1872void KABCore::initActions() 1872void KABCore::initActions()
1873{ 1873{
1874//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1874//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1875 1875
1876#ifndef KAB_EMBEDDED 1876#ifndef KAB_EMBEDDED
1877 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1877 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1878 SLOT( clipboardDataChanged() ) ); 1878 SLOT( clipboardDataChanged() ) );
1879#endif //KAB_EMBEDDED 1879#endif //KAB_EMBEDDED
1880 1880
1881 // file menu 1881 // file menu
1882 1882
1883 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1883 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1884 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1884 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1885 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1885 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1886 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1886 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1887 1887
1888 1888
1889 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1889 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1890 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1890 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1891 1891
1892 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1892 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1893 SLOT( save() ), actionCollection(), "file_sync" ); 1893 SLOT( save() ), actionCollection(), "file_sync" );
1894 1894
1895 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1895 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1896 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1896 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1897 1897
1898 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1898 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1899 this, SLOT( mailVCard() ), 1899 this, SLOT( mailVCard() ),
1900 actionCollection(), "file_mail_vcard"); 1900 actionCollection(), "file_mail_vcard");
1901 1901
1902 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1902 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1903 SLOT( export2phone() ), actionCollection(), 1903 SLOT( export2phone() ), actionCollection(),
1904 "kaddressbook_ex2phone" ); 1904 "kaddressbook_ex2phone" );
1905 1905
1906 mActionBeamVCard = 0; 1906 mActionBeamVCard = 0;
1907 mActionBeam = 0; 1907 mActionBeam = 0;
1908 1908
1909#ifndef DESKTOP_VERSION 1909#ifndef DESKTOP_VERSION
1910 if ( Ir::supported() ) { 1910 if ( Ir::supported() ) {
1911 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1911 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1912 SLOT( beamVCard() ), actionCollection(), 1912 SLOT( beamVCard() ), actionCollection(),
1913 "kaddressbook_beam_vcard" ); 1913 "kaddressbook_beam_vcard" );
1914 1914
1915 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1915 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1916 SLOT( beamMySelf() ), actionCollection(), 1916 SLOT( beamMySelf() ), actionCollection(),
1917 "kaddressbook_beam_myself" ); 1917 "kaddressbook_beam_myself" );
1918 } 1918 }
1919#endif 1919#endif
1920 1920
1921 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1921 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1922 this, SLOT( editContact2() ), 1922 this, SLOT( editContact2() ),
1923 actionCollection(), "file_properties" ); 1923 actionCollection(), "file_properties" );
1924 1924
1925#ifdef KAB_EMBEDDED 1925#ifdef KAB_EMBEDDED
1926 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1926 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1927 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1927 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1928 mMainWindow, SLOT( exit() ), 1928 mMainWindow, SLOT( exit() ),
1929 actionCollection(), "quit" ); 1929 actionCollection(), "quit" );
1930#endif //KAB_EMBEDDED 1930#endif //KAB_EMBEDDED
1931 1931
1932 // edit menu 1932 // edit menu
1933 if ( mIsPart ) { 1933 if ( mIsPart ) {
1934 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1934 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1935 SLOT( copyContacts() ), actionCollection(), 1935 SLOT( copyContacts() ), actionCollection(),
1936 "kaddressbook_copy" ); 1936 "kaddressbook_copy" );
1937 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1937 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1938 SLOT( cutContacts() ), actionCollection(), 1938 SLOT( cutContacts() ), actionCollection(),
1939 "kaddressbook_cut" ); 1939 "kaddressbook_cut" );
1940 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1940 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1941 SLOT( pasteContacts() ), actionCollection(), 1941 SLOT( pasteContacts() ), actionCollection(),
1942 "kaddressbook_paste" ); 1942 "kaddressbook_paste" );
1943 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1943 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1944 SLOT( selectAllContacts() ), actionCollection(), 1944 SLOT( selectAllContacts() ), actionCollection(),
1945 "kaddressbook_select_all" ); 1945 "kaddressbook_select_all" );
1946 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1946 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1947 SLOT( undo() ), actionCollection(), 1947 SLOT( undo() ), actionCollection(),
1948 "kaddressbook_undo" ); 1948 "kaddressbook_undo" );
1949 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1949 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1950 this, SLOT( redo() ), actionCollection(), 1950 this, SLOT( redo() ), actionCollection(),
1951 "kaddressbook_redo" ); 1951 "kaddressbook_redo" );
1952 } else { 1952 } else {
1953 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1953 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1954 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1954 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1955 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1955 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1956 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1956 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1957 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1957 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1958 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1958 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1959 } 1959 }
1960 1960
1961 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1961 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1962 Key_Delete, this, SLOT( deleteContacts() ), 1962 Key_Delete, this, SLOT( deleteContacts() ),
1963 actionCollection(), "edit_delete" ); 1963 actionCollection(), "edit_delete" );
1964 1964
1965 mActionUndo->setEnabled( false ); 1965 mActionUndo->setEnabled( false );
1966 mActionRedo->setEnabled( false ); 1966 mActionRedo->setEnabled( false );
1967 1967
1968 // settings menu 1968 // settings menu
1969#ifdef KAB_EMBEDDED 1969#ifdef KAB_EMBEDDED
1970//US special menuentry to configure the addressbook resources. On KDE 1970//US special menuentry to configure the addressbook resources. On KDE
1971// you do that through the control center !!! 1971// you do that through the control center !!!
1972 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1972 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1973 SLOT( configureResources() ), actionCollection(), 1973 SLOT( configureResources() ), actionCollection(),
1974 "kaddressbook_configure_resources" ); 1974 "kaddressbook_configure_resources" );
1975#endif //KAB_EMBEDDED 1975#endif //KAB_EMBEDDED
1976 1976
1977 if ( mIsPart ) { 1977 if ( mIsPart ) {
1978 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1978 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1979 SLOT( openConfigDialog() ), actionCollection(), 1979 SLOT( openConfigDialog() ), actionCollection(),
1980 "kaddressbook_configure" ); 1980 "kaddressbook_configure" );
1981 1981
1982 //US not implemented yet 1982 //US not implemented yet
1983 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1983 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1984 // this, SLOT( configureKeyBindings() ), actionCollection(), 1984 // this, SLOT( configureKeyBindings() ), actionCollection(),
1985 // "kaddressbook_configure_shortcuts" ); 1985 // "kaddressbook_configure_shortcuts" );
1986#ifdef KAB_EMBEDDED 1986#ifdef KAB_EMBEDDED
1987 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1987 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1988 mActionConfigureToolbars->setEnabled( false ); 1988 mActionConfigureToolbars->setEnabled( false );
1989#endif //KAB_EMBEDDED 1989#endif //KAB_EMBEDDED
1990 1990
1991 } else { 1991 } else {
1992 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1992 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1993 1993
1994 //US not implemented yet 1994 //US not implemented yet
1995 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1995 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1996 } 1996 }
1997 1997
1998 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1998 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1999 actionCollection(), "options_show_jump_bar" ); 1999 actionCollection(), "options_show_jump_bar" );
2000 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2000 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
2001 2001
2002 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2002 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2003 actionCollection(), "options_show_details" ); 2003 actionCollection(), "options_show_details" );
2004 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2004 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2005 2005
2006 2006
2007 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2007 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2008 SLOT( toggleBeamReceive() ), actionCollection(), 2008 SLOT( toggleBeamReceive() ), actionCollection(),
2009 "kaddressbook_beam_rec" ); 2009 "kaddressbook_beam_rec" );
2010 2010
2011 2011
2012 // misc 2012 // misc
2013 // only enable LDAP lookup if we can handle the protocol 2013 // only enable LDAP lookup if we can handle the protocol
2014#ifndef KAB_EMBEDDED 2014#ifndef KAB_EMBEDDED
2015 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2015 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2016 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2016 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2017 this, SLOT( openLDAPDialog() ), actionCollection(), 2017 this, SLOT( openLDAPDialog() ), actionCollection(),
2018 "ldap_lookup" ); 2018 "ldap_lookup" );
2019 } 2019 }
2020#else //KAB_EMBEDDED 2020#else //KAB_EMBEDDED
2021 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2021 //qDebug("KABCore::initActions() LDAP has to be implemented");
2022#endif //KAB_EMBEDDED 2022#endif //KAB_EMBEDDED
2023 2023
2024 2024
2025 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2025 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2026 SLOT( setWhoAmI() ), actionCollection(), 2026 SLOT( setWhoAmI() ), actionCollection(),
2027 "set_personal" ); 2027 "set_personal" );
2028 2028
2029 2029
2030 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2030 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
2031 SLOT( setCategories() ), actionCollection(), 2031 SLOT( setCategories() ), actionCollection(),
2032 "edit_set_categories" ); 2032 "edit_set_categories" );
2033 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2033 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
2034 SLOT( editCategories() ), actionCollection(), 2034 SLOT( editCategories() ), actionCollection(),
2035 "edit__categories" ); 2035 "edit__categories" );
2036 2036
2037 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2037 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2038 SLOT( removeVoice() ), actionCollection(), 2038 SLOT( removeVoice() ), actionCollection(),
2039 "remove_voice" ); 2039 "remove_voice" );
2040 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2040 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2041 SLOT( setFormattedName() ), actionCollection(), 2041 SLOT( setFormattedName() ), actionCollection(),
2042 "set_formatted" ); 2042 "set_formatted" );
2043 2043
2044 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2044 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2045 SLOT( manageCategories() ), actionCollection(), 2045 SLOT( manageCategories() ), actionCollection(),
2046 "remove_voice" ); 2046 "remove_voice" );
2047 2047
2048 2048
2049 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2049 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2050 SLOT( importFromOL() ), actionCollection(), 2050 SLOT( importFromOL() ), actionCollection(),
2051 "import_OL" ); 2051 "import_OL" );
2052#ifdef KAB_EMBEDDED 2052#ifdef KAB_EMBEDDED
2053 mActionLicence = new KAction( i18n( "Licence" ), 0, 2053 mActionLicence = new KAction( i18n( "Licence" ), 0,
2054 this, SLOT( showLicence() ), actionCollection(), 2054 this, SLOT( showLicence() ), actionCollection(),
2055 "licence_about_data" ); 2055 "licence_about_data" );
2056 mActionFaq = new KAction( i18n( "Faq" ), 0, 2056 mActionFaq = new KAction( i18n( "Faq" ), 0,
2057 this, SLOT( faq() ), actionCollection(), 2057 this, SLOT( faq() ), actionCollection(),
2058 "faq_about_data" ); 2058 "faq_about_data" );
2059 mActionWN = new KAction( i18n( "What's New?" ), 0, 2059 mActionWN = new KAction( i18n( "What's New?" ), 0,
2060 this, SLOT( whatsnew() ), actionCollection(), 2060 this, SLOT( whatsnew() ), actionCollection(),
2061 "wn" ); 2061 "wn" );
2062 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2062 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2063 this, SLOT( synchowto() ), actionCollection(), 2063 this, SLOT( synchowto() ), actionCollection(),
2064 "sync" ); 2064 "sync" );
2065 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2065 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2066 this, SLOT( kdesynchowto() ), actionCollection(), 2066 this, SLOT( kdesynchowto() ), actionCollection(),
2067 "kdesync" ); 2067 "kdesync" );
2068 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2068 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2069 this, SLOT( multisynchowto() ), actionCollection(), 2069 this, SLOT( multisynchowto() ), actionCollection(),
2070 "multisync" ); 2070 "multisync" );
2071 2071
2072 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2072 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2073 this, SLOT( createAboutData() ), actionCollection(), 2073 this, SLOT( createAboutData() ), actionCollection(),
2074 "kaddressbook_about_data" ); 2074 "kaddressbook_about_data" );
2075#endif //KAB_EMBEDDED 2075#endif //KAB_EMBEDDED
2076 2076
2077 clipboardDataChanged(); 2077 clipboardDataChanged();
2078 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2078 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2079 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2079 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2080} 2080}
2081 2081
2082//US we need this function, to plug all actions into the correct menues. 2082//US we need this function, to plug all actions into the correct menues.
2083// KDE uses a XML format to plug the actions, but we work her without this overhead. 2083// KDE uses a XML format to plug the actions, but we work her without this overhead.
2084void KABCore::addActionsManually() 2084void KABCore::addActionsManually()
2085{ 2085{
2086//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2086//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2087 2087
2088#ifdef KAB_EMBEDDED 2088#ifdef KAB_EMBEDDED
2089 QPopupMenu *fileMenu = new QPopupMenu( this ); 2089 QPopupMenu *fileMenu = new QPopupMenu( this );
2090 QPopupMenu *editMenu = new QPopupMenu( this ); 2090 QPopupMenu *editMenu = new QPopupMenu( this );
2091 QPopupMenu *helpMenu = new QPopupMenu( this ); 2091 QPopupMenu *helpMenu = new QPopupMenu( this );
2092 2092
2093 KToolBar* tb = mMainWindow->toolBar(); 2093 KToolBar* tb = mMainWindow->toolBar();
2094 2094
2095#ifndef DESKTOP_VERSION 2095#ifndef DESKTOP_VERSION
2096 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2096 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2097#endif 2097#endif
2098 QMenuBar* mb = mMainWindow->menuBar(); 2098 QMenuBar* mb = mMainWindow->menuBar();
2099 2099
2100 //US setup menubar. 2100 //US setup menubar.
2101 //Disable the following block if you do not want to have a menubar. 2101 //Disable the following block if you do not want to have a menubar.
2102 mb->insertItem( i18n("&File"), fileMenu ); 2102 mb->insertItem( i18n("&File"), fileMenu );
2103 mb->insertItem( i18n("&Edit"), editMenu ); 2103 mb->insertItem( i18n("&Edit"), editMenu );
2104 mb->insertItem( i18n("&View"), viewMenu ); 2104 mb->insertItem( i18n("&View"), viewMenu );
2105 mb->insertItem( i18n("&Settings"), settingsMenu ); 2105 mb->insertItem( i18n("&Settings"), settingsMenu );
2106 mb->insertItem( i18n("Synchronize"), syncMenu ); 2106 mb->insertItem( i18n("Synchronize"), syncMenu );
2107 //mb->insertItem( i18n("&Change"), changeMenu ); 2107 //mb->insertItem( i18n("&Change"), changeMenu );
2108 mb->insertItem( i18n("&Help"), helpMenu ); 2108 mb->insertItem( i18n("&Help"), helpMenu );
2109 mIncSearchWidget = new IncSearchWidget( tb ); 2109 mIncSearchWidget = new IncSearchWidget( tb );
2110 // tb->insertWidget(-1, 0, mIncSearchWidget); 2110 // tb->insertWidget(-1, 0, mIncSearchWidget);
2111#ifndef DESKTOP_VERSION 2111#ifndef DESKTOP_VERSION
2112 } else { 2112 } else {
2113 //US setup toolbar 2113 //US setup toolbar
2114 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2114 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2115 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2115 QPopupMenu *popupBarTB = new QPopupMenu( this );
2116 menuBarTB->insertItem( "ME", popupBarTB); 2116 menuBarTB->insertItem( "ME", popupBarTB);
2117 tb->insertWidget(-1, 0, menuBarTB); 2117 tb->insertWidget(-1, 0, menuBarTB);
2118 mIncSearchWidget = new IncSearchWidget( tb ); 2118 mIncSearchWidget = new IncSearchWidget( tb );
2119 2119
2120 tb->enableMoving(false); 2120 tb->enableMoving(false);
2121 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2121 popupBarTB->insertItem( i18n("&File"), fileMenu );
2122 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2122 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2123 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2123 popupBarTB->insertItem( i18n("&View"), viewMenu );
2124 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2124 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2125 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2125 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2126 mViewManager->getFilterAction()->plug ( popupBarTB); 2126 mViewManager->getFilterAction()->plug ( popupBarTB);
2127 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2127 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2128 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2128 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2129 if (QApplication::desktop()->width() > 320 ) { 2129 if (QApplication::desktop()->width() > 320 ) {
2130 // mViewManager->getFilterAction()->plug ( tb); 2130 // mViewManager->getFilterAction()->plug ( tb);
2131 } 2131 }
2132 } 2132 }
2133#endif 2133#endif
2134 // mActionQuit->plug ( mMainWindow->toolBar()); 2134 // mActionQuit->plug ( mMainWindow->toolBar());
2135 2135
2136 2136
2137 2137
2138 //US Now connect the actions with the menue entries. 2138 //US Now connect the actions with the menue entries.
2139#ifdef DESKTOP_VERSION 2139#ifdef DESKTOP_VERSION
2140 mActionPrint->plug( fileMenu ); 2140 mActionPrint->plug( fileMenu );
2141 mActionPrintDetails->plug( fileMenu ); 2141 mActionPrintDetails->plug( fileMenu );
2142 fileMenu->insertSeparator(); 2142 fileMenu->insertSeparator();
2143#endif 2143#endif
2144 mActionMail->plug( fileMenu ); 2144 mActionMail->plug( fileMenu );
2145 fileMenu->insertSeparator(); 2145 fileMenu->insertSeparator();
2146 2146
2147 mActionNewContact->plug( fileMenu ); 2147 mActionNewContact->plug( fileMenu );
2148 mActionNewContact->plug( tb ); 2148 mActionNewContact->plug( tb );
2149 2149
2150 mActionEditAddressee->plug( fileMenu ); 2150 mActionEditAddressee->plug( fileMenu );
2151 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2151 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2152 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2152 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2153 mActionEditAddressee->plug( tb ); 2153 mActionEditAddressee->plug( tb );
2154 2154
2155 fileMenu->insertSeparator(); 2155 fileMenu->insertSeparator();
2156 mActionSave->plug( fileMenu ); 2156 mActionSave->plug( fileMenu );
2157 fileMenu->insertItem( "&Import", ImportMenu ); 2157 fileMenu->insertItem( "&Import", ImportMenu );
2158 fileMenu->insertItem( "&Export", ExportMenu ); 2158 fileMenu->insertItem( "&Export", ExportMenu );
2159 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2159 fileMenu->insertItem( i18n("&Change"), changeMenu );
2160#ifndef DESKTOP_VERSION 2160#ifndef DESKTOP_VERSION
2161 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2161 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2162#endif 2162#endif
2163#if 0 2163#if 0
2164 // PENDING fix MailVCard 2164 // PENDING fix MailVCard
2165 fileMenu->insertSeparator(); 2165 fileMenu->insertSeparator();
2166 mActionMailVCard->plug( fileMenu ); 2166 mActionMailVCard->plug( fileMenu );
2167#endif 2167#endif
2168#ifndef DESKTOP_VERSION 2168#ifndef DESKTOP_VERSION
2169 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2169 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2170 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2170 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2171 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2171 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2172#endif 2172#endif
2173 fileMenu->insertSeparator(); 2173 fileMenu->insertSeparator();
2174 mActionQuit->plug( fileMenu ); 2174 mActionQuit->plug( fileMenu );
2175#ifdef _WIN32_ 2175#ifdef _WIN32_
2176 mActionImportOL->plug( ImportMenu ); 2176 mActionImportOL->plug( ImportMenu );
2177#endif 2177#endif
2178 // edit menu 2178 // edit menu
2179 mActionUndo->plug( editMenu ); 2179 mActionUndo->plug( editMenu );
2180 mActionRedo->plug( editMenu ); 2180 mActionRedo->plug( editMenu );
2181 editMenu->insertSeparator(); 2181 editMenu->insertSeparator();
2182 mActionCut->plug( editMenu ); 2182 mActionCut->plug( editMenu );
2183 mActionCopy->plug( editMenu ); 2183 mActionCopy->plug( editMenu );
2184 mActionPaste->plug( editMenu ); 2184 mActionPaste->plug( editMenu );
2185 mActionDelete->plug( editMenu ); 2185 mActionDelete->plug( editMenu );
2186 editMenu->insertSeparator(); 2186 editMenu->insertSeparator();
2187 mActionSelectAll->plug( editMenu ); 2187 mActionSelectAll->plug( editMenu );
2188 2188
2189 mActionSetFormattedName->plug( changeMenu ); 2189 mActionSetFormattedName->plug( changeMenu );
2190 mActionRemoveVoice->plug( changeMenu ); 2190 mActionRemoveVoice->plug( changeMenu );
2191 // settings menu 2191 // settings menu
2192//US special menuentry to configure the addressbook resources. On KDE 2192//US special menuentry to configure the addressbook resources. On KDE
2193// you do that through the control center !!! 2193// you do that through the control center !!!
2194 mActionConfigResources->plug( settingsMenu ); 2194 mActionConfigResources->plug( settingsMenu );
2195 settingsMenu->insertSeparator(); 2195 settingsMenu->insertSeparator();
2196 2196
2197 mActionConfigKAddressbook->plug( settingsMenu ); 2197 mActionConfigKAddressbook->plug( settingsMenu );
2198 2198
2199 if ( mIsPart ) { 2199 if ( mIsPart ) {
2200 //US not implemented yet 2200 //US not implemented yet
2201 //mActionConfigShortcuts->plug( settingsMenu ); 2201 //mActionConfigShortcuts->plug( settingsMenu );
2202 //mActionConfigureToolbars->plug( settingsMenu ); 2202 //mActionConfigureToolbars->plug( settingsMenu );
2203 2203
2204 } else { 2204 } else {
2205 //US not implemented yet 2205 //US not implemented yet
2206 //mActionKeyBindings->plug( settingsMenu ); 2206 //mActionKeyBindings->plug( settingsMenu );
2207 } 2207 }
2208 2208
2209 settingsMenu->insertSeparator(); 2209 settingsMenu->insertSeparator();
2210 2210
2211 mActionJumpBar->plug( settingsMenu ); 2211 mActionJumpBar->plug( settingsMenu );
2212 mActionDetails->plug( settingsMenu ); 2212 mActionDetails->plug( settingsMenu );
2213 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2213 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2214 mActionDetails->plug( tb ); 2214 mActionDetails->plug( tb );
2215 settingsMenu->insertSeparator(); 2215 settingsMenu->insertSeparator();
2216#ifndef DESKTOP_VERSION 2216#ifndef DESKTOP_VERSION
2217 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2217 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2218#endif 2218#endif
2219 settingsMenu->insertSeparator(); 2219 settingsMenu->insertSeparator();
2220 2220
2221 mActionWhoAmI->plug( settingsMenu ); 2221 mActionWhoAmI->plug( settingsMenu );
2222 mActionEditCategories->plug( settingsMenu ); 2222 mActionEditCategories->plug( settingsMenu );
2223 mActionEditCategories->plug( changeMenu ); 2223 mActionEditCategories->plug( changeMenu );
2224 mActionCategories->plug( changeMenu ); 2224 mActionCategories->plug( changeMenu );
2225 mActionManageCategories->plug( changeMenu ); 2225 mActionManageCategories->plug( changeMenu );
2226 2226
2227 mActionCategories->plug( settingsMenu ); 2227 mActionCategories->plug( settingsMenu );
2228 mActionManageCategories->plug( settingsMenu ); 2228 mActionManageCategories->plug( settingsMenu );
2229 2229
2230 2230
2231 mActionWN->plug( helpMenu ); 2231 mActionWN->plug( helpMenu );
2232 mActionSyncHowto->plug( helpMenu ); 2232 mActionSyncHowto->plug( helpMenu );
2233 mActionKdeSyncHowto->plug( helpMenu ); 2233 mActionKdeSyncHowto->plug( helpMenu );
2234 mActionMultiSyncHowto->plug( helpMenu ); 2234 mActionMultiSyncHowto->plug( helpMenu );
2235 mActionFaq->plug( helpMenu ); 2235 mActionFaq->plug( helpMenu );
2236 mActionLicence->plug( helpMenu ); 2236 mActionLicence->plug( helpMenu );
2237 mActionAboutKAddressbook->plug( helpMenu ); 2237 mActionAboutKAddressbook->plug( helpMenu );
2238 2238
2239 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2239 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2240 2240
2241 mActionSave->plug( tb ); 2241 mActionSave->plug( tb );
2242 mViewManager->getFilterAction()->plug ( tb); 2242 mViewManager->getFilterAction()->plug ( tb);
2243 //LR hide filteraction on started in 480x640 2243 //LR hide filteraction on started in 480x640
2244 if (QApplication::desktop()->width() == 480 ) { 2244 if (QApplication::desktop()->width() == 480 ) {
2245 mViewManager->getFilterAction()->setComboWidth( 0 ); 2245 mViewManager->getFilterAction()->setComboWidth( 0 );
2246 } 2246 }
2247 mActionUndo->plug( tb ); 2247 mActionUndo->plug( tb );
2248 mActionDelete->plug( tb ); 2248 mActionDelete->plug( tb );
2249 mActionRedo->plug( tb ); 2249 mActionRedo->plug( tb );
2250 } else { 2250 } else {
2251 mActionSave->plug( tb ); 2251 mActionSave->plug( tb );
2252 tb->enableMoving(false); 2252 tb->enableMoving(false);
2253 } 2253 }
2254 //mActionQuit->plug ( tb ); 2254 //mActionQuit->plug ( tb );
2255 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2255 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2256 2256
2257 //US link the searchwidget first to this. 2257 //US link the searchwidget first to this.
2258 // The real linkage to the toolbar happens later. 2258 // The real linkage to the toolbar happens later.
2259//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2259//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2260//US tb->insertItem( mIncSearchWidget ); 2260//US tb->insertItem( mIncSearchWidget );
2261/*US 2261/*US
2262 mIncSearchWidget = new IncSearchWidget( tb ); 2262 mIncSearchWidget = new IncSearchWidget( tb );
2263 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2263 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2264 SLOT( incrementalSearch( const QString& ) ) ); 2264 SLOT( incrementalSearch( const QString& ) ) );
2265 2265
2266 mJumpButtonBar = new JumpButtonBar( this, this ); 2266 mJumpButtonBar = new JumpButtonBar( this, this );
2267 2267
2268//US topLayout->addWidget( mJumpButtonBar ); 2268//US topLayout->addWidget( mJumpButtonBar );
2269 this->layout()->add( mJumpButtonBar ); 2269 this->layout()->add( mJumpButtonBar );
2270*/ 2270*/
2271 2271
2272#endif //KAB_EMBEDDED 2272#endif //KAB_EMBEDDED
2273 2273
2274 mActionExport2phone->plug( ExportMenu ); 2274 mActionExport2phone->plug( ExportMenu );
2275 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2275 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2276 syncManager->fillSyncMenu(); 2276 syncManager->fillSyncMenu();
2277 2277
2278} 2278}
2279void KABCore::showLicence() 2279void KABCore::showLicence()
2280{ 2280{
2281 KApplication::showLicence(); 2281 KApplication::showLicence();
2282} 2282}
2283 2283
2284void KABCore::manageCategories( ) 2284void KABCore::manageCategories( )
2285{ 2285{
2286 KABCatPrefs* cp = new KABCatPrefs(); 2286 KABCatPrefs* cp = new KABCatPrefs();
2287 cp->show(); 2287 cp->show();
2288 int w =cp->sizeHint().width() ; 2288 int w =cp->sizeHint().width() ;
2289 int h = cp->sizeHint().height() ; 2289 int h = cp->sizeHint().height() ;
2290 int dw = QApplication::desktop()->width(); 2290 int dw = QApplication::desktop()->width();
2291 int dh = QApplication::desktop()->height(); 2291 int dh = QApplication::desktop()->height();
2292 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2292 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2293 if ( !cp->exec() ) { 2293 if ( !cp->exec() ) {
2294 delete cp; 2294 delete cp;
2295 return; 2295 return;
2296 } 2296 }
2297 int count = 0; 2297 int count = 0;
2298 message( i18n("Please wait, processing categories...")); 2298 message( i18n("Please wait, processing categories..."));
2299 if ( cp->addCat() ) { 2299 if ( cp->addCat() ) {
2300 KABC::AddressBook::Iterator it; 2300 KABC::AddressBook::Iterator it;
2301 QStringList catList = KABPrefs::instance()->mCustomCategories; 2301 QStringList catList = KABPrefs::instance()->mCustomCategories;
2302 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2302 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2303 QStringList catIncList = (*it).categories(); 2303 QStringList catIncList = (*it).categories();
2304 int i; 2304 int i;
2305 for( i = 0; i< catIncList.count(); ++i ) { 2305 for( i = 0; i< catIncList.count(); ++i ) {
2306 if ( !catList.contains (catIncList[i])) { 2306 if ( !catList.contains (catIncList[i])) {
2307 catList.append( catIncList[i] ); 2307 catList.append( catIncList[i] );
2308 //qDebug("add cat %s ", catIncList[i].latin1()); 2308 //qDebug("add cat %s ", catIncList[i].latin1());
2309 ++count; 2309 ++count;
2310 } 2310 }
2311 } 2311 }
2312 } 2312 }
2313 catList.sort(); 2313 catList.sort();
2314 KABPrefs::instance()->mCustomCategories = catList; 2314 KABPrefs::instance()->mCustomCategories = catList;
2315 KABPrefs::instance()->writeConfig(); 2315 KABPrefs::instance()->writeConfig();
2316 message(QString::number( count )+ i18n(" categories added to list! ")); 2316 message(QString::number( count )+ i18n(" categories added to list! "));
2317 } else { 2317 } else {
2318 QStringList catList = KABPrefs::instance()->mCustomCategories; 2318 QStringList catList = KABPrefs::instance()->mCustomCategories;
2319 QStringList catIncList; 2319 QStringList catIncList;
2320 QStringList newCatList; 2320 QStringList newCatList;
2321 KABC::AddressBook::Iterator it; 2321 KABC::AddressBook::Iterator it;
2322 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2322 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2323 QStringList catIncList = (*it).categories(); 2323 QStringList catIncList = (*it).categories();
2324 int i; 2324 int i;
2325 if ( catIncList.count() ) { 2325 if ( catIncList.count() ) {
2326 newCatList.clear(); 2326 newCatList.clear();
2327 for( i = 0; i< catIncList.count(); ++i ) { 2327 for( i = 0; i< catIncList.count(); ++i ) {
2328 if ( catList.contains (catIncList[i])) { 2328 if ( catList.contains (catIncList[i])) {
2329 newCatList.append( catIncList[i] ); 2329 newCatList.append( catIncList[i] );
2330 } 2330 }
2331 } 2331 }
2332 newCatList.sort(); 2332 newCatList.sort();
2333 (*it).setCategories( newCatList ); 2333 (*it).setCategories( newCatList );
2334 mAddressBook->insertAddressee( (*it) ); 2334 mAddressBook->insertAddressee( (*it) );
2335 } 2335 }
2336 } 2336 }
2337 setModified( true ); 2337 setModified( true );
2338 mViewManager->refreshView(); 2338 mViewManager->refreshView();
2339 message( i18n("Removing categories done!")); 2339 message( i18n("Removing categories done!"));
2340 } 2340 }
2341 delete cp; 2341 delete cp;
2342} 2342}
2343void KABCore::removeVoice() 2343void KABCore::removeVoice()
2344{ 2344{
2345 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 ) 2345 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 )
2346 return; 2346 return;
2347 KABC::Addressee::List list; 2347 KABC::Addressee::List list;
2348 XXPortSelectDialog dlg( this, false, this ); 2348 XXPortSelectDialog dlg( this, false, this );
2349 if ( dlg.exec() ) 2349 if ( dlg.exec() )
2350 list = dlg.contacts(); 2350 list = dlg.contacts();
2351 else 2351 else
2352 return; 2352 return;
2353 KABC::Addressee::List::Iterator it; 2353 KABC::Addressee::List::Iterator it;
2354 for ( it = list.begin(); it != list.end(); ++it ) { 2354 for ( it = list.begin(); it != list.end(); ++it ) {
2355 if ( (*it).removeVoice() ) 2355 if ( (*it).removeVoice() )
2356 addrModified((*it), false ); 2356 addrModified((*it), false );
2357 } 2357 }
2358} 2358}
2359 2359
2360void KABCore::setFormattedName() 2360void KABCore::setFormattedName()
2361{ 2361{
2362 KABFormatPrefs setpref; 2362 KABFormatPrefs setpref;
2363 if ( !setpref.exec() ) { 2363 if ( !setpref.exec() ) {
2364 return; 2364 return;
2365 } 2365 }
2366 KABC::Addressee::List list; 2366 KABC::Addressee::List list;
2367 XXPortSelectDialog dlg( this, false, this ); 2367 XXPortSelectDialog dlg( this, false, this );
2368 if ( dlg.exec() ) 2368 if ( dlg.exec() )
2369 list = dlg.contacts(); 2369 list = dlg.contacts();
2370 else 2370 else
2371 return; 2371 return;
2372 KABC::Addressee::List::Iterator it; 2372 KABC::Addressee::List::Iterator it;
2373 for ( it = list.begin(); it != list.end(); ++it ) { 2373 for ( it = list.begin(); it != list.end(); ++it ) {
2374 QString fName; 2374 QString fName;
2375 if ( setpref.simple->isChecked() ) 2375 if ( setpref.simple->isChecked() )
2376 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2376 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2377 else if ( setpref.full->isChecked() ) 2377 else if ( setpref.full->isChecked() )
2378 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2378 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2379 else if ( setpref.reverse->isChecked() ) 2379 else if ( setpref.reverse->isChecked() )
2380 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2380 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2381 else 2381 else
2382 fName = (*it).organization(); 2382 fName = (*it).organization();
2383 if ( setpref.setCompany->isChecked() ) 2383 if ( setpref.setCompany->isChecked() )
2384 if ( fName.isEmpty() || fName =="," ) 2384 if ( fName.isEmpty() || fName =="," )
2385 fName = (*it).organization(); 2385 fName = (*it).organization();
2386 (*it).setFormattedName( fName ); 2386 (*it).setFormattedName( fName );
2387 addrModified((*it),false ); 2387 addrModified((*it),false );
2388 } 2388 }
2389 Addressee add; 2389 Addressee add;
2390 mDetails->setAddressee( add ); 2390 mDetails->setAddressee( add );
2391} 2391}
2392 2392
2393void KABCore::clipboardDataChanged() 2393void KABCore::clipboardDataChanged()
2394{ 2394{
2395 2395
2396 if ( mReadWrite ) 2396 if ( mReadWrite )
2397 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2397 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2398 2398
2399} 2399}
2400 2400
2401void KABCore::updateActionMenu() 2401void KABCore::updateActionMenu()
2402{ 2402{
2403 UndoStack *undo = UndoStack::instance(); 2403 UndoStack *undo = UndoStack::instance();
2404 RedoStack *redo = RedoStack::instance(); 2404 RedoStack *redo = RedoStack::instance();
2405 2405
2406 if ( undo->isEmpty() ) 2406 if ( undo->isEmpty() )
2407 mActionUndo->setText( i18n( "Undo" ) ); 2407 mActionUndo->setText( i18n( "Undo" ) );
2408 else 2408 else
2409 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2409 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2410 2410
2411 mActionUndo->setEnabled( !undo->isEmpty() ); 2411 mActionUndo->setEnabled( !undo->isEmpty() );
2412 2412
2413 if ( !redo->top() ) 2413 if ( !redo->top() )
2414 mActionRedo->setText( i18n( "Redo" ) ); 2414 mActionRedo->setText( i18n( "Redo" ) );
2415 else 2415 else
2416 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2416 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2417 2417
2418 mActionRedo->setEnabled( !redo->isEmpty() ); 2418 mActionRedo->setEnabled( !redo->isEmpty() );
2419} 2419}
2420 2420
2421void KABCore::configureKeyBindings() 2421void KABCore::configureKeyBindings()
2422{ 2422{
2423#ifndef KAB_EMBEDDED 2423#ifndef KAB_EMBEDDED
2424 KKeyDialog::configure( actionCollection(), true ); 2424 KKeyDialog::configure( actionCollection(), true );
2425#else //KAB_EMBEDDED 2425#else //KAB_EMBEDDED
2426 qDebug("KABCore::configureKeyBindings() not implemented"); 2426 qDebug("KABCore::configureKeyBindings() not implemented");
2427#endif //KAB_EMBEDDED 2427#endif //KAB_EMBEDDED
2428} 2428}
2429 2429
2430#ifdef KAB_EMBEDDED 2430#ifdef KAB_EMBEDDED
2431void KABCore::configureResources() 2431void KABCore::configureResources()
2432{ 2432{
2433 KRES::KCMKResources dlg( this, "" , 0 ); 2433 KRES::KCMKResources dlg( this, "" , 0 );
2434 2434
2435 if ( !dlg.exec() ) 2435 if ( !dlg.exec() )
2436 return; 2436 return;
2437 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2437 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2438} 2438}
2439#endif //KAB_EMBEDDED 2439#endif //KAB_EMBEDDED
2440 2440
2441 2441
2442/* this method will be called through the QCop interface from Ko/Pi to select addresses 2442/* this method will be called through the QCop interface from Ko/Pi to select addresses
2443 * for the attendees list of an event. 2443 * for the attendees list of an event.
2444 */ 2444 */
2445void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2445void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2446{ 2446{
2447 QStringList nameList; 2447 QStringList nameList;
2448 QStringList emailList; 2448 QStringList emailList;
2449 QStringList uidList; 2449 QStringList uidList;
2450 2450
2451 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2451 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2452 uint i=0; 2452 uint i=0;
2453 for (i=0; i < list.count(); i++) 2453 for (i=0; i < list.count(); i++)
2454 { 2454 {
2455 nameList.append(list[i].realName()); 2455 nameList.append(list[i].realName());
2456 emailList.append(list[i].preferredEmail()); 2456 emailList.append(list[i].preferredEmail());
2457 uidList.append(list[i].uid()); 2457 uidList.append(list[i].uid());
2458 } 2458 }
2459 2459
2460 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2460 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2461 2461
2462} 2462}
2463 2463
2464/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2464/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2465 * to put them into the calendar. 2465 * to put them into the calendar.
2466 */ 2466 */
2467void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2467void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2468{ 2468{
2469 // qDebug("KABCore::requestForBirthdayList"); 2469 // qDebug("KABCore::requestForBirthdayList");
2470 QStringList birthdayList; 2470 QStringList birthdayList;
2471 QStringList anniversaryList; 2471 QStringList anniversaryList;
2472 QStringList realNameList; 2472 QStringList realNameList;
2473 QStringList preferredEmailList; 2473 QStringList preferredEmailList;
2474 QStringList assembledNameList; 2474 QStringList assembledNameList;
2475 QStringList uidList; 2475 QStringList uidList;
2476 2476
2477 KABC::AddressBook::Iterator it; 2477 KABC::AddressBook::Iterator it;
2478 2478
2479 int count = 0; 2479 int count = 0;
2480 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2480 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2481 ++count; 2481 ++count;
2482 } 2482 }
2483 QProgressBar bar(count,0 ); 2483 QProgressBar bar(count,0 );
2484 int w = 300; 2484 int w = 300;
2485 if ( QApplication::desktop()->width() < 320 ) 2485 if ( QApplication::desktop()->width() < 320 )
2486 w = 220; 2486 w = 220;
2487 int h = bar.sizeHint().height() ; 2487 int h = bar.sizeHint().height() ;
2488 int dw = QApplication::desktop()->width(); 2488 int dw = QApplication::desktop()->width();
2489 int dh = QApplication::desktop()->height(); 2489 int dh = QApplication::desktop()->height();
2490 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2490 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2491 bar.show(); 2491 bar.show();
2492 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2492 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2493 qApp->processEvents(); 2493 qApp->processEvents();
2494 2494
2495 QDate bday; 2495 QDate bday;
2496 QString anni; 2496 QString anni;
2497 QString formattedbday; 2497 QString formattedbday;
2498 2498
2499 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2499 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2500 { 2500 {
2501 if ( ! bar.isVisible() ) 2501 if ( ! bar.isVisible() )
2502 return; 2502 return;
2503 bar.setProgress( count++ ); 2503 bar.setProgress( count++ );
2504 qApp->processEvents(); 2504 qApp->processEvents();
2505 bday = (*it).birthday().date(); 2505 bday = (*it).birthday().date();
2506 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2506 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2507 2507
2508 if ( bday.isValid() || !anni.isEmpty()) 2508 if ( bday.isValid() || !anni.isEmpty())
2509 { 2509 {
2510 if (bday.isValid()) 2510 if (bday.isValid())
2511 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2511 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2512 else 2512 else
2513 formattedbday = "NOTVALID"; 2513 formattedbday = "NOTVALID";
2514 if (anni.isEmpty()) 2514 if (anni.isEmpty())
2515 anni = "INVALID"; 2515 anni = "INVALID";
2516 2516
2517 birthdayList.append(formattedbday); 2517 birthdayList.append(formattedbday);
2518 anniversaryList.append(anni); //should be ISODate 2518 anniversaryList.append(anni); //should be ISODate
2519 realNameList.append((*it).realName()); 2519 realNameList.append((*it).realName());
2520 preferredEmailList.append((*it).preferredEmail()); 2520 preferredEmailList.append((*it).preferredEmail());
2521 assembledNameList.append((*it).assembledName()); 2521 assembledNameList.append((*it).assembledName());
2522 uidList.append((*it).uid()); 2522 uidList.append((*it).uid());
2523 2523
2524 //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() ); 2524 //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() );
2525 } 2525 }
2526 } 2526 }
2527 2527
2528 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2528 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2529 2529
2530} 2530}
2531 2531
2532/* this method will be called through the QCop interface from other apps to show details of a contact. 2532/* this method will be called through the QCop interface from other apps to show details of a contact.
2533 */ 2533 */
2534void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2534void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2535{ 2535{
2536 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2536 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2537 2537
2538 QString foundUid = QString::null; 2538 QString foundUid = QString::null;
2539 if ( ! uid.isEmpty() ) { 2539 if ( ! uid.isEmpty() ) {
2540 Addressee adrr = mAddressBook->findByUid( uid ); 2540 Addressee adrr = mAddressBook->findByUid( uid );
2541 if ( !adrr.isEmpty() ) { 2541 if ( !adrr.isEmpty() ) {
2542 foundUid = uid; 2542 foundUid = uid;
2543 } 2543 }
2544 if ( email == "sendbacklist" ) { 2544 if ( email == "sendbacklist" ) {
2545 //qDebug("ssssssssssssssssssssssend "); 2545 //qDebug("ssssssssssssssssssssssend ");
2546 QStringList nameList; 2546 QStringList nameList;
2547 QStringList emailList; 2547 QStringList emailList;
2548 QStringList uidList; 2548 QStringList uidList;
2549 nameList.append(adrr.realName()); 2549 nameList.append(adrr.realName());
2550 emailList = adrr.emails(); 2550 emailList = adrr.emails();
2551 uidList.append( adrr.preferredEmail()); 2551 uidList.append( adrr.preferredEmail());
2552 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2552 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2553 return; 2553 return;
2554 } 2554 }
2555 2555
2556 } 2556 }
2557 2557
2558 if ( email == "sendbacklist" ) 2558 if ( email == "sendbacklist" )
2559 return; 2559 return;
2560 if (foundUid.isEmpty()) 2560 if (foundUid.isEmpty())
2561 { 2561 {
2562 //find the uid of the person first 2562 //find the uid of the person first
2563 Addressee::List namelist; 2563 Addressee::List namelist;
2564 Addressee::List emaillist; 2564 Addressee::List emaillist;
2565 2565
2566 if (!name.isEmpty()) 2566 if (!name.isEmpty())
2567 namelist = mAddressBook->findByName( name ); 2567 namelist = mAddressBook->findByName( name );
2568 2568
2569 if (!email.isEmpty()) 2569 if (!email.isEmpty())
2570 emaillist = mAddressBook->findByEmail( email ); 2570 emaillist = mAddressBook->findByEmail( email );
2571 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2571 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2572 //check if we have a match in Namelist and Emaillist 2572 //check if we have a match in Namelist and Emaillist
2573 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2573 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2574 foundUid = emaillist[0].uid(); 2574 foundUid = emaillist[0].uid();
2575 } 2575 }
2576 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2576 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2577 foundUid = namelist[0].uid(); 2577 foundUid = namelist[0].uid();
2578 else 2578 else
2579 { 2579 {
2580 for (int i = 0; i < namelist.count(); i++) 2580 for (int i = 0; i < namelist.count(); i++)
2581 { 2581 {
2582 for (int j = 0; j < emaillist.count(); j++) 2582 for (int j = 0; j < emaillist.count(); j++)
2583 { 2583 {
2584 if (namelist[i] == emaillist[j]) 2584 if (namelist[i] == emaillist[j])
2585 { 2585 {
2586 foundUid = namelist[i].uid(); 2586 foundUid = namelist[i].uid();
2587 } 2587 }
2588 } 2588 }
2589 } 2589 }
2590 } 2590 }
2591 } 2591 }
2592 else 2592 else
2593 { 2593 {
2594 foundUid = uid; 2594 foundUid = uid;
2595 } 2595 }
2596 2596
2597 if (!foundUid.isEmpty()) 2597 if (!foundUid.isEmpty())
2598 { 2598 {
2599 2599
2600 // raise Ka/Pi if it is in the background 2600 // raise Ka/Pi if it is in the background
2601#ifndef DESKTOP_VERSION 2601#ifndef DESKTOP_VERSION
2602#ifndef KORG_NODCOP 2602#ifndef KORG_NODCOP
2603 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2603 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2604#endif 2604#endif
2605#endif 2605#endif
2606 2606
2607 mMainWindow->showMaximized(); 2607 mMainWindow->showMaximized();
2608 mMainWindow-> raise(); 2608 mMainWindow-> raise();
2609 2609
2610 mViewManager->setSelected( "", false); 2610 mViewManager->setSelected( "", false);
2611 mViewManager->refreshView( "" ); 2611 mViewManager->refreshView( "" );
2612 mViewManager->setSelected( foundUid, true ); 2612 mViewManager->setSelected( foundUid, true );
2613 mViewManager->refreshView( foundUid ); 2613 mViewManager->refreshView( foundUid );
2614 2614
2615 if ( !mMultipleViewsAtOnce ) 2615 if ( !mMultipleViewsAtOnce )
2616 { 2616 {
2617 setDetailsVisible( true ); 2617 setDetailsVisible( true );
2618 mActionDetails->setChecked(true); 2618 mActionDetails->setChecked(true);
2619 } 2619 }
2620 } 2620 }
2621} 2621}
2622 2622
2623void KABCore::whatsnew() 2623void KABCore::whatsnew()
2624{ 2624{
2625 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2625 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2626} 2626}
2627void KABCore::synchowto() 2627void KABCore::synchowto()
2628{ 2628{
2629 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2629 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2630} 2630}
2631void KABCore::kdesynchowto() 2631void KABCore::kdesynchowto()
2632{ 2632{
2633 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2633 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2634} 2634}
2635void KABCore::multisynchowto() 2635void KABCore::multisynchowto()
2636{ 2636{
2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2638} 2638}
2639void KABCore::faq() 2639void KABCore::faq()
2640{ 2640{
2641 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2641 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2642} 2642}
2643 2643
2644#include <libkcal/syncdefines.h> 2644#include <libkcal/syncdefines.h>
2645 2645
2646KABC::Addressee KABCore::getLastSyncAddressee() 2646KABC::Addressee KABCore::getLastSyncAddressee()
2647{ 2647{
2648 Addressee lse; 2648 Addressee lse;
2649 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2649 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2650 2650
2651 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2651 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2652 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2652 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2653 if (lse.isEmpty()) { 2653 if (lse.isEmpty()) {
2654 qDebug("Creating new last-syncAddressee "); 2654 qDebug("Creating new last-syncAddressee ");
2655 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2655 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2656 QString sum = ""; 2656 QString sum = "";
2657 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2657 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2658 sum = "E: "; 2658 sum = "E: ";
2659 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2659 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2660 lse.setRevision( mLastAddressbookSync ); 2660 lse.setRevision( mLastAddressbookSync );
2661 lse.setCategories( i18n("SyncEvent") ); 2661 lse.setCategories( i18n("SyncEvent") );
2662 mAddressBook->insertAddressee( lse ); 2662 mAddressBook->insertAddressee( lse );
2663 } 2663 }
2664 return lse; 2664 return lse;
2665} 2665}
2666int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2666int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2667{ 2667{
2668 2668
2669 //void setZaurusId(int id); 2669 //void setZaurusId(int id);
2670 // int zaurusId() const; 2670 // int zaurusId() const;
2671 // void setZaurusUid(int id); 2671 // void setZaurusUid(int id);
2672 // int zaurusUid() const; 2672 // int zaurusUid() const;
2673 // void setZaurusStat(int id); 2673 // void setZaurusStat(int id);
2674 // int zaurusStat() const; 2674 // int zaurusStat() const;
2675 // 0 equal 2675 // 0 equal
2676 // 1 take local 2676 // 1 take local
2677 // 2 take remote 2677 // 2 take remote
2678 // 3 cancel 2678 // 3 cancel
2679 QDateTime lastSync = mLastAddressbookSync; 2679 QDateTime lastSync = mLastAddressbookSync;
2680 QDateTime localMod = local->revision(); 2680 QDateTime localMod = local->revision();
2681 QDateTime remoteMod = remote->revision(); 2681 QDateTime remoteMod = remote->revision();
2682 2682
2683 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2683 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2684 2684
2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2686 bool remCh, locCh; 2686 bool remCh, locCh;
2687 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2687 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2688 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2688 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2689 locCh = ( localMod > mLastAddressbookSync ); 2689 locCh = ( localMod > mLastAddressbookSync );
2690 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2690 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2691 if ( !remCh && ! locCh ) { 2691 if ( !remCh && ! locCh ) {
2692 //qDebug("both not changed "); 2692 //qDebug("both not changed ");
2693 lastSync = localMod.addDays(1); 2693 lastSync = localMod.addDays(1);
2694 if ( mode <= SYNC_PREF_ASK ) 2694 if ( mode <= SYNC_PREF_ASK )
2695 return 0; 2695 return 0;
2696 } else { 2696 } else {
2697 if ( locCh ) { 2697 if ( locCh ) {
2698 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2698 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2699 lastSync = localMod.addDays( -1 ); 2699 lastSync = localMod.addDays( -1 );
2700 if ( !remCh ) 2700 if ( !remCh )
2701 remoteMod =( lastSync.addDays( -1 ) ); 2701 remoteMod =( lastSync.addDays( -1 ) );
2702 } else { 2702 } else {
2703 //qDebug(" not loc changed "); 2703 //qDebug(" not loc changed ");
2704 lastSync = localMod.addDays( 1 ); 2704 lastSync = localMod.addDays( 1 );
2705 if ( remCh ) { 2705 if ( remCh ) {
2706 //qDebug("rem changed "); 2706 //qDebug("rem changed ");
2707 remoteMod =( lastSync.addDays( 1 ) ); 2707 remoteMod =( lastSync.addDays( 1 ) );
2708 } 2708 }
2709 2709
2710 } 2710 }
2711 } 2711 }
2712 full = true; 2712 full = true;
2713 if ( mode < SYNC_PREF_ASK ) 2713 if ( mode < SYNC_PREF_ASK )
2714 mode = SYNC_PREF_ASK; 2714 mode = SYNC_PREF_ASK;
2715 } else { 2715 } else {
2716 if ( localMod == remoteMod ) 2716 if ( localMod == remoteMod )
2717 return 0; 2717 return 0;
2718 2718
2719 } 2719 }
2720 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2720 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2721 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2721 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2722 //full = true; //debug only 2722 //full = true; //debug only
2723 if ( full ) { 2723 if ( full ) {
2724 bool equ = ( (*local) == (*remote) ); 2724 bool equ = ( (*local) == (*remote) );
2725 if ( equ ) { 2725 if ( equ ) {
2726 //qDebug("equal "); 2726 //qDebug("equal ");
2727 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2727 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2728 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2728 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2729 } 2729 }
2730 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2730 if ( mode < SYNC_PREF_FORCE_LOCAL )
2731 return 0; 2731 return 0;
2732 2732
2733 }//else //debug only 2733 }//else //debug only
2734 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2734 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2735 } 2735 }
2736 int result; 2736 int result;
2737 bool localIsNew; 2737 bool localIsNew;
2738 //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() ); 2738 //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() );
2739 2739
2740 if ( full && mode < SYNC_PREF_NEWEST ) 2740 if ( full && mode < SYNC_PREF_NEWEST )
2741 mode = SYNC_PREF_ASK; 2741 mode = SYNC_PREF_ASK;
2742 2742
2743 switch( mode ) { 2743 switch( mode ) {
2744 case SYNC_PREF_LOCAL: 2744 case SYNC_PREF_LOCAL:
2745 if ( lastSync > remoteMod ) 2745 if ( lastSync > remoteMod )
2746 return 1; 2746 return 1;
2747 if ( lastSync > localMod ) 2747 if ( lastSync > localMod )
2748 return 2; 2748 return 2;
2749 return 1; 2749 return 1;
2750 break; 2750 break;
2751 case SYNC_PREF_REMOTE: 2751 case SYNC_PREF_REMOTE:
2752 if ( lastSync > remoteMod ) 2752 if ( lastSync > remoteMod )
2753 return 1; 2753 return 1;
2754 if ( lastSync > localMod ) 2754 if ( lastSync > localMod )
2755 return 2; 2755 return 2;
2756 return 2; 2756 return 2;
2757 break; 2757 break;
2758 case SYNC_PREF_NEWEST: 2758 case SYNC_PREF_NEWEST:
2759 if ( localMod > remoteMod ) 2759 if ( localMod > remoteMod )
2760 return 1; 2760 return 1;
2761 else 2761 else
2762 return 2; 2762 return 2;
2763 break; 2763 break;
2764 case SYNC_PREF_ASK: 2764 case SYNC_PREF_ASK:
2765 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2765 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2766 if ( lastSync > remoteMod ) 2766 if ( lastSync > remoteMod )
2767 return 1; 2767 return 1;
2768 if ( lastSync > localMod ) { 2768 if ( lastSync > localMod ) {
2769 return 2; 2769 return 2;
2770 } 2770 }
2771 localIsNew = localMod >= remoteMod; 2771 localIsNew = localMod >= remoteMod;
2772 //qDebug("conflict! ************************************** "); 2772 //qDebug("conflict! ************************************** ");
2773 { 2773 {
2774 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2774 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2775 result = acd.executeD(localIsNew); 2775 result = acd.executeD(localIsNew);
2776 return result; 2776 return result;
2777 } 2777 }
2778 break; 2778 break;
2779 case SYNC_PREF_FORCE_LOCAL: 2779 case SYNC_PREF_FORCE_LOCAL:
2780 return 1; 2780 return 1;
2781 break; 2781 break;
2782 case SYNC_PREF_FORCE_REMOTE: 2782 case SYNC_PREF_FORCE_REMOTE:
2783 return 2; 2783 return 2;
2784 break; 2784 break;
2785 2785
2786 default: 2786 default:
2787 // SYNC_PREF_TAKE_BOTH not implemented 2787 // SYNC_PREF_TAKE_BOTH not implemented
2788 break; 2788 break;
2789 } 2789 }
2790 return 0; 2790 return 0;
2791} 2791}
2792 2792
2793 2793
2794bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2794bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2795{ 2795{
2796 bool syncOK = true; 2796 bool syncOK = true;
2797 int addedAddressee = 0; 2797 int addedAddressee = 0;
2798 int addedAddresseeR = 0; 2798 int addedAddresseeR = 0;
2799 int deletedAddresseeR = 0; 2799 int deletedAddresseeR = 0;
2800 int deletedAddresseeL = 0; 2800 int deletedAddresseeL = 0;
2801 int changedLocal = 0; 2801 int changedLocal = 0;
2802 int changedRemote = 0; 2802 int changedRemote = 0;
2803 int filteredIN = 0; 2803 int filteredIN = 0;
2804 int filteredOUT = 0; 2804 int filteredOUT = 0;
2805 2805
2806 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2806 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2807 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2807 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2808 2808
2809 //QPtrList<Addressee> el = local->rawAddressees(); 2809 //QPtrList<Addressee> el = local->rawAddressees();
2810 Addressee addresseeR; 2810 Addressee addresseeR;
2811 QString uid; 2811 QString uid;
2812 int take; 2812 int take;
2813 Addressee addresseeL; 2813 Addressee addresseeL;
2814 Addressee addresseeRSync; 2814 Addressee addresseeRSync;
2815 Addressee addresseeLSync; 2815 Addressee addresseeLSync;
2816 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2816 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2817 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2817 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2818 bool fullDateRange = false; 2818 bool fullDateRange = false;
2819 local->resetTempSyncStat(); 2819 local->resetTempSyncStat();
2820 mLastAddressbookSync = QDateTime::currentDateTime(); 2820 mLastAddressbookSync = QDateTime::currentDateTime();
2821 if ( syncManager->syncWithDesktop() ) { 2821 if ( syncManager->syncWithDesktop() ) {
2822 // remote->removeSyncInfo( QString());//remove all info 2822 // remote->removeSyncInfo( QString());//remove all info
2823 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2823 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2824 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2824 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2825 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2825 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2826 } else { 2826 } else {
2827 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2827 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2828 } 2828 }
2829 } 2829 }
2830 QDateTime modifiedCalendar = mLastAddressbookSync; 2830 QDateTime modifiedCalendar = mLastAddressbookSync;
2831 addresseeLSync = getLastSyncAddressee(); 2831 addresseeLSync = getLastSyncAddressee();
2832 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2832 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2833 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2833 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2834 if ( !addresseeR.isEmpty() ) { 2834 if ( !addresseeR.isEmpty() ) {
2835 addresseeRSync = addresseeR; 2835 addresseeRSync = addresseeR;
2836 remote->removeAddressee(addresseeR ); 2836 remote->removeAddressee(addresseeR );
2837 2837
2838 } else { 2838 } else {
2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2840 addresseeRSync = addresseeLSync ; 2840 addresseeRSync = addresseeLSync ;
2841 } else { 2841 } else {
2842 //qDebug("FULLDATE 1"); 2842 //qDebug("FULLDATE 1");
2843 fullDateRange = true; 2843 fullDateRange = true;
2844 Addressee newAdd; 2844 Addressee newAdd;
2845 addresseeRSync = newAdd; 2845 addresseeRSync = newAdd;
2846 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2846 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2847 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2847 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2848 addresseeRSync.setRevision( mLastAddressbookSync ); 2848 addresseeRSync.setRevision( mLastAddressbookSync );
2849 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2849 addresseeRSync.setCategories( i18n("SyncAddressee") );
2850 } 2850 }
2851 } 2851 }
2852 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2852 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2853 // qDebug("FULLDATE 2"); 2853 // qDebug("FULLDATE 2");
2854 fullDateRange = true; 2854 fullDateRange = true;
2855 } 2855 }
2856 if ( ! fullDateRange ) { 2856 if ( ! fullDateRange ) {
2857 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2857 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2858 2858
2859 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2859 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2860 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2860 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2861 fullDateRange = true; 2861 fullDateRange = true;
2862 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2862 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2863 } 2863 }
2864 } 2864 }
2865 // fullDateRange = true; // debug only! 2865 // fullDateRange = true; // debug only!
2866 if ( fullDateRange ) 2866 if ( fullDateRange )
2867 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2867 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2868 else 2868 else
2869 mLastAddressbookSync = addresseeLSync.revision(); 2869 mLastAddressbookSync = addresseeLSync.revision();
2870 // for resyncing if own file has changed 2870 // for resyncing if own file has changed
2871 // PENDING fixme later when implemented 2871 // PENDING fixme later when implemented
2872#if 0 2872#if 0
2873 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2873 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2874 mLastAddressbookSync = loadedFileVersion; 2874 mLastAddressbookSync = loadedFileVersion;
2875 qDebug("setting mLastAddressbookSync "); 2875 qDebug("setting mLastAddressbookSync ");
2876 } 2876 }
2877#endif 2877#endif
2878 2878
2879 2879
2880 // ********** setting filters **************** 2880 // ********** setting filters ****************
2881 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2881 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2882 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2882 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2883 2883
2884 //qDebug("*************************** "); 2884 //qDebug("*************************** ");
2885 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2885 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2886 QStringList er = remote->uidList(); 2886 QStringList er = remote->uidList();
2887 Addressee inR ;//= er.first(); 2887 Addressee inR ;//= er.first();
2888 Addressee inL; 2888 Addressee inL;
2889 2889
2890 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2890 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2891 2891
2892 int modulo = (er.count()/10)+1; 2892 int modulo = (er.count()/10)+1;
2893 int incCounter = 0; 2893 int incCounter = 0;
2894 while ( incCounter < er.count()) { 2894 while ( incCounter < er.count()) {
2895 if (syncManager->isProgressBarCanceled()) 2895 if (syncManager->isProgressBarCanceled())
2896 return false; 2896 return false;
2897 if ( incCounter % modulo == 0 ) 2897 if ( incCounter % modulo == 0 )
2898 syncManager->showProgressBar(incCounter); 2898 syncManager->showProgressBar(incCounter);
2899 2899
2900 uid = er[ incCounter ]; 2900 uid = er[ incCounter ];
2901 bool skipIncidence = false; 2901 bool skipIncidence = false;
2902 if ( uid.left(19) == QString("last-syncAddressee-") ) 2902 if ( uid.left(19) == QString("last-syncAddressee-") )
2903 skipIncidence = true; 2903 skipIncidence = true;
2904 QString idS,OidS; 2904 QString idS,OidS;
2905 qApp->processEvents(); 2905 qApp->processEvents();
2906 if ( !skipIncidence ) { 2906 if ( !skipIncidence ) {
2907 inL = local->findByUid( uid ); 2907 inL = local->findByUid( uid );
2908 inR = remote->findByUid( uid ); 2908 inR = remote->findByUid( uid );
2909 //inL.setResource( 0 ); 2909 //inL.setResource( 0 );
2910 //inR.setResource( 0 ); 2910 //inR.setResource( 0 );
2911 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2911 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2912 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2912 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2913 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2913 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2914 //qDebug("take %d %s ", take, inL.summary().latin1()); 2914 //qDebug("take %d %s ", take, inL.summary().latin1());
2915 if ( take == 3 ) 2915 if ( take == 3 )
2916 return false; 2916 return false;
2917 if ( take == 1 ) {// take local ********************** 2917 if ( take == 1 ) {// take local **********************
2918 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2918 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2919 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2919 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2920 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2920 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2921 local->insertAddressee( inL, false ); 2921 local->insertAddressee( inL, false );
2922 idS = inR.externalUID(); 2922 idS = inR.externalUID();
2923 OidS = inR.originalExternalUID(); 2923 OidS = inR.originalExternalUID();
2924 } 2924 }
2925 else 2925 else
2926 idS = inR.IDStr(); 2926 idS = inR.IDStr();
2927 remote->removeAddressee( inR ); 2927 remote->removeAddressee( inR );
2928 inR = inL; 2928 inR = inL;
2929 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2929 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2930 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2930 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2931 inR.setOriginalExternalUID( OidS ); 2931 inR.setOriginalExternalUID( OidS );
2932 inR.setExternalUID( idS ); 2932 inR.setExternalUID( idS );
2933 if ( syncManager->syncWithDesktop() ) { 2933 if ( syncManager->syncWithDesktop() ) {
2934 inR.setIDStr("changed" ); 2934 inR.setIDStr("changed" );
2935 } 2935 }
2936 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2936 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2937 } else { 2937 } else {
2938 inR.setIDStr( idS ); 2938 inR.setIDStr( idS );
2939 } 2939 }
2940 inR.setResource( 0 ); 2940 inR.setResource( 0 );
2941 remote->insertAddressee( inR , false); 2941 remote->insertAddressee( inR , false);
2942 ++changedRemote; 2942 ++changedRemote;
2943 } else { // take == 2 take remote ********************** 2943 } else { // take == 2 take remote **********************
2944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2945 if ( inR.revision().date().year() < 2004 ) 2945 if ( inR.revision().date().year() < 2004 )
2946 inR.setRevision( modifiedCalendar ); 2946 inR.setRevision( modifiedCalendar );
2947 } 2947 }
2948 idS = inL.IDStr(); 2948 idS = inL.IDStr();
2949 local->removeAddressee( inL ); 2949 local->removeAddressee( inL );
2950 inL = inR; 2950 inL = inR;
2951 inL.setIDStr( idS ); 2951 inL.setIDStr( idS );
2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2955 } 2955 }
2956 inL.setResource( 0 ); 2956 inL.setResource( 0 );
2957 local->insertAddressee( inL , false ); 2957 local->insertAddressee( inL , false );
2958 ++changedLocal; 2958 ++changedLocal;
2959 } 2959 }
2960 } 2960 }
2961 } 2961 }
2962 } else { // no conflict ********** add or delete remote 2962 } else { // no conflict ********** add or delete remote
2963 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2963 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2965 QString des = addresseeLSync.note(); 2965 QString des = addresseeLSync.note();
2966 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2966 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2967 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2967 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2968 remote->insertAddressee( inR, false ); 2968 remote->insertAddressee( inR, false );
2969 ++deletedAddresseeR; 2969 ++deletedAddresseeR;
2970 } else { 2970 } else {
2971 inR.setRevision( modifiedCalendar ); 2971 inR.setRevision( modifiedCalendar );
2972 remote->insertAddressee( inR, false ); 2972 remote->insertAddressee( inR, false );
2973 inL = inR; 2973 inL = inR;
2974 inL.setIDStr( ":" ); 2974 inL.setIDStr( ":" );
2975 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2975 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2976 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2976 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2977 inL.setResource( 0 ); 2977 inL.setResource( 0 );
2978 local->insertAddressee( inL , false); 2978 local->insertAddressee( inL , false);
2979 ++addedAddressee; 2979 ++addedAddressee;
2980 } 2980 }
2981 } else { 2981 } else {
2982 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2982 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2983 inR.setRevision( modifiedCalendar ); 2983 inR.setRevision( modifiedCalendar );
2984 remote->insertAddressee( inR, false ); 2984 remote->insertAddressee( inR, false );
2985 inR.setResource( 0 ); 2985 inR.setResource( 0 );
2986 local->insertAddressee( inR, false ); 2986 local->insertAddressee( inR, false );
2987 ++addedAddressee; 2987 ++addedAddressee;
2988 } else { 2988 } else {
2989 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2989 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2990 remote->removeAddressee( inR ); 2990 remote->removeAddressee( inR );
2991 ++deletedAddresseeR; 2991 ++deletedAddresseeR;
2992 } 2992 }
2993 } 2993 }
2994 } else { 2994 } else {
2995 ++filteredIN; 2995 ++filteredIN;
2996 } 2996 }
2997 } 2997 }
2998 } 2998 }
2999 ++incCounter; 2999 ++incCounter;
3000 } 3000 }
3001 er.clear(); 3001 er.clear();
3002 QStringList el = local->uidList(); 3002 QStringList el = local->uidList();
3003 modulo = (el.count()/10)+1; 3003 modulo = (el.count()/10)+1;
3004 3004
3005 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3005 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3006 incCounter = 0; 3006 incCounter = 0;
3007 while ( incCounter < el.count()) { 3007 while ( incCounter < el.count()) {
3008 qApp->processEvents(); 3008 qApp->processEvents();
3009 if (syncManager->isProgressBarCanceled()) 3009 if (syncManager->isProgressBarCanceled())
3010 return false; 3010 return false;
3011 if ( incCounter % modulo == 0 ) 3011 if ( incCounter % modulo == 0 )
3012 syncManager->showProgressBar(incCounter); 3012 syncManager->showProgressBar(incCounter);
3013 uid = el[ incCounter ]; 3013 uid = el[ incCounter ];
3014 bool skipIncidence = false; 3014 bool skipIncidence = false;
3015 if ( uid.left(19) == QString("last-syncAddressee-") ) 3015 if ( uid.left(19) == QString("last-syncAddressee-") )
3016 skipIncidence = true; 3016 skipIncidence = true;
3017 if ( !skipIncidence ) { 3017 if ( !skipIncidence ) {
3018 inL = local->findByUid( uid ); 3018 inL = local->findByUid( uid );
3019 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3019 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3020 inR = remote->findByUid( uid ); 3020 inR = remote->findByUid( uid );
3021 if ( inR.isEmpty() ){ 3021 if ( inR.isEmpty() ){
3022 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3022 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3023 // no conflict ********** add or delete local 3023 // no conflict ********** add or delete local
3024 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3024 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3025 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3025 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3026 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3026 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3027 local->removeAddressee( inL ); 3027 local->removeAddressee( inL );
3028 ++deletedAddresseeL; 3028 ++deletedAddresseeL;
3029 } else { 3029 } else {
3030 if ( ! syncManager->mWriteBackExistingOnly ) { 3030 if ( ! syncManager->mWriteBackExistingOnly ) {
3031 inL.removeID(mCurrentSyncDevice ); 3031 inL.removeID(mCurrentSyncDevice );
3032 ++addedAddresseeR; 3032 ++addedAddresseeR;
3033 inL.setRevision( modifiedCalendar ); 3033 inL.setRevision( modifiedCalendar );
3034 local->insertAddressee( inL, false ); 3034 local->insertAddressee( inL, false );
3035 inR = inL; 3035 inR = inL;
3036 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3036 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3037 inR.setResource( 0 ); 3037 inR.setResource( 0 );
3038 remote->insertAddressee( inR, false ); 3038 remote->insertAddressee( inR, false );
3039 } 3039 }
3040 } 3040 }
3041 } else { 3041 } else {
3042 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3042 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3043 //qDebug("data %s ", inL.revision().toString().latin1()); 3043 //qDebug("data %s ", inL.revision().toString().latin1());
3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3045 local->removeAddressee( inL ); 3045 local->removeAddressee( inL );
3046 ++deletedAddresseeL; 3046 ++deletedAddresseeL;
3047 } else { 3047 } else {
3048 if ( ! syncManager->mWriteBackExistingOnly ) { 3048 if ( ! syncManager->mWriteBackExistingOnly ) {
3049 ++addedAddresseeR; 3049 ++addedAddresseeR;
3050 inL.setRevision( modifiedCalendar ); 3050 inL.setRevision( modifiedCalendar );
3051 local->insertAddressee( inL, false ); 3051 local->insertAddressee( inL, false );
3052 inR = inL; 3052 inR = inL;
3053 inR.setIDStr( ":" ); 3053 inR.setIDStr( ":" );
3054 inR.setResource( 0 ); 3054 inR.setResource( 0 );
3055 remote->insertAddressee( inR, false ); 3055 remote->insertAddressee( inR, false );
3056 } 3056 }
3057 } 3057 }
3058 } 3058 }
3059 } else { 3059 } else {
3060 ++filteredOUT; 3060 ++filteredOUT;
3061 } 3061 }
3062 } 3062 }
3063 } 3063 }
3064 } 3064 }
3065 ++incCounter; 3065 ++incCounter;
3066 } 3066 }
3067 el.clear(); 3067 el.clear();
3068 syncManager->hideProgressBar(); 3068 syncManager->hideProgressBar();
3069 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3069 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3070 // get rid of micro seconds 3070 // get rid of micro seconds
3071 QTime t = mLastAddressbookSync.time(); 3071 QTime t = mLastAddressbookSync.time();
3072 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3072 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3073 addresseeLSync.setRevision( mLastAddressbookSync ); 3073 addresseeLSync.setRevision( mLastAddressbookSync );
3074 addresseeRSync.setRevision( mLastAddressbookSync ); 3074 addresseeRSync.setRevision( mLastAddressbookSync );
3075 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3075 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3076 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3076 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3077 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3077 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3078 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3078 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3079 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3079 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3080 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3080 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3081 addresseeRSync.setNote( "" ) ; 3081 addresseeRSync.setNote( "" ) ;
3082 addresseeLSync.setNote( "" ); 3082 addresseeLSync.setNote( "" );
3083 3083
3084 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3084 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3085 remote->insertAddressee( addresseeRSync, false ); 3085 remote->insertAddressee( addresseeRSync, false );
3086 local->insertAddressee( addresseeLSync, false ); 3086 local->insertAddressee( addresseeLSync, false );
3087 QString mes; 3087 QString mes;
3088 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 ); 3088 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 );
3089 qDebug( mes ); 3089 qDebug( mes );
3090 mes = i18n("Local addressbook changed!\n") +mes; 3090 mes = i18n("Local addressbook changed!\n") +mes;
3091 if ( syncManager->mShowSyncSummary ) { 3091 if ( syncManager->mShowSyncSummary ) {
3092 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3092 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3093 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3093 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3094 qDebug("cancelled "); 3094 qDebug("cancelled ");
3095 return false; 3095 return false;
3096 } 3096 }
3097 } 3097 }
3098 return syncOK; 3098 return syncOK;
3099} 3099}
3100 3100
3101 3101
3102//this is a overwritten callbackmethods from the syncinterface 3102//this is a overwritten callbackmethods from the syncinterface
3103bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3103bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3104{ 3104{
3105 3105
3106 //pending prepare addresseeview for output 3106 //pending prepare addresseeview for output
3107 //pending detect, if remote file has REV field. if not switch to external sync 3107 //pending detect, if remote file has REV field. if not switch to external sync
3108 mGlobalSyncMode = SYNC_MODE_NORMAL; 3108 mGlobalSyncMode = SYNC_MODE_NORMAL;
3109 if ( manager != syncManager ) 3109 if ( manager != syncManager )
3110 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3110 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3111 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3111 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3112 3112
3113 AddressBook abLocal(filename,"syncContact"); 3113 AddressBook abLocal(filename,"syncContact");
3114 bool syncOK = false; 3114 bool syncOK = false;
3115 if ( abLocal.load() ) { 3115 if ( abLocal.load() ) {
3116 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3116 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3117 bool external = false; 3117 bool external = false;
3118 bool isXML = false; 3118 bool isXML = false;
3119 if ( filename.right(4) == ".xml") { 3119 if ( filename.right(4) == ".xml") {
3120 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3120 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3121 isXML = true; 3121 isXML = true;
3122 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3122 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3123 } else { 3123 } else {
3124 external = !manager->mIsKapiFile; 3124 external = !manager->mIsKapiFile;
3125 if ( external ) { 3125 if ( external ) {
3126 qDebug("Setting vcf mode to external "); 3126 qDebug("Setting vcf mode to external ");
3127 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3127 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3128 AddressBook::Iterator it; 3128 AddressBook::Iterator it;
3129 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3129 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3130 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3130 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3131 (*it).computeCsum( mCurrentSyncDevice ); 3131 (*it).computeCsum( mCurrentSyncDevice );
3132 } 3132 }
3133 } 3133 }
3134 } 3134 }
3135 //AddressBook::Iterator it; 3135 //AddressBook::Iterator it;
3136 //QStringList vcards; 3136 //QStringList vcards;
3137 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3137 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3138 // qDebug("Name %s ", (*it).familyName().latin1()); 3138 // qDebug("Name %s ", (*it).familyName().latin1());
3139 //} 3139 //}
3140 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3140 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3141 if ( syncOK ) { 3141 if ( syncOK ) {
3142 if ( syncManager->mWriteBackFile ) 3142 if ( syncManager->mWriteBackFile )
3143 { 3143 {
3144 if ( external ) 3144 if ( external )
3145 abLocal.removeSyncAddressees( !isXML); 3145 abLocal.removeSyncAddressees( !isXML);
3146 qDebug("Saving remote AB "); 3146 qDebug("Saving remote AB ");
3147 if ( ! abLocal.saveAB()) 3147 if ( ! abLocal.saveAB())
3148 qDebug("Error writing back AB to file "); 3148 qDebug("Error writing back AB to file ");
3149 if ( external ) { 3149 if ( external ) {
3150 // afterwrite processing 3150 // afterwrite processing
3151 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3151 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3152 } 3152 }
3153 } 3153 }
3154 } 3154 }
3155 setModified(); 3155 setModified();
3156 3156
3157 } 3157 }
3158 abLocal.removeResources(); 3158 abLocal.removeResources();
3159 if ( syncOK ) 3159 if ( syncOK )
3160 mViewManager->refreshView(); 3160 mViewManager->refreshView();
3161 return syncOK; 3161 return syncOK;
3162 3162
3163} 3163}
3164void KABCore::removeSyncInfo( QString syncProfile) 3164void KABCore::removeSyncInfo( QString syncProfile)
3165{ 3165{
3166 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3166 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3167 mAddressBook->removeSyncInfo( syncProfile ); 3167 mAddressBook->removeSyncInfo( syncProfile );
3168 setModified(); 3168 setModified();
3169} 3169}
3170 3170
3171 3171
3172//this is a overwritten callbackmethods from the syncinterface 3172//this is a overwritten callbackmethods from the syncinterface
3173bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3173bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3174{ 3174{
3175 if ( resource == "phone" ) 3175 if ( resource == "phone" )
3176 return syncPhone(); 3176 return syncPhone();
3177 disableBR( true ); 3177 disableBR( true );
3178 if ( manager != syncManager ) 3178 if ( manager != syncManager )
3179 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3179 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3180 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3180 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3181 3181
3182 AddressBook abLocal( resource,"syncContact"); 3182 AddressBook abLocal( resource,"syncContact");
3183 bool syncOK = false; 3183 bool syncOK = false;
3184 if ( abLocal.load() ) { 3184 if ( abLocal.load() ) {
3185 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3185 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3186 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3186 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3187 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3187 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3189 if ( syncOK ) { 3189 if ( syncOK ) {
3190 if ( syncManager->mWriteBackFile ) { 3190 if ( syncManager->mWriteBackFile ) {
3191 abLocal.removeSyncAddressees( false ); 3191 abLocal.removeSyncAddressees( false );
3192 abLocal.saveAB(); 3192 abLocal.saveAB();
3193 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3193 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3194 } 3194 }
3195 } else 3195 } else
3196 message( i18n("Sync cancelled or failed.") ); 3196 message( i18n("Sync cancelled or failed.") );
3197 setModified(); 3197 setModified();
3198 } 3198 }
3199 abLocal.removeResources(); 3199 abLocal.removeResources();
3200 if ( syncOK ) 3200 if ( syncOK )
3201 mViewManager->refreshView(); 3201 mViewManager->refreshView();
3202 disableBR( false ); 3202 disableBR( false );
3203 return syncOK; 3203 return syncOK;
3204 3204
3205} 3205}
3206void KABCore::message( QString m ) 3206void KABCore::message( QString m )
3207{ 3207{
3208 topLevelWidget()->setCaption( m ); 3208 topLevelWidget()->setCaption( m );
3209 mMessageTimer->start( 15000, true ); 3209 mMessageTimer->start( 15000, true );
3210} 3210}
3211bool KABCore::syncPhone() 3211bool KABCore::syncPhone()
3212{ 3212{
3213 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3213 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3214 QString fileName = getPhoneFile(); 3214 QString fileName = getPhoneFile();
3215 if ( !PhoneAccess::readFromPhone( fileName) ) { 3215 if ( !PhoneAccess::readFromPhone( fileName) ) {
3216 message(i18n("Phone access failed!")); 3216 message(i18n("Phone access failed!"));
3217 return false; 3217 return false;
3218 } 3218 }
3219 AddressBook abLocal( fileName,"syncContact"); 3219 AddressBook abLocal( fileName,"syncContact");
3220 bool syncOK = false; 3220 bool syncOK = false;
3221 { 3221 {
3222 abLocal.importFromFile( fileName ); 3222 abLocal.importFromFile( fileName );
3223 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3223 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3224 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3224 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3225 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3225 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3226 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3226 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3227 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3227 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3228 if ( syncOK ) { 3228 if ( syncOK ) {
3229 if ( syncManager->mWriteBackFile ) { 3229 if ( syncManager->mWriteBackFile ) {
3230 abLocal.removeSyncAddressees( true ); 3230 abLocal.removeSyncAddressees( true );
3231 abLocal.saveABphone( fileName ); 3231 abLocal.saveABphone( fileName );
3232 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3232 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3233 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3233 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3234 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3234 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3235 } 3235 }
3236 } 3236 }
3237 setModified(); 3237 setModified();
3238 } 3238 }
3239 abLocal.removeResources(); 3239 abLocal.removeResources();
3240 if ( syncOK ) 3240 if ( syncOK )
3241 mViewManager->refreshView(); 3241 mViewManager->refreshView();
3242 return syncOK; 3242 return syncOK;
3243} 3243}
3244void KABCore::getFile( bool success ) 3244void KABCore::getFile( bool success )
3245{ 3245{
3246 if ( ! success ) { 3246 if ( ! success ) {
3247 message( i18n("Error receiving file. Nothing changed!") ); 3247 message( i18n("Error receiving file. Nothing changed!") );
3248 return; 3248 return;
3249 } 3249 }
3250 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3250 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3251 if ( count ) 3251 if ( count )
3252 setModified( true ); 3252 setModified( true );
3253 message( i18n("Pi-Sync successful!") ); 3253 message( i18n("Pi-Sync successful!") );
3254 mViewManager->refreshView(); 3254 mViewManager->refreshView();
3255} 3255}
3256void KABCore::syncFileRequest() 3256void KABCore::syncFileRequest()
3257{ 3257{
3258 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3258 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3259 syncManager->slotSyncMenu( 999 ); 3259 syncManager->slotSyncMenu( 999 );
3260 } 3260 }
3261 mAddressBook->export2File( sentSyncFile() ); 3261 mAddressBook->export2File( sentSyncFile() );
3262} 3262}
3263QString KABCore::sentSyncFile() 3263QString KABCore::sentSyncFile()
3264{ 3264{
3265#ifdef DESKTOP_VERSION 3265#ifdef DESKTOP_VERSION
3266 return locateLocal( "tmp", "copysyncab.vcf" ); 3266 return locateLocal( "tmp", "copysyncab.vcf" );
3267#else 3267#else
3268 return QString( "/tmp/copysyncab.vcf" ); 3268 return QString( "/tmp/copysyncab.vcf" );
3269#endif 3269#endif
3270} 3270}
3271 3271
3272void KABCore::setCaptionBack() 3272void KABCore::setCaptionBack()
3273{ 3273{
3274 mMessageTimer->stop(); 3274 mMessageTimer->stop();
3275 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3275 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3276} 3276}
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 4be860e..04759a7 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,734 +1,737 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h> 63#include <qapplication.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 67#include "filtereditdialog.h"
68#include "addviewdialog.h" 68#include "addviewdialog.h"
69#include "kabcore.h" 69#include "kabcore.h"
70#include "kabprefs.h" 70#include "kabprefs.h"
71#include "viewmanager.h" 71#include "viewmanager.h"
72 72
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 75{
76 initGUI(); 76 initGUI();
77 initActions(); 77 initActions();
78 78
79 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
80 80
81 createViewFactories(); 81 createViewFactories();
82} 82}
83 83
84ViewManager::~ViewManager() 84ViewManager::~ViewManager()
85{ 85{
86 unloadViews(); 86 unloadViews();
87 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
88} 88}
89void ViewManager::scrollUP() 89void ViewManager::scrollUP()
90{ 90{
91 if ( mActiveView ) 91 if ( mActiveView )
92 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
93} 93}
94void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
95{ 95{
96 if ( mActiveView ) 96 if ( mActiveView )
97 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
98} 98}
99void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
100{ 100{
101 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 103
104 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
105 105
106 // Filter 106 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 ) 111 if (QApplication::desktop()->width() == 480 )
112 cw = 0; 112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 113 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
115 // been modified by global settings 115 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
117 117
118 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
122 } 122 }
123 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
124 124
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 126}
127 127
128void ViewManager::saveSettings() 128void ViewManager::saveSettings()
129{ 129{
130 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
131 131
132 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
137#else 137#else
138 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
139#endif 139#endif
140 } 140 }
141 141
142 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 144
145 // write the view name list 145 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 148
149} 149}
150 150
151QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
152{ 152{
153 if ( mActiveView ) 153 if ( mActiveView )
154 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
155 else 155 else
156 return QStringList(); 156 return QStringList();
157} 157}
158 158
159QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
160{ 160{
161 if ( mActiveView ) 161 if ( mActiveView )
162 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
163 else 163 else
164 return QStringList(); 164 return QStringList();
165} 165}
166 166
167KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 168{
169 KABC::Addressee::List list; 169 KABC::Addressee::List list;
170 if ( mActiveView ) { 170 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 172 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
176 list.append( addr ); 176 list.append( addr );
177 } 177 }
178 } 178 }
179 179
180 return list; 180 return list;
181} 181}
182//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
183void ViewManager::setSelected() 183void ViewManager::setSelected()
184{ 184{
185 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
186} 186}
187 187
188void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
189{ 189{
190 if ( mActiveView ) 190 if ( mActiveView )
191 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
192} 192}
193 193
194void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
195{ 195{
196 int i, count = list.count(); 196 int i, count = list.count();
197 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
198 setSelected( list[i], true ); 198 setSelected( list[i], true );
199 199
200} 200}
201void ViewManager::unloadViews() 201void ViewManager::unloadViews()
202{ 202{
203 mViewDict.clear(); 203 mViewDict.clear();
204 mActiveView = 0; 204 mActiveView = 0;
205} 205}
206 206
207void ViewManager::selectView( const QString &name )
208{
209 setActiveView( name );
210 mCore->saveSettings();
211}
207void ViewManager::setActiveView( const QString &name ) 212void ViewManager::setActiveView( const QString &name )
208{ 213{
209 KAddressBookView *view = 0; 214 KAddressBookView *view = 0;
210 215
211 // Check that this isn't the same as the current active view 216 // Check that this isn't the same as the current active view
212 if ( mActiveView && ( mActiveView->caption() == name ) ) 217 if ( mActiveView && ( mActiveView->caption() == name ) )
213 return; 218 return;
214 219
215 // At this point we know the view that should be active is not 220 // At this point we know the view that should be active is not
216 // currently active. We will try to find the new on in the list. If 221 // currently active. We will try to find the new on in the list. If
217 // we can't find it, it means it hasn't been instantiated, so we will 222 // we can't find it, it means it hasn't been instantiated, so we will
218 // create it on demand. 223 // create it on demand.
219 224
220 view = mViewDict.find( name ); 225 view = mViewDict.find( name );
221 226
222 // Check if we found the view. If we didn't, then we need to create it 227 // Check if we found the view. If we didn't, then we need to create it
223 if ( view == 0 ) { 228 if ( view == 0 ) {
224 KConfig *config = mCore->config(); 229 KConfig *config = mCore->config();
225 230
226 KConfigGroupSaver saver( config, name ); 231 KConfigGroupSaver saver( config, name );
227 232
228 QString type = config->readEntry( "Type", "Table" ); 233 QString type = config->readEntry( "Type", "Table" );
229 234
230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 235 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
231 236
232 ViewFactory *factory = mViewFactoryDict.find( type ); 237 ViewFactory *factory = mViewFactoryDict.find( type );
233 if ( factory ) 238 if ( factory )
234 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 239 view = factory->view( mCore->addressBook(), mViewWidgetStack );
235 240
236 if ( view ) { 241 if ( view ) {
237 view->setCaption( name ); 242 view->setCaption( name );
238 mViewDict.insert( name, view ); 243 mViewDict.insert( name, view );
239//US my version needs an int as second parameter to addWidget 244//US my version needs an int as second parameter to addWidget
240 mViewWidgetStack->addWidget( view, -1 ); 245 mViewWidgetStack->addWidget( view, -1 );
241 view->readConfig( config ); 246 view->readConfig( config );
242 247
243 // The manager just relays the signals 248 // The manager just relays the signals
244 connect( view, SIGNAL( selected( const QString& ) ), 249 connect( view, SIGNAL( selected( const QString& ) ),
245 SIGNAL( selected( const QString & ) ) ); 250 SIGNAL( selected( const QString & ) ) );
246 connect( view, SIGNAL( executed( const QString& ) ), 251 connect( view, SIGNAL( executed( const QString& ) ),
247 SIGNAL( executed( const QString& ) ) ); 252 SIGNAL( executed( const QString& ) ) );
248 253
249 connect( view, SIGNAL( deleteRequest( ) ), 254 connect( view, SIGNAL( deleteRequest( ) ),
250 SIGNAL( deleteRequest( ) ) ); 255 SIGNAL( deleteRequest( ) ) );
251 256
252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 257 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
253 connect( view, SIGNAL( dropped( QDropEvent* ) ), 258 connect( view, SIGNAL( dropped( QDropEvent* ) ),
254 SLOT( dropped( QDropEvent* ) ) ); 259 SLOT( dropped( QDropEvent* ) ) );
255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 260 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
256 } 261 }
257 } 262 }
258 263
259 // If we found or created the view, raise it and refresh it 264 // If we found or created the view, raise it and refresh it
260 if ( view ) { 265 if ( view ) {
261 mActiveView = view; 266 mActiveView = view;
262 mViewWidgetStack->raiseWidget( view ); 267 mViewWidgetStack->raiseWidget( view );
263 // Set the proper filter in the view. By setting the combo 268 // Set the proper filter in the view. By setting the combo
264 // box, the activated slot will be called, which will push 269 // box, the activated slot will be called, which will push
265 // the filter to the view and refresh it. 270 // the filter to the view and refresh it.
266 271
267 if ( view->defaultFilterType() == KAddressBookView::None ) { 272 if ( view->defaultFilterType() == KAddressBookView::None ) {
268 273
269 mActionSelectFilter->setCurrentItem( 0 ); 274 mActionSelectFilter->setCurrentItem( 0 );
270 setActiveFilter( 0 ); 275 setActiveFilter( 0 );
271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 276 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
272 setActiveFilter( mActionSelectFilter->currentItem() ); 277 setActiveFilter( mActionSelectFilter->currentItem() );
273 } else { 278 } else {
274 uint pos = filterPosition( view->defaultFilterName() ); 279 uint pos = filterPosition( view->defaultFilterName() );
275 mActionSelectFilter->setCurrentItem( pos ); 280 mActionSelectFilter->setCurrentItem( pos );
276 setActiveFilter( pos ); 281 setActiveFilter( pos );
277 } 282 }
278//US qDebug("ViewManager::setActiveView 6" ); 283//US qDebug("ViewManager::setActiveView 6" );
279 284
280 // Update the inc search widget to show the fields in the new active 285 // Update the inc search widget to show the fields in the new active
281 // view. 286 // view.
282 mCore->setSearchFields( mActiveView->fields() ); 287 mCore->setSearchFields( mActiveView->fields() );
283 288
284//US performance optimization. setActiveFilter calls also mActiveView->refresh() 289//US performance optimization. setActiveFilter calls also mActiveView->refresh()
285//US mActiveView->refresh(); 290//US mActiveView->refresh();
286 mCore->saveSettings();
287 } 291 }
288 else 292 else
289 { 293 {
290 qDebug("ViewManager::setActiveView: unable to find view" ); 294 qDebug("ViewManager::setActiveView: unable to find view" );
291 } 295 }
292} 296}
293 297
294//US added another method with no parameter, since my moc compiler does not support default parameters. 298//US added another method with no parameter, since my moc compiler does not support default parameters.
295void ViewManager::refreshView() 299void ViewManager::refreshView()
296{ 300{
297 refreshView( QString::null ); 301 refreshView( QString::null );
298} 302}
299 303
300void ViewManager::refreshView( const QString &uid ) 304void ViewManager::refreshView( const QString &uid )
301{ 305{
302 if ( mActiveView ) 306 if ( mActiveView )
303 mActiveView->refresh( uid ); 307 mActiveView->refresh( uid );
304} 308}
305 309
306void ViewManager::setFocusAV() 310void ViewManager::setFocusAV()
307{ 311{
308 if ( mActiveView ) 312 if ( mActiveView )
309 mActiveView->setFocusAV(); 313 mActiveView->setFocusAV();
310} 314}
311void ViewManager::editView() 315void ViewManager::editView()
312{ 316{
313 if ( !mActiveView ) 317 if ( !mActiveView )
314 return; 318 return;
315 319
316 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 320 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
317 ViewConfigureWidget *wdg = 0; 321 ViewConfigureWidget *wdg = 0;
318 ViewConfigureDialog* dlg = 0; 322 ViewConfigureDialog* dlg = 0;
319 if ( factory ) { 323 if ( factory ) {
320 // Save the filters so the dialog has the latest set 324 // Save the filters so the dialog has the latest set
321 Filter::save( mCore->config(), "Filter", mFilterList ); 325 Filter::save( mCore->config(), "Filter", mFilterList );
322 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 326 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
323 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 327 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
324 } else { 328 } else {
325 qDebug("ViewManager::editView()::cannot find viewfactory "); 329 qDebug("ViewManager::editView()::cannot find viewfactory ");
326 return; 330 return;
327 } 331 }
328 if ( wdg ) { 332 if ( wdg ) {
329 dlg->setWidget( wdg ); 333 dlg->setWidget( wdg );
330 334
331#ifndef DESKTOP_VERSION 335#ifndef DESKTOP_VERSION
332 //dlg.setMaximumSize( 640, 480 ); 336 //dlg.setMaximumSize( 640, 480 );
333 //dlg->setGeometry( 40,40, 400, 300); 337 //dlg->setGeometry( 40,40, 400, 300);
334 dlg->showMaximized(); 338 dlg->showMaximized();
335#endif 339#endif
336 340
337 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 341 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
338 342
339 dlg->restoreSettings( mCore->config() ); 343 dlg->restoreSettings( mCore->config() );
340 344
341 if ( dlg->exec() ) { 345 if ( dlg->exec() ) {
342 dlg->saveSettings( mCore->config() ); 346 dlg->saveSettings( mCore->config() );
343 mActiveView->readConfig( mCore->config() ); 347 mActiveView->readConfig( mCore->config() );
344 348
345 // Set the proper filter in the view. By setting the combo 349 // Set the proper filter in the view. By setting the combo
346 // box, the activated slot will be called, which will push 350 // box, the activated slot will be called, which will push
347 // the filter to the view and refresh it. 351 // the filter to the view and refresh it.
348 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 352 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
349 mActionSelectFilter->setCurrentItem( 0 ); 353 mActionSelectFilter->setCurrentItem( 0 );
350 setActiveFilter( 0 ); 354 setActiveFilter( 0 );
351 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 355 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
352 setActiveFilter( mActionSelectFilter->currentItem() ); 356 setActiveFilter( mActionSelectFilter->currentItem() );
353 } else { 357 } else {
354 uint pos = filterPosition( mActiveView->defaultFilterName() ); 358 uint pos = filterPosition( mActiveView->defaultFilterName() );
355 mActionSelectFilter->setCurrentItem( pos ); 359 mActionSelectFilter->setCurrentItem( pos );
356 setActiveFilter( pos ); 360 setActiveFilter( pos );
357 } 361 }
358 mCore->setSearchFields( mActiveView->fields() ); 362 mCore->setSearchFields( mActiveView->fields() );
359//US performance optimization. setActiveFilter calls also mActiveView->refresh() 363//US performance optimization. setActiveFilter calls also mActiveView->refresh()
360//US mActiveView->refresh(); 364//US mActiveView->refresh();
361 365
362 366
363 //US this is a bugfix, that we get notified if we change a views configuration 367 //US this is a bugfix, that we get notified if we change a views configuration
364 emit modified(); 368 emit modified();
365 369
366 } 370 }
367 371
368 } 372 }
369 delete dlg; 373 delete dlg;
370} 374}
371 375
372void ViewManager::deleteView() 376void ViewManager::deleteView()
373{ 377{
374 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 378 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
375 .arg( mActiveView->caption() ); 379 .arg( mActiveView->caption() );
376 QString caption = i18n( "Confirm Delete" ); 380 QString caption = i18n( "Confirm Delete" );
377 381
378 382
379 if (QMessageBox::information( this, caption, 383 if (QMessageBox::information( this, caption,
380 text, 384 text,
381 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 385 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
382 { 386 {
383 mViewNameList.remove( mActiveView->caption() ); 387 mViewNameList.remove( mActiveView->caption() );
384 388
385 // remove the view from the config file 389 // remove the view from the config file
386 KConfig *config = mCore->config(); 390 KConfig *config = mCore->config();
387 config->deleteGroup( mActiveView->caption() ); 391 config->deleteGroup( mActiveView->caption() );
388 392
389 mViewDict.remove( mActiveView->caption() ); 393 mViewDict.remove( mActiveView->caption() );
390 mActiveView = 0; 394 mActiveView = 0;
391 395
392 // we are in an invalid state now, but that should be fixed after 396 // we are in an invalid state now, but that should be fixed after
393 // we emit the signal 397 // we emit the signal
394 mActionSelectView->setItems( mViewNameList ); 398 mActionSelectView->setItems( mViewNameList );
395 if ( mViewNameList.count() > 0 ) { 399 if ( mViewNameList.count() > 0 ) {
396 mActionSelectView->setCurrentItem( 0 ); 400 mActionSelectView->setCurrentItem( 0 );
397 setActiveView( mViewNameList[ 0 ] ); 401 setActiveView( mViewNameList[ 0 ] );
398 } 402 }
399 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 403 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
400 } 404 }
401} 405}
402 406
403void ViewManager::addView() 407void ViewManager::addView()
404{ 408{
405 AddViewDialog dialog( &mViewFactoryDict, this ); 409 AddViewDialog dialog( &mViewFactoryDict, this );
406 410
407 if ( dialog.exec() ) { 411 if ( dialog.exec() ) {
408 QString newName = dialog.viewName(); 412 QString newName = dialog.viewName();
409 QString type = dialog.viewType(); 413 QString type = dialog.viewType();
410 414
411 // Check for name conflicts 415 // Check for name conflicts
412 bool firstConflict = true; 416 bool firstConflict = true;
413 int numTries = 1; 417 int numTries = 1;
414 while ( mViewNameList.contains( newName ) > 0 ) { 418 while ( mViewNameList.contains( newName ) > 0 ) {
415 if ( !firstConflict ) { 419 if ( !firstConflict ) {
416 newName = newName.left( newName.length() - 4 ); 420 newName = newName.left( newName.length() - 4 );
417 firstConflict = false; 421 firstConflict = false;
418 } 422 }
419 423
420 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 424 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
421 numTries++; 425 numTries++;
422 } 426 }
423 427
424 // Add the new one to the list 428 // Add the new one to the list
425 mViewNameList.append( newName ); 429 mViewNameList.append( newName );
426 430
427 // write the view to the config file, 431 // write the view to the config file,
428 KConfig *config = mCore->config(); 432 KConfig *config = mCore->config();
429 433
430 config->deleteGroup( newName ); 434 config->deleteGroup( newName );
431 435
432 KConfigGroupSaver saver( config, newName ); 436 KConfigGroupSaver saver( config, newName );
433 437
434 config->writeEntry( "Type", type ); 438 config->writeEntry( "Type", type );
435 439
436 // try to set the active view 440 // try to set the active view
437 mActionSelectView->setItems( mViewNameList ); 441 mActionSelectView->setItems( mViewNameList );
438 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 442 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
439 setActiveView( newName ); 443 setActiveView( newName );
440 444
441 editView(); 445 editView();
442 446
443 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 447 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
444 } 448 }
445} 449}
446 450
447void ViewManager::createViewFactories() 451void ViewManager::createViewFactories()
448{ 452{
449#ifndef KAB_EMBEDDED 453#ifndef KAB_EMBEDDED
450 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 454 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
451 KTrader::OfferList::ConstIterator it; 455 KTrader::OfferList::ConstIterator it;
452 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 456 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
453 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 457 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
454 continue; 458 continue;
455 459
456 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 460 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
457 461
458 if ( !factory ) { 462 if ( !factory ) {
459 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 463 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
460 continue; 464 continue;
461 } 465 }
462 466
463 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 467 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
464 468
465 if ( !viewFactory ) { 469 if ( !viewFactory ) {
466 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 470 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
467 continue; 471 continue;
468 } 472 }
469 473
470 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 474 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
471 } 475 }
472 476
473#else //KAB_EMBEDDED 477#else //KAB_EMBEDDED
474 ViewFactory* viewFactory = new IconViewFactory(); 478 ViewFactory* viewFactory = new IconViewFactory();
475 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 479 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
476// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
477 481
478 viewFactory = new TableViewFactory(); 482 viewFactory = new TableViewFactory();
479 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 483 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
480// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
481 485
482 viewFactory = new CardViewFactory(); 486 viewFactory = new CardViewFactory();
483 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 487 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
484// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 488// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
485 489
486#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
487 491
488} 492}
489 493
490void ViewManager::dropped( QDropEvent *e ) 494void ViewManager::dropped( QDropEvent *e )
491{ 495{
492 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
493 496
494#ifndef KAB_EMBEDDED 497#ifndef KAB_EMBEDDED
495 498
496 QString clipText, vcards; 499 QString clipText, vcards;
497 KURL::List urls; 500 KURL::List urls;
498 501
499 if ( KURLDrag::decode( e, urls) ) { 502 if ( KURLDrag::decode( e, urls) ) {
500 KURL::List::Iterator it = urls.begin(); 503 KURL::List::Iterator it = urls.begin();
501 int c = urls.count(); 504 int c = urls.count();
502 if ( c > 1 ) { 505 if ( c > 1 ) {
503 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 506 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
504 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 507 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
505 for ( ; it != urls.end(); ++it ) 508 for ( ; it != urls.end(); ++it )
506 emit urlDropped( *it ); 509 emit urlDropped( *it );
507 } 510 }
508 } else if ( c == 1 ) 511 } else if ( c == 1 )
509 emit urlDropped( *it ); 512 emit urlDropped( *it );
510 } else if ( KVCardDrag::decode( e, vcards ) ) { 513 } else if ( KVCardDrag::decode( e, vcards ) ) {
511 KABC::Addressee addr; 514 KABC::Addressee addr;
512 KABC::VCardConverter converter; 515 KABC::VCardConverter converter;
513 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 516 QStringList list = QStringList::split( "\r\n\r\n", vcards );
514 QStringList::Iterator it; 517 QStringList::Iterator it;
515 for ( it = list.begin(); it != list.end(); ++it ) { 518 for ( it = list.begin(); it != list.end(); ++it ) {
516 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
517 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
518 if ( a.isEmpty() ) { 521 if ( a.isEmpty() ) {
519 mCore->addressBook()->insertAddressee( addr ); 522 mCore->addressBook()->insertAddressee( addr );
520 emit modified(); 523 emit modified();
521 } 524 }
522 } 525 }
523 } 526 }
524 527
525 mActiveView->refresh(); 528 mActiveView->refresh();
526 } 529 }
527#else //KAB_EMBEDDED 530#else //KAB_EMBEDDED
528qDebug("ViewManager::dropped() has to be changed!!" ); 531qDebug("ViewManager::dropped() has to be changed!!" );
529#endif //KAB_EMBEDDED 532#endif //KAB_EMBEDDED
530 533
531} 534}
532 535
533void ViewManager::startDrag() 536void ViewManager::startDrag()
534{ 537{
535 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
536 539
537#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
538 541
539 // Get the list of all the selected addressees 542 // Get the list of all the selected addressees
540 KABC::Addressee::List addrList; 543 KABC::Addressee::List addrList;
541 QStringList uidList = selectedUids(); 544 QStringList uidList = selectedUids();
542 QStringList::Iterator iter; 545 QStringList::Iterator iter;
543 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
544 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 547 addrList.append( mCore->addressBook()->findByUid( *iter ) );
545 548
546 KMultipleDrag *drag = new KMultipleDrag( this ); 549 KMultipleDrag *drag = new KMultipleDrag( this );
547 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
548 KABC::Addressee::List::Iterator it; 551 KABC::Addressee::List::Iterator it;
549 QStringList vcards; 552 QStringList vcards;
550 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 553 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
551 QString vcard = QString::null; 554 QString vcard = QString::null;
552 KABC::VCardConverter converter; 555 KABC::VCardConverter converter;
553 if ( converter.addresseeToVCard( *it, vcard ) ) 556 if ( converter.addresseeToVCard( *it, vcard ) )
554 vcards.append( vcard ); 557 vcards.append( vcard );
555 } 558 }
556 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
557 560
558 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
559 drag->dragCopy(); 562 drag->dragCopy();
560 563
561#else //KAB_EMBEDDED 564#else //KAB_EMBEDDED
562qDebug("ViewManager::startDrag() has to be changed!!" ); 565qDebug("ViewManager::startDrag() has to be changed!!" );
563#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
564 567
565} 568}
566void ViewManager::doSearch( const QString& s,KABC::Field *field ) 569void ViewManager::doSearch( const QString& s,KABC::Field *field )
567{ 570{
568 if ( mActiveView ) 571 if ( mActiveView )
569 mActiveView->doSearch( s, field ); 572 mActiveView->doSearch( s, field );
570 573
571} 574}
572void ViewManager::setActiveFilter( int index ) 575void ViewManager::setActiveFilter( int index )
573{ 576{
574 Filter currentFilter; 577 Filter currentFilter;
575 578
576 if ( ( index - 1 ) < 0 ) 579 if ( ( index - 1 ) < 0 )
577 currentFilter = Filter(); 580 currentFilter = Filter();
578 else 581 else
579 currentFilter = mFilterList[ index - 1 ]; 582 currentFilter = mFilterList[ index - 1 ];
580 583
581 // Check if we have a view. Since the filter combo is created before 584 // Check if we have a view. Since the filter combo is created before
582 // the view, this slot could be called before there is a valid view. 585 // the view, this slot could be called before there is a valid view.
583 if ( mActiveView ) { 586 if ( mActiveView ) {
584 mActiveView->setFilter( currentFilter ); 587 mActiveView->setFilter( currentFilter );
585 mActiveView->refresh(); 588 mActiveView->refresh();
586 emit selected( QString::null ); 589 emit selected( QString::null );
587 } 590 }
588} 591}
589 592
590void ViewManager::configureFilters() 593void ViewManager::configureFilters()
591{ 594{
592 FilterDialog dlg( this ); 595 FilterDialog dlg( this );
593 596
594 dlg.setFilters( mFilterList ); 597 dlg.setFilters( mFilterList );
595 598
596 if ( dlg.exec() ) 599 if ( dlg.exec() )
597 mFilterList = dlg.filters(); 600 mFilterList = dlg.filters();
598 601
599 uint pos = mActionSelectFilter->currentItem(); 602 uint pos = mActionSelectFilter->currentItem();
600 mActionSelectFilter->setItems( filterNames() ); 603 mActionSelectFilter->setItems( filterNames() );
601 mActionSelectFilter->setCurrentItem( pos ); 604 mActionSelectFilter->setCurrentItem( pos );
602 setActiveFilter( pos ); 605 setActiveFilter( pos );
603 int cw = 150; 606 int cw = 150;
604 if (QApplication::desktop()->width() == 480 ) 607 if (QApplication::desktop()->width() == 480 )
605 cw = 0; 608 cw = 0;
606 mActionSelectFilter->setComboWidth( cw ); 609 mActionSelectFilter->setComboWidth( cw );
607 saveSettings(); 610 saveSettings();
608} 611}
609 612
610QStringList ViewManager::filterNames() const 613QStringList ViewManager::filterNames() const
611{ 614{
612 QStringList names( i18n( "No Filter" ) ); 615 QStringList names( i18n( "No Filter" ) );
613 616
614 Filter::List::ConstIterator it; 617 Filter::List::ConstIterator it;
615 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
616 names.append( (*it).name() ); 619 names.append( (*it).name() );
617 620
618 return names; 621 return names;
619} 622}
620Filter ViewManager::getFilterByName( const QString &name ) const 623Filter ViewManager::getFilterByName( const QString &name ) const
621{ 624{
622 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
623 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
624 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
625 return (*it); 628 return (*it);
626 629
627 return Filter(); 630 return Filter();
628} 631}
629 632
630int ViewManager::filterPosition( const QString &name ) const 633int ViewManager::filterPosition( const QString &name ) const
631{ 634{
632 int pos = 0; 635 int pos = 0;
633 636
634 Filter::List::ConstIterator it; 637 Filter::List::ConstIterator it;
635 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
636 if ( name == (*it).name() ) 639 if ( name == (*it).name() )
637 return pos + 1; 640 return pos + 1;
638 641
639 return 0; 642 return 0;
640} 643}
641 644
642void ViewManager::initActions() 645void ViewManager::initActions()
643{ 646{
644//US <ActionList name="view_loadedviews"/> 647//US <ActionList name="view_loadedviews"/>
645//US <Separator/> 648//US <Separator/>
646 649
647#ifdef KAB_EMBEDDED 650#ifdef KAB_EMBEDDED
648 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
649 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
650 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
651#endif //KAB_EMBEDDED 654#endif //KAB_EMBEDDED
652 655
653 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
654#if KDE_VERSION >= 309 657#if KDE_VERSION >= 309
655 mActionSelectView->setMenuAccelsEnabled( false ); 658 mActionSelectView->setMenuAccelsEnabled( false );
656#endif 659#endif
657 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
658 SLOT( setActiveView( const QString& ) ) ); 661 SLOT( selectView( const QString& ) ) );
659 662
660 663
661#ifdef KAB_EMBEDDED 664#ifdef KAB_EMBEDDED
662 mActionSelectView->plug(viewmenu); 665 mActionSelectView->plug(viewmenu);
663 viewmenu->insertSeparator(); 666 viewmenu->insertSeparator();
664#endif //KAB_EMBEDDED 667#endif //KAB_EMBEDDED
665 668
666 KAction *action; 669 KAction *action;
667 670
668 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
669 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 672 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
670#ifndef KAB_EMBEDDED 673#ifndef KAB_EMBEDDED
671 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
672#else //KAB_EMBEDDED 675#else //KAB_EMBEDDED
673 action->plug(viewmenu); 676 action->plug(viewmenu);
674#endif //KAB_EMBEDDED 677#endif //KAB_EMBEDDED
675 678
676 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
677 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 680 SLOT( addView() ), mCore->actionCollection(), "view_add" );
678#ifndef KAB_EMBEDDED 681#ifndef KAB_EMBEDDED
679 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
680#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
681 action->plug(viewmenu); 684 action->plug(viewmenu);
682#endif //KAB_EMBEDDED 685#endif //KAB_EMBEDDED
683 686
684 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
685 this, SLOT( deleteView() ), 688 this, SLOT( deleteView() ),
686 mCore->actionCollection(), "view_delete" ); 689 mCore->actionCollection(), "view_delete" );
687#ifndef KAB_EMBEDDED 690#ifndef KAB_EMBEDDED
688 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
689#else //KAB_EMBEDDED 692#else //KAB_EMBEDDED
690 mActionDeleteView->plug(viewmenu); 693 mActionDeleteView->plug(viewmenu);
691 viewmenu->insertSeparator(); 694 viewmenu->insertSeparator();
692#endif //KAB_EMBEDDED 695#endif //KAB_EMBEDDED
693 696
694#ifndef KAB_EMBEDDED 697#ifndef KAB_EMBEDDED
695 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
696 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 699 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
697 "view_refresh" ); 700 "view_refresh" );
698 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
699#else //KAB_EMBEDDED 702#else //KAB_EMBEDDED
700 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
701 SLOT( refreshView()), mCore->actionCollection(), 704 SLOT( refreshView()), mCore->actionCollection(),
702 "view_refresh" ); 705 "view_refresh" );
703 action->plug(viewmenu); 706 action->plug(viewmenu);
704 viewmenu->insertSeparator(); 707 viewmenu->insertSeparator();
705#endif //KAB_EMBEDDED 708#endif //KAB_EMBEDDED
706 709
707 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
708 SLOT( configureFilters() ), mCore->actionCollection(), 711 SLOT( configureFilters() ), mCore->actionCollection(),
709 "options_edit_filters" ); 712 "options_edit_filters" );
710 713
711 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
712#if KDE_VERSION >= 309 715#if KDE_VERSION >= 309
713 mActionSelectFilter->setMenuAccelsEnabled( false ); 716 mActionSelectFilter->setMenuAccelsEnabled( false );
714#endif 717#endif
715 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 718 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
716 SLOT( setActiveFilter( int ) ) ); 719 SLOT( setActiveFilter( int ) ) );
717 720
718#ifdef KAB_EMBEDDED 721#ifdef KAB_EMBEDDED
719 action->plug(settingsmenu); 722 action->plug(settingsmenu);
720 mActionSelectFilter->plug(viewmenu); 723 mActionSelectFilter->plug(viewmenu);
721#endif //KAB_EMBEDDED 724#endif //KAB_EMBEDDED
722 725
723} 726}
724 727
725void ViewManager::initGUI() 728void ViewManager::initGUI()
726{ 729{
727 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
728 mViewWidgetStack = new QWidgetStack( this ); 731 mViewWidgetStack = new QWidgetStack( this );
729 layout->addWidget( mViewWidgetStack ); 732 layout->addWidget( mViewWidgetStack );
730} 733}
731 734
732#ifndef KAB_EMBEDDED 735#ifndef KAB_EMBEDDED
733#include "viewmanager.moc" 736#include "viewmanager.moc"
734#endif //KAB_EMBEDDED 737#endif //KAB_EMBEDDED
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index dff9998..ab5d372 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -1,160 +1,161 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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#ifndef VIEWMANAGER_H 24#ifndef VIEWMANAGER_H
25#define VIEWMANAGER_H 25#define VIEWMANAGER_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <kaddressbookview.h> 29#include <kaddressbookview.h>
30#include <qdict.h> 30#include <qdict.h>
31#include "filter.h" 31#include "filter.h"
32 32
33class KAction; 33class KAction;
34class KSelectAction; 34class KSelectAction;
35 35
36class KABCore; 36class KABCore;
37class QWidgetStack; 37class QWidgetStack;
38class QDropEvent; 38class QDropEvent;
39 39
40namespace KABC { class AddressBook; } 40namespace KABC { class AddressBook; }
41 41
42/** 42/**
43 The view manager manages the views and everything related to them. The 43 The view manager manages the views and everything related to them. The
44 manager will load the views at startup and display a view when told to 44 manager will load the views at startup and display a view when told to
45 make one active. 45 make one active.
46 46
47 The view manager will also create and manage all dialogs directly related to 47 The view manager will also create and manage all dialogs directly related to
48 views (ie: AddView, ConfigureView, DeleteView, etc). 48 views (ie: AddView, ConfigureView, DeleteView, etc).
49 */ 49 */
50class ViewManager : public QWidget 50class ViewManager : public QWidget
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); 54 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
55 ~ViewManager(); 55 ~ViewManager();
56 56
57 void restoreSettings(); 57 void restoreSettings();
58 void saveSettings(); 58 void saveSettings();
59 void doSearch( const QString& s ,KABC::Field *field ); 59 void doSearch( const QString& s ,KABC::Field *field );
60 60
61 void unloadViews(); 61 void unloadViews();
62 KSelectAction * getFilterAction() { return mActionSelectFilter; } 62 KSelectAction * getFilterAction() { return mActionSelectFilter; }
63 Filter getFilterByName( const QString &name ) const; 63 Filter getFilterByName( const QString &name ) const;
64 64
65 QStringList selectedUids() const; 65 QStringList selectedUids() const;
66 QStringList selectedEmails() const; 66 QStringList selectedEmails() const;
67 KABC::Addressee::List selectedAddressees() const; 67 KABC::Addressee::List selectedAddressees() const;
68 void setListSelected(QStringList); 68 void setListSelected(QStringList);
69 void setFocusAV(); 69 void setFocusAV();
70 70
71 public slots: 71 public slots:
72 void printView() { if (mActiveView) mActiveView->printMyView() ;} 72 void printView() { if (mActiveView) mActiveView->printMyView() ;}
73 void scrollUP(); 73 void scrollUP();
74 void scrollDOWN(); 74 void scrollDOWN();
75 75
76//US void setSelected( const QString &uid = QString::null, bool selected = true ); 76//US void setSelected( const QString &uid = QString::null, bool selected = true );
77 void setSelected( const QString &uid, bool); 77 void setSelected( const QString &uid, bool);
78//US added another method with no parameter, since my moc compiler does not support default parameters. 78//US added another method with no parameter, since my moc compiler does not support default parameters.
79 void setSelected(); 79 void setSelected();
80 80
81 81
82 82
83//US added another method with no parameter, since my moc compiler does not support default parameters. 83//US added another method with no parameter, since my moc compiler does not support default parameters.
84 void refreshView(); 84 void refreshView();
85 void refreshView( const QString &uid); 85 void refreshView( const QString &uid);
86 86
87 void editView(); 87 void editView();
88 void deleteView(); 88 void deleteView();
89 void addView(); 89 void addView();
90 90
91 protected slots: 91 protected slots:
92 /** 92 /**
93 Called whenever the user drops something in the active view. 93 Called whenever the user drops something in the active view.
94 This method will try to decode what was dropped, and if it was 94 This method will try to decode what was dropped, and if it was
95 a valid addressee, add it to the addressbook. 95 a valid addressee, add it to the addressbook.
96 */ 96 */
97 void dropped( QDropEvent* ); 97 void dropped( QDropEvent* );
98 98
99 /** 99 /**
100 Called whenever the user attempts to start a drag in the view. 100 Called whenever the user attempts to start a drag in the view.
101 This method will convert all the selected addressees into text (vcard) 101 This method will convert all the selected addressees into text (vcard)
102 and create a drag object. 102 and create a drag object.
103 */ 103 */
104 void startDrag(); 104 void startDrag();
105 105
106 signals: 106 signals:
107 /** 107 /**
108 Emitted whenever the user selects an entry in the view. 108 Emitted whenever the user selects an entry in the view.
109 */ 109 */
110 void selected( const QString &uid ); 110 void selected( const QString &uid );
111 void deleteRequest( ); 111 void deleteRequest( );
112 112
113 /** 113 /**
114 Emitted whenever the user activates an entry in the view. 114 Emitted whenever the user activates an entry in the view.
115 */ 115 */
116 void executed( const QString &uid ); 116 void executed( const QString &uid );
117 117
118 /** 118 /**
119 Emitted whenever the address book is modified in some way. 119 Emitted whenever the address book is modified in some way.
120 */ 120 */
121 void modified(); 121 void modified();
122 122
123 /** 123 /**
124 Emitted whenever a url is dragged on a view. 124 Emitted whenever a url is dragged on a view.
125 */ 125 */
126 void urlDropped( const KURL& ); 126 void urlDropped( const KURL& );
127 127
128 private slots: 128 private slots:
129 void selectView( const QString &name );
129 void setActiveView( const QString &name ); 130 void setActiveView( const QString &name );
130 void setActiveFilter( int index ); 131 void setActiveFilter( int index );
131 void configureFilters(); 132 void configureFilters();
132 133
133 private: 134 private:
134 void createViewFactories(); 135 void createViewFactories();
135 QStringList filterNames() const; 136 QStringList filterNames() const;
136 int filterPosition( const QString &name ) const; 137 int filterPosition( const QString &name ) const;
137 QStringList viewNames() const; 138 QStringList viewNames() const;
138 int viewPosition( const QString &name ) const; 139 int viewPosition( const QString &name ) const;
139 void initActions(); 140 void initActions();
140 void initGUI(); 141 void initGUI();
141 142
142 KABCore *mCore; 143 KABCore *mCore;
143 144
144 Filter mCurrentFilter; 145 Filter mCurrentFilter;
145 Filter::List mFilterList; 146 Filter::List mFilterList;
146 147
147 QDict<KAddressBookView> mViewDict; 148 QDict<KAddressBookView> mViewDict;
148 QDict<ViewFactory> mViewFactoryDict; 149 QDict<ViewFactory> mViewFactoryDict;
149 QStringList mViewNameList; 150 QStringList mViewNameList;
150 151
151 QWidgetStack *mViewWidgetStack; 152 QWidgetStack *mViewWidgetStack;
152 KAddressBookView *mActiveView; 153 KAddressBookView *mActiveView;
153 154
154 KAction *mActionDeleteView; 155 KAction *mActionDeleteView;
155 KSelectAction *mActionSelectFilter; 156 KSelectAction *mActionSelectFilter;
156 KSelectAction *mActionSelectView; 157 KSelectAction *mActionSelectView;
157 158
158}; 159};
159 160
160#endif 161#endif
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index e9226c0..1ad1728 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -1,2266 +1,2266 @@
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, 1998 Stephan Kulow (coolo@kde.org) 4 (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
6 (C) 1997, 1998 Sven Radej (radej@kde.org) 6 (C) 1997, 1998 Sven Radej (radej@kde.org)
7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
8 (C) 1999 Chris Schlaeger (cs@kde.org) 8 (C) 1999 Chris Schlaeger (cs@kde.org)
9 (C) 1999 Kurt Granroth (granroth@kde.org) 9 (C) 1999 Kurt Granroth (granroth@kde.org)
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#ifdef KDE_USE_FINAL 26#ifdef KDE_USE_FINAL
27#undef Always 27#undef Always
28#include <qdockwindow.h> 28#include <qdockwindow.h>
29#endif 29#endif
30 30
31 31
32 32
33#include "ktoolbar.h" 33#include "ktoolbar.h"
34#include "kmainwindow.h" 34#include "kmainwindow.h"
35 35
36#include <string.h> 36#include <string.h>
37 37
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qtooltip.h> 39#include <qtooltip.h>
40#include <qdrawutil.h> 40#include <qdrawutil.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qrect.h> 42#include <qrect.h>
43#include <qobjectlist.h> 43#include <qobjectlist.h>
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qstyle.h> 45#include <qstyle.h>
46#include <qapplication.h> 46#include <qapplication.h>
47 47
48//US #include <config.h> 48//US #include <config.h>
49 49
50#include "klineedit.h" 50#include "klineedit.h"
51#include "kseparator.h" 51#include "kseparator.h"
52#include <klocale.h> 52#include <klocale.h>
53#include <kapplication.h> 53#include <kapplication.h>
54#include <kaction.h> 54#include <kaction.h>
55#include <kstdaction.h> 55#include <kstdaction.h>
56#include <kglobal.h> 56#include <kglobal.h>
57#include <kconfig.h> 57#include <kconfig.h>
58#include <kiconloader.h> 58#include <kiconloader.h>
59#include <kcombobox.h> 59#include <kcombobox.h>
60//US #include <kpopupmenu.h> 60//US #include <kpopupmenu.h>
61//US #include <kanimwidget.h> 61//US #include <kanimwidget.h>
62//US #include <kipc.h> 62//US #include <kipc.h>
63//US #include <kwin.h> 63//US #include <kwin.h>
64#include <kdebug.h> 64#include <kdebug.h>
65#include <qlayout.h> 65#include <qlayout.h>
66 66
67#include "ktoolbarbutton.h" 67#include "ktoolbarbutton.h"
68 68
69//US 69//US
70#include "kconfigbase.h" 70#include "kconfigbase.h"
71 71
72#include <qpopupmenu.h> 72#include <qpopupmenu.h>
73#include <qmainwindow.h> 73#include <qmainwindow.h>
74 74
75enum { 75enum {
76 CONTEXT_TOP = 0, 76 CONTEXT_TOP = 0,
77 CONTEXT_LEFT = 1, 77 CONTEXT_LEFT = 1,
78 CONTEXT_RIGHT = 2, 78 CONTEXT_RIGHT = 2,
79 CONTEXT_BOTTOM = 3, 79 CONTEXT_BOTTOM = 3,
80 CONTEXT_FLOAT = 4, 80 CONTEXT_FLOAT = 4,
81 CONTEXT_FLAT = 5, 81 CONTEXT_FLAT = 5,
82 CONTEXT_ICONS = 6, 82 CONTEXT_ICONS = 6,
83 CONTEXT_TEXT = 7, 83 CONTEXT_TEXT = 7,
84 CONTEXT_TEXTRIGHT = 8, 84 CONTEXT_TEXTRIGHT = 8,
85 CONTEXT_TEXTUNDER = 9, 85 CONTEXT_TEXTUNDER = 9,
86 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before 86 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before
87}; 87};
88 88
89class KToolBarPrivate 89class KToolBarPrivate
90{ 90{
91public: 91public:
92 KToolBarPrivate() { 92 KToolBarPrivate() {
93 m_iconSize = 0; 93 m_iconSize = 0;
94 m_iconText = KToolBar::IconOnly; 94 m_iconText = KToolBar::IconOnly;
95 m_highlight = true; 95 m_highlight = true;
96 m_transparent = true; 96 m_transparent = true;
97 m_honorStyle = false; 97 m_honorStyle = false;
98 98
99 m_enableContext = true; 99 m_enableContext = true;
100 100
101 m_xmlguiClient = 0; 101 m_xmlguiClient = 0;
102 m_configurePlugged = false; 102 m_configurePlugged = false;
103 103
104//US oldPos = Qt::DockUnmanaged; 104//US oldPos = Qt::DockUnmanaged;
105 oldPos = QMainWindow::Unmanaged; 105 oldPos = QMainWindow::Unmanaged;
106 106
107 modified = m_isHorizontal = positioned = FALSE; 107 modified = m_isHorizontal = positioned = FALSE;
108 108
109 HiddenDefault = false; 109 HiddenDefault = false;
110 IconSizeDefault = 0; 110 IconSizeDefault = 0;
111 IconTextDefault = "IconOnly"; 111 IconTextDefault = "IconOnly";
112 IndexDefault = -1; 112 IndexDefault = -1;
113 NewLineDefault = false; 113 NewLineDefault = false;
114 OffsetDefault = -1; 114 OffsetDefault = -1;
115 PositionDefault = "Top"; 115 PositionDefault = "Top";
116 idleButtons.setAutoDelete(true); 116 idleButtons.setAutoDelete(true);
117 } 117 }
118 118
119 int m_iconSize; 119 int m_iconSize;
120 KToolBar::IconText m_iconText; 120 KToolBar::IconText m_iconText;
121 bool m_highlight : 1; 121 bool m_highlight : 1;
122 bool m_transparent : 1; 122 bool m_transparent : 1;
123 bool m_honorStyle : 1; 123 bool m_honorStyle : 1;
124 bool m_isHorizontal : 1; 124 bool m_isHorizontal : 1;
125 bool m_enableContext : 1; 125 bool m_enableContext : 1;
126 bool m_configurePlugged : 1; 126 bool m_configurePlugged : 1;
127 bool modified : 1; 127 bool modified : 1;
128 bool positioned : 1; 128 bool positioned : 1;
129 129
130 QWidget *m_parent; 130 QWidget *m_parent;
131 131
132 QMainWindow::ToolBarDock oldPos; 132 QMainWindow::ToolBarDock oldPos;
133 133
134 KXMLGUIClient *m_xmlguiClient; 134 KXMLGUIClient *m_xmlguiClient;
135 135
136 struct ToolBarInfo 136 struct ToolBarInfo
137 { 137 {
138//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} 138//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {}
139 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} 139 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {}
140//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 140//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
141 ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 141 ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
142 int index, offset; 142 int index, offset;
143 bool newline; 143 bool newline;
144//US Qt::Dock dock; 144//US Qt::Dock dock;
145 QMainWindow::ToolBarDock dock; 145 QMainWindow::ToolBarDock dock;
146 }; 146 };
147 147
148 ToolBarInfo toolBarInfo; 148 ToolBarInfo toolBarInfo;
149 QValueList<int> iconSizes; 149 QValueList<int> iconSizes;
150 QTimer repaintTimer; 150 QTimer repaintTimer;
151 151
152 // Default Values. 152 // Default Values.
153 bool HiddenDefault; 153 bool HiddenDefault;
154 int IconSizeDefault; 154 int IconSizeDefault;
155 QString IconTextDefault; 155 QString IconTextDefault;
156 int IndexDefault; 156 int IndexDefault;
157 bool NewLineDefault; 157 bool NewLineDefault;
158 int OffsetDefault; 158 int OffsetDefault;
159 QString PositionDefault; 159 QString PositionDefault;
160 160
161 QPtrList<QWidget> idleButtons; 161 QPtrList<QWidget> idleButtons;
162}; 162};
163 163
164KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, 164KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent,
165 const char* name ) 165 const char* name )
166 :QFrame( parent, name ), line( l ) 166 :QFrame( parent, name ), line( l )
167{ 167{
168 connect( parent, SIGNAL(orientationChanged(Orientation)), 168 connect( parent, SIGNAL(orientationChanged(Orientation)),
169 this, SLOT(setOrientation(Orientation)) ); 169 this, SLOT(setOrientation(Orientation)) );
170 setOrientation( o ); 170 setOrientation( o );
171 setBackgroundMode( parent->backgroundMode() ); 171 setBackgroundMode( parent->backgroundMode() );
172 setBackgroundOrigin( ParentOrigin ); 172 setBackgroundOrigin( ParentOrigin );
173} 173}
174 174
175void KToolBarSeparator::setOrientation( Orientation o ) 175void KToolBarSeparator::setOrientation( Orientation o )
176{ 176{
177 orient = o; 177 orient = o;
178 if ( line ) { 178 if ( line ) {
179 if ( orientation() == Vertical ) 179 if ( orientation() == Vertical )
180 setFrameStyle( HLine + Sunken ); 180 setFrameStyle( HLine + Sunken );
181 else 181 else
182 setFrameStyle( VLine + Sunken ); 182 setFrameStyle( VLine + Sunken );
183 } else { 183 } else {
184 setFrameStyle( NoFrame ); 184 setFrameStyle( NoFrame );
185 } 185 }
186} 186}
187 187
188void KToolBarSeparator::styleChange( QStyle& ) 188void KToolBarSeparator::styleChange( QStyle& )
189{ 189{
190 setOrientation( orient ); 190 setOrientation( orient );
191} 191}
192 192
193QSize KToolBarSeparator::sizeHint() const 193QSize KToolBarSeparator::sizeHint() const
194{ 194{
195 return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); 195 return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 );
196} 196}
197 197
198QSizePolicy KToolBarSeparator::sizePolicy() const 198QSizePolicy KToolBarSeparator::sizePolicy() const
199{ 199{
200 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); 200 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
201} 201}
202 202
203KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) 203KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig )
204#ifdef DESKTOP_VERSION 204#ifdef DESKTOP_VERSION
205 : QToolBar( QString::fromLatin1( name ), 205 : QToolBar( QString::fromLatin1( name ),
206 parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 206 parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0,
207 parent, FALSE, 207 parent, FALSE,
208 name ? name : "mainToolBar") 208 name ? name : "mainToolBar")
209#else 209#else
210 : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 210 : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0,
211 QString::fromLatin1( name )) 211 QString::fromLatin1( name ))
212 212
213 213
214#endif 214#endif
215{ 215{
216 init( readConfig, honorStyle ); 216 init( readConfig, honorStyle );
217} 217}
218 218
219KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 219KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 : QToolBar( QString::fromLatin1( name ), 221 : QToolBar( QString::fromLatin1( name ),
222 parentWindow, dock, newLine, 222 parentWindow, dock, newLine,
223 name ? name : "mainToolBar") 223 name ? name : "mainToolBar")
224#else 224#else
225 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 225 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
226 226
227 227
228#endif 228#endif
229 229
230{ 230{
231 init( readConfig, honorStyle ); 231 init( readConfig, honorStyle );
232} 232}
233 233
234KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 234KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
235#ifdef DESKTOP_VERSION 235#ifdef DESKTOP_VERSION
236 : QToolBar( QString::fromLatin1( name ), 236 : QToolBar( QString::fromLatin1( name ),
237 parentWindow, dock, newLine, 237 parentWindow, dock, newLine,
238 name ? name : "mainToolBar") 238 name ? name : "mainToolBar")
239#else 239#else
240 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 240 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
241 241
242 242
243#endif 243#endif
244 244
245{ 245{
246 init( readConfig, honorStyle ); 246 init( readConfig, honorStyle );
247} 247}
248 248
249KToolBar::~KToolBar() 249KToolBar::~KToolBar()
250{ 250{
251 inshutdownprocess = true; 251 inshutdownprocess = true;
252 emit toolbarDestroyed(); 252 emit toolbarDestroyed();
253 delete d; 253 delete d;
254} 254}
255 255
256void KToolBar::init( bool readConfig, bool honorStyle ) 256void KToolBar::init( bool readConfig, bool honorStyle )
257{ 257{
258 inshutdownprocess = false; 258 inshutdownprocess = false;
259 d = new KToolBarPrivate; 259 d = new KToolBarPrivate;
260 setFullSize( TRUE ); 260 setFullSize( TRUE );
261 d->m_honorStyle = honorStyle; 261 d->m_honorStyle = honorStyle;
262 context = 0; 262 context = 0;
263 layoutTimer = new QTimer( this ); 263 layoutTimer = new QTimer( this );
264 connect( layoutTimer, SIGNAL( timeout() ), 264 connect( layoutTimer, SIGNAL( timeout() ),
265 this, SLOT( rebuildLayout() ) ); 265 this, SLOT( rebuildLayout() ) );
266 connect( &(d->repaintTimer), SIGNAL( timeout() ), 266 connect( &(d->repaintTimer), SIGNAL( timeout() ),
267 this, SLOT( slotRepaint() ) ); 267 this, SLOT( slotRepaint() ) );
268/*US 268/*US
269 if ( kapp ) { // may be null when started inside designer 269 if ( kapp ) { // may be null when started inside designer
270 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); 270 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged()));
271 // request notification of changes in icon style 271 // request notification of changes in icon style
272 kapp->addKipcEventMask(KIPC::IconChanged); 272 kapp->addKipcEventMask(KIPC::IconChanged);
273 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); 273 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int)));
274 } 274 }
275*/ 275*/
276 // finally, read in our configurable settings 276 // finally, read in our configurable settings
277 if ( readConfig ) 277 if ( readConfig )
278 slotReadConfig(); 278 slotReadConfig();
279 279
280 if ( mainWindow() ) 280 if ( mainWindow() )
281 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), 281 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ),
282 this, SLOT( toolBarPosChanged( QToolBar * ) ) ); 282 this, SLOT( toolBarPosChanged( QToolBar * ) ) );
283 283
284 // Hack to make sure we recalculate our size when we dock. 284 // Hack to make sure we recalculate our size when we dock.
285//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); 285//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) );
286} 286}
287 287
288int KToolBar::insertButton(const QString& icon, int id, bool enabled, 288int KToolBar::insertButton(const QString& icon, int id, bool enabled,
289 const QString& text, int index/*US, KInstance *_instance*/ ) 289 const QString& text, int index/*US, KInstance *_instance*/ )
290{ 290{
291 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); 291 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ );
292 292
293 insertWidgetInternal( button, index, id ); 293 insertWidgetInternal( button, index, id );
294 button->setEnabled( enabled ); 294 button->setEnabled( enabled );
295 doConnections( button ); 295 doConnections( button );
296 return index; 296 return index;
297} 297}
298 298
299 299
300int KToolBar::insertButton(const QString& icon, int id, const char *signal, 300int KToolBar::insertButton(const QString& icon, int id, const char *signal,
301 const QObject *receiver, const char *slot, 301 const QObject *receiver, const char *slot,
302 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) 302 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ )
303{ 303{
304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); 304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/);
305 insertWidgetInternal( button, index, id ); 305 insertWidgetInternal( button, index, id );
306 button->setEnabled( enabled ); 306 button->setEnabled( enabled );
307 connect( button, signal, receiver, slot ); 307 connect( button, signal, receiver, slot );
308 doConnections( button ); 308 doConnections( button );
309 return index; 309 return index;
310} 310}
311 311
312 312
313int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, 313int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled,
314 const QString& text, int index ) 314 const QString& text, int index )
315{ 315{
316 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 316 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
317 insertWidgetInternal( button, index, id ); 317 insertWidgetInternal( button, index, id );
318 button->setEnabled( enabled ); 318 button->setEnabled( enabled );
319 doConnections( button ); 319 doConnections( button );
320 return index; 320 return index;
321} 321}
322#if 0 322#if 0
323 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 323 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
324 SLOT( slotActivated() ), 324 SLOT( slotActivated() ),
325 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 325 d->isEnabled(), d->plainText(), index/*US, instance*/ );
326#endif 326#endif
327 327
328int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, 328int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal,
329 const QObject *receiver, const char *slot, 329 const QObject *receiver, const char *slot,
330 bool enabled, const QString& text, 330 bool enabled, const QString& text,
331 int index ) 331 int index )
332{ 332{
333 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 333 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
334 insertWidgetInternal( button, index, id ); 334 insertWidgetInternal( button, index, id );
335 button->setEnabled( enabled ); 335 button->setEnabled( enabled );
336 connect( button, signal, receiver, slot ); 336 connect( button, signal, receiver, slot );
337 doConnections( button ); 337 doConnections( button );
338 return index; 338 return index;
339} 339}
340 340
341 341
342int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, 342int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup,
343 bool enabled, const QString &text, int index ) 343 bool enabled, const QString &text, int index )
344{ 344{
345 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); 345 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text );
346 insertWidgetInternal( button, index, id ); 346 insertWidgetInternal( button, index, id );
347 button->setEnabled( enabled ); 347 button->setEnabled( enabled );
348 button->setPopup( popup ); 348 button->setPopup( popup );
349 doConnections( button ); 349 doConnections( button );
350 return index; 350 return index;
351} 351}
352 352
353 353
354int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 354int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
355 bool enabled, const QString &text, int index ) 355 bool enabled, const QString &text, int index )
356{ 356{
357 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); 357 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text );
358 insertWidgetInternal( button, index, id ); 358 insertWidgetInternal( button, index, id );
359 button->setEnabled( enabled ); 359 button->setEnabled( enabled );
360 button->setPopup( popup ); 360 button->setPopup( popup );
361 doConnections( button ); 361 doConnections( button );
362 return index; 362 return index;
363} 363}
364 364
365 365
366int KToolBar::insertLined (const QString& text, int id, 366int KToolBar::insertLined (const QString& text, int id,
367 const char *signal, 367 const char *signal,
368 const QObject *receiver, const char *slot, 368 const QObject *receiver, const char *slot,
369 bool enabled , 369 bool enabled ,
370 const QString& toolTipText, 370 const QString& toolTipText,
371 int size, int index ) 371 int size, int index )
372{ 372{
373 KLineEdit *lined = new KLineEdit ( this, 0 ); 373 KLineEdit *lined = new KLineEdit ( this, 0 );
374 if ( !toolTipText.isEmpty() ) 374 if ( !toolTipText.isEmpty() )
375 QToolTip::add( lined, toolTipText ); 375 QToolTip::add( lined, toolTipText );
376 if ( size > 0 ) 376 if ( size > 0 )
377 lined->setMinimumWidth( size ); 377 lined->setMinimumWidth( size );
378 insertWidgetInternal( lined, index, id ); 378 insertWidgetInternal( lined, index, id );
379 connect( lined, signal, receiver, slot ); 379 connect( lined, signal, receiver, slot );
380 lined->setText(text); 380 lined->setText(text);
381 lined->setEnabled( enabled ); 381 lined->setEnabled( enabled );
382 return index; 382 return index;
383} 383}
384 384
385int KToolBar::insertCombo (const QStringList &list, int id, bool writable, 385int KToolBar::insertCombo (const QStringList &list, int id, bool writable,
386 const char *signal, const QObject *receiver, 386 const char *signal, const QObject *receiver,
387 const char *slot, bool enabled, 387 const char *slot, bool enabled,
388 const QString& tooltiptext, 388 const QString& tooltiptext,
389 int size, int index, 389 int size, int index,
390 QComboBox::Policy policy ) 390 QComboBox::Policy policy )
391{ 391{
392//US KComboBox *combo = new KComboBox ( writable, this ); 392//US KComboBox *combo = new KComboBox ( writable, this );
393 KComboBox *combo = new KComboBox ( this ); 393 KComboBox *combo = new KComboBox ( this );
394 combo->setEditable(writable); 394 combo->setEditable(writable);
395 395
396 insertWidgetInternal( combo, index, id ); 396 insertWidgetInternal( combo, index, id );
397 combo->insertStringList (list); 397 combo->insertStringList (list);
398 combo->setInsertionPolicy(policy); 398 combo->setInsertionPolicy(policy);
399 combo->setEnabled( enabled ); 399 combo->setEnabled( enabled );
400 if ( !tooltiptext.isEmpty() ) 400 if ( !tooltiptext.isEmpty() )
401 QToolTip::add( combo, tooltiptext ); 401 QToolTip::add( combo, tooltiptext );
402 if ( size > 0 ) 402 if ( size > 0 )
403 combo->setMinimumWidth( size ); 403 combo->setMinimumWidth( size );
404 if (!tooltiptext.isNull()) 404 if (!tooltiptext.isNull())
405 QToolTip::add( combo, tooltiptext ); 405 QToolTip::add( combo, tooltiptext );
406 406
407 if ( signal && receiver && slot ) 407 if ( signal && receiver && slot )
408 connect ( combo, signal, receiver, slot ); 408 connect ( combo, signal, receiver, slot );
409 return index; 409 return index;
410} 410}
411 411
412 412
413int KToolBar::insertCombo (const QString& text, int id, bool writable, 413int KToolBar::insertCombo (const QString& text, int id, bool writable,
414 const char *signal, QObject *receiver, 414 const char *signal, QObject *receiver,
415 const char *slot, bool enabled, 415 const char *slot, bool enabled,
416 const QString& tooltiptext, 416 const QString& tooltiptext,
417 int size, int index, 417 int size, int index,
418 QComboBox::Policy policy ) 418 QComboBox::Policy policy )
419{ 419{
420//US KComboBox *combo = new KComboBox ( writable, this ); 420//US KComboBox *combo = new KComboBox ( writable, this );
421 KComboBox *combo = new KComboBox ( this ); 421 KComboBox *combo = new KComboBox ( this );
422 combo->setEditable(writable); 422 combo->setEditable(writable);
423 423
424 insertWidgetInternal( combo, index, id ); 424 insertWidgetInternal( combo, index, id );
425 combo->insertItem (text); 425 combo->insertItem (text);
426 combo->setInsertionPolicy(policy); 426 combo->setInsertionPolicy(policy);
427 combo->setEnabled( enabled ); 427 combo->setEnabled( enabled );
428 if ( !tooltiptext.isEmpty() ) 428 if ( !tooltiptext.isEmpty() )
429 QToolTip::add( combo, tooltiptext ); 429 QToolTip::add( combo, tooltiptext );
430 if ( size > 0 ) 430 if ( size > 0 )
431 combo->setMinimumWidth( size ); 431 combo->setMinimumWidth( size );
432 if (!tooltiptext.isNull()) 432 if (!tooltiptext.isNull())
433 QToolTip::add( combo, tooltiptext ); 433 QToolTip::add( combo, tooltiptext );
434 connect (combo, signal, receiver, slot); 434 connect (combo, signal, receiver, slot);
435 return index; 435 return index;
436} 436}
437 437
438int KToolBar::insertSeparator(int index, int id) 438int KToolBar::insertSeparator(int index, int id)
439{ 439{
440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); 440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" );
441 insertWidgetInternal( w, index, id ); 441 insertWidgetInternal( w, index, id );
442 return index; 442 return index;
443} 443}
444 444
445int KToolBar::insertLineSeparator(int index, int id) 445int KToolBar::insertLineSeparator(int index, int id)
446{ 446{
447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); 447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" );
448 insertWidgetInternal( w, index, id ); 448 insertWidgetInternal( w, index, id );
449 return index; 449 return index;
450} 450}
451 451
452 452
453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) 453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index)
454{ 454{
455 // removeWidgetInternal( widget ); // in case we already have it ? 455 // removeWidgetInternal( widget ); // in case we already have it ?
456 insertWidgetInternal( widget, index, id ); 456 insertWidgetInternal( widget, index, id );
457 return index; 457 return index;
458} 458}
459/*US 459/*US
460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, 460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot,
461 const QString& icons, int index ) 461 const QString& icons, int index )
462{ 462{
463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); 463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
464 insertWidgetInternal( anim, index, id ); 464 insertWidgetInternal( anim, index, id );
465 465
466 if ( receiver ) 466 if ( receiver )
467 connect( anim, SIGNAL(clicked()), receiver, slot); 467 connect( anim, SIGNAL(clicked()), receiver, slot);
468 468
469 return index; 469 return index;
470} 470}
471 471
472KAnimWidget *KToolBar::animatedWidget( int id ) 472KAnimWidget *KToolBar::animatedWidget( int id )
473{ 473{
474 Id2WidgetMap::Iterator it = id2widget.find( id ); 474 Id2WidgetMap::Iterator it = id2widget.find( id );
475 if ( it == id2widget.end() ) 475 if ( it == id2widget.end() )
476 return 0; 476 return 0;
477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) 477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) )
478 return (KAnimWidget*)(*it); 478 return (KAnimWidget*)(*it);
479 QObjectList *l = queryList( "KAnimWidget" ); 479 QObjectList *l = queryList( "KAnimWidget" );
480 if ( !l || !l->first() ) { 480 if ( !l || !l->first() ) {
481 delete l; 481 delete l;
482 return 0; 482 return 0;
483 } 483 }
484 484
485 for ( QObject *o = l->first(); o; o = l->next() ) { 485 for ( QObject *o = l->first(); o; o = l->next() ) {
486 if ( o->inherits( "KAnimWidget" ) ) 486 if ( o->inherits( "KAnimWidget" ) )
487 { 487 {
488 delete l; 488 delete l;
489 return (KAnimWidget*)o; 489 return (KAnimWidget*)o;
490 } 490 }
491 } 491 }
492 492
493 delete l; 493 delete l;
494 return 0; 494 return 0;
495} 495}
496*/ 496*/
497 497
498void KToolBar::addConnection (int id, const char *signal, 498void KToolBar::addConnection (int id, const char *signal,
499 const QObject *receiver, const char *slot) 499 const QObject *receiver, const char *slot)
500{ 500{
501 Id2WidgetMap::Iterator it = id2widget.find( id ); 501 Id2WidgetMap::Iterator it = id2widget.find( id );
502 if ( it == id2widget.end() ) 502 if ( it == id2widget.end() )
503 return; 503 return;
504 if ( (*it) ) 504 if ( (*it) )
505 connect( (*it), signal, receiver, slot ); 505 connect( (*it), signal, receiver, slot );
506} 506}
507 507
508void KToolBar::setItemEnabled( int id, bool enabled ) 508void KToolBar::setItemEnabled( int id, bool enabled )
509{ 509{
510 Id2WidgetMap::Iterator it = id2widget.find( id ); 510 Id2WidgetMap::Iterator it = id2widget.find( id );
511 if ( it == id2widget.end() ) 511 if ( it == id2widget.end() )
512 return; 512 return;
513 if ( (*it) ) 513 if ( (*it) )
514 (*it)->setEnabled( enabled ); 514 (*it)->setEnabled( enabled );
515} 515}
516 516
517 517
518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) 518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
519{ 519{
520 Id2WidgetMap::Iterator it = id2widget.find( id ); 520 Id2WidgetMap::Iterator it = id2widget.find( id );
521 if ( it == id2widget.end() ) 521 if ( it == id2widget.end() )
522 return; 522 return;
523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
524 KToolBarButton * button = (KToolBarButton *)( *it ); 524 KToolBarButton * button = (KToolBarButton *)( *it );
525 if ( button ) 525 if ( button )
526 button->setPixmap( _pixmap ); 526 button->setPixmap( _pixmap );
527} 527}
528 528
529 529
530void KToolBar::setButtonIcon( int id, const QString& _icon ) 530void KToolBar::setButtonIcon( int id, const QString& _icon )
531{ 531{
532 Id2WidgetMap::Iterator it = id2widget.find( id ); 532 Id2WidgetMap::Iterator it = id2widget.find( id );
533 if ( it == id2widget.end() ) 533 if ( it == id2widget.end() )
534 return; 534 return;
535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
536 KToolBarButton * button = (KToolBarButton *)( *it ); 536 KToolBarButton * button = (KToolBarButton *)( *it );
537 if ( button ) 537 if ( button )
538 button->setIcon( _icon ); 538 button->setIcon( _icon );
539} 539}
540 540
541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) 541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset )
542{ 542{
543 Id2WidgetMap::Iterator it = id2widget.find( id ); 543 Id2WidgetMap::Iterator it = id2widget.find( id );
544 if ( it == id2widget.end() ) 544 if ( it == id2widget.end() )
545 return; 545 return;
546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
547 KToolBarButton * button = (KToolBarButton *)( *it ); 547 KToolBarButton * button = (KToolBarButton *)( *it );
548 if ( button ) 548 if ( button )
549 button->setIconSet( iconset ); 549 button->setIconSet( iconset );
550} 550}
551 551
552 552
553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) 553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle )
554{ 554{
555 Id2WidgetMap::Iterator it = id2widget.find( id ); 555 Id2WidgetMap::Iterator it = id2widget.find( id );
556 if ( it == id2widget.end() ) 556 if ( it == id2widget.end() )
557 return; 557 return;
558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
559 KToolBarButton * button = (KToolBarButton *)( *it ); 559 KToolBarButton * button = (KToolBarButton *)( *it );
560 if ( button ) 560 if ( button )
561 button->setDelayedPopup( _popup, toggle ); 561 button->setDelayedPopup( _popup, toggle );
562} 562}
563 563
564 564
565void KToolBar::setAutoRepeat (int id, bool flag) 565void KToolBar::setAutoRepeat (int id, bool flag)
566{ 566{
567 Id2WidgetMap::Iterator it = id2widget.find( id ); 567 Id2WidgetMap::Iterator it = id2widget.find( id );
568 if ( it == id2widget.end() ) 568 if ( it == id2widget.end() )
569 return; 569 return;
570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
571 KToolBarButton * button = (KToolBarButton *)( *it ); 571 KToolBarButton * button = (KToolBarButton *)( *it );
572 if ( button ) 572 if ( button )
573 button->setAutoRepeat( flag ); 573 button->setAutoRepeat( flag );
574} 574}
575 575
576 576
577void KToolBar::setToggle (int id, bool flag ) 577void KToolBar::setToggle (int id, bool flag )
578{ 578{
579 Id2WidgetMap::Iterator it = id2widget.find( id ); 579 Id2WidgetMap::Iterator it = id2widget.find( id );
580 if ( it == id2widget.end() ) 580 if ( it == id2widget.end() )
581 return; 581 return;
582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
583 KToolBarButton * button = (KToolBarButton *)( *it ); 583 KToolBarButton * button = (KToolBarButton *)( *it );
584 if ( button ) 584 if ( button )
585 button->setToggle( flag ); 585 button->setToggle( flag );
586} 586}
587 587
588 588
589void KToolBar::toggleButton (int id) 589void KToolBar::toggleButton (int id)
590{ 590{
591 Id2WidgetMap::Iterator it = id2widget.find( id ); 591 Id2WidgetMap::Iterator it = id2widget.find( id );
592 if ( it == id2widget.end() ) 592 if ( it == id2widget.end() )
593 return; 593 return;
594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
595 KToolBarButton * button = (KToolBarButton *)( *it ); 595 KToolBarButton * button = (KToolBarButton *)( *it );
596 if ( button ) 596 if ( button )
597 button->toggle(); 597 button->toggle();
598} 598}
599 599
600 600
601void KToolBar::setButton (int id, bool flag) 601void KToolBar::setButton (int id, bool flag)
602{ 602{
603 Id2WidgetMap::Iterator it = id2widget.find( id ); 603 Id2WidgetMap::Iterator it = id2widget.find( id );
604 if ( it == id2widget.end() ) 604 if ( it == id2widget.end() )
605 return; 605 return;
606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
607 KToolBarButton * button = (KToolBarButton *)( *it ); 607 KToolBarButton * button = (KToolBarButton *)( *it );
608 if ( button ) 608 if ( button )
609 button->on( flag ); 609 button->on( flag );
610} 610}
611 611
612 612
613bool KToolBar::isButtonOn (int id) const 613bool KToolBar::isButtonOn (int id) const
614{ 614{
615 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 615 Id2WidgetMap::ConstIterator it = id2widget.find( id );
616 if ( it == id2widget.end() ) 616 if ( it == id2widget.end() )
617 return false; 617 return false;
618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
619 KToolBarButton * button = (KToolBarButton *)( *it ); 619 KToolBarButton * button = (KToolBarButton *)( *it );
620 return button ? button->isOn() : false; 620 return button ? button->isOn() : false;
621} 621}
622 622
623 623
624void KToolBar::setLinedText (int id, const QString& text) 624void KToolBar::setLinedText (int id, const QString& text)
625{ 625{
626 Id2WidgetMap::Iterator it = id2widget.find( id ); 626 Id2WidgetMap::Iterator it = id2widget.find( id );
627 if ( it == id2widget.end() ) 627 if ( it == id2widget.end() )
628 return; 628 return;
629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
630 QLineEdit * lineEdit = (QLineEdit *)( *it ); 630 QLineEdit * lineEdit = (QLineEdit *)( *it );
631 if ( lineEdit ) 631 if ( lineEdit )
632 lineEdit->setText( text ); 632 lineEdit->setText( text );
633} 633}
634 634
635 635
636QString KToolBar::getLinedText (int id) const 636QString KToolBar::getLinedText (int id) const
637{ 637{
638 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 638 Id2WidgetMap::ConstIterator it = id2widget.find( id );
639 if ( it == id2widget.end() ) 639 if ( it == id2widget.end() )
640 return QString::null; 640 return QString::null;
641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
642 QLineEdit * lineEdit = (QLineEdit *)( *it ); 642 QLineEdit * lineEdit = (QLineEdit *)( *it );
643 return lineEdit ? lineEdit->text() : QString::null; 643 return lineEdit ? lineEdit->text() : QString::null;
644} 644}
645 645
646 646
647void KToolBar::insertComboItem (int id, const QString& text, int index) 647void KToolBar::insertComboItem (int id, const QString& text, int index)
648{ 648{
649 Id2WidgetMap::Iterator it = id2widget.find( id ); 649 Id2WidgetMap::Iterator it = id2widget.find( id );
650 if ( it == id2widget.end() ) 650 if ( it == id2widget.end() )
651 return; 651 return;
652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
653 QComboBox * comboBox = (QComboBox *)( *it ); 653 QComboBox * comboBox = (QComboBox *)( *it );
654 if (comboBox) 654 if (comboBox)
655 comboBox->insertItem( text, index ); 655 comboBox->insertItem( text, index );
656} 656}
657 657
658void KToolBar::insertComboList (int id, const QStringList &list, int index) 658void KToolBar::insertComboList (int id, const QStringList &list, int index)
659{ 659{
660 Id2WidgetMap::Iterator it = id2widget.find( id ); 660 Id2WidgetMap::Iterator it = id2widget.find( id );
661 if ( it == id2widget.end() ) 661 if ( it == id2widget.end() )
662 return; 662 return;
663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
664 QComboBox * comboBox = (QComboBox *)( *it ); 664 QComboBox * comboBox = (QComboBox *)( *it );
665 if (comboBox) 665 if (comboBox)
666 comboBox->insertStringList( list, index ); 666 comboBox->insertStringList( list, index );
667} 667}
668 668
669 669
670void KToolBar::removeComboItem (int id, int index) 670void KToolBar::removeComboItem (int id, int index)
671{ 671{
672 Id2WidgetMap::Iterator it = id2widget.find( id ); 672 Id2WidgetMap::Iterator it = id2widget.find( id );
673 if ( it == id2widget.end() ) 673 if ( it == id2widget.end() )
674 return; 674 return;
675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
676 QComboBox * comboBox = (QComboBox *)( *it ); 676 QComboBox * comboBox = (QComboBox *)( *it );
677 if (comboBox) 677 if (comboBox)
678 comboBox->removeItem( index ); 678 comboBox->removeItem( index );
679} 679}
680 680
681 681
682void KToolBar::setCurrentComboItem (int id, int index) 682void KToolBar::setCurrentComboItem (int id, int index)
683{ 683{
684 Id2WidgetMap::Iterator it = id2widget.find( id ); 684 Id2WidgetMap::Iterator it = id2widget.find( id );
685 if ( it == id2widget.end() ) 685 if ( it == id2widget.end() )
686 return; 686 return;
687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
688 QComboBox * comboBox = (QComboBox *)( *it ); 688 QComboBox * comboBox = (QComboBox *)( *it );
689 if (comboBox) 689 if (comboBox)
690 comboBox->setCurrentItem( index ); 690 comboBox->setCurrentItem( index );
691} 691}
692 692
693 693
694void KToolBar::changeComboItem (int id, const QString& text, int index) 694void KToolBar::changeComboItem (int id, const QString& text, int index)
695{ 695{
696 Id2WidgetMap::Iterator it = id2widget.find( id ); 696 Id2WidgetMap::Iterator it = id2widget.find( id );
697 if ( it == id2widget.end() ) 697 if ( it == id2widget.end() )
698 return; 698 return;
699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
700 QComboBox * comboBox = (QComboBox *)( *it ); 700 QComboBox * comboBox = (QComboBox *)( *it );
701 if (comboBox) 701 if (comboBox)
702 comboBox->changeItem( text, index ); 702 comboBox->changeItem( text, index );
703} 703}
704 704
705 705
706void KToolBar::clearCombo (int id) 706void KToolBar::clearCombo (int id)
707{ 707{
708 Id2WidgetMap::Iterator it = id2widget.find( id ); 708 Id2WidgetMap::Iterator it = id2widget.find( id );
709 if ( it == id2widget.end() ) 709 if ( it == id2widget.end() )
710 return; 710 return;
711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
712 QComboBox * comboBox = (QComboBox *)( *it ); 712 QComboBox * comboBox = (QComboBox *)( *it );
713 if (comboBox) 713 if (comboBox)
714 comboBox->clear(); 714 comboBox->clear();
715} 715}
716 716
717 717
718QString KToolBar::getComboItem (int id, int index) const 718QString KToolBar::getComboItem (int id, int index) const
719{ 719{
720 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 720 Id2WidgetMap::ConstIterator it = id2widget.find( id );
721 if ( it == id2widget.end() ) 721 if ( it == id2widget.end() )
722 return QString::null; 722 return QString::null;
723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
724 QComboBox * comboBox = (QComboBox *)( *it ); 724 QComboBox * comboBox = (QComboBox *)( *it );
725 return comboBox ? comboBox->text( index ) : QString::null; 725 return comboBox ? comboBox->text( index ) : QString::null;
726} 726}
727 727
728 728
729KComboBox * KToolBar::getCombo(int id) 729KComboBox * KToolBar::getCombo(int id)
730{ 730{
731 Id2WidgetMap::Iterator it = id2widget.find( id ); 731 Id2WidgetMap::Iterator it = id2widget.find( id );
732 if ( it == id2widget.end() ) 732 if ( it == id2widget.end() )
733 return 0; 733 return 0;
734//US return dynamic_cast<KComboBox *>( *it ); 734//US return dynamic_cast<KComboBox *>( *it );
735 return (KComboBox *)( *it ); 735 return (KComboBox *)( *it );
736} 736}
737 737
738 738
739KLineEdit * KToolBar::getLined (int id) 739KLineEdit * KToolBar::getLined (int id)
740{ 740{
741 Id2WidgetMap::Iterator it = id2widget.find( id ); 741 Id2WidgetMap::Iterator it = id2widget.find( id );
742 if ( it == id2widget.end() ) 742 if ( it == id2widget.end() )
743 return 0; 743 return 0;
744//US return dynamic_cast<KLineEdit *>( *it ); 744//US return dynamic_cast<KLineEdit *>( *it );
745 return (KLineEdit *)( *it ); 745 return (KLineEdit *)( *it );
746} 746}
747 747
748 748
749KToolBarButton * KToolBar::getButton (int id) 749KToolBarButton * KToolBar::getButton (int id)
750{ 750{
751 Id2WidgetMap::Iterator it = id2widget.find( id ); 751 Id2WidgetMap::Iterator it = id2widget.find( id );
752 if ( it == id2widget.end() ) 752 if ( it == id2widget.end() )
753 return 0; 753 return 0;
754//US return dynamic_cast<KToolBarButton *>( *it ); 754//US return dynamic_cast<KToolBarButton *>( *it );
755 return (KToolBarButton *)( *it ); 755 return (KToolBarButton *)( *it );
756} 756}
757 757
758 758
759void KToolBar::alignItemRight (int id, bool right ) 759void KToolBar::alignItemRight (int id, bool right )
760{ 760{
761 Id2WidgetMap::Iterator it = id2widget.find( id ); 761 Id2WidgetMap::Iterator it = id2widget.find( id );
762 if ( it == id2widget.end() ) 762 if ( it == id2widget.end() )
763 return; 763 return;
764 if ( rightAligned && !right && (*it) == rightAligned ) 764 if ( rightAligned && !right && (*it) == rightAligned )
765 rightAligned = 0; 765 rightAligned = 0;
766 if ( (*it) && right ) 766 if ( (*it) && right )
767 rightAligned = (*it); 767 rightAligned = (*it);
768} 768}
769 769
770 770
771QWidget *KToolBar::getWidget (int id) 771QWidget *KToolBar::getWidget (int id)
772{ 772{
773 Id2WidgetMap::Iterator it = id2widget.find( id ); 773 Id2WidgetMap::Iterator it = id2widget.find( id );
774 return ( it == id2widget.end() ) ? 0 : (*it); 774 return ( it == id2widget.end() ) ? 0 : (*it);
775} 775}
776 776
777 777
778void KToolBar::setItemAutoSized (int id, bool yes ) 778void KToolBar::setItemAutoSized (int id, bool yes )
779{ 779{
780 QWidget *w = getWidget(id); 780 QWidget *w = getWidget(id);
781 if ( w && yes ) 781 if ( w && yes )
782 setStretchableWidget( w ); 782 setStretchableWidget( w );
783} 783}
784 784
785 785
786void KToolBar::clear () 786void KToolBar::clear ()
787{ 787{
788 QToolBar::clear(); 788 QToolBar::clear();
789 widget2id.clear(); 789 widget2id.clear();
790 id2widget.clear(); 790 id2widget.clear();
791} 791}
792 792
793 793
794void KToolBar::removeItem(int id) 794void KToolBar::removeItem(int id)
795{ 795{
796 Id2WidgetMap::Iterator it = id2widget.find( id ); 796 Id2WidgetMap::Iterator it = id2widget.find( id );
797 if ( it == id2widget.end() ) 797 if ( it == id2widget.end() )
798 { 798 {
799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
800 return; 800 return;
801 } 801 }
802 QWidget * w = (*it); 802 QWidget * w = (*it);
803 id2widget.remove( id ); 803 id2widget.remove( id );
804 widget2id.remove( w ); 804 widget2id.remove( w );
805 widgets.removeRef( w ); 805 widgets.removeRef( w );
806 delete w; 806 delete w;
807} 807}
808 808
809 809
810void KToolBar::removeItemDelayed(int id) 810void KToolBar::removeItemDelayed(int id)
811{ 811{
812 Id2WidgetMap::Iterator it = id2widget.find( id ); 812 Id2WidgetMap::Iterator it = id2widget.find( id );
813 if ( it == id2widget.end() ) 813 if ( it == id2widget.end() )
814 { 814 {
815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
816 return; 816 return;
817 } 817 }
818 QWidget * w = (*it); 818 QWidget * w = (*it);
819 id2widget.remove( id ); 819 id2widget.remove( id );
820 widget2id.remove( w ); 820 widget2id.remove( w );
821 widgets.removeRef( w ); 821 widgets.removeRef( w );
822 822
823 w->blockSignals(true); 823 w->blockSignals(true);
824 d->idleButtons.append(w); 824 d->idleButtons.append(w);
825 layoutTimer->start( 50, TRUE ); 825 layoutTimer->start( 50, TRUE );
826} 826}
827 827
828 828
829void KToolBar::hideItem (int id) 829void KToolBar::hideItem (int id)
830{ 830{
831 QWidget *w = getWidget(id); 831 QWidget *w = getWidget(id);
832 if ( w ) 832 if ( w )
833 w->hide(); 833 w->hide();
834} 834}
835 835
836 836
837void KToolBar::showItem (int id) 837void KToolBar::showItem (int id)
838{ 838{
839 QWidget *w = getWidget(id); 839 QWidget *w = getWidget(id);
840 if ( w ) 840 if ( w )
841 w->show(); 841 w->show();
842} 842}
843 843
844 844
845int KToolBar::itemIndex (int id) 845int KToolBar::itemIndex (int id)
846{ 846{
847 QWidget *w = getWidget(id); 847 QWidget *w = getWidget(id);
848 return w ? widgets.findRef(w) : -1; 848 return w ? widgets.findRef(w) : -1;
849} 849}
850 850
851 851
852void KToolBar::setFullSize(bool flag ) 852void KToolBar::setFullSize(bool flag )
853{ 853{
854 setHorizontalStretchable( flag ); 854 setHorizontalStretchable( flag );
855 setVerticalStretchable( flag ); 855 setVerticalStretchable( flag );
856} 856}
857 857
858 858
859bool KToolBar::fullSize() const 859bool KToolBar::fullSize() const
860{ 860{
861 return isHorizontalStretchable() || isVerticalStretchable(); 861 return isHorizontalStretchable() || isVerticalStretchable();
862} 862}
863 863
864 864
865void KToolBar::enableMoving(bool flag ) 865void KToolBar::enableMoving(bool flag )
866{ 866{
867//US setMovingEnabled(flag); 867//US setMovingEnabled(flag);
868 this->mainWindow()->setToolBarsMovable(flag); 868 this->mainWindow()->setToolBarsMovable(flag);
869} 869}
870 870
871 871
872void KToolBar::setBarPos (BarPosition bpos) 872void KToolBar::setBarPos (BarPosition bpos)
873{ 873{
874 if ( !mainWindow() ) 874 if ( !mainWindow() )
875 return; 875 return;
876//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 876//US mainWindow()->moveDockWindow( this, (Dock)bpos );
877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
878} 878}
879 879
880 880
881KToolBar::BarPosition KToolBar::barPos() 881KToolBar::BarPosition KToolBar::barPos()
882{ 882{
883 if ( !(QMainWindow*)mainWindow() ) 883 if ( !(QMainWindow*)mainWindow() )
884 return KToolBar::Top; 884 return KToolBar::Top;
885//US Dock dock; 885//US Dock dock;
886 QMainWindow::ToolBarDock dock; 886 QMainWindow::ToolBarDock dock;
887 int dm1, dm2; 887 int dm1, dm2;
888 bool dm3; 888 bool dm3;
889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
890//US if ( dock == DockUnmanaged ) { 890//US if ( dock == DockUnmanaged ) {
891 if ( dock == QMainWindow::Unmanaged ) { 891 if ( dock == QMainWindow::Unmanaged ) {
892 return (KToolBar::BarPosition)Top; 892 return (KToolBar::BarPosition)Top;
893 } 893 }
894 return (BarPosition)dock; 894 return (BarPosition)dock;
895} 895}
896 896
897 897
898bool KToolBar::enable(BarStatus stat) 898bool KToolBar::enable(BarStatus stat)
899{ 899{
900 bool mystat = isVisible(); 900 bool mystat = isVisible();
901 901
902 if ( (stat == Toggle && mystat) || stat == Hide ) 902 if ( (stat == Toggle && mystat) || stat == Hide )
903 hide(); 903 hide();
904 else 904 else
905 show(); 905 show();
906 906
907 return isVisible() == mystat; 907 return isVisible() == mystat;
908} 908}
909 909
910 910
911void KToolBar::setMaxHeight ( int h ) 911void KToolBar::setMaxHeight ( int h )
912{ 912{
913 setMaximumHeight( h ); 913 setMaximumHeight( h );
914} 914}
915 915
916int KToolBar::maxHeight() 916int KToolBar::maxHeight()
917{ 917{
918 return maximumHeight(); 918 return maximumHeight();
919} 919}
920 920
921 921
922void KToolBar::setMaxWidth (int dw) 922void KToolBar::setMaxWidth (int dw)
923{ 923{
924 setMaximumWidth( dw ); 924 setMaximumWidth( dw );
925} 925}
926 926
927 927
928int KToolBar::maxWidth() 928int KToolBar::maxWidth()
929{ 929{
930 return maximumWidth(); 930 return maximumWidth();
931} 931}
932 932
933 933
934void KToolBar::setTitle (const QString& _title) 934void KToolBar::setTitle (const QString& _title)
935{ 935{
936 setLabel( _title ); 936 setLabel( _title );
937} 937}
938 938
939 939
940void KToolBar::enableFloating (bool ) 940void KToolBar::enableFloating (bool )
941{ 941{
942} 942}
943 943
944 944
945void KToolBar::setIconText(IconText it) 945void KToolBar::setIconText(IconText it)
946{ 946{
947 setIconText( it, true ); 947 setIconText( it, true );
948} 948}
949 949
950 950
951void KToolBar::setIconText(IconText icontext, bool update) 951void KToolBar::setIconText(IconText icontext, bool update)
952{ 952{
953 bool doUpdate=false; 953 bool doUpdate=false;
954 954
955 if (icontext != d->m_iconText) { 955 if (icontext != d->m_iconText) {
956 d->m_iconText = icontext; 956 d->m_iconText = icontext;
957 doUpdate=true; 957 doUpdate=true;
958 } 958 }
959 959
960 if (update == false) 960 if (update == false)
961 return; 961 return;
962 962
963 if (doUpdate) 963 if (doUpdate)
964 emit modechange(); // tell buttons what happened 964 emit modechange(); // tell buttons what happened
965 965
966 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 966 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
967 if ( mainWindow() ) { 967 if ( mainWindow() ) {
968 QMainWindow *mw = mainWindow(); 968 QMainWindow *mw = mainWindow();
969 mw->setUpdatesEnabled( FALSE ); 969 mw->setUpdatesEnabled( FALSE );
970 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 970 mw->setToolBarsMovable( !mw->toolBarsMovable() );
971 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 971 mw->setToolBarsMovable( !mw->toolBarsMovable() );
972 mw->setUpdatesEnabled( TRUE ); 972 mw->setUpdatesEnabled( TRUE );
973 } 973 }
974} 974}
975 975
976 976
977KToolBar::IconText KToolBar::iconText() const 977KToolBar::IconText KToolBar::iconText() const
978{ 978{
979 return d->m_iconText; 979 return d->m_iconText;
980} 980}
981 981
982 982
983void KToolBar::setIconSize(int size) 983void KToolBar::setIconSize(int size)
984{ 984{
985 setIconSize( size, true ); 985 setIconSize( size, true );
986} 986}
987 987
988void KToolBar::setIconSize(int size, bool update) 988void KToolBar::setIconSize(int size, bool update)
989{ 989{
990 bool doUpdate=false; 990 bool doUpdate=false;
991 991
992 if ( size != d->m_iconSize ) { 992 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 993 d->m_iconSize = size;
994 doUpdate=true; 994 doUpdate=true;
995 } 995 }
996 996
997 if (update == false) 997 if (update == false)
998 return; 998 return;
999 999
1000 if (doUpdate) 1000 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1001 emit modechange(); // tell buttons what happened
1002 1002
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1004 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1005 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1006 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1007 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1008 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1009 mw->setUpdatesEnabled( TRUE );
1010 } 1010 }
1011} 1011}
1012 1012
1013 1013
1014int KToolBar::iconSize() const 1014int KToolBar::iconSize() const
1015{ 1015{
1016/*US 1016/*US
1017 if ( !d->m_iconSize ) // default value? 1017 if ( !d->m_iconSize ) // default value?
1018 { 1018 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1019 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1021 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1023 }
1024 return d->m_iconSize; 1024 return d->m_iconSize;
1025*/ 1025*/
1026 int ret = 18; 1026 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 ) 1027 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1028 ret = 30;
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 QString configGroup = _configGroup; 1164 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1165 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1166 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1168
1169 QString position, icontext; 1169 QString position, icontext;
1170 int index; 1170 int index;
1171 getAttributes( position, icontext, index ); 1171 getAttributes( position, icontext, index );
1172 1172
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1174
1175 KConfigGroupSaver saver(config, configGroup); 1175 KConfigGroupSaver saver(config, configGroup);
1176 1176
1177 if ( position != d->PositionDefault ) 1177 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1178 config->writeEntry("Position", position);
1179 else 1179 else
1180 config->deleteEntry("Position"); 1180 config->deleteEntry("Position");
1181 1181
1182 if ( icontext != d->IconTextDefault ) 1182 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1183 config->writeEntry("IconText", icontext);
1184 else 1184 else
1185 config->deleteEntry("IconText"); 1185 config->deleteEntry("IconText");
1186 1186
1187 if ( iconSize() != d->IconSizeDefault ) 1187 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1188 config->writeEntry("IconSize", iconSize());
1189 else 1189 else
1190 config->deleteEntry("IconSize"); 1190 config->deleteEntry("IconSize");
1191 1191
1192 if ( isHidden() != d->HiddenDefault ) 1192 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1193 config->writeEntry("Hidden", isHidden());
1194 else 1194 else
1195 config->deleteEntry("Hidden"); 1195 config->deleteEntry("Hidden");
1196 1196
1197 if ( index != d->IndexDefault ) 1197 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1198 config->writeEntry( "Index", index );
1199 else 1199 else
1200 config->deleteEntry("Index"); 1200 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1201//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1202/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1203 config->writeEntry( "Offset", offset() );
1204 else 1204 else
1205*/ 1205*/
1206 config->deleteEntry("Offset"); 1206 config->deleteEntry("Offset");
1207 1207
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1208//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1209/*
1210 if ( newLine() != d->NewLineDefault ) 1210 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1211 config->writeEntry( "NewLine", newLine() );
1212 else 1212 else
1213*/ 1213*/
1214 config->deleteEntry("NewLine"); 1214 config->deleteEntry("NewLine");
1215} 1215}
1216 1216
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1218{
1219 d->m_xmlguiClient = client; 1219 d->m_xmlguiClient = client;
1220} 1220}
1221 1221
1222void KToolBar::setText( const QString & txt ) 1222void KToolBar::setText( const QString & txt )
1223{ 1223{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1224//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1226}
1227 1227
1228 1228
1229QString KToolBar::text() const 1229QString KToolBar::text() const
1230{ 1230{
1231 return label(); 1231 return label();
1232} 1232}
1233 1233
1234 1234
1235void KToolBar::doConnections( KToolBarButton *button ) 1235void KToolBar::doConnections( KToolBarButton *button )
1236{ 1236{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1243}
1244 1244
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1245void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1246{
1247 if ( !mainWindow() ) 1247 if ( !mainWindow() )
1248 return; 1248 return;
1249 QMainWindow *mw = mainWindow(); 1249 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1250 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1251 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1252 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1253 switch ( i ) {
1254 case -1: 1254 case -1:
1255 return; // popup cancelled 1255 return; // popup cancelled
1256 case CONTEXT_LEFT: 1256 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1257//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1258 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1259 break;
1260 case CONTEXT_RIGHT: 1260 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1261//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1262 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1263 break;
1264 case CONTEXT_TOP: 1264 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1265//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1266 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1267 break;
1268 case CONTEXT_BOTTOM: 1268 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1269//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1270 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1271 break;
1272 case CONTEXT_FLOAT: 1272 case CONTEXT_FLOAT:
1273 break; 1273 break;
1274 case CONTEXT_FLAT: 1274 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1275//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1276 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1277 break;
1278 case CONTEXT_ICONS: 1278 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1279 setIconText( IconOnly );
1280 break; 1280 break;
1281 case CONTEXT_TEXTRIGHT: 1281 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1282 setIconText( IconTextRight );
1283 break; 1283 break;
1284 case CONTEXT_TEXT: 1284 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1285 setIconText( TextOnly );
1286 break; 1286 break;
1287 case CONTEXT_TEXTUNDER: 1287 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1288 setIconText( IconTextBottom );
1289 break; 1289 break;
1290 default: 1290 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1291 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1292 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1293 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1295 }
1296/*US 1296/*US
1297 if ( mw->inherits("KMainWindow") ) 1297 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1298 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1299*/
1300 } 1300 }
1301 } 1301 }
1302} 1302}
1303 1303
1304 1304
1305void KToolBar::rebuildLayout() 1305void KToolBar::rebuildLayout()
1306{ 1306{
1307 1307
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1309 w->blockSignals(false);
1310 d->idleButtons.clear(); 1310 d->idleButtons.clear();
1311 1311
1312 layoutTimer->stop(); 1312 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1314 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1315 l->setMargin( 1 );
1316 // clear the old layout 1316 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1317 QLayoutIterator it = l->iterator();
1318 1318
1319 while ( it.current() ) { 1319 while ( it.current() ) {
1320 it.deleteCurrent(); 1320 it.deleteCurrent();
1321 } 1321 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1323 if ( w == rightAligned ) {
1324 continue; 1324 continue;
1325 } 1325 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1326 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1327 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1328 l->addSpacing( 6 );
1329 w->hide(); 1329 w->hide();
1330 continue; 1330 continue;
1331 } 1331 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1332 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1333 continue;
1334 l->addWidget( w ); 1334 l->addWidget( w );
1335 w->show(); 1335 w->show();
1336 } 1336 }
1337 if ( rightAligned ) { 1337 if ( rightAligned ) {
1338 l->addStretch(); 1338 l->addStretch();
1339 l->addWidget( rightAligned ); 1339 l->addWidget( rightAligned );
1340 rightAligned->show(); 1340 rightAligned->show();
1341 } 1341 }
1342 1342
1343 if ( fullSize() ) { 1343 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1345 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1347 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1348 if ( !rightAligned )
1349 l->addStretch(); 1349 l->addStretch();
1350 if ( stretchableWidget ) 1350 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1351 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1352 }
1353 l->invalidate(); 1353 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1355 //#endif //DESKTOP_VERSION
1356} 1356}
1357 1357
1358void KToolBar::childEvent( QChildEvent *e ) 1358void KToolBar::childEvent( QChildEvent *e )
1359{ 1359{
1360 1360
1361 if ( e->child()->isWidgetType() ) { 1361 if ( e->child()->isWidgetType() ) {
1362 QWidget * w = (QWidget*)e->child(); 1362 QWidget * w = (QWidget*)e->child();
1363 if ( e->type() == QEvent::ChildInserted ) { 1363 if ( e->type() == QEvent::ChildInserted ) {
1364 if ( !e->child()->inherits( "QPopupMenu" ) && 1364 if ( !e->child()->inherits( "QPopupMenu" ) &&
1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1366 1366
1367 // prevent items that have been explicitly inserted by insert*() from 1367 // prevent items that have been explicitly inserted by insert*() from
1368 // being inserted again 1368 // being inserted again
1369 if ( !widget2id.contains( w ) ) 1369 if ( !widget2id.contains( w ) )
1370 { 1370 {
1371 int dummy = -1; 1371 int dummy = -1;
1372 insertWidgetInternal( w, dummy, -1 ); 1372 insertWidgetInternal( w, dummy, -1 );
1373 } 1373 }
1374 } 1374 }
1375 } else { 1375 } else {
1376 removeWidgetInternal( w ); 1376 removeWidgetInternal( w );
1377 } 1377 }
1378 if ( isVisibleTo( 0 ) ) 1378 if ( isVisibleTo( 0 ) )
1379 { 1379 {
1380 QBoxLayout *l = boxLayout(); 1380 QBoxLayout *l = boxLayout();
1381 // QLayout *l = layout(); 1381 // QLayout *l = layout();
1382 1382
1383 // clear the old layout so that we don't get unnecassery layout 1383 // clear the old layout so that we don't get unnecassery layout
1384 // changes till we have rebuild the thing 1384 // changes till we have rebuild the thing
1385 QLayoutIterator it = l->iterator(); 1385 QLayoutIterator it = l->iterator();
1386 while ( it.current() ) { 1386 while ( it.current() ) {
1387 it.deleteCurrent(); 1387 it.deleteCurrent();
1388 } 1388 }
1389 layoutTimer->start( 50, TRUE ); 1389 layoutTimer->start( 50, TRUE );
1390 } 1390 }
1391 } 1391 }
1392 QToolBar::childEvent( e ); 1392 QToolBar::childEvent( e );
1393} 1393}
1394 1394
1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1396{ 1396{
1397 // we can't have it in widgets, or something is really wrong 1397 // we can't have it in widgets, or something is really wrong
1398 //widgets.removeRef( w ); 1398 //widgets.removeRef( w );
1399 1399
1400 connect( w, SIGNAL( destroyed() ), 1400 connect( w, SIGNAL( destroyed() ),
1401 this, SLOT( widgetDestroyed() ) ); 1401 this, SLOT( widgetDestroyed() ) );
1402 if ( index == -1 || index > (int)widgets.count() ) { 1402 if ( index == -1 || index > (int)widgets.count() ) {
1403 widgets.append( w ); 1403 widgets.append( w );
1404 index = (int)widgets.count(); 1404 index = (int)widgets.count();
1405 } 1405 }
1406 else 1406 else
1407 widgets.insert( index, w ); 1407 widgets.insert( index, w );
1408 if ( id == -1 ) 1408 if ( id == -1 )
1409 id = id2widget.count(); 1409 id = id2widget.count();
1410 id2widget.insert( id, w ); 1410 id2widget.insert( id, w );
1411 widget2id.insert( w, id ); 1411 widget2id.insert( w, id );
1412} 1412}
1413void KToolBar::repaintMe() 1413void KToolBar::repaintMe()
1414{ 1414{
1415 setUpdatesEnabled( true ); 1415 setUpdatesEnabled( true );
1416 QToolBar::repaint( true ); 1416 QToolBar::repaint( true );
1417 qDebug(" KToolBar::repaintMe() "); 1417 //qDebug(" KToolBar::repaintMe() ");
1418} 1418}
1419 1419
1420void KToolBar::showEvent( QShowEvent *e ) 1420void KToolBar::showEvent( QShowEvent *e )
1421{ 1421{
1422 QToolBar::showEvent( e ); 1422 QToolBar::showEvent( e );
1423 rebuildLayout(); 1423 rebuildLayout();
1424} 1424}
1425 1425
1426void KToolBar::setStretchableWidget( QWidget *w ) 1426void KToolBar::setStretchableWidget( QWidget *w )
1427{ 1427{
1428 QToolBar::setStretchableWidget( w ); 1428 QToolBar::setStretchableWidget( w );
1429 stretchableWidget = w; 1429 stretchableWidget = w;
1430} 1430}
1431 1431
1432QSizePolicy KToolBar::sizePolicy() const 1432QSizePolicy KToolBar::sizePolicy() const
1433{ 1433{
1434 if ( orientation() == Horizontal ) 1434 if ( orientation() == Horizontal )
1435 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1435 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1436 else 1436 else
1437 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1437 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1438} 1438}
1439 1439
1440QSize KToolBar::sizeHint() const 1440QSize KToolBar::sizeHint() const
1441{ 1441{
1442 return QToolBar::sizeHint(); 1442 return QToolBar::sizeHint();
1443#if 0 1443#if 0
1444 QWidget::polish(); 1444 QWidget::polish();
1445 static int iii = 0; 1445 static int iii = 0;
1446 ++iii; 1446 ++iii;
1447 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1447 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1448 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1448 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1449 switch( barPos() ) 1449 switch( barPos() )
1450 { 1450 {
1451 case KToolBar::Top: 1451 case KToolBar::Top:
1452 case KToolBar::Bottom: 1452 case KToolBar::Bottom:
1453 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1453 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1454 { 1454 {
1455 if ( w->inherits( "KToolBarSeparator" ) && 1455 if ( w->inherits( "KToolBarSeparator" ) &&
1456 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1456 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1457 { 1457 {
1458 minSize += QSize(6, 0); 1458 minSize += QSize(6, 0);
1459 } 1459 }
1460 else 1460 else
1461 { 1461 {
1462 QSize sh = w->sizeHint(); 1462 QSize sh = w->sizeHint();
1463 if (!sh.isValid()) 1463 if (!sh.isValid())
1464 sh = w->minimumSize(); 1464 sh = w->minimumSize();
1465 minSize = minSize.expandedTo(QSize(0, sh.height())); 1465 minSize = minSize.expandedTo(QSize(0, sh.height()));
1466 minSize += QSize(sh.width()+1, 0); 1466 minSize += QSize(sh.width()+1, 0);
1467 } 1467 }
1468 } 1468 }
1469/*US 1469/*US
1470 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1470 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1471*/ 1471*/
1472 minSize += QSize(margin*2, margin*2); 1472 minSize += QSize(margin*2, margin*2);
1473 break; 1473 break;
1474 1474
1475 case KToolBar::Left: 1475 case KToolBar::Left:
1476 case KToolBar::Right: 1476 case KToolBar::Right:
1477 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1477 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1478 { 1478 {
1479 if ( w->inherits( "KToolBarSeparator" ) && 1479 if ( w->inherits( "KToolBarSeparator" ) &&
1480 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1480 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1481 { 1481 {
1482 minSize += QSize(0, 6); 1482 minSize += QSize(0, 6);
1483 } 1483 }
1484 else 1484 else
1485 { 1485 {
1486 QSize sh = w->sizeHint(); 1486 QSize sh = w->sizeHint();
1487 if (!sh.isValid()) 1487 if (!sh.isValid())
1488 sh = w->minimumSize(); 1488 sh = w->minimumSize();
1489 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1489 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1490 minSize += QSize(0, sh.height()+1); 1490 minSize += QSize(0, sh.height()+1);
1491 } 1491 }
1492 } 1492 }
1493/*US 1493/*US
1494 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1494 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1495*/ 1495*/
1496 minSize += QSize(margin*2, margin*2); 1496 minSize += QSize(margin*2, margin*2);
1497 break; 1497 break;
1498 1498
1499 default: 1499 default:
1500 minSize = QToolBar::sizeHint(); 1500 minSize = QToolBar::sizeHint();
1501 break; 1501 break;
1502 } 1502 }
1503 return minSize; 1503 return minSize;
1504#endif 1504#endif
1505} 1505}
1506 1506
1507QSize KToolBar::minimumSize() const 1507QSize KToolBar::minimumSize() const
1508{ 1508{
1509 return minimumSizeHint(); 1509 return minimumSizeHint();
1510} 1510}
1511 1511
1512QSize KToolBar::minimumSizeHint() const 1512QSize KToolBar::minimumSizeHint() const
1513{ 1513{
1514 return sizeHint(); 1514 return sizeHint();
1515} 1515}
1516 1516
1517bool KToolBar::highlight() const 1517bool KToolBar::highlight() const
1518{ 1518{
1519 return d->m_highlight; 1519 return d->m_highlight;
1520} 1520}
1521 1521
1522void KToolBar::hide() 1522void KToolBar::hide()
1523{ 1523{
1524 QToolBar::hide(); 1524 QToolBar::hide();
1525} 1525}
1526 1526
1527void KToolBar::show() 1527void KToolBar::show()
1528{ 1528{
1529 QToolBar::show(); 1529 QToolBar::show();
1530} 1530}
1531 1531
1532void KToolBar::resizeEvent( QResizeEvent *e ) 1532void KToolBar::resizeEvent( QResizeEvent *e )
1533{ 1533{
1534 bool b = isUpdatesEnabled(); 1534 bool b = isUpdatesEnabled();
1535 setUpdatesEnabled( FALSE ); 1535 setUpdatesEnabled( FALSE );
1536 QToolBar::resizeEvent( e ); 1536 QToolBar::resizeEvent( e );
1537 if (b) 1537 if (b)
1538 d->repaintTimer.start( 100, true ); 1538 d->repaintTimer.start( 100, true );
1539} 1539}
1540 1540
1541void KToolBar::slotIconChanged(int group) 1541void KToolBar::slotIconChanged(int group)
1542{ 1542{
1543 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1543 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1544 return; 1544 return;
1545 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1545 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1546 return; 1546 return;
1547 1547
1548 emit modechange(); 1548 emit modechange();
1549 if (isVisible()) 1549 if (isVisible())
1550 updateGeometry(); 1550 updateGeometry();
1551} 1551}
1552 1552
1553void KToolBar::slotReadConfig() 1553void KToolBar::slotReadConfig()
1554{ 1554{
1555 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1555 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1556 // Read appearance settings (hmm, we used to do both here, 1556 // Read appearance settings (hmm, we used to do both here,
1557 // but a well behaved application will call applyMainWindowSettings 1557 // but a well behaved application will call applyMainWindowSettings
1558 // anyway, right ?) 1558 // anyway, right ?)
1559 applyAppearanceSettings(KGlobal::config(), QString::null ); 1559 applyAppearanceSettings(KGlobal::config(), QString::null );
1560} 1560}
1561 1561
1562void KToolBar::slotAppearanceChanged() 1562void KToolBar::slotAppearanceChanged()
1563{ 1563{
1564 // Read appearance settings from global file. 1564 // Read appearance settings from global file.
1565 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1565 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1566 // And remember to save the new look later 1566 // And remember to save the new look later
1567/*US 1567/*US
1568 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1568 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1569 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1569 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1570*/ 1570*/
1571} 1571}
1572 1572
1573//static 1573//static
1574bool KToolBar::highlightSetting() 1574bool KToolBar::highlightSetting()
1575{ 1575{
1576 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1576 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1577 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1577 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1578 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1578 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1579} 1579}
1580 1580
1581//static 1581//static
1582bool KToolBar::transparentSetting() 1582bool KToolBar::transparentSetting()
1583{ 1583{
1584 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1584 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1585 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1585 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1586 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1586 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1587} 1587}
1588 1588
1589//static 1589//static
1590KToolBar::IconText KToolBar::iconTextSetting() 1590KToolBar::IconText KToolBar::iconTextSetting()
1591{ 1591{
1592 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1592 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1593 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1593 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1594 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1594 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1595 if ( icontext == "IconTextRight" ) 1595 if ( icontext == "IconTextRight" )
1596 return IconTextRight; 1596 return IconTextRight;
1597 else if ( icontext == "IconTextBottom" ) 1597 else if ( icontext == "IconTextBottom" )
1598 return IconTextBottom; 1598 return IconTextBottom;
1599 else if ( icontext == "TextOnly" ) 1599 else if ( icontext == "TextOnly" )
1600 return TextOnly; 1600 return TextOnly;
1601 else 1601 else
1602 return IconOnly; 1602 return IconOnly;
1603} 1603}
1604 1604
1605void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1605void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1606{ 1606{
1607 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1607 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1608 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1608 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1609 // We have application-specific settings in the XML file, 1609 // We have application-specific settings in the XML file,
1610 // and nothing in the application's config file 1610 // and nothing in the application's config file
1611 // -> don't apply the global defaults, the XML ones are preferred 1611 // -> don't apply the global defaults, the XML ones are preferred
1612 // See applySettings for a full explanation 1612 // See applySettings for a full explanation
1613/*US :we do not support xml files 1613/*US :we do not support xml files
1614 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1614 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1615 !config->hasGroup(configGroup) ) 1615 !config->hasGroup(configGroup) )
1616 { 1616 {
1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1618 return; 1618 return;
1619 } 1619 }
1620*/ 1620*/
1621 if ( !config->hasGroup(configGroup) ) 1621 if ( !config->hasGroup(configGroup) )
1622 { 1622 {
1623 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1623 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1624 return; 1624 return;
1625 } 1625 }
1626 1626
1627 1627
1628 KConfig *gconfig = KGlobal::config(); 1628 KConfig *gconfig = KGlobal::config();
1629/*US 1629/*US
1630 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1630 static const QString &attrIconText = KGlobal::staticQString("IconText");
1631 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1631 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1632 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1632 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1633 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1633 static const QString &attrSize = KGlobal::staticQString("IconSize");
1634*/ 1634*/
1635 // we actually do this in two steps. 1635 // we actually do this in two steps.
1636 // First, we read in the global styles [Toolbar style] (from the KControl module). 1636 // First, we read in the global styles [Toolbar style] (from the KControl module).
1637 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1637 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1638 bool highlight; 1638 bool highlight;
1639 int transparent; 1639 int transparent;
1640 QString icontext; 1640 QString icontext;
1641 int iconsize = 0; 1641 int iconsize = 0;
1642 1642
1643 // this is the first iteration 1643 // this is the first iteration
1644 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1644 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1645 { // start block for KConfigGroupSaver 1645 { // start block for KConfigGroupSaver
1646 KConfigGroupSaver saver(gconfig, grpToolbar); 1646 KConfigGroupSaver saver(gconfig, grpToolbar);
1647 1647
1648 // first, get the generic settings 1648 // first, get the generic settings
1649//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1649//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1650 highlight = gconfig->readBoolEntry("Highlighting", true); 1650 highlight = gconfig->readBoolEntry("Highlighting", true);
1651//US transparent = gconfig->readBoolEntry(attrTrans, true); 1651//US transparent = gconfig->readBoolEntry(attrTrans, true);
1652 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1652 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1653 1653
1654 // we read in the IconText property *only* if we intend on actually 1654 // we read in the IconText property *only* if we intend on actually
1655 // honoring it 1655 // honoring it
1656 if (d->m_honorStyle) 1656 if (d->m_honorStyle)
1657//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1657//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1658 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1658 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1659 else 1659 else
1660 d->IconTextDefault = "IconOnly"; 1660 d->IconTextDefault = "IconOnly";
1661 1661
1662 // Use the default icon size for toolbar icons. 1662 // Use the default icon size for toolbar icons.
1663//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1663//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1664 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1664 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1665 1665
1666 if ( !forceGlobal && config->hasGroup(configGroup) ) 1666 if ( !forceGlobal && config->hasGroup(configGroup) )
1667 { 1667 {
1668 config->setGroup(configGroup); 1668 config->setGroup(configGroup);
1669 1669
1670 // first, get the generic settings 1670 // first, get the generic settings
1671//US highlight = config->readBoolEntry(attrHighlight, highlight); 1671//US highlight = config->readBoolEntry(attrHighlight, highlight);
1672 highlight = config->readBoolEntry("Highlighting", highlight); 1672 highlight = config->readBoolEntry("Highlighting", highlight);
1673//US transparent = config->readBoolEntry(attrTrans, transparent); 1673//US transparent = config->readBoolEntry(attrTrans, transparent);
1674 transparent = config->readBoolEntry("TransparentMoving", transparent); 1674 transparent = config->readBoolEntry("TransparentMoving", transparent);
1675 // now we always read in the IconText property 1675 // now we always read in the IconText property
1676//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1676//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1677 icontext = config->readEntry("IconText", d->IconTextDefault); 1677 icontext = config->readEntry("IconText", d->IconTextDefault);
1678 1678
1679 // now get the size 1679 // now get the size
1680//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1680//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1681 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1681 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1682 } 1682 }
1683 else 1683 else
1684 { 1684 {
1685 iconsize = d->IconSizeDefault; 1685 iconsize = d->IconSizeDefault;
1686 icontext = d->IconTextDefault; 1686 icontext = d->IconTextDefault;
1687 } 1687 }
1688 1688
1689 // revert back to the old group 1689 // revert back to the old group
1690 } // end block for KConfigGroupSaver 1690 } // end block for KConfigGroupSaver
1691 1691
1692 bool doUpdate = false; 1692 bool doUpdate = false;
1693 1693
1694 IconText icon_text; 1694 IconText icon_text;
1695 if ( icontext == "IconTextRight" ) 1695 if ( icontext == "IconTextRight" )
1696 icon_text = IconTextRight; 1696 icon_text = IconTextRight;
1697 else if ( icontext == "IconTextBottom" ) 1697 else if ( icontext == "IconTextBottom" )
1698 icon_text = IconTextBottom; 1698 icon_text = IconTextBottom;
1699 else if ( icontext == "TextOnly" ) 1699 else if ( icontext == "TextOnly" )
1700 icon_text = TextOnly; 1700 icon_text = TextOnly;
1701 else 1701 else
1702 icon_text = IconOnly; 1702 icon_text = IconOnly;
1703 1703
1704 // check if the icon/text has changed 1704 // check if the icon/text has changed
1705 if (icon_text != d->m_iconText) { 1705 if (icon_text != d->m_iconText) {
1706 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1706 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1707 setIconText(icon_text, false); 1707 setIconText(icon_text, false);
1708 doUpdate = true; 1708 doUpdate = true;
1709 } 1709 }
1710 1710
1711 // ...and check if the icon size has changed 1711 // ...and check if the icon size has changed
1712 if (iconsize != d->m_iconSize) { 1712 if (iconsize != d->m_iconSize) {
1713 setIconSize(iconsize, false); 1713 setIconSize(iconsize, false);
1714 doUpdate = true; 1714 doUpdate = true;
1715 } 1715 }
1716 1716
1717 QMainWindow *mw = mainWindow(); 1717 QMainWindow *mw = mainWindow();
1718 1718
1719 // ...and if we should highlight 1719 // ...and if we should highlight
1720 if ( highlight != d->m_highlight ) { 1720 if ( highlight != d->m_highlight ) {
1721 d->m_highlight = highlight; 1721 d->m_highlight = highlight;
1722 doUpdate = true; 1722 doUpdate = true;
1723 } 1723 }
1724 1724
1725 // ...and if we should move transparently 1725 // ...and if we should move transparently
1726 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1726 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1727 mw->setOpaqueMoving( !transparent ); 1727 mw->setOpaqueMoving( !transparent );
1728 } 1728 }
1729 1729
1730 if (doUpdate) 1730 if (doUpdate)
1731 emit modechange(); // tell buttons what happened 1731 emit modechange(); // tell buttons what happened
1732 if (isVisible ()) 1732 if (isVisible ())
1733 updateGeometry(); 1733 updateGeometry();
1734} 1734}
1735 1735
1736void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1736void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1737{ 1737{
1738 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1738 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1739 1739
1740 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1740 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1741 1741
1742 /* 1742 /*
1743 Let's explain this a bit more in details. 1743 Let's explain this a bit more in details.
1744 The order in which we apply settings is : 1744 The order in which we apply settings is :
1745 Global config / <appnamerc> user settings if no XMLGUI is used 1745 Global config / <appnamerc> user settings if no XMLGUI is used
1746 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1746 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1747 1747
1748 So in the first case, we simply read everything from KConfig as below, 1748 So in the first case, we simply read everything from KConfig as below,
1749 but in the second case we don't do anything here if there is no app-specific config, 1749 but in the second case we don't do anything here if there is no app-specific config,
1750 and the XMLGUI uses the static methods of this class to get the global defaults. 1750 and the XMLGUI uses the static methods of this class to get the global defaults.
1751 1751
1752 Global config doesn't include position (index, offset, newline and hidden/shown). 1752 Global config doesn't include position (index, offset, newline and hidden/shown).
1753 */ 1753 */
1754 1754
1755 // First the appearance stuff - the one which has a global config 1755 // First the appearance stuff - the one which has a global config
1756 applyAppearanceSettings( config, _configGroup ); 1756 applyAppearanceSettings( config, _configGroup );
1757 1757
1758 // ...and now the position stuff 1758 // ...and now the position stuff
1759 if ( config->hasGroup(configGroup) ) 1759 if ( config->hasGroup(configGroup) )
1760 { 1760 {
1761 KConfigGroupSaver cgs(config, configGroup); 1761 KConfigGroupSaver cgs(config, configGroup);
1762/*US 1762/*US
1763 static const QString &attrPosition = KGlobal::staticQString("Position"); 1763 static const QString &attrPosition = KGlobal::staticQString("Position");
1764 static const QString &attrIndex = KGlobal::staticQString("Index"); 1764 static const QString &attrIndex = KGlobal::staticQString("Index");
1765 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1765 static const QString &attrOffset = KGlobal::staticQString("Offset");
1766 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1766 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1767 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1767 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1768 1768
1769 QString position = config->readEntry(attrPosition, d->PositionDefault); 1769 QString position = config->readEntry(attrPosition, d->PositionDefault);
1770 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1770 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1771 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1771 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1772 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1772 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1773 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1773 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1774*/ 1774*/
1775 1775
1776 QString position = config->readEntry("Position", d->PositionDefault); 1776 QString position = config->readEntry("Position", d->PositionDefault);
1777 int index = config->readNumEntry("Index", d->IndexDefault); 1777 int index = config->readNumEntry("Index", d->IndexDefault);
1778 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1778 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1779 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1779 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1780 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1780 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1781 1781
1782/*US Dock pos(DockTop); 1782/*US Dock pos(DockTop);
1783 if ( position == "Top" ) 1783 if ( position == "Top" )
1784 pos = DockTop; 1784 pos = DockTop;
1785 else if ( position == "Bottom" ) 1785 else if ( position == "Bottom" )
1786 pos = DockBottom; 1786 pos = DockBottom;
1787 else if ( position == "Left" ) 1787 else if ( position == "Left" )
1788 pos = DockLeft; 1788 pos = DockLeft;
1789 else if ( position == "Right" ) 1789 else if ( position == "Right" )
1790 pos = DockRight; 1790 pos = DockRight;
1791 else if ( position == "Floating" ) 1791 else if ( position == "Floating" )
1792 pos = DockTornOff; 1792 pos = DockTornOff;
1793 else if ( position == "Flat" ) 1793 else if ( position == "Flat" )
1794 pos = DockMinimized; 1794 pos = DockMinimized;
1795*/ 1795*/
1796 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1796 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1797 if ( position == "Top" ) 1797 if ( position == "Top" )
1798 pos = QMainWindow::Top; 1798 pos = QMainWindow::Top;
1799 else if ( position == "Bottom" ) 1799 else if ( position == "Bottom" )
1800 pos = QMainWindow::Bottom; 1800 pos = QMainWindow::Bottom;
1801 else if ( position == "Left" ) 1801 else if ( position == "Left" )
1802 pos = QMainWindow::Left; 1802 pos = QMainWindow::Left;
1803 else if ( position == "Right" ) 1803 else if ( position == "Right" )
1804 pos = QMainWindow::Right; 1804 pos = QMainWindow::Right;
1805 else if ( position == "Floating" ) 1805 else if ( position == "Floating" )
1806 pos = QMainWindow::TornOff; 1806 pos = QMainWindow::TornOff;
1807 else if ( position == "Flat" ) 1807 else if ( position == "Flat" )
1808 pos = QMainWindow::Minimized; 1808 pos = QMainWindow::Minimized;
1809 1809
1810 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; 1810 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl;
1811 if (hidden) 1811 if (hidden)
1812 hide(); 1812 hide();
1813 else 1813 else
1814 show(); 1814 show();
1815 1815
1816 if ( mainWindow() ) 1816 if ( mainWindow() )
1817 { 1817 {
1818 QMainWindow *mw = mainWindow(); 1818 QMainWindow *mw = mainWindow();
1819 1819
1820 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; 1820 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
1821 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); 1821 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
1822 1822
1823 // moveDockWindow calls QDockArea which does a reparent() on us with 1823 // moveDockWindow calls QDockArea which does a reparent() on us with
1824 // showIt = true, so we loose our visibility status 1824 // showIt = true, so we loose our visibility status
1825 bool doHide = isHidden(); 1825 bool doHide = isHidden();
1826 1826
1827//US mw->moveDockWindow( this, pos, newLine, index, offset ); 1827//US mw->moveDockWindow( this, pos, newLine, index, offset );
1828 mw->moveToolBar( this, pos, newLine, index, offset ); 1828 mw->moveToolBar( this, pos, newLine, index, offset );
1829 1829
1830 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; 1830 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
1831 if ( doHide ) 1831 if ( doHide )
1832 hide(); 1832 hide();
1833 } 1833 }
1834 if (isVisible ()) 1834 if (isVisible ())
1835 updateGeometry(); 1835 updateGeometry();
1836 } 1836 }
1837} 1837}
1838 1838
1839bool KToolBar::event( QEvent *e ) 1839bool KToolBar::event( QEvent *e )
1840{ 1840{
1841 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) 1841 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
1842 d->repaintTimer.start( 100, true ); 1842 d->repaintTimer.start( 100, true );
1843 1843
1844 if (e->type() == QEvent::ChildInserted ) 1844 if (e->type() == QEvent::ChildInserted )
1845 { 1845 {
1846 // By pass QToolBar::event, 1846 // By pass QToolBar::event,
1847 // it will show() the inserted child and we don't want to 1847 // it will show() the inserted child and we don't want to
1848 // do that until we have rebuild the layout. 1848 // do that until we have rebuild the layout.
1849 childEvent((QChildEvent *)e); 1849 childEvent((QChildEvent *)e);
1850 return true; 1850 return true;
1851 } 1851 }
1852 1852
1853 return QToolBar::event( e ); 1853 return QToolBar::event( e );
1854} 1854}
1855 1855
1856void KToolBar::slotRepaint() 1856void KToolBar::slotRepaint()
1857{ 1857{
1858 setUpdatesEnabled( FALSE ); 1858 setUpdatesEnabled( FALSE );
1859 // Send a resizeEvent to update the "toolbar extension arrow" 1859 // Send a resizeEvent to update the "toolbar extension arrow"
1860 // (The button you get when your toolbar-items don't fit in 1860 // (The button you get when your toolbar-items don't fit in
1861 // the available space) 1861 // the available space)
1862 QResizeEvent ev(size(), size()); 1862 QResizeEvent ev(size(), size());
1863 resizeEvent(&ev); 1863 resizeEvent(&ev);
1864 //#ifdef DESKTOP_VERSION 1864 //#ifdef DESKTOP_VERSION
1865 QApplication::sendPostedEvents( this, QEvent::LayoutHint ); 1865 QApplication::sendPostedEvents( this, QEvent::LayoutHint );
1866 //#endif //DESKTOP_VERSION 1866 //#endif //DESKTOP_VERSION
1867 setUpdatesEnabled( TRUE ); 1867 setUpdatesEnabled( TRUE );
1868 repaint( TRUE ); 1868 repaint( TRUE );
1869} 1869}
1870 1870
1871void KToolBar::toolBarPosChanged( QToolBar *tb ) 1871void KToolBar::toolBarPosChanged( QToolBar *tb )
1872{ 1872{
1873 if ( tb != this ) 1873 if ( tb != this )
1874 return; 1874 return;
1875//US if ( d->oldPos == DockMinimized ) 1875//US if ( d->oldPos == DockMinimized )
1876 if ( d->oldPos == QMainWindow::Minimized ) 1876 if ( d->oldPos == QMainWindow::Minimized )
1877 rebuildLayout(); 1877 rebuildLayout();
1878 d->oldPos = (QMainWindow::ToolBarDock)barPos(); 1878 d->oldPos = (QMainWindow::ToolBarDock)barPos();
1879/*US 1879/*US
1880 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1880 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1881 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1881 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1882*/ 1882*/
1883} 1883}
1884 1884
1885/*US 1885/*US
1886void KToolBar::loadState( const QDomElement &element ) 1886void KToolBar::loadState( const QDomElement &element )
1887{ 1887{
1888 //kdDebug(220) << "KToolBar::loadState " << this << endl; 1888 //kdDebug(220) << "KToolBar::loadState " << this << endl;
1889 if ( !mainWindow() ) 1889 if ( !mainWindow() )
1890 return; 1890 return;
1891 1891
1892 { 1892 {
1893 QCString text = element.namedItem( "text" ).toElement().text().utf8(); 1893 QCString text = element.namedItem( "text" ).toElement().text().utf8();
1894 if ( text.isEmpty() ) 1894 if ( text.isEmpty() )
1895 text = element.namedItem( "Text" ).toElement().text().utf8(); 1895 text = element.namedItem( "Text" ).toElement().text().utf8();
1896 if ( !text.isEmpty() ) 1896 if ( !text.isEmpty() )
1897 setText( i18n( text ) ); 1897 setText( i18n( text ) );
1898 } 1898 }
1899 1899
1900 { 1900 {
1901 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); 1901 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
1902 if ( !attrFullWidth.isEmpty() ) 1902 if ( !attrFullWidth.isEmpty() )
1903 setFullSize( attrFullWidth == "true" ); 1903 setFullSize( attrFullWidth == "true" );
1904 } 1904 }
1905 1905
1906 Dock dock = DockTop; 1906 Dock dock = DockTop;
1907 { 1907 {
1908 QCString attrPosition = element.attribute( "position" ).lower().latin1(); 1908 QCString attrPosition = element.attribute( "position" ).lower().latin1();
1909 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; 1909 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl;
1910 if ( !attrPosition.isEmpty() ) { 1910 if ( !attrPosition.isEmpty() ) {
1911 if ( attrPosition == "top" ) 1911 if ( attrPosition == "top" )
1912 dock = DockTop; 1912 dock = DockTop;
1913 else if ( attrPosition == "left" ) 1913 else if ( attrPosition == "left" )
1914 dock = DockLeft; 1914 dock = DockLeft;
1915 else if ( attrPosition == "right" ) 1915 else if ( attrPosition == "right" )
1916 dock = DockRight; 1916 dock = DockRight;
1917 else if ( attrPosition == "bottom" ) 1917 else if ( attrPosition == "bottom" )
1918 dock = DockBottom; 1918 dock = DockBottom;
1919 else if ( attrPosition == "floating" ) 1919 else if ( attrPosition == "floating" )
1920 dock = DockTornOff; 1920 dock = DockTornOff;
1921 else if ( attrPosition == "flat" ) 1921 else if ( attrPosition == "flat" )
1922 dock = DockMinimized; 1922 dock = DockMinimized;
1923 } 1923 }
1924 } 1924 }
1925 1925
1926 { 1926 {
1927 QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); 1927 QCString attrIconText = element.attribute( "iconText" ).lower().latin1();
1928 if ( !attrIconText.isEmpty() ) { 1928 if ( !attrIconText.isEmpty() ) {
1929 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; 1929 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl;
1930 if ( attrIconText == "icontextright" ) 1930 if ( attrIconText == "icontextright" )
1931 setIconText( KToolBar::IconTextRight ); 1931 setIconText( KToolBar::IconTextRight );
1932 else if ( attrIconText == "textonly" ) 1932 else if ( attrIconText == "textonly" )
1933 setIconText( KToolBar::TextOnly ); 1933 setIconText( KToolBar::TextOnly );
1934 else if ( attrIconText == "icontextbottom" ) 1934 else if ( attrIconText == "icontextbottom" )
1935 setIconText( KToolBar::IconTextBottom ); 1935 setIconText( KToolBar::IconTextBottom );
1936 else if ( attrIconText == "icononly" ) 1936 else if ( attrIconText == "icononly" )
1937 setIconText( KToolBar::IconOnly ); 1937 setIconText( KToolBar::IconOnly );
1938 } else 1938 } else
1939 // Use global setting 1939 // Use global setting
1940 setIconText( iconTextSetting() ); 1940 setIconText( iconTextSetting() );
1941 } 1941 }
1942 1942
1943 { 1943 {
1944 QString attrIconSize = element.attribute( "iconSize" ).lower(); 1944 QString attrIconSize = element.attribute( "iconSize" ).lower();
1945 if ( !attrIconSize.isEmpty() ) 1945 if ( !attrIconSize.isEmpty() )
1946 d->IconSizeDefault = attrIconSize.toInt(); 1946 d->IconSizeDefault = attrIconSize.toInt();
1947 setIconSize( d->IconSizeDefault ); 1947 setIconSize( d->IconSizeDefault );
1948 } 1948 }
1949 1949
1950 { 1950 {
1951 QString attrIndex = element.attribute( "index" ).lower(); 1951 QString attrIndex = element.attribute( "index" ).lower();
1952 if ( !attrIndex.isEmpty() ) 1952 if ( !attrIndex.isEmpty() )
1953 d->IndexDefault = attrIndex.toInt(); 1953 d->IndexDefault = attrIndex.toInt();
1954 } 1954 }
1955 1955
1956 { 1956 {
1957 QString attrOffset = element.attribute( "offset" ).lower(); 1957 QString attrOffset = element.attribute( "offset" ).lower();
1958 if ( !attrOffset.isEmpty() ) 1958 if ( !attrOffset.isEmpty() )
1959 d->OffsetDefault = attrOffset.toInt(); 1959 d->OffsetDefault = attrOffset.toInt();
1960 } 1960 }
1961 1961
1962 { 1962 {
1963 QString attrNewLine = element.attribute( "newline" ).lower(); 1963 QString attrNewLine = element.attribute( "newline" ).lower();
1964 if ( !attrNewLine.isEmpty() ) 1964 if ( !attrNewLine.isEmpty() )
1965 d->NewLineDefault = attrNewLine == "true"; 1965 d->NewLineDefault = attrNewLine == "true";
1966 } 1966 }
1967 1967
1968 { 1968 {
1969 QString attrHidden = element.attribute( "hidden" ).lower(); 1969 QString attrHidden = element.attribute( "hidden" ).lower();
1970 if ( !attrHidden.isEmpty() ) 1970 if ( !attrHidden.isEmpty() )
1971 d->HiddenDefault = attrHidden == "true"; 1971 d->HiddenDefault = attrHidden == "true";
1972 } 1972 }
1973 1973
1974 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); 1974 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault );
1975 mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); 1975 mainWindow()->addDockWindow( this, dock, d->NewLineDefault );
1976//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1976//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1977 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1977 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1978 1978
1979 // Apply the highlight button setting 1979 // Apply the highlight button setting
1980 d->m_highlight = highlightSetting(); 1980 d->m_highlight = highlightSetting();
1981 1981
1982 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, 1982 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow,
1983 // but we do it only if there are toolbars...) 1983 // but we do it only if there are toolbars...)
1984 if ( transparentSetting() != !mainWindow()->opaqueMoving() ) 1984 if ( transparentSetting() != !mainWindow()->opaqueMoving() )
1985 mainWindow()->setOpaqueMoving( !transparentSetting() ); 1985 mainWindow()->setOpaqueMoving( !transparentSetting() );
1986 1986
1987 if ( d->HiddenDefault ) 1987 if ( d->HiddenDefault )
1988 hide(); 1988 hide();
1989 else 1989 else
1990 show(); 1990 show();
1991 1991
1992 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); 1992 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault );
1993} 1993}
1994*/ 1994*/
1995 1995
1996void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) 1996void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
1997{ 1997{
1998 // get all of the stuff to save 1998 // get all of the stuff to save
1999 switch ( barPos() ) { 1999 switch ( barPos() ) {
2000 case KToolBar::Flat: 2000 case KToolBar::Flat:
2001 position = "Flat"; 2001 position = "Flat";
2002 break; 2002 break;
2003 case KToolBar::Bottom: 2003 case KToolBar::Bottom:
2004 position = "Bottom"; 2004 position = "Bottom";
2005 break; 2005 break;
2006 case KToolBar::Left: 2006 case KToolBar::Left:
2007 position = "Left"; 2007 position = "Left";
2008 break; 2008 break;
2009 case KToolBar::Right: 2009 case KToolBar::Right:
2010 position = "Right"; 2010 position = "Right";
2011 break; 2011 break;
2012 case KToolBar::Floating: 2012 case KToolBar::Floating:
2013 position = "Floating"; 2013 position = "Floating";
2014 break; 2014 break;
2015 case KToolBar::Top: 2015 case KToolBar::Top:
2016 default: 2016 default:
2017 position = "Top"; 2017 position = "Top";
2018 break; 2018 break;
2019 } 2019 }
2020 2020
2021 if ( mainWindow() ) { 2021 if ( mainWindow() ) {
2022 QMainWindow::ToolBarDock dock; 2022 QMainWindow::ToolBarDock dock;
2023 bool newLine; 2023 bool newLine;
2024 int offset; 2024 int offset;
2025 mainWindow()->getLocation( this, dock, index, newLine, offset ); 2025 mainWindow()->getLocation( this, dock, index, newLine, offset );
2026 } 2026 }
2027 2027
2028 switch (d->m_iconText) { 2028 switch (d->m_iconText) {
2029 case KToolBar::IconTextRight: 2029 case KToolBar::IconTextRight:
2030 icontext = "IconTextRight"; 2030 icontext = "IconTextRight";
2031 break; 2031 break;
2032 case KToolBar::IconTextBottom: 2032 case KToolBar::IconTextBottom:
2033 icontext = "IconTextBottom"; 2033 icontext = "IconTextBottom";
2034 break; 2034 break;
2035 case KToolBar::TextOnly: 2035 case KToolBar::TextOnly:
2036 icontext = "TextOnly"; 2036 icontext = "TextOnly";
2037 break; 2037 break;
2038 case KToolBar::IconOnly: 2038 case KToolBar::IconOnly:
2039 default: 2039 default:
2040 icontext = "IconOnly"; 2040 icontext = "IconOnly";
2041 break; 2041 break;
2042 } 2042 }
2043} 2043}
2044/*US 2044/*US
2045void KToolBar::saveState( QDomElement &current ) 2045void KToolBar::saveState( QDomElement &current )
2046{ 2046{
2047 QString position, icontext; 2047 QString position, icontext;
2048 int index = -1; 2048 int index = -1;
2049 getAttributes( position, icontext, index ); 2049 getAttributes( position, icontext, index );
2050 2050
2051 current.setAttribute( "noMerge", "1" ); 2051 current.setAttribute( "noMerge", "1" );
2052 current.setAttribute( "position", position ); 2052 current.setAttribute( "position", position );
2053 current.setAttribute( "iconText", icontext ); 2053 current.setAttribute( "iconText", icontext );
2054 current.setAttribute( "index", index ); 2054 current.setAttribute( "index", index );
2055 current.setAttribute( "offset", offset() ); 2055 current.setAttribute( "offset", offset() );
2056 current.setAttribute( "newline", newLine() ); 2056 current.setAttribute( "newline", newLine() );
2057 if ( isHidden() ) 2057 if ( isHidden() )
2058 current.setAttribute( "hidden", "true" ); 2058 current.setAttribute( "hidden", "true" );
2059 d->modified = true; 2059 d->modified = true;
2060} 2060}
2061*/ 2061*/
2062 2062
2063void KToolBar::positionYourself( bool force ) 2063void KToolBar::positionYourself( bool force )
2064{ 2064{
2065 if (force) 2065 if (force)
2066 d->positioned = false; 2066 d->positioned = false;
2067 2067
2068 if ( d->positioned || !mainWindow() ) 2068 if ( d->positioned || !mainWindow() )
2069 { 2069 {
2070 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; 2070 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl;
2071 return; 2071 return;
2072 } 2072 }
2073 // we can't test for ForceHide after moveDockWindow because QDockArea 2073 // we can't test for ForceHide after moveDockWindow because QDockArea
2074 // does a reparent() with showIt == true 2074 // does a reparent() with showIt == true
2075 bool doHide = isHidden(); 2075 bool doHide = isHidden();
2076 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; 2076 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl;
2077/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, 2077/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
2078 d->toolBarInfo.newline, 2078 d->toolBarInfo.newline,
2079 d->toolBarInfo.index, 2079 d->toolBarInfo.index,
2080 d->toolBarInfo.offset ); 2080 d->toolBarInfo.offset );
2081*/ 2081*/
2082 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 2082 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
2083 2083
2084 if ( doHide ) 2084 if ( doHide )
2085 hide(); 2085 hide();
2086 // This method can only have an effect once - unless force is set 2086 // This method can only have an effect once - unless force is set
2087 d->positioned = TRUE; 2087 d->positioned = TRUE;
2088} 2088}
2089 2089
2090//US KPopupMenu *KToolBar::contextMenu() 2090//US KPopupMenu *KToolBar::contextMenu()
2091QPopupMenu *KToolBar::contextMenu() 2091QPopupMenu *KToolBar::contextMenu()
2092{ 2092{
2093 if ( context ) 2093 if ( context )
2094 return context; 2094 return context;
2095 2095
2096 // Construct our context popup menu. Name it qt_dockwidget_internal so it 2096 // Construct our context popup menu. Name it qt_dockwidget_internal so it
2097 // won't be deleted by QToolBar::clear(). 2097 // won't be deleted by QToolBar::clear().
2098//US context = new KPopupMenu( this, "qt_dockwidget_internal" ); 2098//US context = new KPopupMenu( this, "qt_dockwidget_internal" );
2099 context = new QPopupMenu( this, "qt_dockwidget_internal" ); 2099 context = new QPopupMenu( this, "qt_dockwidget_internal" );
2100//US context->insertTitle(i18n("Toolbar Menu")); 2100//US context->insertTitle(i18n("Toolbar Menu"));
2101 2101
2102//US KPopupMenu *orient = new KPopupMenu( context, "orient" ); 2102//US KPopupMenu *orient = new KPopupMenu( context, "orient" );
2103 QPopupMenu *orient = new QPopupMenu( context, "orient" ); 2103 QPopupMenu *orient = new QPopupMenu( context, "orient" );
2104 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); 2104 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP );
2105 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); 2105 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT );
2106 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); 2106 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT );
2107 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); 2107 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
2108 orient->insertSeparator(-1); 2108 orient->insertSeparator(-1);
2109 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); 2109 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
2110 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); 2110 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT );
2111 2111
2112//US KPopupMenu *mode = new KPopupMenu( context, "mode" ); 2112//US KPopupMenu *mode = new KPopupMenu( context, "mode" );
2113 QPopupMenu *mode = new QPopupMenu( context, "mode" ); 2113 QPopupMenu *mode = new QPopupMenu( context, "mode" );
2114 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); 2114 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS );
2115 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); 2115 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT );
2116 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); 2116 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT );
2117 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); 2117 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER );
2118 2118
2119//US KPopupMenu *size = new KPopupMenu( context, "size" ); 2119//US KPopupMenu *size = new KPopupMenu( context, "size" );
2120 QPopupMenu *size = new QPopupMenu( context, "size" ); 2120 QPopupMenu *size = new QPopupMenu( context, "size" );
2121 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); 2121 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES );
2122 // Query the current theme for available sizes 2122 // Query the current theme for available sizes
2123 QValueList<int> avSizes; 2123 QValueList<int> avSizes;
2124/*US 2124/*US
2125 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); 2125 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme();
2126 if (!::qstrcmp(QObject::name(), "mainToolBar")) 2126 if (!::qstrcmp(QObject::name(), "mainToolBar"))
2127 avSizes = theme->querySizes( KIcon::MainToolbar); 2127 avSizes = theme->querySizes( KIcon::MainToolbar);
2128 else 2128 else
2129 avSizes = theme->querySizes( KIcon::Toolbar); 2129 avSizes = theme->querySizes( KIcon::Toolbar);
2130*/ 2130*/
2131 avSizes << 16; 2131 avSizes << 16;
2132 avSizes << 32; 2132 avSizes << 32;
2133 2133
2134 d->iconSizes = avSizes; 2134 d->iconSizes = avSizes;
2135 2135
2136 QValueList<int>::Iterator it; 2136 QValueList<int>::Iterator it;
2137 for (it=avSizes.begin(); it!=avSizes.end(); it++) { 2137 for (it=avSizes.begin(); it!=avSizes.end(); it++) {
2138 QString text; 2138 QString text;
2139 if ( *it < 19 ) 2139 if ( *it < 19 )
2140 text = i18n("Small (%1x%2)").arg(*it).arg(*it); 2140 text = i18n("Small (%1x%2)").arg(*it).arg(*it);
2141 else if (*it < 25) 2141 else if (*it < 25)
2142 text = i18n("Medium (%1x%2)").arg(*it).arg(*it); 2142 text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
2143 else 2143 else
2144 text = i18n("Large (%1x%2)").arg(*it).arg(*it); 2144 text = i18n("Large (%1x%2)").arg(*it).arg(*it);
2145 //we use the size as an id, with an offset 2145 //we use the size as an id, with an offset
2146 size->insertItem( text, CONTEXT_ICONSIZES + *it ); 2146 size->insertItem( text, CONTEXT_ICONSIZES + *it );
2147 } 2147 }
2148 2148
2149 context->insertItem( i18n("Orientation"), orient ); 2149 context->insertItem( i18n("Orientation"), orient );
2150 orient->setItemChecked(CONTEXT_TOP, true); 2150 orient->setItemChecked(CONTEXT_TOP, true);
2151 context->insertItem( i18n("Text Position"), mode ); 2151 context->insertItem( i18n("Text Position"), mode );
2152 context->setItemChecked(CONTEXT_ICONS, true); 2152 context->setItemChecked(CONTEXT_ICONS, true);
2153 context->insertItem( i18n("Icon Size"), size ); 2153 context->insertItem( i18n("Icon Size"), size );
2154 2154
2155/*US 2155/*US
2156 if (mainWindow()->inherits("KMainWindow")) 2156 if (mainWindow()->inherits("KMainWindow"))
2157 { 2157 {
2158 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && 2158 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) &&
2159 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) 2159 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) )
2160 2160
2161 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); 2161 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context);
2162 } 2162 }
2163*/ 2163*/
2164 2164
2165 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); 2165 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) );
2166 return context; 2166 return context;
2167} 2167}
2168 2168
2169void KToolBar::slotContextAboutToShow() 2169void KToolBar::slotContextAboutToShow()
2170{ 2170{
2171 if (!d->m_configurePlugged) 2171 if (!d->m_configurePlugged)
2172 { 2172 {
2173 // try to find "configure toolbars" action 2173 // try to find "configure toolbars" action
2174 2174
2175 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; 2175 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient;
2176 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 2176 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
2177 xmlGuiClient = (KXMLGUIClient *)mainWindow(); 2177 xmlGuiClient = (KXMLGUIClient *)mainWindow();
2178 if ( xmlGuiClient ) 2178 if ( xmlGuiClient )
2179 { 2179 {
2180 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); 2180 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars));
2181 if ( configureAction ) 2181 if ( configureAction )
2182 { 2182 {
2183 configureAction->plug(context); 2183 configureAction->plug(context);
2184 d->m_configurePlugged = true; 2184 d->m_configurePlugged = true;
2185 } 2185 }
2186 } 2186 }
2187 } 2187 }
2188 2188
2189 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) 2189 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i)
2190 context->setItemChecked(i, false); 2190 context->setItemChecked(i, false);
2191 2191
2192 switch( d->m_iconText ) 2192 switch( d->m_iconText )
2193 { 2193 {
2194 case IconOnly: 2194 case IconOnly:
2195 default: 2195 default:
2196 context->setItemChecked(CONTEXT_ICONS, true); 2196 context->setItemChecked(CONTEXT_ICONS, true);
2197 break; 2197 break;
2198 case IconTextRight: 2198 case IconTextRight:
2199 context->setItemChecked(CONTEXT_TEXTRIGHT, true); 2199 context->setItemChecked(CONTEXT_TEXTRIGHT, true);
2200 break; 2200 break;
2201 case TextOnly: 2201 case TextOnly:
2202 context->setItemChecked(CONTEXT_TEXT, true); 2202 context->setItemChecked(CONTEXT_TEXT, true);
2203 break; 2203 break;
2204 case IconTextBottom: 2204 case IconTextBottom:
2205 context->setItemChecked(CONTEXT_TEXTUNDER, true); 2205 context->setItemChecked(CONTEXT_TEXTUNDER, true);
2206 break; 2206 break;
2207 } 2207 }
2208 2208
2209 QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); 2209 QValueList<int>::ConstIterator iIt = d->iconSizes.begin();
2210 QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); 2210 QValueList<int>::ConstIterator iEnd = d->iconSizes.end();
2211 for (; iIt != iEnd; ++iIt ) 2211 for (; iIt != iEnd; ++iIt )
2212 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); 2212 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false );
2213 2213
2214 context->setItemChecked( CONTEXT_ICONSIZES, false ); 2214 context->setItemChecked( CONTEXT_ICONSIZES, false );
2215 2215
2216 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); 2216 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true );
2217 2217
2218 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) 2218 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i )
2219 context->setItemChecked( i, false ); 2219 context->setItemChecked( i, false );
2220 2220
2221 switch ( barPos() ) 2221 switch ( barPos() )
2222 { 2222 {
2223 case KToolBar::Flat: 2223 case KToolBar::Flat:
2224 context->setItemChecked( CONTEXT_FLAT, true ); 2224 context->setItemChecked( CONTEXT_FLAT, true );
2225 break; 2225 break;
2226 case KToolBar::Bottom: 2226 case KToolBar::Bottom:
2227 context->setItemChecked( CONTEXT_BOTTOM, true ); 2227 context->setItemChecked( CONTEXT_BOTTOM, true );
2228 break; 2228 break;
2229 case KToolBar::Left: 2229 case KToolBar::Left:
2230 context->setItemChecked( CONTEXT_LEFT, true ); 2230 context->setItemChecked( CONTEXT_LEFT, true );
2231 break; 2231 break;
2232 case KToolBar::Right: 2232 case KToolBar::Right:
2233 context->setItemChecked( CONTEXT_RIGHT, true ); 2233 context->setItemChecked( CONTEXT_RIGHT, true );
2234 break; 2234 break;
2235 case KToolBar::Floating: 2235 case KToolBar::Floating:
2236 context->setItemChecked( CONTEXT_FLOAT, true ); 2236 context->setItemChecked( CONTEXT_FLOAT, true );
2237 break; 2237 break;
2238 case KToolBar::Top: 2238 case KToolBar::Top:
2239 context->setItemChecked( CONTEXT_TOP, true ); 2239 context->setItemChecked( CONTEXT_TOP, true );
2240 break; 2240 break;
2241 default: break; 2241 default: break;
2242 } 2242 }
2243} 2243}
2244 2244
2245void KToolBar::widgetDestroyed() 2245void KToolBar::widgetDestroyed()
2246{ 2246{
2247 removeWidgetInternal( (QWidget*)sender() ); 2247 removeWidgetInternal( (QWidget*)sender() );
2248} 2248}
2249 2249
2250void KToolBar::removeWidgetInternal( QWidget * w ) 2250void KToolBar::removeWidgetInternal( QWidget * w )
2251{ 2251{
2252 if ( inshutdownprocess ) 2252 if ( inshutdownprocess )
2253 return; 2253 return;
2254 widgets.removeRef( w ); 2254 widgets.removeRef( w );
2255 QMap< QWidget*, int >::Iterator it = widget2id.find( w ); 2255 QMap< QWidget*, int >::Iterator it = widget2id.find( w );
2256 if ( it == widget2id.end() ) 2256 if ( it == widget2id.end() )
2257 return; 2257 return;
2258 id2widget.remove( *it ); 2258 id2widget.remove( *it );
2259 widget2id.remove( it ); 2259 widget2id.remove( it );
2260} 2260}
2261 2261
2262void KToolBar::virtual_hook( int, void* ) 2262void KToolBar::virtual_hook( int, void* )
2263{ /*BASE::virtual_hook( id, data );*/ } 2263{ /*BASE::virtual_hook( id, data );*/ }
2264 2264
2265//US #include "ktoolbar.moc" 2265//US #include "ktoolbar.moc"
2266 2266