summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-22 14:12:43 (UTC)
committer zautrix <zautrix>2005-10-22 14:12:43 (UTC)
commita72d70beb381b9cd6f2af301b52ca82cdcafb299 (patch) (unidiff)
treef5b068e80395821abb5717fb07757a17d805f770
parenta72f3f3acfac791715a1c512fc4cc4c3facdbb62 (diff)
downloadkdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.zip
kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.gz
kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--microkde/kapplication.cpp4
-rw-r--r--microkde/kdeui/ktoolbar.cpp14
-rw-r--r--microkde/kdeui/ktoolbar.h4
4 files changed, 23 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4e2523e..033e537 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3491 +1,3495 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 306 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 408}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 410{
411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 412 mCStringMess = cmsg;
413 mByteData = data; 413 mByteData = data;
414} 414}
415 415
416void KABCore::loadDataAfterStart() 416void KABCore::loadDataAfterStart()
417{ 417{
418 //qDebug("KABCore::loadDataAfterStart() "); 418 //qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 419 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 420 mViewManager->refreshView();
421 421
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 424
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 426 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 428#endif
429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 430 setCaptionBack();
431} 431}
432void KABCore::updateToolBar() 432void KABCore::updateToolBar()
433{ 433{
434 static int iii = 0; 434 static int iii = 0;
435 ++iii; 435 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 436 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 437 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 439}
440KABCore::~KABCore() 440KABCore::~KABCore()
441{ 441{
442 // save(); 442 // save();
443 //saveSettings(); 443 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 444 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 445 delete AddresseeConfig::instance();
446 mAddressBook = 0; 446 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 447 KABC::StdAddressBook::close();
448 448
449 delete syncManager; 449 delete syncManager;
450#ifndef DESKTOP_VERSION 450#ifndef DESKTOP_VERSION
451 if ( infrared ) 451 if ( infrared )
452 delete infrared; 452 delete infrared;
453#endif 453#endif
454} 454}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 455void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 456{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 457 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 458 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 459 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 460 QString fileName;
461 stream >> fileName; 461 stream >> fileName;
462 recieve( fileName ); 462 recieve( fileName );
463 return; 463 return;
464 } 464 }
465} 465}
466void KABCore::toggleBeamReceive( ) 466void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 //qDebug("KA: KABCore::saveSettings() "); 615 //qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 //mMainWindow->repaint(); 847 //mMainWindow->repaint();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) 851 if ( !mMiniSplitter ) {
852 QWidget::resizeEvent( e );
852 return; 853 return;
854 }
855#ifndef DESKTOP_VERSION
853 static int desktop_width = 0; 856 static int desktop_width = 0;
854 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); 857 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() );
855 if ( desktop_width != QApplication::desktop()->width() ) 858 if ( desktop_width != QApplication::desktop()->width() )
856 if ( QApplication::desktop()->width() >= 480 ) { 859 if ( QApplication::desktop()->width() >= 480 ) {
857 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 860 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
858 //qDebug("640 "); 861 //qDebug("640 ");
859 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 862 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
860 //qDebug("switch V->H "); 863 //qDebug("switch V->H ");
861 mMiniSplitter->setOrientation( Qt::Horizontal); 864 mMiniSplitter->setOrientation( Qt::Horizontal);
862 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 865 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
863 } 866 }
864 if ( QApplication::desktop()->width() <= 640 ) { 867 if ( QApplication::desktop()->width() <= 640 ) {
865 bool shot = mMainWindow->isVisible(); 868 bool shot = mMainWindow->isVisible();
866 mMainWindow->showMinimized(); 869 mMainWindow->showMinimized();
867 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 870 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
868 mViewManager->getFilterAction()->setComboWidth( 150 ); 871 mViewManager->getFilterAction()->setComboWidth( 150 );
869 if ( mIncSearchWidget ) 872 if ( mIncSearchWidget )
870 mIncSearchWidget->setSize(); 873 mIncSearchWidget->setSize();
871 if ( shot ) 874 if ( shot )
872 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 875 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
873 } 876 }
874 877
875 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 878 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
876 //qDebug("480 "); 879 //qDebug("480 ");
877 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 880 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
878 //qDebug("switch H->V "); 881 //qDebug("switch H->V ");
879 mMiniSplitter->setOrientation( Qt::Vertical ); 882 mMiniSplitter->setOrientation( Qt::Vertical );
880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 883 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
881 } 884 }
882 if ( QApplication::desktop()->width() <= 640 ) { 885 if ( QApplication::desktop()->width() <= 640 ) {
883 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 886 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
884 bool shot = mMainWindow->isVisible(); 887 bool shot = mMainWindow->isVisible();
885 mMainWindow->showMinimized(); 888 mMainWindow->showMinimized();
886 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 889 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
887 if ( mIncSearchWidget ) { 890 if ( mIncSearchWidget ) {
888 mIncSearchWidget->setSize(); 891 mIncSearchWidget->setSize();
889 } 892 }
890 } else { 893 } else {
891 mViewManager->getFilterAction()->setComboWidth( 0 ); 894 mViewManager->getFilterAction()->setComboWidth( 0 );
892 } 895 }
893 if ( shot ) 896 if ( shot )
894 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 897 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
895 } 898 }
896 } 899 }
897 } 900 }
898 desktop_width = QApplication::desktop()->width(); 901 desktop_width = QApplication::desktop()->width();
902#endif
899 QWidget::resizeEvent( e ); 903 QWidget::resizeEvent( e );
900 904
901} 905}
902void KABCore::export2phone() 906void KABCore::export2phone()
903{ 907{
904 908
905 QStringList uids; 909 QStringList uids;
906 XXPortSelectDialog dlg( this, false, this ); 910 XXPortSelectDialog dlg( this, false, this );
907 if ( dlg.exec() ) 911 if ( dlg.exec() )
908 uids = dlg.uids(); 912 uids = dlg.uids();
909 else 913 else
910 return; 914 return;
911 if ( uids.isEmpty() ) 915 if ( uids.isEmpty() )
912 return; 916 return;
913 // qDebug("count %d ", uids.count()); 917 // qDebug("count %d ", uids.count());
914 918
915 KAex2phonePrefs ex2phone; 919 KAex2phonePrefs ex2phone;
916 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
917 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
918 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
919 923
920 if ( !ex2phone.exec() ) { 924 if ( !ex2phone.exec() ) {
921 return; 925 return;
922 } 926 }
923 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
924 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
925 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
926 930
927 931
928 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
929 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 933 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
930 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 934 KPimGlobalPrefs::instance()->mEx2PhoneModel );
931 935
932 QString fileName = getPhoneFile(); 936 QString fileName = getPhoneFile();
933 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
934 return; 938 return;
935 939
936 message(i18n("Exporting to phone...")); 940 message(i18n("Exporting to phone..."));
937 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 941 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
938 942
939} 943}
940QString KABCore::getPhoneFile() 944QString KABCore::getPhoneFile()
941{ 945{
942#ifdef DESKTOP_VERSION 946#ifdef DESKTOP_VERSION
943 return locateLocal("tmp", "phonefile.vcf"); 947 return locateLocal("tmp", "phonefile.vcf");
944#else 948#else
945 return "/tmp/phonefile.vcf"; 949 return "/tmp/phonefile.vcf";
946#endif 950#endif
947 951
948} 952}
949void KABCore::writeToPhone( ) 953void KABCore::writeToPhone( )
950{ 954{
951 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
952 message(i18n("Export to phone finished!")); 956 message(i18n("Export to phone finished!"));
953 else 957 else
954 qDebug(i18n("KA: Error exporting to phone")); 958 qDebug(i18n("KA: Error exporting to phone"));
955} 959}
956void KABCore::beamVCard() 960void KABCore::beamVCard()
957{ 961{
958 QStringList uids; 962 QStringList uids;
959 XXPortSelectDialog dlg( this, false, this ); 963 XXPortSelectDialog dlg( this, false, this );
960 if ( dlg.exec() ) 964 if ( dlg.exec() )
961 uids = dlg.uids(); 965 uids = dlg.uids();
962 else 966 else
963 return; 967 return;
964 if ( uids.isEmpty() ) 968 if ( uids.isEmpty() )
965 return; 969 return;
966 beamVCard( uids ); 970 beamVCard( uids );
967} 971}
968 972
969 973
970void KABCore::beamVCard(const QStringList& uids) 974void KABCore::beamVCard(const QStringList& uids)
971{ 975{
972 976
973 // LR: we should use the /tmp dir on the Zaurus, 977 // LR: we should use the /tmp dir on the Zaurus,
974 // because: /tmp = RAM, (HOME)/kdepim = flash memory 978 // because: /tmp = RAM, (HOME)/kdepim = flash memory
975 979
976#ifdef DESKTOP_VERSION 980#ifdef DESKTOP_VERSION
977 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
978#else 982#else
979 QString fileName = "/tmp/kapibeamfile.vcf"; 983 QString fileName = "/tmp/kapibeamfile.vcf";
980#endif 984#endif
981 985
982 KABC::VCardConverter converter; 986 KABC::VCardConverter converter;
983 QString description; 987 QString description;
984 QString datastream; 988 QString datastream;
985 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
986 KABC::Addressee a = mAddressBook->findByUid( *it ); 990 KABC::Addressee a = mAddressBook->findByUid( *it );
987 991
988 if ( a.isEmpty() ) 992 if ( a.isEmpty() )
989 continue; 993 continue;
990 994
991 if (description.isEmpty()) 995 if (description.isEmpty())
992 description = a.formattedName(); 996 description = a.formattedName();
993 997
994 QString vcard; 998 QString vcard;
995 converter.addresseeToVCard( a, vcard ); 999 converter.addresseeToVCard( a, vcard );
996 int start = 0; 1000 int start = 0;
997 int next; 1001 int next;
998 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
999 int semi = vcard.find(";", next); 1003 int semi = vcard.find(";", next);
1000 int dopp = vcard.find(":", next); 1004 int dopp = vcard.find(":", next);
1001 int sep; 1005 int sep;
1002 if ( semi < dopp && semi >= 0 ) 1006 if ( semi < dopp && semi >= 0 )
1003 sep = semi ; 1007 sep = semi ;
1004 else 1008 else
1005 sep = dopp; 1009 sep = dopp;
1006 datastream +=vcard.mid( start, next - start); 1010 datastream +=vcard.mid( start, next - start);
1007 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1008 start = sep; 1012 start = sep;
1009 } 1013 }
1010 datastream += vcard.mid( start,vcard.length() ); 1014 datastream += vcard.mid( start,vcard.length() );
1011 } 1015 }
1012#ifndef DESKTOP_VERSION 1016#ifndef DESKTOP_VERSION
1013 QFile outFile(fileName); 1017 QFile outFile(fileName);
1014 if ( outFile.open(IO_WriteOnly) ) { 1018 if ( outFile.open(IO_WriteOnly) ) {
1015 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1016 QTextStream t( &outFile ); // use a text stream 1020 QTextStream t( &outFile ); // use a text stream
1017 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1021 //t.setEncoding( QTextStream::UnicodeUTF8 );
1018 t.setEncoding( QTextStream::Latin1 ); 1022 t.setEncoding( QTextStream::Latin1 );
1019 t <<datastream.latin1(); 1023 t <<datastream.latin1();
1020 outFile.close(); 1024 outFile.close();
1021 Ir *ir = new Ir( this ); 1025 Ir *ir = new Ir( this );
1022 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1023 ir->send( fileName, description, "text/x-vCard" ); 1027 ir->send( fileName, description, "text/x-vCard" );
1024 } else { 1028 } else {
1025 qDebug("KA: Error open temp beam file "); 1029 qDebug("KA: Error open temp beam file ");
1026 return; 1030 return;
1027 } 1031 }
1028#endif 1032#endif
1029 1033
1030} 1034}
1031 1035
1032void KABCore::beamDone( Ir *ir ) 1036void KABCore::beamDone( Ir *ir )
1033{ 1037{
1034#ifndef DESKTOP_VERSION 1038#ifndef DESKTOP_VERSION
1035 delete ir; 1039 delete ir;
1036#endif 1040#endif
1037 topLevelWidget()->raise(); 1041 topLevelWidget()->raise();
1038 message( i18n("Beaming finished!") ); 1042 message( i18n("Beaming finished!") );
1039} 1043}
1040 1044
1041 1045
1042void KABCore::browse( const QString& url ) 1046void KABCore::browse( const QString& url )
1043{ 1047{
1044#ifndef KAB_EMBEDDED 1048#ifndef KAB_EMBEDDED
1045 kapp->invokeBrowser( url ); 1049 kapp->invokeBrowser( url );
1046#else //KAB_EMBEDDED 1050#else //KAB_EMBEDDED
1047 qDebug("KABCore::browse must be fixed"); 1051 qDebug("KABCore::browse must be fixed");
1048#endif //KAB_EMBEDDED 1052#endif //KAB_EMBEDDED
1049} 1053}
1050 1054
1051void KABCore::selectAllContacts() 1055void KABCore::selectAllContacts()
1052{ 1056{
1053 mViewManager->setSelected( QString::null, true ); 1057 mViewManager->setSelected( QString::null, true );
1054} 1058}
1055 1059
1056void KABCore::deleteContacts() 1060void KABCore::deleteContacts()
1057{ 1061{
1058 QStringList uidList = mViewManager->selectedUids(); 1062 QStringList uidList = mViewManager->selectedUids();
1059 deleteContacts( uidList ); 1063 deleteContacts( uidList );
1060} 1064}
1061 1065
1062void KABCore::deleteContacts( const QStringList &uids ) 1066void KABCore::deleteContacts( const QStringList &uids )
1063{ 1067{
1064 1068
1065 if ( uids.count() > 0 ) { 1069 if ( uids.count() > 0 ) {
1066 1070
1067 if ( KABPrefs::instance()->mAskForDelete ) { 1071 if ( KABPrefs::instance()->mAskForDelete ) {
1068 int count = uids.count(); 1072 int count = uids.count();
1069 if ( count > 5 ) count = 5; 1073 if ( count > 5 ) count = 5;
1070 QString cNames; 1074 QString cNames;
1071 int i; 1075 int i;
1072 for ( i = 0; i < count ; ++i ) { 1076 for ( i = 0; i < count ; ++i ) {
1073 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1074 } 1078 }
1075 if ( uids.count() > 5 ) 1079 if ( uids.count() > 5 )
1076 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1077 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1078 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1079 return; 1083 return;
1080 } 1084 }
1081 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1082 UndoStack::instance()->push( command ); 1086 UndoStack::instance()->push( command );
1083 RedoStack::instance()->clear(); 1087 RedoStack::instance()->clear();
1084 1088
1085 // now if we deleted anything, refresh 1089 // now if we deleted anything, refresh
1086 setContactSelected( QString::null ); 1090 setContactSelected( QString::null );
1087 setModified( true ); 1091 setModified( true );
1088 } 1092 }
1089} 1093}
1090 1094
1091void KABCore::copyContacts() 1095void KABCore::copyContacts()
1092{ 1096{
1093 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1094 1098
1095 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1096 1100
1097 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1098 1102
1099 QClipboard *cb = QApplication::clipboard(); 1103 QClipboard *cb = QApplication::clipboard();
1100 cb->setText( clipText ); 1104 cb->setText( clipText );
1101} 1105}
1102 1106
1103void KABCore::cutContacts() 1107void KABCore::cutContacts()
1104{ 1108{
1105 QStringList uidList = mViewManager->selectedUids(); 1109 QStringList uidList = mViewManager->selectedUids();
1106 1110
1107//US if ( uidList.size() > 0 ) { 1111//US if ( uidList.size() > 0 ) {
1108 if ( uidList.count() > 0 ) { 1112 if ( uidList.count() > 0 ) {
1109 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1110 UndoStack::instance()->push( command ); 1114 UndoStack::instance()->push( command );
1111 RedoStack::instance()->clear(); 1115 RedoStack::instance()->clear();
1112 1116
1113 setModified( true ); 1117 setModified( true );
1114 } 1118 }
1115} 1119}
1116 1120
1117void KABCore::pasteContacts() 1121void KABCore::pasteContacts()
1118{ 1122{
1119 QClipboard *cb = QApplication::clipboard(); 1123 QClipboard *cb = QApplication::clipboard();
1120 1124
1121 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1122 1126
1123 pasteContacts( list ); 1127 pasteContacts( list );
1124} 1128}
1125 1129
1126void KABCore::pasteContacts( KABC::Addressee::List &list ) 1130void KABCore::pasteContacts( KABC::Addressee::List &list )
1127{ 1131{
1128 KABC::Resource *resource = requestResource( this ); 1132 KABC::Resource *resource = requestResource( this );
1129 KABC::Addressee::List::Iterator it; 1133 KABC::Addressee::List::Iterator it;
1130 for ( it = list.begin(); it != list.end(); ++it ) 1134 for ( it = list.begin(); it != list.end(); ++it )
1131 (*it).setResource( resource ); 1135 (*it).setResource( resource );
1132 1136
1133 PwPasteCommand *command = new PwPasteCommand( this, list ); 1137 PwPasteCommand *command = new PwPasteCommand( this, list );
1134 UndoStack::instance()->push( command ); 1138 UndoStack::instance()->push( command );
1135 RedoStack::instance()->clear(); 1139 RedoStack::instance()->clear();
1136 1140
1137 setModified( true ); 1141 setModified( true );
1138} 1142}
1139 1143
1140void KABCore::setWhoAmI() 1144void KABCore::setWhoAmI()
1141{ 1145{
1142 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1143 1147
1144 if ( addrList.count() > 1 ) { 1148 if ( addrList.count() > 1 ) {
1145 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1146 return; 1150 return;
1147 } 1151 }
1148 1152
1149 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1150 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1151 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1152} 1156}
1153void KABCore::editCategories() 1157void KABCore::editCategories()
1154{ 1158{
1155 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1156 dlg.exec(); 1160 dlg.exec();
1157} 1161}
1158void KABCore::setCategories() 1162void KABCore::setCategories()
1159{ 1163{
1160 1164
1161 QStringList uids; 1165 QStringList uids;
1162 XXPortSelectDialog dlgx( this, false, this ); 1166 XXPortSelectDialog dlgx( this, false, this );
1163 if ( dlgx.exec() ) 1167 if ( dlgx.exec() )
1164 uids = dlgx.uids(); 1168 uids = dlgx.uids();
1165 else 1169 else
1166 return; 1170 return;
1167 if ( uids.isEmpty() ) 1171 if ( uids.isEmpty() )
1168 return; 1172 return;
1169 // qDebug("count %d ", uids.count()); 1173 // qDebug("count %d ", uids.count());
1170 1174
1171 1175
1172 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1173 if ( !dlg.exec() ) { 1177 if ( !dlg.exec() ) {
1174 message( i18n("Setting categories cancelled") ); 1178 message( i18n("Setting categories cancelled") );
1175 return; 1179 return;
1176 } 1180 }
1177 bool merge = false; 1181 bool merge = false;
1178 QString msg = i18n( "Merge with existing categories?" ); 1182 QString msg = i18n( "Merge with existing categories?" );
1179 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1180 merge = true; 1184 merge = true;
1181 1185
1182 message( i18n("Setting categories ... please wait!") ); 1186 message( i18n("Setting categories ... please wait!") );
1183 QStringList categories = dlg.selectedCategories(); 1187 QStringList categories = dlg.selectedCategories();
1184 1188
1185 //QStringList uids = mViewManager->selectedUids(); 1189 //QStringList uids = mViewManager->selectedUids();
1186 QStringList::Iterator it; 1190 QStringList::Iterator it;
1187 for ( it = uids.begin(); it != uids.end(); ++it ) { 1191 for ( it = uids.begin(); it != uids.end(); ++it ) {
1188 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1192 KABC::Addressee addr = mAddressBook->findByUid( *it );
1189 if ( !addr.isEmpty() ) { 1193 if ( !addr.isEmpty() ) {
1190 if ( !merge ) 1194 if ( !merge )
1191 addr.setCategories( categories ); 1195 addr.setCategories( categories );
1192 else { 1196 else {
1193 QStringList addrCategories = addr.categories(); 1197 QStringList addrCategories = addr.categories();
1194 QStringList::Iterator catIt; 1198 QStringList::Iterator catIt;
1195 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1196 if ( !addrCategories.contains( *catIt ) ) 1200 if ( !addrCategories.contains( *catIt ) )
1197 addrCategories.append( *catIt ); 1201 addrCategories.append( *catIt );
1198 } 1202 }
1199 addr.setCategories( addrCategories ); 1203 addr.setCategories( addrCategories );
1200 } 1204 }
1201 mAddressBook->insertAddressee( addr ); 1205 mAddressBook->insertAddressee( addr );
1202 } 1206 }
1203 } 1207 }
1204 1208
1205 if ( uids.count() > 0 ) 1209 if ( uids.count() > 0 )
1206 setModified( true ); 1210 setModified( true );
1207 message( i18n("Setting categories completed!") ); 1211 message( i18n("Setting categories completed!") );
1208} 1212}
1209 1213
1210void KABCore::setSearchFields( const KABC::Field::List &fields ) 1214void KABCore::setSearchFields( const KABC::Field::List &fields )
1211{ 1215{
1212 mIncSearchWidget->setFields( fields ); 1216 mIncSearchWidget->setFields( fields );
1213} 1217}
1214 1218
1215void KABCore::incrementalSearch( const QString& text ) 1219void KABCore::incrementalSearch( const QString& text )
1216{ 1220{
1217 QString stext; 1221 QString stext;
1218 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1219 stext = "*" + text; 1223 stext = "*" + text;
1220 } else { 1224 } else {
1221 stext = text; 1225 stext = text;
1222 } 1226 }
1223 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1224} 1228}
1225void KABCore::incrementalSearchJump( const QString& text ) 1229void KABCore::incrementalSearchJump( const QString& text )
1226{ 1230{
1227 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1228} 1232}
1229 1233
1230void KABCore::setModified() 1234void KABCore::setModified()
1231{ 1235{
1232 setModified( true ); 1236 setModified( true );
1233} 1237}
1234 1238
1235void KABCore::setModifiedWOrefresh() 1239void KABCore::setModifiedWOrefresh()
1236{ 1240{
1237 // qDebug("KABCore::setModifiedWOrefresh() "); 1241 // qDebug("KABCore::setModifiedWOrefresh() ");
1238 mModified = true; 1242 mModified = true;
1239 mActionSave->setEnabled( mModified ); 1243 mActionSave->setEnabled( mModified );
1240 1244
1241 1245
1242} 1246}
1243void KABCore::setModified( bool modified ) 1247void KABCore::setModified( bool modified )
1244{ 1248{
1245 mModified = modified; 1249 mModified = modified;
1246 mActionSave->setEnabled( mModified ); 1250 mActionSave->setEnabled( mModified );
1247 1251
1248 if ( modified ) 1252 if ( modified )
1249 mJumpButtonBar->recreateButtons(); 1253 mJumpButtonBar->recreateButtons();
1250 1254
1251 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1252 1256
1253} 1257}
1254 1258
1255bool KABCore::modified() const 1259bool KABCore::modified() const
1256{ 1260{
1257 return mModified; 1261 return mModified;
1258} 1262}
1259 1263
1260void KABCore::contactModified( const KABC::Addressee &addr ) 1264void KABCore::contactModified( const KABC::Addressee &addr )
1261{ 1265{
1262 addrModified( addr ); 1266 addrModified( addr );
1263#if 0 // debug only 1267#if 0 // debug only
1264 KABC::Addressee ad = addr; 1268 KABC::Addressee ad = addr;
1265 ad.computeCsum( "123"); 1269 ad.computeCsum( "123");
1266#endif 1270#endif
1267} 1271}
1268 1272
1269void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1270{ 1274{
1271 1275
1272 Command *command = 0; 1276 Command *command = 0;
1273 QString uid; 1277 QString uid;
1274 1278
1275 // check if it exists already 1279 // check if it exists already
1276 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1277 if ( origAddr.isEmpty() ) 1281 if ( origAddr.isEmpty() )
1278 command = new PwNewCommand( mAddressBook, addr ); 1282 command = new PwNewCommand( mAddressBook, addr );
1279 else { 1283 else {
1280 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1284 command = new PwEditCommand( mAddressBook, origAddr, addr );
1281 uid = addr.uid(); 1285 uid = addr.uid();
1282 } 1286 }
1283 1287
1284 UndoStack::instance()->push( command ); 1288 UndoStack::instance()->push( command );
1285 RedoStack::instance()->clear(); 1289 RedoStack::instance()->clear();
1286 if ( updateDetails ) 1290 if ( updateDetails )
1287 mDetails->setAddressee( addr ); 1291 mDetails->setAddressee( addr );
1288 setModified( true ); 1292 setModified( true );
1289} 1293}
1290 1294
1291void KABCore::newContact() 1295void KABCore::newContact()
1292{ 1296{
1293 1297
1294 1298
1295 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1296 1300
1297 QPtrList<KRES::Resource> kresResources; 1301 QPtrList<KRES::Resource> kresResources;
1298 QPtrListIterator<KABC::Resource> it( kabcResources ); 1302 QPtrListIterator<KABC::Resource> it( kabcResources );
1299 KABC::Resource *resource; 1303 KABC::Resource *resource;
1300 while ( ( resource = it.current() ) != 0 ) { 1304 while ( ( resource = it.current() ) != 0 ) {
1301 ++it; 1305 ++it;
1302 if ( !resource->readOnly() ) { 1306 if ( !resource->readOnly() ) {
1303 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1304 if ( res ) 1308 if ( res )
1305 kresResources.append( res ); 1309 kresResources.append( res );
1306 } 1310 }
1307 } 1311 }
1308 1312
1309 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1310 resource = static_cast<KABC::Resource*>( res ); 1314 resource = static_cast<KABC::Resource*>( res );
1311 1315
1312 if ( resource ) { 1316 if ( resource ) {
1313 KABC::Addressee addr; 1317 KABC::Addressee addr;
1314 addr.setResource( resource ); 1318 addr.setResource( resource );
1315 mEditorDialog->setAddressee( addr ); 1319 mEditorDialog->setAddressee( addr );
1316 mEditorDialog->setCaption( i18n("Edit new contact")); 1320 mEditorDialog->setCaption( i18n("Edit new contact"));
1317 KApplication::execDialog ( mEditorDialog ); 1321 KApplication::execDialog ( mEditorDialog );
1318 1322
1319 } else 1323 } else
1320 return; 1324 return;
1321 1325
1322 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1326 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1323 1327
1324 1328
1325} 1329}
1326 1330
1327void KABCore::addEmail( QString aStr ) 1331void KABCore::addEmail( QString aStr )
1328{ 1332{
1329#ifndef KAB_EMBEDDED 1333#ifndef KAB_EMBEDDED
1330 QString fullName, email; 1334 QString fullName, email;
1331 1335
1332 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1333 1337
1334 // Try to lookup the addressee matching the email address 1338 // Try to lookup the addressee matching the email address
1335 bool found = false; 1339 bool found = false;
1336 QStringList emailList; 1340 QStringList emailList;
1337 KABC::AddressBook::Iterator it; 1341 KABC::AddressBook::Iterator it;
1338 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1339 emailList = (*it).emails(); 1343 emailList = (*it).emails();
1340 if ( emailList.contains( email ) > 0 ) { 1344 if ( emailList.contains( email ) > 0 ) {
1341 found = true; 1345 found = true;
1342 (*it).setNameFromString( fullName ); 1346 (*it).setNameFromString( fullName );
1343 editContact( (*it).uid() ); 1347 editContact( (*it).uid() );
1344 } 1348 }
1345 } 1349 }
1346 1350
1347 if ( !found ) { 1351 if ( !found ) {
1348 KABC::Addressee addr; 1352 KABC::Addressee addr;
1349 addr.setNameFromString( fullName ); 1353 addr.setNameFromString( fullName );
1350 addr.insertEmail( email, true ); 1354 addr.insertEmail( email, true );
1351 1355
1352 mAddressBook->insertAddressee( addr ); 1356 mAddressBook->insertAddressee( addr );
1353 mViewManager->refreshView( addr.uid() ); 1357 mViewManager->refreshView( addr.uid() );
1354 editContact( addr.uid() ); 1358 editContact( addr.uid() );
1355 } 1359 }
1356#else //KAB_EMBEDDED 1360#else //KAB_EMBEDDED
1357 qDebug("KABCore::addEmail finsih method"); 1361 qDebug("KABCore::addEmail finsih method");
1358#endif //KAB_EMBEDDED 1362#endif //KAB_EMBEDDED
1359} 1363}
1360 1364
1361void KABCore::importVCard( const KURL &url, bool showPreview ) 1365void KABCore::importVCard( const KURL &url, bool showPreview )
1362{ 1366{
1363 mXXPortManager->importVCard( url, showPreview ); 1367 mXXPortManager->importVCard( url, showPreview );
1364} 1368}
1365void KABCore::importFromOL() 1369void KABCore::importFromOL()
1366{ 1370{
1367#ifdef _OL_IMPORT_ 1371#ifdef _OL_IMPORT_
1368 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1369 idgl->exec(); 1373 idgl->exec();
1370 KABC::Addressee::List list = idgl->getAddressList(); 1374 KABC::Addressee::List list = idgl->getAddressList();
1371 if ( list.count() > 0 ) { 1375 if ( list.count() > 0 ) {
1372 KABC::Addressee::List listNew; 1376 KABC::Addressee::List listNew;
1373 KABC::Addressee::List listExisting; 1377 KABC::Addressee::List listExisting;
1374 KABC::Addressee::List::Iterator it; 1378 KABC::Addressee::List::Iterator it;
1375 KABC::AddressBook::Iterator iter; 1379 KABC::AddressBook::Iterator iter;
1376 for ( it = list.begin(); it != list.end(); ++it ) { 1380 for ( it = list.begin(); it != list.end(); ++it ) {
1377 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1378 listNew.append( (*it) ); 1382 listNew.append( (*it) );
1379 else 1383 else
1380 listExisting.append( (*it) ); 1384 listExisting.append( (*it) );
1381 } 1385 }
1382 if ( listExisting.count() > 0 ) 1386 if ( listExisting.count() > 0 )
1383 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1384 if ( listNew.count() > 0 ) { 1388 if ( listNew.count() > 0 ) {
1385 pasteWithNewUid = false; 1389 pasteWithNewUid = false;
1386 pasteContacts( listNew ); 1390 pasteContacts( listNew );
1387 pasteWithNewUid = true; 1391 pasteWithNewUid = true;
1388 } 1392 }
1389 } 1393 }
1390 delete idgl; 1394 delete idgl;
1391#endif 1395#endif
1392} 1396}
1393 1397
1394void KABCore::importVCard( const QString &vCard, bool showPreview ) 1398void KABCore::importVCard( const QString &vCard, bool showPreview )
1395{ 1399{
1396 mXXPortManager->importVCard( vCard, showPreview ); 1400 mXXPortManager->importVCard( vCard, showPreview );
1397} 1401}
1398 1402
1399//US added a second method without defaultparameter 1403//US added a second method without defaultparameter
1400void KABCore::editContact2() { 1404void KABCore::editContact2() {
1401 editContact( QString::null ); 1405 editContact( QString::null );
1402} 1406}
1403 1407
1404void KABCore::editContact( const QString &uid ) 1408void KABCore::editContact( const QString &uid )
1405{ 1409{
1406 1410
1407 if ( mExtensionManager->isQuickEditVisible() ) 1411 if ( mExtensionManager->isQuickEditVisible() )
1408 return; 1412 return;
1409 1413
1410 // First, locate the contact entry 1414 // First, locate the contact entry
1411 QString localUID = uid; 1415 QString localUID = uid;
1412 if ( localUID.isNull() ) { 1416 if ( localUID.isNull() ) {
1413 QStringList uidList = mViewManager->selectedUids(); 1417 QStringList uidList = mViewManager->selectedUids();
1414 if ( uidList.count() > 0 ) 1418 if ( uidList.count() > 0 )
1415 localUID = *( uidList.at( 0 ) ); 1419 localUID = *( uidList.at( 0 ) );
1416 } 1420 }
1417 1421
1418 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1422 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1419 if ( !addr.isEmpty() ) { 1423 if ( !addr.isEmpty() ) {
1420 mEditorDialog->setAddressee( addr ); 1424 mEditorDialog->setAddressee( addr );
1421 KApplication::execDialog ( mEditorDialog ); 1425 KApplication::execDialog ( mEditorDialog );
1422 } 1426 }
1423} 1427}
1424 1428
1425/** 1429/**
1426 Shows or edits the detail view for the given uid. If the uid is QString::null, 1430 Shows or edits the detail view for the given uid. If the uid is QString::null,
1427 the method will try to find a selected addressee in the view. 1431 the method will try to find a selected addressee in the view.
1428 */ 1432 */
1429void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1430{ 1434{
1431 if ( mMultipleViewsAtOnce ) 1435 if ( mMultipleViewsAtOnce )
1432 { 1436 {
1433 editContact( uid ); 1437 editContact( uid );
1434 } 1438 }
1435 else 1439 else
1436 { 1440 {
1437 setDetailsVisible( true ); 1441 setDetailsVisible( true );
1438 mActionDetails->setChecked(true); 1442 mActionDetails->setChecked(true);
1439 } 1443 }
1440 1444
1441} 1445}
1442 1446
1443void KABCore::save() 1447void KABCore::save()
1444{ 1448{
1445 if (syncManager->blockSave()) 1449 if (syncManager->blockSave())
1446 return; 1450 return;
1447 if ( !mModified ) 1451 if ( !mModified )
1448 return; 1452 return;
1449 1453
1450 syncManager->setBlockSave(true); 1454 syncManager->setBlockSave(true);
1451 QString text = i18n( "There was an error while attempting to save\n the " 1455 QString text = i18n( "There was an error while attempting to save\n the "
1452 "address book. Please check that some \nother application is " 1456 "address book. Please check that some \nother application is "
1453 "not using it. " ); 1457 "not using it. " );
1454 message(i18n("Saving ... please wait! "), false); 1458 message(i18n("Saving ... please wait! "), false);
1455 //qApp->processEvents(); 1459 //qApp->processEvents();
1456#ifndef KAB_EMBEDDED 1460#ifndef KAB_EMBEDDED
1457 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1458 if ( !b || !b->save() ) { 1462 if ( !b || !b->save() ) {
1459 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1460 } 1464 }
1461#else //KAB_EMBEDDED 1465#else //KAB_EMBEDDED
1462 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1463 if ( !b || !b->save() ) { 1467 if ( !b || !b->save() ) {
1464 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1465 } 1469 }
1466#endif //KAB_EMBEDDED 1470#endif //KAB_EMBEDDED
1467 1471
1468 message(i18n("Addressbook saved!")); 1472 message(i18n("Addressbook saved!"));
1469 setModified( false ); 1473 setModified( false );
1470 syncManager->setBlockSave(false); 1474 syncManager->setBlockSave(false);
1471} 1475}
1472 1476
1473 1477
1474void KABCore::undo() 1478void KABCore::undo()
1475{ 1479{
1476 UndoStack::instance()->undo(); 1480 UndoStack::instance()->undo();
1477 1481
1478 // Refresh the view 1482 // Refresh the view
1479 mViewManager->refreshView(); 1483 mViewManager->refreshView();
1480} 1484}
1481 1485
1482void KABCore::redo() 1486void KABCore::redo()
1483{ 1487{
1484 RedoStack::instance()->redo(); 1488 RedoStack::instance()->redo();
1485 1489
1486 // Refresh the view 1490 // Refresh the view
1487 mViewManager->refreshView(); 1491 mViewManager->refreshView();
1488} 1492}
1489void KABCore::setJumpButtonBar( bool visible ) 1493void KABCore::setJumpButtonBar( bool visible )
1490{ 1494{
1491 setJumpButtonBarVisible(visible ); 1495 setJumpButtonBarVisible(visible );
1492 saveSettings(); 1496 saveSettings();
1493} 1497}
1494void KABCore::setJumpButtonBarVisible( bool visible ) 1498void KABCore::setJumpButtonBarVisible( bool visible )
1495{ 1499{
1496 if (mMultipleViewsAtOnce) 1500 if (mMultipleViewsAtOnce)
1497 { 1501 {
1498 if ( visible ) 1502 if ( visible )
1499 mJumpButtonBar->show(); 1503 mJumpButtonBar->show();
1500 else 1504 else
1501 mJumpButtonBar->hide(); 1505 mJumpButtonBar->hide();
1502 } 1506 }
1503 else 1507 else
1504 { 1508 {
1505 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1506 if (mViewManager->isVisible()) 1510 if (mViewManager->isVisible())
1507 { 1511 {
1508 if ( visible ) 1512 if ( visible )
1509 mJumpButtonBar->show(); 1513 mJumpButtonBar->show();
1510 else 1514 else
1511 mJumpButtonBar->hide(); 1515 mJumpButtonBar->hide();
1512 } 1516 }
1513 else 1517 else
1514 { 1518 {
1515 mJumpButtonBar->hide(); 1519 mJumpButtonBar->hide();
1516 } 1520 }
1517 } 1521 }
1518 if ( visible ) { 1522 if ( visible ) {
1519 if ( mIncSearchWidget->currentItem() == 0 ) { 1523 if ( mIncSearchWidget->currentItem() == 0 ) {
1520 message( i18n("Change search field enable jump bar") ); 1524 message( i18n("Change search field enable jump bar") );
1521 } 1525 }
1522 } 1526 }
1523} 1527}
1524 1528
1525 1529
1526void KABCore::setDetailsToState() 1530void KABCore::setDetailsToState()
1527{ 1531{
1528 setDetailsVisible( mActionDetails->isChecked() ); 1532 setDetailsVisible( mActionDetails->isChecked() );
1529} 1533}
1530void KABCore::setDetailsToggle() 1534void KABCore::setDetailsToggle()
1531{ 1535{
1532 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1536 mActionDetails->setChecked( !mActionDetails->isChecked() );
1533 setDetailsToState(); 1537 setDetailsToState();
1534} 1538}
1535 1539
1536 1540
1537 1541
1538void KABCore::setDetailsVisible( bool visible ) 1542void KABCore::setDetailsVisible( bool visible )
1539{ 1543{
1540 if (visible && mDetails->isHidden()) 1544 if (visible && mDetails->isHidden())
1541 { 1545 {
1542 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1543 if ( addrList.count() > 0 ) 1547 if ( addrList.count() > 0 )
1544 mDetails->setAddressee( addrList[ 0 ] ); 1548 mDetails->setAddressee( addrList[ 0 ] );
1545 } 1549 }
1546 1550
1547 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1548 // the listview and the detailview. We do that by changing the splitbar size. 1552 // the listview and the detailview. We do that by changing the splitbar size.
1549 if (mMultipleViewsAtOnce) 1553 if (mMultipleViewsAtOnce)
1550 { 1554 {
1551 if ( visible ) 1555 if ( visible )
1552 mDetails->show(); 1556 mDetails->show();
1553 else 1557 else
1554 mDetails->hide(); 1558 mDetails->hide();
1555 } 1559 }
1556 else 1560 else
1557 { 1561 {
1558 if ( visible ) { 1562 if ( visible ) {
1559 mViewManager->hide(); 1563 mViewManager->hide();
1560 mDetails->show(); 1564 mDetails->show();
1561 mIncSearchWidget->setFocus(); 1565 mIncSearchWidget->setFocus();
1562 } 1566 }
1563 else { 1567 else {
1564 mViewManager->show(); 1568 mViewManager->show();
1565 mDetails->hide(); 1569 mDetails->hide();
1566 mViewManager->setFocusAV(); 1570 mViewManager->setFocusAV();
1567 } 1571 }
1568 setJumpButtonBarVisible( !visible ); 1572 setJumpButtonBarVisible( !visible );
1569 } 1573 }
1570 1574
1571} 1575}
1572 1576
1573void KABCore::extensionChanged( int id ) 1577void KABCore::extensionChanged( int id )
1574{ 1578{
1575 //change the details view only for non desktop systems 1579 //change the details view only for non desktop systems
1576#ifndef DESKTOP_VERSION 1580#ifndef DESKTOP_VERSION
1577 1581
1578 if (id == 0) 1582 if (id == 0)
1579 { 1583 {
1580 //the user disabled the extension. 1584 //the user disabled the extension.
1581 1585
1582 if (mMultipleViewsAtOnce) 1586 if (mMultipleViewsAtOnce)
1583 { // enable detailsview again 1587 { // enable detailsview again
1584 setDetailsVisible( true ); 1588 setDetailsVisible( true );
1585 mActionDetails->setChecked( true ); 1589 mActionDetails->setChecked( true );
1586 } 1590 }
1587 else 1591 else
1588 { //go back to the listview 1592 { //go back to the listview
1589 setDetailsVisible( false ); 1593 setDetailsVisible( false );
1590 mActionDetails->setChecked( false ); 1594 mActionDetails->setChecked( false );
1591 mActionDetails->setEnabled(true); 1595 mActionDetails->setEnabled(true);
1592 } 1596 }
1593 1597
1594 } 1598 }
1595 else 1599 else
1596 { 1600 {
1597 //the user enabled the extension. 1601 //the user enabled the extension.
1598 setDetailsVisible( false ); 1602 setDetailsVisible( false );
1599 mActionDetails->setChecked( false ); 1603 mActionDetails->setChecked( false );
1600 1604
1601 if (!mMultipleViewsAtOnce) 1605 if (!mMultipleViewsAtOnce)
1602 { 1606 {
1603 mActionDetails->setEnabled(false); 1607 mActionDetails->setEnabled(false);
1604 } 1608 }
1605 1609
1606 mExtensionManager->setSelectionChanged(); 1610 mExtensionManager->setSelectionChanged();
1607 1611
1608 } 1612 }
1609 1613
1610#endif// DESKTOP_VERSION 1614#endif// DESKTOP_VERSION
1611 1615
1612} 1616}
1613 1617
1614 1618
1615void KABCore::extensionModified( const KABC::Addressee::List &list ) 1619void KABCore::extensionModified( const KABC::Addressee::List &list )
1616{ 1620{
1617 1621
1618 if ( list.count() != 0 ) { 1622 if ( list.count() != 0 ) {
1619 KABC::Addressee::List::ConstIterator it; 1623 KABC::Addressee::List::ConstIterator it;
1620 for ( it = list.begin(); it != list.end(); ++it ) 1624 for ( it = list.begin(); it != list.end(); ++it )
1621 mAddressBook->insertAddressee( *it ); 1625 mAddressBook->insertAddressee( *it );
1622 if ( list.count() > 1 ) 1626 if ( list.count() > 1 )
1623 setModified(); 1627 setModified();
1624 else 1628 else
1625 setModifiedWOrefresh(); 1629 setModifiedWOrefresh();
1626 } 1630 }
1627 if ( list.count() == 0 ) 1631 if ( list.count() == 0 )
1628 mViewManager->refreshView(); 1632 mViewManager->refreshView();
1629 else 1633 else
1630 mViewManager->refreshView( list[ 0 ].uid() ); 1634 mViewManager->refreshView( list[ 0 ].uid() );
1631 1635
1632 1636
1633 1637
1634} 1638}
1635 1639
1636QString KABCore::getNameByPhone( const QString &phone ) 1640QString KABCore::getNameByPhone( const QString &phone )
1637{ 1641{
1638#ifndef KAB_EMBEDDED 1642#ifndef KAB_EMBEDDED
1639 QRegExp r( "[/*/-/ ]" ); 1643 QRegExp r( "[/*/-/ ]" );
1640 QString localPhone( phone ); 1644 QString localPhone( phone );
1641 1645
1642 bool found = false; 1646 bool found = false;
1643 QString ownerName = ""; 1647 QString ownerName = "";
1644 KABC::AddressBook::Iterator iter; 1648 KABC::AddressBook::Iterator iter;
1645 KABC::PhoneNumber::List::Iterator phoneIter; 1649 KABC::PhoneNumber::List::Iterator phoneIter;
1646 KABC::PhoneNumber::List phoneList; 1650 KABC::PhoneNumber::List phoneList;
1647 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1648 phoneList = (*iter).phoneNumbers(); 1652 phoneList = (*iter).phoneNumbers();
1649 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1650 ++phoneIter) { 1654 ++phoneIter) {
1651 // Get rid of separator chars so just the numbers are compared. 1655 // Get rid of separator chars so just the numbers are compared.
1652 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1653 ownerName = (*iter).formattedName(); 1657 ownerName = (*iter).formattedName();
1654 found = true; 1658 found = true;
1655 } 1659 }
1656 } 1660 }
1657 } 1661 }
1658 1662
1659 return ownerName; 1663 return ownerName;
1660#else //KAB_EMBEDDED 1664#else //KAB_EMBEDDED
1661 qDebug("KABCore::getNameByPhone finsih method"); 1665 qDebug("KABCore::getNameByPhone finsih method");
1662 return ""; 1666 return "";
1663#endif //KAB_EMBEDDED 1667#endif //KAB_EMBEDDED
1664 1668
1665} 1669}
1666void KABCore::openConfigGlobalDialog() 1670void KABCore::openConfigGlobalDialog()
1667{ 1671{
1668 KPimPrefsGlobalDialog gc ( this ); 1672 KPimPrefsGlobalDialog gc ( this );
1669 gc.exec(); 1673 gc.exec();
1670} 1674}
1671void KABCore::openConfigDialog() 1675void KABCore::openConfigDialog()
1672{ 1676{
1673 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1674 1678
1675 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1676 ConfigureDialog->setMainWidget( kabcfg ); 1680 ConfigureDialog->setMainWidget( kabcfg );
1677 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1681 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1678 this, SLOT( configurationChanged() ) ); 1682 this, SLOT( configurationChanged() ) );
1679 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1683 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1680 kabcfg, SLOT( save() ) ); 1684 kabcfg, SLOT( save() ) );
1681 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1682 this, SLOT( configurationChanged() ) ); 1686 this, SLOT( configurationChanged() ) );
1683 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1684 kabcfg, SLOT( save() ) ); 1688 kabcfg, SLOT( save() ) );
1685 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1686 kabcfg, SLOT( defaults() ) ); 1690 kabcfg, SLOT( defaults() ) );
1687 saveSettings(); 1691 saveSettings();
1688 kabcfg->load(); 1692 kabcfg->load();
1689#ifndef DESKTOP_VERSION 1693#ifndef DESKTOP_VERSION
1690 if ( QApplication::desktop()->height() <= 480 ) 1694 if ( QApplication::desktop()->height() <= 480 )
1691 ConfigureDialog->hideButtons(); 1695 ConfigureDialog->hideButtons();
1692 ConfigureDialog->showMaximized(); 1696 ConfigureDialog->showMaximized();
1693#endif 1697#endif
1694 if ( ConfigureDialog->exec() ) 1698 if ( ConfigureDialog->exec() )
1695 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1696 delete ConfigureDialog; 1700 delete ConfigureDialog;
1697} 1701}
1698 1702
1699void KABCore::openLDAPDialog() 1703void KABCore::openLDAPDialog()
1700{ 1704{
1701#ifndef KAB_EMBEDDED 1705#ifndef KAB_EMBEDDED
1702 if ( !mLdapSearchDialog ) { 1706 if ( !mLdapSearchDialog ) {
1703 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1704 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1705 SLOT( refreshView() ) ); 1709 SLOT( refreshView() ) );
1706 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1707 SLOT( setModified() ) ); 1711 SLOT( setModified() ) );
1708 } else 1712 } else
1709 mLdapSearchDialog->restoreSettings(); 1713 mLdapSearchDialog->restoreSettings();
1710 1714
1711 if ( mLdapSearchDialog->isOK() ) 1715 if ( mLdapSearchDialog->isOK() )
1712 mLdapSearchDialog->exec(); 1716 mLdapSearchDialog->exec();
1713#else //KAB_EMBEDDED 1717#else //KAB_EMBEDDED
1714 qDebug("KABCore::openLDAPDialog() finsih method"); 1718 qDebug("KABCore::openLDAPDialog() finsih method");
1715#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1716} 1720}
1717 1721
1718void KABCore::print() 1722void KABCore::print()
1719{ 1723{
1720#ifndef KAB_EMBEDDED 1724#ifndef KAB_EMBEDDED
1721 KPrinter printer; 1725 KPrinter printer;
1722 if ( !printer.setup( this ) ) 1726 if ( !printer.setup( this ) )
1723 return; 1727 return;
1724 1728
1725 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1726 mViewManager->selectedUids(), this ); 1730 mViewManager->selectedUids(), this );
1727 1731
1728 wizard.exec(); 1732 wizard.exec();
1729#else //KAB_EMBEDDED 1733#else //KAB_EMBEDDED
1730 qDebug("KABCore::print() finsih method"); 1734 qDebug("KABCore::print() finsih method");
1731#endif //KAB_EMBEDDED 1735#endif //KAB_EMBEDDED
1732 1736
1733} 1737}
1734 1738
1735 1739
1736void KABCore::addGUIClient( KXMLGUIClient *client ) 1740void KABCore::addGUIClient( KXMLGUIClient *client )
1737{ 1741{
1738 if ( mGUIClient ) 1742 if ( mGUIClient )
1739 mGUIClient->insertChildClient( client ); 1743 mGUIClient->insertChildClient( client );
1740 else 1744 else
1741 KMessageBox::error( this, "no KXMLGUICLient"); 1745 KMessageBox::error( this, "no KXMLGUICLient");
1742} 1746}
1743 1747
1744 1748
1745void KABCore::configurationChanged() 1749void KABCore::configurationChanged()
1746{ 1750{
1747 mExtensionManager->reconfigure(); 1751 mExtensionManager->reconfigure();
1748} 1752}
1749 1753
1750void KABCore::addressBookChanged() 1754void KABCore::addressBookChanged()
1751{ 1755{
1752/*US 1756/*US
1753 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1754 while ( it.current() ) { 1758 while ( it.current() ) {
1755 if ( it.current()->dirty() ) { 1759 if ( it.current()->dirty() ) {
1756 QString text = i18n( "Data has been changed externally. Unsaved " 1760 QString text = i18n( "Data has been changed externally. Unsaved "
1757 "changes will be lost." ); 1761 "changes will be lost." );
1758 KMessageBox::information( this, text ); 1762 KMessageBox::information( this, text );
1759 } 1763 }
1760 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1761 ++it; 1765 ++it;
1762 } 1766 }
1763*/ 1767*/
1764 if (mEditorDialog) 1768 if (mEditorDialog)
1765 { 1769 {
1766 if (mEditorDialog->dirty()) 1770 if (mEditorDialog->dirty())
1767 { 1771 {
1768 QString text = i18n( "Data has been changed externally. Unsaved " 1772 QString text = i18n( "Data has been changed externally. Unsaved "
1769 "changes will be lost." ); 1773 "changes will be lost." );
1770 KMessageBox::information( this, text ); 1774 KMessageBox::information( this, text );
1771 } 1775 }
1772 QString currentuid = mEditorDialog->addressee().uid(); 1776 QString currentuid = mEditorDialog->addressee().uid();
1773 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1774 } 1778 }
1775 mViewManager->refreshView(); 1779 mViewManager->refreshView();
1776 1780
1777 1781
1778} 1782}
1779 1783
1780AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1781 const char *name ) 1785 const char *name )
1782{ 1786{
1783 1787
1784 if ( mEditorDialog == 0 ) { 1788 if ( mEditorDialog == 0 ) {
1785 mEditorDialog = new AddresseeEditorDialog( this, parent, 1789 mEditorDialog = new AddresseeEditorDialog( this, parent,
1786 name ? name : "editorDialog" ); 1790 name ? name : "editorDialog" );
1787 1791
1788 1792
1789 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1790 SLOT( contactModified( const KABC::Addressee& ) ) ); 1794 SLOT( contactModified( const KABC::Addressee& ) ) );
1791 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1792 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1796 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1793 } 1797 }
1794 1798
1795 return mEditorDialog; 1799 return mEditorDialog;
1796} 1800}
1797 1801
1798void KABCore::slotEditorDestroyed( const QString &uid ) 1802void KABCore::slotEditorDestroyed( const QString &uid )
1799{ 1803{
1800 //mEditorDict.remove( uid ); 1804 //mEditorDict.remove( uid );
1801} 1805}
1802 1806
1803void KABCore::initGUI() 1807void KABCore::initGUI()
1804{ 1808{
1805#ifndef KAB_EMBEDDED 1809#ifndef KAB_EMBEDDED
1806 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1810 QHBoxLayout *topLayout = new QHBoxLayout( this );
1807 topLayout->setSpacing( KDialogBase::spacingHint() ); 1811 topLayout->setSpacing( KDialogBase::spacingHint() );
1808 1812
1809 mExtensionBarSplitter = new QSplitter( this ); 1813 mExtensionBarSplitter = new QSplitter( this );
1810 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1814 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1811 1815
1812 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1813 1817
1814 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1818 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1815 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1819 mIncSearchWidget = new IncSearchWidget( viewSpace );
1816 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1817 SLOT( incrementalSearch( const QString& ) ) ); 1821 SLOT( incrementalSearch( const QString& ) ) );
1818 1822
1819 mViewManager = new ViewManager( this, viewSpace ); 1823 mViewManager = new ViewManager( this, viewSpace );
1820 viewSpace->setStretchFactor( mViewManager, 1 ); 1824 viewSpace->setStretchFactor( mViewManager, 1 );
1821 1825
1822 mDetails = new ViewContainer( mDetailsSplitter ); 1826 mDetails = new ViewContainer( mDetailsSplitter );
1823 1827
1824 mJumpButtonBar = new JumpButtonBar( this, this ); 1828 mJumpButtonBar = new JumpButtonBar( this, this );
1825 1829
1826 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1827 1831
1828 topLayout->addWidget( mExtensionBarSplitter ); 1832 topLayout->addWidget( mExtensionBarSplitter );
1829 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1830 topLayout->addWidget( mJumpButtonBar ); 1834 topLayout->addWidget( mJumpButtonBar );
1831 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1832 1836
1833 mXXPortManager = new XXPortManager( this, this ); 1837 mXXPortManager = new XXPortManager( this, this );
1834 1838
1835#else //KAB_EMBEDDED 1839#else //KAB_EMBEDDED
1836 //US initialize viewMenu before settingup viewmanager. 1840 //US initialize viewMenu before settingup viewmanager.
1837 // Viewmanager needs this menu to plugin submenues. 1841 // Viewmanager needs this menu to plugin submenues.
1838 viewMenu = new QPopupMenu( this ); 1842 viewMenu = new QPopupMenu( this );
1839 settingsMenu = new QPopupMenu( this ); 1843 settingsMenu = new QPopupMenu( this );
1840 //filterMenu = new QPopupMenu( this ); 1844 //filterMenu = new QPopupMenu( this );
1841 ImportMenu = new QPopupMenu( this ); 1845 ImportMenu = new QPopupMenu( this );
1842 ExportMenu = new QPopupMenu( this ); 1846 ExportMenu = new QPopupMenu( this );
1843 syncMenu = new QPopupMenu( this ); 1847 syncMenu = new QPopupMenu( this );
1844 changeMenu= new QPopupMenu( this ); 1848 changeMenu= new QPopupMenu( this );
1845 beamMenu= new QPopupMenu( this ); 1849 beamMenu= new QPopupMenu( this );
1846 1850
1847//US since we have no splitter for the embedded system, setup 1851//US since we have no splitter for the embedded system, setup
1848// a layout with two frames. One left and one right. 1852// a layout with two frames. One left and one right.
1849 1853
1850 QBoxLayout *topLayout; 1854 QBoxLayout *topLayout;
1851 1855
1852 // = new QHBoxLayout( this ); 1856 // = new QHBoxLayout( this );
1853// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1857// QBoxLayout *topLayout = (QBoxLayout*)layout();
1854 1858
1855// QWidget *mainBox = new QWidget( this ); 1859// QWidget *mainBox = new QWidget( this );
1856// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1857 1861
1858#ifdef DESKTOP_VERSION 1862#ifdef DESKTOP_VERSION
1859 topLayout = new QHBoxLayout( this ); 1863 topLayout = new QHBoxLayout( this );
1860 1864
1861 1865
1862 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1863 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1864 1868
1865 topLayout->addWidget(mMiniSplitter ); 1869 topLayout->addWidget(mMiniSplitter );
1866 1870
1867 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1868 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1869 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1873 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1870 mDetails = new ViewContainer( mMiniSplitter ); 1874 mDetails = new ViewContainer( mMiniSplitter );
1871 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1872#else 1876#else
1873 if ( QApplication::desktop()->width() > 480 ) { 1877 if ( QApplication::desktop()->width() > 480 ) {
1874 topLayout = new QHBoxLayout( this ); 1878 topLayout = new QHBoxLayout( this );
1875 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1876 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1877 } else { 1881 } else {
1878 1882
1879 topLayout = new QHBoxLayout( this ); 1883 topLayout = new QHBoxLayout( this );
1880 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1881 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1882 } 1886 }
1883 1887
1884 topLayout->addWidget(mMiniSplitter ); 1888 topLayout->addWidget(mMiniSplitter );
1885 mViewManager = new ViewManager( this, mMiniSplitter ); 1889 mViewManager = new ViewManager( this, mMiniSplitter );
1886 mDetails = new ViewContainer( mMiniSplitter ); 1890 mDetails = new ViewContainer( mMiniSplitter );
1887 1891
1888 1892
1889 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1890#endif 1894#endif
1891 //eh->hide(); 1895 //eh->hide();
1892 // topLayout->addWidget(mExtensionManager ); 1896 // topLayout->addWidget(mExtensionManager );
1893 1897
1894 1898
1895/*US 1899/*US
1896#ifndef KAB_NOSPLITTER 1900#ifndef KAB_NOSPLITTER
1897 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1901 QHBoxLayout *topLayout = new QHBoxLayout( this );
1898//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1902//US topLayout->setSpacing( KDialogBase::spacingHint() );
1899 topLayout->setSpacing( 10 ); 1903 topLayout->setSpacing( 10 );
1900 1904
1901 mDetailsSplitter = new QSplitter( this ); 1905 mDetailsSplitter = new QSplitter( this );
1902 1906
1903 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1907 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1904 1908
1905 mViewManager = new ViewManager( this, viewSpace ); 1909 mViewManager = new ViewManager( this, viewSpace );
1906 viewSpace->setStretchFactor( mViewManager, 1 ); 1910 viewSpace->setStretchFactor( mViewManager, 1 );
1907 1911
1908 mDetails = new ViewContainer( mDetailsSplitter ); 1912 mDetails = new ViewContainer( mDetailsSplitter );
1909 1913
1910 topLayout->addWidget( mDetailsSplitter ); 1914 topLayout->addWidget( mDetailsSplitter );
1911 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1915 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1912#else //KAB_NOSPLITTER 1916#else //KAB_NOSPLITTER
1913 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1917 QHBoxLayout *topLayout = new QHBoxLayout( this );
1914//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1918//US topLayout->setSpacing( KDialogBase::spacingHint() );
1915 topLayout->setSpacing( 10 ); 1919 topLayout->setSpacing( 10 );
1916 1920
1917// mDetailsSplitter = new QSplitter( this ); 1921// mDetailsSplitter = new QSplitter( this );
1918 1922
1919 QVBox *viewSpace = new QVBox( this ); 1923 QVBox *viewSpace = new QVBox( this );
1920 1924
1921 mViewManager = new ViewManager( this, viewSpace ); 1925 mViewManager = new ViewManager( this, viewSpace );
1922 viewSpace->setStretchFactor( mViewManager, 1 ); 1926 viewSpace->setStretchFactor( mViewManager, 1 );
1923 1927
1924 mDetails = new ViewContainer( this ); 1928 mDetails = new ViewContainer( this );
1925 1929
1926 topLayout->addWidget( viewSpace ); 1930 topLayout->addWidget( viewSpace );
1927// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1931// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1928 topLayout->addWidget( mDetails ); 1932 topLayout->addWidget( mDetails );
1929#endif //KAB_NOSPLITTER 1933#endif //KAB_NOSPLITTER
1930*/ 1934*/
1931 1935
1932 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1933 syncManager->setBlockSave(false); 1937 syncManager->setBlockSave(false);
1934 1938
1935 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1939 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1936 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1937 QString sync_file = sentSyncFile(); 1941 QString sync_file = sentSyncFile();
1938 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1939 syncManager->setDefaultFileName( sync_file ); 1943 syncManager->setDefaultFileName( sync_file );
1940 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1941 1945
1942#endif //KAB_EMBEDDED 1946#endif //KAB_EMBEDDED
1943 initActions(); 1947 initActions();
1944 1948
1945#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1946 addActionsManually(); 1950 addActionsManually();
1947 //US make sure the export and import menues are initialized before creating the xxPortManager. 1951 //US make sure the export and import menues are initialized before creating the xxPortManager.
1948 mXXPortManager = new XXPortManager( this, this ); 1952 mXXPortManager = new XXPortManager( this, this );
1949 1953
1950 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1951 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1952 // mActionQuit->plug ( mMainWindow->toolBar()); 1956 // mActionQuit->plug ( mMainWindow->toolBar());
1953 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1954 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1955 // mIncSearchWidget->hide(); 1959 // mIncSearchWidget->hide();
1956 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1957 SLOT( incrementalSearch( const QString& ) ) ); 1961 SLOT( incrementalSearch( const QString& ) ) );
1958 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1959 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1960 1964
1961 mJumpButtonBar = new JumpButtonBar( this, this ); 1965 mJumpButtonBar = new JumpButtonBar( this, this );
1962 1966
1963 topLayout->addWidget( mJumpButtonBar ); 1967 topLayout->addWidget( mJumpButtonBar );
1964//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1965 1969
1966// mMainWindow->getIconToolBar()->raise(); 1970// mMainWindow->getIconToolBar()->raise();
1967 1971
1968#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1969 1973
1970} 1974}
1971void KABCore::initActions() 1975void KABCore::initActions()
1972{ 1976{
1973//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1974 1978
1975#ifndef KAB_EMBEDDED 1979#ifndef KAB_EMBEDDED
1976 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1977 SLOT( clipboardDataChanged() ) ); 1981 SLOT( clipboardDataChanged() ) );
1978#endif //KAB_EMBEDDED 1982#endif //KAB_EMBEDDED
1979 1983
1980 // file menu 1984 // file menu
1981 1985
1982 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1983 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1984 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1985 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1986 1990
1987 1991
1988 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1989 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1990 1994
1991 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1992 SLOT( save() ), actionCollection(), "file_sync" ); 1996 SLOT( save() ), actionCollection(), "file_sync" );
1993 1997
1994 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1995 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1999 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1996 2000
1997 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1998 this, SLOT( mailVCard() ), 2002 this, SLOT( mailVCard() ),
1999 actionCollection(), "file_mail_vcard"); 2003 actionCollection(), "file_mail_vcard");
2000 2004
2001 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2002 SLOT( export2phone() ), actionCollection(), 2006 SLOT( export2phone() ), actionCollection(),
2003 "kaddressbook_ex2phone" ); 2007 "kaddressbook_ex2phone" );
2004 2008
2005 mActionBeamVCard = 0; 2009 mActionBeamVCard = 0;
2006 mActionBeam = 0; 2010 mActionBeam = 0;
2007 2011
2008#ifndef DESKTOP_VERSION 2012#ifndef DESKTOP_VERSION
2009 if ( Ir::supported() ) { 2013 if ( Ir::supported() ) {
2010 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2011 SLOT( beamVCard() ), actionCollection(), 2015 SLOT( beamVCard() ), actionCollection(),
2012 "kaddressbook_beam_vcard" ); 2016 "kaddressbook_beam_vcard" );
2013 2017
2014 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2015 SLOT( beamMySelf() ), actionCollection(), 2019 SLOT( beamMySelf() ), actionCollection(),
2016 "kaddressbook_beam_myself" ); 2020 "kaddressbook_beam_myself" );
2017 } 2021 }
2018#endif 2022#endif
2019 2023
2020 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2021 this, SLOT( editContact2() ), 2025 this, SLOT( editContact2() ),
2022 actionCollection(), "file_properties" ); 2026 actionCollection(), "file_properties" );
2023 2027
2024#ifdef KAB_EMBEDDED 2028#ifdef KAB_EMBEDDED
2025 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2026 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2027 mMainWindow, SLOT( exit() ), 2031 mMainWindow, SLOT( exit() ),
2028 actionCollection(), "quit" ); 2032 actionCollection(), "quit" );
2029#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2030 2034
2031 // edit menu 2035 // edit menu
2032 if ( mIsPart ) { 2036 if ( mIsPart ) {
2033 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2034 SLOT( copyContacts() ), actionCollection(), 2038 SLOT( copyContacts() ), actionCollection(),
2035 "kaddressbook_copy" ); 2039 "kaddressbook_copy" );
2036 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2037 SLOT( cutContacts() ), actionCollection(), 2041 SLOT( cutContacts() ), actionCollection(),
2038 "kaddressbook_cut" ); 2042 "kaddressbook_cut" );
2039 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2040 SLOT( pasteContacts() ), actionCollection(), 2044 SLOT( pasteContacts() ), actionCollection(),
2041 "kaddressbook_paste" ); 2045 "kaddressbook_paste" );
2042 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2043 SLOT( selectAllContacts() ), actionCollection(), 2047 SLOT( selectAllContacts() ), actionCollection(),
2044 "kaddressbook_select_all" ); 2048 "kaddressbook_select_all" );
2045 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2046 SLOT( undo() ), actionCollection(), 2050 SLOT( undo() ), actionCollection(),
2047 "kaddressbook_undo" ); 2051 "kaddressbook_undo" );
2048 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2049 this, SLOT( redo() ), actionCollection(), 2053 this, SLOT( redo() ), actionCollection(),
2050 "kaddressbook_redo" ); 2054 "kaddressbook_redo" );
2051 } else { 2055 } else {
2052 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2053 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2054 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2055 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2056 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2057 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2058 } 2062 }
2059 2063
2060 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2061 Key_Delete, this, SLOT( deleteContacts() ), 2065 Key_Delete, this, SLOT( deleteContacts() ),
2062 actionCollection(), "edit_delete" ); 2066 actionCollection(), "edit_delete" );
2063 2067
2064 mActionUndo->setEnabled( false ); 2068 mActionUndo->setEnabled( false );
2065 mActionRedo->setEnabled( false ); 2069 mActionRedo->setEnabled( false );
2066 2070
2067 // settings menu 2071 // settings menu
2068#ifdef KAB_EMBEDDED 2072#ifdef KAB_EMBEDDED
2069//US special menuentry to configure the addressbook resources. On KDE 2073//US special menuentry to configure the addressbook resources. On KDE
2070// you do that through the control center !!! 2074// you do that through the control center !!!
2071 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2072 SLOT( configureResources() ), actionCollection(), 2076 SLOT( configureResources() ), actionCollection(),
2073 "kaddressbook_configure_resources" ); 2077 "kaddressbook_configure_resources" );
2074#endif //KAB_EMBEDDED 2078#endif //KAB_EMBEDDED
2075 2079
2076 if ( mIsPart ) { 2080 if ( mIsPart ) {
2077 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2078 SLOT( openConfigDialog() ), actionCollection(), 2082 SLOT( openConfigDialog() ), actionCollection(),
2079 "kaddressbook_configure" ); 2083 "kaddressbook_configure" );
2080 2084
2081 //US not implemented yet 2085 //US not implemented yet
2082 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2083 // this, SLOT( configureKeyBindings() ), actionCollection(), 2087 // this, SLOT( configureKeyBindings() ), actionCollection(),
2084 // "kaddressbook_configure_shortcuts" ); 2088 // "kaddressbook_configure_shortcuts" );
2085#ifdef KAB_EMBEDDED 2089#ifdef KAB_EMBEDDED
2086 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2087 mActionConfigureToolbars->setEnabled( false ); 2091 mActionConfigureToolbars->setEnabled( false );
2088#endif //KAB_EMBEDDED 2092#endif //KAB_EMBEDDED
2089 2093
2090 } else { 2094 } else {
2091 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2092 SLOT( openConfigDialog() ), actionCollection(), 2096 SLOT( openConfigDialog() ), actionCollection(),
2093 "kaddressbook_configure" ); 2097 "kaddressbook_configure" );
2094 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2095 SLOT( openConfigGlobalDialog() ), actionCollection(), 2099 SLOT( openConfigGlobalDialog() ), actionCollection(),
2096 "kaddressbook_configure" ); 2100 "kaddressbook_configure" );
2097 } 2101 }
2098 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2099 actionCollection(), "options_show_jump_bar" ); 2103 actionCollection(), "options_show_jump_bar" );
2100 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2101 2105
2102 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2103 actionCollection(), "options_show_details" ); 2107 actionCollection(), "options_show_details" );
2104 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2105 2109
2106 2110
2107 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2108 SLOT( toggleBeamReceive() ), actionCollection(), 2112 SLOT( toggleBeamReceive() ), actionCollection(),
2109 "kaddressbook_beam_rec" ); 2113 "kaddressbook_beam_rec" );
2110 2114
2111 2115
2112 // misc 2116 // misc
2113 // only enable LDAP lookup if we can handle the protocol 2117 // only enable LDAP lookup if we can handle the protocol
2114#ifndef KAB_EMBEDDED 2118#ifndef KAB_EMBEDDED
2115 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2116 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2117 this, SLOT( openLDAPDialog() ), actionCollection(), 2121 this, SLOT( openLDAPDialog() ), actionCollection(),
2118 "ldap_lookup" ); 2122 "ldap_lookup" );
2119 } 2123 }
2120#else //KAB_EMBEDDED 2124#else //KAB_EMBEDDED
2121 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2125 //qDebug("KABCore::initActions() LDAP has to be implemented");
2122#endif //KAB_EMBEDDED 2126#endif //KAB_EMBEDDED
2123 2127
2124 2128
2125 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2126 SLOT( setWhoAmI() ), actionCollection(), 2130 SLOT( setWhoAmI() ), actionCollection(),
2127 "set_personal" ); 2131 "set_personal" );
2128 2132
2129 2133
2130 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2131 SLOT( setCategories() ), actionCollection(), 2135 SLOT( setCategories() ), actionCollection(),
2132 "edit_set_categories" ); 2136 "edit_set_categories" );
2133 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2134 SLOT( editCategories() ), actionCollection(), 2138 SLOT( editCategories() ), actionCollection(),
2135 "edit__categories" ); 2139 "edit__categories" );
2136 2140
2137 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2138 SLOT( removeVoice() ), actionCollection(), 2142 SLOT( removeVoice() ), actionCollection(),
2139 "remove_voice" ); 2143 "remove_voice" );
2140 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2141 SLOT( setFormattedName() ), actionCollection(), 2145 SLOT( setFormattedName() ), actionCollection(),
2142 "set_formatted" ); 2146 "set_formatted" );
2143 2147
2144 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2145 SLOT( manageCategories() ), actionCollection(), 2149 SLOT( manageCategories() ), actionCollection(),
2146 "remove_voice" ); 2150 "remove_voice" );
2147 2151
2148 2152
2149 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2150 SLOT( importFromOL() ), actionCollection(), 2154 SLOT( importFromOL() ), actionCollection(),
2151 "import_OL" ); 2155 "import_OL" );
2152#ifdef KAB_EMBEDDED 2156#ifdef KAB_EMBEDDED
2153 mActionLicence = new KAction( i18n( "Licence" ), 0, 2157 mActionLicence = new KAction( i18n( "Licence" ), 0,
2154 this, SLOT( showLicence() ), actionCollection(), 2158 this, SLOT( showLicence() ), actionCollection(),
2155 "licence_about_data" ); 2159 "licence_about_data" );
2156 mActionFaq = new KAction( i18n( "Faq" ), 0, 2160 mActionFaq = new KAction( i18n( "Faq" ), 0,
2157 this, SLOT( faq() ), actionCollection(), 2161 this, SLOT( faq() ), actionCollection(),
2158 "faq_about_data" ); 2162 "faq_about_data" );
2159 mActionWN = new KAction( i18n( "What's New?" ), 0, 2163 mActionWN = new KAction( i18n( "What's New?" ), 0,
2160 this, SLOT( whatsnew() ), actionCollection(), 2164 this, SLOT( whatsnew() ), actionCollection(),
2161 "wn" ); 2165 "wn" );
2162 2166
2163 2167
2164 2168
2165 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2166 this, SLOT( storagehowto() ), actionCollection(), 2170 this, SLOT( storagehowto() ), actionCollection(),
2167 "storage" ); 2171 "storage" );
2168 2172
2169 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2170 this, SLOT( synchowto() ), actionCollection(), 2174 this, SLOT( synchowto() ), actionCollection(),
2171 "sync" ); 2175 "sync" );
2172 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2173 this, SLOT( kdesynchowto() ), actionCollection(), 2177 this, SLOT( kdesynchowto() ), actionCollection(),
2174 "kdesync" ); 2178 "kdesync" );
2175 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2176 this, SLOT( multisynchowto() ), actionCollection(), 2180 this, SLOT( multisynchowto() ), actionCollection(),
2177 "multisync" ); 2181 "multisync" );
2178 2182
2179 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2180 this, SLOT( createAboutData() ), actionCollection(), 2184 this, SLOT( createAboutData() ), actionCollection(),
2181 "kaddressbook_about_data" ); 2185 "kaddressbook_about_data" );
2182#endif //KAB_EMBEDDED 2186#endif //KAB_EMBEDDED
2183 2187
2184 clipboardDataChanged(); 2188 clipboardDataChanged();
2185 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2186 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2187} 2191}
2188 2192
2189//US we need this function, to plug all actions into the correct menues. 2193//US we need this function, to plug all actions into the correct menues.
2190// KDE uses a XML format to plug the actions, but we work her without this overhead. 2194// KDE uses a XML format to plug the actions, but we work her without this overhead.
2191void KABCore::addActionsManually() 2195void KABCore::addActionsManually()
2192{ 2196{
2193//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2194 2198
2195#ifdef KAB_EMBEDDED 2199#ifdef KAB_EMBEDDED
2196 QPopupMenu *fileMenu = new QPopupMenu( this ); 2200 QPopupMenu *fileMenu = new QPopupMenu( this );
2197 QPopupMenu *editMenu = new QPopupMenu( this ); 2201 QPopupMenu *editMenu = new QPopupMenu( this );
2198 QPopupMenu *helpMenu = new QPopupMenu( this ); 2202 QPopupMenu *helpMenu = new QPopupMenu( this );
2199 2203
2200 KToolBar* tb = mMainWindow->toolBar(); 2204 KToolBar* tb = mMainWindow->toolBar();
2201 mMainWindow->setToolBarsMovable (false ); 2205 mMainWindow->setToolBarsMovable (false );
2202#ifndef DESKTOP_VERSION 2206#ifndef DESKTOP_VERSION
2203 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2204#endif 2208#endif
2205 QMenuBar* mb = mMainWindow->menuBar(); 2209 QMenuBar* mb = mMainWindow->menuBar();
2206 2210
2207 //US setup menubar. 2211 //US setup menubar.
2208 //Disable the following block if you do not want to have a menubar. 2212 //Disable the following block if you do not want to have a menubar.
2209 mb->insertItem( i18n("&File"), fileMenu ); 2213 mb->insertItem( i18n("&File"), fileMenu );
2210 mb->insertItem( i18n("&Edit"), editMenu ); 2214 mb->insertItem( i18n("&Edit"), editMenu );
2211 mb->insertItem( i18n("&View"), viewMenu ); 2215 mb->insertItem( i18n("&View"), viewMenu );
2212 mb->insertItem( i18n("&Settings"), settingsMenu ); 2216 mb->insertItem( i18n("&Settings"), settingsMenu );
2213#ifdef DESKTOP_VERSION 2217#ifdef DESKTOP_VERSION
2214 mb->insertItem( i18n("Synchronize"), syncMenu ); 2218 mb->insertItem( i18n("Synchronize"), syncMenu );
2215#else 2219#else
2216 mb->insertItem( i18n("Sync"), syncMenu ); 2220 mb->insertItem( i18n("Sync"), syncMenu );
2217#endif 2221#endif
2218 //mb->insertItem( i18n("&Change"), changeMenu ); 2222 //mb->insertItem( i18n("&Change"), changeMenu );
2219 mb->insertItem( i18n("&Help"), helpMenu ); 2223 mb->insertItem( i18n("&Help"), helpMenu );
2220 mIncSearchWidget = new IncSearchWidget( tb ); 2224 mIncSearchWidget = new IncSearchWidget( tb );
2221 // tb->insertWidget(-1, 0, mIncSearchWidget); 2225 // tb->insertWidget(-1, 0, mIncSearchWidget);
2222#ifndef DESKTOP_VERSION 2226#ifndef DESKTOP_VERSION
2223 } else { 2227 } else {
2224 //US setup toolbar 2228 //US setup toolbar
2225 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2226 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2230 QPopupMenu *popupBarTB = new QPopupMenu( this );
2227 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2228 tb->insertWidget(-1, 0, menuBarTB); 2232 tb->insertWidget(-1, 0, menuBarTB);
2229 mIncSearchWidget = new IncSearchWidget( tb ); 2233 mIncSearchWidget = new IncSearchWidget( tb );
2230 tb->enableMoving(false); 2234 tb->enableMoving(false);
2231 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2235 popupBarTB->insertItem( i18n("&File"), fileMenu );
2232 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2236 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2233 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2237 popupBarTB->insertItem( i18n("&View"), viewMenu );
2234 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2235 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2236 mViewManager->getFilterAction()->plug ( popupBarTB); 2240 mViewManager->getFilterAction()->plug ( popupBarTB);
2237 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2238 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2242 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2239 if (QApplication::desktop()->width() > 320 ) { 2243 if (QApplication::desktop()->width() > 320 ) {
2240 // mViewManager->getFilterAction()->plug ( tb); 2244 // mViewManager->getFilterAction()->plug ( tb);
2241 } 2245 }
2242 } 2246 }
2243#endif 2247#endif
2244 mIncSearchWidget->setSize(); 2248 mIncSearchWidget->setSize();
2245 // mActionQuit->plug ( mMainWindow->toolBar()); 2249 // mActionQuit->plug ( mMainWindow->toolBar());
2246 2250
2247 2251
2248 2252
2249 //US Now connect the actions with the menue entries. 2253 //US Now connect the actions with the menue entries.
2250#ifdef DESKTOP_VERSION 2254#ifdef DESKTOP_VERSION
2251 mActionPrint->plug( fileMenu ); 2255 mActionPrint->plug( fileMenu );
2252 mActionPrintDetails->plug( fileMenu ); 2256 mActionPrintDetails->plug( fileMenu );
2253 fileMenu->insertSeparator(); 2257 fileMenu->insertSeparator();
2254#endif 2258#endif
2255 mActionMail->plug( fileMenu ); 2259 mActionMail->plug( fileMenu );
2256 fileMenu->insertSeparator(); 2260 fileMenu->insertSeparator();
2257 2261
2258 mActionNewContact->plug( editMenu ); 2262 mActionNewContact->plug( editMenu );
2259 mActionNewContact->plug( tb ); 2263 mActionNewContact->plug( tb );
2260 2264
2261 mActionEditAddressee->plug( editMenu ); 2265 mActionEditAddressee->plug( editMenu );
2262 editMenu->insertSeparator(); 2266 editMenu->insertSeparator();
2263 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2264 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2265 mActionEditAddressee->plug( tb ); 2269 mActionEditAddressee->plug( tb );
2266 2270
2267 // fileMenu->insertSeparator(); 2271 // fileMenu->insertSeparator();
2268 mActionSave->plug( fileMenu ); 2272 mActionSave->plug( fileMenu );
2269 fileMenu->insertItem( "&Import", ImportMenu ); 2273 fileMenu->insertItem( "&Import", ImportMenu );
2270 fileMenu->insertItem( "&Export", ExportMenu ); 2274 fileMenu->insertItem( "&Export", ExportMenu );
2271 editMenu->insertItem( i18n("&Change"), changeMenu ); 2275 editMenu->insertItem( i18n("&Change"), changeMenu );
2272 editMenu->insertSeparator(); 2276 editMenu->insertSeparator();
2273#ifndef DESKTOP_VERSION 2277#ifndef DESKTOP_VERSION
2274 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2275#endif 2279#endif
2276#if 0 2280#if 0
2277 // PENDING fix MailVCard 2281 // PENDING fix MailVCard
2278 fileMenu->insertSeparator(); 2282 fileMenu->insertSeparator();
2279 mActionMailVCard->plug( fileMenu ); 2283 mActionMailVCard->plug( fileMenu );
2280#endif 2284#endif
2281#ifndef DESKTOP_VERSION 2285#ifndef DESKTOP_VERSION
2282 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2286 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2283 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2284 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2285#endif 2289#endif
2286 fileMenu->insertSeparator(); 2290 fileMenu->insertSeparator();
2287 mActionQuit->plug( fileMenu ); 2291 mActionQuit->plug( fileMenu );
2288#ifdef _OL_IMPORT_ 2292#ifdef _OL_IMPORT_
2289 mActionImportOL->plug( ImportMenu ); 2293 mActionImportOL->plug( ImportMenu );
2290#endif 2294#endif
2291 // edit menu 2295 // edit menu
2292 mActionUndo->plug( editMenu ); 2296 mActionUndo->plug( editMenu );
2293 mActionRedo->plug( editMenu ); 2297 mActionRedo->plug( editMenu );
2294 editMenu->insertSeparator(); 2298 editMenu->insertSeparator();
2295 mActionCut->plug( editMenu ); 2299 mActionCut->plug( editMenu );
2296 mActionCopy->plug( editMenu ); 2300 mActionCopy->plug( editMenu );
2297 mActionPaste->plug( editMenu ); 2301 mActionPaste->plug( editMenu );
2298 mActionDelete->plug( editMenu ); 2302 mActionDelete->plug( editMenu );
2299 editMenu->insertSeparator(); 2303 editMenu->insertSeparator();
2300 mActionSelectAll->plug( editMenu ); 2304 mActionSelectAll->plug( editMenu );
2301 2305
2302 mActionSetFormattedName->plug( changeMenu ); 2306 mActionSetFormattedName->plug( changeMenu );
2303 mActionRemoveVoice->plug( changeMenu ); 2307 mActionRemoveVoice->plug( changeMenu );
2304 // settingsmings menu 2308 // settingsmings menu
2305//US special menuentry to configure the addressbook resources. On KDE 2309//US special menuentry to configure the addressbook resources. On KDE
2306// you do that through the control center !!! 2310// you do that through the control center !!!
2307 // settingsMenu->insertSeparator(); 2311 // settingsMenu->insertSeparator();
2308 2312
2309 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2313 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2310 mActionConfigGlobal->plug( settingsMenu, 1 ); 2314 mActionConfigGlobal->plug( settingsMenu, 1 );
2311 mActionConfigResources->plug( settingsMenu,2 ); 2315 mActionConfigResources->plug( settingsMenu,2 );
2312 settingsMenu->insertSeparator(3); 2316 settingsMenu->insertSeparator(3);
2313 2317
2314 if ( mIsPart ) { 2318 if ( mIsPart ) {
2315 //US not implemented yet 2319 //US not implemented yet
2316 //mActionConfigShortcuts->plug( settingsMenu ); 2320 //mActionConfigShortcuts->plug( settingsMenu );
2317 //mActionConfigureToolbars->plug( settingsMenu ); 2321 //mActionConfigureToolbars->plug( settingsMenu );
2318 2322
2319 } else { 2323 } else {
2320 //US not implemented yet 2324 //US not implemented yet
2321 //mActionKeyBindings->plug( settingsMenu ); 2325 //mActionKeyBindings->plug( settingsMenu );
2322 } 2326 }
2323 2327
2324 mActionEditCategories->plug( settingsMenu ); 2328 mActionEditCategories->plug( settingsMenu );
2325 mActionManageCategories->plug( settingsMenu ); 2329 mActionManageCategories->plug( settingsMenu );
2326 mActionJumpBar->plug( viewMenu,0 ); 2330 mActionJumpBar->plug( viewMenu,0 );
2327 mActionDetails->plug( viewMenu,0 ); 2331 mActionDetails->plug( viewMenu,0 );
2328 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2329 mActionDetails->plug( tb ); 2333 mActionDetails->plug( tb );
2330 settingsMenu->insertSeparator(); 2334 settingsMenu->insertSeparator();
2331#ifndef DESKTOP_VERSION 2335#ifndef DESKTOP_VERSION
2332 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2333 settingsMenu->insertSeparator(); 2337 settingsMenu->insertSeparator();
2334#endif 2338#endif
2335 2339
2336 mActionWhoAmI->plug( settingsMenu ); 2340 mActionWhoAmI->plug( settingsMenu );
2337 //mActionEditCategories->plug( changeMenu ); 2341 //mActionEditCategories->plug( changeMenu );
2338 mActionCategories->plug( changeMenu ); 2342 mActionCategories->plug( changeMenu );
2339 //mActionManageCategories->plug( changeMenu ); 2343 //mActionManageCategories->plug( changeMenu );
2340 2344
2341 //mActionCategories->plug( settingsMenu ); 2345 //mActionCategories->plug( settingsMenu );
2342 2346
2343 2347
2344 mActionWN->plug( helpMenu ); 2348 mActionWN->plug( helpMenu );
2345 mActionStorageHowto->plug( helpMenu ); 2349 mActionStorageHowto->plug( helpMenu );
2346 mActionSyncHowto->plug( helpMenu ); 2350 mActionSyncHowto->plug( helpMenu );
2347 mActionKdeSyncHowto->plug( helpMenu ); 2351 mActionKdeSyncHowto->plug( helpMenu );
2348 mActionMultiSyncHowto->plug( helpMenu ); 2352 mActionMultiSyncHowto->plug( helpMenu );
2349 mActionFaq->plug( helpMenu ); 2353 mActionFaq->plug( helpMenu );
2350 mActionLicence->plug( helpMenu ); 2354 mActionLicence->plug( helpMenu );
2351 mActionAboutKAddressbook->plug( helpMenu ); 2355 mActionAboutKAddressbook->plug( helpMenu );
2352 2356
2353 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2354 2358
2355 mActionSave->plug( tb ); 2359 mActionSave->plug( tb );
2356 mViewManager->getFilterAction()->plug ( tb); 2360 mViewManager->getFilterAction()->plug ( tb);
2357 //LR hide filteraction on started in 480x640 2361 //LR hide filteraction on started in 480x640
2358 if (QApplication::desktop()->width() == 480 ) { 2362 if (QApplication::desktop()->width() == 480 ) {
2359 mViewManager->getFilterAction()->setComboWidth( 0 ); 2363 mViewManager->getFilterAction()->setComboWidth( 0 );
2360 } 2364 }
2361 mActionUndo->plug( tb ); 2365 mActionUndo->plug( tb );
2362 mActionDelete->plug( tb ); 2366 mActionDelete->plug( tb );
2363 mActionRedo->plug( tb ); 2367 mActionRedo->plug( tb );
2364 } else { 2368 } else {
2365 mActionSave->plug( tb ); 2369 mActionSave->plug( tb );
2366 tb->enableMoving(false); 2370 tb->enableMoving(false);
2367 } 2371 }
2368 //mActionQuit->plug ( tb ); 2372 //mActionQuit->plug ( tb );
2369 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2370 2374
2371 //US link the searchwidget first to this. 2375 //US link the searchwidget first to this.
2372 // The real linkage to the toolbar happens later. 2376 // The real linkage to the toolbar happens later.
2373//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2374//US tb->insertItem( mIncSearchWidget ); 2378//US tb->insertItem( mIncSearchWidget );
2375/*US 2379/*US
2376 mIncSearchWidget = new IncSearchWidget( tb ); 2380 mIncSearchWidget = new IncSearchWidget( tb );
2377 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2378 SLOT( incrementalSearch( const QString& ) ) ); 2382 SLOT( incrementalSearch( const QString& ) ) );
2379 2383
2380 mJumpButtonBar = new JumpButtonBar( this, this ); 2384 mJumpButtonBar = new JumpButtonBar( this, this );
2381 2385
2382//US topLayout->addWidget( mJumpButtonBar ); 2386//US topLayout->addWidget( mJumpButtonBar );
2383 this->layout()->add( mJumpButtonBar ); 2387 this->layout()->add( mJumpButtonBar );
2384*/ 2388*/
2385 2389
2386#endif //KAB_EMBEDDED 2390#endif //KAB_EMBEDDED
2387 2391
2388 mActionExport2phone->plug( ExportMenu ); 2392 mActionExport2phone->plug( ExportMenu );
2389 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2390 syncManager->fillSyncMenu(); 2394 syncManager->fillSyncMenu();
2391 2395
2392} 2396}
2393void KABCore::showLicence() 2397void KABCore::showLicence()
2394{ 2398{
2395 KApplication::showLicence(); 2399 KApplication::showLicence();
2396} 2400}
2397 2401
2398void KABCore::manageCategories( ) 2402void KABCore::manageCategories( )
2399{ 2403{
2400 KABCatPrefs* cp = new KABCatPrefs(); 2404 KABCatPrefs* cp = new KABCatPrefs();
2401 cp->show(); 2405 cp->show();
2402 int w =cp->sizeHint().width() ; 2406 int w =cp->sizeHint().width() ;
2403 int h = cp->sizeHint().height() ; 2407 int h = cp->sizeHint().height() ;
2404 int dw = QApplication::desktop()->width(); 2408 int dw = QApplication::desktop()->width();
2405 int dh = QApplication::desktop()->height(); 2409 int dh = QApplication::desktop()->height();
2406 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2407 if ( !cp->exec() ) { 2411 if ( !cp->exec() ) {
2408 delete cp; 2412 delete cp;
2409 return; 2413 return;
2410 } 2414 }
2411 int count = 0; 2415 int count = 0;
2412 int cc = 0; 2416 int cc = 0;
2413 message( i18n("Please wait, processing categories...")); 2417 message( i18n("Please wait, processing categories..."));
2414 if ( cp->addCat() ) { 2418 if ( cp->addCat() ) {
2415 KABC::AddressBook::Iterator it; 2419 KABC::AddressBook::Iterator it;
2416 QStringList catList = KABPrefs::instance()->mCustomCategories; 2420 QStringList catList = KABPrefs::instance()->mCustomCategories;
2417 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2418 ++cc; 2422 ++cc;
2419 if ( cc %10 == 0) 2423 if ( cc %10 == 0)
2420 message(i18n("Processing contact #%1").arg(cc)); 2424 message(i18n("Processing contact #%1").arg(cc));
2421 QStringList catIncList = (*it).categories(); 2425 QStringList catIncList = (*it).categories();
2422 int i; 2426 int i;
2423 for( i = 0; i< catIncList.count(); ++i ) { 2427 for( i = 0; i< catIncList.count(); ++i ) {
2424 if ( !catList.contains (catIncList[i])) { 2428 if ( !catList.contains (catIncList[i])) {
2425 catList.append( catIncList[i] ); 2429 catList.append( catIncList[i] );
2426 //qDebug("add cat %s ", catIncList[i].latin1()); 2430 //qDebug("add cat %s ", catIncList[i].latin1());
2427 ++count; 2431 ++count;
2428 } 2432 }
2429 } 2433 }
2430 } 2434 }
2431 catList.sort(); 2435 catList.sort();
2432 KABPrefs::instance()->mCustomCategories = catList; 2436 KABPrefs::instance()->mCustomCategories = catList;
2433 KABPrefs::instance()->writeConfig(); 2437 KABPrefs::instance()->writeConfig();
2434 message(QString::number( count )+ i18n(" categories added to list! ")); 2438 message(QString::number( count )+ i18n(" categories added to list! "));
2435 } else { 2439 } else {
2436 QStringList catList = KABPrefs::instance()->mCustomCategories; 2440 QStringList catList = KABPrefs::instance()->mCustomCategories;
2437 QStringList catIncList; 2441 QStringList catIncList;
2438 QStringList newCatList; 2442 QStringList newCatList;
2439 KABC::AddressBook::Iterator it; 2443 KABC::AddressBook::Iterator it;
2440 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2441 ++cc; 2445 ++cc;
2442 if ( cc %10 == 0) 2446 if ( cc %10 == 0)
2443 message(i18n("Processing contact #%1").arg(cc)); 2447 message(i18n("Processing contact #%1").arg(cc));
2444 QStringList catIncList = (*it).categories(); 2448 QStringList catIncList = (*it).categories();
2445 int i; 2449 int i;
2446 if ( catIncList.count() ) { 2450 if ( catIncList.count() ) {
2447 newCatList.clear(); 2451 newCatList.clear();
2448 for( i = 0; i< catIncList.count(); ++i ) { 2452 for( i = 0; i< catIncList.count(); ++i ) {
2449 if ( catList.contains (catIncList[i])) { 2453 if ( catList.contains (catIncList[i])) {
2450 newCatList.append( catIncList[i] ); 2454 newCatList.append( catIncList[i] );
2451 } 2455 }
2452 } 2456 }
2453 newCatList.sort(); 2457 newCatList.sort();
2454 (*it).setCategories( newCatList ); 2458 (*it).setCategories( newCatList );
2455 mAddressBook->insertAddressee( (*it) ); 2459 mAddressBook->insertAddressee( (*it) );
2456 } 2460 }
2457 } 2461 }
2458 setModified( true ); 2462 setModified( true );
2459 mViewManager->refreshView(); 2463 mViewManager->refreshView();
2460 message( i18n("Removing categories done!")); 2464 message( i18n("Removing categories done!"));
2461 } 2465 }
2462 delete cp; 2466 delete cp;
2463} 2467}
2464void KABCore::removeVoice() 2468void KABCore::removeVoice()
2465{ 2469{
2466 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 ) 2470 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 )
2467 return; 2471 return;
2468 XXPortSelectDialog dlg( this, false, this ); 2472 XXPortSelectDialog dlg( this, false, this );
2469 if ( !dlg.exec() ) 2473 if ( !dlg.exec() )
2470 return; 2474 return;
2471 mAddressBook->setUntagged(); 2475 mAddressBook->setUntagged();
2472 dlg.tagSelected(); 2476 dlg.tagSelected();
2473 message(i18n("Removing voice..."), false ); 2477 message(i18n("Removing voice..."), false );
2474 KABC::AddressBook::Iterator it; 2478 KABC::AddressBook::Iterator it;
2475 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2476 if ( (*it).tagged() ) { 2480 if ( (*it).tagged() ) {
2477 (*it).removeVoice(); 2481 (*it).removeVoice();
2478 } 2482 }
2479 } 2483 }
2480 message(i18n("Refreshing view...") ); 2484 message(i18n("Refreshing view...") );
2481 mViewManager->refreshView( "" ); 2485 mViewManager->refreshView( "" );
2482 Addressee add; 2486 Addressee add;
2483 mDetails->setAddressee( add ); 2487 mDetails->setAddressee( add );
2484 message(i18n("Remove voice completed!") ); 2488 message(i18n("Remove voice completed!") );
2485 2489
2486 2490
2487 2491
2488} 2492}
2489 2493
2490void KABCore::setFormattedName() 2494void KABCore::setFormattedName()
2491{ 2495{
2492 KABFormatPrefs setpref; 2496 KABFormatPrefs setpref;
2493 if ( !setpref.exec() ) { 2497 if ( !setpref.exec() ) {
2494 return; 2498 return;
2495 } 2499 }
2496 XXPortSelectDialog dlg( this, false, this ); 2500 XXPortSelectDialog dlg( this, false, this );
2497 if ( !dlg.exec() ) 2501 if ( !dlg.exec() )
2498 return; 2502 return;
2499 mAddressBook->setUntagged(); 2503 mAddressBook->setUntagged();
2500 dlg.tagSelected(); 2504 dlg.tagSelected();
2501 int count = 0; 2505 int count = 0;
2502 KABC::AddressBook::Iterator it; 2506 KABC::AddressBook::Iterator it;
2503 bool modified = false; 2507 bool modified = false;
2504 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2505 if ( (*it).tagged() ) { 2509 if ( (*it).tagged() ) {
2506 if ( (*it).uid().left( 2 ) == "la" ) 2510 if ( (*it).uid().left( 2 ) == "la" )
2507 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2508 continue; 2512 continue;
2509 ++count; 2513 ++count;
2510 if ( count %10 == 0 ) 2514 if ( count %10 == 0 )
2511 message(i18n("Changing contact #%1").arg( count ) ); 2515 message(i18n("Changing contact #%1").arg( count ) );
2512 QString fName; 2516 QString fName;
2513 if ( setpref.simple->isChecked() ) 2517 if ( setpref.simple->isChecked() )
2514 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2515 else if ( setpref.full->isChecked() ) 2519 else if ( setpref.full->isChecked() )
2516 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2517 else if ( setpref.reverse->isChecked() ) 2521 else if ( setpref.reverse->isChecked() )
2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2519 else 2523 else
2520 fName = (*it).organization(); 2524 fName = (*it).organization();
2521 if ( setpref.setCompany->isChecked() ) 2525 if ( setpref.setCompany->isChecked() )
2522 if ( fName.isEmpty() || fName =="," ) 2526 if ( fName.isEmpty() || fName =="," )
2523 fName = (*it).organization(); 2527 fName = (*it).organization();
2524 (*it).setFormattedName( fName ); 2528 (*it).setFormattedName( fName );
2525 (*it).setChanged( true ); 2529 (*it).setChanged( true );
2526 modified = true; 2530 modified = true;
2527 (*it).setRevision( QDateTime::currentDateTime() ); 2531 (*it).setRevision( QDateTime::currentDateTime() );
2528 } 2532 }
2529 } 2533 }
2530 message(i18n("Refreshing view...") ); 2534 message(i18n("Refreshing view...") );
2531 if ( modified ) 2535 if ( modified )
2532 setModified( true ); 2536 setModified( true );
2533 Addressee add; 2537 Addressee add;
2534 mDetails->setAddressee( add ); 2538 mDetails->setAddressee( add );
2535 if ( count == 0 ) 2539 if ( count == 0 )
2536 message(i18n("No contact changed!") ); 2540 message(i18n("No contact changed!") );
2537 else 2541 else
2538 message(i18n("%1 contacts changed!").arg( count ) ); 2542 message(i18n("%1 contacts changed!").arg( count ) );
2539} 2543}
2540 2544
2541void KABCore::clipboardDataChanged() 2545void KABCore::clipboardDataChanged()
2542{ 2546{
2543 2547
2544 if ( mReadWrite ) 2548 if ( mReadWrite )
2545 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2546 2550
2547} 2551}
2548 2552
2549void KABCore::updateActionMenu() 2553void KABCore::updateActionMenu()
2550{ 2554{
2551 UndoStack *undo = UndoStack::instance(); 2555 UndoStack *undo = UndoStack::instance();
2552 RedoStack *redo = RedoStack::instance(); 2556 RedoStack *redo = RedoStack::instance();
2553 2557
2554 if ( undo->isEmpty() ) 2558 if ( undo->isEmpty() )
2555 mActionUndo->setText( i18n( "Undo" ) ); 2559 mActionUndo->setText( i18n( "Undo" ) );
2556 else 2560 else
2557 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2558 2562
2559 mActionUndo->setEnabled( !undo->isEmpty() ); 2563 mActionUndo->setEnabled( !undo->isEmpty() );
2560 2564
2561 if ( !redo->top() ) 2565 if ( !redo->top() )
2562 mActionRedo->setText( i18n( "Redo" ) ); 2566 mActionRedo->setText( i18n( "Redo" ) );
2563 else 2567 else
2564 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2565 2569
2566 mActionRedo->setEnabled( !redo->isEmpty() ); 2570 mActionRedo->setEnabled( !redo->isEmpty() );
2567} 2571}
2568 2572
2569void KABCore::configureKeyBindings() 2573void KABCore::configureKeyBindings()
2570{ 2574{
2571#ifndef KAB_EMBEDDED 2575#ifndef KAB_EMBEDDED
2572 KKeyDialog::configure( actionCollection(), true ); 2576 KKeyDialog::configure( actionCollection(), true );
2573#else //KAB_EMBEDDED 2577#else //KAB_EMBEDDED
2574 qDebug("KABCore::configureKeyBindings() not implemented"); 2578 qDebug("KABCore::configureKeyBindings() not implemented");
2575#endif //KAB_EMBEDDED 2579#endif //KAB_EMBEDDED
2576} 2580}
2577 2581
2578#ifdef KAB_EMBEDDED 2582#ifdef KAB_EMBEDDED
2579void KABCore::configureResources() 2583void KABCore::configureResources()
2580{ 2584{
2581 KRES::KCMKResources dlg( this, "" , 0 ); 2585 KRES::KCMKResources dlg( this, "" , 0 );
2582 2586
2583 if ( !dlg.exec() ) 2587 if ( !dlg.exec() )
2584 return; 2588 return;
2585 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2586} 2590}
2587#endif //KAB_EMBEDDED 2591#endif //KAB_EMBEDDED
2588 2592
2589 2593
2590/* this method will be called through the QCop interface from Ko/Pi to select addresses 2594/* this method will be called through the QCop interface from Ko/Pi to select addresses
2591 * for the attendees list of an event. 2595 * for the attendees list of an event.
2592 */ 2596 */
2593void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2594{ 2598{
2595 qDebug("KABCore::requestForNameEmailUidList "); 2599 qDebug("KABCore::requestForNameEmailUidList ");
2596 bool ok = false; 2600 bool ok = false;
2597 mEmailSourceChannel = sourceChannel; 2601 mEmailSourceChannel = sourceChannel;
2598 mEmailSourceUID = uid; 2602 mEmailSourceUID = uid;
2599 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2600 //callContactdialog(); 2604 //callContactdialog();
2601#if 0 2605#if 0
2602 int wid = uid.toInt( &ok ); 2606 int wid = uid.toInt( &ok );
2603 qDebug("UID %s ", uid.latin1()); 2607 qDebug("UID %s ", uid.latin1());
2604 if ( ok ) { 2608 if ( ok ) {
2605 if ( wid != QApplication::desktop()->width() ) { 2609 if ( wid != QApplication::desktop()->width() ) {
2606 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2607 message( i18n("Resizing, please wait...") ); 2611 message( i18n("Resizing, please wait...") );
2608 mMainWindow->showMinimized(); 2612 mMainWindow->showMinimized();
2609 /* 2613 /*
2610 { 2614 {
2611 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2612 } 2616 }
2613 */ 2617 */
2614 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2615 return; 2619 return;
2616 } 2620 }
2617 2621
2618 } else { 2622 } else {
2619 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2620 } 2624 }
2621 callContactdialog(); 2625 callContactdialog();
2622 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2623#endif 2627#endif
2624} 2628}
2625void KABCore::resizeAndCallContactdialog() 2629void KABCore::resizeAndCallContactdialog()
2626{ 2630{
2627 updateMainWindow(); 2631 updateMainWindow();
2628 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2629} 2633}
2630 2634
2631void KABCore::doRingSync() 2635void KABCore::doRingSync()
2632{ 2636{
2633 topLevelWidget()->raise(); 2637 topLevelWidget()->raise();
2634 syncManager->multiSync( false ); 2638 syncManager->multiSync( false );
2635} 2639}
2636void KABCore::callContactdialog() 2640void KABCore::callContactdialog()
2637{ 2641{
2638 static bool running = false; 2642 static bool running = false;
2639 if (running) return; 2643 if (running) return;
2640 running = true; 2644 running = true;
2641 QStringList nameList; 2645 QStringList nameList;
2642 QStringList emailList; 2646 QStringList emailList;
2643 QStringList uidList; 2647 QStringList uidList;
2644 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2645 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2646 uint i=0; 2650 uint i=0;
2647 for (i=0; i < list.count(); i++) 2651 for (i=0; i < list.count(); i++)
2648 { 2652 {
2649 nameList.append(list[i].realName()); 2653 nameList.append(list[i].realName());
2650 emailList.append(list[i].preferredEmail()); 2654 emailList.append(list[i].preferredEmail());
2651 uidList.append(list[i].uid()); 2655 uidList.append(list[i].uid());
2652 } 2656 }
2653 QString uid = mEmailSourceUID; 2657 QString uid = mEmailSourceUID;
2654 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2655 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2656 running = false; 2660 running = false;
2657} 2661}
2658/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2659 * to put them into the calendar. 2663 * to put them into the calendar.
2660 */ 2664 */
2661void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2662{ 2666{
2663 // qDebug("KABCore::requestForBirthdayList"); 2667 // qDebug("KABCore::requestForBirthdayList");
2664 QStringList birthdayList; 2668 QStringList birthdayList;
2665 QStringList anniversaryList; 2669 QStringList anniversaryList;
2666 QStringList realNameList; 2670 QStringList realNameList;
2667 QStringList preferredEmailList; 2671 QStringList preferredEmailList;
2668 QStringList assembledNameList; 2672 QStringList assembledNameList;
2669 QStringList uidList; 2673 QStringList uidList;
2670 2674
2671 KABC::AddressBook::Iterator it; 2675 KABC::AddressBook::Iterator it;
2672 2676
2673 int count = 0; 2677 int count = 0;
2674 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2675 ++count; 2679 ++count;
2676 } 2680 }
2677 QProgressBar bar(count,0 ); 2681 QProgressBar bar(count,0 );
2678 int w = 300; 2682 int w = 300;
2679 if ( QApplication::desktop()->width() < 320 ) 2683 if ( QApplication::desktop()->width() < 320 )
2680 w = 220; 2684 w = 220;
2681 int h = bar.sizeHint().height() ; 2685 int h = bar.sizeHint().height() ;
2682 int dw = QApplication::desktop()->width(); 2686 int dw = QApplication::desktop()->width();
2683 int dh = QApplication::desktop()->height(); 2687 int dh = QApplication::desktop()->height();
2684 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2685 bar.show(); 2689 bar.show();
2686 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2687 qApp->processEvents(); 2691 qApp->processEvents();
2688 2692
2689 QDate bday; 2693 QDate bday;
2690 QString anni; 2694 QString anni;
2691 QString formattedbday; 2695 QString formattedbday;
2692 2696
2693 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2694 { 2698 {
2695 if ( ! bar.isVisible() ) 2699 if ( ! bar.isVisible() )
2696 return; 2700 return;
2697 bar.setProgress( count++ ); 2701 bar.setProgress( count++ );
2698 qApp->processEvents(); 2702 qApp->processEvents();
2699 bday = (*it).birthday().date(); 2703 bday = (*it).birthday().date();
2700 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2701 2705
2702 if ( bday.isValid() || !anni.isEmpty()) 2706 if ( bday.isValid() || !anni.isEmpty())
2703 { 2707 {
2704 if (bday.isValid()) 2708 if (bday.isValid())
2705 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2706 else 2710 else
2707 formattedbday = "NOTVALID"; 2711 formattedbday = "NOTVALID";
2708 if (anni.isEmpty()) 2712 if (anni.isEmpty())
2709 anni = "INVALID"; 2713 anni = "INVALID";
2710 2714
2711 birthdayList.append(formattedbday); 2715 birthdayList.append(formattedbday);
2712 anniversaryList.append(anni); //should be ISODate 2716 anniversaryList.append(anni); //should be ISODate
2713 realNameList.append((*it).realName()); 2717 realNameList.append((*it).realName());
2714 preferredEmailList.append((*it).preferredEmail()); 2718 preferredEmailList.append((*it).preferredEmail());
2715 assembledNameList.append((*it).realName()); 2719 assembledNameList.append((*it).realName());
2716 uidList.append((*it).uid()); 2720 uidList.append((*it).uid());
2717 2721
2718 //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() ); 2722 //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() );
2719 } 2723 }
2720 } 2724 }
2721 2725
2722 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2723 2727
2724} 2728}
2725 2729
2726/* this method will be called through the QCop interface from other apps to show details of a contact. 2730/* this method will be called through the QCop interface from other apps to show details of a contact.
2727 */ 2731 */
2728void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2729{ 2733{
2730 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2731 2735
2732 QString foundUid = QString::null; 2736 QString foundUid = QString::null;
2733 if ( ! uid.isEmpty() ) { 2737 if ( ! uid.isEmpty() ) {
2734 Addressee adrr = mAddressBook->findByUid( uid ); 2738 Addressee adrr = mAddressBook->findByUid( uid );
2735 if ( !adrr.isEmpty() ) { 2739 if ( !adrr.isEmpty() ) {
2736 foundUid = uid; 2740 foundUid = uid;
2737 } 2741 }
2738 if ( email == "sendbacklist" ) { 2742 if ( email == "sendbacklist" ) {
2739 //qDebug("ssssssssssssssssssssssend "); 2743 //qDebug("ssssssssssssssssssssssend ");
2740 QStringList nameList; 2744 QStringList nameList;
2741 QStringList emailList; 2745 QStringList emailList;
2742 QStringList uidList; 2746 QStringList uidList;
2743 nameList.append(adrr.realName()); 2747 nameList.append(adrr.realName());
2744 emailList = adrr.emails(); 2748 emailList = adrr.emails();
2745 uidList.append( adrr.preferredEmail()); 2749 uidList.append( adrr.preferredEmail());
2746 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2747 return; 2751 return;
2748 } 2752 }
2749 2753
2750 } 2754 }
2751 2755
2752 if ( email == "sendbacklist" ) 2756 if ( email == "sendbacklist" )
2753 return; 2757 return;
2754 if (foundUid.isEmpty()) 2758 if (foundUid.isEmpty())
2755 { 2759 {
2756 //find the uid of the person first 2760 //find the uid of the person first
2757 Addressee::List namelist; 2761 Addressee::List namelist;
2758 Addressee::List emaillist; 2762 Addressee::List emaillist;
2759 2763
2760 if (!name.isEmpty()) 2764 if (!name.isEmpty())
2761 namelist = mAddressBook->findByName( name ); 2765 namelist = mAddressBook->findByName( name );
2762 2766
2763 if (!email.isEmpty()) 2767 if (!email.isEmpty())
2764 emaillist = mAddressBook->findByEmail( email ); 2768 emaillist = mAddressBook->findByEmail( email );
2765 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2766 //check if we have a match in Namelist and Emaillist 2770 //check if we have a match in Namelist and Emaillist
2767 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2768 foundUid = emaillist[0].uid(); 2772 foundUid = emaillist[0].uid();
2769 } 2773 }
2770 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2774 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2771 foundUid = namelist[0].uid(); 2775 foundUid = namelist[0].uid();
2772 else 2776 else
2773 { 2777 {
2774 for (int i = 0; i < namelist.count(); i++) 2778 for (int i = 0; i < namelist.count(); i++)
2775 { 2779 {
2776 for (int j = 0; j < emaillist.count(); j++) 2780 for (int j = 0; j < emaillist.count(); j++)
2777 { 2781 {
2778 if (namelist[i] == emaillist[j]) 2782 if (namelist[i] == emaillist[j])
2779 { 2783 {
2780 foundUid = namelist[i].uid(); 2784 foundUid = namelist[i].uid();
2781 } 2785 }
2782 } 2786 }
2783 } 2787 }
2784 } 2788 }
2785 } 2789 }
2786 else 2790 else
2787 { 2791 {
2788 foundUid = uid; 2792 foundUid = uid;
2789 } 2793 }
2790 2794
2791 if (!foundUid.isEmpty()) 2795 if (!foundUid.isEmpty())
2792 { 2796 {
2793 2797
2794 // raise Ka/Pi if it is in the background 2798 // raise Ka/Pi if it is in the background
2795#ifndef DESKTOP_VERSION 2799#ifndef DESKTOP_VERSION
2796#ifndef KORG_NODCOP 2800#ifndef KORG_NODCOP
2797 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2801 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2798#endif 2802#endif
2799#endif 2803#endif
2800 2804
2801 mMainWindow->showMaximized(); 2805 mMainWindow->showMaximized();
2802 mMainWindow-> raise(); 2806 mMainWindow-> raise();
2803 2807
2804 mViewManager->setSelected( "", false); 2808 mViewManager->setSelected( "", false);
2805 mViewManager->refreshView( "" ); 2809 mViewManager->refreshView( "" );
2806 mViewManager->setSelected( foundUid, true ); 2810 mViewManager->setSelected( foundUid, true );
2807 mViewManager->refreshView( foundUid ); 2811 mViewManager->refreshView( foundUid );
2808 2812
2809 if ( !mMultipleViewsAtOnce ) 2813 if ( !mMultipleViewsAtOnce )
2810 { 2814 {
2811 setDetailsVisible( true ); 2815 setDetailsVisible( true );
2812 mActionDetails->setChecked(true); 2816 mActionDetails->setChecked(true);
2813 } 2817 }
2814 } 2818 }
2815} 2819}
2816void KABCore::storagehowto() 2820void KABCore::storagehowto()
2817{ 2821{
2818 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2819} 2823}
2820void KABCore::whatsnew() 2824void KABCore::whatsnew()
2821{ 2825{
2822 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2823} 2827}
2824void KABCore::synchowto() 2828void KABCore::synchowto()
2825{ 2829{
2826 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2827} 2831}
2828void KABCore::kdesynchowto() 2832void KABCore::kdesynchowto()
2829{ 2833{
2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2831} 2835}
2832void KABCore::multisynchowto() 2836void KABCore::multisynchowto()
2833{ 2837{
2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2835} 2839}
2836void KABCore::faq() 2840void KABCore::faq()
2837{ 2841{
2838 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2839} 2843}
2840 2844
2841#include <libkcal/syncdefines.h> 2845#include <libkcal/syncdefines.h>
2842 2846
2843KABC::Addressee KABCore::getLastSyncAddressee() 2847KABC::Addressee KABCore::getLastSyncAddressee()
2844{ 2848{
2845 Addressee lse; 2849 Addressee lse;
2846 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2847 2851
2848 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2849 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2850 if (lse.isEmpty()) { 2854 if (lse.isEmpty()) {
2851 qDebug("KA: Creating new last-syncAddressee "); 2855 qDebug("KA: Creating new last-syncAddressee ");
2852 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2853 QString sum = ""; 2857 QString sum = "";
2854 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2855 sum = "E: "; 2859 sum = "E: ";
2856 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2857 lse.setRevision( mLastAddressbookSync ); 2861 lse.setRevision( mLastAddressbookSync );
2858 lse.setCategories( i18n("SyncEvent") ); 2862 lse.setCategories( i18n("SyncEvent") );
2859 mAddressBook->insertAddressee( lse ); 2863 mAddressBook->insertAddressee( lse );
2860 } 2864 }
2861 return lse; 2865 return lse;
2862} 2866}
2863int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2864{ 2868{
2865 2869
2866 //void setZaurusId(int id); 2870 //void setZaurusId(int id);
2867 // int zaurusId() const; 2871 // int zaurusId() const;
2868 // void setZaurusUid(int id); 2872 // void setZaurusUid(int id);
2869 // int zaurusUid() const; 2873 // int zaurusUid() const;
2870 // void setZaurusStat(int id); 2874 // void setZaurusStat(int id);
2871 // int zaurusStat() const; 2875 // int zaurusStat() const;
2872 // 0 equal 2876 // 0 equal
2873 // 1 take local 2877 // 1 take local
2874 // 2 take remote 2878 // 2 take remote
2875 // 3 cancel 2879 // 3 cancel
2876 QDateTime lastSync = mLastAddressbookSync; 2880 QDateTime lastSync = mLastAddressbookSync;
2877 QDateTime localMod = local->revision(); 2881 QDateTime localMod = local->revision();
2878 QDateTime remoteMod = remote->revision(); 2882 QDateTime remoteMod = remote->revision();
2879 2883
2880 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2881 2885
2882 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2883 bool remCh, locCh; 2887 bool remCh, locCh;
2884 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2885 //if ( remCh ) 2889 //if ( remCh )
2886 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2887 locCh = ( localMod > mLastAddressbookSync ); 2891 locCh = ( localMod > mLastAddressbookSync );
2888 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2892 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2889 if ( !remCh && ! locCh ) { 2893 if ( !remCh && ! locCh ) {
2890 //qDebug("both not changed "); 2894 //qDebug("both not changed ");
2891 lastSync = localMod.addDays(1); 2895 lastSync = localMod.addDays(1);
2892 if ( mode <= SYNC_PREF_ASK ) 2896 if ( mode <= SYNC_PREF_ASK )
2893 return 0; 2897 return 0;
2894 } else { 2898 } else {
2895 if ( locCh ) { 2899 if ( locCh ) {
2896 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2897 lastSync = localMod.addDays( -1 ); 2901 lastSync = localMod.addDays( -1 );
2898 if ( !remCh ) 2902 if ( !remCh )
2899 remoteMod =( lastSync.addDays( -1 ) ); 2903 remoteMod =( lastSync.addDays( -1 ) );
2900 } else { 2904 } else {
2901 //qDebug(" not loc changed "); 2905 //qDebug(" not loc changed ");
2902 lastSync = localMod.addDays( 1 ); 2906 lastSync = localMod.addDays( 1 );
2903 if ( remCh ) { 2907 if ( remCh ) {
2904 //qDebug("rem changed "); 2908 //qDebug("rem changed ");
2905 remoteMod =( lastSync.addDays( 1 ) ); 2909 remoteMod =( lastSync.addDays( 1 ) );
2906 } 2910 }
2907 2911
2908 } 2912 }
2909 } 2913 }
2910 full = true; 2914 full = true;
2911 if ( mode < SYNC_PREF_ASK ) 2915 if ( mode < SYNC_PREF_ASK )
2912 mode = SYNC_PREF_ASK; 2916 mode = SYNC_PREF_ASK;
2913 } else { 2917 } else {
2914 if ( localMod == remoteMod ) 2918 if ( localMod == remoteMod )
2915 return 0; 2919 return 0;
2916 2920
2917 } 2921 }
2918 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2919 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2923 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2920 //full = true; //debug only 2924 //full = true; //debug only
2921 if ( full ) { 2925 if ( full ) {
2922 bool equ = ( (*local) == (*remote) ); 2926 bool equ = ( (*local) == (*remote) );
2923 if ( equ ) { 2927 if ( equ ) {
2924 //qDebug("equal "); 2928 //qDebug("equal ");
2925 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2926 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2927 } 2931 }
2928 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2932 if ( mode < SYNC_PREF_FORCE_LOCAL )
2929 return 0; 2933 return 0;
2930 2934
2931 }//else //debug only 2935 }//else //debug only
2932 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2933 } 2937 }
2934 int result; 2938 int result;
2935 bool localIsNew; 2939 bool localIsNew;
2936 //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() ); 2940 //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() );
2937 2941
2938 if ( full && mode < SYNC_PREF_NEWEST ) 2942 if ( full && mode < SYNC_PREF_NEWEST )
2939 mode = SYNC_PREF_ASK; 2943 mode = SYNC_PREF_ASK;
2940 2944
2941 switch( mode ) { 2945 switch( mode ) {
2942 case SYNC_PREF_LOCAL: 2946 case SYNC_PREF_LOCAL:
2943 if ( lastSync > remoteMod ) 2947 if ( lastSync > remoteMod )
2944 return 1; 2948 return 1;
2945 if ( lastSync > localMod ) 2949 if ( lastSync > localMod )
2946 return 2; 2950 return 2;
2947 return 1; 2951 return 1;
2948 break; 2952 break;
2949 case SYNC_PREF_REMOTE: 2953 case SYNC_PREF_REMOTE:
2950 if ( lastSync > localMod ) 2954 if ( lastSync > localMod )
2951 return 2; 2955 return 2;
2952 if ( lastSync > remoteMod ) 2956 if ( lastSync > remoteMod )
2953 return 1; 2957 return 1;
2954 return 2; 2958 return 2;
2955 break; 2959 break;
2956 case SYNC_PREF_NEWEST: 2960 case SYNC_PREF_NEWEST:
2957 if ( localMod > remoteMod ) 2961 if ( localMod > remoteMod )
2958 return 1; 2962 return 1;
2959 else 2963 else
2960 return 2; 2964 return 2;
2961 break; 2965 break;
2962 case SYNC_PREF_ASK: 2966 case SYNC_PREF_ASK:
2963 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2964 if ( lastSync > remoteMod && lastSync > localMod) 2968 if ( lastSync > remoteMod && lastSync > localMod)
2965 return 0; 2969 return 0;
2966 if ( lastSync > remoteMod ) 2970 if ( lastSync > remoteMod )
2967 return 1; 2971 return 1;
2968 if ( lastSync > localMod ) { 2972 if ( lastSync > localMod ) {
2969 return 2; 2973 return 2;
2970 } 2974 }
2971 localIsNew = localMod >= remoteMod; 2975 localIsNew = localMod >= remoteMod;
2972 //qDebug("conflict! ************************************** "); 2976 //qDebug("conflict! ************************************** ");
2973 { 2977 {
2974 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2975 result = acd.executeD(localIsNew); 2979 result = acd.executeD(localIsNew);
2976 return result; 2980 return result;
2977 } 2981 }
2978 break; 2982 break;
2979 case SYNC_PREF_FORCE_LOCAL: 2983 case SYNC_PREF_FORCE_LOCAL:
2980 return 1; 2984 return 1;
2981 break; 2985 break;
2982 case SYNC_PREF_FORCE_REMOTE: 2986 case SYNC_PREF_FORCE_REMOTE:
2983 return 2; 2987 return 2;
2984 break; 2988 break;
2985 2989
2986 default: 2990 default:
2987 // SYNC_PREF_TAKE_BOTH not implemented 2991 // SYNC_PREF_TAKE_BOTH not implemented
2988 break; 2992 break;
2989 } 2993 }
2990 return 0; 2994 return 0;
2991} 2995}
2992 2996
2993 2997
2994bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2995{ 2999{
2996 bool syncOK = true; 3000 bool syncOK = true;
2997 int addedAddressee = 0; 3001 int addedAddressee = 0;
2998 int addedAddresseeR = 0; 3002 int addedAddresseeR = 0;
2999 int deletedAddresseeR = 0; 3003 int deletedAddresseeR = 0;
3000 int deletedAddresseeL = 0; 3004 int deletedAddresseeL = 0;
3001 int changedLocal = 0; 3005 int changedLocal = 0;
3002 int changedRemote = 0; 3006 int changedRemote = 0;
3003 int filteredIN = 0; 3007 int filteredIN = 0;
3004 int filteredOUT = 0; 3008 int filteredOUT = 0;
3005 3009
3006 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 3010 QString mCurrentSyncName = syncManager->getCurrentSyncName();
3007 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3008 3012
3009 //QPtrList<Addressee> el = local->rawAddressees(); 3013 //QPtrList<Addressee> el = local->rawAddressees();
3010 Addressee addresseeR; 3014 Addressee addresseeR;
3011 QString uid; 3015 QString uid;
3012 int take; 3016 int take;
3013 Addressee addresseeL; 3017 Addressee addresseeL;
3014 Addressee addresseeRSync; 3018 Addressee addresseeRSync;
3015 Addressee addresseeLSync; 3019 Addressee addresseeLSync;
3016 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3017 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3018 bool fullDateRange = false; 3022 bool fullDateRange = false;
3019 local->resetTempSyncStat(); 3023 local->resetTempSyncStat();
3020 mLastAddressbookSync = QDateTime::currentDateTime(); 3024 mLastAddressbookSync = QDateTime::currentDateTime();
3021 if ( syncManager->syncWithDesktop() ) { 3025 if ( syncManager->syncWithDesktop() ) {
3022 // remote->removeSyncInfo( QString());//remove all info 3026 // remote->removeSyncInfo( QString());//remove all info
3023 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3024 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3025 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3026 } else { 3030 } else {
3027 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3028 } 3032 }
3029 } 3033 }
3030 QDateTime modifiedCalendar = mLastAddressbookSync; 3034 QDateTime modifiedCalendar = mLastAddressbookSync;
3031 addresseeLSync = getLastSyncAddressee(); 3035 addresseeLSync = getLastSyncAddressee();
3032 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3033 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3034 if ( !addresseeR.isEmpty() ) { 3038 if ( !addresseeR.isEmpty() ) {
3035 addresseeRSync = addresseeR; 3039 addresseeRSync = addresseeR;
3036 remote->removeAddressee(addresseeR ); 3040 remote->removeAddressee(addresseeR );
3037 3041
3038 } else { 3042 } else {
3039 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3040 addresseeRSync = addresseeLSync ; 3044 addresseeRSync = addresseeLSync ;
3041 } else { 3045 } else {
3042 //qDebug("FULLDATE 1"); 3046 //qDebug("FULLDATE 1");
3043 fullDateRange = true; 3047 fullDateRange = true;
3044 Addressee newAdd; 3048 Addressee newAdd;
3045 addresseeRSync = newAdd; 3049 addresseeRSync = newAdd;
3046 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3047 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3048 addresseeRSync.setRevision( mLastAddressbookSync ); 3052 addresseeRSync.setRevision( mLastAddressbookSync );
3049 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3053 addresseeRSync.setCategories( i18n("SyncAddressee") );
3050 } 3054 }
3051 } 3055 }
3052 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3053 // qDebug("FULLDATE 2"); 3057 // qDebug("FULLDATE 2");
3054 fullDateRange = true; 3058 fullDateRange = true;
3055 } 3059 }
3056 if ( ! fullDateRange ) { 3060 if ( ! fullDateRange ) {
3057 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3058 3062
3059 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3060 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3061 fullDateRange = true; 3065 fullDateRange = true;
3062 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3063 } 3067 }
3064 } 3068 }
3065 // fullDateRange = true; // debug only! 3069 // fullDateRange = true; // debug only!
3066 if ( fullDateRange ) 3070 if ( fullDateRange )
3067 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3068 else 3072 else
3069 mLastAddressbookSync = addresseeLSync.revision(); 3073 mLastAddressbookSync = addresseeLSync.revision();
3070 // for resyncing if own file has changed 3074 // for resyncing if own file has changed
3071 // PENDING fixme later when implemented 3075 // PENDING fixme later when implemented
3072#if 0 3076#if 0
3073 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3077 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3074 mLastAddressbookSync = loadedFileVersion; 3078 mLastAddressbookSync = loadedFileVersion;
3075 qDebug("setting mLastAddressbookSync "); 3079 qDebug("setting mLastAddressbookSync ");
3076 } 3080 }
3077#endif 3081#endif
3078 3082
3079 3083
3080 // ********** setting filters **************** 3084 // ********** setting filters ****************
3081 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3082 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3083 3087
3084 //qDebug("*************************** "); 3088 //qDebug("*************************** ");
3085 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3086 QStringList er = remote->uidList(); 3090 QStringList er = remote->uidList();
3087 Addressee inR ;//= er.first(); 3091 Addressee inR ;//= er.first();
3088 Addressee inL; 3092 Addressee inL;
3089 3093
3090 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3091 3095
3092 int modulo = (er.count()/10)+1; 3096 int modulo = (er.count()/10)+1;
3093 int incCounter = 0; 3097 int incCounter = 0;
3094 while ( incCounter < er.count()) { 3098 while ( incCounter < er.count()) {
3095 if (syncManager->isProgressBarCanceled()) 3099 if (syncManager->isProgressBarCanceled())
3096 return false; 3100 return false;
3097 if ( incCounter % modulo == 0 ) 3101 if ( incCounter % modulo == 0 )
3098 syncManager->showProgressBar(incCounter); 3102 syncManager->showProgressBar(incCounter);
3099 3103
3100 uid = er[ incCounter ]; 3104 uid = er[ incCounter ];
3101 bool skipIncidence = false; 3105 bool skipIncidence = false;
3102 if ( uid.left(19) == QString("last-syncAddressee-") ) 3106 if ( uid.left(19) == QString("last-syncAddressee-") )
3103 skipIncidence = true; 3107 skipIncidence = true;
3104 QString idS,OidS; 3108 QString idS,OidS;
3105 qApp->processEvents(); 3109 qApp->processEvents();
3106 if ( !skipIncidence ) { 3110 if ( !skipIncidence ) {
3107 inL = local->findByUid( uid ); 3111 inL = local->findByUid( uid );
3108 inR = remote->findByUid( uid ); 3112 inR = remote->findByUid( uid );
3109 //inL.setResource( 0 ); 3113 //inL.setResource( 0 );
3110 //inR.setResource( 0 ); 3114 //inR.setResource( 0 );
3111 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3112 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3116 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3113 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3114 //qDebug("take %d %s ", take, inL.summary().latin1()); 3118 //qDebug("take %d %s ", take, inL.summary().latin1());
3115 if ( take == 3 ) 3119 if ( take == 3 )
3116 return false; 3120 return false;
3117 if ( take == 1 ) {// take local ********************** 3121 if ( take == 1 ) {// take local **********************
3118 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3119 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3120 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3121 local->insertAddressee( inL, false ); 3125 local->insertAddressee( inL, false );
3122 idS = inR.externalUID(); 3126 idS = inR.externalUID();
3123 OidS = inR.originalExternalUID(); 3127 OidS = inR.originalExternalUID();
3124 } 3128 }
3125 else 3129 else
3126 idS = inR.IDStr(); 3130 idS = inR.IDStr();
3127 remote->removeAddressee( inR ); 3131 remote->removeAddressee( inR );
3128 inR = inL; 3132 inR = inL;
3129 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3130 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3131 inR.setOriginalExternalUID( OidS ); 3135 inR.setOriginalExternalUID( OidS );
3132 inR.setExternalUID( idS ); 3136 inR.setExternalUID( idS );
3133 if ( syncManager->syncWithDesktop() ) { 3137 if ( syncManager->syncWithDesktop() ) {
3134 inR.setIDStr("changed" ); 3138 inR.setIDStr("changed" );
3135 } 3139 }
3136 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3137 } else { 3141 } else {
3138 inR.setIDStr( idS ); 3142 inR.setIDStr( idS );
3139 } 3143 }
3140 inR.setResource( 0 ); 3144 inR.setResource( 0 );
3141 remote->insertAddressee( inR , false); 3145 remote->insertAddressee( inR , false);
3142 ++changedRemote; 3146 ++changedRemote;
3143 } else { // take == 2 take remote ********************** 3147 } else { // take == 2 take remote **********************
3144 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3145 if ( inR.revision().date().year() < 2004 ) 3149 if ( inR.revision().date().year() < 2004 )
3146 inR.setRevision( modifiedCalendar ); 3150 inR.setRevision( modifiedCalendar );
3147 } 3151 }
3148 idS = inL.IDStr(); 3152 idS = inL.IDStr();
3149 local->removeAddressee( inL ); 3153 local->removeAddressee( inL );
3150 inL = inR; 3154 inL = inR;
3151 inL.setIDStr( idS ); 3155 inL.setIDStr( idS );
3152 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3153 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3154 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3155 } 3159 }
3156 inL.setResource( 0 ); 3160 inL.setResource( 0 );
3157 local->insertAddressee( inL , false ); 3161 local->insertAddressee( inL , false );
3158 ++changedLocal; 3162 ++changedLocal;
3159 } 3163 }
3160 } 3164 }
3161 } 3165 }
3162 } else { // no conflict ********** add or delete remote 3166 } else { // no conflict ********** add or delete remote
3163 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3164 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3165 QString des = addresseeLSync.note(); 3169 QString des = addresseeLSync.note();
3166 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3167 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3168 remote->insertAddressee( inR, false ); 3172 remote->insertAddressee( inR, false );
3169 ++deletedAddresseeR; 3173 ++deletedAddresseeR;
3170 } else { 3174 } else {
3171 inR.setRevision( modifiedCalendar ); 3175 inR.setRevision( modifiedCalendar );
3172 remote->insertAddressee( inR, false ); 3176 remote->insertAddressee( inR, false );
3173 inL = inR; 3177 inL = inR;
3174 inL.setIDStr( ":" ); 3178 inL.setIDStr( ":" );
3175 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3176 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3177 inL.setResource( 0 ); 3181 inL.setResource( 0 );
3178 local->insertAddressee( inL , false); 3182 local->insertAddressee( inL , false);
3179 ++addedAddressee; 3183 ++addedAddressee;
3180 } 3184 }
3181 } else { 3185 } else {
3182 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3183 inR.setRevision( modifiedCalendar ); 3187 inR.setRevision( modifiedCalendar );
3184 remote->insertAddressee( inR, false ); 3188 remote->insertAddressee( inR, false );
3185 inR.setResource( 0 ); 3189 inR.setResource( 0 );
3186 local->insertAddressee( inR, false ); 3190 local->insertAddressee( inR, false );
3187 ++addedAddressee; 3191 ++addedAddressee;
3188 } else { 3192 } else {
3189 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3190 remote->removeAddressee( inR ); 3194 remote->removeAddressee( inR );
3191 ++deletedAddresseeR; 3195 ++deletedAddresseeR;
3192 } 3196 }
3193 } 3197 }
3194 } else { 3198 } else {
3195 ++filteredIN; 3199 ++filteredIN;
3196 } 3200 }
3197 } 3201 }
3198 } 3202 }
3199 ++incCounter; 3203 ++incCounter;
3200 } 3204 }
3201 er.clear(); 3205 er.clear();
3202 QStringList el = local->uidList(); 3206 QStringList el = local->uidList();
3203 modulo = (el.count()/10)+1; 3207 modulo = (el.count()/10)+1;
3204 3208
3205 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3206 incCounter = 0; 3210 incCounter = 0;
3207 while ( incCounter < el.count()) { 3211 while ( incCounter < el.count()) {
3208 qApp->processEvents(); 3212 qApp->processEvents();
3209 if (syncManager->isProgressBarCanceled()) 3213 if (syncManager->isProgressBarCanceled())
3210 return false; 3214 return false;
3211 if ( incCounter % modulo == 0 ) 3215 if ( incCounter % modulo == 0 )
3212 syncManager->showProgressBar(incCounter); 3216 syncManager->showProgressBar(incCounter);
3213 uid = el[ incCounter ]; 3217 uid = el[ incCounter ];
3214 bool skipIncidence = false; 3218 bool skipIncidence = false;
3215 if ( uid.left(19) == QString("last-syncAddressee-") ) 3219 if ( uid.left(19) == QString("last-syncAddressee-") )
3216 skipIncidence = true; 3220 skipIncidence = true;
3217 if ( !skipIncidence ) { 3221 if ( !skipIncidence ) {
3218 inL = local->findByUid( uid ); 3222 inL = local->findByUid( uid );
3219 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3223 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3220 inR = remote->findByUid( uid ); 3224 inR = remote->findByUid( uid );
3221 if ( inR.isEmpty() ){ 3225 if ( inR.isEmpty() ){
3222 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3223 // no conflict ********** add or delete local 3227 // no conflict ********** add or delete local
3224 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3225 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3226 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3227 local->removeAddressee( inL ); 3231 local->removeAddressee( inL );
3228 ++deletedAddresseeL; 3232 ++deletedAddresseeL;
3229 } else { 3233 } else {
3230 if ( ! syncManager->mWriteBackExistingOnly ) { 3234 if ( ! syncManager->mWriteBackExistingOnly ) {
3231 inL.removeID(mCurrentSyncDevice ); 3235 inL.removeID(mCurrentSyncDevice );
3232 ++addedAddresseeR; 3236 ++addedAddresseeR;
3233 inL.setRevision( modifiedCalendar ); 3237 inL.setRevision( modifiedCalendar );
3234 local->insertAddressee( inL, false ); 3238 local->insertAddressee( inL, false );
3235 inR = inL; 3239 inR = inL;
3236 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3237 inR.setResource( 0 ); 3241 inR.setResource( 0 );
3238 remote->insertAddressee( inR, false ); 3242 remote->insertAddressee( inR, false );
3239 } 3243 }
3240 } 3244 }
3241 } else { 3245 } else {
3242 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3243 //qDebug("data %s ", inL.revision().toString().latin1()); 3247 //qDebug("data %s ", inL.revision().toString().latin1());
3244 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3245 local->removeAddressee( inL ); 3249 local->removeAddressee( inL );
3246 ++deletedAddresseeL; 3250 ++deletedAddresseeL;
3247 } else { 3251 } else {
3248 if ( ! syncManager->mWriteBackExistingOnly ) { 3252 if ( ! syncManager->mWriteBackExistingOnly ) {
3249 ++addedAddresseeR; 3253 ++addedAddresseeR;
3250 inL.setRevision( modifiedCalendar ); 3254 inL.setRevision( modifiedCalendar );
3251 local->insertAddressee( inL, false ); 3255 local->insertAddressee( inL, false );
3252 inR = inL; 3256 inR = inL;
3253 inR.setIDStr( ":" ); 3257 inR.setIDStr( ":" );
3254 inR.setResource( 0 ); 3258 inR.setResource( 0 );
3255 remote->insertAddressee( inR, false ); 3259 remote->insertAddressee( inR, false );
3256 } 3260 }
3257 } 3261 }
3258 } 3262 }
3259 } else { 3263 } else {
3260 ++filteredOUT; 3264 ++filteredOUT;
3261 } 3265 }
3262 } 3266 }
3263 } 3267 }
3264 } 3268 }
3265 ++incCounter; 3269 ++incCounter;
3266 } 3270 }
3267 el.clear(); 3271 el.clear();
3268 syncManager->hideProgressBar(); 3272 syncManager->hideProgressBar();
3269 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3270 // get rid of micro seconds 3274 // get rid of micro seconds
3271 QTime t = mLastAddressbookSync.time(); 3275 QTime t = mLastAddressbookSync.time();
3272 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3273 addresseeLSync.setRevision( mLastAddressbookSync ); 3277 addresseeLSync.setRevision( mLastAddressbookSync );
3274 addresseeRSync.setRevision( mLastAddressbookSync ); 3278 addresseeRSync.setRevision( mLastAddressbookSync );
3275 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3276 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3277 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3278 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3279 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3280 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3281 addresseeRSync.setNote( "" ) ; 3285 addresseeRSync.setNote( "" ) ;
3282 addresseeLSync.setNote( "" ); 3286 addresseeLSync.setNote( "" );
3283 3287
3284 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3285 remote->insertAddressee( addresseeRSync, false ); 3289 remote->insertAddressee( addresseeRSync, false );
3286 local->insertAddressee( addresseeLSync, false ); 3290 local->insertAddressee( addresseeLSync, false );
3287 QString mes; 3291 QString mes;
3288 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 ); 3292 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 );
3289 qDebug( mes ); 3293 qDebug( mes );
3290 mes = i18n("Local addressbook changed!\n") +mes; 3294 mes = i18n("Local addressbook changed!\n") +mes;
3291 if ( syncManager->mShowSyncSummary ) { 3295 if ( syncManager->mShowSyncSummary ) {
3292 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3293 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3294 qDebug("KA: WB cancelled "); 3298 qDebug("KA: WB cancelled ");
3295 syncManager->mWriteBackFile = false; 3299 syncManager->mWriteBackFile = false;
3296 return syncOK; 3300 return syncOK;
3297 } 3301 }
3298 } 3302 }
3299 return syncOK; 3303 return syncOK;
3300} 3304}
3301 3305
3302 3306
3303//this is a overwritten callbackmethods from the syncinterface 3307//this is a overwritten callbackmethods from the syncinterface
3304bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3305{ 3309{
3306 3310
3307 //pending prepare addresseeview for output 3311 //pending prepare addresseeview for output
3308 //pending detect, if remote file has REV field. if not switch to external sync 3312 //pending detect, if remote file has REV field. if not switch to external sync
3309 mGlobalSyncMode = SYNC_MODE_NORMAL; 3313 mGlobalSyncMode = SYNC_MODE_NORMAL;
3310 if ( manager != syncManager ) 3314 if ( manager != syncManager )
3311 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3312 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3313 3317
3314 AddressBook abLocal(filename,"syncContact"); 3318 AddressBook abLocal(filename,"syncContact");
3315 bool syncOK = false; 3319 bool syncOK = false;
3316 if ( abLocal.load() ) { 3320 if ( abLocal.load() ) {
3317 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3318 bool external = false; 3322 bool external = false;
3319 bool isXML = false; 3323 bool isXML = false;
3320 if ( filename.right(4) == ".xml") { 3324 if ( filename.right(4) == ".xml") {
3321 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3322 isXML = true; 3326 isXML = true;
3323 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3324 } else { 3328 } else {
3325 external = !manager->mIsKapiFile; 3329 external = !manager->mIsKapiFile;
3326 if ( external ) { 3330 if ( external ) {
3327 qDebug("KA: Sync::Setting vcf mode to external "); 3331 qDebug("KA: Sync::Setting vcf mode to external ");
3328 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3329 AddressBook::Iterator it; 3333 AddressBook::Iterator it;
3330 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3331 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3335 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3332 (*it).computeCsum( mCurrentSyncDevice ); 3336 (*it).computeCsum( mCurrentSyncDevice );
3333 } 3337 }
3334 } 3338 }
3335 } 3339 }
3336 //AddressBook::Iterator it; 3340 //AddressBook::Iterator it;
3337 //QStringList vcards; 3341 //QStringList vcards;
3338 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3339 // qDebug("Name %s ", (*it).familyName().latin1()); 3343 // qDebug("Name %s ", (*it).familyName().latin1());
3340 //} 3344 //}
3341 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3342 syncManager->hideProgressBar(); 3346 syncManager->hideProgressBar();
3343 if ( syncOK ) { 3347 if ( syncOK ) {
3344 if ( syncManager->mWriteBackFile ) 3348 if ( syncManager->mWriteBackFile )
3345 { 3349 {
3346 if ( external ) 3350 if ( external )
3347 abLocal.removeSyncAddressees( !isXML); 3351 abLocal.removeSyncAddressees( !isXML);
3348 qDebug("KA: Sync::Saving remote AB "); 3352 qDebug("KA: Sync::Saving remote AB ");
3349 if ( ! abLocal.saveAB()) 3353 if ( ! abLocal.saveAB())
3350 qDebug("KA: sync::Error writing back AB to file "); 3354 qDebug("KA: sync::Error writing back AB to file ");
3351 if ( external ) { 3355 if ( external ) {
3352 // afterwrite processing 3356 // afterwrite processing
3353 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3354 } 3358 }
3355 } 3359 }
3356 } 3360 }
3357 setModified(); 3361 setModified();
3358 3362
3359 } 3363 }
3360 abLocal.removeResources(); 3364 abLocal.removeResources();
3361 if ( syncOK ) 3365 if ( syncOK )
3362 mViewManager->refreshView(); 3366 mViewManager->refreshView();
3363 return syncOK; 3367 return syncOK;
3364 3368
3365} 3369}
3366void KABCore::removeSyncInfo( QString syncProfile) 3370void KABCore::removeSyncInfo( QString syncProfile)
3367{ 3371{
3368 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3369 mAddressBook->removeSyncInfo( syncProfile ); 3373 mAddressBook->removeSyncInfo( syncProfile );
3370 setModified(); 3374 setModified();
3371} 3375}
3372 3376
3373 3377
3374//this is a overwritten callbackmethods from the syncinterface 3378//this is a overwritten callbackmethods from the syncinterface
3375bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3379bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3376{ 3380{
3377 if ( resource == "phone" ) 3381 if ( resource == "phone" )
3378 return syncPhone(); 3382 return syncPhone();
3379 disableBR( true ); 3383 disableBR( true );
3380 if ( manager != syncManager ) 3384 if ( manager != syncManager )
3381 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3382 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3383 3387
3384 AddressBook abLocal( resource,"syncContact"); 3388 AddressBook abLocal( resource,"syncContact");
3385 bool syncOK = false; 3389 bool syncOK = false;
3386 message(i18n("Loading DTM address data..."), false); 3390 message(i18n("Loading DTM address data..."), false);
3387 if ( abLocal.load() ) { 3391 if ( abLocal.load() ) {
3388 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3389 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3390 message(i18n("Sync preprocessing..."),false); 3394 message(i18n("Sync preprocessing..."),false);
3391 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3392 message(i18n("Synchronizing..."),false); 3396 message(i18n("Synchronizing..."),false);
3393 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3394 syncManager->hideProgressBar(); 3398 syncManager->hideProgressBar();
3395 if ( syncOK ) { 3399 if ( syncOK ) {
3396 if ( syncManager->mWriteBackFile ) { 3400 if ( syncManager->mWriteBackFile ) {
3397 abLocal.removeSyncAddressees( false ); 3401 abLocal.removeSyncAddressees( false );
3398 message(i18n("Saving DTM address data..."),false); 3402 message(i18n("Saving DTM address data..."),false);
3399 abLocal.saveAB(); 3403 abLocal.saveAB();
3400 message(i18n("Sync postprocessing..."),false); 3404 message(i18n("Sync postprocessing..."),false);
3401 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3402 } 3406 }
3403 } else 3407 } else
3404 message( i18n("Sync cancelled or failed.") ); 3408 message( i18n("Sync cancelled or failed.") );
3405 setModified(); 3409 setModified();
3406 } 3410 }
3407 abLocal.removeResources(); 3411 abLocal.removeResources();
3408 if ( syncOK ) { 3412 if ( syncOK ) {
3409 mViewManager->refreshView(); 3413 mViewManager->refreshView();
3410 message(i18n("DTM syncing finished.")); 3414 message(i18n("DTM syncing finished."));
3411 } 3415 }
3412 disableBR( false ); 3416 disableBR( false );
3413 return syncOK; 3417 return syncOK;
3414 3418
3415} 3419}
3416void KABCore::message( QString m, bool startTimer) 3420void KABCore::message( QString m, bool startTimer)
3417{ 3421{
3418 topLevelWidget()->setCaption( m ); 3422 topLevelWidget()->setCaption( m );
3419 qApp->processEvents(); 3423 qApp->processEvents();
3420 if ( startTimer ) 3424 if ( startTimer )
3421 mMessageTimer->start( 15000, true ); 3425 mMessageTimer->start( 15000, true );
3422 else 3426 else
3423 mMessageTimer->stop(); 3427 mMessageTimer->stop();
3424} 3428}
3425bool KABCore::syncPhone() 3429bool KABCore::syncPhone()
3426{ 3430{
3427 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3428 QString fileName = getPhoneFile(); 3432 QString fileName = getPhoneFile();
3429 if ( !PhoneAccess::readFromPhone( fileName) ) { 3433 if ( !PhoneAccess::readFromPhone( fileName) ) {
3430 message(i18n("Phone access failed!")); 3434 message(i18n("Phone access failed!"));
3431 return false; 3435 return false;
3432 } 3436 }
3433 AddressBook abLocal( fileName,"syncContact"); 3437 AddressBook abLocal( fileName,"syncContact");
3434 bool syncOK = false; 3438 bool syncOK = false;
3435 { 3439 {
3436 abLocal.importFromFile( fileName ); 3440 abLocal.importFromFile( fileName );
3437 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3438 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3439 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3440 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3441 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3442 syncManager->hideProgressBar(); 3446 syncManager->hideProgressBar();
3443 if ( syncOK ) { 3447 if ( syncOK ) {
3444 if ( syncManager->mWriteBackFile ) { 3448 if ( syncManager->mWriteBackFile ) {
3445 abLocal.removeSyncAddressees( true ); 3449 abLocal.removeSyncAddressees( true );
3446 abLocal.saveABphone( fileName ); 3450 abLocal.saveABphone( fileName );
3447 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3448 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3449 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3450 } 3454 }
3451 } 3455 }
3452 setModified(); 3456 setModified();
3453 } 3457 }
3454 abLocal.removeResources(); 3458 abLocal.removeResources();
3455 if ( syncOK ) 3459 if ( syncOK )
3456 mViewManager->refreshView(); 3460 mViewManager->refreshView();
3457 return syncOK; 3461 return syncOK;
3458} 3462}
3459void KABCore::getFile( bool success ) 3463void KABCore::getFile( bool success )
3460{ 3464{
3461 if ( ! success ) { 3465 if ( ! success ) {
3462 message( i18n("Error receiving file. Nothing changed!") ); 3466 message( i18n("Error receiving file. Nothing changed!") );
3463 return; 3467 return;
3464 } 3468 }
3465 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3466 if ( count ) 3470 if ( count )
3467 setModified( true ); 3471 setModified( true );
3468 message( i18n("Pi-Sync successful!") ); 3472 message( i18n("Pi-Sync successful!") );
3469 mViewManager->refreshView(); 3473 mViewManager->refreshView();
3470} 3474}
3471void KABCore::syncFileRequest() 3475void KABCore::syncFileRequest()
3472{ 3476{
3473 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3474 syncManager->slotSyncMenu( 999 ); 3478 syncManager->slotSyncMenu( 999 );
3475 } 3479 }
3476 mAddressBook->export2File( sentSyncFile() ); 3480 mAddressBook->export2File( sentSyncFile() );
3477} 3481}
3478QString KABCore::sentSyncFile() 3482QString KABCore::sentSyncFile()
3479{ 3483{
3480#ifdef DESKTOP_VERSION 3484#ifdef DESKTOP_VERSION
3481 return locateLocal( "tmp", "copysyncab.vcf" ); 3485 return locateLocal( "tmp", "copysyncab.vcf" );
3482#else 3486#else
3483 return QString( "/tmp/copysyncab.vcf" ); 3487 return QString( "/tmp/copysyncab.vcf" );
3484#endif 3488#endif
3485} 3489}
3486 3490
3487void KABCore::setCaptionBack() 3491void KABCore::setCaptionBack()
3488{ 3492{
3489 mMessageTimer->stop(); 3493 mMessageTimer->stop();
3490 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3494 topLevelWidget()->setCaption( i18n("KA/Pi") );
3491} 3495}
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f36c5ae..d7c12bb 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,249 +1,251 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <qtextbrowser.h>
13#include <qregexp.h> 13#include <qregexp.h>
14 14
15int KApplication::random() 15int KApplication::random()
16{ 16{
17 return rand(); 17 return rand();
18} 18}
19 19
20//US 20//US
21QString KApplication::randomString(int length) 21QString KApplication::randomString(int length)
22{ 22{
23 if (length <=0 ) return QString::null; 23 if (length <=0 ) return QString::null;
24 24
25 QString str; 25 QString str;
26 while (length--) 26 while (length--)
27 { 27 {
28 int r=random() % 62; 28 int r=random() % 62;
29 r+=48; 29 r+=48;
30 if (r>57) r+=7; 30 if (r>57) r+=7;
31 if (r>90) r+=6; 31 if (r>90) r+=6;
32 str += char(r); 32 str += char(r);
33 // so what if I work backwards? 33 // so what if I work backwards?
34 } 34 }
35 return str; 35 return str;
36} 36}
37int KApplication::execDialog( QDialog* d ) 37int KApplication::execDialog( QDialog* d )
38{ 38{
39 if (QApplication::desktop()->width() <= 640 ) 39 if (QApplication::desktop()->width() <= 640 )
40 d->showMaximized(); 40 d->showMaximized();
41 else 41 else
42 ;//d->resize( 800, 600 ); 42 ;//d->resize( 800, 600 );
43 return d->exec(); 43 return d->exec();
44} 44}
45void KApplication::showLicence() 45void KApplication::showLicence()
46{ 46{
47 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 47 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
48} 48}
49 49
50void KApplication::testCoords( int* x, int* y, int* wid, int * hei ) 50void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
51{ 51{
52 int dWid = QApplication::desktop()->width() ; 52 int dWid = QApplication::desktop()->width() ;
53 int dHei = QApplication::desktop()->height(); 53 int dHei = QApplication::desktop()->height();
54 if ( *x < 0 ) *x = 0;
55 if ( *y < 20 ) *y = 20 ;
54 if ( *x + *wid > dWid ) { 56 if ( *x + *wid > dWid ) {
55 *x = 0; 57 *x = 0;
56 if ( *wid > dWid ) 58 if ( *wid > dWid )
57 *wid = dWid; 59 *wid = dWid;
58 } 60 }
59 if ( *y + *hei > dHei ) { 61 if ( *y + *hei > dHei ) {
60 *y = 0; 62 *y = 20;
61 if ( *hei > dHei ) 63 if ( *hei > dHei )
62 *hei = dHei; 64 *hei = dHei;
63 } 65 }
64} 66}
65void KApplication::showFile(QString caption, QString fn) 67void KApplication::showFile(QString caption, QString fn)
66{ 68{
67 QString text; 69 QString text;
68 QString fileName; 70 QString fileName;
69#ifndef DESKTOP_VERSION 71#ifndef DESKTOP_VERSION
70 fileName = getenv("QPEDIR"); 72 fileName = getenv("QPEDIR");
71 fileName += "/pics/" + fn ; 73 fileName += "/pics/" + fn ;
72#else 74#else
73 fileName = qApp->applicationDirPath () + "/" + fn; 75 fileName = qApp->applicationDirPath () + "/" + fn;
74#endif 76#endif
75 QFile file( fileName ); 77 QFile file( fileName );
76 if (!file.open( IO_ReadOnly ) ) { 78 if (!file.open( IO_ReadOnly ) ) {
77 return ; 79 return ;
78 } 80 }
79 QTextStream ts( &file ); 81 QTextStream ts( &file );
80 text = ts.read(); 82 text = ts.read();
81 file.close(); 83 file.close();
82 KApplication::showText( caption, text ); 84 KApplication::showText( caption, text );
83 85
84} 86}
85 87
86bool KApplication::convert2latin1(QString fileName) 88bool KApplication::convert2latin1(QString fileName)
87{ 89{
88 QString text; 90 QString text;
89 QFile file( fileName ); 91 QFile file( fileName );
90 if (!file.open( IO_ReadOnly ) ) { 92 if (!file.open( IO_ReadOnly ) ) {
91 return false; 93 return false;
92 94
93 } 95 }
94 QTextStream ts( &file ); 96 QTextStream ts( &file );
95 ts.setEncoding( QTextStream::UnicodeUTF8 ); 97 ts.setEncoding( QTextStream::UnicodeUTF8 );
96 text = ts.read(); 98 text = ts.read();
97 file.close(); 99 file.close();
98 if (!file.open( IO_WriteOnly ) ) { 100 if (!file.open( IO_WriteOnly ) ) {
99 return false; 101 return false;
100 } 102 }
101 QTextStream tsIn( &file ); 103 QTextStream tsIn( &file );
102 tsIn.setEncoding( QTextStream::Latin1 ); 104 tsIn.setEncoding( QTextStream::Latin1 );
103 tsIn << text.latin1(); 105 tsIn << text.latin1();
104 file.close(); 106 file.close();
105 return true; 107 return true;
106 108
107 109
108} 110}
109void KApplication::showText(QString caption, QString text) 111void KApplication::showText(QString caption, QString text)
110{ 112{
111 QDialog dia( 0, "name", true ); ; 113 QDialog dia( 0, "name", true ); ;
112 dia.setCaption( caption ); 114 dia.setCaption( caption );
113 QVBoxLayout* lay = new QVBoxLayout( &dia ); 115 QVBoxLayout* lay = new QVBoxLayout( &dia );
114 lay->setSpacing( 3 ); 116 lay->setSpacing( 3 );
115 lay->setMargin( 3 ); 117 lay->setMargin( 3 );
116 KTextEdit tb ( &dia ); 118 KTextEdit tb ( &dia );
117 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 119 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
118 lay->addWidget( &tb ); 120 lay->addWidget( &tb );
119 tb.setText( text ); 121 tb.setText( text );
120#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
121 dia.resize( 640, 480); 123 dia.resize( 640, 480);
122#else 124#else
123 dia.showMaximized(); 125 dia.showMaximized();
124#endif 126#endif
125 dia.exec(); 127 dia.exec();
126 128
127} 129}
128 130
129#include <qlabel.h> 131#include <qlabel.h>
130#include <qpushbutton.h> 132#include <qpushbutton.h>
131#include <qlayout.h> 133#include <qlayout.h>
132#include <qdir.h> 134#include <qdir.h>
133#include <qradiobutton.h> 135#include <qradiobutton.h>
134#include <qbuttongroup.h> 136#include <qbuttongroup.h>
135#include "kglobal.h" 137#include "kglobal.h"
136#include "klocale.h" 138#include "klocale.h"
137 139
138class KBackupPrefs : public QDialog 140class KBackupPrefs : public QDialog
139{ 141{
140 public: 142 public:
141 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : 143 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) :
142 QDialog( parent, name, true ) 144 QDialog( parent, name, true )
143 { 145 {
144 setCaption( i18n("Backup Failed!") ); 146 setCaption( i18n("Backup Failed!") );
145 QVBoxLayout* lay = new QVBoxLayout( this ); 147 QVBoxLayout* lay = new QVBoxLayout( this );
146 lay->setSpacing( 3 ); 148 lay->setSpacing( 3 );
147 lay->setMargin( 3 ); 149 lay->setMargin( 3 );
148 QLabel * lab = new QLabel( message, this ); 150 QLabel * lab = new QLabel( message, this );
149 lay->addWidget( lab ); 151 lay->addWidget( lab );
150 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this );
151 lay->addWidget( format ); 153 lay->addWidget( format );
152 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
153 vcal = new QRadioButton(i18n("Try again now"), format ); 155 vcal = new QRadioButton(i18n("Try again now"), format );
154 tcal = new QRadioButton(i18n("Try again later"), format ); 156 tcal = new QRadioButton(i18n("Try again later"), format );
155 ical = new QRadioButton(i18n("Try again tomorrow"), format ); 157 ical = new QRadioButton(i18n("Try again tomorrow"), format );
156 ocal = new QRadioButton(i18n("Disable backup"), format ); 158 ocal = new QRadioButton(i18n("Disable backup"), format );
157 vcal->setChecked( true ); 159 vcal->setChecked( true );
158 QPushButton * ok = new QPushButton( i18n("OK"), this ); 160 QPushButton * ok = new QPushButton( i18n("OK"), this );
159 lay->addWidget(ok ); 161 lay->addWidget(ok );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 162 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 } 163 }
162 164
163 bool again() { return vcal->isChecked(); } 165 bool again() { return vcal->isChecked(); }
164 bool later() { return tcal->isChecked(); } 166 bool later() { return tcal->isChecked(); }
165 bool againTomorrow() { return ical->isChecked(); } 167 bool againTomorrow() { return ical->isChecked(); }
166private: 168private:
167 QRadioButton* vcal, *ical, *ocal, *tcal; 169 QRadioButton* vcal, *ical, *ocal, *tcal;
168}; 170};
169int KApplication::createBackup( QString fn, QString dp, int numBup ) 171int KApplication::createBackup( QString fn, QString dp, int numBup )
170{ 172{
171 if ( numBup < 1) return 3; 173 if ( numBup < 1) return 3;
172 int ret = 3; 174 int ret = 3;
173 //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup); 175 //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup);
174 QDir bupDir ( dp ); 176 QDir bupDir ( dp );
175 bool tryAgain = true; 177 bool tryAgain = true;
176 while ( tryAgain ) { 178 while ( tryAgain ) {
177 if ( !bupDir.exists() ) { 179 if ( !bupDir.exists() ) {
178 QString bd = dp.right(25); 180 QString bd = dp.right(25);
179 if ( dp.length() > 25 ) 181 if ( dp.length() > 25 )
180 bd = "..." + bd; 182 bd = "..." + bd;
181 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + bd); 183 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + bd);
182 if ( !noDir.exec() ) return 3; 184 if ( !noDir.exec() ) return 3;
183 if ( noDir.againTomorrow() ) { 185 if ( noDir.againTomorrow() ) {
184 return 0; 186 return 0;
185 } else if ( noDir.later() ) { 187 } else if ( noDir.later() ) {
186 return 3; 188 return 3;
187 } else if ( !noDir.again() ) { 189 } else if ( !noDir.again() ) {
188 return 2; 190 return 2;
189 } 191 }
190 } else { 192 } else {
191 tryAgain = false; 193 tryAgain = false;
192 } 194 }
193 } 195 }
194 // we have a valid dir! 196 // we have a valid dir!
195 QStringList allFileList = bupDir.entryList(QDir::Files); 197 QStringList allFileList = bupDir.entryList(QDir::Files);
196 QFileInfo fileInfo ( fn ); 198 QFileInfo fileInfo ( fn );
197 QString fName = fileInfo.fileName (); 199 QString fName = fileInfo.fileName ();
198 QStringList fileList; 200 QStringList fileList;
199 201
200 int i; 202 int i;
201 for ( i = 0; i < allFileList.count(); ++i ) { 203 for ( i = 0; i < allFileList.count(); ++i ) {
202 QString fi = allFileList[i]; 204 QString fi = allFileList[i];
203 if ( fi. find( fName ) > -1 ) 205 if ( fi. find( fName ) > -1 )
204 fileList.append( fi ); 206 fileList.append( fi );
205 } 207 }
206 qDebug("KApp: %d backup files exist ", fileList.count()); 208 qDebug("KApp: %d backup files exist ", fileList.count());
207 int count = fileList.count(); 209 int count = fileList.count();
208 fileList.sort(); 210 fileList.sort();
209 int remCount = 0; 211 int remCount = 0;
210 while ( count >= numBup ) { 212 while ( count >= numBup ) {
211 QString fnr = dp + "/"+fileList[remCount]; 213 QString fnr = dp + "/"+fileList[remCount];
212 QFile::remove( fnr ); 214 QFile::remove( fnr );
213 --count; 215 --count;
214 ++remCount; 216 ++remCount;
215 } 217 }
216 QDateTime mRunStart = QDateTime::currentDateTime(); 218 QDateTime mRunStart = QDateTime::currentDateTime();
217 QString file = "%1%2%3-%4%5%6-"; 219 QString file = "%1%2%3-%4%5%6-";
218 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 220 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
219 file.replace ( QRegExp (" "), "0" ); 221 file.replace ( QRegExp (" "), "0" );
220 file += fName ; 222 file += fName ;
221 file = dp + file; 223 file = dp + file;
222 QString command; 224 QString command;
223 int res = 0; 225 int res = 0;
224#ifdef _WIN32_ 226#ifdef _WIN32_
225 command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" "; 227 command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" ";
226#else 228#else
227 command = "cp "+ fn+ " "+file; 229 command = "cp "+ fn+ " "+file;
228#endif 230#endif
229 //qDebug("command %s ",command.latin1() ); 231 //qDebug("command %s ",command.latin1() );
230 tryAgain = true; 232 tryAgain = true;
231 while ( tryAgain ) { 233 while ( tryAgain ) {
232 res = system ( command.latin1() ); 234 res = system ( command.latin1() );
233 qDebug("KApp: Copy result %d ", res); 235 qDebug("KApp: Copy result %d ", res);
234 if ( res != 0 ) { 236 if ( res != 0 ) {
235 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>")); 237 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>"));
236 if ( !noDir.exec() ) return 3; 238 if ( !noDir.exec() ) return 3;
237 if ( noDir.againTomorrow() ) { 239 if ( noDir.againTomorrow() ) {
238 return 0; 240 return 0;
239 } else if ( noDir.later() ) { 241 } else if ( noDir.later() ) {
240 return 3; 242 return 3;
241 } else if ( !noDir.again() ) { 243 } else if ( !noDir.again() ) {
242 return 2; 244 return 2;
243 } 245 }
244 } else { 246 } else {
245 tryAgain = false; 247 tryAgain = false;
246 } 248 }
247 } 249 }
248 return 1; 250 return 1;
249} 251}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index df2aad8..027e5e9 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -1,2268 +1,2278 @@
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 sizeHintW = 240;
259 sizeHintH = 22;
258 inshutdownprocess = false; 260 inshutdownprocess = false;
259 d = new KToolBarPrivate; 261 d = new KToolBarPrivate;
260 setFullSize( TRUE ); 262 setFullSize( TRUE );
261 d->m_honorStyle = honorStyle; 263 d->m_honorStyle = honorStyle;
262 context = 0; 264 context = 0;
263 layoutTimer = new QTimer( this ); 265 layoutTimer = new QTimer( this );
264 connect( layoutTimer, SIGNAL( timeout() ), 266 connect( layoutTimer, SIGNAL( timeout() ),
265 this, SLOT( rebuildLayout() ) ); 267 this, SLOT( rebuildLayout() ) );
266 connect( &(d->repaintTimer), SIGNAL( timeout() ), 268 connect( &(d->repaintTimer), SIGNAL( timeout() ),
267 this, SLOT( slotRepaint() ) ); 269 this, SLOT( slotRepaint() ) );
268/*US 270/*US
269 if ( kapp ) { // may be null when started inside designer 271 if ( kapp ) { // may be null when started inside designer
270 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); 272 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged()));
271 // request notification of changes in icon style 273 // request notification of changes in icon style
272 kapp->addKipcEventMask(KIPC::IconChanged); 274 kapp->addKipcEventMask(KIPC::IconChanged);
273 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); 275 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int)));
274 } 276 }
275*/ 277*/
276 // finally, read in our configurable settings 278 // finally, read in our configurable settings
277 if ( readConfig ) 279 if ( readConfig )
278 slotReadConfig(); 280 slotReadConfig();
279 281
280 if ( mainWindow() ) 282 if ( mainWindow() )
281 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), 283 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ),
282 this, SLOT( toolBarPosChanged( QToolBar * ) ) ); 284 this, SLOT( toolBarPosChanged( QToolBar * ) ) );
283 285
284 // Hack to make sure we recalculate our size when we dock. 286 // Hack to make sure we recalculate our size when we dock.
285//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); 287//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) );
286} 288}
287 289
288int KToolBar::insertButton(const QString& icon, int id, bool enabled, 290int KToolBar::insertButton(const QString& icon, int id, bool enabled,
289 const QString& text, int index/*US, KInstance *_instance*/ ) 291 const QString& text, int index/*US, KInstance *_instance*/ )
290{ 292{
291 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); 293 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ );
292 294
293 insertWidgetInternal( button, index, id ); 295 insertWidgetInternal( button, index, id );
294 button->setEnabled( enabled ); 296 button->setEnabled( enabled );
295 doConnections( button ); 297 doConnections( button );
296 return index; 298 return index;
297} 299}
298 300
299 301
300int KToolBar::insertButton(const QString& icon, int id, const char *signal, 302int KToolBar::insertButton(const QString& icon, int id, const char *signal,
301 const QObject *receiver, const char *slot, 303 const QObject *receiver, const char *slot,
302 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) 304 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ )
303{ 305{
304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); 306 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/);
305 insertWidgetInternal( button, index, id ); 307 insertWidgetInternal( button, index, id );
306 button->setEnabled( enabled ); 308 button->setEnabled( enabled );
307 connect( button, signal, receiver, slot ); 309 connect( button, signal, receiver, slot );
308 doConnections( button ); 310 doConnections( button );
309 return index; 311 return index;
310} 312}
311 313
312 314
313int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, 315int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled,
314 const QString& text, int index ) 316 const QString& text, int index )
315{ 317{
316 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 318 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
317 insertWidgetInternal( button, index, id ); 319 insertWidgetInternal( button, index, id );
318 button->setEnabled( enabled ); 320 button->setEnabled( enabled );
319 doConnections( button ); 321 doConnections( button );
320 return index; 322 return index;
321} 323}
322#if 0 324#if 0
323 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 325 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
324 SLOT( slotActivated() ), 326 SLOT( slotActivated() ),
325 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 327 d->isEnabled(), d->plainText(), index/*US, instance*/ );
326#endif 328#endif
327 329
328int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, 330int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal,
329 const QObject *receiver, const char *slot, 331 const QObject *receiver, const char *slot,
330 bool enabled, const QString& text, 332 bool enabled, const QString& text,
331 int index ) 333 int index )
332{ 334{
333 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 335 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
334 insertWidgetInternal( button, index, id ); 336 insertWidgetInternal( button, index, id );
335 button->setEnabled( enabled ); 337 button->setEnabled( enabled );
336 connect( button, signal, receiver, slot ); 338 connect( button, signal, receiver, slot );
337 doConnections( button ); 339 doConnections( button );
338 return index; 340 return index;
339} 341}
340 342
341 343
342int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, 344int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup,
343 bool enabled, const QString &text, int index ) 345 bool enabled, const QString &text, int index )
344{ 346{
345 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); 347 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text );
346 insertWidgetInternal( button, index, id ); 348 insertWidgetInternal( button, index, id );
347 button->setEnabled( enabled ); 349 button->setEnabled( enabled );
348 button->setPopup( popup ); 350 button->setPopup( popup );
349 doConnections( button ); 351 doConnections( button );
350 return index; 352 return index;
351} 353}
352 354
353 355
354int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 356int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
355 bool enabled, const QString &text, int index ) 357 bool enabled, const QString &text, int index )
356{ 358{
357 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); 359 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text );
358 insertWidgetInternal( button, index, id ); 360 insertWidgetInternal( button, index, id );
359 button->setEnabled( enabled ); 361 button->setEnabled( enabled );
360 button->setPopup( popup ); 362 button->setPopup( popup );
361 doConnections( button ); 363 doConnections( button );
362 return index; 364 return index;
363} 365}
364 366
365 367
366int KToolBar::insertLined (const QString& text, int id, 368int KToolBar::insertLined (const QString& text, int id,
367 const char *signal, 369 const char *signal,
368 const QObject *receiver, const char *slot, 370 const QObject *receiver, const char *slot,
369 bool enabled , 371 bool enabled ,
370 const QString& toolTipText, 372 const QString& toolTipText,
371 int size, int index ) 373 int size, int index )
372{ 374{
373 KLineEdit *lined = new KLineEdit ( this, 0 ); 375 KLineEdit *lined = new KLineEdit ( this, 0 );
374 if ( !toolTipText.isEmpty() ) 376 if ( !toolTipText.isEmpty() )
375 QToolTip::add( lined, toolTipText ); 377 QToolTip::add( lined, toolTipText );
376 if ( size > 0 ) 378 if ( size > 0 )
377 lined->setMinimumWidth( size ); 379 lined->setMinimumWidth( size );
378 insertWidgetInternal( lined, index, id ); 380 insertWidgetInternal( lined, index, id );
379 connect( lined, signal, receiver, slot ); 381 connect( lined, signal, receiver, slot );
380 lined->setText(text); 382 lined->setText(text);
381 lined->setEnabled( enabled ); 383 lined->setEnabled( enabled );
382 return index; 384 return index;
383} 385}
384 386
385int KToolBar::insertCombo (const QStringList &list, int id, bool writable, 387int KToolBar::insertCombo (const QStringList &list, int id, bool writable,
386 const char *signal, const QObject *receiver, 388 const char *signal, const QObject *receiver,
387 const char *slot, bool enabled, 389 const char *slot, bool enabled,
388 const QString& tooltiptext, 390 const QString& tooltiptext,
389 int size, int index, 391 int size, int index,
390 QComboBox::Policy policy ) 392 QComboBox::Policy policy )
391{ 393{
392//US KComboBox *combo = new KComboBox ( writable, this ); 394//US KComboBox *combo = new KComboBox ( writable, this );
393 KComboBox *combo = new KComboBox ( this ); 395 KComboBox *combo = new KComboBox ( this );
394 combo->setEditable(writable); 396 combo->setEditable(writable);
395 397
396 insertWidgetInternal( combo, index, id ); 398 insertWidgetInternal( combo, index, id );
397 combo->insertStringList (list); 399 combo->insertStringList (list);
398 combo->setInsertionPolicy(policy); 400 combo->setInsertionPolicy(policy);
399 combo->setEnabled( enabled ); 401 combo->setEnabled( enabled );
400 if ( !tooltiptext.isEmpty() ) 402 if ( !tooltiptext.isEmpty() )
401 QToolTip::add( combo, tooltiptext ); 403 QToolTip::add( combo, tooltiptext );
402 if ( size > 0 ) 404 if ( size > 0 )
403 combo->setMinimumWidth( size ); 405 combo->setMinimumWidth( size );
404 if (!tooltiptext.isNull()) 406 if (!tooltiptext.isNull())
405 QToolTip::add( combo, tooltiptext ); 407 QToolTip::add( combo, tooltiptext );
406 408
407 if ( signal && receiver && slot ) 409 if ( signal && receiver && slot )
408 connect ( combo, signal, receiver, slot ); 410 connect ( combo, signal, receiver, slot );
409 return index; 411 return index;
410} 412}
411 413
412 414
413int KToolBar::insertCombo (const QString& text, int id, bool writable, 415int KToolBar::insertCombo (const QString& text, int id, bool writable,
414 const char *signal, QObject *receiver, 416 const char *signal, QObject *receiver,
415 const char *slot, bool enabled, 417 const char *slot, bool enabled,
416 const QString& tooltiptext, 418 const QString& tooltiptext,
417 int size, int index, 419 int size, int index,
418 QComboBox::Policy policy ) 420 QComboBox::Policy policy )
419{ 421{
420//US KComboBox *combo = new KComboBox ( writable, this ); 422//US KComboBox *combo = new KComboBox ( writable, this );
421 KComboBox *combo = new KComboBox ( this ); 423 KComboBox *combo = new KComboBox ( this );
422 combo->setEditable(writable); 424 combo->setEditable(writable);
423 425
424 insertWidgetInternal( combo, index, id ); 426 insertWidgetInternal( combo, index, id );
425 combo->insertItem (text); 427 combo->insertItem (text);
426 combo->setInsertionPolicy(policy); 428 combo->setInsertionPolicy(policy);
427 combo->setEnabled( enabled ); 429 combo->setEnabled( enabled );
428 if ( !tooltiptext.isEmpty() ) 430 if ( !tooltiptext.isEmpty() )
429 QToolTip::add( combo, tooltiptext ); 431 QToolTip::add( combo, tooltiptext );
430 if ( size > 0 ) 432 if ( size > 0 )
431 combo->setMinimumWidth( size ); 433 combo->setMinimumWidth( size );
432 if (!tooltiptext.isNull()) 434 if (!tooltiptext.isNull())
433 QToolTip::add( combo, tooltiptext ); 435 QToolTip::add( combo, tooltiptext );
434 connect (combo, signal, receiver, slot); 436 connect (combo, signal, receiver, slot);
435 return index; 437 return index;
436} 438}
437 439
438int KToolBar::insertSeparator(int index, int id) 440int KToolBar::insertSeparator(int index, int id)
439{ 441{
440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); 442 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" );
441 insertWidgetInternal( w, index, id ); 443 insertWidgetInternal( w, index, id );
442 return index; 444 return index;
443} 445}
444 446
445int KToolBar::insertLineSeparator(int index, int id) 447int KToolBar::insertLineSeparator(int index, int id)
446{ 448{
447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); 449 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" );
448 insertWidgetInternal( w, index, id ); 450 insertWidgetInternal( w, index, id );
449 return index; 451 return index;
450} 452}
451 453
452 454
453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) 455int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index)
454{ 456{
455 // removeWidgetInternal( widget ); // in case we already have it ? 457 // removeWidgetInternal( widget ); // in case we already have it ?
456 insertWidgetInternal( widget, index, id ); 458 insertWidgetInternal( widget, index, id );
457 return index; 459 return index;
458} 460}
459/*US 461/*US
460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, 462int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot,
461 const QString& icons, int index ) 463 const QString& icons, int index )
462{ 464{
463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); 465 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
464 insertWidgetInternal( anim, index, id ); 466 insertWidgetInternal( anim, index, id );
465 467
466 if ( receiver ) 468 if ( receiver )
467 connect( anim, SIGNAL(clicked()), receiver, slot); 469 connect( anim, SIGNAL(clicked()), receiver, slot);
468 470
469 return index; 471 return index;
470} 472}
471 473
472KAnimWidget *KToolBar::animatedWidget( int id ) 474KAnimWidget *KToolBar::animatedWidget( int id )
473{ 475{
474 Id2WidgetMap::Iterator it = id2widget.find( id ); 476 Id2WidgetMap::Iterator it = id2widget.find( id );
475 if ( it == id2widget.end() ) 477 if ( it == id2widget.end() )
476 return 0; 478 return 0;
477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) 479 if ( (*it) && (*it)->inherits( "KAnimWidget" ) )
478 return (KAnimWidget*)(*it); 480 return (KAnimWidget*)(*it);
479 QObjectList *l = queryList( "KAnimWidget" ); 481 QObjectList *l = queryList( "KAnimWidget" );
480 if ( !l || !l->first() ) { 482 if ( !l || !l->first() ) {
481 delete l; 483 delete l;
482 return 0; 484 return 0;
483 } 485 }
484 486
485 for ( QObject *o = l->first(); o; o = l->next() ) { 487 for ( QObject *o = l->first(); o; o = l->next() ) {
486 if ( o->inherits( "KAnimWidget" ) ) 488 if ( o->inherits( "KAnimWidget" ) )
487 { 489 {
488 delete l; 490 delete l;
489 return (KAnimWidget*)o; 491 return (KAnimWidget*)o;
490 } 492 }
491 } 493 }
492 494
493 delete l; 495 delete l;
494 return 0; 496 return 0;
495} 497}
496*/ 498*/
497 499
498void KToolBar::addConnection (int id, const char *signal, 500void KToolBar::addConnection (int id, const char *signal,
499 const QObject *receiver, const char *slot) 501 const QObject *receiver, const char *slot)
500{ 502{
501 Id2WidgetMap::Iterator it = id2widget.find( id ); 503 Id2WidgetMap::Iterator it = id2widget.find( id );
502 if ( it == id2widget.end() ) 504 if ( it == id2widget.end() )
503 return; 505 return;
504 if ( (*it) ) 506 if ( (*it) )
505 connect( (*it), signal, receiver, slot ); 507 connect( (*it), signal, receiver, slot );
506} 508}
507 509
508void KToolBar::setItemEnabled( int id, bool enabled ) 510void KToolBar::setItemEnabled( int id, bool enabled )
509{ 511{
510 Id2WidgetMap::Iterator it = id2widget.find( id ); 512 Id2WidgetMap::Iterator it = id2widget.find( id );
511 if ( it == id2widget.end() ) 513 if ( it == id2widget.end() )
512 return; 514 return;
513 if ( (*it) ) 515 if ( (*it) )
514 (*it)->setEnabled( enabled ); 516 (*it)->setEnabled( enabled );
515} 517}
516 518
517 519
518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) 520void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
519{ 521{
520 Id2WidgetMap::Iterator it = id2widget.find( id ); 522 Id2WidgetMap::Iterator it = id2widget.find( id );
521 if ( it == id2widget.end() ) 523 if ( it == id2widget.end() )
522 return; 524 return;
523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 525//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
524 KToolBarButton * button = (KToolBarButton *)( *it ); 526 KToolBarButton * button = (KToolBarButton *)( *it );
525 if ( button ) 527 if ( button )
526 button->setPixmap( _pixmap ); 528 button->setPixmap( _pixmap );
527} 529}
528 530
529 531
530void KToolBar::setButtonIcon( int id, const QString& _icon ) 532void KToolBar::setButtonIcon( int id, const QString& _icon )
531{ 533{
532 Id2WidgetMap::Iterator it = id2widget.find( id ); 534 Id2WidgetMap::Iterator it = id2widget.find( id );
533 if ( it == id2widget.end() ) 535 if ( it == id2widget.end() )
534 return; 536 return;
535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 537//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
536 KToolBarButton * button = (KToolBarButton *)( *it ); 538 KToolBarButton * button = (KToolBarButton *)( *it );
537 if ( button ) 539 if ( button )
538 button->setIcon( _icon ); 540 button->setIcon( _icon );
539} 541}
540 542
541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) 543void KToolBar::setButtonIconSet( int id, const QIconSet& iconset )
542{ 544{
543 Id2WidgetMap::Iterator it = id2widget.find( id ); 545 Id2WidgetMap::Iterator it = id2widget.find( id );
544 if ( it == id2widget.end() ) 546 if ( it == id2widget.end() )
545 return; 547 return;
546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 548//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
547 KToolBarButton * button = (KToolBarButton *)( *it ); 549 KToolBarButton * button = (KToolBarButton *)( *it );
548 if ( button ) 550 if ( button )
549 button->setIconSet( iconset ); 551 button->setIconSet( iconset );
550} 552}
551 553
552 554
553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) 555void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle )
554{ 556{
555 Id2WidgetMap::Iterator it = id2widget.find( id ); 557 Id2WidgetMap::Iterator it = id2widget.find( id );
556 if ( it == id2widget.end() ) 558 if ( it == id2widget.end() )
557 return; 559 return;
558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 560//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
559 KToolBarButton * button = (KToolBarButton *)( *it ); 561 KToolBarButton * button = (KToolBarButton *)( *it );
560 if ( button ) 562 if ( button )
561 button->setDelayedPopup( _popup, toggle ); 563 button->setDelayedPopup( _popup, toggle );
562} 564}
563 565
564 566
565void KToolBar::setAutoRepeat (int id, bool flag) 567void KToolBar::setAutoRepeat (int id, bool flag)
566{ 568{
567 Id2WidgetMap::Iterator it = id2widget.find( id ); 569 Id2WidgetMap::Iterator it = id2widget.find( id );
568 if ( it == id2widget.end() ) 570 if ( it == id2widget.end() )
569 return; 571 return;
570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 572//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
571 KToolBarButton * button = (KToolBarButton *)( *it ); 573 KToolBarButton * button = (KToolBarButton *)( *it );
572 if ( button ) 574 if ( button )
573 button->setAutoRepeat( flag ); 575 button->setAutoRepeat( flag );
574} 576}
575 577
576 578
577void KToolBar::setToggle (int id, bool flag ) 579void KToolBar::setToggle (int id, bool flag )
578{ 580{
579 Id2WidgetMap::Iterator it = id2widget.find( id ); 581 Id2WidgetMap::Iterator it = id2widget.find( id );
580 if ( it == id2widget.end() ) 582 if ( it == id2widget.end() )
581 return; 583 return;
582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 584//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
583 KToolBarButton * button = (KToolBarButton *)( *it ); 585 KToolBarButton * button = (KToolBarButton *)( *it );
584 if ( button ) 586 if ( button )
585 button->setToggle( flag ); 587 button->setToggle( flag );
586} 588}
587 589
588 590
589void KToolBar::toggleButton (int id) 591void KToolBar::toggleButton (int id)
590{ 592{
591 Id2WidgetMap::Iterator it = id2widget.find( id ); 593 Id2WidgetMap::Iterator it = id2widget.find( id );
592 if ( it == id2widget.end() ) 594 if ( it == id2widget.end() )
593 return; 595 return;
594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 596//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
595 KToolBarButton * button = (KToolBarButton *)( *it ); 597 KToolBarButton * button = (KToolBarButton *)( *it );
596 if ( button ) 598 if ( button )
597 button->toggle(); 599 button->toggle();
598} 600}
599 601
600 602
601void KToolBar::setButton (int id, bool flag) 603void KToolBar::setButton (int id, bool flag)
602{ 604{
603 Id2WidgetMap::Iterator it = id2widget.find( id ); 605 Id2WidgetMap::Iterator it = id2widget.find( id );
604 if ( it == id2widget.end() ) 606 if ( it == id2widget.end() )
605 return; 607 return;
606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 608//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
607 KToolBarButton * button = (KToolBarButton *)( *it ); 609 KToolBarButton * button = (KToolBarButton *)( *it );
608 if ( button ) 610 if ( button )
609 button->on( flag ); 611 button->on( flag );
610} 612}
611 613
612 614
613bool KToolBar::isButtonOn (int id) const 615bool KToolBar::isButtonOn (int id) const
614{ 616{
615 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 617 Id2WidgetMap::ConstIterator it = id2widget.find( id );
616 if ( it == id2widget.end() ) 618 if ( it == id2widget.end() )
617 return false; 619 return false;
618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 620//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
619 KToolBarButton * button = (KToolBarButton *)( *it ); 621 KToolBarButton * button = (KToolBarButton *)( *it );
620 return button ? button->isOn() : false; 622 return button ? button->isOn() : false;
621} 623}
622 624
623 625
624void KToolBar::setLinedText (int id, const QString& text) 626void KToolBar::setLinedText (int id, const QString& text)
625{ 627{
626 Id2WidgetMap::Iterator it = id2widget.find( id ); 628 Id2WidgetMap::Iterator it = id2widget.find( id );
627 if ( it == id2widget.end() ) 629 if ( it == id2widget.end() )
628 return; 630 return;
629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 631//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
630 QLineEdit * lineEdit = (QLineEdit *)( *it ); 632 QLineEdit * lineEdit = (QLineEdit *)( *it );
631 if ( lineEdit ) 633 if ( lineEdit )
632 lineEdit->setText( text ); 634 lineEdit->setText( text );
633} 635}
634 636
635 637
636QString KToolBar::getLinedText (int id) const 638QString KToolBar::getLinedText (int id) const
637{ 639{
638 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 640 Id2WidgetMap::ConstIterator it = id2widget.find( id );
639 if ( it == id2widget.end() ) 641 if ( it == id2widget.end() )
640 return QString::null; 642 return QString::null;
641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 643//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
642 QLineEdit * lineEdit = (QLineEdit *)( *it ); 644 QLineEdit * lineEdit = (QLineEdit *)( *it );
643 return lineEdit ? lineEdit->text() : QString::null; 645 return lineEdit ? lineEdit->text() : QString::null;
644} 646}
645 647
646 648
647void KToolBar::insertComboItem (int id, const QString& text, int index) 649void KToolBar::insertComboItem (int id, const QString& text, int index)
648{ 650{
649 Id2WidgetMap::Iterator it = id2widget.find( id ); 651 Id2WidgetMap::Iterator it = id2widget.find( id );
650 if ( it == id2widget.end() ) 652 if ( it == id2widget.end() )
651 return; 653 return;
652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 654//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
653 QComboBox * comboBox = (QComboBox *)( *it ); 655 QComboBox * comboBox = (QComboBox *)( *it );
654 if (comboBox) 656 if (comboBox)
655 comboBox->insertItem( text, index ); 657 comboBox->insertItem( text, index );
656} 658}
657 659
658void KToolBar::insertComboList (int id, const QStringList &list, int index) 660void KToolBar::insertComboList (int id, const QStringList &list, int index)
659{ 661{
660 Id2WidgetMap::Iterator it = id2widget.find( id ); 662 Id2WidgetMap::Iterator it = id2widget.find( id );
661 if ( it == id2widget.end() ) 663 if ( it == id2widget.end() )
662 return; 664 return;
663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 665//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
664 QComboBox * comboBox = (QComboBox *)( *it ); 666 QComboBox * comboBox = (QComboBox *)( *it );
665 if (comboBox) 667 if (comboBox)
666 comboBox->insertStringList( list, index ); 668 comboBox->insertStringList( list, index );
667} 669}
668 670
669 671
670void KToolBar::removeComboItem (int id, int index) 672void KToolBar::removeComboItem (int id, int index)
671{ 673{
672 Id2WidgetMap::Iterator it = id2widget.find( id ); 674 Id2WidgetMap::Iterator it = id2widget.find( id );
673 if ( it == id2widget.end() ) 675 if ( it == id2widget.end() )
674 return; 676 return;
675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 677//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
676 QComboBox * comboBox = (QComboBox *)( *it ); 678 QComboBox * comboBox = (QComboBox *)( *it );
677 if (comboBox) 679 if (comboBox)
678 comboBox->removeItem( index ); 680 comboBox->removeItem( index );
679} 681}
680 682
681 683
682void KToolBar::setCurrentComboItem (int id, int index) 684void KToolBar::setCurrentComboItem (int id, int index)
683{ 685{
684 Id2WidgetMap::Iterator it = id2widget.find( id ); 686 Id2WidgetMap::Iterator it = id2widget.find( id );
685 if ( it == id2widget.end() ) 687 if ( it == id2widget.end() )
686 return; 688 return;
687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 689//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
688 QComboBox * comboBox = (QComboBox *)( *it ); 690 QComboBox * comboBox = (QComboBox *)( *it );
689 if (comboBox) 691 if (comboBox)
690 comboBox->setCurrentItem( index ); 692 comboBox->setCurrentItem( index );
691} 693}
692 694
693 695
694void KToolBar::changeComboItem (int id, const QString& text, int index) 696void KToolBar::changeComboItem (int id, const QString& text, int index)
695{ 697{
696 Id2WidgetMap::Iterator it = id2widget.find( id ); 698 Id2WidgetMap::Iterator it = id2widget.find( id );
697 if ( it == id2widget.end() ) 699 if ( it == id2widget.end() )
698 return; 700 return;
699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 701//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
700 QComboBox * comboBox = (QComboBox *)( *it ); 702 QComboBox * comboBox = (QComboBox *)( *it );
701 if (comboBox) 703 if (comboBox)
702 comboBox->changeItem( text, index ); 704 comboBox->changeItem( text, index );
703} 705}
704 706
705 707
706void KToolBar::clearCombo (int id) 708void KToolBar::clearCombo (int id)
707{ 709{
708 Id2WidgetMap::Iterator it = id2widget.find( id ); 710 Id2WidgetMap::Iterator it = id2widget.find( id );
709 if ( it == id2widget.end() ) 711 if ( it == id2widget.end() )
710 return; 712 return;
711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 713//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
712 QComboBox * comboBox = (QComboBox *)( *it ); 714 QComboBox * comboBox = (QComboBox *)( *it );
713 if (comboBox) 715 if (comboBox)
714 comboBox->clear(); 716 comboBox->clear();
715} 717}
716 718
717 719
718QString KToolBar::getComboItem (int id, int index) const 720QString KToolBar::getComboItem (int id, int index) const
719{ 721{
720 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 722 Id2WidgetMap::ConstIterator it = id2widget.find( id );
721 if ( it == id2widget.end() ) 723 if ( it == id2widget.end() )
722 return QString::null; 724 return QString::null;
723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 725//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
724 QComboBox * comboBox = (QComboBox *)( *it ); 726 QComboBox * comboBox = (QComboBox *)( *it );
725 return comboBox ? comboBox->text( index ) : QString::null; 727 return comboBox ? comboBox->text( index ) : QString::null;
726} 728}
727 729
728 730
729KComboBox * KToolBar::getCombo(int id) 731KComboBox * KToolBar::getCombo(int id)
730{ 732{
731 Id2WidgetMap::Iterator it = id2widget.find( id ); 733 Id2WidgetMap::Iterator it = id2widget.find( id );
732 if ( it == id2widget.end() ) 734 if ( it == id2widget.end() )
733 return 0; 735 return 0;
734//US return dynamic_cast<KComboBox *>( *it ); 736//US return dynamic_cast<KComboBox *>( *it );
735 return (KComboBox *)( *it ); 737 return (KComboBox *)( *it );
736} 738}
737 739
738 740
739KLineEdit * KToolBar::getLined (int id) 741KLineEdit * KToolBar::getLined (int id)
740{ 742{
741 Id2WidgetMap::Iterator it = id2widget.find( id ); 743 Id2WidgetMap::Iterator it = id2widget.find( id );
742 if ( it == id2widget.end() ) 744 if ( it == id2widget.end() )
743 return 0; 745 return 0;
744//US return dynamic_cast<KLineEdit *>( *it ); 746//US return dynamic_cast<KLineEdit *>( *it );
745 return (KLineEdit *)( *it ); 747 return (KLineEdit *)( *it );
746} 748}
747 749
748 750
749KToolBarButton * KToolBar::getButton (int id) 751KToolBarButton * KToolBar::getButton (int id)
750{ 752{
751 Id2WidgetMap::Iterator it = id2widget.find( id ); 753 Id2WidgetMap::Iterator it = id2widget.find( id );
752 if ( it == id2widget.end() ) 754 if ( it == id2widget.end() )
753 return 0; 755 return 0;
754//US return dynamic_cast<KToolBarButton *>( *it ); 756//US return dynamic_cast<KToolBarButton *>( *it );
755 return (KToolBarButton *)( *it ); 757 return (KToolBarButton *)( *it );
756} 758}
757 759
758 760
759void KToolBar::alignItemRight (int id, bool right ) 761void KToolBar::alignItemRight (int id, bool right )
760{ 762{
761 Id2WidgetMap::Iterator it = id2widget.find( id ); 763 Id2WidgetMap::Iterator it = id2widget.find( id );
762 if ( it == id2widget.end() ) 764 if ( it == id2widget.end() )
763 return; 765 return;
764 if ( rightAligned && !right && (*it) == rightAligned ) 766 if ( rightAligned && !right && (*it) == rightAligned )
765 rightAligned = 0; 767 rightAligned = 0;
766 if ( (*it) && right ) 768 if ( (*it) && right )
767 rightAligned = (*it); 769 rightAligned = (*it);
768} 770}
769 771
770 772
771QWidget *KToolBar::getWidget (int id) 773QWidget *KToolBar::getWidget (int id)
772{ 774{
773 Id2WidgetMap::Iterator it = id2widget.find( id ); 775 Id2WidgetMap::Iterator it = id2widget.find( id );
774 return ( it == id2widget.end() ) ? 0 : (*it); 776 return ( it == id2widget.end() ) ? 0 : (*it);
775} 777}
776 778
777 779
778void KToolBar::setItemAutoSized (int id, bool yes ) 780void KToolBar::setItemAutoSized (int id, bool yes )
779{ 781{
780 QWidget *w = getWidget(id); 782 QWidget *w = getWidget(id);
781 if ( w && yes ) 783 if ( w && yes )
782 setStretchableWidget( w ); 784 setStretchableWidget( w );
783} 785}
784 786
785 787
786void KToolBar::clear () 788void KToolBar::clear ()
787{ 789{
788 QToolBar::clear(); 790 QToolBar::clear();
789 widget2id.clear(); 791 widget2id.clear();
790 id2widget.clear(); 792 id2widget.clear();
791} 793}
792 794
793 795
794void KToolBar::removeItem(int id) 796void KToolBar::removeItem(int id)
795{ 797{
796 Id2WidgetMap::Iterator it = id2widget.find( id ); 798 Id2WidgetMap::Iterator it = id2widget.find( id );
797 if ( it == id2widget.end() ) 799 if ( it == id2widget.end() )
798 { 800 {
799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 801 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
800 return; 802 return;
801 } 803 }
802 QWidget * w = (*it); 804 QWidget * w = (*it);
803 id2widget.remove( id ); 805 id2widget.remove( id );
804 widget2id.remove( w ); 806 widget2id.remove( w );
805 widgets.removeRef( w ); 807 widgets.removeRef( w );
806 delete w; 808 delete w;
807} 809}
808 810
809 811
810void KToolBar::removeItemDelayed(int id) 812void KToolBar::removeItemDelayed(int id)
811{ 813{
812 Id2WidgetMap::Iterator it = id2widget.find( id ); 814 Id2WidgetMap::Iterator it = id2widget.find( id );
813 if ( it == id2widget.end() ) 815 if ( it == id2widget.end() )
814 { 816 {
815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 817 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
816 return; 818 return;
817 } 819 }
818 QWidget * w = (*it); 820 QWidget * w = (*it);
819 id2widget.remove( id ); 821 id2widget.remove( id );
820 widget2id.remove( w ); 822 widget2id.remove( w );
821 widgets.removeRef( w ); 823 widgets.removeRef( w );
822 824
823 w->blockSignals(true); 825 w->blockSignals(true);
824 d->idleButtons.append(w); 826 d->idleButtons.append(w);
825 layoutTimer->start( 50, TRUE ); 827 layoutTimer->start( 50, TRUE );
826} 828}
827 829
828 830
829void KToolBar::hideItem (int id) 831void KToolBar::hideItem (int id)
830{ 832{
831 QWidget *w = getWidget(id); 833 QWidget *w = getWidget(id);
832 if ( w ) 834 if ( w )
833 w->hide(); 835 w->hide();
834} 836}
835 837
836 838
837void KToolBar::showItem (int id) 839void KToolBar::showItem (int id)
838{ 840{
839 QWidget *w = getWidget(id); 841 QWidget *w = getWidget(id);
840 if ( w ) 842 if ( w )
841 w->show(); 843 w->show();
842} 844}
843 845
844 846
845int KToolBar::itemIndex (int id) 847int KToolBar::itemIndex (int id)
846{ 848{
847 QWidget *w = getWidget(id); 849 QWidget *w = getWidget(id);
848 return w ? widgets.findRef(w) : -1; 850 return w ? widgets.findRef(w) : -1;
849} 851}
850 852
851 853
852void KToolBar::setFullSize(bool flag ) 854void KToolBar::setFullSize(bool flag )
853{ 855{
854 setHorizontalStretchable( flag ); 856 setHorizontalStretchable( flag );
855 setVerticalStretchable( flag ); 857 setVerticalStretchable( flag );
856} 858}
857 859
858 860
859bool KToolBar::fullSize() const 861bool KToolBar::fullSize() const
860{ 862{
861 return isHorizontalStretchable() || isVerticalStretchable(); 863 return isHorizontalStretchable() || isVerticalStretchable();
862} 864}
863 865
864 866
865void KToolBar::enableMoving(bool flag ) 867void KToolBar::enableMoving(bool flag )
866{ 868{
867//US setMovingEnabled(flag); 869//US setMovingEnabled(flag);
868 this->mainWindow()->setToolBarsMovable(flag); 870 this->mainWindow()->setToolBarsMovable(flag);
869} 871}
870 872
871 873
872void KToolBar::setBarPos (BarPosition bpos) 874void KToolBar::setBarPos (BarPosition bpos)
873{ 875{
874 if ( !mainWindow() ) 876 if ( !mainWindow() )
875 return; 877 return;
876//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 878//US mainWindow()->moveDockWindow( this, (Dock)bpos );
877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 879 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
878} 880}
879 881
880 882
881const KToolBar::BarPosition KToolBar::barPos() 883const KToolBar::BarPosition KToolBar::barPos()
882{ 884{
883 if ( !(QMainWindow*)mainWindow() ) 885 if ( !(QMainWindow*)mainWindow() )
884 return KToolBar::Top; 886 return KToolBar::Top;
885//US Dock dock; 887//US Dock dock;
886 QMainWindow::ToolBarDock dock; 888 QMainWindow::ToolBarDock dock;
887 int dm1, dm2; 889 int dm1, dm2;
888 bool dm3; 890 bool dm3;
889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 891 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
890//US if ( dock == DockUnmanaged ) { 892//US if ( dock == DockUnmanaged ) {
891 if ( dock == QMainWindow::Unmanaged ) { 893 if ( dock == QMainWindow::Unmanaged ) {
892 return (KToolBar::BarPosition)Top; 894 return (KToolBar::BarPosition)Top;
893 } 895 }
894 return (BarPosition)dock; 896 return (BarPosition)dock;
895} 897}
896 898
897 899
898bool KToolBar::enable(BarStatus stat) 900bool KToolBar::enable(BarStatus stat)
899{ 901{
900 bool mystat = isVisible(); 902 bool mystat = isVisible();
901 903
902 if ( (stat == Toggle && mystat) || stat == Hide ) 904 if ( (stat == Toggle && mystat) || stat == Hide )
903 hide(); 905 hide();
904 else 906 else
905 show(); 907 show();
906 908
907 return isVisible() == mystat; 909 return isVisible() == mystat;
908} 910}
909 911
910 912
911void KToolBar::setMaxHeight ( int h ) 913void KToolBar::setMaxHeight ( int h )
912{ 914{
913 setMaximumHeight( h ); 915 setMaximumHeight( h );
914} 916}
915 917
916int KToolBar::maxHeight() 918int KToolBar::maxHeight()
917{ 919{
918 return maximumHeight(); 920 return maximumHeight();
919} 921}
920 922
921 923
922void KToolBar::setMaxWidth (int dw) 924void KToolBar::setMaxWidth (int dw)
923{ 925{
924 setMaximumWidth( dw ); 926 setMaximumWidth( dw );
925} 927}
926 928
927 929
928int KToolBar::maxWidth() 930int KToolBar::maxWidth()
929{ 931{
930 return maximumWidth(); 932 return maximumWidth();
931} 933}
932 934
933 935
934void KToolBar::setTitle (const QString& _title) 936void KToolBar::setTitle (const QString& _title)
935{ 937{
936 setLabel( _title ); 938 setLabel( _title );
937} 939}
938 940
939 941
940void KToolBar::enableFloating (bool ) 942void KToolBar::enableFloating (bool )
941{ 943{
942} 944}
943 945
944 946
945void KToolBar::setIconText(IconText it) 947void KToolBar::setIconText(IconText it)
946{ 948{
947 setIconText( it, true ); 949 setIconText( it, true );
948} 950}
949 951
950 952
951void KToolBar::setIconText(IconText icontext, bool update) 953void KToolBar::setIconText(IconText icontext, bool update)
952{ 954{
953 bool doUpdate=false; 955 bool doUpdate=false;
954 956
955 if (icontext != d->m_iconText) { 957 if (icontext != d->m_iconText) {
956 d->m_iconText = icontext; 958 d->m_iconText = icontext;
957 doUpdate=true; 959 doUpdate=true;
958 } 960 }
959 961
960 if (update == false) 962 if (update == false)
961 return; 963 return;
962 964
963 if (doUpdate) 965 if (doUpdate)
964 emit modechange(); // tell buttons what happened 966 emit modechange(); // tell buttons what happened
965 967
966 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 968 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
967 if ( mainWindow() ) { 969 if ( mainWindow() ) {
968 QMainWindow *mw = mainWindow(); 970 QMainWindow *mw = mainWindow();
969 mw->setUpdatesEnabled( FALSE ); 971 mw->setUpdatesEnabled( FALSE );
970 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 972 mw->setToolBarsMovable( !mw->toolBarsMovable() );
971 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 973 mw->setToolBarsMovable( !mw->toolBarsMovable() );
972 mw->setUpdatesEnabled( TRUE ); 974 mw->setUpdatesEnabled( TRUE );
973 } 975 }
974} 976}
975 977
976 978
977KToolBar::IconText KToolBar::iconText() const 979KToolBar::IconText KToolBar::iconText() const
978{ 980{
979 return d->m_iconText; 981 return d->m_iconText;
980} 982}
981 983
982 984
983void KToolBar::setIconSize(int size) 985void KToolBar::setIconSize(int size)
984{ 986{
985 setIconSize( size, true ); 987 setIconSize( size, true );
986} 988}
987 989
988void KToolBar::setIconSize(int size, bool update) 990void KToolBar::setIconSize(int size, bool update)
989{ 991{
990 bool doUpdate=false; 992 bool doUpdate=false;
991 993
992 if ( size != d->m_iconSize ) { 994 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 995 d->m_iconSize = size;
994 doUpdate=true; 996 doUpdate=true;
995 } 997 }
996 998
997 if (update == false) 999 if (update == false)
998 return; 1000 return;
999 1001
1000 if (doUpdate) 1002 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1003 emit modechange(); // tell buttons what happened
1002 1004
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1005 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1006 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1007 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1008 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1009 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1010 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1011 mw->setUpdatesEnabled( TRUE );
1010 } 1012 }
1011} 1013}
1012 1014
1013 1015
1014int KToolBar::iconSize() const 1016int KToolBar::iconSize() const
1015{ 1017{
1016/*US 1018/*US
1017 if ( !d->m_iconSize ) // default value? 1019 if ( !d->m_iconSize ) // default value?
1018 { 1020 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1021 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1023 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1024 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1025 }
1024 return d->m_iconSize; 1026 return d->m_iconSize;
1025*/ 1027*/
1026 int ret = 18; 1028 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 ) 1029 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1030 ret = 30;
1029 return ret; 1031 return ret;
1030} 1032}
1031 1033
1032 1034
1033void KToolBar::setEnableContextMenu(bool enable ) 1035void KToolBar::setEnableContextMenu(bool enable )
1034{ 1036{
1035 d->m_enableContext = enable; 1037 d->m_enableContext = enable;
1036} 1038}
1037 1039
1038 1040
1039bool KToolBar::contextMenuEnabled() const 1041bool KToolBar::contextMenuEnabled() const
1040{ 1042{
1041 return d->m_enableContext; 1043 return d->m_enableContext;
1042} 1044}
1043 1045
1044 1046
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1047void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1048{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1049 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1050 if ( it == id2widget.end() )
1049 return; 1051 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1052//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1053 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1054 if (button)
1053 button->setNoStyle( no_style ); 1055 button->setNoStyle( no_style );
1054} 1056}
1055 1057
1056 1058
1057void KToolBar::setFlat (bool flag) 1059void KToolBar::setFlat (bool flag)
1058{ 1060{
1059 if ( !mainWindow() ) 1061 if ( !mainWindow() )
1060 return; 1062 return;
1061 if ( flag ) 1063 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1064//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1065 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1066 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1067//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1068 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1069 // And remember to save the new look later
1068/*US 1070/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1071 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1072 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1073*/
1072} 1074}
1073 1075
1074 1076
1075int KToolBar::count() const 1077int KToolBar::count() const
1076{ 1078{
1077 return id2widget.count(); 1079 return id2widget.count();
1078} 1080}
1079 1081
1080 1082
1081void KToolBar::saveState() 1083void KToolBar::saveState()
1082{ 1084{
1083/*US 1085/*US
1084 // first, try to save to the xml file 1086 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1087 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1088 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1089 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1090 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1091 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1092 QDomElement current;
1091 // now try to find our toolbar 1093 // now try to find our toolbar
1092 d->modified = false; 1094 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1095 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1096 current = elem;
1095 1097
1096 if ( current.tagName().lower() != "toolbar" ) 1098 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1099 continue;
1098 1100
1099 QString curname(current.attribute( "name" )); 1101 QString curname(current.attribute( "name" ));
1100 1102
1101 if ( curname == barname ) { 1103 if ( curname == barname ) {
1102 saveState( current ); 1104 saveState( current );
1103 break; 1105 break;
1104 } 1106 }
1105 } 1107 }
1106 // if we didn't make changes, then just return 1108 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1109 if ( !d->modified )
1108 return; 1110 return;
1109 1111
1110 // now we load in the (non-merged) local file 1112 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1113 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1114 QDomDocument local;
1113 local.setContent(local_xml); 1115 local.setContent(local_xml);
1114 1116
1115 // make sure we don't append if this toolbar already exists locally 1117 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1118 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1119 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1120 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1121 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1122 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1123 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1124 continue;
1123 1125
1124 QString curname(elem.attribute( "name" )); 1126 QString curname(elem.attribute( "name" ));
1125 1127
1126 if ( curname == barname ) { 1128 if ( curname == barname ) {
1127 just_append = false; 1129 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1130 local.documentElement().replaceChild( current, elem );
1129 break; 1131 break;
1130 } 1132 }
1131 } 1133 }
1132 1134
1133 if (just_append) 1135 if (just_append)
1134 local.documentElement().appendChild( current ); 1136 local.documentElement().appendChild( current );
1135 1137
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1138 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1139
1138 return; 1140 return;
1139 } 1141 }
1140*/ 1142*/
1141 // if that didn't work, we save to the config file 1143 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1144 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1145 saveSettings(config, QString::null);
1144 config->sync(); 1146 config->sync();
1145} 1147}
1146 1148
1147QString KToolBar::settingsGroup() 1149QString KToolBar::settingsGroup()
1148{ 1150{
1149 QString configGroup; 1151 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1152 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1153 configGroup = "Toolbar style";
1152 else 1154 else
1153 configGroup = QString(name()) + " Toolbar style"; 1155 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1156 if ( this->mainWindow() )
1155 { 1157 {
1156 configGroup.prepend(" "); 1158 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1159 configGroup.prepend( this->mainWindow()->name() );
1158 } 1160 }
1159 return configGroup; 1161 return configGroup;
1160} 1162}
1161 1163
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1164void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1165{
1164 return; 1166 return;
1165 QString configGroup = _configGroup; 1167 QString configGroup = _configGroup;
1166 if (configGroup.isEmpty()) 1168 if (configGroup.isEmpty())
1167 configGroup = settingsGroup(); 1169 configGroup = settingsGroup();
1168 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1170 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1169 1171
1170 QString position, icontext; 1172 QString position, icontext;
1171 int index; 1173 int index;
1172 getAttributes( position, icontext, index ); 1174 getAttributes( position, icontext, index );
1173 1175
1174 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1176 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1175 1177
1176 KConfigGroupSaver saver(config, configGroup); 1178 KConfigGroupSaver saver(config, configGroup);
1177 1179
1178 if ( position != d->PositionDefault ) 1180 if ( position != d->PositionDefault )
1179 config->writeEntry("Position", position); 1181 config->writeEntry("Position", position);
1180 else 1182 else
1181 config->deleteEntry("Position"); 1183 config->deleteEntry("Position");
1182 1184
1183 if ( icontext != d->IconTextDefault ) 1185 if ( icontext != d->IconTextDefault )
1184 config->writeEntry("IconText", icontext); 1186 config->writeEntry("IconText", icontext);
1185 else 1187 else
1186 config->deleteEntry("IconText"); 1188 config->deleteEntry("IconText");
1187 1189
1188 if ( iconSize() != d->IconSizeDefault ) 1190 if ( iconSize() != d->IconSizeDefault )
1189 config->writeEntry("IconSize", iconSize()); 1191 config->writeEntry("IconSize", iconSize());
1190 else 1192 else
1191 config->deleteEntry("IconSize"); 1193 config->deleteEntry("IconSize");
1192 1194
1193 if ( isHidden() != d->HiddenDefault ) 1195 if ( isHidden() != d->HiddenDefault )
1194 config->writeEntry("Hidden", isHidden()); 1196 config->writeEntry("Hidden", isHidden());
1195 else 1197 else
1196 config->deleteEntry("Hidden"); 1198 config->deleteEntry("Hidden");
1197 1199
1198 if ( index != d->IndexDefault ) 1200 if ( index != d->IndexDefault )
1199 config->writeEntry( "Index", index ); 1201 config->writeEntry( "Index", index );
1200 else 1202 else
1201 config->deleteEntry("Index"); 1203 config->deleteEntry("Index");
1202//US the older version of KDE (used on the Zaurus) has no Offset property 1204//US the older version of KDE (used on the Zaurus) has no Offset property
1203/* if ( offset() != d->OffsetDefault ) 1205/* if ( offset() != d->OffsetDefault )
1204 config->writeEntry( "Offset", offset() ); 1206 config->writeEntry( "Offset", offset() );
1205 else 1207 else
1206*/ 1208*/
1207 config->deleteEntry("Offset"); 1209 config->deleteEntry("Offset");
1208 1210
1209//US the older version of KDE (used on the Zaurus) has no NewLine property 1211//US the older version of KDE (used on the Zaurus) has no NewLine property
1210/* 1212/*
1211 if ( newLine() != d->NewLineDefault ) 1213 if ( newLine() != d->NewLineDefault )
1212 config->writeEntry( "NewLine", newLine() ); 1214 config->writeEntry( "NewLine", newLine() );
1213 else 1215 else
1214*/ 1216*/
1215 config->deleteEntry("NewLine"); 1217 config->deleteEntry("NewLine");
1216} 1218}
1217 1219
1218void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1220void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1219{ 1221{
1220 d->m_xmlguiClient = client; 1222 d->m_xmlguiClient = client;
1221} 1223}
1222 1224
1223void KToolBar::setText( const QString & txt ) 1225void KToolBar::setText( const QString & txt )
1224{ 1226{
1225//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1227//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1226 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1228 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1227} 1229}
1228 1230
1229 1231
1230QString KToolBar::text() const 1232QString KToolBar::text() const
1231{ 1233{
1232 return label(); 1234 return label();
1233} 1235}
1234 1236
1235 1237
1236void KToolBar::doConnections( KToolBarButton *button ) 1238void KToolBar::doConnections( KToolBarButton *button )
1237{ 1239{
1238 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1240 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1239 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1241 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1240 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1242 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1241 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1243 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1242 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1244 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1243 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1245 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1244} 1246}
1245 1247
1246void KToolBar::mousePressEvent ( QMouseEvent *m ) 1248void KToolBar::mousePressEvent ( QMouseEvent *m )
1247{ 1249{
1248 if ( !mainWindow() ) 1250 if ( !mainWindow() )
1249 return; 1251 return;
1250 QMainWindow *mw = mainWindow(); 1252 QMainWindow *mw = mainWindow();
1251 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1253 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1252 if ( m->button() == RightButton ) { 1254 if ( m->button() == RightButton ) {
1253 int i = contextMenu()->exec( m->globalPos(), 0 ); 1255 int i = contextMenu()->exec( m->globalPos(), 0 );
1254 switch ( i ) { 1256 switch ( i ) {
1255 case -1: 1257 case -1:
1256 return; // popup cancelled 1258 return; // popup cancelled
1257 case CONTEXT_LEFT: 1259 case CONTEXT_LEFT:
1258//US mw->moveDockWindow( this, DockLeft ); 1260//US mw->moveDockWindow( this, DockLeft );
1259 mw->moveToolBar( this, QMainWindow::Left ); 1261 mw->moveToolBar( this, QMainWindow::Left );
1260 break; 1262 break;
1261 case CONTEXT_RIGHT: 1263 case CONTEXT_RIGHT:
1262//US mw->moveDockWindow( this, DockRight ); 1264//US mw->moveDockWindow( this, DockRight );
1263 mw->moveToolBar( this, QMainWindow::Right ); 1265 mw->moveToolBar( this, QMainWindow::Right );
1264 break; 1266 break;
1265 case CONTEXT_TOP: 1267 case CONTEXT_TOP:
1266//US mw->moveDockWindow( this, DockTop ); 1268//US mw->moveDockWindow( this, DockTop );
1267 mw->moveToolBar( this, QMainWindow::Top ); 1269 mw->moveToolBar( this, QMainWindow::Top );
1268 break; 1270 break;
1269 case CONTEXT_BOTTOM: 1271 case CONTEXT_BOTTOM:
1270//US mw->moveDockWindow( this, DockBottom ); 1272//US mw->moveDockWindow( this, DockBottom );
1271 mw->moveToolBar( this, QMainWindow::Bottom ); 1273 mw->moveToolBar( this, QMainWindow::Bottom );
1272 break; 1274 break;
1273 case CONTEXT_FLOAT: 1275 case CONTEXT_FLOAT:
1274 break; 1276 break;
1275 case CONTEXT_FLAT: 1277 case CONTEXT_FLAT:
1276//US mw->moveDockWindow( this, DockMinimized ); 1278//US mw->moveDockWindow( this, DockMinimized );
1277 mw->moveToolBar( this, QMainWindow::Minimized ); 1279 mw->moveToolBar( this, QMainWindow::Minimized );
1278 break; 1280 break;
1279 case CONTEXT_ICONS: 1281 case CONTEXT_ICONS:
1280 setIconText( IconOnly ); 1282 setIconText( IconOnly );
1281 break; 1283 break;
1282 case CONTEXT_TEXTRIGHT: 1284 case CONTEXT_TEXTRIGHT:
1283 setIconText( IconTextRight ); 1285 setIconText( IconTextRight );
1284 break; 1286 break;
1285 case CONTEXT_TEXT: 1287 case CONTEXT_TEXT:
1286 setIconText( TextOnly ); 1288 setIconText( TextOnly );
1287 break; 1289 break;
1288 case CONTEXT_TEXTUNDER: 1290 case CONTEXT_TEXTUNDER:
1289 setIconText( IconTextBottom ); 1291 setIconText( IconTextBottom );
1290 break; 1292 break;
1291 default: 1293 default:
1292 if ( i >= CONTEXT_ICONSIZES ) 1294 if ( i >= CONTEXT_ICONSIZES )
1293 setIconSize( i - CONTEXT_ICONSIZES ); 1295 setIconSize( i - CONTEXT_ICONSIZES );
1294 else 1296 else
1295 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1297 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1296 } 1298 }
1297/*US 1299/*US
1298 if ( mw->inherits("KMainWindow") ) 1300 if ( mw->inherits("KMainWindow") )
1299 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1301 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1300*/ 1302*/
1301 } 1303 }
1302 } 1304 }
1303} 1305}
1304 1306
1305 1307
1306void KToolBar::rebuildLayout() 1308void KToolBar::rebuildLayout()
1307{ 1309{
1308 1310
1309 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1311 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1310 w->blockSignals(false); 1312 w->blockSignals(false);
1311 d->idleButtons.clear(); 1313 d->idleButtons.clear();
1312 1314
1313 layoutTimer->stop(); 1315 layoutTimer->stop();
1314 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1316 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1315 QBoxLayout *l = boxLayout(); 1317 QBoxLayout *l = boxLayout();
1316 l->setMargin( 1 ); 1318 l->setMargin( 1 );
1317 // clear the old layout 1319 // clear the old layout
1318 QLayoutIterator it = l->iterator(); 1320 QLayoutIterator it = l->iterator();
1319 1321
1320 while ( it.current() ) { 1322 while ( it.current() ) {
1321 it.deleteCurrent(); 1323 it.deleteCurrent();
1322 } 1324 }
1323 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1325 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1324 if ( w == rightAligned ) { 1326 if ( w == rightAligned ) {
1325 continue; 1327 continue;
1326 } 1328 }
1327 if ( w->inherits( "KToolBarSeparator" ) && 1329 if ( w->inherits( "KToolBarSeparator" ) &&
1328 !( (KToolBarSeparator*)w )->showLine() ) { 1330 !( (KToolBarSeparator*)w )->showLine() ) {
1329 l->addSpacing( 6 ); 1331 l->addSpacing( 6 );
1330 w->hide(); 1332 w->hide();
1331 continue; 1333 continue;
1332 } 1334 }
1333 if ( w->inherits( "QPopupMenu" ) ) 1335 if ( w->inherits( "QPopupMenu" ) )
1334 continue; 1336 continue;
1335 l->addWidget( w ); 1337 l->addWidget( w );
1336 w->show(); 1338 w->show();
1337 } 1339 }
1338 if ( rightAligned ) { 1340 if ( rightAligned ) {
1339 l->addStretch(); 1341 l->addStretch();
1340 l->addWidget( rightAligned ); 1342 l->addWidget( rightAligned );
1341 rightAligned->show(); 1343 rightAligned->show();
1342 } 1344 }
1343 1345
1344 if ( fullSize() ) { 1346 if ( fullSize() ) {
1345 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1347 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1346 //if ( !stretchableWidget && widgets.last() && 1348 //if ( !stretchableWidget && widgets.last() &&
1347 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1349 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1348 // setStretchableWidget( widgets.last() ); 1350 // setStretchableWidget( widgets.last() );
1349 if ( !rightAligned ) 1351 if ( !rightAligned )
1350 l->addStretch(); 1352 l->addStretch();
1351 if ( stretchableWidget ) 1353 if ( stretchableWidget )
1352 l->setStretchFactor( stretchableWidget, 10 ); 1354 l->setStretchFactor( stretchableWidget, 10 );
1353 } 1355 }
1354 l->invalidate(); 1356 l->invalidate();
1355 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1357 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1356 //#endif //DESKTOP_VERSION 1358 //#endif //DESKTOP_VERSION
1357} 1359}
1358 1360
1359void KToolBar::childEvent( QChildEvent *e ) 1361void KToolBar::childEvent( QChildEvent *e )
1360{ 1362{
1361 1363
1362 if ( e->child()->isWidgetType() ) { 1364 if ( e->child()->isWidgetType() ) {
1363 QWidget * w = (QWidget*)e->child(); 1365 QWidget * w = (QWidget*)e->child();
1364 if ( e->type() == QEvent::ChildInserted ) { 1366 if ( e->type() == QEvent::ChildInserted ) {
1365 if ( !e->child()->inherits( "QPopupMenu" ) && 1367 if ( !e->child()->inherits( "QPopupMenu" ) &&
1366 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1368 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1367 1369
1368 // prevent items that have been explicitly inserted by insert*() from 1370 // prevent items that have been explicitly inserted by insert*() from
1369 // being inserted again 1371 // being inserted again
1370 if ( !widget2id.contains( w ) ) 1372 if ( !widget2id.contains( w ) )
1371 { 1373 {
1372 int dummy = -1; 1374 int dummy = -1;
1373 insertWidgetInternal( w, dummy, -1 ); 1375 insertWidgetInternal( w, dummy, -1 );
1374 } 1376 }
1375 } 1377 }
1376 } else { 1378 } else {
1377 removeWidgetInternal( w ); 1379 removeWidgetInternal( w );
1378 } 1380 }
1379 if ( isVisibleTo( 0 ) ) 1381 if ( isVisibleTo( 0 ) )
1380 { 1382 {
1381 QBoxLayout *l = boxLayout(); 1383 QBoxLayout *l = boxLayout();
1382 // QLayout *l = layout(); 1384 // QLayout *l = layout();
1383 1385
1384 // clear the old layout so that we don't get unnecassery layout 1386 // clear the old layout so that we don't get unnecassery layout
1385 // changes till we have rebuild the thing 1387 // changes till we have rebuild the thing
1386 QLayoutIterator it = l->iterator(); 1388 QLayoutIterator it = l->iterator();
1387 while ( it.current() ) { 1389 while ( it.current() ) {
1388 it.deleteCurrent(); 1390 it.deleteCurrent();
1389 } 1391 }
1390 layoutTimer->start( 50, TRUE ); 1392 layoutTimer->start( 50, TRUE );
1391 } 1393 }
1392 } 1394 }
1393 QToolBar::childEvent( e ); 1395 QToolBar::childEvent( e );
1394} 1396}
1395 1397
1396void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1398void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1397{ 1399{
1398 // we can't have it in widgets, or something is really wrong 1400 // we can't have it in widgets, or something is really wrong
1399 //widgets.removeRef( w ); 1401 //widgets.removeRef( w );
1400 1402
1401 connect( w, SIGNAL( destroyed() ), 1403 connect( w, SIGNAL( destroyed() ),
1402 this, SLOT( widgetDestroyed() ) ); 1404 this, SLOT( widgetDestroyed() ) );
1403 if ( index == -1 || index > (int)widgets.count() ) { 1405 if ( index == -1 || index > (int)widgets.count() ) {
1404 widgets.append( w ); 1406 widgets.append( w );
1405 index = (int)widgets.count(); 1407 index = (int)widgets.count();
1406 } 1408 }
1407 else 1409 else
1408 widgets.insert( index, w ); 1410 widgets.insert( index, w );
1409 if ( id == -1 ) 1411 if ( id == -1 )
1410 id = id2widget.count(); 1412 id = id2widget.count();
1411 id2widget.insert( id, w ); 1413 id2widget.insert( id, w );
1412 widget2id.insert( w, id ); 1414 widget2id.insert( w, id );
1413} 1415}
1414void KToolBar::repaintMe() 1416void KToolBar::repaintMe()
1415{ 1417{
1416 setUpdatesEnabled( true ); 1418 setUpdatesEnabled( true );
1417 QToolBar::repaint( true ); 1419 QToolBar::repaint( true );
1418 qDebug(" KToolBar::repaintMe() "); 1420 qDebug(" KToolBar::repaintMe() ");
1419} 1421}
1420 1422
1421void KToolBar::showEvent( QShowEvent *e ) 1423void KToolBar::showEvent( QShowEvent *e )
1422{ 1424{
1423 rebuildLayout(); 1425 rebuildLayout();
1424 QToolBar::showEvent( e ); 1426 QToolBar::showEvent( e );
1425} 1427}
1426 1428
1427void KToolBar::setStretchableWidget( QWidget *w ) 1429void KToolBar::setStretchableWidget( QWidget *w )
1428{ 1430{
1429 QToolBar::setStretchableWidget( w ); 1431 QToolBar::setStretchableWidget( w );
1430 stretchableWidget = w; 1432 stretchableWidget = w;
1431} 1433}
1432 1434
1433QSizePolicy KToolBar::sizePolicy() const 1435QSizePolicy KToolBar::sizePolicy() const
1434{ 1436{
1435 if ( orientation() == Horizontal ) 1437 if ( orientation() == Horizontal )
1436 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1438 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1437 else 1439 else
1438 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1440 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1439} 1441}
1440 1442
1441QSize KToolBar::sizeHint() const 1443QSize KToolBar::sizeHint() const
1442{ 1444{
1443 return QToolBar::sizeHint(); 1445 QSize sh = QToolBar::sizeHint();
1446 //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() );
1447 if ( sh.height() <= 20 || sh.width() < 60 )
1448 return QSize( sizeHintW, sizeHintH );
1449 KToolBar* ttt = (KToolBar*) this;
1450 ttt->sizeHintW = sh.width();
1451 ttt->sizeHintH = sh.height();
1452 return sh;
1453 //return QToolBar::sizeHint();
1444#if 0 1454#if 0
1445 QWidget::polish(); 1455 QWidget::polish();
1446 static int iii = 0; 1456 static int iii = 0;
1447 ++iii; 1457 ++iii;
1448 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1458 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1449 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1459 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1450 switch( barPos() ) 1460 switch( barPos() )
1451 { 1461 {
1452 case KToolBar::Top: 1462 case KToolBar::Top:
1453 case KToolBar::Bottom: 1463 case KToolBar::Bottom:
1454 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1464 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1455 { 1465 {
1456 if ( w->inherits( "KToolBarSeparator" ) && 1466 if ( w->inherits( "KToolBarSeparator" ) &&
1457 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1467 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1458 { 1468 {
1459 minSize += QSize(6, 0); 1469 minSize += QSize(6, 0);
1460 } 1470 }
1461 else 1471 else
1462 { 1472 {
1463 QSize sh = w->sizeHint(); 1473 QSize sh = w->sizeHint();
1464 if (!sh.isValid()) 1474 if (!sh.isValid())
1465 sh = w->minimumSize(); 1475 sh = w->minimumSize();
1466 minSize = minSize.expandedTo(QSize(0, sh.height())); 1476 minSize = minSize.expandedTo(QSize(0, sh.height()));
1467 minSize += QSize(sh.width()+1, 0); 1477 minSize += QSize(sh.width()+1, 0);
1468 } 1478 }
1469 } 1479 }
1470/*US 1480/*US
1471 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1481 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1472*/ 1482*/
1473 minSize += QSize(margin*2, margin*2); 1483 minSize += QSize(margin*2, margin*2);
1474 break; 1484 break;
1475 1485
1476 case KToolBar::Left: 1486 case KToolBar::Left:
1477 case KToolBar::Right: 1487 case KToolBar::Right:
1478 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1488 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1479 { 1489 {
1480 if ( w->inherits( "KToolBarSeparator" ) && 1490 if ( w->inherits( "KToolBarSeparator" ) &&
1481 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1491 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1482 { 1492 {
1483 minSize += QSize(0, 6); 1493 minSize += QSize(0, 6);
1484 } 1494 }
1485 else 1495 else
1486 { 1496 {
1487 QSize sh = w->sizeHint(); 1497 QSize sh = w->sizeHint();
1488 if (!sh.isValid()) 1498 if (!sh.isValid())
1489 sh = w->minimumSize(); 1499 sh = w->minimumSize();
1490 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1500 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1491 minSize += QSize(0, sh.height()+1); 1501 minSize += QSize(0, sh.height()+1);
1492 } 1502 }
1493 } 1503 }
1494/*US 1504/*US
1495 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1505 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1496*/ 1506*/
1497 minSize += QSize(margin*2, margin*2); 1507 minSize += QSize(margin*2, margin*2);
1498 break; 1508 break;
1499 1509
1500 default: 1510 default:
1501 minSize = QToolBar::sizeHint(); 1511 minSize = QToolBar::sizeHint();
1502 break; 1512 break;
1503 } 1513 }
1504 return minSize; 1514 return minSize;
1505#endif 1515#endif
1506} 1516}
1507 1517
1508QSize KToolBar::minimumSize() const 1518QSize KToolBar::minimumSize() const
1509{ 1519{
1510 return minimumSizeHint(); 1520 return minimumSizeHint();
1511} 1521}
1512 1522
1513QSize KToolBar::minimumSizeHint() const 1523QSize KToolBar::minimumSizeHint() const
1514{ 1524{
1515 return sizeHint(); 1525 return sizeHint();
1516} 1526}
1517 1527
1518bool KToolBar::highlight() const 1528bool KToolBar::highlight() const
1519{ 1529{
1520 return d->m_highlight; 1530 return d->m_highlight;
1521} 1531}
1522 1532
1523void KToolBar::hide() 1533void KToolBar::hide()
1524{ 1534{
1525 QToolBar::hide(); 1535 QToolBar::hide();
1526} 1536}
1527 1537
1528void KToolBar::show() 1538void KToolBar::show()
1529{ 1539{
1530 QToolBar::show(); 1540 QToolBar::show();
1531} 1541}
1532 1542
1533void KToolBar::resizeEvent( QResizeEvent *e ) 1543void KToolBar::resizeEvent( QResizeEvent *e )
1534{ 1544{
1535 bool b = isUpdatesEnabled(); 1545 bool b = isUpdatesEnabled();
1536 setUpdatesEnabled( FALSE ); 1546 setUpdatesEnabled( FALSE );
1537 QToolBar::resizeEvent( e ); 1547 QToolBar::resizeEvent( e );
1538 if (b) 1548 if (b)
1539 d->repaintTimer.start( 100, true ); 1549 d->repaintTimer.start( 100, true );
1540} 1550}
1541 1551
1542void KToolBar::slotIconChanged(int group) 1552void KToolBar::slotIconChanged(int group)
1543{ 1553{
1544 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1554 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1545 return; 1555 return;
1546 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1556 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1547 return; 1557 return;
1548 1558
1549 emit modechange(); 1559 emit modechange();
1550 if (isVisible()) 1560 if (isVisible())
1551 updateGeometry(); 1561 updateGeometry();
1552} 1562}
1553 1563
1554void KToolBar::slotReadConfig() 1564void KToolBar::slotReadConfig()
1555{ 1565{
1556 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1566 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1557 // Read appearance settings (hmm, we used to do both here, 1567 // Read appearance settings (hmm, we used to do both here,
1558 // but a well behaved application will call applyMainWindowSettings 1568 // but a well behaved application will call applyMainWindowSettings
1559 // anyway, right ?) 1569 // anyway, right ?)
1560 applyAppearanceSettings(KGlobal::config(), QString::null ); 1570 applyAppearanceSettings(KGlobal::config(), QString::null );
1561} 1571}
1562 1572
1563void KToolBar::slotAppearanceChanged() 1573void KToolBar::slotAppearanceChanged()
1564{ 1574{
1565 // Read appearance settings from global file. 1575 // Read appearance settings from global file.
1566 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1576 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1567 // And remember to save the new look later 1577 // And remember to save the new look later
1568/*US 1578/*US
1569 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1579 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1570 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1580 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1571*/ 1581*/
1572} 1582}
1573 1583
1574//static 1584//static
1575bool KToolBar::highlightSetting() 1585bool KToolBar::highlightSetting()
1576{ 1586{
1577 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1587 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1578 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1588 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1579 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1589 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1580} 1590}
1581 1591
1582//static 1592//static
1583bool KToolBar::transparentSetting() 1593bool KToolBar::transparentSetting()
1584{ 1594{
1585 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1595 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1586 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1596 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1587 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1597 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1588} 1598}
1589 1599
1590//static 1600//static
1591KToolBar::IconText KToolBar::iconTextSetting() 1601KToolBar::IconText KToolBar::iconTextSetting()
1592{ 1602{
1593 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1603 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1594 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1604 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1595 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1605 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1596 if ( icontext == "IconTextRight" ) 1606 if ( icontext == "IconTextRight" )
1597 return IconTextRight; 1607 return IconTextRight;
1598 else if ( icontext == "IconTextBottom" ) 1608 else if ( icontext == "IconTextBottom" )
1599 return IconTextBottom; 1609 return IconTextBottom;
1600 else if ( icontext == "TextOnly" ) 1610 else if ( icontext == "TextOnly" )
1601 return TextOnly; 1611 return TextOnly;
1602 else 1612 else
1603 return IconOnly; 1613 return IconOnly;
1604} 1614}
1605 1615
1606void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1616void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1607{ 1617{
1608 return; 1618 return;
1609 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1619 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1610 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1620 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1611 // We have application-specific settings in the XML file, 1621 // We have application-specific settings in the XML file,
1612 // and nothing in the application's config file 1622 // and nothing in the application's config file
1613 // -> don't apply the global defaults, the XML ones are preferred 1623 // -> don't apply the global defaults, the XML ones are preferred
1614 // See applySettings for a full explanation 1624 // See applySettings for a full explanation
1615/*US :we do not support xml files 1625/*US :we do not support xml files
1616 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1626 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1617 !config->hasGroup(configGroup) ) 1627 !config->hasGroup(configGroup) )
1618 { 1628 {
1619 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1629 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1620 return; 1630 return;
1621 } 1631 }
1622*/ 1632*/
1623 if ( !config->hasGroup(configGroup) ) 1633 if ( !config->hasGroup(configGroup) )
1624 { 1634 {
1625 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1635 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1626 return; 1636 return;
1627 } 1637 }
1628 1638
1629 1639
1630 KConfig *gconfig = KGlobal::config(); 1640 KConfig *gconfig = KGlobal::config();
1631/*US 1641/*US
1632 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1642 static const QString &attrIconText = KGlobal::staticQString("IconText");
1633 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1643 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1634 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1644 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1635 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1645 static const QString &attrSize = KGlobal::staticQString("IconSize");
1636*/ 1646*/
1637 // we actually do this in two steps. 1647 // we actually do this in two steps.
1638 // First, we read in the global styles [Toolbar style] (from the KControl module). 1648 // First, we read in the global styles [Toolbar style] (from the KControl module).
1639 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1649 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1640 bool highlight; 1650 bool highlight;
1641 int transparent; 1651 int transparent;
1642 QString icontext; 1652 QString icontext;
1643 int iconsize = 0; 1653 int iconsize = 0;
1644 1654
1645 // this is the first iteration 1655 // this is the first iteration
1646 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1656 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1647 { // start block for KConfigGroupSaver 1657 { // start block for KConfigGroupSaver
1648 KConfigGroupSaver saver(gconfig, grpToolbar); 1658 KConfigGroupSaver saver(gconfig, grpToolbar);
1649 1659
1650 // first, get the generic settings 1660 // first, get the generic settings
1651//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1661//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1652 highlight = gconfig->readBoolEntry("Highlighting", true); 1662 highlight = gconfig->readBoolEntry("Highlighting", true);
1653//US transparent = gconfig->readBoolEntry(attrTrans, true); 1663//US transparent = gconfig->readBoolEntry(attrTrans, true);
1654 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1664 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1655 1665
1656 // we read in the IconText property *only* if we intend on actually 1666 // we read in the IconText property *only* if we intend on actually
1657 // honoring it 1667 // honoring it
1658 if (d->m_honorStyle) 1668 if (d->m_honorStyle)
1659//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1669//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1660 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1670 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1661 else 1671 else
1662 d->IconTextDefault = "IconOnly"; 1672 d->IconTextDefault = "IconOnly";
1663 1673
1664 // Use the default icon size for toolbar icons. 1674 // Use the default icon size for toolbar icons.
1665//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1675//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1666 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1676 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1667 1677
1668 if ( !forceGlobal && config->hasGroup(configGroup) ) 1678 if ( !forceGlobal && config->hasGroup(configGroup) )
1669 { 1679 {
1670 config->setGroup(configGroup); 1680 config->setGroup(configGroup);
1671 1681
1672 // first, get the generic settings 1682 // first, get the generic settings
1673//US highlight = config->readBoolEntry(attrHighlight, highlight); 1683//US highlight = config->readBoolEntry(attrHighlight, highlight);
1674 highlight = config->readBoolEntry("Highlighting", highlight); 1684 highlight = config->readBoolEntry("Highlighting", highlight);
1675//US transparent = config->readBoolEntry(attrTrans, transparent); 1685//US transparent = config->readBoolEntry(attrTrans, transparent);
1676 transparent = config->readBoolEntry("TransparentMoving", transparent); 1686 transparent = config->readBoolEntry("TransparentMoving", transparent);
1677 // now we always read in the IconText property 1687 // now we always read in the IconText property
1678//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1688//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1679 icontext = config->readEntry("IconText", d->IconTextDefault); 1689 icontext = config->readEntry("IconText", d->IconTextDefault);
1680 1690
1681 // now get the size 1691 // now get the size
1682//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1692//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1683 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1693 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1684 } 1694 }
1685 else 1695 else
1686 { 1696 {
1687 iconsize = d->IconSizeDefault; 1697 iconsize = d->IconSizeDefault;
1688 icontext = d->IconTextDefault; 1698 icontext = d->IconTextDefault;
1689 } 1699 }
1690 1700
1691 // revert back to the old group 1701 // revert back to the old group
1692 } // end block for KConfigGroupSaver 1702 } // end block for KConfigGroupSaver
1693 1703
1694 bool doUpdate = false; 1704 bool doUpdate = false;
1695 1705
1696 IconText icon_text; 1706 IconText icon_text;
1697 if ( icontext == "IconTextRight" ) 1707 if ( icontext == "IconTextRight" )
1698 icon_text = IconTextRight; 1708 icon_text = IconTextRight;
1699 else if ( icontext == "IconTextBottom" ) 1709 else if ( icontext == "IconTextBottom" )
1700 icon_text = IconTextBottom; 1710 icon_text = IconTextBottom;
1701 else if ( icontext == "TextOnly" ) 1711 else if ( icontext == "TextOnly" )
1702 icon_text = TextOnly; 1712 icon_text = TextOnly;
1703 else 1713 else
1704 icon_text = IconOnly; 1714 icon_text = IconOnly;
1705 1715
1706 // check if the icon/text has changed 1716 // check if the icon/text has changed
1707 if (icon_text != d->m_iconText) { 1717 if (icon_text != d->m_iconText) {
1708 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1718 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1709 setIconText(icon_text, false); 1719 setIconText(icon_text, false);
1710 doUpdate = true; 1720 doUpdate = true;
1711 } 1721 }
1712 1722
1713 // ...and check if the icon size has changed 1723 // ...and check if the icon size has changed
1714 if (iconsize != d->m_iconSize) { 1724 if (iconsize != d->m_iconSize) {
1715 setIconSize(iconsize, false); 1725 setIconSize(iconsize, false);
1716 doUpdate = true; 1726 doUpdate = true;
1717 } 1727 }
1718 1728
1719 QMainWindow *mw = mainWindow(); 1729 QMainWindow *mw = mainWindow();
1720 1730
1721 // ...and if we should highlight 1731 // ...and if we should highlight
1722 if ( highlight != d->m_highlight ) { 1732 if ( highlight != d->m_highlight ) {
1723 d->m_highlight = highlight; 1733 d->m_highlight = highlight;
1724 doUpdate = true; 1734 doUpdate = true;
1725 } 1735 }
1726 1736
1727 // ...and if we should move transparently 1737 // ...and if we should move transparently
1728 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1738 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1729 mw->setOpaqueMoving( !transparent ); 1739 mw->setOpaqueMoving( !transparent );
1730 } 1740 }
1731 1741
1732 if (doUpdate) 1742 if (doUpdate)
1733 emit modechange(); // tell buttons what happened 1743 emit modechange(); // tell buttons what happened
1734 if (isVisible ()) 1744 if (isVisible ())
1735 updateGeometry(); 1745 updateGeometry();
1736} 1746}
1737 1747
1738void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1748void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1739{ 1749{
1740 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1750 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1741 1751
1742 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1752 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1743 1753
1744 /* 1754 /*
1745 Let's explain this a bit more in details. 1755 Let's explain this a bit more in details.
1746 The order in which we apply settings is : 1756 The order in which we apply settings is :
1747 Global config / <appnamerc> user settings if no XMLGUI is used 1757 Global config / <appnamerc> user settings if no XMLGUI is used
1748 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1758 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1749 1759
1750 So in the first case, we simply read everything from KConfig as below, 1760 So in the first case, we simply read everything from KConfig as below,
1751 but in the second case we don't do anything here if there is no app-specific config, 1761 but in the second case we don't do anything here if there is no app-specific config,
1752 and the XMLGUI uses the static methods of this class to get the global defaults. 1762 and the XMLGUI uses the static methods of this class to get the global defaults.
1753 1763
1754 Global config doesn't include position (index, offset, newline and hidden/shown). 1764 Global config doesn't include position (index, offset, newline and hidden/shown).
1755 */ 1765 */
1756 1766
1757 // First the appearance stuff - the one which has a global config 1767 // First the appearance stuff - the one which has a global config
1758 applyAppearanceSettings( config, _configGroup ); 1768 applyAppearanceSettings( config, _configGroup );
1759 1769
1760 // ...and now the position stuff 1770 // ...and now the position stuff
1761 if ( config->hasGroup(configGroup) ) 1771 if ( config->hasGroup(configGroup) )
1762 { 1772 {
1763 KConfigGroupSaver cgs(config, configGroup); 1773 KConfigGroupSaver cgs(config, configGroup);
1764/*US 1774/*US
1765 static const QString &attrPosition = KGlobal::staticQString("Position"); 1775 static const QString &attrPosition = KGlobal::staticQString("Position");
1766 static const QString &attrIndex = KGlobal::staticQString("Index"); 1776 static const QString &attrIndex = KGlobal::staticQString("Index");
1767 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1777 static const QString &attrOffset = KGlobal::staticQString("Offset");
1768 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1778 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1769 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1779 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1770 1780
1771 QString position = config->readEntry(attrPosition, d->PositionDefault); 1781 QString position = config->readEntry(attrPosition, d->PositionDefault);
1772 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1782 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1773 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1783 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1774 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1784 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1775 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1785 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1776*/ 1786*/
1777 1787
1778 QString position = config->readEntry("Position", d->PositionDefault); 1788 QString position = config->readEntry("Position", d->PositionDefault);
1779 int index = config->readNumEntry("Index", d->IndexDefault); 1789 int index = config->readNumEntry("Index", d->IndexDefault);
1780 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1790 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1781 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1791 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1782 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1792 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1783 1793
1784/*US Dock pos(DockTop); 1794/*US Dock pos(DockTop);
1785 if ( position == "Top" ) 1795 if ( position == "Top" )
1786 pos = DockTop; 1796 pos = DockTop;
1787 else if ( position == "Bottom" ) 1797 else if ( position == "Bottom" )
1788 pos = DockBottom; 1798 pos = DockBottom;
1789 else if ( position == "Left" ) 1799 else if ( position == "Left" )
1790 pos = DockLeft; 1800 pos = DockLeft;
1791 else if ( position == "Right" ) 1801 else if ( position == "Right" )
1792 pos = DockRight; 1802 pos = DockRight;
1793 else if ( position == "Floating" ) 1803 else if ( position == "Floating" )
1794 pos = DockTornOff; 1804 pos = DockTornOff;
1795 else if ( position == "Flat" ) 1805 else if ( position == "Flat" )
1796 pos = DockMinimized; 1806 pos = DockMinimized;
1797*/ 1807*/
1798 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1808 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1799 if ( position == "Top" ) 1809 if ( position == "Top" )
1800 pos = QMainWindow::Top; 1810 pos = QMainWindow::Top;
1801 else if ( position == "Bottom" ) 1811 else if ( position == "Bottom" )
1802 pos = QMainWindow::Bottom; 1812 pos = QMainWindow::Bottom;
1803 else if ( position == "Left" ) 1813 else if ( position == "Left" )
1804 pos = QMainWindow::Left; 1814 pos = QMainWindow::Left;
1805 else if ( position == "Right" ) 1815 else if ( position == "Right" )
1806 pos = QMainWindow::Right; 1816 pos = QMainWindow::Right;
1807 else if ( position == "Floating" ) 1817 else if ( position == "Floating" )
1808 pos = QMainWindow::TornOff; 1818 pos = QMainWindow::TornOff;
1809 else if ( position == "Flat" ) 1819 else if ( position == "Flat" )
1810 pos = QMainWindow::Minimized; 1820 pos = QMainWindow::Minimized;
1811 1821
1812 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; 1822 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl;
1813 if (hidden) 1823 if (hidden)
1814 hide(); 1824 hide();
1815 else 1825 else
1816 show(); 1826 show();
1817 1827
1818 if ( mainWindow() ) 1828 if ( mainWindow() )
1819 { 1829 {
1820 QMainWindow *mw = mainWindow(); 1830 QMainWindow *mw = mainWindow();
1821 1831
1822 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; 1832 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
1823 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); 1833 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
1824 1834
1825 // moveDockWindow calls QDockArea which does a reparent() on us with 1835 // moveDockWindow calls QDockArea which does a reparent() on us with
1826 // showIt = true, so we loose our visibility status 1836 // showIt = true, so we loose our visibility status
1827 bool doHide = isHidden(); 1837 bool doHide = isHidden();
1828 1838
1829//US mw->moveDockWindow( this, pos, newLine, index, offset ); 1839//US mw->moveDockWindow( this, pos, newLine, index, offset );
1830 mw->moveToolBar( this, pos, newLine, index, offset ); 1840 mw->moveToolBar( this, pos, newLine, index, offset );
1831 1841
1832 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; 1842 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
1833 if ( doHide ) 1843 if ( doHide )
1834 hide(); 1844 hide();
1835 } 1845 }
1836 if (isVisible ()) 1846 if (isVisible ())
1837 updateGeometry(); 1847 updateGeometry();
1838 } 1848 }
1839} 1849}
1840 1850
1841bool KToolBar::event( QEvent *e ) 1851bool KToolBar::event( QEvent *e )
1842{ 1852{
1843 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) 1853 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
1844 d->repaintTimer.start( 100, true ); 1854 d->repaintTimer.start( 100, true );
1845 1855
1846 if (e->type() == QEvent::ChildInserted ) 1856 if (e->type() == QEvent::ChildInserted )
1847 { 1857 {
1848 // By pass QToolBar::event, 1858 // By pass QToolBar::event,
1849 // it will show() the inserted child and we don't want to 1859 // it will show() the inserted child and we don't want to
1850 // do that until we have rebuild the layout. 1860 // do that until we have rebuild the layout.
1851 childEvent((QChildEvent *)e); 1861 childEvent((QChildEvent *)e);
1852 return true; 1862 return true;
1853 } 1863 }
1854 1864
1855 return QToolBar::event( e ); 1865 return QToolBar::event( e );
1856} 1866}
1857 1867
1858void KToolBar::slotRepaint() 1868void KToolBar::slotRepaint()
1859{ 1869{
1860 setUpdatesEnabled( FALSE ); 1870 setUpdatesEnabled( FALSE );
1861 // Send a resizeEvent to update the "toolbar extension arrow" 1871 // Send a resizeEvent to update the "toolbar extension arrow"
1862 // (The button you get when your toolbar-items don't fit in 1872 // (The button you get when your toolbar-items don't fit in
1863 // the available space) 1873 // the available space)
1864 QResizeEvent ev(size(), size()); 1874 QResizeEvent ev(size(), size());
1865 resizeEvent(&ev); 1875 resizeEvent(&ev);
1866 //#ifdef DESKTOP_VERSION 1876 //#ifdef DESKTOP_VERSION
1867 QApplication::sendPostedEvents( this, QEvent::LayoutHint ); 1877 QApplication::sendPostedEvents( this, QEvent::LayoutHint );
1868 //#endif //DESKTOP_VERSION 1878 //#endif //DESKTOP_VERSION
1869 setUpdatesEnabled( TRUE ); 1879 setUpdatesEnabled( TRUE );
1870 repaint( TRUE ); 1880 repaint( TRUE );
1871} 1881}
1872 1882
1873void KToolBar::toolBarPosChanged( QToolBar *tb ) 1883void KToolBar::toolBarPosChanged( QToolBar *tb )
1874{ 1884{
1875 if ( tb != this ) 1885 if ( tb != this )
1876 return; 1886 return;
1877//US if ( d->oldPos == DockMinimized ) 1887//US if ( d->oldPos == DockMinimized )
1878 if ( d->oldPos == QMainWindow::Minimized ) 1888 if ( d->oldPos == QMainWindow::Minimized )
1879 rebuildLayout(); 1889 rebuildLayout();
1880 d->oldPos = (QMainWindow::ToolBarDock)barPos(); 1890 d->oldPos = (QMainWindow::ToolBarDock)barPos();
1881/*US 1891/*US
1882 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1892 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1883 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1893 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1884*/ 1894*/
1885} 1895}
1886 1896
1887/*US 1897/*US
1888void KToolBar::loadState( const QDomElement &element ) 1898void KToolBar::loadState( const QDomElement &element )
1889{ 1899{
1890 //kdDebug(220) << "KToolBar::loadState " << this << endl; 1900 //kdDebug(220) << "KToolBar::loadState " << this << endl;
1891 if ( !mainWindow() ) 1901 if ( !mainWindow() )
1892 return; 1902 return;
1893 1903
1894 { 1904 {
1895 QCString text = element.namedItem( "text" ).toElement().text().utf8(); 1905 QCString text = element.namedItem( "text" ).toElement().text().utf8();
1896 if ( text.isEmpty() ) 1906 if ( text.isEmpty() )
1897 text = element.namedItem( "Text" ).toElement().text().utf8(); 1907 text = element.namedItem( "Text" ).toElement().text().utf8();
1898 if ( !text.isEmpty() ) 1908 if ( !text.isEmpty() )
1899 setText( i18n( text ) ); 1909 setText( i18n( text ) );
1900 } 1910 }
1901 1911
1902 { 1912 {
1903 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); 1913 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
1904 if ( !attrFullWidth.isEmpty() ) 1914 if ( !attrFullWidth.isEmpty() )
1905 setFullSize( attrFullWidth == "true" ); 1915 setFullSize( attrFullWidth == "true" );
1906 } 1916 }
1907 1917
1908 Dock dock = DockTop; 1918 Dock dock = DockTop;
1909 { 1919 {
1910 QCString attrPosition = element.attribute( "position" ).lower().latin1(); 1920 QCString attrPosition = element.attribute( "position" ).lower().latin1();
1911 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; 1921 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl;
1912 if ( !attrPosition.isEmpty() ) { 1922 if ( !attrPosition.isEmpty() ) {
1913 if ( attrPosition == "top" ) 1923 if ( attrPosition == "top" )
1914 dock = DockTop; 1924 dock = DockTop;
1915 else if ( attrPosition == "left" ) 1925 else if ( attrPosition == "left" )
1916 dock = DockLeft; 1926 dock = DockLeft;
1917 else if ( attrPosition == "right" ) 1927 else if ( attrPosition == "right" )
1918 dock = DockRight; 1928 dock = DockRight;
1919 else if ( attrPosition == "bottom" ) 1929 else if ( attrPosition == "bottom" )
1920 dock = DockBottom; 1930 dock = DockBottom;
1921 else if ( attrPosition == "floating" ) 1931 else if ( attrPosition == "floating" )
1922 dock = DockTornOff; 1932 dock = DockTornOff;
1923 else if ( attrPosition == "flat" ) 1933 else if ( attrPosition == "flat" )
1924 dock = DockMinimized; 1934 dock = DockMinimized;
1925 } 1935 }
1926 } 1936 }
1927 1937
1928 { 1938 {
1929 QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); 1939 QCString attrIconText = element.attribute( "iconText" ).lower().latin1();
1930 if ( !attrIconText.isEmpty() ) { 1940 if ( !attrIconText.isEmpty() ) {
1931 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; 1941 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl;
1932 if ( attrIconText == "icontextright" ) 1942 if ( attrIconText == "icontextright" )
1933 setIconText( KToolBar::IconTextRight ); 1943 setIconText( KToolBar::IconTextRight );
1934 else if ( attrIconText == "textonly" ) 1944 else if ( attrIconText == "textonly" )
1935 setIconText( KToolBar::TextOnly ); 1945 setIconText( KToolBar::TextOnly );
1936 else if ( attrIconText == "icontextbottom" ) 1946 else if ( attrIconText == "icontextbottom" )
1937 setIconText( KToolBar::IconTextBottom ); 1947 setIconText( KToolBar::IconTextBottom );
1938 else if ( attrIconText == "icononly" ) 1948 else if ( attrIconText == "icononly" )
1939 setIconText( KToolBar::IconOnly ); 1949 setIconText( KToolBar::IconOnly );
1940 } else 1950 } else
1941 // Use global setting 1951 // Use global setting
1942 setIconText( iconTextSetting() ); 1952 setIconText( iconTextSetting() );
1943 } 1953 }
1944 1954
1945 { 1955 {
1946 QString attrIconSize = element.attribute( "iconSize" ).lower(); 1956 QString attrIconSize = element.attribute( "iconSize" ).lower();
1947 if ( !attrIconSize.isEmpty() ) 1957 if ( !attrIconSize.isEmpty() )
1948 d->IconSizeDefault = attrIconSize.toInt(); 1958 d->IconSizeDefault = attrIconSize.toInt();
1949 setIconSize( d->IconSizeDefault ); 1959 setIconSize( d->IconSizeDefault );
1950 } 1960 }
1951 1961
1952 { 1962 {
1953 QString attrIndex = element.attribute( "index" ).lower(); 1963 QString attrIndex = element.attribute( "index" ).lower();
1954 if ( !attrIndex.isEmpty() ) 1964 if ( !attrIndex.isEmpty() )
1955 d->IndexDefault = attrIndex.toInt(); 1965 d->IndexDefault = attrIndex.toInt();
1956 } 1966 }
1957 1967
1958 { 1968 {
1959 QString attrOffset = element.attribute( "offset" ).lower(); 1969 QString attrOffset = element.attribute( "offset" ).lower();
1960 if ( !attrOffset.isEmpty() ) 1970 if ( !attrOffset.isEmpty() )
1961 d->OffsetDefault = attrOffset.toInt(); 1971 d->OffsetDefault = attrOffset.toInt();
1962 } 1972 }
1963 1973
1964 { 1974 {
1965 QString attrNewLine = element.attribute( "newline" ).lower(); 1975 QString attrNewLine = element.attribute( "newline" ).lower();
1966 if ( !attrNewLine.isEmpty() ) 1976 if ( !attrNewLine.isEmpty() )
1967 d->NewLineDefault = attrNewLine == "true"; 1977 d->NewLineDefault = attrNewLine == "true";
1968 } 1978 }
1969 1979
1970 { 1980 {
1971 QString attrHidden = element.attribute( "hidden" ).lower(); 1981 QString attrHidden = element.attribute( "hidden" ).lower();
1972 if ( !attrHidden.isEmpty() ) 1982 if ( !attrHidden.isEmpty() )
1973 d->HiddenDefault = attrHidden == "true"; 1983 d->HiddenDefault = attrHidden == "true";
1974 } 1984 }
1975 1985
1976 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); 1986 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault );
1977 mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); 1987 mainWindow()->addDockWindow( this, dock, d->NewLineDefault );
1978//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1988//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1979 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1989 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1980 1990
1981 // Apply the highlight button setting 1991 // Apply the highlight button setting
1982 d->m_highlight = highlightSetting(); 1992 d->m_highlight = highlightSetting();
1983 1993
1984 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, 1994 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow,
1985 // but we do it only if there are toolbars...) 1995 // but we do it only if there are toolbars...)
1986 if ( transparentSetting() != !mainWindow()->opaqueMoving() ) 1996 if ( transparentSetting() != !mainWindow()->opaqueMoving() )
1987 mainWindow()->setOpaqueMoving( !transparentSetting() ); 1997 mainWindow()->setOpaqueMoving( !transparentSetting() );
1988 1998
1989 if ( d->HiddenDefault ) 1999 if ( d->HiddenDefault )
1990 hide(); 2000 hide();
1991 else 2001 else
1992 show(); 2002 show();
1993 2003
1994 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); 2004 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault );
1995} 2005}
1996*/ 2006*/
1997 2007
1998void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) 2008void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
1999{ 2009{
2000 // get all of the stuff to save 2010 // get all of the stuff to save
2001 switch ( barPos() ) { 2011 switch ( barPos() ) {
2002 case KToolBar::Flat: 2012 case KToolBar::Flat:
2003 position = "Flat"; 2013 position = "Flat";
2004 break; 2014 break;
2005 case KToolBar::Bottom: 2015 case KToolBar::Bottom:
2006 position = "Bottom"; 2016 position = "Bottom";
2007 break; 2017 break;
2008 case KToolBar::Left: 2018 case KToolBar::Left:
2009 position = "Left"; 2019 position = "Left";
2010 break; 2020 break;
2011 case KToolBar::Right: 2021 case KToolBar::Right:
2012 position = "Right"; 2022 position = "Right";
2013 break; 2023 break;
2014 case KToolBar::Floating: 2024 case KToolBar::Floating:
2015 position = "Floating"; 2025 position = "Floating";
2016 break; 2026 break;
2017 case KToolBar::Top: 2027 case KToolBar::Top:
2018 default: 2028 default:
2019 position = "Top"; 2029 position = "Top";
2020 break; 2030 break;
2021 } 2031 }
2022 2032
2023 if ( mainWindow() ) { 2033 if ( mainWindow() ) {
2024 QMainWindow::ToolBarDock dock; 2034 QMainWindow::ToolBarDock dock;
2025 bool newLine; 2035 bool newLine;
2026 int offset; 2036 int offset;
2027 mainWindow()->getLocation( this, dock, index, newLine, offset ); 2037 mainWindow()->getLocation( this, dock, index, newLine, offset );
2028 } 2038 }
2029 2039
2030 switch (d->m_iconText) { 2040 switch (d->m_iconText) {
2031 case KToolBar::IconTextRight: 2041 case KToolBar::IconTextRight:
2032 icontext = "IconTextRight"; 2042 icontext = "IconTextRight";
2033 break; 2043 break;
2034 case KToolBar::IconTextBottom: 2044 case KToolBar::IconTextBottom:
2035 icontext = "IconTextBottom"; 2045 icontext = "IconTextBottom";
2036 break; 2046 break;
2037 case KToolBar::TextOnly: 2047 case KToolBar::TextOnly:
2038 icontext = "TextOnly"; 2048 icontext = "TextOnly";
2039 break; 2049 break;
2040 case KToolBar::IconOnly: 2050 case KToolBar::IconOnly:
2041 default: 2051 default:
2042 icontext = "IconOnly"; 2052 icontext = "IconOnly";
2043 break; 2053 break;
2044 } 2054 }
2045} 2055}
2046/*US 2056/*US
2047void KToolBar::saveState( QDomElement &current ) 2057void KToolBar::saveState( QDomElement &current )
2048{ 2058{
2049 QString position, icontext; 2059 QString position, icontext;
2050 int index = -1; 2060 int index = -1;
2051 getAttributes( position, icontext, index ); 2061 getAttributes( position, icontext, index );
2052 2062
2053 current.setAttribute( "noMerge", "1" ); 2063 current.setAttribute( "noMerge", "1" );
2054 current.setAttribute( "position", position ); 2064 current.setAttribute( "position", position );
2055 current.setAttribute( "iconText", icontext ); 2065 current.setAttribute( "iconText", icontext );
2056 current.setAttribute( "index", index ); 2066 current.setAttribute( "index", index );
2057 current.setAttribute( "offset", offset() ); 2067 current.setAttribute( "offset", offset() );
2058 current.setAttribute( "newline", newLine() ); 2068 current.setAttribute( "newline", newLine() );
2059 if ( isHidden() ) 2069 if ( isHidden() )
2060 current.setAttribute( "hidden", "true" ); 2070 current.setAttribute( "hidden", "true" );
2061 d->modified = true; 2071 d->modified = true;
2062} 2072}
2063*/ 2073*/
2064 2074
2065void KToolBar::positionYourself( bool force ) 2075void KToolBar::positionYourself( bool force )
2066{ 2076{
2067 if (force) 2077 if (force)
2068 d->positioned = false; 2078 d->positioned = false;
2069 2079
2070 if ( d->positioned || !mainWindow() ) 2080 if ( d->positioned || !mainWindow() )
2071 { 2081 {
2072 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; 2082 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl;
2073 return; 2083 return;
2074 } 2084 }
2075 // we can't test for ForceHide after moveDockWindow because QDockArea 2085 // we can't test for ForceHide after moveDockWindow because QDockArea
2076 // does a reparent() with showIt == true 2086 // does a reparent() with showIt == true
2077 bool doHide = isHidden(); 2087 bool doHide = isHidden();
2078 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; 2088 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl;
2079/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, 2089/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
2080 d->toolBarInfo.newline, 2090 d->toolBarInfo.newline,
2081 d->toolBarInfo.index, 2091 d->toolBarInfo.index,
2082 d->toolBarInfo.offset ); 2092 d->toolBarInfo.offset );
2083*/ 2093*/
2084 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 2094 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
2085 2095
2086 if ( doHide ) 2096 if ( doHide )
2087 hide(); 2097 hide();
2088 // This method can only have an effect once - unless force is set 2098 // This method can only have an effect once - unless force is set
2089 d->positioned = TRUE; 2099 d->positioned = TRUE;
2090} 2100}
2091 2101
2092//US KPopupMenu *KToolBar::contextMenu() 2102//US KPopupMenu *KToolBar::contextMenu()
2093QPopupMenu *KToolBar::contextMenu() 2103QPopupMenu *KToolBar::contextMenu()
2094{ 2104{
2095 if ( context ) 2105 if ( context )
2096 return context; 2106 return context;
2097 2107
2098 // Construct our context popup menu. Name it qt_dockwidget_internal so it 2108 // Construct our context popup menu. Name it qt_dockwidget_internal so it
2099 // won't be deleted by QToolBar::clear(). 2109 // won't be deleted by QToolBar::clear().
2100//US context = new KPopupMenu( this, "qt_dockwidget_internal" ); 2110//US context = new KPopupMenu( this, "qt_dockwidget_internal" );
2101 context = new QPopupMenu( this, "qt_dockwidget_internal" ); 2111 context = new QPopupMenu( this, "qt_dockwidget_internal" );
2102//US context->insertTitle(i18n("Toolbar Menu")); 2112//US context->insertTitle(i18n("Toolbar Menu"));
2103 2113
2104//US KPopupMenu *orient = new KPopupMenu( context, "orient" ); 2114//US KPopupMenu *orient = new KPopupMenu( context, "orient" );
2105 QPopupMenu *orient = new QPopupMenu( context, "orient" ); 2115 QPopupMenu *orient = new QPopupMenu( context, "orient" );
2106 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); 2116 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP );
2107 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); 2117 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT );
2108 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); 2118 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT );
2109 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); 2119 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
2110 orient->insertSeparator(-1); 2120 orient->insertSeparator(-1);
2111 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); 2121 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
2112 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); 2122 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT );
2113 2123
2114//US KPopupMenu *mode = new KPopupMenu( context, "mode" ); 2124//US KPopupMenu *mode = new KPopupMenu( context, "mode" );
2115 QPopupMenu *mode = new QPopupMenu( context, "mode" ); 2125 QPopupMenu *mode = new QPopupMenu( context, "mode" );
2116 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); 2126 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS );
2117 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); 2127 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT );
2118 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); 2128 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT );
2119 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); 2129 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER );
2120 2130
2121//US KPopupMenu *size = new KPopupMenu( context, "size" ); 2131//US KPopupMenu *size = new KPopupMenu( context, "size" );
2122 QPopupMenu *size = new QPopupMenu( context, "size" ); 2132 QPopupMenu *size = new QPopupMenu( context, "size" );
2123 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); 2133 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES );
2124 // Query the current theme for available sizes 2134 // Query the current theme for available sizes
2125 QValueList<int> avSizes; 2135 QValueList<int> avSizes;
2126/*US 2136/*US
2127 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); 2137 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme();
2128 if (!::qstrcmp(QObject::name(), "mainToolBar")) 2138 if (!::qstrcmp(QObject::name(), "mainToolBar"))
2129 avSizes = theme->querySizes( KIcon::MainToolbar); 2139 avSizes = theme->querySizes( KIcon::MainToolbar);
2130 else 2140 else
2131 avSizes = theme->querySizes( KIcon::Toolbar); 2141 avSizes = theme->querySizes( KIcon::Toolbar);
2132*/ 2142*/
2133 avSizes << 16; 2143 avSizes << 16;
2134 avSizes << 32; 2144 avSizes << 32;
2135 2145
2136 d->iconSizes = avSizes; 2146 d->iconSizes = avSizes;
2137 2147
2138 QValueList<int>::Iterator it; 2148 QValueList<int>::Iterator it;
2139 for (it=avSizes.begin(); it!=avSizes.end(); it++) { 2149 for (it=avSizes.begin(); it!=avSizes.end(); it++) {
2140 QString text; 2150 QString text;
2141 if ( *it < 19 ) 2151 if ( *it < 19 )
2142 text = i18n("Small (%1x%2)").arg(*it).arg(*it); 2152 text = i18n("Small (%1x%2)").arg(*it).arg(*it);
2143 else if (*it < 25) 2153 else if (*it < 25)
2144 text = i18n("Medium (%1x%2)").arg(*it).arg(*it); 2154 text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
2145 else 2155 else
2146 text = i18n("Large (%1x%2)").arg(*it).arg(*it); 2156 text = i18n("Large (%1x%2)").arg(*it).arg(*it);
2147 //we use the size as an id, with an offset 2157 //we use the size as an id, with an offset
2148 size->insertItem( text, CONTEXT_ICONSIZES + *it ); 2158 size->insertItem( text, CONTEXT_ICONSIZES + *it );
2149 } 2159 }
2150 2160
2151 context->insertItem( i18n("Orientation"), orient ); 2161 context->insertItem( i18n("Orientation"), orient );
2152 orient->setItemChecked(CONTEXT_TOP, true); 2162 orient->setItemChecked(CONTEXT_TOP, true);
2153 context->insertItem( i18n("Text Position"), mode ); 2163 context->insertItem( i18n("Text Position"), mode );
2154 context->setItemChecked(CONTEXT_ICONS, true); 2164 context->setItemChecked(CONTEXT_ICONS, true);
2155 context->insertItem( i18n("Icon Size"), size ); 2165 context->insertItem( i18n("Icon Size"), size );
2156 2166
2157/*US 2167/*US
2158 if (mainWindow()->inherits("KMainWindow")) 2168 if (mainWindow()->inherits("KMainWindow"))
2159 { 2169 {
2160 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && 2170 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) &&
2161 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) 2171 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) )
2162 2172
2163 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); 2173 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context);
2164 } 2174 }
2165*/ 2175*/
2166 2176
2167 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); 2177 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) );
2168 return context; 2178 return context;
2169} 2179}
2170 2180
2171void KToolBar::slotContextAboutToShow() 2181void KToolBar::slotContextAboutToShow()
2172{ 2182{
2173 if (!d->m_configurePlugged) 2183 if (!d->m_configurePlugged)
2174 { 2184 {
2175 // try to find "configure toolbars" action 2185 // try to find "configure toolbars" action
2176 2186
2177 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; 2187 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient;
2178 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 2188 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
2179 xmlGuiClient = (KXMLGUIClient *)mainWindow(); 2189 xmlGuiClient = (KXMLGUIClient *)mainWindow();
2180 if ( xmlGuiClient ) 2190 if ( xmlGuiClient )
2181 { 2191 {
2182 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); 2192 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars));
2183 if ( configureAction ) 2193 if ( configureAction )
2184 { 2194 {
2185 configureAction->plug(context); 2195 configureAction->plug(context);
2186 d->m_configurePlugged = true; 2196 d->m_configurePlugged = true;
2187 } 2197 }
2188 } 2198 }
2189 } 2199 }
2190 2200
2191 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) 2201 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i)
2192 context->setItemChecked(i, false); 2202 context->setItemChecked(i, false);
2193 2203
2194 switch( d->m_iconText ) 2204 switch( d->m_iconText )
2195 { 2205 {
2196 case IconOnly: 2206 case IconOnly:
2197 default: 2207 default:
2198 context->setItemChecked(CONTEXT_ICONS, true); 2208 context->setItemChecked(CONTEXT_ICONS, true);
2199 break; 2209 break;
2200 case IconTextRight: 2210 case IconTextRight:
2201 context->setItemChecked(CONTEXT_TEXTRIGHT, true); 2211 context->setItemChecked(CONTEXT_TEXTRIGHT, true);
2202 break; 2212 break;
2203 case TextOnly: 2213 case TextOnly:
2204 context->setItemChecked(CONTEXT_TEXT, true); 2214 context->setItemChecked(CONTEXT_TEXT, true);
2205 break; 2215 break;
2206 case IconTextBottom: 2216 case IconTextBottom:
2207 context->setItemChecked(CONTEXT_TEXTUNDER, true); 2217 context->setItemChecked(CONTEXT_TEXTUNDER, true);
2208 break; 2218 break;
2209 } 2219 }
2210 2220
2211 QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); 2221 QValueList<int>::ConstIterator iIt = d->iconSizes.begin();
2212 QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); 2222 QValueList<int>::ConstIterator iEnd = d->iconSizes.end();
2213 for (; iIt != iEnd; ++iIt ) 2223 for (; iIt != iEnd; ++iIt )
2214 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); 2224 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false );
2215 2225
2216 context->setItemChecked( CONTEXT_ICONSIZES, false ); 2226 context->setItemChecked( CONTEXT_ICONSIZES, false );
2217 2227
2218 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); 2228 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true );
2219 2229
2220 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) 2230 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i )
2221 context->setItemChecked( i, false ); 2231 context->setItemChecked( i, false );
2222 2232
2223 switch ( barPos() ) 2233 switch ( barPos() )
2224 { 2234 {
2225 case KToolBar::Flat: 2235 case KToolBar::Flat:
2226 context->setItemChecked( CONTEXT_FLAT, true ); 2236 context->setItemChecked( CONTEXT_FLAT, true );
2227 break; 2237 break;
2228 case KToolBar::Bottom: 2238 case KToolBar::Bottom:
2229 context->setItemChecked( CONTEXT_BOTTOM, true ); 2239 context->setItemChecked( CONTEXT_BOTTOM, true );
2230 break; 2240 break;
2231 case KToolBar::Left: 2241 case KToolBar::Left:
2232 context->setItemChecked( CONTEXT_LEFT, true ); 2242 context->setItemChecked( CONTEXT_LEFT, true );
2233 break; 2243 break;
2234 case KToolBar::Right: 2244 case KToolBar::Right:
2235 context->setItemChecked( CONTEXT_RIGHT, true ); 2245 context->setItemChecked( CONTEXT_RIGHT, true );
2236 break; 2246 break;
2237 case KToolBar::Floating: 2247 case KToolBar::Floating:
2238 context->setItemChecked( CONTEXT_FLOAT, true ); 2248 context->setItemChecked( CONTEXT_FLOAT, true );
2239 break; 2249 break;
2240 case KToolBar::Top: 2250 case KToolBar::Top:
2241 context->setItemChecked( CONTEXT_TOP, true ); 2251 context->setItemChecked( CONTEXT_TOP, true );
2242 break; 2252 break;
2243 default: break; 2253 default: break;
2244 } 2254 }
2245} 2255}
2246 2256
2247void KToolBar::widgetDestroyed() 2257void KToolBar::widgetDestroyed()
2248{ 2258{
2249 removeWidgetInternal( (QWidget*)sender() ); 2259 removeWidgetInternal( (QWidget*)sender() );
2250} 2260}
2251 2261
2252void KToolBar::removeWidgetInternal( QWidget * w ) 2262void KToolBar::removeWidgetInternal( QWidget * w )
2253{ 2263{
2254 if ( inshutdownprocess ) 2264 if ( inshutdownprocess )
2255 return; 2265 return;
2256 widgets.removeRef( w ); 2266 widgets.removeRef( w );
2257 QMap< QWidget*, int >::Iterator it = widget2id.find( w ); 2267 QMap< QWidget*, int >::Iterator it = widget2id.find( w );
2258 if ( it == widget2id.end() ) 2268 if ( it == widget2id.end() )
2259 return; 2269 return;
2260 id2widget.remove( *it ); 2270 id2widget.remove( *it );
2261 widget2id.remove( it ); 2271 widget2id.remove( it );
2262} 2272}
2263 2273
2264void KToolBar::virtual_hook( int, void* ) 2274void KToolBar::virtual_hook( int, void* )
2265{ /*BASE::virtual_hook( id, data );*/ } 2275{ /*BASE::virtual_hook( id, data );*/ }
2266 2276
2267//US #include "ktoolbar.moc" 2277//US #include "ktoolbar.moc"
2268 2278
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h
index 7a5c114..3319fa8 100644
--- a/microkde/kdeui/ktoolbar.h
+++ b/microkde/kdeui/ktoolbar.h
@@ -1,1108 +1,1110 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org) 2 Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org)
3 (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 3 (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
4 (C) 1997, 1998 Sven Radej (radej@kde.org) 4 (C) 1997, 1998 Sven Radej (radej@kde.org)
5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
6 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999, 2000 Kurt Granroth (granroth@kde.org) 7 (C) 1999, 2000 Kurt Granroth (granroth@kde.org)
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License version 2 as published by the Free Software Foundation. 11 License version 2 as published by the Free Software Foundation.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22 */ 22 */
23 23
24#ifndef KTOOLBAR_H 24#ifndef KTOOLBAR_H
25#define KTOOLBAR_H 25#define KTOOLBAR_H
26 26
27#ifndef DESKTOP_VERSION 27#ifndef DESKTOP_VERSION
28#define private public 28#define private public
29#include <qtoolbar.h> 29#include <qtoolbar.h>
30#undef private 30#undef private
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32#else 32#else
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#endif 34#endif
35 35
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qmap.h> 39#include <qmap.h>
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include <kglobal.h> 41#include <kglobal.h>
42#include <qguardedptr.h> 42#include <qguardedptr.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qiconset.h> 44#include <qiconset.h>
45 45
46class QDomElement; 46class QDomElement;
47class QSize; 47class QSize;
48class QPixmap; 48class QPixmap;
49class QPopupMenu; 49class QPopupMenu;
50class QStringList; 50class QStringList;
51class QDomDocument; 51class QDomDocument;
52class QTimer; 52class QTimer;
53 53
54class KLineEdit; 54class KLineEdit;
55class KToolBar; 55class KToolBar;
56class KToolBarButton; 56class KToolBarButton;
57class KToolBoxManager; 57class KToolBoxManager;
58//US class KAnimWidget; 58//US class KAnimWidget;
59//US class KPopupMenu; 59//US class KPopupMenu;
60//US class KInstance; 60//US class KInstance;
61class KComboBox; 61class KComboBox;
62class KXMLGUIClient; 62class KXMLGUIClient;
63 63
64class KToolBarPrivate; 64class KToolBarPrivate;
65 65
66class KToolBarSeparator : public QFrame 66class KToolBarSeparator : public QFrame
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69public: 69public:
70 KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 ); 70 KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 );
71 71
72 QSize sizeHint() const; 72 QSize sizeHint() const;
73 Orientation orientation() const { return orient; } 73 Orientation orientation() const { return orient; }
74 QSizePolicy sizePolicy() const; 74 QSizePolicy sizePolicy() const;
75 bool showLine() const { return line; } 75 bool showLine() const { return line; }
76public slots: 76public slots:
77 void setOrientation( Orientation ); 77 void setOrientation( Orientation );
78protected: 78protected:
79 void styleChange( QStyle& ); 79 void styleChange( QStyle& );
80private: 80private:
81 Orientation orient; 81 Orientation orient;
82 bool line; 82 bool line;
83}; 83};
84 84
85 85
86 /** 86 /**
87 * A KDE-style toolbar. 87 * A KDE-style toolbar.
88 * 88 *
89 * KToolBar can be dragged around in and between different docks. 89 * KToolBar can be dragged around in and between different docks.
90 * 90 *
91 * A KToolBar can contain all sorts of widgets. 91 * A KToolBar can contain all sorts of widgets.
92 * 92 *
93 * KToolBar can be used as a standalone widget, but @ref KMainWindow 93 * KToolBar can be used as a standalone widget, but @ref KMainWindow
94 * provides easy factories and management of one or more toolbars. 94 * provides easy factories and management of one or more toolbars.
95 * Once you have a KToolBar object, you can insert items into it with the 95 * Once you have a KToolBar object, you can insert items into it with the
96 * insert... methods, or remove them with the @ref removeItem() method. This 96 * insert... methods, or remove them with the @ref removeItem() method. This
97 * can be done at any time; the toolbar will be automatically updated. 97 * can be done at any time; the toolbar will be automatically updated.
98 * There are also many methods to set per-child properties like alignment 98 * There are also many methods to set per-child properties like alignment
99 * and toggle behaviour. 99 * and toggle behaviour.
100 * 100 *
101 * KToolBar uses a global config group to load toolbar settings on 101 * KToolBar uses a global config group to load toolbar settings on
102 * construction. It will reread this config group on a 102 * construction. It will reread this config group on a
103 * @ref KApplication::appearanceChanged() signal. 103 * @ref KApplication::appearanceChanged() signal.
104 * 104 *
105 * @short Floatable toolbar with auto resize. 105 * @short Floatable toolbar with auto resize.
106 * @version $Id$ 106 * @version $Id$
107 * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>. 107 * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>.
108 */ 108 */
109 109
110// strange things are happening ... so I have to use strange define methods ... 110// strange things are happening ... so I have to use strange define methods ...
111// porting KToolBar back to Qt2 really needs some strange hacks 111// porting KToolBar back to Qt2 really needs some strange hacks
112 112
113#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
114#define QToolBar QPEToolBar 114#define QToolBar QPEToolBar
115#endif 115#endif
116 116
117 class KToolBar : public QToolBar 117 class KToolBar : public QToolBar
118{ 118{
119 Q_OBJECT 119 Q_OBJECT
120 120
121 121
122 Q_ENUMS( IconText BarPosition ) 122 Q_ENUMS( IconText BarPosition )
123 123
124 Q_PROPERTY( IconText iconText READ iconText WRITE setIconText ) 124 Q_PROPERTY( IconText iconText READ iconText WRITE setIconText )
125 Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos ) 125 Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos )
126 Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize ) 126 Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize )
127 Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize ) 127 Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize )
128 Q_PROPERTY( QString text READ text WRITE setText ) 128 Q_PROPERTY( QString text READ text WRITE setText )
129#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
130#undef QToolBar 130#undef QToolBar
131#endif 131#endif
132public: 132public:
133 enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom}; 133 enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom};
134 /** 134 /**
135 * The state of the status bar. 135 * The state of the status bar.
136 * @deprecated 136 * @deprecated
137 **/ 137 **/
138 enum BarStatus{Toggle, Show, Hide}; 138 enum BarStatus{Toggle, Show, Hide};
139 /** 139 /**
140 * Possible bar positions. 140 * Possible bar positions.
141 **/ 141 **/
142 enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat}; 142 enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat};
143 143
144 /** 144 /**
145 * Constructor. 145 * Constructor.
146 * This constructor is used by the XML-GUI. If you use it, you need 146 * This constructor is used by the XML-GUI. If you use it, you need
147 * to call QMainWindow::addToolBar to specify the position of the toolbar. 147 * to call QMainWindow::addToolBar to specify the position of the toolbar.
148 * So it's simpler to use the other constructor. 148 * So it's simpler to use the other constructor.
149 * 149 *
150 * The toolbar will read in various global config settings for 150 * The toolbar will read in various global config settings for
151 * things like icon size and text position, etc. However, some of 151 * things like icon size and text position, etc. However, some of
152 * the settings will be honored only if @ref #_honor_mode is set to 152 * the settings will be honored only if @ref #_honor_mode is set to
153 * true. All other toolbars will be IconOnly and use Medium icons. 153 * true. All other toolbars will be IconOnly and use Medium icons.
154 * 154 *
155 * @param parent The standard toolbar parent (usually a 155 * @param parent The standard toolbar parent (usually a
156 * @ref KMainWindow) 156 * @ref KMainWindow)
157 * @param name The standard internal name 157 * @param name The standard internal name
158 * @param honor_style If true, then global settings for IconSize and IconText will be honored 158 * @param honor_style If true, then global settings for IconSize and IconText will be honored
159 * @param readConfig whether to apply the configuration (global and application-specific) 159 * @param readConfig whether to apply the configuration (global and application-specific)
160 */ 160 */
161 KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 161 KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
162 162
163 /** 163 /**
164 * Constructor for non-XML-GUI applications. 164 * Constructor for non-XML-GUI applications.
165 * 165 *
166 * The toolbar will read in various global config settings for 166 * The toolbar will read in various global config settings for
167 * things like icon size and text position, etc. However, some of 167 * things like icon size and text position, etc. However, some of
168 * the settings will be honored only if @ref #_honor_mode is set to 168 * the settings will be honored only if @ref #_honor_mode is set to
169 * true. All other toolbars will be IconOnly and use Medium icons. 169 * true. All other toolbars will be IconOnly and use Medium icons.
170 * 170 *
171 * @param parentWindow The window that should be the parent of this toolbar 171 * @param parentWindow The window that should be the parent of this toolbar
172 * @param dock The position of the toolbar. Usually QMainWindow::Top. 172 * @param dock The position of the toolbar. Usually QMainWindow::Top.
173 * @param newLine If true, start a new line in the dock for this toolbar. 173 * @param newLine If true, start a new line in the dock for this toolbar.
174 * @param name The standard internal name 174 * @param name The standard internal name
175 * @param honor_style If true, then global settings for IconSize and IconText will be honored 175 * @param honor_style If true, then global settings for IconSize and IconText will be honored
176 * @param readConfig whether to apply the configuration (global and application-specific) 176 * @param readConfig whether to apply the configuration (global and application-specific)
177 */ 177 */
178 KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, 178 KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false,
179 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 179 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
180 180
181 /** 181 /**
182 * Constructor for non-XML-GUI applications. 182 * Constructor for non-XML-GUI applications.
183 * 183 *
184 * The toolbar will read in various global config settings for 184 * The toolbar will read in various global config settings for
185 * things like icon size and text position, etc. However, some of 185 * things like icon size and text position, etc. However, some of
186 * the settings will be honored only if @ref #_honor_mode is set to 186 * the settings will be honored only if @ref #_honor_mode is set to
187 * true. All other toolbars will be IconOnly and use Medium icons. 187 * true. All other toolbars will be IconOnly and use Medium icons.
188 * 188 *
189 * @param parentWindow The window that should be the parent of this toolbar 189 * @param parentWindow The window that should be the parent of this toolbar
190 * @param dock Another widget than the mainwindow to dock toolbar to. 190 * @param dock Another widget than the mainwindow to dock toolbar to.
191 * @param newLine If true, start a new line in the dock for this toolbar. 191 * @param newLine If true, start a new line in the dock for this toolbar.
192 * @param name The standard internal name 192 * @param name The standard internal name
193 * @param honor_style If true, then global settings for IconSize and IconText will be honored 193 * @param honor_style If true, then global settings for IconSize and IconText will be honored
194 * @param readConfig whether to apply the configuration (global and application-specific) 194 * @param readConfig whether to apply the configuration (global and application-specific)
195 */ 195 */
196 KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false, 196 KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false,
197 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 197 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
198 198
199 virtual ~KToolBar(); 199 virtual ~KToolBar();
200 200
201 /** 201 /**
202 * Insert a button (a @ref KToolBarButton) with a pixmap. The 202 * Insert a button (a @ref KToolBarButton) with a pixmap. The
203 * pixmap is loaded by the button itself based on the global icon 203 * pixmap is loaded by the button itself based on the global icon
204 * settings. 204 * settings.
205 * 205 *
206 * You should connect to one or more signals in KToolBar: 206 * You should connect to one or more signals in KToolBar:
207 * @ref clicked() , @ref pressed() , @ref released() , or 207 * @ref clicked() , @ref pressed() , @ref released() , or
208 * @ref highlighted() and if the button is a toggle button 208 * @ref highlighted() and if the button is a toggle button
209 * (@ref setToggle() ) @ref toggled() . Those signals have @p id 209 * (@ref setToggle() ) @ref toggled() . Those signals have @p id
210 * of a button that caused the signal. If you want to bind a popup 210 * of a button that caused the signal. If you want to bind a popup
211 * to button, see @ref setButton(). 211 * to button, see @ref setButton().
212 * 212 *
213 * @param icon The name of the icon to use as the active pixmap 213 * @param icon The name of the icon to use as the active pixmap
214 * @param id The id of this button 214 * @param id The id of this button
215 * @param enabled Enable or disable the button at startup 215 * @param enabled Enable or disable the button at startup
216 * @param text The tooltip or toolbar text (depending on state) 216 * @param text The tooltip or toolbar text (depending on state)
217 * @param index The position of the button. (-1 = at end). 217 * @param index The position of the button. (-1 = at end).
218 * 218 *
219 * @return The item index. 219 * @return The item index.
220 */ 220 */
221 int insertButton(const QString& icon, int id, bool enabled = true, 221 int insertButton(const QString& icon, int id, bool enabled = true,
222 const QString& text = QString::null, int index=-1/*US , 222 const QString& text = QString::null, int index=-1/*US ,
223 KInstance *_instance = KGlobal::instance()*/); 223 KInstance *_instance = KGlobal::instance()*/);
224 224
225 /** 225 /**
226 * This is the same as above, but with specified signals and 226 * This is the same as above, but with specified signals and
227 * slots to which this button will be connected. 227 * slots to which this button will be connected.
228 * 228 *
229 * You can add more signals with @ref addConnection(). 229 * You can add more signals with @ref addConnection().
230 * 230 *
231 * @param icon The name of the icon to use as the active pixmap 231 * @param icon The name of the icon to use as the active pixmap
232 * @param id The id of this button 232 * @param id The id of this button
233 * @param signal The signal to connect to 233 * @param signal The signal to connect to
234 * @param receiver The slot's parent 234 * @param receiver The slot's parent
235 * @param enabled Enable or disable the button at startup 235 * @param enabled Enable or disable the button at startup
236 * @param text The tooltip or toolbar text (depending on state) 236 * @param text The tooltip or toolbar text (depending on state)
237 * @param index The position of the button. (-1 = at end). 237 * @param index The position of the button. (-1 = at end).
238 * 238 *
239 * @return The item index. 239 * @return The item index.
240 */ 240 */
241 int insertButton(const QString& icon, int id, const char *signal, 241 int insertButton(const QString& icon, int id, const char *signal,
242 const QObject *receiver, const char *slot, 242 const QObject *receiver, const char *slot,
243 bool enabled = true, const QString& text = QString::null, 243 bool enabled = true, const QString& text = QString::null,
244 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ ); 244 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ );
245 245
246 /** 246 /**
247 * Inserts a button (a @ref KToolBarButton) with the specified 247 * Inserts a button (a @ref KToolBarButton) with the specified
248 * pixmap. This pixmap will be used as the "active" one and the 248 * pixmap. This pixmap will be used as the "active" one and the
249 * disabled and default ones will be autogenerated. 249 * disabled and default ones will be autogenerated.
250 * 250 *
251 * It is recommended that you use the insertButton function that 251 * It is recommended that you use the insertButton function that
252 * allows you to specify the icon name rather then the pixmap 252 * allows you to specify the icon name rather then the pixmap
253 * itself. Specifying the icon name is much more flexible. 253 * itself. Specifying the icon name is much more flexible.
254 * 254 *
255 * You should connect to one or more signals in KToolBar: 255 * You should connect to one or more signals in KToolBar:
256 * @ref clicked() , @ref pressed() , @ref released() , or 256 * @ref clicked() , @ref pressed() , @ref released() , or
257 * @ref highlighted() and if the button is a toggle button 257 * @ref highlighted() and if the button is a toggle button
258 * (@ref setToggle() ) @ref toggled() . Those signals have @p id 258 * (@ref setToggle() ) @ref toggled() . Those signals have @p id
259 * of a button that caused the signal. If you want to bind a popup 259 * of a button that caused the signal. If you want to bind a popup
260 * to button, see @ref setButton(). 260 * to button, see @ref setButton().
261 * 261 *
262 * @param pixmap The active pixmap 262 * @param pixmap The active pixmap
263 * @param id The id of this button 263 * @param id The id of this button
264 * @param enabled Enable or disable the button at startup 264 * @param enabled Enable or disable the button at startup
265 * @param text The tooltip or toolbar text (depending on state) 265 * @param text The tooltip or toolbar text (depending on state)
266 * @param index The position of the button. (-1 = at end). 266 * @param index The position of the button. (-1 = at end).
267 * 267 *
268 * @return The item index. 268 * @return The item index.
269 */ 269 */
270 int insertButton(const QPixmap& pixmap, int id, bool enabled = true, 270 int insertButton(const QPixmap& pixmap, int id, bool enabled = true,
271 const QString& text = QString::null, int index=-1 ); 271 const QString& text = QString::null, int index=-1 );
272 272
273 /** 273 /**
274 * This is the same as above, but with specified signals and 274 * This is the same as above, but with specified signals and
275 * slots to which this button will be connected. 275 * slots to which this button will be connected.
276 * 276 *
277 * You can add more signals with @ref addConnection(). 277 * You can add more signals with @ref addConnection().
278 * 278 *
279 * @param icon The name of the icon to use as the active pixmap 279 * @param icon The name of the icon to use as the active pixmap
280 * @param id The id of this button 280 * @param id The id of this button
281 * @param signal The signal to connect to 281 * @param signal The signal to connect to
282 * @param receiver The slot's parent 282 * @param receiver The slot's parent
283 * @param enabled Enable or disable the button at startup 283 * @param enabled Enable or disable the button at startup
284 * @param text The tooltip or toolbar text (depending on state) 284 * @param text The tooltip or toolbar text (depending on state)
285 * @param index The position of the button. (-1 = at end). 285 * @param index The position of the button. (-1 = at end).
286 * 286 *
287 * @return The item index. 287 * @return The item index.
288 */ 288 */
289 int insertButton(const QPixmap& pixmap, int id, const char *signal, 289 int insertButton(const QPixmap& pixmap, int id, const char *signal,
290 const QObject *receiver, const char *slot, 290 const QObject *receiver, const char *slot,
291 bool enabled = true, const QString& text = QString::null, 291 bool enabled = true, const QString& text = QString::null,
292 int index=-1 ); 292 int index=-1 );
293 293
294 /** 294 /**
295 * Inserts a button with popupmenu. 295 * Inserts a button with popupmenu.
296 * 296 *
297 * Button will have small 297 * Button will have small
298 * triangle. You have to connect to popup's signals. The 298 * triangle. You have to connect to popup's signals. The
299 * signals @ref KButton::pressed(), @ref KButton::released(), 299 * signals @ref KButton::pressed(), @ref KButton::released(),
300 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 300 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
301 * emmited by 301 * emmited by
302 * this button (see @ref setDelayedPopup() for that). 302 * this button (see @ref setDelayedPopup() for that).
303 * You can add custom popups which inherit @ref QPopupMenu to get popups 303 * You can add custom popups which inherit @ref QPopupMenu to get popups
304 * with tables, drawings etc. Just don't fiddle with events there. 304 * with tables, drawings etc. Just don't fiddle with events there.
305 */ 305 */
306 int insertButton(const QString& icon, int id, QPopupMenu *popup, 306 int insertButton(const QString& icon, int id, QPopupMenu *popup,
307 bool enabled, const QString&_text, int index=-1); 307 bool enabled, const QString&_text, int index=-1);
308 308
309 /** 309 /**
310 * Inserts a button with popupmenu. 310 * Inserts a button with popupmenu.
311 * 311 *
312 * Button will have small 312 * Button will have small
313 * triangle. You have to connect to popup's signals. The 313 * triangle. You have to connect to popup's signals. The
314 * signals @ref KButton::pressed(), @ref KButton::released(), 314 * signals @ref KButton::pressed(), @ref KButton::released(),
315 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 315 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
316 * emmited by 316 * emmited by
317 * this button (see @ref setDelayedPopup() for that). 317 * this button (see @ref setDelayedPopup() for that).
318 * You can add custom popups which inherit @ref QPopupMenu to get popups 318 * You can add custom popups which inherit @ref QPopupMenu to get popups
319 * with tables, drawings etc. Just don't fiddle with events there. 319 * with tables, drawings etc. Just don't fiddle with events there.
320 */ 320 */
321 int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 321 int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
322 bool enabled, const QString&_text, int index=-1); 322 bool enabled, const QString&_text, int index=-1);
323 323
324 /** 324 /**
325 * Inserts a @ref KLineEdit. You have to specify signals and slots to 325 * Inserts a @ref KLineEdit. You have to specify signals and slots to
326 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit 326 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit
327 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation 327 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation
328 * KLineEdit can be set to autoresize itself to full free width 328 * KLineEdit can be set to autoresize itself to full free width
329 * in toolbar, that is to last right aligned item. For that, 329 * in toolbar, that is to last right aligned item. For that,
330 * toolbar must be set to full width (which it is by default). 330 * toolbar must be set to full width (which it is by default).
331 * @see setFullWidth() 331 * @see setFullWidth()
332 * @see setItemAutoSized() 332 * @see setItemAutoSized()
333 * @see KLineEdit 333 * @see KLineEdit
334 * @return Item index. 334 * @return Item index.
335 */ 335 */
336 int insertLined (const QString& text, int id, 336 int insertLined (const QString& text, int id,
337 const char *signal, 337 const char *signal,
338 const QObject *receiver, const char *slot, 338 const QObject *receiver, const char *slot,
339 bool enabled = true, 339 bool enabled = true,
340 const QString& toolTipText = QString::null, 340 const QString& toolTipText = QString::null,
341 int size = 70, int index =-1); 341 int size = 70, int index =-1);
342 342
343 /** 343 /**
344 * Inserts a @ref KComboBox with list. 344 * Inserts a @ref KComboBox with list.
345 * 345 *
346 * Can be writable, but cannot contain 346 * Can be writable, but cannot contain
347 * pixmaps. By default inserting policy is AtBottom, i.e. typed items 347 * pixmaps. By default inserting policy is AtBottom, i.e. typed items
348 * are placed at the bottom of the list. Can be autosized. If the size 348 * are placed at the bottom of the list. Can be autosized. If the size
349 * argument is specified as -1, the width of the combobox is automatically 349 * argument is specified as -1, the width of the combobox is automatically
350 * computed. 350 * computed.
351 * 351 *
352 * @see setFullWidth() 352 * @see setFullWidth()
353 * @see setItemAutoSized() 353 * @see setItemAutoSized()
354 * @see KComboBox 354 * @see KComboBox
355 * @return Item index. 355 * @return Item index.
356 */ 356 */
357 int insertCombo (const QStringList &list, int id, bool writable, 357 int insertCombo (const QStringList &list, int id, bool writable,
358 const char *signal, const QObject *receiver, 358 const char *signal, const QObject *receiver,
359 const char *slot, bool enabled=true, 359 const char *slot, bool enabled=true,
360 const QString& tooltiptext=QString::null, 360 const QString& tooltiptext=QString::null,
361 int size=70, int index=-1, 361 int size=70, int index=-1,
362 QComboBox::Policy policy = QComboBox::AtBottom); 362 QComboBox::Policy policy = QComboBox::AtBottom);
363 363
364 /** 364 /**
365 * Insert a @ref KComboBox with text. 365 * Insert a @ref KComboBox with text.
366 * 366 *
367 * The rest is the same as above. 367 * The rest is the same as above.
368 * @see setItemAutoSized() 368 * @see setItemAutoSized()
369 * 369 *
370 * @see KComboBox 370 * @see KComboBox
371 * @return Item index. 371 * @return Item index.
372 */ 372 */
373 int insertCombo (const QString& text, int id, bool writable, 373 int insertCombo (const QString& text, int id, bool writable,
374 const char *signal, QObject *recevier, 374 const char *signal, QObject *recevier,
375 const char *slot, bool enabled=true, 375 const char *slot, bool enabled=true,
376 const QString& tooltiptext=QString::null, 376 const QString& tooltiptext=QString::null,
377 int size=70, int index=-1, 377 int size=70, int index=-1,
378 QComboBox::Policy policy = QComboBox::AtBottom); 378 QComboBox::Policy policy = QComboBox::AtBottom);
379 379
380 /** 380 /**
381 * Inserts a separator into the toolbar with the given id. 381 * Inserts a separator into the toolbar with the given id.
382 * Returns the separator's index 382 * Returns the separator's index
383 */ 383 */
384 int insertSeparator( int index = -1, int id = -1 ); 384 int insertSeparator( int index = -1, int id = -1 );
385 385
386 /** 386 /**
387 * Inserts a line separator into the toolbar with the given id. 387 * Inserts a line separator into the toolbar with the given id.
388 * Returns the separator's index 388 * Returns the separator's index
389 */ 389 */
390 int insertLineSeparator( int index = -1, int id = -1 ); 390 int insertLineSeparator( int index = -1, int id = -1 );
391 391
392 /** 392 /**
393 * Inserts a user-defined widget. The widget @p must have this 393 * Inserts a user-defined widget. The widget @p must have this
394 * toolbar as its parent. 394 * toolbar as its parent.
395 * 395 *
396 * Widget must have a QWidget for base class. Widget can be 396 * Widget must have a QWidget for base class. Widget can be
397 * autosized to full width. If you forget about it, you can get a 397 * autosized to full width. If you forget about it, you can get a
398 * pointer to this widget with @ref getWidget(). 398 * pointer to this widget with @ref getWidget().
399 * @see setItemAutoSized() 399 * @see setItemAutoSized()
400 * @return Item index. 400 * @return Item index.
401 */ 401 */
402 int insertWidget(int id, int width, QWidget *_widget, int index=-1); 402 int insertWidget(int id, int width, QWidget *_widget, int index=-1);
403 403
404 /** 404 /**
405 * Inserts an animated widget. A @ref KAnimWidget will be created 405 * Inserts an animated widget. A @ref KAnimWidget will be created
406 * internally using the icon name you provide. 406 * internally using the icon name you provide.
407 * This will emit a signal (clicked()) whenever the 407 * This will emit a signal (clicked()) whenever the
408 * animation widget is clicked. 408 * animation widget is clicked.
409 * 409 *
410 * @see animatedWidget() 410 * @see animatedWidget()
411 * 411 *
412 * @param id The id for this toolbar item 412 * @param id The id for this toolbar item
413 * @param receiver The parent of your slot 413 * @param receiver The parent of your slot
414 * @param slot The slot to receive the clicked() signal 414 * @param slot The slot to receive the clicked() signal
415 * @param icons The name of the animation icon group to use 415 * @param icons The name of the animation icon group to use
416 * @param index The item index 416 * @param index The item index
417 * 417 *
418 * @return The item index 418 * @return The item index
419 */ 419 */
420/*US 420/*US
421 int insertAnimatedWidget(int id, QObject *receiver, const char *slot, 421 int insertAnimatedWidget(int id, QObject *receiver, const char *slot,
422 const QString& icons, int index = -1); 422 const QString& icons, int index = -1);
423*/ 423*/
424 /** 424 /**
425 * This will return a pointer to the given animated widget, if it 425 * This will return a pointer to the given animated widget, if it
426 * exists. 426 * exists.
427 * 427 *
428 * @see insertAnimatedWidget 428 * @see insertAnimatedWidget
429 * 429 *
430 * @param id The id for the widget you want to get a pointer to 430 * @param id The id for the widget you want to get a pointer to
431 * 431 *
432 * @return A pointer to the current animated widget or 0L 432 * @return A pointer to the current animated widget or 0L
433 */ 433 */
434//US KAnimWidget *animatedWidget( int id ); 434//US KAnimWidget *animatedWidget( int id );
435 435
436 /** 436 /**
437 * Adds connections to items. 437 * Adds connections to items.
438 * 438 *
439 * It is important that you 439 * It is important that you
440 * know the @p id of particular item. Nothing happens if you forget @p id. 440 * know the @p id of particular item. Nothing happens if you forget @p id.
441 */ 441 */
442 void addConnection (int id, const char *signal, 442 void addConnection (int id, const char *signal,
443 const QObject *receiver, const char *slot); 443 const QObject *receiver, const char *slot);
444 /** 444 /**
445 * Enables/disables item. 445 * Enables/disables item.
446 */ 446 */
447 void setItemEnabled( int id, bool enabled ); 447 void setItemEnabled( int id, bool enabled );
448 448
449 /** 449 /**
450 * Sets the icon for a button. 450 * Sets the icon for a button.
451 * 451 *
452 * Can be used while button is visible. 452 * Can be used while button is visible.
453 */ 453 */
454 void setButtonIcon( int id, const QString& _icon ); 454 void setButtonIcon( int id, const QString& _icon );
455 455
456 /** 456 /**
457 * Sets button pixmap. 457 * Sets button pixmap.
458 * 458 *
459 * Can be used while button is visible. 459 * Can be used while button is visible.
460 */ 460 */
461 void setButtonPixmap( int id, const QPixmap& _pixmap ); 461 void setButtonPixmap( int id, const QPixmap& _pixmap );
462 462
463 /** 463 /**
464 * Sets a button icon from a QIconSet. 464 * Sets a button icon from a QIconSet.
465 * 465 *
466 * Can be used while button is visible. 466 * Can be used while button is visible.
467 */ 467 */
468 void setButtonIconSet( int id, const QIconSet& iconset ); 468 void setButtonIconSet( int id, const QIconSet& iconset );
469 469
470 /** 470 /**
471 * Sets a delayed popup for a button. 471 * Sets a delayed popup for a button.
472 * 472 *
473 * Delayed popup is what you see in 473 * Delayed popup is what you see in
474 * Netscape Navigator's Previous and Next buttons: If you click them you 474 * Netscape Navigator's Previous and Next buttons: If you click them you
475 * go back 475 * go back
476 * or forth. If you press them long enough, you get a history-menu. 476 * or forth. If you press them long enough, you get a history-menu.
477 * This is exactly what we do here. 477 * This is exactly what we do here.
478 * 478 *
479 * You will insert normal a button with connection (or use signals from 479 * You will insert normal a button with connection (or use signals from
480 * toolbar): 480 * toolbar):
481 * <pre> 481 * <pre>
482 * bar->insertButton(icon, id, SIGNAL(clicked ()), this, 482 * bar->insertButton(icon, id, SIGNAL(clicked ()), this,
483 * SLOT (slotClick()), true, "click or wait for popup"); 483 * SLOT (slotClick()), true, "click or wait for popup");
484 * </pre> And then add a delayed popup: 484 * </pre> And then add a delayed popup:
485 * <pre> 485 * <pre>
486 * bar->setDelayedPopup (id, historyPopup); </pre> 486 * bar->setDelayedPopup (id, historyPopup); </pre>
487 * 487 *
488 * Don't add delayed popups to buttons which have normal popups. 488 * Don't add delayed popups to buttons which have normal popups.
489 * 489 *
490 * You may add popups which are derived from @ref QPopupMenu. You may 490 * You may add popups which are derived from @ref QPopupMenu. You may
491 * add popups that are already in the menu bar or are submenus of 491 * add popups that are already in the menu bar or are submenus of
492 * other popups. 492 * other popups.
493 */ 493 */
494 void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); 494 void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false);
495 495
496 /** 496 /**
497 * Turns a button into an autorepeat button. 497 * Turns a button into an autorepeat button.
498 * 498 *
499 * Toggle buttons, buttons with menus, or 499 * Toggle buttons, buttons with menus, or
500 * buttons with delayed menus cannot be made into autorepeat buttons. 500 * buttons with delayed menus cannot be made into autorepeat buttons.
501 * Moreover, you can and will receive 501 * Moreover, you can and will receive
502 * only the signal clicked(), but not pressed() or released(). 502 * only the signal clicked(), but not pressed() or released().
503 * When the user presses this button, you will receive the signal clicked(), 503 * When the user presses this button, you will receive the signal clicked(),
504 * and if the button is still pressed after some time, 504 * and if the button is still pressed after some time,
505 * you will receive more clicked() signals separated by regular 505 * you will receive more clicked() signals separated by regular
506 * intervals. Since this uses @ref QButton::setAutoRepeat() , 506 * intervals. Since this uses @ref QButton::setAutoRepeat() ,
507 * I can't quantify 'some'. 507 * I can't quantify 'some'.
508 */ 508 */
509 void setAutoRepeat (int id, bool flag=true); 509 void setAutoRepeat (int id, bool flag=true);
510 510
511 511
512 /** 512 /**
513 * Turns button into a toggle button if @p flag is true. 513 * Turns button into a toggle button if @p flag is true.
514 */ 514 */
515 void setToggle (int id, bool flag = true); 515 void setToggle (int id, bool flag = true);
516 516
517 /** 517 /**
518 * Toggles a togglebutton. 518 * Toggles a togglebutton.
519 * 519 *
520 * If the button is a toggle button (see @ref setToggle()) 520 * If the button is a toggle button (see @ref setToggle())
521 * the button state will be toggled. This will also cause the toolbar to 521 * the button state will be toggled. This will also cause the toolbar to
522 * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to 522 * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to
523 * this signal, or use @ref addConnection() to connect directly to the 523 * this signal, or use @ref addConnection() to connect directly to the
524 * button signal @ref KButton::toggled(). 524 * button signal @ref KButton::toggled().
525 */ 525 */
526 void toggleButton (int id); 526 void toggleButton (int id);
527 527
528 /** 528 /**
529 * Sets a toggle button state. 529 * Sets a toggle button state.
530 * 530 *
531 * If the button is a toggle button (see @ref setToggle()) 531 * If the button is a toggle button (see @ref setToggle())
532 * this will set its state flag. This will also emit the signal 532 * this will set its state flag. This will also emit the signal
533 * @ref KButton::toggled(). 533 * @ref KButton::toggled().
534 * 534 *
535 * @see setToggle() 535 * @see setToggle()
536 */ 536 */
537 void setButton (int id, bool flag); 537 void setButton (int id, bool flag);
538 538
539 /** 539 /**
540 * @return @p true if button is on, @p false if button is off or if the 540 * @return @p true if button is on, @p false if button is off or if the
541 * button is not a toggle button. 541 * button is not a toggle button.
542 * @see setToggle() 542 * @see setToggle()
543 */ 543 */
544 bool isButtonOn (int id) const; 544 bool isButtonOn (int id) const;
545 545
546 /** 546 /**
547 * Sets the text of a line editor. 547 * Sets the text of a line editor.
548 * 548 *
549 * Cursor is set at end of text. 549 * Cursor is set at end of text.
550 */ 550 */
551 void setLinedText (int id, const QString& text); 551 void setLinedText (int id, const QString& text);
552 552
553 /** 553 /**
554 * Returns a line editor text. 554 * Returns a line editor text.
555 */ 555 */
556 QString getLinedText (int id) const; 556 QString getLinedText (int id) const;
557 557
558 /** 558 /**
559 * Inserts @p text in combobox @p id at position @p index. 559 * Inserts @p text in combobox @p id at position @p index.
560 */ 560 */
561 void insertComboItem (int id, const QString& text, int index); 561 void insertComboItem (int id, const QString& text, int index);
562 562
563 /** 563 /**
564 * Inserts @p list in combobox @p id at position @p index. 564 * Inserts @p list in combobox @p id at position @p index.
565 */ 565 */
566 void insertComboList (int id, const QStringList &list, int index); 566 void insertComboList (int id, const QStringList &list, int index);
567 567
568 /** 568 /**
569 * Removes item @p index from combobox @p id. 569 * Removes item @p index from combobox @p id.
570 */ 570 */
571 void removeComboItem (int id, int index); 571 void removeComboItem (int id, int index);
572 572
573 /** 573 /**
574 * Sets item @p index to be current item in combobox @p id. 574 * Sets item @p index to be current item in combobox @p id.
575 */ 575 */
576 void setCurrentComboItem (int id, int index); 576 void setCurrentComboItem (int id, int index);
577 577
578 /** 578 /**
579 * Changes item @p index in combobox @p id to text. 579 * Changes item @p index in combobox @p id to text.
580 * 580 *
581 * @p index = -1 refers current item (one displayed in the button). 581 * @p index = -1 refers current item (one displayed in the button).
582 */ 582 */
583 void changeComboItem (int id, const QString& text, int index=-1); 583 void changeComboItem (int id, const QString& text, int index=-1);
584 584
585 /** 585 /**
586 * Clears the combobox @p id. 586 * Clears the combobox @p id.
587 * 587 *
588 * Does not delete it or hide it. 588 * Does not delete it or hide it.
589 */ 589 */
590 void clearCombo (int id); 590 void clearCombo (int id);
591 591
592 /** 592 /**
593 * Returns text of item @p index from combobox @p id. 593 * Returns text of item @p index from combobox @p id.
594 * 594 *
595 * @p index = -1 refers to current item. 595 * @p index = -1 refers to current item.
596 */ 596 */
597 597
598 QString getComboItem (int id, int index=-1) const; 598 QString getComboItem (int id, int index=-1) const;
599 599
600 /** 600 /**
601 * Returns a pointer to the combobox. 601 * Returns a pointer to the combobox.
602 * 602 *
603 * Example: 603 * Example:
604 * <pre> 604 * <pre>
605 * KComboBox *combo = toolbar->getCombo(combo_id); 605 * KComboBox *combo = toolbar->getCombo(combo_id);
606 * </pre> 606 * </pre>
607 * That way you can get access to other public methods 607 * That way you can get access to other public methods
608 * that @ref KComboBox provides. 608 * that @ref KComboBox provides.
609 */ 609 */
610 KComboBox * getCombo(int id); 610 KComboBox * getCombo(int id);
611 611
612 /** 612 /**
613 * Returns a pointer to KToolBarLined. 613 * Returns a pointer to KToolBarLined.
614 * 614 *
615 * Example: 615 * Example:
616 * <pre> 616 * <pre>
617 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id); 617 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id);
618 * </pre> 618 * </pre>
619 * That way you can get access to other public methods 619 * That way you can get access to other public methods
620 * that @ref KLineEdit provides. @ref KLineEdit is the same thing 620 * that @ref KLineEdit provides. @ref KLineEdit is the same thing
621 * as @ref QLineEdit plus completion signals. 621 * as @ref QLineEdit plus completion signals.
622 */ 622 */
623 KLineEdit * getLined (int id); 623 KLineEdit * getLined (int id);
624 624
625 /** 625 /**
626 * Returns a pointer to KToolBarButton. 626 * Returns a pointer to KToolBarButton.
627 * 627 *
628 * Example: 628 * Example:
629 * <pre> 629 * <pre>
630 * KToolBarButton * button = toolbar->getButton(button_id); 630 * KToolBarButton * button = toolbar->getButton(button_id);
631 * </pre> 631 * </pre>
632 * That way you can get access to other public methods 632 * That way you can get access to other public methods
633 * that @ref KToolBarButton provides. 633 * that @ref KToolBarButton provides.
634 * 634 *
635 * Using this method is not recommended. 635 * Using this method is not recommended.
636 */ 636 */
637 KToolBarButton * getButton (int id); 637 KToolBarButton * getButton (int id);
638 638
639 /** 639 /**
640 * Align item to the right. 640 * Align item to the right.
641 * 641 *
642 * This works only if toolbar is set to full width. 642 * This works only if toolbar is set to full width.
643 * @see setFullWidth() 643 * @see setFullWidth()
644 */ 644 */
645 void alignItemRight (int id, bool right = true); 645 void alignItemRight (int id, bool right = true);
646 646
647 /** 647 /**
648 * Returns a pointer to an inserted widget. 648 * Returns a pointer to an inserted widget.
649 * 649 *
650 * Wrong ids are not tested. 650 * Wrong ids are not tested.
651 * You can do with this whatever you want, 651 * You can do with this whatever you want,
652 * except change its height (hardcoded). If you change its width 652 * except change its height (hardcoded). If you change its width
653 * you will probably have to call QToolBar::updateRects(true) 653 * you will probably have to call QToolBar::updateRects(true)
654 * @see QWidget 654 * @see QWidget
655 * @see updateRects() 655 * @see updateRects()
656 * 656 *
657 * KDE4: make this const! 657 * KDE4: make this const!
658 */ 658 */
659 QWidget *getWidget (int id); 659 QWidget *getWidget (int id);
660 660
661 /** 661 /**
662 * Set item autosized. 662 * Set item autosized.
663 * 663 *
664 * This works only if the toolbar is set to full width. 664 * This works only if the toolbar is set to full width.
665 * Only @p one item can be autosized, and it has to be 665 * Only @p one item can be autosized, and it has to be
666 * the last left-aligned item. Items that come after this must be right 666 * the last left-aligned item. Items that come after this must be right
667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and 667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and
668 * Combos. An autosized item will resize itself whenever the toolbar geometry 668 * Combos. An autosized item will resize itself whenever the toolbar geometry
669 * changes to the last right-aligned item (or to end of toolbar if there 669 * changes to the last right-aligned item (or to end of toolbar if there
670 * are no right-aligned items.) 670 * are no right-aligned items.)
671 * @see setFullWidth() 671 * @see setFullWidth()
672 * @see alignItemRight() 672 * @see alignItemRight()
673 */ 673 */
674 void setItemAutoSized (int id, bool yes = true); 674 void setItemAutoSized (int id, bool yes = true);
675 675
676 /** 676 /**
677 * Remove all items. 677 * Remove all items.
678 * 678 *
679 * The toolbar is redrawn after it. 679 * The toolbar is redrawn after it.
680 */ 680 */
681 void clear (); 681 void clear ();
682 682
683 /** 683 /**
684 * Remove item @p id. 684 * Remove item @p id.
685 * 685 *
686 * Item is deleted. Toolbar is redrawn after it. 686 * Item is deleted. Toolbar is redrawn after it.
687 */ 687 */
688 void removeItem (int id); 688 void removeItem (int id);
689 689
690 /** 690 /**
691 * Remove item @p id. 691 * Remove item @p id.
692 * 692 *
693 * Item is deleted when toolbar is redrawn. 693 * Item is deleted when toolbar is redrawn.
694 */ 694 */
695 void removeItemDelayed (int id); 695 void removeItemDelayed (int id);
696 696
697 /** 697 /**
698 * Hide item. 698 * Hide item.
699 */ 699 */
700 void hideItem (int id); 700 void hideItem (int id);
701 701
702 /** 702 /**
703 * Show item. 703 * Show item.
704 */ 704 */
705 void showItem (int id); 705 void showItem (int id);
706 706
707 /** 707 /**
708 * Returns the index of the given item. 708 * Returns the index of the given item.
709 * 709 *
710 * KDE4: make this const! 710 * KDE4: make this const!
711 */ 711 */
712 int itemIndex (int id); 712 int itemIndex (int id);
713 713
714 /** 714 /**
715 * Set toolbar to full parent size (default). 715 * Set toolbar to full parent size (default).
716 * 716 *
717 * In full size mode the bar 717 * In full size mode the bar
718 * extends over the parent's full width or height. If the mode is disabled 718 * extends over the parent's full width or height. If the mode is disabled
719 * the toolbar tries to take as much space as it needs without wrapping, but 719 * the toolbar tries to take as much space as it needs without wrapping, but
720 * it does not exceed the parent box. You can force a certain width or 720 * it does not exceed the parent box. You can force a certain width or
721 * height with @ref setMaxWidth() or @ref setMaxHeight(). 721 * height with @ref setMaxWidth() or @ref setMaxHeight().
722 * 722 *
723 * If you want to use right-aligned items or auto-sized items you must use 723 * If you want to use right-aligned items or auto-sized items you must use
724 * full size mode. 724 * full size mode.
725 */ 725 */
726 void setFullSize(bool flag = true); 726 void setFullSize(bool flag = true);
727 727
728 /** 728 /**
729 * @return @p true if the full-size mode is enabled. Otherwise 729 * @return @p true if the full-size mode is enabled. Otherwise
730 * it returns @false. 730 * it returns @false.
731 */ 731 */
732 bool fullSize() const; 732 bool fullSize() const;
733 733
734 /** 734 /**
735 * @deprecated use setMovingEnabled(bool) instead. 735 * @deprecated use setMovingEnabled(bool) instead.
736 * Enable or disable moving of toolbar. 736 * Enable or disable moving of toolbar.
737 */ 737 */
738 void enableMoving(bool flag = true); 738 void enableMoving(bool flag = true);
739 739
740 /** 740 /**
741 * Set position of toolbar. 741 * Set position of toolbar.
742 * @see BarPosition() 742 * @see BarPosition()
743 */ 743 */
744 void setBarPos (BarPosition bpos); 744 void setBarPos (BarPosition bpos);
745 745
746 /** 746 /**
747 * Returns position of toolbar. 747 * Returns position of toolbar.
748 */ 748 */
749 const BarPosition barPos(); 749 const BarPosition barPos();
750 750
751 /** 751 /**
752 * @deprecated 752 * @deprecated
753 * Show, hide, or toggle toolbar. 753 * Show, hide, or toggle toolbar.
754 * 754 *
755 * This method is provided for compatibility only, 755 * This method is provided for compatibility only,
756 * please use show() and/or hide() instead. 756 * please use show() and/or hide() instead.
757 * @see BarStatus 757 * @see BarStatus
758 */ 758 */
759 bool enable(BarStatus stat); 759 bool enable(BarStatus stat);
760 760
761 /** 761 /**
762 * @deprecated 762 * @deprecated
763 * Use setMaximumHeight() instead. 763 * Use setMaximumHeight() instead.
764 */ 764 */
765 void setMaxHeight (int h); // Set max height for vertical toolbars 765 void setMaxHeight (int h); // Set max height for vertical toolbars
766 766
767 /** 767 /**
768 * @deprecated 768 * @deprecated
769 * Use maximumHeight() instead. 769 * Use maximumHeight() instead.
770 * Returns the value that was set with @ref setMaxHeight(). 770 * Returns the value that was set with @ref setMaxHeight().
771 */ 771 */
772 int maxHeight(); 772 int maxHeight();
773 773
774 /** 774 /**
775 * @deprecated 775 * @deprecated
776 * Use setMaximumWidth() instead. 776 * Use setMaximumWidth() instead.
777 * Set maximal width of horizontal (top or bottom) toolbar. 777 * Set maximal width of horizontal (top or bottom) toolbar.
778 */ 778 */
779 void setMaxWidth (int dw); 779 void setMaxWidth (int dw);
780 780
781 /** 781 /**
782 * @deprecated 782 * @deprecated
783 * Use maximumWidth() instead. 783 * Use maximumWidth() instead.
784 * Returns the value that was set with @ref setMaxWidth(). 784 * Returns the value that was set with @ref setMaxWidth().
785 */ 785 */
786 int maxWidth(); 786 int maxWidth();
787 787
788 /** 788 /**
789 * Set title for toolbar when it floats. 789 * Set title for toolbar when it floats.
790 * 790 *
791 * Titles are however not (yet) 791 * Titles are however not (yet)
792 * visible. You can't change toolbar's title while it's floating. 792 * visible. You can't change toolbar's title while it's floating.
793 */ 793 */
794 void setTitle (const QString& _title); 794 void setTitle (const QString& _title);
795 795
796 /** 796 /**
797 * @deprecated 797 * @deprecated
798 * Use enableMoving() instead. 798 * Use enableMoving() instead.
799 */ 799 */
800 void enableFloating (bool arrrrrrgh); 800 void enableFloating (bool arrrrrrgh);
801 801
802 /** 802 /**
803 * Set the kind of painting for buttons. 803 * Set the kind of painting for buttons.
804 * 804 *
805 * Choose from: 805 * Choose from:
806 * @li IconOnly (only icons), 806 * @li IconOnly (only icons),
807 * @li IconTextRight (icon and text, text is left from icons), 807 * @li IconTextRight (icon and text, text is left from icons),
808 * @li TextOnly (only text), 808 * @li TextOnly (only text),
809 * @li IconTextBottom (icons and text, text is under icons). 809 * @li IconTextBottom (icons and text, text is under icons).
810 * @see IconText 810 * @see IconText
811 * 811 *
812 */ 812 */
813 void setIconText(IconText it); 813 void setIconText(IconText it);
814 // Note: don't merge with the next one, it breaks Qt properties 814 // Note: don't merge with the next one, it breaks Qt properties
815 815
816 /** 816 /**
817 * Similar to @ref setIconText(IconText it) but allows you to 817 * Similar to @ref setIconText(IconText it) but allows you to
818 * disable or enable updating. If @p update is false, then the 818 * disable or enable updating. If @p update is false, then the
819 * buttons will not be updated. This is useful only if you know 819 * buttons will not be updated. This is useful only if you know
820 * that you will be forcing an update later. 820 * that you will be forcing an update later.
821 */ 821 */
822 void setIconText(IconText it, bool update); 822 void setIconText(IconText it, bool update);
823 823
824 /** 824 /**
825 * @return The current text style for buttons. 825 * @return The current text style for buttons.
826 */ 826 */
827 IconText iconText() const; 827 IconText iconText() const;
828 828
829 /** 829 /**
830 * Set the icon size to load. Usually you should not call 830 * Set the icon size to load. Usually you should not call
831 * this, the icon size is taken care of by KIconLoader 831 * this, the icon size is taken care of by KIconLoader
832 * and globally configured. 832 * and globally configured.
833 * By default, the toolbar will load icons of size 32 for main 833 * By default, the toolbar will load icons of size 32 for main
834 * toolbars and 22 for other toolbars 834 * toolbars and 22 for other toolbars
835 * @see KIconLoader. 835 * @see KIconLoader.
836 * 836 *
837 * @param size The size to use 837 * @param size The size to use
838 */ 838 */
839 void setIconSize(int size); 839 void setIconSize(int size);
840 // Note: don't merge with the next one, it breaks Qt properties 840 // Note: don't merge with the next one, it breaks Qt properties
841 841
842 /** 842 /**
843 * Same as @ref setIconText(int size) but allows you 843 * Same as @ref setIconText(int size) but allows you
844 * to disable the toolbar update. 844 * to disable the toolbar update.
845 * 845 *
846 * @param size The size to use 846 * @param size The size to use
847 * @param update If true, then the toolbar will be updated after 847 * @param update If true, then the toolbar will be updated after
848 * this 848 * this
849 */ 849 */
850 void setIconSize(int size, bool update); 850 void setIconSize(int size, bool update);
851 851
852 /** 852 /**
853 * @return The current icon size for buttons. 853 * @return The current icon size for buttons.
854 */ 854 */
855 int iconSize() const; 855 int iconSize() const;
856 856
857 /** 857 /**
858 * This allows you to enable or disable the context menu. 858 * This allows you to enable or disable the context menu.
859 * 859 *
860 * @param enable If false, then the context menu will be disabled 860 * @param enable If false, then the context menu will be disabled
861 */ 861 */
862 void setEnableContextMenu(bool enable = true); 862 void setEnableContextMenu(bool enable = true);
863 863
864 /** 864 /**
865 * Returns whether or not the context menu is disabled 865 * Returns whether or not the context menu is disabled
866 * 866 *
867 * @return The context menu state 867 * @return The context menu state
868 */ 868 */
869 bool contextMenuEnabled() const; 869 bool contextMenuEnabled() const;
870 870
871 /** 871 /**
872 * This will inform a toolbar button to ignore certain style 872 * This will inform a toolbar button to ignore certain style
873 * changes. Specifically, it will ignore IconText (always IconOnly) 873 * changes. Specifically, it will ignore IconText (always IconOnly)
874 * and will not allow image effects to apply. 874 * and will not allow image effects to apply.
875 * 875 *
876 * @param id The button to exclude from styles 876 * @param id The button to exclude from styles
877 * @param no_style If true, then it is excluded (default: true). 877 * @param no_style If true, then it is excluded (default: true).
878 */ 878 */
879 void setItemNoStyle(int id, bool no_style = true); 879 void setItemNoStyle(int id, bool no_style = true);
880 880
881 void setFlat (bool flag); 881 void setFlat (bool flag);
882 882
883 /** 883 /**
884 * @return the number of items in the toolbar 884 * @return the number of items in the toolbar
885 */ 885 */
886 int count() const; 886 int count() const;
887 887
888 /** 888 /**
889 * Instruct the toolbar to save it's current state to either the app 889 * Instruct the toolbar to save it's current state to either the app
890 * config file or to the XML-GUI resource file (whichever has 890 * config file or to the XML-GUI resource file (whichever has
891 * precedence). 891 * precedence).
892 */ 892 */
893 void saveState(); 893 void saveState();
894 894
895 /** 895 /**
896 * Save the toolbar settings to group @p configGroup in @p config. 896 * Save the toolbar settings to group @p configGroup in @p config.
897 */ 897 */
898 void saveSettings(KConfig *config, const QString &configGroup); 898 void saveSettings(KConfig *config, const QString &configGroup);
899 899
900 /** 900 /**
901 * Read the toolbar settings from group @p configGroup in @p config 901 * Read the toolbar settings from group @p configGroup in @p config
902 * and apply them. 902 * and apply them.
903 */ 903 */
904 void applySettings(KConfig *config, const QString &configGroup); 904 void applySettings(KConfig *config, const QString &configGroup);
905 905
906 /** 906 /**
907 * Tell the toolbar what XML-GUI resource file it should use to save 907 * Tell the toolbar what XML-GUI resource file it should use to save
908 * it's state. The state of the toolbar (position, size, etc) is 908 * it's state. The state of the toolbar (position, size, etc) is
909 * saved in KConfig files if the application does not use XML-GUI.. 909 * saved in KConfig files if the application does not use XML-GUI..
910 * but if the app does, then it's saved the XML file. This function 910 * but if the app does, then it's saved the XML file. This function
911 * allows this to happen. 911 * allows this to happen.
912 * 912 *
913 * @param xmlfile The XML-GUI resource file to write to 913 * @param xmlfile The XML-GUI resource file to write to
914 * @param xml The DOM document for the XML-GUI building 914 * @param xml The DOM document for the XML-GUI building
915 */ 915 */
916 // void setXML(const QString& xmlfile, const QDomDocument& xml); 916 // void setXML(const QString& xmlfile, const QDomDocument& xml);
917 /* @internal */ 917 /* @internal */
918 void setXMLGUIClient( KXMLGUIClient *client ); 918 void setXMLGUIClient( KXMLGUIClient *client );
919 919
920 /** 920 /**
921 * Assign a (translated) text to this toolbar. This is used 921 * Assign a (translated) text to this toolbar. This is used
922 * for the tooltip on the handle, and when listing the toolbars. 922 * for the tooltip on the handle, and when listing the toolbars.
923 */ 923 */
924 void setText( const QString & txt ); 924 void setText( const QString & txt );
925 925
926 /** 926 /**
927 * @return the toolbar's text. 927 * @return the toolbar's text.
928 */ 928 */
929 QString text() const; 929 QString text() const;
930 930
931 void setStretchableWidget( QWidget *w ); 931 void setStretchableWidget( QWidget *w );
932 QSizePolicy sizePolicy() const; 932 QSizePolicy sizePolicy() const;
933 bool highlight() const; 933 bool highlight() const;
934 QSize sizeHint() const; 934 QSize sizeHint() const;
935 QSize minimumSizeHint() const; 935 QSize minimumSizeHint() const;
936 QSize minimumSize() const; 936 QSize minimumSize() const;
937 937
938 void hide(); 938 void hide();
939 void show(); 939 void show();
940 940
941 void updateRects( bool = FALSE ) {} 941 void updateRects( bool = FALSE ) {}
942 942
943//US void loadState( const QDomElement &e ); 943//US void loadState( const QDomElement &e );
944//US void saveState( QDomElement &e ); 944//US void saveState( QDomElement &e );
945 945
946 /** 946 /**
947 * @internal 947 * @internal
948 */ 948 */
949 void positionYourself( bool force = false); 949 void positionYourself( bool force = false);
950 950
951signals: 951signals:
952 /** 952 /**
953 * Emitted when button @p id is clicked. 953 * Emitted when button @p id is clicked.
954 */ 954 */
955 void clicked(int id); 955 void clicked(int id);
956 956
957 /** 957 /**
958 * Emitted when button @p id is double-clicked. 958 * Emitted when button @p id is double-clicked.
959 * 959 *
960 * Note: you will always 960 * Note: you will always
961 * recive two @ref clicked() , @ref pressed() and @ref released() signals. 961 * recive two @ref clicked() , @ref pressed() and @ref released() signals.
962 * There is no way to avoid it - at least no easy way. 962 * There is no way to avoid it - at least no easy way.
963 * If you need to resolve this all you can do is set up timers 963 * If you need to resolve this all you can do is set up timers
964 * which wait for @ref QApplication::doubleClickInterval() to expire. 964 * which wait for @ref QApplication::doubleClickInterval() to expire.
965 * If in that time you don't get this signal, you may belive that 965 * If in that time you don't get this signal, you may belive that
966 * button was only clicked and not double-clicked. 966 * button was only clicked and not double-clicked.
967 * And please note that butons with popup menus do not emit this signal, 967 * And please note that butons with popup menus do not emit this signal,
968 * but those with delayed popup do. 968 * but those with delayed popup do.
969 */ 969 */
970 void doubleClicked (int id); 970 void doubleClicked (int id);
971 971
972 /** 972 /**
973 * Emitted when button @p id is pressed. 973 * Emitted when button @p id is pressed.
974 */ 974 */
975 void pressed(int); 975 void pressed(int);
976 976
977 /** 977 /**
978 * Emits when button @p id is released. 978 * Emits when button @p id is released.
979 */ 979 */
980 void released(int); 980 void released(int);
981 981
982 /** 982 /**
983 * Emitted when a toggle button changes state. 983 * Emitted when a toggle button changes state.
984 * 984 *
985 * Emitted also if you change state 985 * Emitted also if you change state
986 * with @ref setButton() or @ref toggleButton() 986 * with @ref setButton() or @ref toggleButton()
987 * If you make a button normal again, with 987 * If you make a button normal again, with
988 * setToggle(false), this signal won't 988 * setToggle(false), this signal won't
989 * be emitted. 989 * be emitted.
990 */ 990 */
991 void toggled(int); 991 void toggled(int);
992 992
993 /** 993 /**
994 * This signal is emitted when item id gets highlighted/unhighlighted 994 * This signal is emitted when item id gets highlighted/unhighlighted
995 * (i.e when mouse enters/exits). 995 * (i.e when mouse enters/exits).
996 * 996 *
997 * Note that this signal is emitted from 997 * Note that this signal is emitted from
998 * all buttons (normal, disabled and toggle) even when there is no visible 998 * all buttons (normal, disabled and toggle) even when there is no visible
999 * change in buttons (i.e., buttons do not raise when mouse enters). 999 * change in buttons (i.e., buttons do not raise when mouse enters).
1000 * The parameter @p isHighlighted is @p true when mouse enters and @p false when 1000 * The parameter @p isHighlighted is @p true when mouse enters and @p false when
1001 * mouse exits. 1001 * mouse exits.
1002 */ 1002 */
1003 void highlighted(int id, bool isHighlighted); 1003 void highlighted(int id, bool isHighlighted);
1004 1004
1005 /** 1005 /**
1006 * This signal is emitted when item id gets highlighted/unhighlighted 1006 * This signal is emitted when item id gets highlighted/unhighlighted
1007 * (i.e when mouse enters/exits). 1007 * (i.e when mouse enters/exits).
1008 * 1008 *
1009 * Note that this signal is emitted from 1009 * Note that this signal is emitted from
1010 * all buttons (normal, disabled and toggle) even when there is no visible 1010 * all buttons (normal, disabled and toggle) even when there is no visible
1011 * change in buttons (i.e., buttons do not raise when mouse enters). 1011 * change in buttons (i.e., buttons do not raise when mouse enters).
1012 */ 1012 */
1013 void highlighted(int id ); 1013 void highlighted(int id );
1014 1014
1015 /** 1015 /**
1016 * Emitted when toolbar changes position, or when 1016 * Emitted when toolbar changes position, or when
1017 * an item is removed from toolbar. 1017 * an item is removed from toolbar.
1018 * 1018 *
1019 * If you subclass @ref KMainWindow and reimplement 1019 * If you subclass @ref KMainWindow and reimplement
1020 * @ref KMainWindow::resizeEvent() be sure to connect to 1020 * @ref KMainWindow::resizeEvent() be sure to connect to
1021 * this signal. Note: You can connect this signal to a slot that 1021 * this signal. Note: You can connect this signal to a slot that
1022 * doesn't take parameter. 1022 * doesn't take parameter.
1023 */ 1023 */
1024 void moved( BarPosition ); 1024 void moved( BarPosition );
1025 1025
1026 /** 1026 /**
1027 * @internal 1027 * @internal
1028 * This signal is emitted when toolbar detects changing of 1028 * This signal is emitted when toolbar detects changing of
1029 * following parameters: 1029 * following parameters:
1030 * highlighting, button-size, button-mode. This signal is 1030 * highlighting, button-size, button-mode. This signal is
1031 * internal, aimed to buttons. 1031 * internal, aimed to buttons.
1032 */ 1032 */
1033 void modechange (); 1033 void modechange ();
1034 1034
1035 /** 1035 /**
1036 * This signal is emitted when the toolbar is getting deleted, 1036 * This signal is emitted when the toolbar is getting deleted,
1037 * and before ~KToolbar finishes (so it's still time to remove 1037 * and before ~KToolbar finishes (so it's still time to remove
1038 * widgets from the toolbar). 1038 * widgets from the toolbar).
1039 * Used by KWidgetAction. 1039 * Used by KWidgetAction.
1040 * @since 3.2 1040 * @since 3.2
1041 */ 1041 */
1042 void toolbarDestroyed(); 1042 void toolbarDestroyed();
1043 1043
1044public: 1044public:
1045 /** 1045 /**
1046 * @return global setting for "Highlight buttons under mouse" 1046 * @return global setting for "Highlight buttons under mouse"
1047 */ 1047 */
1048 void repaintMe(); 1048 void repaintMe();
1049 static bool highlightSetting(); 1049 static bool highlightSetting();
1050 1050
1051 /** 1051 /**
1052 * @return global setting for "Toolbars transparent when moving" 1052 * @return global setting for "Toolbars transparent when moving"
1053 */ 1053 */
1054 static bool transparentSetting(); 1054 static bool transparentSetting();
1055 1055
1056 /** 1056 /**
1057 * @return global setting for "Icon Text" 1057 * @return global setting for "Icon Text"
1058 */ 1058 */
1059 static IconText iconTextSetting(); 1059 static IconText iconTextSetting();
1060 1060
1061public slots: 1061public slots:
1062 virtual void setIconText( const QString &txt ) 1062 virtual void setIconText( const QString &txt )
1063 { QToolBar::setIconText( txt ); } 1063 { QToolBar::setIconText( txt ); }
1064 void slotRepaint(); 1064 void slotRepaint();
1065 1065
1066protected: 1066protected:
1067 void mousePressEvent( QMouseEvent * ); 1067 void mousePressEvent( QMouseEvent * );
1068 void childEvent( QChildEvent *e ); 1068 void childEvent( QChildEvent *e );
1069 void showEvent( QShowEvent *e ); 1069 void showEvent( QShowEvent *e );
1070 void resizeEvent( QResizeEvent *e ); 1070 void resizeEvent( QResizeEvent *e );
1071 bool event( QEvent *e ); 1071 bool event( QEvent *e );
1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); 1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false);
1073 QString settingsGroup(); 1073 QString settingsGroup();
1074 1074
1075private slots: 1075private slots:
1076 void rebuildLayout(); 1076 void rebuildLayout();
1077 void slotReadConfig (); 1077 void slotReadConfig ();
1078 void slotAppearanceChanged(); 1078 void slotAppearanceChanged();
1079 void slotIconChanged(int); 1079 void slotIconChanged(int);
1080 void toolBarPosChanged( QToolBar *tb ); 1080 void toolBarPosChanged( QToolBar *tb );
1081 void slotContextAboutToShow(); 1081 void slotContextAboutToShow();
1082 void widgetDestroyed(); 1082 void widgetDestroyed();
1083 1083
1084private: 1084private:
1085 int sizeHintW;
1086 int sizeHintH;
1085 void init( bool readConfig = true, bool honorStyle = false ); 1087 void init( bool readConfig = true, bool honorStyle = false );
1086 void doConnections( KToolBarButton *button ); 1088 void doConnections( KToolBarButton *button );
1087 void insertWidgetInternal( QWidget *w, int &index, int id ); 1089 void insertWidgetInternal( QWidget *w, int &index, int id );
1088 void removeWidgetInternal( QWidget *w ); 1090 void removeWidgetInternal( QWidget *w );
1089 void getAttributes( QString &position, QString &icontext, int &index ); 1091 void getAttributes( QString &position, QString &icontext, int &index );
1090//US KPopupMenu *contextMenu(); 1092//US KPopupMenu *contextMenu();
1091 QPopupMenu *contextMenu(); 1093 QPopupMenu *contextMenu();
1092 1094
1093 QMap<QWidget*, int > widget2id; 1095 QMap<QWidget*, int > widget2id;
1094 typedef QMap<int, QWidget* > Id2WidgetMap; 1096 typedef QMap<int, QWidget* > Id2WidgetMap;
1095 Id2WidgetMap id2widget; 1097 Id2WidgetMap id2widget;
1096//US KPopupMenu *context; 1098//US KPopupMenu *context;
1097 QPopupMenu *context; 1099 QPopupMenu *context;
1098 QPtrList<QWidget> widgets; 1100 QPtrList<QWidget> widgets;
1099 QTimer *layoutTimer; 1101 QTimer *layoutTimer;
1100 QGuardedPtr<QWidget> stretchableWidget, rightAligned; 1102 QGuardedPtr<QWidget> stretchableWidget, rightAligned;
1101protected: 1103protected:
1102 virtual void virtual_hook( int id, void* data ); 1104 virtual void virtual_hook( int id, void* data );
1103private: 1105private:
1104 KToolBarPrivate *d; 1106 KToolBarPrivate *d;
1105 bool inshutdownprocess; 1107 bool inshutdownprocess;
1106}; 1108};
1107 1109
1108#endif 1110#endif