summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 15:58:52 (UTC)
committer zautrix <zautrix>2004-10-09 15:58:52 (UTC)
commitb80a099d9432bdc3d4eea778b1813b82b2680ecf (patch) (unidiff)
tree6327321f86070a13969b07e25b9cf84d4ad10d13
parented1eac5e36e675b030cb5a5aa90fb2d44eb40c73 (diff)
downloadkdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.zip
kdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.tar.gz
kdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.tar.bz2
removed some debug output
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatplugin.cpp2
-rw-r--r--libkdepim/ksyncmanager.cpp24
-rw-r--r--microkde/kconfig.cpp4
-rw-r--r--microkde/kdecore/kstandarddirs.cpp2
-rw-r--r--microkde/kdeui/kactioncollection.cpp5
-rw-r--r--microkde/kdeui/klistview.cpp2
6 files changed, 18 insertions, 21 deletions
diff --git a/kabc/vcardformatplugin.cpp b/kabc/vcardformatplugin.cpp
index bc18690..8db8c11 100644
--- a/kabc/vcardformatplugin.cpp
+++ b/kabc/vcardformatplugin.cpp
@@ -1,70 +1,70 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include "vcardformatplugin.h" 21#include "vcardformatplugin.h"
22#include "vcardformatimpl.h" 22#include "vcardformatimpl.h"
23 23
24using namespace KABC; 24using namespace KABC;
25 25
26VCardFormatPlugin::VCardFormatPlugin() 26VCardFormatPlugin::VCardFormatPlugin()
27{ 27{
28 mImpl = new VCardFormatImpl; 28 mImpl = new VCardFormatImpl;
29} 29}
30 30
31VCardFormatPlugin::~VCardFormatPlugin() 31VCardFormatPlugin::~VCardFormatPlugin()
32{ 32{
33 delete mImpl; 33 delete mImpl;
34} 34}
35 35
36bool VCardFormatPlugin::load( Addressee &addressee, QFile *file ) 36bool VCardFormatPlugin::load( Addressee &addressee, QFile *file )
37{ 37{
38 qDebug("VCardFormatPlugin::load"); 38 qDebug("VCardFormatPlugin::load");
39 return mImpl->load( addressee, file ); 39 return mImpl->load( addressee, file );
40} 40}
41 41
42bool VCardFormatPlugin::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 42bool VCardFormatPlugin::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
43{ 43{
44 qDebug("VCardFormatPlugin::loadAll"); 44 // qDebug("VCardFormatPlugin::loadAll");
45 return mImpl->loadAll( addressBook, resource, file ); 45 return mImpl->loadAll( addressBook, resource, file );
46} 46}
47 47
48void VCardFormatPlugin::save( const Addressee &addressee, QFile *file ) 48void VCardFormatPlugin::save( const Addressee &addressee, QFile *file )
49{ 49{
50 qDebug("VCardFormatPlugin::save"); 50 qDebug("VCardFormatPlugin::save");
51 mImpl->save( addressee, file ); 51 mImpl->save( addressee, file );
52} 52}
53 53
54void VCardFormatPlugin::saveAll( AddressBook *addressBook, Resource *resource, QFile *file ) 54void VCardFormatPlugin::saveAll( AddressBook *addressBook, Resource *resource, QFile *file )
55{ 55{
56 qDebug("VCardFormatPlugin::saveAll"); 56 qDebug("VCardFormatPlugin::saveAll");
57 mImpl->saveAll( addressBook, resource, file ); 57 mImpl->saveAll( addressBook, resource, file );
58} 58}
59 59
60bool VCardFormatPlugin::checkFormat( QFile *file ) const 60bool VCardFormatPlugin::checkFormat( QFile *file ) const
61{ 61{
62 QString line; 62 QString line;
63 63
64 file->readLine( line, 1024 ); 64 file->readLine( line, 1024 );
65 line = line.stripWhiteSpace(); 65 line = line.stripWhiteSpace();
66 if ( line == "BEGIN:VCARD" ) 66 if ( line == "BEGIN:VCARD" )
67 return true; 67 return true;
68 else 68 else
69 return false; 69 return false;
70} 70}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 80fb147..df53235 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -193,1022 +193,1018 @@ void KSyncManager::slotSyncMenu( int action )
193 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
194 mWriteBackFile = false; 194 mWriteBackFile = false;
195 mAskForPreferences = false; 195 mAskForPreferences = false;
196 mShowSyncSummary = false; 196 mShowSyncSummary = false;
197 mSyncAlgoPrefs = 3; 197 mSyncAlgoPrefs = 3;
198 quickSyncLocalFile(); 198 quickSyncLocalFile();
199 199
200 } else if ( action >= 1003 ) { 200 } else if ( action >= 1003 ) {
201 if ( temp->getIsLocalFileSync() ) { 201 if ( temp->getIsLocalFileSync() ) {
202 switch(mTargetApp) 202 switch(mTargetApp)
203 { 203 {
204 case (KAPI): 204 case (KAPI):
205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
207 break; 207 break;
208 case (KOPI): 208 case (KOPI):
209 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
211 break; 211 break;
212 case (PWMPI): 212 case (PWMPI):
213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
215 break; 215 break;
216 default: 216 default:
217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
218 break; 218 break;
219 219
220 } 220 }
221 } else { 221 } else {
222 if ( temp->getIsPhoneSync() ) { 222 if ( temp->getIsPhoneSync() ) {
223 mPhoneDevice = temp->getPhoneDevice( ) ; 223 mPhoneDevice = temp->getPhoneDevice( ) ;
224 mPhoneConnection = temp->getPhoneConnection( ); 224 mPhoneConnection = temp->getPhoneConnection( );
225 mPhoneModel = temp->getPhoneModel( ); 225 mPhoneModel = temp->getPhoneModel( );
226 syncPhone(); 226 syncPhone();
227 } else if ( temp->getIsPiSync() ) { 227 } else if ( temp->getIsPiSync() ) {
228 if ( mTargetApp == KAPI ) { 228 if ( mTargetApp == KAPI ) {
229 mPassWordPiSync = temp->getRemotePwAB(); 229 mPassWordPiSync = temp->getRemotePwAB();
230 mActiveSyncPort = temp->getRemotePortAB(); 230 mActiveSyncPort = temp->getRemotePortAB();
231 mActiveSyncIP = temp->getRemoteIPAB(); 231 mActiveSyncIP = temp->getRemoteIPAB();
232 } else if ( mTargetApp == KOPI ) { 232 } else if ( mTargetApp == KOPI ) {
233 mPassWordPiSync = temp->getRemotePw(); 233 mPassWordPiSync = temp->getRemotePw();
234 mActiveSyncPort = temp->getRemotePort(); 234 mActiveSyncPort = temp->getRemotePort();
235 mActiveSyncIP = temp->getRemoteIP(); 235 mActiveSyncIP = temp->getRemoteIP();
236 } else { 236 } else {
237 mPassWordPiSync = temp->getRemotePwPWM(); 237 mPassWordPiSync = temp->getRemotePwPWM();
238 mActiveSyncPort = temp->getRemotePortPWM(); 238 mActiveSyncPort = temp->getRemotePortPWM();
239 mActiveSyncIP = temp->getRemoteIPPWM(); 239 mActiveSyncIP = temp->getRemoteIPPWM();
240 } 240 }
241 syncPi(); 241 syncPi();
242 } else 242 } else
243 syncRemote( temp ); 243 syncRemote( temp );
244 244
245 } 245 }
246 } 246 }
247 delete temp; 247 delete temp;
248 setBlockSave(false); 248 setBlockSave(false);
249} 249}
250 250
251void KSyncManager::enableQuick() 251void KSyncManager::enableQuick()
252{ 252{
253 QDialog dia ( 0, "input-dialog", true ); 253 QDialog dia ( 0, "input-dialog", true );
254 QLineEdit lab ( &dia ); 254 QLineEdit lab ( &dia );
255 QVBoxLayout lay( &dia ); 255 QVBoxLayout lay( &dia );
256 lab.setText( mPrefs->mPassiveSyncPort ); 256 lab.setText( mPrefs->mPassiveSyncPort );
257 lay.setMargin(7); 257 lay.setMargin(7);
258 lay.setSpacing(7); 258 lay.setSpacing(7);
259 int po = 9197+mTargetApp; 259 int po = 9197+mTargetApp;
260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
261 lay.addWidget( &label); 261 lay.addWidget( &label);
262 lay.addWidget( &lab); 262 lay.addWidget( &lab);
263 263
264 QLineEdit lepw ( &dia ); 264 QLineEdit lepw ( &dia );
265 lepw.setText( mPrefs->mPassiveSyncPw ); 265 lepw.setText( mPrefs->mPassiveSyncPw );
266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
267 lay.addWidget( &label2); 267 lay.addWidget( &label2);
268 lay.addWidget( &lepw); 268 lay.addWidget( &lepw);
269 dia.setFixedSize( 230,80 ); 269 dia.setFixedSize( 230,80 );
270 dia.setCaption( i18n("Enter port for Pi-Sync") ); 270 dia.setCaption( i18n("Enter port for Pi-Sync") );
271 QPushButton pb ( "OK", &dia); 271 QPushButton pb ( "OK", &dia);
272 lay.addWidget( &pb ); 272 lay.addWidget( &pb );
273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
274 dia.show(); 274 dia.show();
275 if ( ! dia.exec() ) 275 if ( ! dia.exec() )
276 return; 276 return;
277 dia.hide(); 277 dia.hide();
278 qApp->processEvents(); 278 qApp->processEvents();
279 mPrefs->mPassiveSyncPw = lepw.text(); 279 mPrefs->mPassiveSyncPw = lepw.text();
280 mPrefs->mPassiveSyncPort = lab.text(); 280 mPrefs->mPassiveSyncPort = lab.text();
281 bool ok; 281 bool ok;
282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
283 if ( ! ok ) { 283 if ( ! ok ) {
284 KMessageBox::information( 0, i18n("No valid port")); 284 KMessageBox::information( 0, i18n("No valid port"));
285 return; 285 return;
286 } 286 }
287 //qDebug("port %d ", port); 287 //qDebug("port %d ", port);
288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
289 mServerSocket->setFileName( defaultFileName() ); 289 mServerSocket->setFileName( defaultFileName() );
290 //qDebug("connected "); 290 //qDebug("connected ");
291 if ( !mServerSocket->ok() ) { 291 if ( !mServerSocket->ok() ) {
292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
293 delete mServerSocket; 293 delete mServerSocket;
294 mServerSocket = 0; 294 mServerSocket = 0;
295 return; 295 return;
296 } 296 }
297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
299} 299}
300 300
301void KSyncManager::syncLocalFile() 301void KSyncManager::syncLocalFile()
302{ 302{
303 303
304 QString fn =mPrefs->mLastSyncedLocalFile; 304 QString fn =mPrefs->mLastSyncedLocalFile;
305 QString ext; 305 QString ext;
306 306
307 switch(mTargetApp) 307 switch(mTargetApp)
308 { 308 {
309 case (KAPI): 309 case (KAPI):
310 ext = "(*.vcf)"; 310 ext = "(*.vcf)";
311 break; 311 break;
312 case (KOPI): 312 case (KOPI):
313 ext = "(*.ics/*.vcs)"; 313 ext = "(*.ics/*.vcs)";
314 break; 314 break;
315 case (PWMPI): 315 case (PWMPI):
316 ext = "(*.pwm)"; 316 ext = "(*.pwm)";
317 break; 317 break;
318 default: 318 default:
319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
320 break; 320 break;
321 321
322 } 322 }
323 323
324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
325 if ( fn == "" ) 325 if ( fn == "" )
326 return; 326 return;
327 if ( syncWithFile( fn, false ) ) { 327 if ( syncWithFile( fn, false ) ) {
328 qDebug("syncLocalFile() successful "); 328 qDebug("syncLocalFile() successful ");
329 } 329 }
330 330
331} 331}
332 332
333bool KSyncManager::syncWithFile( QString fn , bool quick ) 333bool KSyncManager::syncWithFile( QString fn , bool quick )
334{ 334{
335 bool ret = false; 335 bool ret = false;
336 QFileInfo info; 336 QFileInfo info;
337 info.setFile( fn ); 337 info.setFile( fn );
338 QString mess; 338 QString mess;
339 bool loadbup = true; 339 bool loadbup = true;
340 if ( !info. exists() ) { 340 if ( !info. exists() ) {
341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
342 int result = QMessageBox::warning( mParent, i18n("Warning!"), 342 int result = QMessageBox::warning( mParent, i18n("Warning!"),
343 mess ); 343 mess );
344 return ret; 344 return ret;
345 } 345 }
346 int result = 0; 346 int result = 0;
347 if ( !quick ) { 347 if ( !quick ) {
348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
349 result = QMessageBox::warning( mParent, i18n("Warning!"), 349 result = QMessageBox::warning( mParent, i18n("Warning!"),
350 mess, 350 mess,
351 i18n("Sync"), i18n("Cancel"), 0, 351 i18n("Sync"), i18n("Cancel"), 0,
352 0, 1 ); 352 0, 1 );
353 if ( result ) 353 if ( result )
354 return false; 354 return false;
355 } 355 }
356 if ( mAskForPreferences ) 356 if ( mAskForPreferences )
357 edit_sync_options(); 357 edit_sync_options();
358 if ( result == 0 ) { 358 if ( result == 0 ) {
359 //qDebug("Now sycing ... "); 359 //qDebug("Now sycing ... ");
360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
362 else 362 else
363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
364 if ( ! quick ) 364 if ( ! quick )
365 mPrefs->mLastSyncedLocalFile = fn; 365 mPrefs->mLastSyncedLocalFile = fn;
366 } 366 }
367 return ret; 367 return ret;
368} 368}
369 369
370void KSyncManager::quickSyncLocalFile() 370void KSyncManager::quickSyncLocalFile()
371{ 371{
372 372
373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
374 qDebug("quick syncLocalFile() successful "); 374 qDebug("quick syncLocalFile() successful ");
375 375
376 } 376 }
377} 377}
378 378
379void KSyncManager::multiSync( bool askforPrefs ) 379void KSyncManager::multiSync( bool askforPrefs )
380{ 380{
381 if (blockSave()) 381 if (blockSave())
382 return; 382 return;
383 setBlockSave(true); 383 setBlockSave(true);
384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
386 question, 386 question,
387 i18n("Yes"), i18n("No"), 387 i18n("Yes"), i18n("No"),
388 0, 0 ) != 0 ) { 388 0, 0 ) != 0 ) {
389 setBlockSave(false); 389 setBlockSave(false);
390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
391 return; 391 return;
392 } 392 }
393 mCurrentSyncDevice = i18n("Multiple profiles") ; 393 mCurrentSyncDevice = i18n("Multiple profiles") ;
394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
395 if ( askforPrefs ) { 395 if ( askforPrefs ) {
396 edit_sync_options(); 396 edit_sync_options();
397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
398 } 398 }
399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
400 qApp->processEvents(); 400 qApp->processEvents();
401 int num = ringSync() ; 401 int num = ringSync() ;
402 if ( num > 1 ) 402 if ( num > 1 )
403 ringSync(); 403 ringSync();
404 setBlockSave(false); 404 setBlockSave(false);
405 if ( num ) 405 if ( num )
406 emit save(); 406 emit save();
407 if ( num ) 407 if ( num )
408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
409 else 409 else
410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
411 return; 411 return;
412} 412}
413 413
414int KSyncManager::ringSync() 414int KSyncManager::ringSync()
415{ 415{
416 int syncedProfiles = 0; 416 int syncedProfiles = 0;
417 unsigned int i; 417 unsigned int i;
418 QTime timer; 418 QTime timer;
419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
420 QStringList syncProfileNames = mSyncProfileNames; 420 QStringList syncProfileNames = mSyncProfileNames;
421 KSyncProfile* temp = new KSyncProfile (); 421 KSyncProfile* temp = new KSyncProfile ();
422 mAskForPreferences = false; 422 mAskForPreferences = false;
423 for ( i = 0; i < syncProfileNames.count(); ++i ) { 423 for ( i = 0; i < syncProfileNames.count(); ++i ) {
424 mCurrentSyncProfile = i; 424 mCurrentSyncProfile = i;
425 temp->setName(syncProfileNames[mCurrentSyncProfile]); 425 temp->setName(syncProfileNames[mCurrentSyncProfile]);
426 temp->readConfig(&config); 426 temp->readConfig(&config);
427 427
428 bool includeInRingSync; 428 bool includeInRingSync;
429 switch(mTargetApp) 429 switch(mTargetApp)
430 { 430 {
431 case (KAPI): 431 case (KAPI):
432 includeInRingSync = temp->getIncludeInRingSyncAB(); 432 includeInRingSync = temp->getIncludeInRingSyncAB();
433 break; 433 break;
434 case (KOPI): 434 case (KOPI):
435 includeInRingSync = temp->getIncludeInRingSync(); 435 includeInRingSync = temp->getIncludeInRingSync();
436 break; 436 break;
437 case (PWMPI): 437 case (PWMPI):
438 includeInRingSync = temp->getIncludeInRingSyncPWM(); 438 includeInRingSync = temp->getIncludeInRingSyncPWM();
439 break; 439 break;
440 default: 440 default:
441 qDebug("KSyncManager::ringSync: invalid apptype selected"); 441 qDebug("KSyncManager::ringSync: invalid apptype selected");
442 break; 442 break;
443 443
444 } 444 }
445 445
446 446
447 if ( includeInRingSync && ( i < 1 || i > 2 )) { 447 if ( includeInRingSync && ( i < 1 || i > 2 )) {
448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
449 ++syncedProfiles; 449 ++syncedProfiles;
450 // mAskForPreferences = temp->getAskForPreferences(); 450 // mAskForPreferences = temp->getAskForPreferences();
451 mWriteBackFile = temp->getWriteBackFile(); 451 mWriteBackFile = temp->getWriteBackFile();
452 mWriteBackExistingOnly = temp->getWriteBackExisting(); 452 mWriteBackExistingOnly = temp->getWriteBackExisting();
453 mWriteBackInFuture = 0; 453 mWriteBackInFuture = 0;
454 if ( temp->getWriteBackFuture() ) 454 if ( temp->getWriteBackFuture() )
455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
456 mShowSyncSummary = false; 456 mShowSyncSummary = false;
457 mCurrentSyncDevice = syncProfileNames[i] ; 457 mCurrentSyncDevice = syncProfileNames[i] ;
458 mCurrentSyncName = mLocalMachineName; 458 mCurrentSyncName = mLocalMachineName;
459 if ( i == 0 ) { 459 if ( i == 0 ) {
460 syncSharp(); 460 syncSharp();
461 } else { 461 } else {
462 if ( temp->getIsLocalFileSync() ) { 462 if ( temp->getIsLocalFileSync() ) {
463 switch(mTargetApp) 463 switch(mTargetApp)
464 { 464 {
465 case (KAPI): 465 case (KAPI):
466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
468 break; 468 break;
469 case (KOPI): 469 case (KOPI):
470 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
472 break; 472 break;
473 case (PWMPI): 473 case (PWMPI):
474 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 474 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
475 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 475 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
476 break; 476 break;
477 default: 477 default:
478 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 478 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
479 break; 479 break;
480 } 480 }
481 } else { 481 } else {
482 if ( temp->getIsPhoneSync() ) { 482 if ( temp->getIsPhoneSync() ) {
483 mPhoneDevice = temp->getPhoneDevice( ) ; 483 mPhoneDevice = temp->getPhoneDevice( ) ;
484 mPhoneConnection = temp->getPhoneConnection( ); 484 mPhoneConnection = temp->getPhoneConnection( );
485 mPhoneModel = temp->getPhoneModel( ); 485 mPhoneModel = temp->getPhoneModel( );
486 syncPhone(); 486 syncPhone();
487 } else if ( temp->getIsPiSync() ) { 487 } else if ( temp->getIsPiSync() ) {
488 if ( mTargetApp == KAPI ) { 488 if ( mTargetApp == KAPI ) {
489 mPassWordPiSync = temp->getRemotePwAB(); 489 mPassWordPiSync = temp->getRemotePwAB();
490 mActiveSyncPort = temp->getRemotePortAB(); 490 mActiveSyncPort = temp->getRemotePortAB();
491 mActiveSyncIP = temp->getRemoteIPAB(); 491 mActiveSyncIP = temp->getRemoteIPAB();
492 } else if ( mTargetApp == KOPI ) { 492 } else if ( mTargetApp == KOPI ) {
493 mPassWordPiSync = temp->getRemotePw(); 493 mPassWordPiSync = temp->getRemotePw();
494 mActiveSyncPort = temp->getRemotePort(); 494 mActiveSyncPort = temp->getRemotePort();
495 mActiveSyncIP = temp->getRemoteIP(); 495 mActiveSyncIP = temp->getRemoteIP();
496 } else { 496 } else {
497 mPassWordPiSync = temp->getRemotePwPWM(); 497 mPassWordPiSync = temp->getRemotePwPWM();
498 mActiveSyncPort = temp->getRemotePortPWM(); 498 mActiveSyncPort = temp->getRemotePortPWM();
499 mActiveSyncIP = temp->getRemoteIPPWM(); 499 mActiveSyncIP = temp->getRemoteIPPWM();
500 } 500 }
501 syncPi(); 501 syncPi();
502 } else 502 } else
503 syncRemote( temp, false ); 503 syncRemote( temp, false );
504 504
505 } 505 }
506 } 506 }
507 timer.start(); 507 timer.start();
508 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 508 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
509 while ( timer.elapsed () < 2000 ) { 509 while ( timer.elapsed () < 2000 ) {
510 qApp->processEvents(); 510 qApp->processEvents();
511#ifndef _WIN32_ 511#ifndef _WIN32_
512 sleep (1); 512 sleep (1);
513#endif 513#endif
514 } 514 }
515 515
516 } 516 }
517 517
518 } 518 }
519 delete temp; 519 delete temp;
520 return syncedProfiles; 520 return syncedProfiles;
521} 521}
522 522
523void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 523void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
524{ 524{
525 QString question; 525 QString question;
526 if ( ask ) { 526 if ( ask ) {
527 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 527 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
528 if ( QMessageBox::information( mParent, i18n("Sync"), 528 if ( QMessageBox::information( mParent, i18n("Sync"),
529 question, 529 question,
530 i18n("Yes"), i18n("No"), 530 i18n("Yes"), i18n("No"),
531 0, 0 ) != 0 ) 531 0, 0 ) != 0 )
532 return; 532 return;
533 } 533 }
534 534
535 QString preCommand; 535 QString preCommand;
536 QString localTempFile; 536 QString localTempFile;
537 QString postCommand; 537 QString postCommand;
538 538
539 switch(mTargetApp) 539 switch(mTargetApp)
540 { 540 {
541 case (KAPI): 541 case (KAPI):
542 preCommand = prof->getPreSyncCommandAB(); 542 preCommand = prof->getPreSyncCommandAB();
543 postCommand = prof->getPostSyncCommandAB(); 543 postCommand = prof->getPostSyncCommandAB();
544 localTempFile = prof->getLocalTempFileAB(); 544 localTempFile = prof->getLocalTempFileAB();
545 break; 545 break;
546 case (KOPI): 546 case (KOPI):
547 preCommand = prof->getPreSyncCommand(); 547 preCommand = prof->getPreSyncCommand();
548 postCommand = prof->getPostSyncCommand(); 548 postCommand = prof->getPostSyncCommand();
549 localTempFile = prof->getLocalTempFile(); 549 localTempFile = prof->getLocalTempFile();
550 break; 550 break;
551 case (PWMPI): 551 case (PWMPI):
552 preCommand = prof->getPreSyncCommandPWM(); 552 preCommand = prof->getPreSyncCommandPWM();
553 postCommand = prof->getPostSyncCommandPWM(); 553 postCommand = prof->getPostSyncCommandPWM();
554 localTempFile = prof->getLocalTempFilePWM(); 554 localTempFile = prof->getLocalTempFilePWM();
555 break; 555 break;
556 default: 556 default:
557 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 557 qDebug("KSyncManager::syncRemote: invalid apptype selected");
558 break; 558 break;
559 } 559 }
560 560
561 561
562 int fi; 562 int fi;
563 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 563 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
564 QString pwd = getPassword(); 564 QString pwd = getPassword();
565 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 565 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
566 566
567 } 567 }
568 int maxlen = 30; 568 int maxlen = 30;
569 if ( QApplication::desktop()->width() > 320 ) 569 if ( QApplication::desktop()->width() > 320 )
570 maxlen += 25; 570 maxlen += 25;
571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 571 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
572 int fileSize = 0; 572 int fileSize = 0;
573 int result = system ( preCommand ); 573 int result = system ( preCommand );
574 // 0 : okay 574 // 0 : okay
575 // 256: no such file or dir 575 // 256: no such file or dir
576 // 576 //
577 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 577 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
578 if ( result != 0 ) { 578 if ( result != 0 ) {
579 unsigned int len = maxlen; 579 unsigned int len = maxlen;
580 while ( len < preCommand.length() ) { 580 while ( len < preCommand.length() ) {
581 preCommand.insert( len , "\n" ); 581 preCommand.insert( len , "\n" );
582 len += maxlen +2; 582 len += maxlen +2;
583 } 583 }
584 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 584 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
585 QMessageBox::information( mParent, i18n("Sync - ERROR"), 585 QMessageBox::information( mParent, i18n("Sync - ERROR"),
586 question, 586 question,
587 i18n("Okay!")) ; 587 i18n("Okay!")) ;
588 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 588 mParent->topLevelWidget()->setCaption ("KDE-Pim");
589 return; 589 return;
590 } 590 }
591 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 591 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
592 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 592 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
593 593
594 if ( syncWithFile( localTempFile, true ) ) { 594 if ( syncWithFile( localTempFile, true ) ) {
595 595
596 if ( mWriteBackFile ) { 596 if ( mWriteBackFile ) {
597 int fi; 597 int fi;
598 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 598 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
599 QString pwd = getPassword(); 599 QString pwd = getPassword();
600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 600 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
601 601
602 } 602 }
603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
604 result = system ( postCommand ); 604 result = system ( postCommand );
605 qDebug("Writing back file result: %d ", result); 605 qDebug("Sync:Writing back file result: %d ", result);
606 if ( result != 0 ) { 606 if ( result != 0 ) {
607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 607 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
608 return; 608 return;
609 } else { 609 } else {
610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 610 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
611 } 611 }
612 } 612 }
613 } 613 }
614 return; 614 return;
615} 615}
616void KSyncManager::edit_pisync_options() 616void KSyncManager::edit_pisync_options()
617{ 617{
618 QDialog dia( mParent, "dia", true ); 618 QDialog dia( mParent, "dia", true );
619 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 619 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
620 QVBoxLayout lay ( &dia ); 620 QVBoxLayout lay ( &dia );
621 lay.setSpacing( 5 ); 621 lay.setSpacing( 5 );
622 lay.setMargin( 3 ); 622 lay.setMargin( 3 );
623 QLabel lab1 ( i18n("Password for remote access:"), &dia); 623 QLabel lab1 ( i18n("Password for remote access:"), &dia);
624 lay.addWidget( &lab1 ); 624 lay.addWidget( &lab1 );
625 QLineEdit le1 (&dia ); 625 QLineEdit le1 (&dia );
626 lay.addWidget( &le1 ); 626 lay.addWidget( &le1 );
627 QLabel lab2 ( i18n("Remote IP address:"), &dia); 627 QLabel lab2 ( i18n("Remote IP address:"), &dia);
628 lay.addWidget( &lab2 ); 628 lay.addWidget( &lab2 );
629 QLineEdit le2 (&dia ); 629 QLineEdit le2 (&dia );
630 lay.addWidget( &le2 ); 630 lay.addWidget( &le2 );
631 QLabel lab3 ( i18n("Remote port number:"), &dia); 631 QLabel lab3 ( i18n("Remote port number:"), &dia);
632 lay.addWidget( &lab3 ); 632 lay.addWidget( &lab3 );
633 QLineEdit le3 (&dia ); 633 QLineEdit le3 (&dia );
634 lay.addWidget( &le3 ); 634 lay.addWidget( &le3 );
635 QPushButton pb ( "OK", &dia); 635 QPushButton pb ( "OK", &dia);
636 lay.addWidget( &pb ); 636 lay.addWidget( &pb );
637 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 637 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
638 le1.setText( mPassWordPiSync ); 638 le1.setText( mPassWordPiSync );
639 le2.setText( mActiveSyncIP ); 639 le2.setText( mActiveSyncIP );
640 le3.setText( mActiveSyncPort ); 640 le3.setText( mActiveSyncPort );
641 if ( dia.exec() ) { 641 if ( dia.exec() ) {
642 mPassWordPiSync = le1.text(); 642 mPassWordPiSync = le1.text();
643 mActiveSyncPort = le3.text(); 643 mActiveSyncPort = le3.text();
644 mActiveSyncIP = le2.text(); 644 mActiveSyncIP = le2.text();
645 } 645 }
646 646
647} 647}
648void KSyncManager::edit_sync_options() 648void KSyncManager::edit_sync_options()
649{ 649{
650 650
651 QDialog dia( mParent, "dia", true ); 651 QDialog dia( mParent, "dia", true );
652 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 652 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
653 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 653 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
654 QVBoxLayout lay ( &dia ); 654 QVBoxLayout lay ( &dia );
655 lay.setSpacing( 2 ); 655 lay.setSpacing( 2 );
656 lay.setMargin( 3 ); 656 lay.setMargin( 3 );
657 lay.addWidget(&gr); 657 lay.addWidget(&gr);
658 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 658 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
659 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 659 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
660 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 660 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
661 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 661 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
662 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 662 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
663 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 663 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
664 //QRadioButton both( i18n("Take both on conflict"), &gr ); 664 //QRadioButton both( i18n("Take both on conflict"), &gr );
665 QPushButton pb ( "OK", &dia); 665 QPushButton pb ( "OK", &dia);
666 lay.addWidget( &pb ); 666 lay.addWidget( &pb );
667 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 667 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
668 switch ( mSyncAlgoPrefs ) { 668 switch ( mSyncAlgoPrefs ) {
669 case 0: 669 case 0:
670 loc.setChecked( true); 670 loc.setChecked( true);
671 break; 671 break;
672 case 1: 672 case 1:
673 rem.setChecked( true ); 673 rem.setChecked( true );
674 break; 674 break;
675 case 2: 675 case 2:
676 newest.setChecked( true); 676 newest.setChecked( true);
677 break; 677 break;
678 case 3: 678 case 3:
679 ask.setChecked( true); 679 ask.setChecked( true);
680 break; 680 break;
681 case 4: 681 case 4:
682 f_loc.setChecked( true); 682 f_loc.setChecked( true);
683 break; 683 break;
684 case 5: 684 case 5:
685 f_rem.setChecked( true); 685 f_rem.setChecked( true);
686 break; 686 break;
687 case 6: 687 case 6:
688 // both.setChecked( true); 688 // both.setChecked( true);
689 break; 689 break;
690 default: 690 default:
691 break; 691 break;
692 } 692 }
693 if ( dia.exec() ) { 693 if ( dia.exec() ) {
694 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 694 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
695 } 695 }
696 696
697 697
698} 698}
699 699
700QString KSyncManager::getPassword( ) 700QString KSyncManager::getPassword( )
701{ 701{
702 QString retfile = ""; 702 QString retfile = "";
703 QDialog dia ( mParent, "input-dialog", true ); 703 QDialog dia ( mParent, "input-dialog", true );
704 QLineEdit lab ( &dia ); 704 QLineEdit lab ( &dia );
705 lab.setEchoMode( QLineEdit::Password ); 705 lab.setEchoMode( QLineEdit::Password );
706 QVBoxLayout lay( &dia ); 706 QVBoxLayout lay( &dia );
707 lay.setMargin(7); 707 lay.setMargin(7);
708 lay.setSpacing(7); 708 lay.setSpacing(7);
709 lay.addWidget( &lab); 709 lay.addWidget( &lab);
710 dia.setFixedSize( 230,50 ); 710 dia.setFixedSize( 230,50 );
711 dia.setCaption( i18n("Enter password") ); 711 dia.setCaption( i18n("Enter password") );
712 QPushButton pb ( "OK", &dia); 712 QPushButton pb ( "OK", &dia);
713 lay.addWidget( &pb ); 713 lay.addWidget( &pb );
714 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 714 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
715 dia.show(); 715 dia.show();
716 int res = dia.exec(); 716 int res = dia.exec();
717 if ( res ) 717 if ( res )
718 retfile = lab.text(); 718 retfile = lab.text();
719 dia.hide(); 719 dia.hide();
720 qApp->processEvents(); 720 qApp->processEvents();
721 return retfile; 721 return retfile;
722 722
723} 723}
724 724
725 725
726void KSyncManager::confSync() 726void KSyncManager::confSync()
727{ 727{
728 static KSyncPrefsDialog* sp = 0; 728 static KSyncPrefsDialog* sp = 0;
729 if ( ! sp ) { 729 if ( ! sp ) {
730 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 730 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
731 } 731 }
732 sp->usrReadConfig(); 732 sp->usrReadConfig();
733#ifndef DESKTOP_VERSION 733#ifndef DESKTOP_VERSION
734 sp->showMaximized(); 734 sp->showMaximized();
735#else 735#else
736 sp->show(); 736 sp->show();
737#endif 737#endif
738 sp->exec(); 738 sp->exec();
739 mSyncProfileNames = sp->getSyncProfileNames(); 739 mSyncProfileNames = sp->getSyncProfileNames();
740 mLocalMachineName = sp->getLocalMachineName (); 740 mLocalMachineName = sp->getLocalMachineName ();
741 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 741 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
742} 742}
743 743
744void KSyncManager::syncSharp() 744void KSyncManager::syncSharp()
745{ 745{
746 746
747 if ( ! syncExternalApplication("sharp") ) 747 if ( ! syncExternalApplication("sharp") )
748 qDebug("ERROR sync sharp ");; 748 qDebug("ERROR sync sharp ");
749} 749}
750 750
751bool KSyncManager::syncExternalApplication(QString resource) 751bool KSyncManager::syncExternalApplication(QString resource)
752{ 752{
753 753
754 emit save(); 754 emit save();
755 755
756 if ( mAskForPreferences ) 756 if ( mAskForPreferences )
757 edit_sync_options(); 757 edit_sync_options();
758 758
759 qDebug("sync %s", resource.latin1()); 759 qDebug("Sync extern %s", resource.latin1());
760 760
761 bool syncOK = mImplementation->syncExternal(this, resource); 761 bool syncOK = mImplementation->syncExternal(this, resource);
762 762
763 return syncOK; 763 return syncOK;
764 764
765} 765}
766 766
767void KSyncManager::syncPhone() 767void KSyncManager::syncPhone()
768{ 768{
769 769
770 syncExternalApplication("phone"); 770 syncExternalApplication("phone");
771 771
772} 772}
773 773
774void KSyncManager::showProgressBar(int percentage, QString caption, int total) 774void KSyncManager::showProgressBar(int percentage, QString caption, int total)
775{ 775{
776 if (!bar->isVisible()) 776 if (!bar->isVisible())
777 { 777 {
778 bar->setCaption (caption); 778 bar->setCaption (caption);
779 bar->setTotalSteps ( total ) ; 779 bar->setTotalSteps ( total ) ;
780 780
781 bar->show(); 781 bar->show();
782 } 782 }
783 783
784 bar->setProgress( percentage ); 784 bar->setProgress( percentage );
785} 785}
786 786
787void KSyncManager::hideProgressBar() 787void KSyncManager::hideProgressBar()
788{ 788{
789 bar->hide(); 789 bar->hide();
790} 790}
791 791
792bool KSyncManager::isProgressBarCanceled() 792bool KSyncManager::isProgressBarCanceled()
793{ 793{
794 return !bar->isVisible(); 794 return !bar->isVisible();
795} 795}
796 796
797QString KSyncManager::syncFileName() 797QString KSyncManager::syncFileName()
798{ 798{
799 799
800 QString fn = "tempfile"; 800 QString fn = "tempfile";
801 switch(mTargetApp) 801 switch(mTargetApp)
802 { 802 {
803 case (KAPI): 803 case (KAPI):
804 fn = "tempsyncab.vcf"; 804 fn = "tempsyncab.vcf";
805 break; 805 break;
806 case (KOPI): 806 case (KOPI):
807 fn = "tempsynccal.ics"; 807 fn = "tempsynccal.ics";
808 break; 808 break;
809 case (PWMPI): 809 case (PWMPI):
810 fn = "tempsyncpw.pwm"; 810 fn = "tempsyncpw.pwm";
811 break; 811 break;
812 default: 812 default:
813 break; 813 break;
814 } 814 }
815#ifdef _WIN32_ 815#ifdef _WIN32_
816 return locateLocal( "tmp", fn ); 816 return locateLocal( "tmp", fn );
817#else 817#else
818 return (QString( "/tmp/" )+ fn ); 818 return (QString( "/tmp/" )+ fn );
819#endif 819#endif
820} 820}
821 821
822void KSyncManager::syncPi() 822void KSyncManager::syncPi()
823{ 823{
824 qApp->processEvents(); 824 qApp->processEvents();
825 if ( mAskForPreferences ) 825 if ( mAskForPreferences )
826 edit_pisync_options(); 826 edit_pisync_options();
827 bool ok; 827 bool ok;
828 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 828 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
829 if ( ! ok ) { 829 if ( ! ok ) {
830 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 830 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
831 return; 831 return;
832 } 832 }
833 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 833 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
834 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 834 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 835 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
836 commandSocket->readFile( syncFileName() ); 836 commandSocket->readFile( syncFileName() );
837} 837}
838 838
839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 839void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
840{ 840{
841 qDebug("MainWindow::deleteCommandSocket %d", state);
842
843 //enum { success, errorW, errorR, quiet }; 841 //enum { success, errorW, errorR, quiet };
844 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 842 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
845 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 843 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
846 delete s; 844 delete s;
847 if ( state == KCommandSocket::errorR ) { 845 if ( state == KCommandSocket::errorR ) {
848 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 846 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
849 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 847 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
850 commandSocket->sendStop(); 848 commandSocket->sendStop();
851 } 849 }
852 return; 850 return;
853 851
854 } else if ( state == KCommandSocket::errorW ) { 852 } else if ( state == KCommandSocket::errorW ) {
855 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 853 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
856 854
857 } else if ( state == KCommandSocket::successR ) { 855 } else if ( state == KCommandSocket::successR ) {
858 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 856 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
859 857
860 } else if ( state == KCommandSocket::successW ) { 858 } else if ( state == KCommandSocket::successW ) {
861 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 859 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
862 } 860 }
863 861
864 delete s; 862 delete s;
865} 863}
866 864
867void KSyncManager::readFileFromSocket() 865void KSyncManager::readFileFromSocket()
868{ 866{
869 QString fileName = syncFileName(); 867 QString fileName = syncFileName();
870 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 868 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
871 if ( ! syncWithFile( fileName , true ) ) { 869 if ( ! syncWithFile( fileName , true ) ) {
872 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 870 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
873 qDebug("Syncing failed ");
874 return; 871 return;
875 } 872 }
876 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 873 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
877 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 874 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
878 if ( mWriteBackFile ) 875 if ( mWriteBackFile )
879 commandSocket->writeFile( fileName ); 876 commandSocket->writeFile( fileName );
880 else { 877 else {
881 commandSocket->sendStop(); 878 commandSocket->sendStop();
882 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 879 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
883 } 880 }
884} 881}
885 882
886KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 883KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
887{ 884{
888 mPassWord = pw; 885 mPassWord = pw;
889 mSocket = 0; 886 mSocket = 0;
890 mSyncActionDialog = 0; 887 mSyncActionDialog = 0;
891 blockRC = false; 888 blockRC = false;
892}; 889};
893 890
894void KServerSocket::newConnection ( int socket ) 891void KServerSocket::newConnection ( int socket )
895{ 892{
896 // qDebug("KServerSocket:New connection %d ", socket); 893 // qDebug("KServerSocket:New connection %d ", socket);
897 if ( mSocket ) { 894 if ( mSocket ) {
898 qDebug("KServerSocket::newConnection Socket deleted! "); 895 qDebug("KServerSocket::newConnection Socket deleted! ");
899 delete mSocket; 896 delete mSocket;
900 mSocket = 0; 897 mSocket = 0;
901 } 898 }
902 mSocket = new QSocket( this ); 899 mSocket = new QSocket( this );
903 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 900 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
904 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 901 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
905 mSocket->setSocket( socket ); 902 mSocket->setSocket( socket );
906} 903}
907 904
908void KServerSocket::discardClient() 905void KServerSocket::discardClient()
909{ 906{
910 //qDebug(" KServerSocket::discardClient()"); 907 //qDebug(" KServerSocket::discardClient()");
911 if ( mSocket ) { 908 if ( mSocket ) {
912 delete mSocket; 909 delete mSocket;
913 mSocket = 0; 910 mSocket = 0;
914 } 911 }
915 //emit endConnect(); 912 //emit endConnect();
916} 913}
917void KServerSocket::readClient() 914void KServerSocket::readClient()
918{ 915{
919 if ( blockRC ) 916 if ( blockRC )
920 return; 917 return;
921 if ( mSocket == 0 ) { 918 if ( mSocket == 0 ) {
922 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 919 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
923 return; 920 return;
924 } 921 }
925 qDebug("KServerSocket readClient()"); 922 //qDebug("KServerSocket::readClient()");
926 if ( mSocket->canReadLine() ) { 923 if ( mSocket->canReadLine() ) {
927 QString line = mSocket->readLine(); 924 QString line = mSocket->readLine();
928 qDebug("KServerSocket readline: %s ", line.latin1()); 925 //qDebug("KServerSocket readline: %s ", line.latin1());
929 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 926 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
930 if ( tokens[0] == "GET" ) { 927 if ( tokens[0] == "GET" ) {
931 if ( tokens[1] == mPassWord ) 928 if ( tokens[1] == mPassWord )
932 //emit sendFile( mSocket ); 929 //emit sendFile( mSocket );
933 send_file(); 930 send_file();
934 else { 931 else {
935 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 932 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
936 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 933 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
937 } 934 }
938 } 935 }
939 if ( tokens[0] == "PUT" ) { 936 if ( tokens[0] == "PUT" ) {
940 if ( tokens[1] == mPassWord ) { 937 if ( tokens[1] == mPassWord ) {
941 //emit getFile( mSocket ); 938 //emit getFile( mSocket );
942 blockRC = true; 939 blockRC = true;
943 get_file(); 940 get_file();
944 } 941 }
945 else { 942 else {
946 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 943 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
947 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 944 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
948 } 945 }
949 } 946 }
950 if ( tokens[0] == "STOP" ) { 947 if ( tokens[0] == "STOP" ) {
951 //emit endConnect(); 948 //emit endConnect();
952 end_connect(); 949 end_connect();
953 } 950 }
954 } 951 }
955} 952}
956void KServerSocket::end_connect() 953void KServerSocket::end_connect()
957{ 954{
958 delete mSyncActionDialog; 955 delete mSyncActionDialog;
959 mSyncActionDialog = 0; 956 mSyncActionDialog = 0;
960} 957}
961void KServerSocket::send_file() 958void KServerSocket::send_file()
962{ 959{
963 //qDebug("MainWindow::sendFile(QSocket* s) "); 960 //qDebug("MainWindow::sendFile(QSocket* s) ");
964 if ( mSyncActionDialog ) 961 if ( mSyncActionDialog )
965 delete mSyncActionDialog; 962 delete mSyncActionDialog;
966 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 963 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
967 mSyncActionDialog->setCaption(i18n("Received sync request")); 964 mSyncActionDialog->setCaption(i18n("Received sync request"));
968 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 965 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
969 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 966 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
970 lay->addWidget( label); 967 lay->addWidget( label);
971 lay->setMargin(7); 968 lay->setMargin(7);
972 lay->setSpacing(7); 969 lay->setSpacing(7);
973 mSyncActionDialog->setFixedSize( 230, 120); 970 mSyncActionDialog->setFixedSize( 230, 120);
974 mSyncActionDialog->show(); 971 mSyncActionDialog->show();
975 mSyncActionDialog->raise(); 972 mSyncActionDialog->raise();
976 qDebug("KSS::saving ... ");
977 emit request_file(); 973 emit request_file();
978 qApp->processEvents(); 974 qApp->processEvents();
979 QString fileName = mFileName; 975 QString fileName = mFileName;
980 QFile file( fileName ); 976 QFile file( fileName );
981 if (!file.open( IO_ReadOnly ) ) { 977 if (!file.open( IO_ReadOnly ) ) {
982 delete mSyncActionDialog; 978 delete mSyncActionDialog;
983 mSyncActionDialog = 0; 979 mSyncActionDialog = 0;
984 qDebug("KSS::error open file "); 980 qDebug("KSS::error open file ");
985 mSocket->close(); 981 mSocket->close();
986 if ( mSocket->state() == QSocket::Idle ) 982 if ( mSocket->state() == QSocket::Idle )
987 QTimer::singleShot( 10, this , SLOT ( discardClient())); 983 QTimer::singleShot( 10, this , SLOT ( discardClient()));
988 return ; 984 return ;
989 985
990 } 986 }
991 mSyncActionDialog->setCaption( i18n("Sending file...") ); 987 mSyncActionDialog->setCaption( i18n("Sending file...") );
992 QTextStream ts( &file ); 988 QTextStream ts( &file );
993 ts.setEncoding( QTextStream::Latin1 ); 989 ts.setEncoding( QTextStream::Latin1 );
994 990
995 QTextStream os( mSocket ); 991 QTextStream os( mSocket );
996 os.setEncoding( QTextStream::Latin1 ); 992 os.setEncoding( QTextStream::Latin1 );
997 while ( ! ts.atEnd() ) { 993 while ( ! ts.atEnd() ) {
998 os << ts.readLine() << "\n"; 994 os << ts.readLine() << "\n";
999 } 995 }
1000 //os << ts.read(); 996 //os << ts.read();
1001 file.close(); 997 file.close();
1002 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 998 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1003 mSocket->close(); 999 mSocket->close();
1004 if ( mSocket->state() == QSocket::Idle ) 1000 if ( mSocket->state() == QSocket::Idle )
1005 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1001 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1006} 1002}
1007void KServerSocket::get_file() 1003void KServerSocket::get_file()
1008{ 1004{
1009 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1005 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1010 1006
1011 piTime.start(); 1007 piTime.start();
1012 piFileString = ""; 1008 piFileString = "";
1013 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1009 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1014} 1010}
1015 1011
1016 1012
1017void KServerSocket::readBackFileFromSocket() 1013void KServerSocket::readBackFileFromSocket()
1018{ 1014{
1019 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1015 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1020 while ( mSocket->canReadLine () ) { 1016 while ( mSocket->canReadLine () ) {
1021 piTime.restart(); 1017 piTime.restart();
1022 QString line = mSocket->readLine (); 1018 QString line = mSocket->readLine ();
1023 piFileString += line; 1019 piFileString += line;
1024 //qDebug("readline: %s ", line.latin1()); 1020 //qDebug("readline: %s ", line.latin1());
1025 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1021 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1026 1022
1027 } 1023 }
1028 if ( piTime.elapsed () < 3000 ) { 1024 if ( piTime.elapsed () < 3000 ) {
1029 // wait for more 1025 // wait for more
1030 //qDebug("waitformore "); 1026 //qDebug("waitformore ");
1031 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1027 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1032 return; 1028 return;
1033 } 1029 }
1034 QString fileName = mFileName; 1030 QString fileName = mFileName;
1035 QFile file ( fileName ); 1031 QFile file ( fileName );
1036 if (!file.open( IO_WriteOnly ) ) { 1032 if (!file.open( IO_WriteOnly ) ) {
1037 delete mSyncActionDialog; 1033 delete mSyncActionDialog;
1038 mSyncActionDialog = 0; 1034 mSyncActionDialog = 0;
1039 qDebug("error open cal file "); 1035 qDebug("KSS:Error open read back file ");
1040 piFileString = ""; 1036 piFileString = "";
1041 emit file_received( false ); 1037 emit file_received( false );
1042 blockRC = false; 1038 blockRC = false;
1043 return ; 1039 return ;
1044 1040
1045 } 1041 }
1046 1042
1047 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1043 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1048 QTextStream ts ( &file ); 1044 QTextStream ts ( &file );
1049 ts.setEncoding( QTextStream::Latin1 ); 1045 ts.setEncoding( QTextStream::Latin1 );
1050 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1046 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1051 ts << piFileString; 1047 ts << piFileString;
1052 mSocket->close(); 1048 mSocket->close();
1053 if ( mSocket->state() == QSocket::Idle ) 1049 if ( mSocket->state() == QSocket::Idle )
1054 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1050 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1055 file.close(); 1051 file.close();
1056 delete mSyncActionDialog; 1052 delete mSyncActionDialog;
1057 mSyncActionDialog = 0; 1053 mSyncActionDialog = 0;
1058 piFileString = ""; 1054 piFileString = "";
1059 blockRC = false; 1055 blockRC = false;
1060 emit file_received( true ); 1056 emit file_received( true );
1061 1057
1062} 1058}
1063 1059
1064KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1060KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1065{ 1061{
1066 mPassWord = password; 1062 mPassWord = password;
1067 mSocket = 0; 1063 mSocket = 0;
1068 mPort = port; 1064 mPort = port;
1069 mHost = host; 1065 mHost = host;
1070 1066
1071 mRetVal = quiet; 1067 mRetVal = quiet;
1072 mTimerSocket = new QTimer ( this ); 1068 mTimerSocket = new QTimer ( this );
1073 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1069 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1074} 1070}
1075void KCommandSocket::readFile( QString fn ) 1071void KCommandSocket::readFile( QString fn )
1076{ 1072{
1077 if ( !mSocket ) { 1073 if ( !mSocket ) {
1078 mSocket = new QSocket( this ); 1074 mSocket = new QSocket( this );
1079 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1075 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1080 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1076 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1081 } 1077 }
1082 mFileString = ""; 1078 mFileString = "";
1083 mFileName = fn; 1079 mFileName = fn;
1084 mFirst = true; 1080 mFirst = true;
1085 mSocket->connectToHost( mHost, mPort ); 1081 mSocket->connectToHost( mHost, mPort );
1086 QTextStream os( mSocket ); 1082 QTextStream os( mSocket );
1087 os.setEncoding( QTextStream::Latin1 ); 1083 os.setEncoding( QTextStream::Latin1 );
1088 os << "GET " << mPassWord << "\r\n"; 1084 os << "GET " << mPassWord << "\r\n";
1089 mTimerSocket->start( 10000 ); 1085 mTimerSocket->start( 10000 );
1090} 1086}
1091 1087
1092void KCommandSocket::writeFile( QString fileName ) 1088void KCommandSocket::writeFile( QString fileName )
1093{ 1089{
1094 if ( !mSocket ) { 1090 if ( !mSocket ) {
1095 mSocket = new QSocket( this ); 1091 mSocket = new QSocket( this );
1096 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1092 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1097 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1093 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1098 } 1094 }
1099 mFileName = fileName ; 1095 mFileName = fileName ;
1100 mSocket->connectToHost( mHost, mPort ); 1096 mSocket->connectToHost( mHost, mPort );
1101} 1097}
1102void KCommandSocket::writeFileToSocket() 1098void KCommandSocket::writeFileToSocket()
1103{ 1099{
1104 QFile file2( mFileName ); 1100 QFile file2( mFileName );
1105 if (!file2.open( IO_ReadOnly ) ) { 1101 if (!file2.open( IO_ReadOnly ) ) {
1106 mRetVal= errorW; 1102 mRetVal= errorW;
1107 mSocket->close(); 1103 mSocket->close();
1108 if ( mSocket->state() == QSocket::Idle ) 1104 if ( mSocket->state() == QSocket::Idle )
1109 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1105 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1110 return ; 1106 return ;
1111 } 1107 }
1112 QTextStream ts2( &file2 ); 1108 QTextStream ts2( &file2 );
1113 ts2.setEncoding( QTextStream::Latin1 ); 1109 ts2.setEncoding( QTextStream::Latin1 );
1114 QTextStream os2( mSocket ); 1110 QTextStream os2( mSocket );
1115 os2.setEncoding( QTextStream::Latin1 ); 1111 os2.setEncoding( QTextStream::Latin1 );
1116 os2 << "PUT " << mPassWord << "\r\n";; 1112 os2 << "PUT " << mPassWord << "\r\n";;
1117 while ( ! ts2.atEnd() ) { 1113 while ( ! ts2.atEnd() ) {
1118 os2 << ts2.readLine() << "\n"; 1114 os2 << ts2.readLine() << "\n";
1119 } 1115 }
1120 mRetVal= successW; 1116 mRetVal= successW;
1121 file2.close(); 1117 file2.close();
1122 mSocket->close(); 1118 mSocket->close();
1123 if ( mSocket->state() == QSocket::Idle ) 1119 if ( mSocket->state() == QSocket::Idle )
1124 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1120 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1125} 1121}
1126void KCommandSocket::sendStop() 1122void KCommandSocket::sendStop()
1127{ 1123{
1128 if ( !mSocket ) { 1124 if ( !mSocket ) {
1129 mSocket = new QSocket( this ); 1125 mSocket = new QSocket( this );
1130 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1126 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1131 } 1127 }
1132 mSocket->connectToHost( mHost, mPort ); 1128 mSocket->connectToHost( mHost, mPort );
1133 QTextStream os2( mSocket ); 1129 QTextStream os2( mSocket );
1134 os2.setEncoding( QTextStream::Latin1 ); 1130 os2.setEncoding( QTextStream::Latin1 );
1135 os2 << "STOP\r\n"; 1131 os2 << "STOP\r\n";
1136 mSocket->close(); 1132 mSocket->close();
1137 if ( mSocket->state() == QSocket::Idle ) 1133 if ( mSocket->state() == QSocket::Idle )
1138 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1134 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1139} 1135}
1140 1136
1141void KCommandSocket::startReadFileFromSocket() 1137void KCommandSocket::startReadFileFromSocket()
1142{ 1138{
1143 if ( ! mFirst ) 1139 if ( ! mFirst )
1144 return; 1140 return;
1145 mFirst = false; 1141 mFirst = false;
1146 mTimerSocket->stop(); 1142 mTimerSocket->stop();
1147 mFileString = ""; 1143 mFileString = "";
1148 mTime.start(); 1144 mTime.start();
1149 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1145 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1150 1146
1151} 1147}
1152void KCommandSocket::readFileFromSocket() 1148void KCommandSocket::readFileFromSocket()
1153{ 1149{
1154 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1150 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1155 while ( mSocket->canReadLine () ) { 1151 while ( mSocket->canReadLine () ) {
1156 mTime.restart(); 1152 mTime.restart();
1157 QString line = mSocket->readLine (); 1153 QString line = mSocket->readLine ();
1158 mFileString += line; 1154 mFileString += line;
1159 //qDebug("readline: %s ", line.latin1()); 1155 //qDebug("readline: %s ", line.latin1());
1160 } 1156 }
1161 if ( mTime.elapsed () < 3000 ) { 1157 if ( mTime.elapsed () < 3000 ) {
1162 // wait for more 1158 // wait for more
1163 //qDebug("waitformore "); 1159 //qDebug("waitformore ");
1164 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1160 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1165 return; 1161 return;
1166 } 1162 }
1167 QString fileName = mFileName; 1163 QString fileName = mFileName;
1168 QFile file ( fileName ); 1164 QFile file ( fileName );
1169 if (!file.open( IO_WriteOnly ) ) { 1165 if (!file.open( IO_WriteOnly ) ) {
1170 mFileString = ""; 1166 mFileString = "";
1171 mRetVal = errorR; 1167 mRetVal = errorR;
1172 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1168 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1173 deleteSocket(); 1169 deleteSocket();
1174 return ; 1170 return ;
1175 1171
1176 } 1172 }
1177 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1173 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1178 QTextStream ts ( &file ); 1174 QTextStream ts ( &file );
1179 ts.setEncoding( QTextStream::Latin1 ); 1175 ts.setEncoding( QTextStream::Latin1 );
1180 ts << mFileString; 1176 ts << mFileString;
1181 file.close(); 1177 file.close();
1182 mFileString = ""; 1178 mFileString = "";
1183 mRetVal = successR; 1179 mRetVal = successR;
1184 mSocket->close(); 1180 mSocket->close();
1185 // if state is not idle, deleteSocket(); is called via 1181 // if state is not idle, deleteSocket(); is called via
1186 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1182 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1187 if ( mSocket->state() == QSocket::Idle ) 1183 if ( mSocket->state() == QSocket::Idle )
1188 deleteSocket(); 1184 deleteSocket();
1189} 1185}
1190 1186
1191void KCommandSocket::deleteSocket() 1187void KCommandSocket::deleteSocket()
1192{ 1188{
1193 //qDebug("KCommandSocket::deleteSocket() "); 1189 //qDebug("KCommandSocket::deleteSocket() ");
1194 if ( mTimerSocket->isActive () ) { 1190 if ( mTimerSocket->isActive () ) {
1195 mTimerSocket->stop(); 1191 mTimerSocket->stop();
1196 mRetVal = errorTO; 1192 mRetVal = errorTO;
1197 qDebug("Connection to remote host timed out"); 1193 qDebug("Connection to remote host timed out");
1198 if ( mSocket ) { 1194 if ( mSocket ) {
1199 mSocket->close(); 1195 mSocket->close();
1200 //if ( mSocket->state() == QSocket::Idle ) 1196 //if ( mSocket->state() == QSocket::Idle )
1201 // deleteSocket(); 1197 // deleteSocket();
1202 delete mSocket; 1198 delete mSocket;
1203 mSocket = 0; 1199 mSocket = 0;
1204 } 1200 }
1205 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1201 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1206 emit commandFinished( this, mRetVal ); 1202 emit commandFinished( this, mRetVal );
1207 return; 1203 return;
1208 } 1204 }
1209 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1205 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1210 if ( mSocket) 1206 if ( mSocket)
1211 delete mSocket; 1207 delete mSocket;
1212 mSocket = 0; 1208 mSocket = 0;
1213 emit commandFinished( this, mRetVal ); 1209 emit commandFinished( this, mRetVal );
1214} 1210}
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index ba41f6c..5b685d3 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -1,547 +1,547 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qwidget.h> 3#include <qwidget.h>
4 4
5#include "kdebug.h" 5#include "kdebug.h"
6 6
7#include "kurl.h" 7#include "kurl.h"
8#include "kstandarddirs.h" 8#include "kstandarddirs.h"
9#include "kconfig.h" 9#include "kconfig.h"
10 10
11QString KConfig::mGroup = ""; 11QString KConfig::mGroup = "";
12//QString KConfig::mGroup = "General"; 12//QString KConfig::mGroup = "General";
13 13
14KConfig::KConfig( const QString &fileName ) 14KConfig::KConfig( const QString &fileName )
15 : mFileName( fileName ), mDirty( false ) 15 : mFileName( fileName ), mDirty( false )
16{ 16{
17 17
18 mTempGroup = ""; 18 mTempGroup = "";
19 load(); 19 load();
20 20
21} 21}
22 22
23 23
24KConfig::~KConfig() 24KConfig::~KConfig()
25{ 25{
26 sync(); 26 sync();
27} 27}
28// we need the temp group for plugins on windows 28// we need the temp group for plugins on windows
29void KConfig::setTempGroup( const QString &group ) 29void KConfig::setTempGroup( const QString &group )
30{ 30{
31 mTempGroup = group; 31 mTempGroup = group;
32 32
33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; 33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/";
34} 34}
35 35
36 36
37QString KConfig::tempGroup() const { 37QString KConfig::tempGroup() const {
38 return mTempGroup; 38 return mTempGroup;
39} 39}
40 40
41void KConfig::setGroup( const QString &group ) 41void KConfig::setGroup( const QString &group )
42{ 42{
43 43
44 44
45 mGroup = group; 45 mGroup = group;
46 46
47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; 47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
48} 48}
49 49
50//US 50//US
51QString KConfig::group() const { 51QString KConfig::group() const {
52 return mGroup; 52 return mGroup;
53} 53}
54 54
55//US added method 55//US added method
56QValueList<int> KConfig::readIntListEntry( const QString & key) 56QValueList<int> KConfig::readIntListEntry( const QString & key)
57{ 57{
58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); 58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1());
59 59
60 QValueList<int> result; 60 QValueList<int> result;
61 61
62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); 62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key );
63 63
64 if ( mit == mStringMap.end() ) { 64 if ( mit == mStringMap.end() ) {
65 return result; 65 return result;
66 } 66 }
67 67
68 QStringList valuesAsStrings = QStringList::split(":", *mit ); 68 QStringList valuesAsStrings = QStringList::split(":", *mit );
69 bool ok = false; 69 bool ok = false;
70 bool ok2 = true; 70 bool ok2 = true;
71 int val; 71 int val;
72 72
73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { 73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) {
74 val = (*sit).toInt(&ok); 74 val = (*sit).toInt(&ok);
75 result << val; 75 result << val;
76 if (ok == false) { 76 if (ok == false) {
77 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); 77 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val);
78 ok2 = false; 78 ok2 = false;
79 } 79 }
80 } 80 }
81 81
82 if (ok2 == false) 82 if (ok2 == false)
83 { 83 {
84 84
85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); 85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues.");
86 } 86 }
87 87
88 return result; 88 return result;
89} 89}
90 90
91int KConfig::readNumEntry( const QString & key, int def ) 91int KConfig::readNumEntry( const QString & key, int def )
92{ 92{
93 QString res = readEntry(key, QString::number(def ) ); 93 QString res = readEntry(key, QString::number(def ) );
94 bool ok = false; 94 bool ok = false;
95 int result = res.toInt(&ok); 95 int result = res.toInt(&ok);
96 if ( ok ) 96 if ( ok )
97 return result; 97 return result;
98 return def; 98 return def;
99} 99}
100 100
101QString KConfig::readEntry( const QString &key, const QString &def ) 101QString KConfig::readEntry( const QString &key, const QString &def )
102{ 102{
103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
104 104
105 if ( it == mStringMap.end() ) { 105 if ( it == mStringMap.end() ) {
106 return def; 106 return def;
107 } 107 }
108 108
109 return *it; 109 return *it;
110} 110}
111 111
112QSize KConfig::readSizeEntry( const QString &key, QSize* def ) 112QSize KConfig::readSizeEntry( const QString &key, QSize* def )
113{ 113{
114 QValueList<int> intlist = readIntListEntry(key); 114 QValueList<int> intlist = readIntListEntry(key);
115 115
116 if (intlist.count() < 2) 116 if (intlist.count() < 2)
117 { 117 {
118 if (def) 118 if (def)
119 return *def; 119 return *def;
120 else 120 else
121 return QSize(); 121 return QSize();
122 } 122 }
123 123
124 QSize ret; 124 QSize ret;
125 ret.setWidth(intlist[0]); 125 ret.setWidth(intlist[0]);
126 ret.setHeight(intlist[1]); 126 ret.setHeight(intlist[1]);
127 127
128 return ret; 128 return ret;
129} 129}
130 130
131QStringList KConfig::readListEntry( const QString &key ) 131QStringList KConfig::readListEntry( const QString &key )
132{ 132{
133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
134 134
135 if ( it == mStringMap.end() ) { 135 if ( it == mStringMap.end() ) {
136 return QStringList(); 136 return QStringList();
137 } 137 }
138 return QStringList::split(":", *it ); 138 return QStringList::split(":", *it );
139 139
140} 140}
141 141
142bool KConfig::readBoolEntry( const QString &key, bool def ) 142bool KConfig::readBoolEntry( const QString &key, bool def )
143{ 143{
144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
145 145
146 if ( it == mBoolMap.end() ) { 146 if ( it == mBoolMap.end() ) {
147 return def; 147 return def;
148 } 148 }
149 149
150 return *it; 150 return *it;
151} 151}
152 152
153QColor KConfig::readColorEntry( const QString & e, QColor *def ) 153QColor KConfig::readColorEntry( const QString & e, QColor *def )
154{ 154{
155 155
156 QStringList l; 156 QStringList l;
157 l = readListEntry( e ); 157 l = readListEntry( e );
158 if (l.count() != 3 ) { 158 if (l.count() != 3 ) {
159 if ( def ) 159 if ( def )
160 return *def; 160 return *def;
161 else 161 else
162 return QColor(); 162 return QColor();
163 } 163 }
164 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); 164 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() );
165 return c; 165 return c;
166} 166}
167 167
168QFont KConfig::readFontEntry( const QString & e, QFont *def ) 168QFont KConfig::readFontEntry( const QString & e, QFont *def )
169{ 169{
170 QStringList font = readListEntry( e ); 170 QStringList font = readListEntry( e );
171 if ( font.isEmpty() ) 171 if ( font.isEmpty() )
172 return *def; 172 return *def;
173 QFont f; 173 QFont f;
174 f.setFamily( font[0]); 174 f.setFamily( font[0]);
175 f.setBold ( font[1] == "bold"); 175 f.setBold ( font[1] == "bold");
176 f.setPointSize ( font[2].toInt()); 176 f.setPointSize ( font[2].toInt());
177 f.setItalic( font[3] == "italic" ); 177 f.setItalic( font[3] == "italic" );
178 return f; 178 return f;
179} 179}
180 180
181QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 181QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
182{ 182{
183 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 183 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
184 184
185 if ( it == mDateTimeMap.end() ) { 185 if ( it == mDateTimeMap.end() ) {
186 if ( def ) return *def; 186 if ( def ) return *def;
187 else return QDateTime(); 187 else return QDateTime();
188 } 188 }
189 189
190 return *it; 190 return *it;
191} 191}
192 192
193//US added method 193//US added method
194void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 194void KConfig::writeEntry( const QString &key, const QValueList<int> &value)
195{ 195{
196 QStringList valuesAsStrings; 196 QStringList valuesAsStrings;
197 197
198 QValueList<int>::ConstIterator it; 198 QValueList<int>::ConstIterator it;
199 199
200 for( it = value.begin(); it != value.end(); ++it ) 200 for( it = value.begin(); it != value.end(); ++it )
201 { 201 {
202 valuesAsStrings << QString::number(*it); 202 valuesAsStrings << QString::number(*it);
203 } 203 }
204 204
205 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); 205 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") );
206 mDirty = true; 206 mDirty = true;
207} 207}
208 208
209void KConfig::writeEntry( const QString & key , int num ) 209void KConfig::writeEntry( const QString & key , int num )
210{ 210{
211 writeEntry( key, QString::number ( num ) ); 211 writeEntry( key, QString::number ( num ) );
212} 212}
213 213
214void KConfig::writeEntry( const QString &key, const QString &value ) 214void KConfig::writeEntry( const QString &key, const QString &value )
215{ 215{
216 mStringMap.insert( mGroup + key, value ); 216 mStringMap.insert( mGroup + key, value );
217 217
218 mDirty = true; 218 mDirty = true;
219} 219}
220 220
221void KConfig::writeEntry( const QString &key, const QStringList &value ) 221void KConfig::writeEntry( const QString &key, const QStringList &value )
222{ 222{
223 mStringMap.insert( mGroup + key, value.join(":") ); 223 mStringMap.insert( mGroup + key, value.join(":") );
224 224
225 mDirty = true; 225 mDirty = true;
226} 226}
227 227
228void KConfig::writeEntry( const QString &key, bool value) 228void KConfig::writeEntry( const QString &key, bool value)
229{ 229{
230 mBoolMap.insert( mGroup + key, value ); 230 mBoolMap.insert( mGroup + key, value );
231 231
232 mDirty = true; 232 mDirty = true;
233} 233}
234 234
235void KConfig::writeEntry( const QString & e, const QColor & c ) 235void KConfig::writeEntry( const QString & e, const QColor & c )
236{ 236{
237 QStringList l; 237 QStringList l;
238 l.append( QString::number ( c.red() ) ); 238 l.append( QString::number ( c.red() ) );
239 l.append( QString::number ( c.green() ) ); 239 l.append( QString::number ( c.green() ) );
240 l.append( QString::number ( c.blue() ) ); 240 l.append( QString::number ( c.blue() ) );
241 writeEntry( e, l ); 241 writeEntry( e, l );
242} 242}
243 243
244void KConfig::writeEntry( const QString & e, const QSize & s ) 244void KConfig::writeEntry( const QString & e, const QSize & s )
245{ 245{
246 QValueList<int> intlist; 246 QValueList<int> intlist;
247 intlist << s.width() << s.height(); 247 intlist << s.width() << s.height();
248 writeEntry( e, intlist ); 248 writeEntry( e, intlist );
249} 249}
250 250
251void KConfig::writeEntry( const QString & e , const QFont & f ) 251void KConfig::writeEntry( const QString & e , const QFont & f )
252{ 252{
253 QStringList font; 253 QStringList font;
254 font.append( f.family()); 254 font.append( f.family());
255 font.append( (!f.bold ()?"nonbold":"bold") ); 255 font.append( (!f.bold ()?"nonbold":"bold") );
256 font.append( QString::number ( f.pointSize () ) ); 256 font.append( QString::number ( f.pointSize () ) );
257 font.append( !f.italic ()?"nonitalic":"italic" ); 257 font.append( !f.italic ()?"nonitalic":"italic" );
258 writeEntry( e, font ); 258 writeEntry( e, font );
259} 259}
260 260
261void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 261void KConfig::writeEntry( const QString &key, const QDateTime &dt )
262{ 262{
263 mDateTimeMap.insert( mGroup + key, dt ); 263 mDateTimeMap.insert( mGroup + key, dt );
264} 264}
265 265
266void KConfig::load() 266void KConfig::load()
267{ 267{
268 268
269 269
270 QFile f( mFileName ); 270 QFile f( mFileName );
271 if ( !f.open( IO_ReadOnly ) ) { 271 if ( !f.open( IO_ReadOnly ) ) {
272 qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 272 //qDebug("KConfig: could not open file %s ",mFileName.latin1() );
273 return; 273 return;
274 } 274 }
275 275
276 mBoolMap.clear(); 276 mBoolMap.clear();
277 mStringMap.clear(); 277 mStringMap.clear();
278 278
279 QTextStream t( &f ); 279 QTextStream t( &f );
280 280
281 QString line = t.readLine(); 281 QString line = t.readLine();
282 282
283 while ( !line.isNull() ) { 283 while ( !line.isNull() ) {
284 QStringList tokens = QStringList::split( ",", line ); 284 QStringList tokens = QStringList::split( ",", line );
285 if ( tokens[0] == "bool" ) { 285 if ( tokens[0] == "bool" ) {
286 bool value = false; 286 bool value = false;
287 if ( tokens[2] == "1" ) value = true; 287 if ( tokens[2] == "1" ) value = true;
288 mBoolMap.insert( tokens[1], value ); 288 mBoolMap.insert( tokens[1], value );
289 } else if ( tokens[0] == "QString" ) { 289 } else if ( tokens[0] == "QString" ) {
290 QString value = tokens[2]; 290 QString value = tokens[2];
291 mStringMap.insert( tokens[1], value ); 291 mStringMap.insert( tokens[1], value );
292 } else if ( tokens[0] == "QDateTime" ) { 292 } else if ( tokens[0] == "QDateTime" ) {
293#if 0 293#if 0
294 int year = tokens[2].toInt(); 294 int year = tokens[2].toInt();
295 QDateTime dt( QDate( year, 295 QDateTime dt( QDate( year,
296 tokens[3].toInt(), 296 tokens[3].toInt(),
297 tokens[4].toInt() ), 297 tokens[4].toInt() ),
298 QTime( tokens[5].toInt(), tokens[6].toInt(), 298 QTime( tokens[5].toInt(), tokens[6].toInt(),
299 tokens[7].toInt() ) ); 299 tokens[7].toInt() ) );
300 mDateTimeMap.insert( tokens[1], dt ); 300 mDateTimeMap.insert( tokens[1], dt );
301#endif 301#endif
302 } 302 }
303 303
304 line = t.readLine(); 304 line = t.readLine();
305 } 305 }
306} 306}
307 307
308void KConfig::sync() 308void KConfig::sync()
309{ 309{
310 310
311 if ( !mDirty ) return; 311 if ( !mDirty ) return;
312 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 312 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
313 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 313 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
314 314
315//US I took the following code from a newer version of KDE 315//US I took the following code from a newer version of KDE
316 // Create the containing dir if needed 316 // Create the containing dir if needed
317 KURL path; 317 KURL path;
318 path.setPath(mFileName); 318 path.setPath(mFileName);
319 QString dir=path.directory(); 319 QString dir=path.directory();
320 KStandardDirs::makeDir(dir); 320 KStandardDirs::makeDir(dir);
321 321
322 QFile f( mFileName ); 322 QFile f( mFileName );
323 if ( !f.open( IO_WriteOnly ) ) { 323 if ( !f.open( IO_WriteOnly ) ) {
324 324
325 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 325 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
326 326
327 return; 327 return;
328 } 328 }
329 329
330 QTextStream t( &f ); 330 QTextStream t( &f );
331 331
332 QMap<QString,bool>::ConstIterator itBool; 332 QMap<QString,bool>::ConstIterator itBool;
333 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 333 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
334 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 334 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
335 } 335 }
336 336
337 QMap<QString,QString>::ConstIterator itString; 337 QMap<QString,QString>::ConstIterator itString;
338 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 338 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
339 t << "QString," << itString.key() << "," << (*itString ) << endl; 339 t << "QString," << itString.key() << "," << (*itString ) << endl;
340 } 340 }
341 341
342 QMap<QString,QDateTime>::ConstIterator itDateTime; 342 QMap<QString,QDateTime>::ConstIterator itDateTime;
343 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 343 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
344 QDateTime dt = *itDateTime; 344 QDateTime dt = *itDateTime;
345 t << "QDateTime," << itDateTime.key() << "," 345 t << "QDateTime," << itDateTime.key() << ","
346 << dt.date().year() << "," 346 << dt.date().year() << ","
347 << dt.date().month() << "," 347 << dt.date().month() << ","
348 << dt.date().day() << "," 348 << dt.date().day() << ","
349 << dt.time().hour() << "," 349 << dt.time().hour() << ","
350 << dt.time().minute() << "," 350 << dt.time().minute() << ","
351 << dt.time().second() << endl; 351 << dt.time().second() << endl;
352 } 352 }
353 353
354 f.close(); 354 f.close();
355 355
356 mDirty = false; 356 mDirty = false;
357} 357}
358 358
359 359
360//US I took the following deleteGroup method from a newer version from KDE. 360//US I took the following deleteGroup method from a newer version from KDE.
361/** 361/**
362 * Deletes a configuration entry group 362 * Deletes a configuration entry group
363 * 363 *
364 * If the group is not empty and bDeep is false, nothing gets 364 * If the group is not empty and bDeep is false, nothing gets
365 * deleted and false is returned. 365 * deleted and false is returned.
366 * If this group is the current group and it is deleted, the 366 * If this group is the current group and it is deleted, the
367 * current group is undefined and should be set with setGroup() 367 * current group is undefined and should be set with setGroup()
368 * before the next operation on the configuration object. 368 * before the next operation on the configuration object.
369 * 369 *
370 * @param group The name of the group 370 * @param group The name of the group
371 * returns true if we deleted at least one entry. 371 * returns true if we deleted at least one entry.
372 */ 372 */
373bool KConfig::deleteGroup( const QString& group) 373bool KConfig::deleteGroup( const QString& group)
374{ 374{
375 bool dirty = false; 375 bool dirty = false;
376 int pos; 376 int pos;
377 377
378 QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); 378 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
379 QMap<QString,bool>::Iterator delBool; 379 QMap<QString,bool>::Iterator delBool;
380 380
381 while ( itBool != mBoolMap.end() ) { 381 while ( itBool != mBoolMap.end() ) {
382 pos = itBool.key().find( group ); 382 pos = itBool.key().find( group );
383 if (pos == 0) { 383 if (pos == 0) {
384 delBool = itBool; 384 delBool = itBool;
385 ++itBool; 385 ++itBool;
386 mBoolMap.remove(delBool); 386 mBoolMap.remove(delBool);
387 dirty = true; 387 dirty = true;
388 } else 388 } else
389 ++itBool; 389 ++itBool;
390 390
391 } 391 }
392 /* 392 /*
393 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 393 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
394 { 394 {
395 pos = itBool.key().find( group ); 395 pos = itBool.key().find( group );
396 if (pos == 0) { 396 if (pos == 0) {
397 mBoolMap.remove(itBool); 397 mBoolMap.remove(itBool);
398 dirty = true; 398 dirty = true;
399 } 399 }
400 } 400 }
401 */ 401 */
402 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 402 QMap<QString,QString>::Iterator itString = mStringMap.begin();
403 QMap<QString,QString>::Iterator delString ; 403 QMap<QString,QString>::Iterator delString ;
404 while( itString != mStringMap.end() ) { 404 while( itString != mStringMap.end() ) {
405 pos = itString.key().find( group ); 405 pos = itString.key().find( group );
406 if (pos == 0) { 406 if (pos == 0) {
407 delString = itString; 407 delString = itString;
408 ++itString; 408 ++itString;
409 mStringMap.remove(delString); 409 mStringMap.remove(delString);
410 //qDebug("delte++++++++++++++++++ "); 410 //qDebug("delte++++++++++++++++++ ");
411 dirty = true; 411 dirty = true;
412 } else 412 } else
413 ++itString; 413 ++itString;
414 414
415 } 415 }
416 /* this leads to a memory access violation 416 /* this leads to a memory access violation
417 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 417 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
418 { 418 {
419 pos = itString.key().find( group ); 419 pos = itString.key().find( group );
420 if (pos == 0) { 420 if (pos == 0) {
421 mStringMap.remove(itString); 421 mStringMap.remove(itString);
422 dirty = true; 422 dirty = true;
423 } 423 }
424 } 424 }
425 */ 425 */
426 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 426 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
427 QMap<QString,QDateTime>::Iterator delDateTime; 427 QMap<QString,QDateTime>::Iterator delDateTime;
428 while ( itDateTime != mDateTimeMap.end() ) { 428 while ( itDateTime != mDateTimeMap.end() ) {
429 pos = itDateTime.key().find( group ); 429 pos = itDateTime.key().find( group );
430 if (pos == 0) { 430 if (pos == 0) {
431 delDateTime = itDateTime; 431 delDateTime = itDateTime;
432 ++itDateTime; 432 ++itDateTime;
433 mDateTimeMap.remove(delDateTime); 433 mDateTimeMap.remove(delDateTime);
434 dirty = true; 434 dirty = true;
435 } else 435 } else
436 ++itDateTime; 436 ++itDateTime;
437 437
438 } 438 }
439 /* 439 /*
440 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 440 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
441 { 441 {
442 pos = itDateTime.key().find( group ); 442 pos = itDateTime.key().find( group );
443 if (pos == 0) { 443 if (pos == 0) {
444 mDateTimeMap.remove(itDateTime); 444 mDateTimeMap.remove(itDateTime);
445 dirty = true; 445 dirty = true;
446 } 446 }
447 } 447 }
448 */ 448 */
449 449
450 if (dirty) 450 if (dirty)
451 mDirty = true; 451 mDirty = true;
452 452
453 return dirty; 453 return dirty;
454 454
455} 455}
456 456
457//US I took the following hasGroup method from a newer version from KDE. 457//US I took the following hasGroup method from a newer version from KDE.
458 /** 458 /**
459 * Returns true if the specified group is known about. 459 * Returns true if the specified group is known about.
460 * 460 *
461 * @param group The group to search for. 461 * @param group The group to search for.
462 * @return Whether the group exists. 462 * @return Whether the group exists.
463 */ 463 */
464bool KConfig::hasGroup(const QString &group) const 464bool KConfig::hasGroup(const QString &group) const
465{ 465{
466 QMap<QString,bool>::ConstIterator itBool; 466 QMap<QString,bool>::ConstIterator itBool;
467 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 467 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
468 { 468 {
469 if (itBool.key().find( group ) == 0) { 469 if (itBool.key().find( group ) == 0) {
470 return true; 470 return true;
471 } 471 }
472 } 472 }
473 473
474 QMap<QString,QString>::ConstIterator itString; 474 QMap<QString,QString>::ConstIterator itString;
475 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 475 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
476 { 476 {
477 if (itString.key().find( group ) == 0) { 477 if (itString.key().find( group ) == 0) {
478 return true; 478 return true;
479 } 479 }
480 } 480 }
481 481
482 QMap<QString,QDateTime>::ConstIterator itDateTime; 482 QMap<QString,QDateTime>::ConstIterator itDateTime;
483 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 483 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
484 { 484 {
485 if (itDateTime.key().find( group ) == 0) { 485 if (itDateTime.key().find( group ) == 0) {
486 return true; 486 return true;
487 } 487 }
488 } 488 }
489 489
490 return false; 490 return false;
491} 491}
492 492
493void KConfig::deleteEntry( const QString &key) 493void KConfig::deleteEntry( const QString &key)
494{ 494{
495 bool dirty = false; 495 bool dirty = false;
496 496
497 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 497 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
498 if ( itBool != mBoolMap.end() ) { 498 if ( itBool != mBoolMap.end() ) {
499 mBoolMap.remove(itBool); 499 mBoolMap.remove(itBool);
500 dirty = true; 500 dirty = true;
501 } 501 }
502 502
503 503
504 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 504 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
505 if ( itString != mStringMap.end() ) { 505 if ( itString != mStringMap.end() ) {
506 mStringMap.remove(itString); 506 mStringMap.remove(itString);
507 dirty = true; 507 dirty = true;
508 } 508 }
509 509
510 510
511 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 511 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
512 if ( itDateTime != mDateTimeMap.end() ) { 512 if ( itDateTime != mDateTimeMap.end() ) {
513 mDateTimeMap.remove(itDateTime); 513 mDateTimeMap.remove(itDateTime);
514 dirty = true; 514 dirty = true;
515 } 515 }
516 516
517 if (dirty) 517 if (dirty)
518 mDirty = true; 518 mDirty = true;
519 519
520} 520}
521 521
522//US 522//US
523QString KConfig::getFileName() 523QString KConfig::getFileName()
524{ 524{
525 return mFileName; 525 return mFileName;
526} 526}
527 527
528bool KConfig::hasKey( const QString &key) 528bool KConfig::hasKey( const QString &key)
529{ 529{
530 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 530 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
531 if ( itBool != mBoolMap.end() ) { 531 if ( itBool != mBoolMap.end() ) {
532 return true; 532 return true;
533 } 533 }
534 534
535 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 535 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
536 if ( itString != mStringMap.end() ) { 536 if ( itString != mStringMap.end() ) {
537 return true; 537 return true;
538 } 538 }
539 539
540 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 540 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
541 if ( itDateTime != mDateTimeMap.end() ) { 541 if ( itDateTime != mDateTimeMap.end() ) {
542 return true; 542 return true;
543 } 543 }
544 544
545 return false; 545 return false;
546} 546}
547 547
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index 1c3e0ae..4c03c15 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1175,488 +1175,488 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode)
1175 if (stat(baseEncoded, &st) != 0) 1175 if (stat(baseEncoded, &st) != 0)
1176 { 1176 {
1177 // Directory does not exist.... 1177 // Directory does not exist....
1178 // Or maybe a dangling symlink ? 1178 // Or maybe a dangling symlink ?
1179 if (lstat(baseEncoded, &st) == 0) 1179 if (lstat(baseEncoded, &st) == 0)
1180 (void)unlink(baseEncoded); // try removing 1180 (void)unlink(baseEncoded); // try removing
1181 1181
1182 1182
1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1184 perror("trying to create local folder"); 1184 perror("trying to create local folder");
1185 return false; // Couldn't create it :-( 1185 return false; // Couldn't create it :-(
1186 } 1186 }
1187 } 1187 }
1188*/ 1188*/
1189 1189
1190 if (dirObj.exists(base) == false) 1190 if (dirObj.exists(base) == false)
1191 { 1191 {
1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1193 if (dirObj.mkdir(base) != true) 1193 if (dirObj.mkdir(base) != true)
1194 { 1194 {
1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1196 return false; 1196 return false;
1197 } 1197 }
1198 } 1198 }
1199 1199
1200 i = pos + 1; 1200 i = pos + 1;
1201 } 1201 }
1202 return true; 1202 return true;
1203 1203
1204} 1204}
1205 1205
1206static QString readEnvPath(const char *env) 1206static QString readEnvPath(const char *env)
1207{ 1207{
1208 //#ifdef _WIN32_ 1208 //#ifdef _WIN32_
1209 // return ""; 1209 // return "";
1210 //#else 1210 //#else
1211 QCString c_path; 1211 QCString c_path;
1212 if ( getenv(env) != NULL ) 1212 if ( getenv(env) != NULL )
1213 c_path = QString ( getenv(env) ); 1213 c_path = QString ( getenv(env) );
1214 if (c_path.isEmpty()) 1214 if (c_path.isEmpty())
1215 return QString::null; 1215 return QString::null;
1216 return QFile::decodeName(c_path); 1216 return QFile::decodeName(c_path);
1217 //#endif 1217 //#endif
1218 1218
1219} 1219}
1220 1220
1221void KStandardDirs::addKDEDefaults() 1221void KStandardDirs::addKDEDefaults()
1222{ 1222{
1223 1223
1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1225 //return; 1225 //return;
1226 QStringList kdedirList; 1226 QStringList kdedirList;
1227 1227
1228 // begin KDEDIRS 1228 // begin KDEDIRS
1229 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1229 QString kdedirs = readEnvPath("MICROKDEDIRS");
1230 if (!kdedirs.isEmpty()) 1230 if (!kdedirs.isEmpty())
1231 { 1231 {
1232 tokenize(kdedirList, kdedirs, ":"); 1232 tokenize(kdedirList, kdedirs, ":");
1233 } 1233 }
1234 else 1234 else
1235 { 1235 {
1236 QString kdedir = readEnvPath("MICROKDEDIR"); 1236 QString kdedir = readEnvPath("MICROKDEDIR");
1237 if (!kdedir.isEmpty()) 1237 if (!kdedir.isEmpty())
1238 { 1238 {
1239 kdedir = KShell::tildeExpand(kdedir); 1239 kdedir = KShell::tildeExpand(kdedir);
1240 kdedirList.append(kdedir); 1240 kdedirList.append(kdedir);
1241 } 1241 }
1242 } 1242 }
1243//US kdedirList.append(KDEDIR); 1243//US kdedirList.append(KDEDIR);
1244//US for embedded, add qtopia dir as kdedir 1244//US for embedded, add qtopia dir as kdedir
1245 1245
1246#ifndef DESKTOP_VERSION 1246#ifndef DESKTOP_VERSION
1247 QString tmp = readEnvPath("QPEDIR"); 1247 QString tmp = readEnvPath("QPEDIR");
1248 if (!tmp.isEmpty()) 1248 if (!tmp.isEmpty())
1249 kdedirList.append(tmp); 1249 kdedirList.append(tmp);
1250 1250
1251 tmp = readEnvPath("QTDIR"); 1251 tmp = readEnvPath("QTDIR");
1252 if (!tmp.isEmpty()) 1252 if (!tmp.isEmpty())
1253 kdedirList.append(tmp); 1253 kdedirList.append(tmp);
1254 1254
1255 tmp = readEnvPath("OPIEDIR"); 1255 tmp = readEnvPath("OPIEDIR");
1256 if (!tmp.isEmpty()) 1256 if (!tmp.isEmpty())
1257 kdedirList.append(tmp); 1257 kdedirList.append(tmp);
1258 1258
1259#endif 1259#endif
1260 1260
1261#ifdef __KDE_EXECPREFIX 1261#ifdef __KDE_EXECPREFIX
1262 QString execPrefix(__KDE_EXECPREFIX); 1262 QString execPrefix(__KDE_EXECPREFIX);
1263 if (execPrefix!="NONE") 1263 if (execPrefix!="NONE")
1264 kdedirList.append(execPrefix); 1264 kdedirList.append(execPrefix);
1265#endif 1265#endif
1266 1266
1267 QString localKdeDir; 1267 QString localKdeDir;
1268 1268
1269//US if (getuid()) 1269//US if (getuid())
1270 if (true) 1270 if (true)
1271 { 1271 {
1272 localKdeDir = readEnvPath("MICROKDEHOME"); 1272 localKdeDir = readEnvPath("MICROKDEHOME");
1273 if (!localKdeDir.isEmpty()) 1273 if (!localKdeDir.isEmpty())
1274 { 1274 {
1275#ifdef _WIN32_ 1275#ifdef _WIN32_
1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\') 1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\')
1277 localKdeDir += '\\'; 1277 localKdeDir += '\\';
1278#else 1278#else
1279 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1279 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1280 localKdeDir += '/'; 1280 localKdeDir += '/';
1281#endif 1281#endif
1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); 1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
1283 } 1283 }
1284 else 1284 else
1285 { 1285 {
1286 localKdeDir = QDir::homeDirPath() + "/kdepim/"; 1286 localKdeDir = QDir::homeDirPath() + "/kdepim/";
1287 } 1287 }
1288 } 1288 }
1289 else 1289 else
1290 { 1290 {
1291 // We treat root different to prevent root messing up the 1291 // We treat root different to prevent root messing up the
1292 // file permissions in the users home directory. 1292 // file permissions in the users home directory.
1293 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1293 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1294 if (!localKdeDir.isEmpty()) 1294 if (!localKdeDir.isEmpty())
1295 { 1295 {
1296 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1296 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1297 localKdeDir += '/'; 1297 localKdeDir += '/';
1298 } 1298 }
1299 else 1299 else
1300 { 1300 {
1301//US struct passwd *pw = getpwuid(0); 1301//US struct passwd *pw = getpwuid(0);
1302//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1302//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1303 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1303 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1304 } 1304 }
1305 1305
1306 } 1306 }
1307 1307
1308//US localKdeDir = appDir(); 1308//US localKdeDir = appDir();
1309 1309
1310//US 1310//US
1311// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1311// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1312 if (localKdeDir != "-/") 1312 if (localKdeDir != "-/")
1313 { 1313 {
1314 localKdeDir = KShell::tildeExpand(localKdeDir); 1314 localKdeDir = KShell::tildeExpand(localKdeDir);
1315 addPrefix(localKdeDir); 1315 addPrefix(localKdeDir);
1316 } 1316 }
1317 1317
1318 for (QStringList::ConstIterator it = kdedirList.begin(); 1318 for (QStringList::ConstIterator it = kdedirList.begin();
1319 it != kdedirList.end(); it++) 1319 it != kdedirList.end(); it++)
1320 { 1320 {
1321 QString dir = KShell::tildeExpand(*it); 1321 QString dir = KShell::tildeExpand(*it);
1322 addPrefix(dir); 1322 addPrefix(dir);
1323 } 1323 }
1324 // end KDEDIRS 1324 // end KDEDIRS
1325 1325
1326 // begin XDG_CONFIG_XXX 1326 // begin XDG_CONFIG_XXX
1327 QStringList xdgdirList; 1327 QStringList xdgdirList;
1328 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1328 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1329 if (!xdgdirs.isEmpty()) 1329 if (!xdgdirs.isEmpty())
1330 { 1330 {
1331 tokenize(xdgdirList, xdgdirs, ":"); 1331 tokenize(xdgdirList, xdgdirs, ":");
1332 } 1332 }
1333 else 1333 else
1334 { 1334 {
1335 xdgdirList.clear(); 1335 xdgdirList.clear();
1336 xdgdirList.append("/etc/xdg"); 1336 xdgdirList.append("/etc/xdg");
1337 } 1337 }
1338 1338
1339 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1339 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1340 if (!localXdgDir.isEmpty()) 1340 if (!localXdgDir.isEmpty())
1341 { 1341 {
1342 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1342 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1343 localXdgDir += '/'; 1343 localXdgDir += '/';
1344 } 1344 }
1345 else 1345 else
1346 { 1346 {
1347//US if (getuid()) 1347//US if (getuid())
1348 if (true) 1348 if (true)
1349 { 1349 {
1350 localXdgDir = QDir::homeDirPath() + "/.config/"; 1350 localXdgDir = QDir::homeDirPath() + "/.config/";
1351 } 1351 }
1352 else 1352 else
1353 { 1353 {
1354//US struct passwd *pw = getpwuid(0); 1354//US struct passwd *pw = getpwuid(0);
1355//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1355//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1356 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1356 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1357 } 1357 }
1358 } 1358 }
1359 1359
1360 localXdgDir = KShell::tildeExpand(localXdgDir); 1360 localXdgDir = KShell::tildeExpand(localXdgDir);
1361 addXdgConfigPrefix(localXdgDir); 1361 addXdgConfigPrefix(localXdgDir);
1362 1362
1363 for (QStringList::ConstIterator it = xdgdirList.begin(); 1363 for (QStringList::ConstIterator it = xdgdirList.begin();
1364 it != xdgdirList.end(); it++) 1364 it != xdgdirList.end(); it++)
1365 { 1365 {
1366 QString dir = KShell::tildeExpand(*it); 1366 QString dir = KShell::tildeExpand(*it);
1367 addXdgConfigPrefix(dir); 1367 addXdgConfigPrefix(dir);
1368 } 1368 }
1369 // end XDG_CONFIG_XXX 1369 // end XDG_CONFIG_XXX
1370 1370
1371 // begin XDG_DATA_XXX 1371 // begin XDG_DATA_XXX
1372 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1372 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1373 if (!xdgdirs.isEmpty()) 1373 if (!xdgdirs.isEmpty())
1374 { 1374 {
1375 tokenize(xdgdirList, xdgdirs, ":"); 1375 tokenize(xdgdirList, xdgdirs, ":");
1376 } 1376 }
1377 else 1377 else
1378 { 1378 {
1379 xdgdirList.clear(); 1379 xdgdirList.clear();
1380 for (QStringList::ConstIterator it = kdedirList.begin(); 1380 for (QStringList::ConstIterator it = kdedirList.begin();
1381 it != kdedirList.end(); it++) 1381 it != kdedirList.end(); it++)
1382 { 1382 {
1383 QString dir = *it; 1383 QString dir = *it;
1384 if (dir.at(dir.length()-1) != '/') 1384 if (dir.at(dir.length()-1) != '/')
1385 dir += '/'; 1385 dir += '/';
1386 xdgdirList.append(dir+"share/"); 1386 xdgdirList.append(dir+"share/");
1387 } 1387 }
1388 1388
1389 xdgdirList.append("/usr/local/share/"); 1389 xdgdirList.append("/usr/local/share/");
1390 xdgdirList.append("/usr/share/"); 1390 xdgdirList.append("/usr/share/");
1391 } 1391 }
1392 1392
1393 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1393 localXdgDir = readEnvPath("XDG_DATA_HOME");
1394 if (!localXdgDir.isEmpty()) 1394 if (!localXdgDir.isEmpty())
1395 { 1395 {
1396 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1396 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1397 localXdgDir += '/'; 1397 localXdgDir += '/';
1398 } 1398 }
1399 else 1399 else
1400 { 1400 {
1401//US if (getuid()) 1401//US if (getuid())
1402 if (true) 1402 if (true)
1403 { 1403 {
1404 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1404 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1405 } 1405 }
1406 else 1406 else
1407 { 1407 {
1408//US struct passwd *pw = getpwuid(0); 1408//US struct passwd *pw = getpwuid(0);
1409//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1409//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1410 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1410 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1411 } 1411 }
1412 } 1412 }
1413 1413
1414 localXdgDir = KShell::tildeExpand(localXdgDir); 1414 localXdgDir = KShell::tildeExpand(localXdgDir);
1415 addXdgDataPrefix(localXdgDir); 1415 addXdgDataPrefix(localXdgDir);
1416 1416
1417 for (QStringList::ConstIterator it = xdgdirList.begin(); 1417 for (QStringList::ConstIterator it = xdgdirList.begin();
1418 it != xdgdirList.end(); it++) 1418 it != xdgdirList.end(); it++)
1419 { 1419 {
1420 QString dir = KShell::tildeExpand(*it); 1420 QString dir = KShell::tildeExpand(*it);
1421 1421
1422 addXdgDataPrefix(dir); 1422 addXdgDataPrefix(dir);
1423 } 1423 }
1424 // end XDG_DATA_XXX 1424 // end XDG_DATA_XXX
1425 1425
1426 1426
1427 uint index = 0; 1427 uint index = 0;
1428 while (types[index] != 0) { 1428 while (types[index] != 0) {
1429 addResourceType(types[index], kde_default(types[index])); 1429 addResourceType(types[index], kde_default(types[index]));
1430 index++; 1430 index++;
1431 } 1431 }
1432 1432
1433 addResourceDir("home", QDir::homeDirPath()); 1433 addResourceDir("home", QDir::homeDirPath());
1434} 1434}
1435 1435
1436void KStandardDirs::checkConfig() const 1436void KStandardDirs::checkConfig() const
1437{ 1437{
1438/*US 1438/*US
1439 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1439 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1440 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1440 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1441*/ 1441*/
1442 if (!addedCustoms && KGlobal::config()) 1442 if (!addedCustoms && KGlobal::config())
1443 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1443 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1444} 1444}
1445 1445
1446bool KStandardDirs::addCustomized(KConfig *config) 1446bool KStandardDirs::addCustomized(KConfig *config)
1447{ 1447{
1448 if (addedCustoms) // there are already customized entries 1448 if (addedCustoms) // there are already customized entries
1449 return false; // we just quite and hope they are the right ones 1449 return false; // we just quite and hope they are the right ones
1450 1450
1451 // save the numbers of config directories. If this changes, 1451 // save the numbers of config directories. If this changes,
1452 // we will return true to give KConfig a chance to reparse 1452 // we will return true to give KConfig a chance to reparse
1453 uint configdirs = resourceDirs("config").count(); 1453 uint configdirs = resourceDirs("config").count();
1454 1454
1455 // reading the prefixes in 1455 // reading the prefixes in
1456 QString oldGroup = config->group(); 1456 QString oldGroup = config->group();
1457 config->setGroup("Directories"); 1457 config->setGroup("Directories");
1458 1458
1459 QStringList list; 1459 QStringList list;
1460 QStringList::ConstIterator it; 1460 QStringList::ConstIterator it;
1461 list = config->readListEntry("prefixes"); 1461 list = config->readListEntry("prefixes");
1462 for (it = list.begin(); it != list.end(); it++) 1462 for (it = list.begin(); it != list.end(); it++)
1463 addPrefix(*it); 1463 addPrefix(*it);
1464 1464
1465 // iterating over all entries in the group Directories 1465 // iterating over all entries in the group Directories
1466 // to find entries that start with dir_$type 1466 // to find entries that start with dir_$type
1467/*US 1467/*US
1468 QMap<QString, QString> entries = config->entryMap("Directories"); 1468 QMap<QString, QString> entries = config->entryMap("Directories");
1469 1469
1470 QMap<QString, QString>::ConstIterator it2; 1470 QMap<QString, QString>::ConstIterator it2;
1471 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1471 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1472 { 1472 {
1473 QString key = it2.key(); 1473 QString key = it2.key();
1474 if (key.left(4) == "dir_") { 1474 if (key.left(4) == "dir_") {
1475 // generate directory list, there may be more than 1. 1475 // generate directory list, there may be more than 1.
1476 QStringList dirs = QStringList::split(',', *it2); 1476 QStringList dirs = QStringList::split(',', *it2);
1477 QStringList::Iterator sIt(dirs.begin()); 1477 QStringList::Iterator sIt(dirs.begin());
1478 QString resType = key.mid(4, key.length()); 1478 QString resType = key.mid(4, key.length());
1479 for (; sIt != dirs.end(); ++sIt) { 1479 for (; sIt != dirs.end(); ++sIt) {
1480 addResourceDir(resType.latin1(), *sIt); 1480 addResourceDir(resType.latin1(), *sIt);
1481 } 1481 }
1482 } 1482 }
1483 } 1483 }
1484 1484
1485 // Process KIOSK restrictions. 1485 // Process KIOSK restrictions.
1486 config->setGroup("KDE Resource Restrictions"); 1486 config->setGroup("KDE Resource Restrictions");
1487 entries = config->entryMap("KDE Resource Restrictions"); 1487 entries = config->entryMap("KDE Resource Restrictions");
1488 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1488 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1489 { 1489 {
1490 QString key = it2.key(); 1490 QString key = it2.key();
1491 if (!config->readBoolEntry(key, true)) 1491 if (!config->readBoolEntry(key, true))
1492 { 1492 {
1493 d->restrictionsActive = true; 1493 d->restrictionsActive = true;
1494 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1494 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1495 dircache.remove(key.latin1()); 1495 dircache.remove(key.latin1());
1496 } 1496 }
1497 } 1497 }
1498*/ 1498*/
1499 // save it for future calls - that will return 1499 // save it for future calls - that will return
1500 addedCustoms = true; 1500 addedCustoms = true;
1501 config->setGroup(oldGroup); 1501 config->setGroup(oldGroup);
1502 1502
1503 // return true if the number of config dirs changed 1503 // return true if the number of config dirs changed
1504 return (resourceDirs("config").count() != configdirs); 1504 return (resourceDirs("config").count() != configdirs);
1505} 1505}
1506 1506
1507QString KStandardDirs::localkdedir() const 1507QString KStandardDirs::localkdedir() const
1508{ 1508{
1509 // Return the prefix to use for saving 1509 // Return the prefix to use for saving
1510 return prefixes.first(); 1510 return prefixes.first();
1511} 1511}
1512 1512
1513QString KStandardDirs::localxdgdatadir() const 1513QString KStandardDirs::localxdgdatadir() const
1514{ 1514{
1515 // Return the prefix to use for saving 1515 // Return the prefix to use for saving
1516 return d->xdgdata_prefixes.first(); 1516 return d->xdgdata_prefixes.first();
1517} 1517}
1518 1518
1519QString KStandardDirs::localxdgconfdir() const 1519QString KStandardDirs::localxdgconfdir() const
1520{ 1520{
1521 // Return the prefix to use for saving 1521 // Return the prefix to use for saving
1522 return d->xdgconf_prefixes.first(); 1522 return d->xdgconf_prefixes.first();
1523} 1523}
1524 1524
1525void KStandardDirs::setAppDir( const QString &appDir ) 1525void KStandardDirs::setAppDir( const QString &appDir )
1526{ 1526{
1527 mAppDir = appDir; 1527 mAppDir = appDir;
1528 1528
1529 if ( mAppDir.right( 1 ) != "/" ) 1529 if ( mAppDir.right( 1 ) != "/" )
1530 mAppDir += "/"; 1530 mAppDir += "/";
1531} 1531}
1532 1532
1533QString KStandardDirs::appDir() 1533QString KStandardDirs::appDir()
1534{ 1534{
1535 return mAppDir; 1535 return mAppDir;
1536} 1536}
1537 1537
1538// just to make code more readable without macros 1538// just to make code more readable without macros
1539QString locate( const char *type, 1539QString locate( const char *type,
1540 const QString& filename/*US , const KInstance* inst*/ ) 1540 const QString& filename/*US , const KInstance* inst*/ )
1541{ 1541{
1542//US return inst->dirs()->findResource(type, filename); 1542//US return inst->dirs()->findResource(type, filename);
1543 return KGlobal::dirs()->findResource(type, filename); 1543 return KGlobal::dirs()->findResource(type, filename);
1544} 1544}
1545 1545
1546QString locateLocal( const char *type, 1546QString locateLocal( const char *type,
1547 const QString& filename/*US , const KInstance* inst*/ ) 1547 const QString& filename/*US , const KInstance* inst*/ )
1548{ 1548{
1549 1549
1550 QString path = locateLocal(type, filename, true /*US, inst*/); 1550 QString path = locateLocal(type, filename, true /*US, inst*/);
1551 1551
1552 1552
1553/* 1553/*
1554 static int ccc = 0; 1554 static int ccc = 0;
1555 ++ccc; 1555 ++ccc;
1556 if ( ccc > 13 ) 1556 if ( ccc > 13 )
1557 abort(); 1557 abort();
1558*/ 1558*/
1559 qDebug("locatelocal: %s" , path.latin1()); 1559 //qDebug("locatelocal: %s" , path.latin1());
1560 return path; 1560 return path;
1561 1561
1562/*US why do we put all files into one directory. It is quit complicated. 1562/*US why do we put all files into one directory. It is quit complicated.
1563why not staying with the original directorystructure ? 1563why not staying with the original directorystructure ?
1564 1564
1565 1565
1566 QString escapedFilename = filename; 1566 QString escapedFilename = filename;
1567 escapedFilename.replace( QRegExp( "/" ), "_" ); 1567 escapedFilename.replace( QRegExp( "/" ), "_" );
1568 1568
1569 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1569 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1570 1570
1571 kdDebug() << "locate: '" << path << "'" << endl; 1571 kdDebug() << "locate: '" << path << "'" << endl;
1572 qDebug("locate: %s" , path.latin1()); 1572 qDebug("locate: %s" , path.latin1());
1573 return path; 1573 return path;
1574*/ 1574*/
1575//US so my proposal is this: 1575//US so my proposal is this:
1576 1576
1577// QString escapedFilename = filename; 1577// QString escapedFilename = filename;
1578// escapedFilename.replace( QRegExp( "/" ), "_" ); 1578// escapedFilename.replace( QRegExp( "/" ), "_" );
1579 1579
1580#if 0 1580#if 0
1581#ifdef _WIN32_ 1581#ifdef _WIN32_
1582 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1582 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1583#else 1583#else
1584 QString path = KStandardDirs::appDir() + type + "/" + filename; 1584 QString path = KStandardDirs::appDir() + type + "/" + filename;
1585#endif 1585#endif
1586 1586
1587 //US Create the containing dir if needed 1587 //US Create the containing dir if needed
1588 QFileInfo fi ( path ); 1588 QFileInfo fi ( path );
1589 1589
1590 // QString dir=pathurl.directory(); 1590 // QString dir=pathurl.directory();
1591 //QMessageBox::information( 0,"path", path, 1 ); 1591 //QMessageBox::information( 0,"path", path, 1 );
1592 1592
1593#ifdef _WIN32_ 1593#ifdef _WIN32_
1594 KStandardDirs::makeDir(path); 1594 KStandardDirs::makeDir(path);
1595#else 1595#else
1596 KStandardDirs::makeDir(fi.dirPath( true )); 1596 KStandardDirs::makeDir(fi.dirPath( true ));
1597#endif 1597#endif
1598 1598
1599 qDebug("locate22: %s" , path.latin1()); 1599 qDebug("locate22: %s" , path.latin1());
1600 return path; 1600 return path;
1601 1601
1602#endif 1602#endif
1603 1603
1604} 1604}
1605 1605
1606QString locateLocal( const char *type, 1606QString locateLocal( const char *type,
1607 const QString& filename, bool createDir/*US , const KInstance* inst*/ ) 1607 const QString& filename, bool createDir/*US , const KInstance* inst*/ )
1608{ 1608{
1609 // try to find slashes. If there are some, we have to 1609 // try to find slashes. If there are some, we have to
1610 // create the subdir first 1610 // create the subdir first
1611 int slash = filename.findRev('/')+1; 1611 int slash = filename.findRev('/')+1;
1612 if (!slash) // only one filename 1612 if (!slash) // only one filename
1613 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename; 1613 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename;
1614 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; 1614 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename;
1615 1615
1616 // split path from filename 1616 // split path from filename
1617 QString dir = filename.left(slash); 1617 QString dir = filename.left(slash);
1618 QString file = filename.mid(slash); 1618 QString file = filename.mid(slash);
1619//US return inst->dirs()->saveLocation(type, dir, createDir) + file; 1619//US return inst->dirs()->saveLocation(type, dir, createDir) + file;
1620 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; 1620 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file;
1621 1621
1622 // *************************************************************** 1622 // ***************************************************************
1623#if 0 1623#if 0
1624 1624
1625/*US why do we put all files into one directory. It is quit complicated. 1625/*US why do we put all files into one directory. It is quit complicated.
1626why not staying with the original directorystructure ? 1626why not staying with the original directorystructure ?
1627 1627
1628 1628
1629 QString escapedFilename = filename; 1629 QString escapedFilename = filename;
1630 escapedFilename.replace( QRegExp( "/" ), "_" ); 1630 escapedFilename.replace( QRegExp( "/" ), "_" );
1631 1631
1632 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1632 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1633 1633
1634 kdDebug() << "locate: '" << path << "'" << endl; 1634 kdDebug() << "locate: '" << path << "'" << endl;
1635 qDebug("locate: %s" , path.latin1()); 1635 qDebug("locate: %s" , path.latin1());
1636 return path; 1636 return path;
1637*/ 1637*/
1638//US so my proposal is this: 1638//US so my proposal is this:
1639 1639
1640// QString escapedFilename = filename; 1640// QString escapedFilename = filename;
1641// escapedFilename.replace( QRegExp( "/" ), "_" ); 1641// escapedFilename.replace( QRegExp( "/" ), "_" );
1642 1642
1643#ifdef _WIN32_ 1643#ifdef _WIN32_
1644 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1644 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1645#else 1645#else
1646 QString path = KStandardDirs::appDir() + type + "/" + filename; 1646 QString path = KStandardDirs::appDir() + type + "/" + filename;
1647#endif 1647#endif
1648 1648
1649 //US Create the containing dir if needed 1649 //US Create the containing dir if needed
1650 KURL pathurl; 1650 KURL pathurl;
1651 pathurl.setPath(path); 1651 pathurl.setPath(path);
1652 QString dir=pathurl.directory(); 1652 QString dir=pathurl.directory();
1653 //QMessageBox::information( 0,"path", path, 1 ); 1653 //QMessageBox::information( 0,"path", path, 1 );
1654#ifdef _WIN32_ 1654#ifdef _WIN32_
1655 KStandardDirs::makeDir(path); 1655 KStandardDirs::makeDir(path);
1656#else 1656#else
1657 KStandardDirs::makeDir(dir); 1657 KStandardDirs::makeDir(dir);
1658#endif 1658#endif
1659 1659
1660 return path; 1660 return path;
1661#endif 1661#endif
1662} 1662}
diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp
index b819e76..69e5d02 100644
--- a/microkde/kdeui/kactioncollection.cpp
+++ b/microkde/kdeui/kactioncollection.cpp
@@ -1,544 +1,545 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2002 Joseph Wenninger <jowenn@kde.org> 9 (C) 2002 Joseph Wenninger <jowenn@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#include "kactioncollection.h" 26#include "kactioncollection.h"
27//US#include "kactionshortcutlist.h" 27//US#include "kactionshortcutlist.h"
28 28
29#include <qptrdict.h> 29#include <qptrdict.h>
30//US#include <qvariant.h> 30//US#include <qvariant.h>
31 31
32//US#include <kaccel.h> 32//US#include <kaccel.h>
33//US#include <kaccelbase.h> 33//US#include <kaccelbase.h>
34//US#include <kapplication.h> 34//US#include <kapplication.h>
35#include <kdebug.h> 35#include <kdebug.h>
36//US#include <kxmlguifactory.h> 36//US#include <kxmlguifactory.h>
37 37
38//US I included the following files 38//US I included the following files
39#include <qasciidict.h> 39#include <qasciidict.h>
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include "kaction.h" 41#include "kaction.h"
42#include <kglobal.h> 42#include <kglobal.h>
43#include <qobject.h> 43#include <qobject.h>
44#include <qwidget.h> 44#include <qwidget.h>
45 45
46class KActionCollection::KActionCollectionPrivate 46class KActionCollection::KActionCollectionPrivate
47{ 47{
48public: 48public:
49 KActionCollectionPrivate() 49 KActionCollectionPrivate()
50 { 50 {
51//US m_instance = 0; 51//US m_instance = 0;
52 //m_bOneKAccelOnly = false; 52 //m_bOneKAccelOnly = false;
53 //m_iWidgetCurrent = 0; 53 //m_iWidgetCurrent = 0;
54 m_bAutoConnectShortcuts = true; 54 m_bAutoConnectShortcuts = true;
55 m_widget = 0; 55 m_widget = 0;
56 m_kaccel = m_builderKAccel = 0; 56 m_kaccel = m_builderKAccel = 0;
57 m_dctHighlightContainers.setAutoDelete( true ); 57 m_dctHighlightContainers.setAutoDelete( true );
58 m_highlight = false; 58 m_highlight = false;
59 m_currentHighlightAction = 0; 59 m_currentHighlightAction = 0;
60 m_statusCleared = true; 60 m_statusCleared = true;
61 } 61 }
62 62
63//US KInstance *m_instance; 63//US KInstance *m_instance;
64//US QString m_sXMLFile; 64//US QString m_sXMLFile;
65 bool m_bAutoConnectShortcuts; 65 bool m_bAutoConnectShortcuts;
66 //bool m_bOneKAccelOnly; 66 //bool m_bOneKAccelOnly;
67 //int m_iWidgetCurrent; 67 //int m_iWidgetCurrent;
68 //QValueList<QWidget*> m_widgetList; 68 //QValueList<QWidget*> m_widgetList;
69 //QValueList<KAccel*> m_kaccelList; 69 //QValueList<KAccel*> m_kaccelList;
70 QValueList<KActionCollection*> m_docList; 70 QValueList<KActionCollection*> m_docList;
71 QWidget *m_widget; 71 QWidget *m_widget;
72 KAccel *m_kaccel; 72 KAccel *m_kaccel;
73 KAccel *m_builderKAccel; 73 KAccel *m_builderKAccel;
74 74
75 QAsciiDict<KAction> m_actionDict; 75 QAsciiDict<KAction> m_actionDict;
76 QPtrDict< QPtrList<KAction> > m_dctHighlightContainers; 76 QPtrDict< QPtrList<KAction> > m_dctHighlightContainers;
77 bool m_highlight; 77 bool m_highlight;
78 KAction *m_currentHighlightAction; 78 KAction *m_currentHighlightAction;
79 bool m_statusCleared; 79 bool m_statusCleared;
80}; 80};
81 81
82KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, 82KActionCollection::KActionCollection( QWidget *parent, const char *name /*US,
83 KInstance *instance */) 83 KInstance *instance */)
84 : QObject( (QObject*)parent, name ) 84 : QObject( (QObject*)parent, name )
85{ 85{
86 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis 86 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis
87 d = new KActionCollectionPrivate; 87 d = new KActionCollectionPrivate;
88 if( parent ) 88 if( parent )
89 setWidget( parent ); 89 setWidget( parent );
90 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 90 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
91//US setInstance( instance ); 91//US setInstance( instance );
92} 92}
93 93
94 94
95KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US, 95KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US,
96 KInstance *instance */) 96 KInstance *instance */)
97 : QObject( parent, name ) 97 : QObject( parent, name )
98{ 98{
99 kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis 99 kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis
100 d = new KActionCollectionPrivate; 100 d = new KActionCollectionPrivate;
101 if( watch ) 101 if( watch )
102 setWidget( watch ); 102 setWidget( watch );
103 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 103 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
104//US setInstance( instance ); 104//US setInstance( instance );
105} 105}
106 106
107// KDE 4: remove 107// KDE 4: remove
108KActionCollection::KActionCollection( QObject *parent, const char *name /*US, 108KActionCollection::KActionCollection( QObject *parent, const char *name /*US,
109 KInstance *instance */) 109 KInstance *instance */)
110 : QObject( parent, name ) 110 : QObject( parent, name )
111{ 111{
112 kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis 112 kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis
113//US kdBacktrace not available 113//US kdBacktrace not available
114//US kdDebug(129) << kdBacktrace() << endl; 114//US kdDebug(129) << kdBacktrace() << endl;
115 d = new KActionCollectionPrivate; 115 d = new KActionCollectionPrivate;
116//US QWidget* w = dynamic_cast<QWidget*>( parent ); 116//US QWidget* w = dynamic_cast<QWidget*>( parent );
117 QWidget* w = (QWidget*)( parent ); 117 QWidget* w = (QWidget*)( parent );
118 if( w ) 118 if( w )
119 setWidget( w ); 119 setWidget( w );
120 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 120 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
121//US setInstance( instance ); 121//US setInstance( instance );
122} 122}
123 123
124KActionCollection::KActionCollection( const KActionCollection &copy ) 124KActionCollection::KActionCollection( const KActionCollection &copy )
125 : QObject() 125 : QObject()
126{ 126{
127 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; 127 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl;
128 d = new KActionCollectionPrivate; 128 d = new KActionCollectionPrivate;
129 *this = copy; 129 *this = copy;
130} 130}
131// KDE 4: remove end 131// KDE 4: remove end
132 132
133KActionCollection::~KActionCollection() 133KActionCollection::~KActionCollection()
134{ 134{
135 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; 135 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl;
136 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 136 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
137 KAction* pAction = it.current(); 137 KAction* pAction = it.current();
138 if ( pAction->m_parentCollection == this ) 138 if ( pAction->m_parentCollection == this )
139 pAction->m_parentCollection = 0L; 139 pAction->m_parentCollection = 0L;
140 } 140 }
141 141
142//US delete d->m_kaccel; 142//US delete d->m_kaccel;
143//US delete d->m_builderKAccel; 143//US delete d->m_builderKAccel;
144 delete d; d = 0; 144 delete d; d = 0;
145} 145}
146 146
147void KActionCollection::setWidget( QWidget* w ) 147void KActionCollection::setWidget( QWidget* w )
148{ 148{
149 //if ( d->m_actionDict.count() > 0 ) { 149 //if ( d->m_actionDict.count() > 0 ) {
150 // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl; 150 // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl;
151 // kdDebug(129) << kdBacktrace() << endl; 151 // kdDebug(129) << kdBacktrace() << endl;
152 //} 152 //}
153 //else 153 //else
154 if ( !d->m_widget ) { 154 if ( !d->m_widget ) {
155 d->m_widget = w; 155 d->m_widget = w;
156 qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); 156 //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde");
157//US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" ); 157//US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" );
158 } 158 }
159 else if ( d->m_widget != w ) 159 else if ( d->m_widget != w )
160 kdWarning(129) << "KActionCollection::setWidget(): tried to change widget from " << d->m_widget << " to " << w << endl; 160 ;
161
161} 162}
162 163
163void KActionCollection::setAutoConnectShortcuts( bool b ) 164void KActionCollection::setAutoConnectShortcuts( bool b )
164{ 165{
165 d->m_bAutoConnectShortcuts = b; 166 d->m_bAutoConnectShortcuts = b;
166} 167}
167 168
168bool KActionCollection::isAutoConnectShortcuts() 169bool KActionCollection::isAutoConnectShortcuts()
169{ 170{
170 return d->m_bAutoConnectShortcuts; 171 return d->m_bAutoConnectShortcuts;
171} 172}
172 173
173bool KActionCollection::addDocCollection( KActionCollection* pDoc ) 174bool KActionCollection::addDocCollection( KActionCollection* pDoc )
174{ 175{
175 d->m_docList.append( pDoc ); 176 d->m_docList.append( pDoc );
176 return true; 177 return true;
177} 178}
178 179
179void KActionCollection::beginXMLPlug( QWidget *widget ) 180void KActionCollection::beginXMLPlug( QWidget *widget )
180{ 181{
181 qDebug("KActionCollection::beginXMLPlug has to be fixed"); 182 qDebug("KActionCollection::beginXMLPlug has to be fixed");
182/*US 183/*US
183 kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl; 184 kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl;
184 185
185 if( widget && !d->m_builderKAccel ) { 186 if( widget && !d->m_builderKAccel ) {
186 d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" ); 187 d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" );
187 } 188 }
188*/ 189*/
189} 190}
190 191
191void KActionCollection::endXMLPlug() 192void KActionCollection::endXMLPlug()
192{ 193{
193 kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl; 194 kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl;
194 //s_kaccelXML = 0; 195 //s_kaccelXML = 0;
195} 196}
196 197
197void KActionCollection::prepareXMLUnplug() 198void KActionCollection::prepareXMLUnplug()
198{ 199{
199 qDebug("KActionCollection::prepareXMLUnplug has to be fixed"); 200 qDebug("KActionCollection::prepareXMLUnplug has to be fixed");
200/*US 201/*US
201 kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl; 202 kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl;
202 unplugShortcuts( d->m_kaccel ); 203 unplugShortcuts( d->m_kaccel );
203 204
204 if( d->m_builderKAccel ) { 205 if( d->m_builderKAccel ) {
205 unplugShortcuts( d->m_builderKAccel ); 206 unplugShortcuts( d->m_builderKAccel );
206 delete d->m_builderKAccel; 207 delete d->m_builderKAccel;
207 d->m_builderKAccel = 0; 208 d->m_builderKAccel = 0;
208 } 209 }
209*/ 210*/
210} 211}
211 212
212void KActionCollection::unplugShortcuts( KAccel* kaccel ) 213void KActionCollection::unplugShortcuts( KAccel* kaccel )
213{ 214{
214 qDebug("KActionCollection::unplugShortcuts has to be fixed"); 215 qDebug("KActionCollection::unplugShortcuts has to be fixed");
215/*US 216/*US
216 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 217 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
217 KAction* pAction = it.current(); 218 KAction* pAction = it.current();
218 pAction->removeKAccel( kaccel ); 219 pAction->removeKAccel( kaccel );
219 } 220 }
220 221
221 for( uint i = 0; i < d->m_docList.count(); i++ ) 222 for( uint i = 0; i < d->m_docList.count(); i++ )
222 d->m_docList[i]->unplugShortcuts( kaccel ); 223 d->m_docList[i]->unplugShortcuts( kaccel );
223*/ 224*/
224 225
225} 226}
226 227
227/*void KActionCollection::addWidget( QWidget* w ) 228/*void KActionCollection::addWidget( QWidget* w )
228{ 229{
229 if( !d->m_bOneKAccelOnly ) { 230 if( !d->m_bOneKAccelOnly ) {
230 kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl; 231 kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl;
231 for( uint i = 0; i < d->m_widgetList.count(); i++ ) { 232 for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
232 if( d->m_widgetList[i] == w ) { 233 if( d->m_widgetList[i] == w ) {
233 d->m_iWidgetCurrent = i; 234 d->m_iWidgetCurrent = i;
234 return; 235 return;
235 } 236 }
236 } 237 }
237 d->m_iWidgetCurrent = d->m_widgetList.count(); 238 d->m_iWidgetCurrent = d->m_widgetList.count();
238 d->m_widgetList.append( w ); 239 d->m_widgetList.append( w );
239 d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) ); 240 d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) );
240 } 241 }
241} 242}
242 243
243void KActionCollection::removeWidget( QWidget* w ) 244void KActionCollection::removeWidget( QWidget* w )
244{ 245{
245 if( !d->m_bOneKAccelOnly ) { 246 if( !d->m_bOneKAccelOnly ) {
246 kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl; 247 kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl;
247 for( uint i = 0; i < d->m_widgetList.count(); i++ ) { 248 for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
248 if( d->m_widgetList[i] == w ) { 249 if( d->m_widgetList[i] == w ) {
249 // Remove KAccel object from children. 250 // Remove KAccel object from children.
250 KAccel* pKAccel = d->m_kaccelList[i]; 251 KAccel* pKAccel = d->m_kaccelList[i];
251 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 252 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
252 KAction* pAction = it.current(); 253 KAction* pAction = it.current();
253 if ( pAction->m_parentCollection == this ) { 254 if ( pAction->m_parentCollection == this ) {
254 pAction->removeKAccel( pKAccel ); 255 pAction->removeKAccel( pKAccel );
255 } 256 }
256 } 257 }
257 delete pKAccel; 258 delete pKAccel;
258 259
259 d->m_widgetList.remove( d->m_widgetList.at( i ) ); 260 d->m_widgetList.remove( d->m_widgetList.at( i ) );
260 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 261 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
261 262
262 if( d->m_iWidgetCurrent == (int)i ) 263 if( d->m_iWidgetCurrent == (int)i )
263 d->m_iWidgetCurrent = -1; 264 d->m_iWidgetCurrent = -1;
264 else if( d->m_iWidgetCurrent > (int)i ) 265 else if( d->m_iWidgetCurrent > (int)i )
265 d->m_iWidgetCurrent--; 266 d->m_iWidgetCurrent--;
266 return; 267 return;
267 } 268 }
268 } 269 }
269 kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl; 270 kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl;
270 } 271 }
271} 272}
272 273
273bool KActionCollection::ownsKAccel() const 274bool KActionCollection::ownsKAccel() const
274{ 275{
275 return d->m_bOneKAccelOnly; 276 return d->m_bOneKAccelOnly;
276} 277}
277 278
278uint KActionCollection::widgetCount() const 279uint KActionCollection::widgetCount() const
279{ 280{
280 return d->m_widgetList.count(); 281 return d->m_widgetList.count();
281} 282}
282 283
283const KAccel* KActionCollection::widgetKAccel( uint i ) const 284const KAccel* KActionCollection::widgetKAccel( uint i ) const
284{ 285{
285 return d->m_kaccelList[i]; 286 return d->m_kaccelList[i];
286}*/ 287}*/
287 288
288//US we are using no accelerators so far. So just setup an empty implementation. 289//US we are using no accelerators so far. So just setup an empty implementation.
289KAccel* KActionCollection::kaccel() 290KAccel* KActionCollection::kaccel()
290{ 291{
291 //if( d->m_kaccelList.count() > 0 ) 292 //if( d->m_kaccelList.count() > 0 )
292 // return d->m_kaccelList[d->m_iWidgetCurrent]; 293 // return d->m_kaccelList[d->m_iWidgetCurrent];
293 //else 294 //else
294 // return 0; 295 // return 0;
295//US return d->m_kaccel; 296//US return d->m_kaccel;
296 return 0; 297 return 0;
297} 298}
298 299
299//US we are using no accelerators so far. So just setup an empty implementation. 300//US we are using no accelerators so far. So just setup an empty implementation.
300const KAccel* KActionCollection::kaccel() const 301const KAccel* KActionCollection::kaccel() const
301{ 302{
302 //if( d->m_kaccelList.count() > 0 ) 303 //if( d->m_kaccelList.count() > 0 )
303 // return d->m_kaccelList[d->m_iWidgetCurrent]; 304 // return d->m_kaccelList[d->m_iWidgetCurrent];
304 //else 305 //else
305 // return 0; 306 // return 0;
306 //USreturn d->m_kaccel; 307 //USreturn d->m_kaccel;
307 return 0; 308 return 0;
308} 309}
309 310
310/*void KActionCollection::findMainWindow( QWidget *w ) 311/*void KActionCollection::findMainWindow( QWidget *w )
311{ 312{
312 // Note: topLevelWidget() stops too early, we can't use it. 313 // Note: topLevelWidget() stops too early, we can't use it.
313 QWidget * tl = w; 314 QWidget * tl = w;
314 while ( tl->parentWidget() ) // lookup parent and store 315 while ( tl->parentWidget() ) // lookup parent and store
315 tl = tl->parentWidget(); 316 tl = tl->parentWidget();
316 317
317 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow 318 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
318 if (mw) 319 if (mw)
319 d->m_mainwindow = mw; 320 d->m_mainwindow = mw;
320 else 321 else
321 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; 322 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl;
322}*/ 323}*/
323 324
324void KActionCollection::_insert( KAction* action ) 325void KActionCollection::_insert( KAction* action )
325{ 326{
326 char unnamed_name[100]; 327 char unnamed_name[100];
327 const char *name = action->name(); 328 const char *name = action->name();
328 if( qstrcmp( name, "unnamed" ) == 0 ) 329 if( qstrcmp( name, "unnamed" ) == 0 )
329 { 330 {
330 sprintf(unnamed_name, "unnamed-%p", (void *)action); 331 sprintf(unnamed_name, "unnamed-%p", (void *)action);
331 name = unnamed_name; 332 name = unnamed_name;
332 } 333 }
333 KAction *a = d->m_actionDict[ name ]; 334 KAction *a = d->m_actionDict[ name ];
334 if ( a == action ) 335 if ( a == action )
335 return; 336 return;
336 337
337 d->m_actionDict.insert( name, action ); 338 d->m_actionDict.insert( name, action );
338 339
339 emit inserted( action ); 340 emit inserted( action );
340} 341}
341 342
342void KActionCollection::_remove( KAction* action ) 343void KActionCollection::_remove( KAction* action )
343{ 344{
344 delete _take( action ); 345 delete _take( action );
345} 346}
346 347
347KAction* KActionCollection::_take( KAction* action ) 348KAction* KActionCollection::_take( KAction* action )
348{ 349{
349 char unnamed_name[100]; 350 char unnamed_name[100];
350 const char *name = action->name(); 351 const char *name = action->name();
351 if( qstrcmp( name, "unnamed" ) == 0 ) 352 if( qstrcmp( name, "unnamed" ) == 0 )
352 { 353 {
353 sprintf(unnamed_name, "unnamed-%p", (void *) action); 354 sprintf(unnamed_name, "unnamed-%p", (void *) action);
354 name = unnamed_name; 355 name = unnamed_name;
355 } 356 }
356 357
357 KAction *a = d->m_actionDict.take( name ); 358 KAction *a = d->m_actionDict.take( name );
358 if ( !a || a != action ) 359 if ( !a || a != action )
359 return 0; 360 return 0;
360 361
361 emit removed( action ); 362 emit removed( action );
362 return a; 363 return a;
363} 364}
364 365
365void KActionCollection::_clear() 366void KActionCollection::_clear()
366{ 367{
367 QAsciiDictIterator<KAction> it( d->m_actionDict ); 368 QAsciiDictIterator<KAction> it( d->m_actionDict );
368 while ( it.current() ) 369 while ( it.current() )
369 _remove( it.current() ); 370 _remove( it.current() );
370} 371}
371 372
372void KActionCollection::insert( KAction* action ) { _insert( action ); } 373void KActionCollection::insert( KAction* action ) { _insert( action ); }
373void KActionCollection::remove( KAction* action ) { _remove( action ); } 374void KActionCollection::remove( KAction* action ) { _remove( action ); }
374KAction* KActionCollection::take( KAction* action ) { return _take( action ); } 375KAction* KActionCollection::take( KAction* action ) { return _take( action ); }
375void KActionCollection::clear() { _clear(); } 376void KActionCollection::clear() { _clear(); }
376KAccel* KActionCollection::accel() { return kaccel(); } 377KAccel* KActionCollection::accel() { return kaccel(); }
377const KAccel* KActionCollection::accel() const { return kaccel(); } 378const KAccel* KActionCollection::accel() const { return kaccel(); }
378KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } 379KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; }
379 380
380KAction* KActionCollection::action( const char* name, const char* classname ) const 381KAction* KActionCollection::action( const char* name, const char* classname ) const
381{ 382{
382 KAction* pAction = 0; 383 KAction* pAction = 0;
383 384
384 if ( !classname && name ) 385 if ( !classname && name )
385 pAction = d->m_actionDict[ name ]; 386 pAction = d->m_actionDict[ name ];
386 387
387 else { 388 else {
388 QAsciiDictIterator<KAction> it( d->m_actionDict ); 389 QAsciiDictIterator<KAction> it( d->m_actionDict );
389 for( ; it.current(); ++it ) 390 for( ; it.current(); ++it )
390 { 391 {
391 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && 392 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) &&
392 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { 393 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) {
393 pAction = it.current(); 394 pAction = it.current();
394 break; 395 break;
395 } 396 }
396 } 397 }
397 } 398 }
398 399
399 if( !pAction ) { 400 if( !pAction ) {
400 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) 401 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ )
401 pAction = d->m_docList[i]->action( name, classname ); 402 pAction = d->m_docList[i]->action( name, classname );
402 } 403 }
403 404
404 return pAction; 405 return pAction;
405} 406}
406 407
407KAction* KActionCollection::action( int index ) const 408KAction* KActionCollection::action( int index ) const
408{ 409{
409 QAsciiDictIterator<KAction> it( d->m_actionDict ); 410 QAsciiDictIterator<KAction> it( d->m_actionDict );
410 it += index; 411 it += index;
411 return it.current(); 412 return it.current();
412// return d->m_actions.at( index ); 413// return d->m_actions.at( index );
413} 414}
414/*US 415/*US
415bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) 416bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig )
416{ 417{
417 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); 418 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig );
418} 419}
419 420
420bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const 421bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const
421{ 422{
422 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); 423 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig );
423} 424}
424*/ 425*/
425uint KActionCollection::count() const 426uint KActionCollection::count() const
426{ 427{
427 return d->m_actionDict.count(); 428 return d->m_actionDict.count();
428} 429}
429 430
430QStringList KActionCollection::groups() const 431QStringList KActionCollection::groups() const
431{ 432{
432 QStringList lst; 433 QStringList lst;
433 434
434 QAsciiDictIterator<KAction> it( d->m_actionDict ); 435 QAsciiDictIterator<KAction> it( d->m_actionDict );
435 for( ; it.current(); ++it ) 436 for( ; it.current(); ++it )
436 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) 437 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) )
437 lst.append( it.current()->group() ); 438 lst.append( it.current()->group() );
438 439
439 return lst; 440 return lst;
440} 441}
441 442
442KActionPtrList KActionCollection::actions( const QString& group ) const 443KActionPtrList KActionCollection::actions( const QString& group ) const
443{ 444{
444 KActionPtrList lst; 445 KActionPtrList lst;
445 446
446 QAsciiDictIterator<KAction> it( d->m_actionDict ); 447 QAsciiDictIterator<KAction> it( d->m_actionDict );
447 for( ; it.current(); ++it ) 448 for( ; it.current(); ++it )
448 if ( it.current()->group() == group ) 449 if ( it.current()->group() == group )
449 lst.append( it.current() ); 450 lst.append( it.current() );
450 else if ( it.current()->group().isEmpty() && group.isEmpty() ) 451 else if ( it.current()->group().isEmpty() && group.isEmpty() )
451 lst.append( it.current() ); 452 lst.append( it.current() );
452 453
453 return lst; 454 return lst;
454} 455}
455 456
456KActionPtrList KActionCollection::actions() const 457KActionPtrList KActionCollection::actions() const
457{ 458{
458 KActionPtrList lst; 459 KActionPtrList lst;
459 460
460 QAsciiDictIterator<KAction> it( d->m_actionDict ); 461 QAsciiDictIterator<KAction> it( d->m_actionDict );
461 for( ; it.current(); ++it ) 462 for( ; it.current(); ++it )
462 lst.append( it.current() ); 463 lst.append( it.current() );
463 464
464 return lst; 465 return lst;
465} 466}
466 467
467/*US we have no instance object. Use KGlobal instead 468/*US we have no instance object. Use KGlobal instead
468void KActionCollection::setInstance( KInstance *instance ) 469void KActionCollection::setInstance( KInstance *instance )
469{ 470{
470 if ( instance ) 471 if ( instance )
471 d->m_instance = instance; 472 d->m_instance = instance;
472qDebug("KActionCollection::setInstance has to be fixed"); 473qDebug("KActionCollection::setInstance has to be fixed");
473 else 474 else
474 d->m_instance = KGlobal::instance(); 475 d->m_instance = KGlobal::instance();
475} 476}
476 477
477KInstance *KActionCollection::instance() const 478KInstance *KActionCollection::instance() const
478{ 479{
479 return d->m_instance; 480 return d->m_instance;
480} 481}
481*/ 482*/
482 483
483/*US we have no XML facility in microkde 484/*US we have no XML facility in microkde
484void KActionCollection::setXMLFile( const QString& sXMLFile ) 485void KActionCollection::setXMLFile( const QString& sXMLFile )
485{ 486{
486 d->m_sXMLFile = sXMLFile; 487 d->m_sXMLFile = sXMLFile;
487} 488}
488 489
489const QString& KActionCollection::xmlFile() const 490const QString& KActionCollection::xmlFile() const
490{ 491{
491 return d->m_sXMLFile; 492 return d->m_sXMLFile;
492} 493}
493*/ 494*/
494 495
495void KActionCollection::setHighlightingEnabled( bool enable ) 496void KActionCollection::setHighlightingEnabled( bool enable )
496{ 497{
497 d->m_highlight = enable; 498 d->m_highlight = enable;
498} 499}
499 500
500bool KActionCollection::highlightingEnabled() const 501bool KActionCollection::highlightingEnabled() const
501{ 502{
502 return d->m_highlight; 503 return d->m_highlight;
503} 504}
504 505
505void KActionCollection::connectHighlight( QWidget *container, KAction *action ) 506void KActionCollection::connectHighlight( QWidget *container, KAction *action )
506{ 507{
507 if ( !d->m_highlight ) 508 if ( !d->m_highlight )
508 return; 509 return;
509 510
510 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 511 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
511 512
512 if ( !actionList ) 513 if ( !actionList )
513 { 514 {
514 actionList = new QPtrList<KAction>; 515 actionList = new QPtrList<KAction>;
515 516
516 if ( container->inherits( "QPopupMenu" ) ) 517 if ( container->inherits( "QPopupMenu" ) )
517 { 518 {
518 connect( container, SIGNAL( highlighted( int ) ), 519 connect( container, SIGNAL( highlighted( int ) ),
519 this, SLOT( slotMenuItemHighlighted( int ) ) ); 520 this, SLOT( slotMenuItemHighlighted( int ) ) );
520 connect( container, SIGNAL( aboutToHide() ), 521 connect( container, SIGNAL( aboutToHide() ),
521 this, SLOT( slotMenuAboutToHide() ) ); 522 this, SLOT( slotMenuAboutToHide() ) );
522 } 523 }
523//US else if ( container->inherits( "KToolBar" ) ) 524//US else if ( container->inherits( "KToolBar" ) )
524 else if ( container->inherits( "QToolBar" ) ) 525 else if ( container->inherits( "QToolBar" ) )
525 { 526 {
526 connect( container, SIGNAL( highlighted( int, bool ) ), 527 connect( container, SIGNAL( highlighted( int, bool ) ),
527 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); 528 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) );
528 } 529 }
529 530
530 connect( container, SIGNAL( destroyed() ), 531 connect( container, SIGNAL( destroyed() ),
531 this, SLOT( slotDestroyed() ) ); 532 this, SLOT( slotDestroyed() ) );
532 533
533 d->m_dctHighlightContainers.insert( container, actionList ); 534 d->m_dctHighlightContainers.insert( container, actionList );
534 } 535 }
535 536
536 actionList->append( action ); 537 actionList->append( action );
537} 538}
538 539
539void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) 540void KActionCollection::disconnectHighlight( QWidget *container, KAction *action )
540{ 541{
541 if ( !d->m_highlight ) 542 if ( !d->m_highlight )
542 return; 543 return;
543 544
544 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 545 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index b53a88a..2856f2d 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -134,769 +134,769 @@ public:
134 QPoint dragOverPoint; 134 QPoint dragOverPoint;
135 135
136 QPoint startDragPos; 136 QPoint startDragPos;
137 int dragDelay; 137 int dragDelay;
138 138
139//US KListViewLineEdit *editor; 139//US KListViewLineEdit *editor;
140 QValueList<int> renameable; 140 QValueList<int> renameable;
141 141
142 bool cursorInExecuteArea:1; 142 bool cursorInExecuteArea:1;
143 bool bUseSingle:1; 143 bool bUseSingle:1;
144 bool bChangeCursorOverItem:1; 144 bool bChangeCursorOverItem:1;
145 bool itemsMovable:1; 145 bool itemsMovable:1;
146 bool selectedBySimpleMove : 1; 146 bool selectedBySimpleMove : 1;
147 bool selectedUsingMouse:1; 147 bool selectedUsingMouse:1;
148 bool itemsRenameable:1; 148 bool itemsRenameable:1;
149 bool validDrag:1; 149 bool validDrag:1;
150 bool dragEnabled:1; 150 bool dragEnabled:1;
151 bool autoOpen:1; 151 bool autoOpen:1;
152 bool dropVisualizer:1; 152 bool dropVisualizer:1;
153 bool dropHighlighter:1; 153 bool dropHighlighter:1;
154 bool createChildren:1; 154 bool createChildren:1;
155 bool pressedOnSelected:1; 155 bool pressedOnSelected:1;
156 bool wasShiftEvent:1; 156 bool wasShiftEvent:1;
157 bool fullWidth:1; 157 bool fullWidth:1;
158 bool sortAscending:1; 158 bool sortAscending:1;
159 bool tabRename:1; 159 bool tabRename:1;
160 160
161 int sortColumn; 161 int sortColumn;
162 162
163 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX 163 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
164 int selectionDirection; 164 int selectionDirection;
165 int tooltipColumn; 165 int tooltipColumn;
166 166
167 SelectionModeExt selectionMode; 167 SelectionModeExt selectionMode;
168 int contextMenuKey; 168 int contextMenuKey;
169 bool showContextMenusOnPress; 169 bool showContextMenusOnPress;
170 170
171 QRect mOldDropVisualizer; 171 QRect mOldDropVisualizer;
172 int mDropVisualizerWidth; 172 int mDropVisualizerWidth;
173 QRect mOldDropHighlighter; 173 QRect mOldDropHighlighter;
174 QListViewItem *afterItemDrop; 174 QListViewItem *afterItemDrop;
175 QListViewItem *parentItemDrop; 175 QListViewItem *parentItemDrop;
176 176
177 QColor alternateBackground; 177 QColor alternateBackground;
178}; 178};
179 179
180/*US 180/*US
181KListViewLineEdit::KListViewLineEdit(KListView *parent) 181KListViewLineEdit::KListViewLineEdit(KListView *parent)
182 : KLineEdit(parent->viewport()), item(0), col(0), p(parent) 182 : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
183{ 183{
184 setFrame( false ); 184 setFrame( false );
185 hide(); 185 hide();
186 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); 186 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ));
187} 187}
188 188
189KListViewLineEdit::~KListViewLineEdit() 189KListViewLineEdit::~KListViewLineEdit()
190{ 190{
191} 191}
192 192
193void KListViewLineEdit::load(QListViewItem *i, int c) 193void KListViewLineEdit::load(QListViewItem *i, int c)
194{ 194{
195 item=i; 195 item=i;
196 col=c; 196 col=c;
197 197
198 QRect rect(p->itemRect(i)); 198 QRect rect(p->itemRect(i));
199 setText(item->text(c)); 199 setText(item->text(c));
200 200
201 int fieldX = rect.x() - 1; 201 int fieldX = rect.x() - 1;
202 int fieldW = p->columnWidth(col) + 2; 202 int fieldW = p->columnWidth(col) + 2;
203 203
204 int pos = p->header()->mapToIndex(col); 204 int pos = p->header()->mapToIndex(col);
205 for ( int index = 0; index < pos; index++ ) 205 for ( int index = 0; index < pos; index++ )
206 fieldX += p->columnWidth( p->header()->mapToSection( index )); 206 fieldX += p->columnWidth( p->header()->mapToSection( index ));
207 207
208 if ( col == 0 ) { 208 if ( col == 0 ) {
209 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); 209 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0);
210 d *= p->treeStepSize(); 210 d *= p->treeStepSize();
211 fieldX += d; 211 fieldX += d;
212 fieldW -= d; 212 fieldW -= d;
213 } 213 }
214 214
215 if ( i->pixmap( col ) ) {// add width of pixmap 215 if ( i->pixmap( col ) ) {// add width of pixmap
216 int d = i->pixmap( col )->width(); 216 int d = i->pixmap( col )->width();
217 fieldX += d; 217 fieldX += d;
218 fieldW -= d; 218 fieldW -= d;
219 } 219 }
220 220
221 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); 221 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
222 show(); 222 show();
223 setFocus(); 223 setFocus();
224} 224}
225*/ 225*/
226 /*Helper functions to for 226 /*Helper functions to for
227 *tabOrderedRename functionality. 227 *tabOrderedRename functionality.
228 */ 228 */
229 229
230static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) 230static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir)
231{ 231{
232 if (pi) 232 if (pi)
233 { 233 {
234 //Find the next renameable column in the current row 234 //Find the next renameable column in the current row
235 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) 235 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
236 if (pl->isRenameable(start)) 236 if (pl->isRenameable(start))
237 return start; 237 return start;
238 } 238 }
239 239
240 return -1; 240 return -1;
241} 241}
242 242
243static QListViewItem *prevItem (QListViewItem *pi) 243static QListViewItem *prevItem (QListViewItem *pi)
244{ 244{
245 QListViewItem *pa = pi->itemAbove(); 245 QListViewItem *pa = pi->itemAbove();
246 246
247 /*Does what the QListViewItem::previousSibling() 247 /*Does what the QListViewItem::previousSibling()
248 *of my dreams would do. 248 *of my dreams would do.
249 */ 249 */
250 if (pa && pa->parent() == pi->parent()) 250 if (pa && pa->parent() == pi->parent())
251 return pa; 251 return pa;
252 252
253 return NULL; 253 return NULL;
254} 254}
255 255
256static QListViewItem *lastQChild (QListViewItem *pi) 256static QListViewItem *lastQChild (QListViewItem *pi)
257{ 257{
258 if (pi) 258 if (pi)
259 { 259 {
260 /*Since there's no QListViewItem::lastChild(). 260 /*Since there's no QListViewItem::lastChild().
261 *This finds the last sibling for the given 261 *This finds the last sibling for the given
262 *item. 262 *item.
263 */ 263 */
264 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) 264 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
265 pi = pt; 265 pi = pt;
266 } 266 }
267 267
268 return pi; 268 return pi;
269} 269}
270/*US 270/*US
271void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) 271void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward)
272{ 272{
273 const int ncols = p->columns(); 273 const int ncols = p->columns();
274 const int dir = forward ? +1 : -1; 274 const int dir = forward ? +1 : -1;
275 const int restart = forward ? 0 : (ncols - 1); 275 const int restart = forward ? 0 : (ncols - 1);
276 QListViewItem *top = (pitem && pitem->parent()) 276 QListViewItem *top = (pitem && pitem->parent())
277 ? pitem->parent()->firstChild() 277 ? pitem->parent()->firstChild()
278 : p->firstChild(); 278 : p->firstChild();
279 QListViewItem *pi = pitem; 279 QListViewItem *pi = pitem;
280 280
281 terminate(); //Save current changes 281 terminate(); //Save current changes
282 282
283 do 283 do
284 { 284 {
285*/ 285*/
286 /*Check the rest of the current row for an editable column, 286 /*Check the rest of the current row for an editable column,
287 *if that fails, check the entire next/previous row. The 287 *if that fails, check the entire next/previous row. The
288 *last case goes back to the first item in the current branch 288 *last case goes back to the first item in the current branch
289 *or the last item in the current branch depending on the 289 *or the last item in the current branch depending on the
290 *direction. 290 *direction.
291 */ 291 */
292/*US 292/*US
293 if ((column = nextCol(p, pi, column + dir, dir)) != -1 || 293 if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
294 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || 294 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
295 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) 295 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
296 { 296 {
297 if (pi) 297 if (pi)
298 { 298 {
299 p->setCurrentItem(pi); //Calls terminate 299 p->setCurrentItem(pi); //Calls terminate
300 p->rename(pi, column); 300 p->rename(pi, column);
301*/ 301*/
302 /*Some listviews may override rename() to 302 /*Some listviews may override rename() to
303 *prevent certain items from being renamed, 303 *prevent certain items from being renamed,
304 *if this is done, [m_]item will be NULL 304 *if this is done, [m_]item will be NULL
305 *after the rename() call... try again. 305 *after the rename() call... try again.
306 */ 306 */
307/*US 307/*US
308 if (!item) 308 if (!item)
309 continue; 309 continue;
310 310
311 break; 311 break;
312 } 312 }
313 } 313 }
314 } 314 }
315 while (pi && !item); 315 while (pi && !item);
316} 316}
317*/ 317*/
318 318
319/*US 319/*US
320#ifdef KeyPress 320#ifdef KeyPress
321#undef KeyPress 321#undef KeyPress
322#endif 322#endif
323 323
324bool KListViewLineEdit::event (QEvent *pe) 324bool KListViewLineEdit::event (QEvent *pe)
325{ 325{
326 if (pe->type() == QEvent::KeyPress) 326 if (pe->type() == QEvent::KeyPress)
327 { 327 {
328 QKeyEvent *k = (QKeyEvent *) pe; 328 QKeyEvent *k = (QKeyEvent *) pe;
329 329
330 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && 330 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
331 p->tabOrderedRenaming() && p->itemsRenameable() && 331 p->tabOrderedRenaming() && p->itemsRenameable() &&
332 !(k->state() & ControlButton || k->state() & AltButton)) 332 !(k->state() & ControlButton || k->state() & AltButton))
333 { 333 {
334 selectNextCell(item, col, 334 selectNextCell(item, col,
335 (k->key() == Key_Tab && !(k->state() & ShiftButton))); 335 (k->key() == Key_Tab && !(k->state() & ShiftButton)));
336 return true; 336 return true;
337 } 337 }
338 } 338 }
339 339
340 return KLineEdit::event(pe); 340 return KLineEdit::event(pe);
341} 341}
342 342
343void KListViewLineEdit::keyPressEvent(QKeyEvent *e) 343void KListViewLineEdit::keyPressEvent(QKeyEvent *e)
344{ 344{
345 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) 345 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
346 terminate(true); 346 terminate(true);
347 else if(e->key() == Qt::Key_Escape) 347 else if(e->key() == Qt::Key_Escape)
348 terminate(false); 348 terminate(false);
349 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) 349 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
350 { 350 {
351 terminate(true); 351 terminate(true);
352 KLineEdit::keyPressEvent(e); 352 KLineEdit::keyPressEvent(e);
353 } 353 }
354 else 354 else
355 KLineEdit::keyPressEvent(e); 355 KLineEdit::keyPressEvent(e);
356} 356}
357 357
358void KListViewLineEdit::terminate() 358void KListViewLineEdit::terminate()
359{ 359{
360 terminate(true); 360 terminate(true);
361} 361}
362 362
363void KListViewLineEdit::terminate(bool commit) 363void KListViewLineEdit::terminate(bool commit)
364{ 364{
365 if ( item ) 365 if ( item )
366 { 366 {
367 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; 367 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl;
368 if (commit) 368 if (commit)
369 item->setText(col, text()); 369 item->setText(col, text());
370 int c=col; 370 int c=col;
371 QListViewItem *i=item; 371 QListViewItem *i=item;
372 col=0; 372 col=0;
373 item=0; 373 item=0;
374 hide(); // will call focusOutEvent, that's why we set item=0 before 374 hide(); // will call focusOutEvent, that's why we set item=0 before
375 emit done(i,c); 375 emit done(i,c);
376 } 376 }
377} 377}
378 378
379void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) 379void KListViewLineEdit::focusOutEvent(QFocusEvent *ev)
380{ 380{
381 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); 381 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev);
382 // Don't let a RMB close the editor 382 // Don't let a RMB close the editor
383 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) 383 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow)
384 terminate(true); 384 terminate(true);
385} 385}
386 386
387void KListViewLineEdit::paintEvent( QPaintEvent *e ) 387void KListViewLineEdit::paintEvent( QPaintEvent *e )
388{ 388{
389 KLineEdit::paintEvent( e ); 389 KLineEdit::paintEvent( e );
390 390
391 if ( !frame() ) { 391 if ( !frame() ) {
392 QPainter p( this ); 392 QPainter p( this );
393 p.setClipRegion( e->region() ); 393 p.setClipRegion( e->region() );
394 p.drawRect( rect() ); 394 p.drawRect( rect() );
395 } 395 }
396} 396}
397 397
398// selection changed -> terminate. As our "item" can be already deleted, 398// selection changed -> terminate. As our "item" can be already deleted,
399// we can't call terminate(false), because that would emit done() with 399// we can't call terminate(false), because that would emit done() with
400// a dangling pointer to "item". 400// a dangling pointer to "item".
401void KListViewLineEdit::slotSelectionChanged() 401void KListViewLineEdit::slotSelectionChanged()
402{ 402{
403 item = 0; 403 item = 0;
404 col = 0; 404 col = 0;
405 hide(); 405 hide();
406} 406}
407*/ 407*/
408 408
409KListView::KListView( QWidget *parent, const char *name ) 409KListView::KListView( QWidget *parent, const char *name )
410 : QListView( parent, name ), 410 : QListView( parent, name ),
411 d (new KListViewPrivate (this)) 411 d (new KListViewPrivate (this))
412{ 412{
413#ifndef DESKTOP_VERSION 413#ifndef DESKTOP_VERSION
414 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 414 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
415#endif 415#endif
416//US setDragAutoScroll(true); 416//US setDragAutoScroll(true);
417 417
418 connect( this, SIGNAL( onViewport() ), 418 connect( this, SIGNAL( onViewport() ),
419 this, SLOT( slotOnViewport() ) ); 419 this, SLOT( slotOnViewport() ) );
420 connect( this, SIGNAL( onItem( QListViewItem * ) ), 420 connect( this, SIGNAL( onItem( QListViewItem * ) ),
421 this, SLOT( slotOnItem( QListViewItem * ) ) ); 421 this, SLOT( slotOnItem( QListViewItem * ) ) );
422 422
423 connect (this, SIGNAL(contentsMoving(int,int)), 423 connect (this, SIGNAL(contentsMoving(int,int)),
424 this, SLOT(cleanDropVisualizer())); 424 this, SLOT(cleanDropVisualizer()));
425 connect (this, SIGNAL(contentsMoving(int,int)), 425 connect (this, SIGNAL(contentsMoving(int,int)),
426 this, SLOT(cleanItemHighlighter())); 426 this, SLOT(cleanItemHighlighter()));
427 427
428/*US 428/*US
429 slotSettingsChanged(KApplication::SETTINGS_MOUSE); 429 slotSettingsChanged(KApplication::SETTINGS_MOUSE);
430 430
431 if (kapp) 431 if (kapp)
432 { 432 {
433 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); 433 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) );
434 kapp->addKipcEventMask( KIPC::SettingsChanged ); 434 kapp->addKipcEventMask( KIPC::SettingsChanged );
435 } 435 }
436*/ 436*/
437 slotSettingsChanged(1); //US do this to initialize the connections 437 slotSettingsChanged(1); //US do this to initialize the connections
438 438
439 439
440 connect(&d->autoSelect, SIGNAL( timeout() ), 440 connect(&d->autoSelect, SIGNAL( timeout() ),
441 this, SLOT( slotAutoSelect() ) ); 441 this, SLOT( slotAutoSelect() ) );
442 connect(&d->dragExpand, SIGNAL( timeout() ), 442 connect(&d->dragExpand, SIGNAL( timeout() ),
443 this, SLOT( slotDragExpand() ) ); 443 this, SLOT( slotDragExpand() ) );
444 444
445 // context menu handling 445 // context menu handling
446 if (d->showContextMenusOnPress) 446 if (d->showContextMenusOnPress)
447 { 447 {
448 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 448 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
449 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 449 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
450 } 450 }
451 else 451 else
452 { 452 {
453 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 453 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
454 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 454 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
455 } 455 }
456 456
457 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), 457 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)),
458 this, SLOT (emitContextMenu (KListView*, QListViewItem*))); 458 this, SLOT (emitContextMenu (KListView*, QListViewItem*)));
459 459
460 460
461 //qDebug("KListView::KListView make alternate color configurable"); 461 //qDebug("KListView::KListView make alternate color configurable");
462//US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); 462//US d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
463 d->alternateBackground = QColor(240, 240, 240); 463 d->alternateBackground = QColor(240, 240, 240);
464} 464}
465 465
466 466
467 467
468KListView::~KListView() 468KListView::~KListView()
469{ 469{
470 delete d; 470 delete d;
471} 471}
472 472
473bool KListView::isExecuteArea( const QPoint& point ) 473bool KListView::isExecuteArea( const QPoint& point )
474{ 474{
475 if ( itemAt( point ) ) 475 if ( itemAt( point ) )
476 return isExecuteArea( point.x() ); 476 return isExecuteArea( point.x() );
477 477
478 return false; 478 return false;
479} 479}
480 480
481bool KListView::isExecuteArea( int x ) 481bool KListView::isExecuteArea( int x )
482{ 482{
483 if( allColumnsShowFocus() ) 483 if( allColumnsShowFocus() )
484 return true; 484 return true;
485 else { 485 else {
486 int offset = 0; 486 int offset = 0;
487 int width = columnWidth( 0 ); 487 int width = columnWidth( 0 );
488 int pos = header()->mapToIndex( 0 ); 488 int pos = header()->mapToIndex( 0 );
489 489
490 for ( int index = 0; index < pos; index++ ) 490 for ( int index = 0; index < pos; index++ )
491 offset += columnWidth( header()->mapToSection( index ) ); 491 offset += columnWidth( header()->mapToSection( index ) );
492 492
493 x += contentsX(); // in case of a horizontal scrollbar 493 x += contentsX(); // in case of a horizontal scrollbar
494 return ( x > offset && x < ( offset + width ) ); 494 return ( x > offset && x < ( offset + width ) );
495 } 495 }
496} 496}
497 497
498void KListView::slotOnItem( QListViewItem *item ) 498void KListView::slotOnItem( QListViewItem *item )
499{ 499{
500 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); 500 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
501 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { 501 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
502 d->autoSelect.start( d->autoSelectDelay, true ); 502 d->autoSelect.start( d->autoSelectDelay, true );
503 d->pCurrentItem = item; 503 d->pCurrentItem = item;
504 } 504 }
505} 505}
506 506
507void KListView::slotOnViewport() 507void KListView::slotOnViewport()
508{ 508{
509 if ( d->bChangeCursorOverItem ) 509 if ( d->bChangeCursorOverItem )
510 viewport()->unsetCursor(); 510 viewport()->unsetCursor();
511 511
512 d->autoSelect.stop(); 512 d->autoSelect.stop();
513 d->pCurrentItem = 0L; 513 d->pCurrentItem = 0L;
514} 514}
515 515
516void KListView::slotSettingsChanged(int category) 516void KListView::slotSettingsChanged(int category)
517{ 517{
518qDebug("KListView::slotSettingsChanged has to be verified"); 518 //qDebug("KListView::slotSettingsChanged has to be verified");
519/*US 519/*US
520 520
521 switch (category) 521 switch (category)
522 { 522 {
523 case KApplication::SETTINGS_MOUSE: 523 case KApplication::SETTINGS_MOUSE:
524 d->dragDelay = KGlobalSettings::dndEventDelay(); 524 d->dragDelay = KGlobalSettings::dndEventDelay();
525 d->bUseSingle = KGlobalSettings::singleClick(); 525 d->bUseSingle = KGlobalSettings::singleClick();
526 526
527 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 527 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
528 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 528 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int)));
529 529
530 if( d->bUseSingle ) 530 if( d->bUseSingle )
531 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 531 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
532 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 532 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
533 533
534 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 534 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
535 d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 535 d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
536 536
537 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 537 if( !d->bUseSingle || !d->bChangeCursorOverItem )
538 viewport()->unsetCursor(); 538 viewport()->unsetCursor();
539 539
540 break; 540 break;
541 541
542 case KApplication::SETTINGS_POPUPMENU: 542 case KApplication::SETTINGS_POPUPMENU:
543 d->contextMenuKey = KGlobalSettings::contextMenuKey (); 543 d->contextMenuKey = KGlobalSettings::contextMenuKey ();
544 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); 544 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress ();
545 545
546 if (d->showContextMenusOnPress) 546 if (d->showContextMenusOnPress)
547 { 547 {
548 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 548 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
549 549
550 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 550 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
551 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 551 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
552 } 552 }
553 else 553 else
554 { 554 {
555 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 555 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
556 556
557 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 557 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
558 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 558 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
559 } 559 }
560 break; 560 break;
561 561
562 default: 562 default:
563 break; 563 break;
564 } 564 }
565*/ 565*/
566 566
567 if( d->bUseSingle ) 567 if( d->bUseSingle )
568 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 568 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
569 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 569 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
570 570
571} 571}
572 572
573void KListView::slotAutoSelect() 573void KListView::slotAutoSelect()
574{ 574{
575 // check that the item still exists 575 // check that the item still exists
576 if( itemIndex( d->pCurrentItem ) == -1 ) 576 if( itemIndex( d->pCurrentItem ) == -1 )
577 return; 577 return;
578 578
579 if (!isActiveWindow()) 579 if (!isActiveWindow())
580 { 580 {
581 d->autoSelect.stop(); 581 d->autoSelect.stop();
582 return; 582 return;
583 } 583 }
584 584
585 //Give this widget the keyboard focus. 585 //Give this widget the keyboard focus.
586 if( !hasFocus() ) 586 if( !hasFocus() )
587 setFocus(); 587 setFocus();
588 588
589 QListViewItem* previousItem = currentItem(); 589 QListViewItem* previousItem = currentItem();
590 setCurrentItem( d->pCurrentItem ); 590 setCurrentItem( d->pCurrentItem );
591 591
592#if 0 592#if 0
593#ifndef Q_WS_QWS 593#ifndef Q_WS_QWS
594 // FIXME(E): Implement for Qt Embedded 594 // FIXME(E): Implement for Qt Embedded
595 if( d->pCurrentItem ) { 595 if( d->pCurrentItem ) {
596 //Shift pressed? 596 //Shift pressed?
597 if( (keybstate & ShiftMask) ) { 597 if( (keybstate & ShiftMask) ) {
598 bool block = signalsBlocked(); 598 bool block = signalsBlocked();
599 blockSignals( true ); 599 blockSignals( true );
600 600
601 //No Ctrl? Then clear before! 601 //No Ctrl? Then clear before!
602 if( !(keybstate & ControlMask) ) 602 if( !(keybstate & ControlMask) )
603 clearSelection(); 603 clearSelection();
604 604
605 bool select = !d->pCurrentItem->isSelected(); 605 bool select = !d->pCurrentItem->isSelected();
606 bool update = viewport()->isUpdatesEnabled(); 606 bool update = viewport()->isUpdatesEnabled();
607 viewport()->setUpdatesEnabled( false ); 607 viewport()->setUpdatesEnabled( false );
608 608
609 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); 609 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
610 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); 610 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
611 for ( ; lit.current(); ++lit ) { 611 for ( ; lit.current(); ++lit ) {
612 if ( down && lit.current() == d->pCurrentItem ) { 612 if ( down && lit.current() == d->pCurrentItem ) {
613 d->pCurrentItem->setSelected( select ); 613 d->pCurrentItem->setSelected( select );
614 break; 614 break;
615 } 615 }
616 if ( !down && lit.current() == previousItem ) { 616 if ( !down && lit.current() == previousItem ) {
617 previousItem->setSelected( select ); 617 previousItem->setSelected( select );
618 break; 618 break;
619 } 619 }
620 lit.current()->setSelected( select ); 620 lit.current()->setSelected( select );
621 } 621 }
622 622
623 blockSignals( block ); 623 blockSignals( block );
624 viewport()->setUpdatesEnabled( update ); 624 viewport()->setUpdatesEnabled( update );
625 triggerUpdate(); 625 triggerUpdate();
626 626
627 emit selectionChanged(); 627 emit selectionChanged();
628 628
629 if( selectionMode() == QListView::Single ) 629 if( selectionMode() == QListView::Single )
630 emit selectionChanged( d->pCurrentItem ); 630 emit selectionChanged( d->pCurrentItem );
631 } 631 }
632 else if( (keybstate & ControlMask) ) 632 else if( (keybstate & ControlMask) )
633 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); 633 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
634 else { 634 else {
635 bool block = signalsBlocked(); 635 bool block = signalsBlocked();
636 blockSignals( true ); 636 blockSignals( true );
637 637
638 if( !d->pCurrentItem->isSelected() ) 638 if( !d->pCurrentItem->isSelected() )
639 clearSelection(); 639 clearSelection();
640 640
641 blockSignals( block ); 641 blockSignals( block );
642 642
643 setSelected( d->pCurrentItem, true ); 643 setSelected( d->pCurrentItem, true );
644 } 644 }
645 } 645 }
646 else 646 else
647 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; 647 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl;
648#endif 648#endif
649#endif 649#endif
650} 650}
651 651
652void KListView::slotHeaderChanged() 652void KListView::slotHeaderChanged()
653{ 653{
654 if (d->fullWidth && columns()) 654 if (d->fullWidth && columns())
655 { 655 {
656 int w = 0; 656 int w = 0;
657 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); 657 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i);
658 setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); 658 setColumnWidth( columns() - 1, viewport()->width() - w - 1 );
659 } 659 }
660} 660}
661 661
662void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) 662void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c )
663{ 663{
664 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { 664 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
665 665
666 // Double click mode ? 666 // Double click mode ?
667 if ( !d->bUseSingle ) 667 if ( !d->bUseSingle )
668 { 668 {
669 emit executed( item ); 669 emit executed( item );
670 emit executed( item, pos, c ); 670 emit executed( item, pos, c );
671 } 671 }
672 else 672 else
673 { 673 {
674#if 0 674#if 0
675#ifndef Q_WS_QWS 675#ifndef Q_WS_QWS
676 // FIXME(E): Implement for Qt Embedded 676 // FIXME(E): Implement for Qt Embedded
677 Window root; 677 Window root;
678 Window child; 678 Window child;
679 int root_x, root_y, win_x, win_y; 679 int root_x, root_y, win_x, win_y;
680 uint keybstate; 680 uint keybstate;
681 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, 681 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
682 &root_x, &root_y, &win_x, &win_y, &keybstate ); 682 &root_x, &root_y, &win_x, &win_y, &keybstate );
683 683
684 d->autoSelect.stop(); 684 d->autoSelect.stop();
685 685
686 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 686 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
687 if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 687 if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
688 emit executed( item ); 688 emit executed( item );
689 emit executed( item, pos, c ); 689 emit executed( item, pos, c );
690 } 690 }
691#endif 691#endif
692#endif 692#endif
693 } 693 }
694 } 694 }
695} 695}
696 696
697void KListView::focusInEvent( QFocusEvent *fe ) 697void KListView::focusInEvent( QFocusEvent *fe )
698{ 698{
699 // kdDebug()<<"KListView::focusInEvent()"<<endl; 699 // kdDebug()<<"KListView::focusInEvent()"<<endl;
700 QListView::focusInEvent( fe ); 700 QListView::focusInEvent( fe );
701 if ((d->selectedBySimpleMove) 701 if ((d->selectedBySimpleMove)
702 && (d->selectionMode == FileManager) 702 && (d->selectionMode == FileManager)
703 && (fe->reason()!=QFocusEvent::Popup) 703 && (fe->reason()!=QFocusEvent::Popup)
704 && (fe->reason()!=QFocusEvent::ActiveWindow) 704 && (fe->reason()!=QFocusEvent::ActiveWindow)
705 && (currentItem()!=0)) 705 && (currentItem()!=0))
706 { 706 {
707 currentItem()->setSelected(true); 707 currentItem()->setSelected(true);
708 currentItem()->repaint(); 708 currentItem()->repaint();
709 emit selectionChanged(); 709 emit selectionChanged();
710 }; 710 };
711} 711}
712 712
713void KListView::focusOutEvent( QFocusEvent *fe ) 713void KListView::focusOutEvent( QFocusEvent *fe )
714{ 714{
715 cleanDropVisualizer(); 715 cleanDropVisualizer();
716 cleanItemHighlighter(); 716 cleanItemHighlighter();
717 717
718 d->autoSelect.stop(); 718 d->autoSelect.stop();
719 719
720 if ((d->selectedBySimpleMove) 720 if ((d->selectedBySimpleMove)
721 && (d->selectionMode == FileManager) 721 && (d->selectionMode == FileManager)
722 && (fe->reason()!=QFocusEvent::Popup) 722 && (fe->reason()!=QFocusEvent::Popup)
723 && (fe->reason()!=QFocusEvent::ActiveWindow) 723 && (fe->reason()!=QFocusEvent::ActiveWindow)
724 && (currentItem()!=0) 724 && (currentItem()!=0)
725/*US && (!d->editor->isVisible()) */ 725/*US && (!d->editor->isVisible()) */
726 ) 726 )
727 { 727 {
728 currentItem()->setSelected(false); 728 currentItem()->setSelected(false);
729 currentItem()->repaint(); 729 currentItem()->repaint();
730 emit selectionChanged(); 730 emit selectionChanged();
731 }; 731 };
732 732
733 QListView::focusOutEvent( fe ); 733 QListView::focusOutEvent( fe );
734} 734}
735 735
736void KListView::leaveEvent( QEvent *e ) 736void KListView::leaveEvent( QEvent *e )
737{ 737{
738 d->autoSelect.stop(); 738 d->autoSelect.stop();
739 739
740 QListView::leaveEvent( e ); 740 QListView::leaveEvent( e );
741} 741}
742 742
743bool KListView::event( QEvent *e ) 743bool KListView::event( QEvent *e )
744{ 744{
745 if (e->type() == QEvent::ApplicationPaletteChange) { 745 if (e->type() == QEvent::ApplicationPaletteChange) {
746qDebug("KListView::event make alternate color configurable"); 746qDebug("KListView::event make alternate color configurable");
747//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); 747//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
748 d->alternateBackground = QColor(240, 240, 240); 748 d->alternateBackground = QColor(240, 240, 240);
749 } 749 }
750 750
751 return QListView::event(e); 751 return QListView::event(e);
752} 752}
753 753
754void KListView::contentsMousePressEvent( QMouseEvent *e ) 754void KListView::contentsMousePressEvent( QMouseEvent *e )
755{ 755{
756 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) 756 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) )
757 { 757 {
758 bool block = signalsBlocked(); 758 bool block = signalsBlocked();
759 blockSignals( true ); 759 blockSignals( true );
760 760
761 clearSelection(); 761 clearSelection();
762 762
763 blockSignals( block ); 763 blockSignals( block );
764 } 764 }
765 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) 765 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
766 { 766 {
767 d->selectedBySimpleMove=false; 767 d->selectedBySimpleMove=false;
768 d->selectedUsingMouse=true; 768 d->selectedUsingMouse=true;
769 if (currentItem()!=0) 769 if (currentItem()!=0)
770 { 770 {
771 currentItem()->setSelected(false); 771 currentItem()->setSelected(false);
772 currentItem()->repaint(); 772 currentItem()->repaint();
773// emit selectionChanged(); 773// emit selectionChanged();
774 }; 774 };
775 }; 775 };
776 776
777 QPoint p( contentsToViewport( e->pos() ) ); 777 QPoint p( contentsToViewport( e->pos() ) );
778 QListViewItem *at = itemAt (p); 778 QListViewItem *at = itemAt (p);
779 779
780 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 780 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
781 bool rootDecoClicked = at 781 bool rootDecoClicked = at
782 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 782 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
783 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 783 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
784 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 784 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
785 785
786 if (e->button() == LeftButton && !rootDecoClicked) 786 if (e->button() == LeftButton && !rootDecoClicked)
787 { 787 {
788 //Start a drag 788 //Start a drag
789 d->startDragPos = e->pos(); 789 d->startDragPos = e->pos();
790 790
791 if (at) 791 if (at)
792 { 792 {
793 d->validDrag = true; 793 d->validDrag = true;
794 d->pressedOnSelected = at->isSelected(); 794 d->pressedOnSelected = at->isSelected();
795 } 795 }
796 } 796 }
797 797
798 QListView::contentsMousePressEvent( e ); 798 QListView::contentsMousePressEvent( e );
799} 799}
800 800
801void KListView::contentsMouseMoveEvent( QMouseEvent *e ) 801void KListView::contentsMouseMoveEvent( QMouseEvent *e )
802{ 802{
803 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { 803 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) {
804 QListView::contentsMouseMoveEvent (e); 804 QListView::contentsMouseMoveEvent (e);
805 return; 805 return;
806 } 806 }
807 807
808 QPoint vp = contentsToViewport(e->pos()); 808 QPoint vp = contentsToViewport(e->pos());
809 QListViewItem *item = itemAt( vp ); 809 QListViewItem *item = itemAt( vp );
810 810
811 //do we process cursor changes at all? 811 //do we process cursor changes at all?
812 if ( item && d->bChangeCursorOverItem && d->bUseSingle ) 812 if ( item && d->bChangeCursorOverItem && d->bUseSingle )
813 { 813 {
814 //Cursor moved on a new item or in/out the execute area 814 //Cursor moved on a new item or in/out the execute area
815 if( (item != d->pCurrentItem) || 815 if( (item != d->pCurrentItem) ||
816 (isExecuteArea(vp) != d->cursorInExecuteArea) ) 816 (isExecuteArea(vp) != d->cursorInExecuteArea) )
817 { 817 {
818 d->cursorInExecuteArea = isExecuteArea(vp); 818 d->cursorInExecuteArea = isExecuteArea(vp);
819qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); 819qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet");
820/*US 820/*US
821 if( d->cursorInExecuteArea ) //cursor moved in execute area 821 if( d->cursorInExecuteArea ) //cursor moved in execute area
822 viewport()->setCursor( KCursor::handCursor() ); 822 viewport()->setCursor( KCursor::handCursor() );
823 else //cursor moved out of execute area 823 else //cursor moved out of execute area
824 viewport()->unsetCursor(); 824 viewport()->unsetCursor();
825*/ 825*/
826 } 826 }
827 } 827 }
828 828
829 bool dragOn = dragEnabled(); 829 bool dragOn = dragEnabled();
830 QPoint newPos = e->pos(); 830 QPoint newPos = e->pos();
831 if (dragOn && d->validDrag && 831 if (dragOn && d->validDrag &&
832 (newPos.x() > d->startDragPos.x()+d->dragDelay || 832 (newPos.x() > d->startDragPos.x()+d->dragDelay ||
833 newPos.x() < d->startDragPos.x()-d->dragDelay || 833 newPos.x() < d->startDragPos.x()-d->dragDelay ||
834 newPos.y() > d->startDragPos.y()+d->dragDelay || 834 newPos.y() > d->startDragPos.y()+d->dragDelay ||
835 newPos.y() < d->startDragPos.y()-d->dragDelay)) 835 newPos.y() < d->startDragPos.y()-d->dragDelay))
836 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) 836 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
837 { 837 {
838 QListView::contentsMouseReleaseEvent( 0 ); 838 QListView::contentsMouseReleaseEvent( 0 );
839 startDrag(); 839 startDrag();
840 d->startDragPos = QPoint(); 840 d->startDragPos = QPoint();
841 d->validDrag = false; 841 d->validDrag = false;
842 } 842 }
843} 843}
844 844
845void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) 845void KListView::contentsMouseReleaseEvent( QMouseEvent *e )
846{ 846{
847 if (e->button() == LeftButton) 847 if (e->button() == LeftButton)
848 { 848 {
849 // If the row was already selected, maybe we want to start an in-place editing 849 // If the row was already selected, maybe we want to start an in-place editing
850 if ( d->pressedOnSelected && itemsRenameable() ) 850 if ( d->pressedOnSelected && itemsRenameable() )
851 { 851 {
852 QPoint p( contentsToViewport( e->pos() ) ); 852 QPoint p( contentsToViewport( e->pos() ) );
853 QListViewItem *at = itemAt (p); 853 QListViewItem *at = itemAt (p);
854 if ( at ) 854 if ( at )
855 { 855 {
856 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 856 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
857 bool rootDecoClicked = 857 bool rootDecoClicked =
858 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 858 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
859 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 859 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
860 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 860 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
861 861
862 if (!rootDecoClicked) 862 if (!rootDecoClicked)
863 { 863 {
864 int col = header()->mapToLogical( header()->cellAt( p.x() ) ); 864 int col = header()->mapToLogical( header()->cellAt( p.x() ) );
865 if ( d->renameable.contains(col) ) 865 if ( d->renameable.contains(col) )
866 rename(at, col); 866 rename(at, col);
867 } 867 }
868 } 868 }
869 } 869 }
870 870
871 d->pressedOnSelected = false; 871 d->pressedOnSelected = false;
872 d->validDrag = false; 872 d->validDrag = false;
873 d->startDragPos = QPoint(); 873 d->startDragPos = QPoint();
874 } 874 }
875 QListView::contentsMouseReleaseEvent( e ); 875 QListView::contentsMouseReleaseEvent( e );
876} 876}
877 877
878void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) 878void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e )
879{ 879{
880 // We don't want to call the parent method because it does setOpen, 880 // We don't want to call the parent method because it does setOpen,
881 // whereas we don't do it in single click mode... (David) 881 // whereas we don't do it in single click mode... (David)
882 //QListView::contentsMouseDoubleClickEvent( e ); 882 //QListView::contentsMouseDoubleClickEvent( e );
883 883
884 QPoint vp = contentsToViewport(e->pos()); 884 QPoint vp = contentsToViewport(e->pos());
885 QListViewItem *item = itemAt( vp ); 885 QListViewItem *item = itemAt( vp );
886 emit QListView::doubleClicked( item ); // we do it now 886 emit QListView::doubleClicked( item ); // we do it now
887 887
888 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; 888 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1;
889 889
890 if( item ) { 890 if( item ) {
891 emit doubleClicked( item, e->globalPos(), col ); 891 emit doubleClicked( item, e->globalPos(), col );
892 892
893 if( (e->button() == LeftButton) && !d->bUseSingle ) 893 if( (e->button() == LeftButton) && !d->bUseSingle )
894 emitExecute( item, e->globalPos(), col ); 894 emitExecute( item, e->globalPos(), col );
895 } 895 }
896} 896}
897 897
898void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) 898void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c )
899{ 899{
900 if( (btn == LeftButton) && item ) 900 if( (btn == LeftButton) && item )
901 emitExecute(item, pos, c); 901 emitExecute(item, pos, c);
902} 902}