summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-02 12:16:34 (UTC)
committer zautrix <zautrix>2005-04-02 12:16:34 (UTC)
commit997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (unidiff)
treef788b37459574b5cea0d2ab874882c6a396c240d
parente0d51120d2f0c178115746e0c1357af40f95bc77 (diff)
downloadkdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz
kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp5
-rw-r--r--kaddressbook/viewmanager.cpp2
-rw-r--r--kaddressbook/views/colorlistbox.cpp7
-rw-r--r--kaddressbook/views/colorlistbox.h1
-rw-r--r--kaddressbook/views/configurecardviewdialog.cpp4
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp6
-rw-r--r--korganizer/koagenda.cpp57
-rw-r--r--korganizer/koagenda.h4
-rw-r--r--korganizer/koagendaview.cpp18
-rw-r--r--korganizer/koagendaview.h4
-rw-r--r--korganizer/kotodoview.cpp49
-rw-r--r--microkde/kcolordialog.cpp1
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
13 files changed, 120 insertions, 40 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 5ef61b1..e34951a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -210,385 +210,385 @@ class KABFormatPrefs : public QDialog
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
212 lay->addWidget( lab ); 212 lay->addWidget( lab );
213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
214 lay->addWidget( format ); 214 lay->addWidget( format );
215 format->setExclusive ( true ) ; 215 format->setExclusive ( true ) ;
216 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 216 simple = new QRadioButton(i18n("Simple: James Bond"), format );
217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
219 company = new QRadioButton(i18n("Organization: MI6"), format ); 219 company = new QRadioButton(i18n("Organization: MI6"), format );
220 simple->setChecked( true ); 220 simple->setChecked( true );
221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
222 lay->addWidget( setCompany ); 222 lay->addWidget( setCompany );
223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
224 lay->addWidget( ok ); 224 lay->addWidget( ok );
225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
226 lay->addWidget( cancel ); 226 lay->addWidget( cancel );
227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
229 //resize( 200, 200 ); 229 //resize( 200, 200 );
230 230
231 } 231 }
232public: 232public:
233 QRadioButton* simple, *full, *reverse, *company; 233 QRadioButton* simple, *full, *reverse, *company;
234 QCheckBox* setCompany; 234 QCheckBox* setCompany;
235}; 235};
236 236
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mIncSearchWidget = 0; 301 mIncSearchWidget = 0;
302 mMiniSplitter = 0; 302 mMiniSplitter = 0;
303 mExtensionBarSplitter = 0; 303 mExtensionBarSplitter = 0;
304 mIsPart = !parent->inherits( "KAddressBookMain" ); 304 mIsPart = !parent->inherits( "KAddressBookMain" );
305 mAddressBook = KABC::StdAddressBook::self(); 305 mAddressBook = KABC::StdAddressBook::self();
306 KABC::StdAddressBook::setAutomaticSave( false ); 306 KABC::StdAddressBook::setAutomaticSave( false );
307 307
308#ifndef KAB_EMBEDDED 308#ifndef KAB_EMBEDDED
309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
313 SLOT( addressBookChanged() ) ); 313 SLOT( addressBookChanged() ) );
314 314
315#if 0 315#if 0
316 // LR moved to addressbook init method 316 // LR moved to addressbook init method
317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
318 "X-Department", "KADDRESSBOOK" ); 318 "X-Department", "KADDRESSBOOK" );
319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
320 "X-Profession", "KADDRESSBOOK" ); 320 "X-Profession", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
322 "X-AssistantsName", "KADDRESSBOOK" ); 322 "X-AssistantsName", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
324 "X-ManagersName", "KADDRESSBOOK" ); 324 "X-ManagersName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
326 "X-SpousesName", "KADDRESSBOOK" ); 326 "X-SpousesName", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
328 "X-Office", "KADDRESSBOOK" ); 328 "X-Office", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
330 "X-IMAddress", "KADDRESSBOOK" ); 330 "X-IMAddress", "KADDRESSBOOK" );
331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
332 "X-Anniversary", "KADDRESSBOOK" ); 332 "X-Anniversary", "KADDRESSBOOK" );
333 333
334 //US added this field to become compatible with Opie/qtopia addressbook 334 //US added this field to become compatible with Opie/qtopia addressbook
335 // values can be "female" or "male" or "". An empty field represents undefined. 335 // values can be "female" or "male" or "". An empty field represents undefined.
336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
337 "X-Gender", "KADDRESSBOOK" ); 337 "X-Gender", "KADDRESSBOOK" );
338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
339 "X-Children", "KADDRESSBOOK" ); 339 "X-Children", "KADDRESSBOOK" );
340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
341 "X-FreeBusyUrl", "KADDRESSBOOK" ); 341 "X-FreeBusyUrl", "KADDRESSBOOK" );
342#endif 342#endif
343 initGUI(); 343 initGUI();
344 344
345 mIncSearchWidget->setFocus(); 345 mIncSearchWidget->setFocus();
346 346
347 347
348 connect( mViewManager, SIGNAL( selected( const QString& ) ), 348 connect( mViewManager, SIGNAL( selected( const QString& ) ),
349 SLOT( setContactSelected( const QString& ) ) ); 349 SLOT( setContactSelected( const QString& ) ) );
350 connect( mViewManager, SIGNAL( executed( const QString& ) ), 350 connect( mViewManager, SIGNAL( executed( const QString& ) ),
351 SLOT( executeContact( const QString& ) ) ); 351 SLOT( executeContact( const QString& ) ) );
352 352
353 connect( mViewManager, SIGNAL( deleteRequest( ) ), 353 connect( mViewManager, SIGNAL( deleteRequest( ) ),
354 SLOT( deleteContacts( ) ) ); 354 SLOT( deleteContacts( ) ) );
355 connect( mViewManager, SIGNAL( modified() ), 355 connect( mViewManager, SIGNAL( modified() ),
356 SLOT( setModified() ) ); 356 SLOT( setModified() ) );
357 357
358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
360 360
361 connect( mXXPortManager, SIGNAL( modified() ), 361 connect( mXXPortManager, SIGNAL( modified() ),
362 SLOT( setModified() ) ); 362 SLOT( setModified() ) );
363 363
364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
365 SLOT( incrementalSearchJump( const QString& ) ) ); 365 SLOT( incrementalSearchJump( const QString& ) ) );
366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
367 mJumpButtonBar, SLOT( recreateButtons() ) ); 367 mJumpButtonBar, SLOT( recreateButtons() ) );
368 368
369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
370 SLOT( sendMail( const QString& ) ) ); 370 SLOT( sendMail( const QString& ) ) );
371 371
372 372
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
378 378
379 379
380#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
382 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 382 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
383 383
384 connect( mDetails, SIGNAL( browse( const QString& ) ), 384 connect( mDetails, SIGNAL( browse( const QString& ) ),
385 SLOT( browse( const QString& ) ) ); 385 SLOT( browse( const QString& ) ) );
386 386
387 387
388 mAddressBookService = new KAddressBookService( this ); 388 mAddressBookService = new KAddressBookService( this );
389 389
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 mMessageTimer = new QTimer( this ); 392 mMessageTimer = new QTimer( this );
393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
394 mEditorDialog = 0; 394 mEditorDialog = 0;
395 createAddresseeEditorDialog( this ); 395 createAddresseeEditorDialog( this );
396 setModified( false ); 396 setModified( false );
397 mBRdisabled = false; 397 mBRdisabled = false;
398#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
399 infrared = 0; 399 infrared = 0;
400#endif 400#endif
401 //toggleBeamReceive( ); 401 //toggleBeamReceive( );
402 //mMainWindow->toolBar()->show(); 402 mMainWindow->toolBar()->show();
403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
404 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 404 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
405} 405}
406 406
407void KABCore::updateToolBar() 407void KABCore::updateToolBar()
408{ 408{
409 static int iii = 0; 409 static int iii = 0;
410 ++iii; 410 ++iii;
411 mMainWindow->toolBar()->repaintMe(); 411 mMainWindow->toolBar()->repaintMe();
412 if ( iii < 4 ) 412 if ( iii < 4 )
413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
414} 414}
415KABCore::~KABCore() 415KABCore::~KABCore()
416{ 416{
417 // save(); 417 // save();
418 //saveSettings(); 418 //saveSettings();
419 //KABPrefs::instance()->writeConfig(); 419 //KABPrefs::instance()->writeConfig();
420 delete AddresseeConfig::instance(); 420 delete AddresseeConfig::instance();
421 mAddressBook = 0; 421 mAddressBook = 0;
422 KABC::StdAddressBook::close(); 422 KABC::StdAddressBook::close();
423 423
424 delete syncManager; 424 delete syncManager;
425#ifndef DESKTOP_VERSION 425#ifndef DESKTOP_VERSION
426 if ( infrared ) 426 if ( infrared )
427 delete infrared; 427 delete infrared;
428#endif 428#endif
429} 429}
430void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 430void KABCore::receive( const QCString& cmsg, const QByteArray& data )
431{ 431{
432 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 432 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
433 if ( cmsg == "setDocument(QString)" ) { 433 if ( cmsg == "setDocument(QString)" ) {
434 QDataStream stream( data, IO_ReadOnly ); 434 QDataStream stream( data, IO_ReadOnly );
435 QString fileName; 435 QString fileName;
436 stream >> fileName; 436 stream >> fileName;
437 recieve( fileName ); 437 recieve( fileName );
438 return; 438 return;
439 } 439 }
440} 440}
441void KABCore::toggleBeamReceive( ) 441void KABCore::toggleBeamReceive( )
442{ 442{
443 if ( mBRdisabled ) 443 if ( mBRdisabled )
444 return; 444 return;
445#ifndef DESKTOP_VERSION 445#ifndef DESKTOP_VERSION
446 if ( infrared ) { 446 if ( infrared ) {
447 qDebug("KA: AB disable BeamReceive "); 447 qDebug("KA: AB disable BeamReceive ");
448 delete infrared; 448 delete infrared;
449 infrared = 0; 449 infrared = 0;
450 mActionBR->setChecked(false); 450 mActionBR->setChecked(false);
451 return; 451 return;
452 } 452 }
453 qDebug("KA: AB enable BeamReceive "); 453 qDebug("KA: AB enable BeamReceive ");
454 mActionBR->setChecked(true); 454 mActionBR->setChecked(true);
455 455
456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
458#endif 458#endif
459} 459}
460 460
461 461
462void KABCore::disableBR(bool b) 462void KABCore::disableBR(bool b)
463{ 463{
464#ifndef DESKTOP_VERSION 464#ifndef DESKTOP_VERSION
465 if ( b ) { 465 if ( b ) {
466 if ( infrared ) { 466 if ( infrared ) {
467 toggleBeamReceive( ); 467 toggleBeamReceive( );
468 } 468 }
469 mBRdisabled = true; 469 mBRdisabled = true;
470 } else { 470 } else {
471 if ( mBRdisabled ) { 471 if ( mBRdisabled ) {
472 mBRdisabled = false; 472 mBRdisabled = false;
473 //toggleBeamReceive( ); 473 //toggleBeamReceive( );
474 } 474 }
475 } 475 }
476#endif 476#endif
477 477
478} 478}
479void KABCore::recieve( QString fn ) 479void KABCore::recieve( QString fn )
480{ 480{
481 //qDebug("KABCore::recieve "); 481 //qDebug("KABCore::recieve ");
482 int count = mAddressBook->importFromFile( fn, true ); 482 int count = mAddressBook->importFromFile( fn, true );
483 if ( count ) 483 if ( count )
484 setModified( true ); 484 setModified( true );
485 mViewManager->refreshView(); 485 mViewManager->refreshView();
486 message(i18n("%1 contact(s) received!").arg( count )); 486 message(i18n("%1 contact(s) received!").arg( count ));
487 topLevelWidget()->showMaximized(); 487 topLevelWidget()->showMaximized();
488 topLevelWidget()->raise(); 488 topLevelWidget()->raise();
489} 489}
490void KABCore::restoreSettings() 490void KABCore::restoreSettings()
491{ 491{
492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
493 493
494 bool state; 494 bool state;
495 495
496 if (mMultipleViewsAtOnce) 496 if (mMultipleViewsAtOnce)
497 state = KABPrefs::instance()->mDetailsPageVisible; 497 state = KABPrefs::instance()->mDetailsPageVisible;
498 else 498 else
499 state = false; 499 state = false;
500 500
501 mActionDetails->setChecked( state ); 501 mActionDetails->setChecked( state );
502 setDetailsVisible( state ); 502 setDetailsVisible( state );
503 503
504 state = KABPrefs::instance()->mJumpButtonBarVisible; 504 state = KABPrefs::instance()->mJumpButtonBarVisible;
505 505
506 mActionJumpBar->setChecked( state ); 506 mActionJumpBar->setChecked( state );
507 setJumpButtonBarVisible( state ); 507 setJumpButtonBarVisible( state );
508/*US 508/*US
509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
510 if ( splitterSize.count() == 0 ) { 510 if ( splitterSize.count() == 0 ) {
511 splitterSize.append( width() / 2 ); 511 splitterSize.append( width() / 2 );
512 splitterSize.append( width() / 2 ); 512 splitterSize.append( width() / 2 );
513 } 513 }
514 mMiniSplitter->setSizes( splitterSize ); 514 mMiniSplitter->setSizes( splitterSize );
515 if ( mExtensionBarSplitter ) { 515 if ( mExtensionBarSplitter ) {
516 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 516 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
517 if ( splitterSize.count() == 0 ) { 517 if ( splitterSize.count() == 0 ) {
518 splitterSize.append( width() / 2 ); 518 splitterSize.append( width() / 2 );
519 splitterSize.append( width() / 2 ); 519 splitterSize.append( width() / 2 );
520 } 520 }
521 mExtensionBarSplitter->setSizes( splitterSize ); 521 mExtensionBarSplitter->setSizes( splitterSize );
522 522
523 } 523 }
524*/ 524*/
525 mViewManager->restoreSettings(); 525 mViewManager->restoreSettings();
526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
527 mExtensionManager->restoreSettings(); 527 mExtensionManager->restoreSettings();
528#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
529 int wid = width(); 529 int wid = width();
530 if ( wid < 10 ) 530 if ( wid < 10 )
531 wid = 400; 531 wid = 400;
532#else 532#else
533 int wid = QApplication::desktop()->width(); 533 int wid = QApplication::desktop()->width();
534 if ( wid < 640 ) 534 if ( wid < 640 )
535 wid = QApplication::desktop()->height(); 535 wid = QApplication::desktop()->height();
536#endif 536#endif
537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
538 if ( true /*splitterSize.count() == 0*/ ) { 538 if ( true /*splitterSize.count() == 0*/ ) {
539 splitterSize.append( wid / 2 ); 539 splitterSize.append( wid / 2 );
540 splitterSize.append( wid / 2 ); 540 splitterSize.append( wid / 2 );
541 } 541 }
542 mMiniSplitter->setSizes( splitterSize ); 542 mMiniSplitter->setSizes( splitterSize );
543 if ( mExtensionBarSplitter ) { 543 if ( mExtensionBarSplitter ) {
544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
545 if ( true /*splitterSize.count() == 0*/ ) { 545 if ( true /*splitterSize.count() == 0*/ ) {
546 splitterSize.append( wid / 2 ); 546 splitterSize.append( wid / 2 );
547 splitterSize.append( wid / 2 ); 547 splitterSize.append( wid / 2 );
548 } 548 }
549 mExtensionBarSplitter->setSizes( splitterSize ); 549 mExtensionBarSplitter->setSizes( splitterSize );
550 550
551 } 551 }
552 552
553 553
554} 554}
555 555
556void KABCore::saveSettings() 556void KABCore::saveSettings()
557{ 557{
558 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 558 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
559 if ( mExtensionBarSplitter ) 559 if ( mExtensionBarSplitter )
560 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 560 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
561 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 561 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
562 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 562 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
563#ifndef KAB_EMBEDDED 563#ifndef KAB_EMBEDDED
564 564
565 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 565 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
566 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 566 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
567#endif //KAB_EMBEDDED 567#endif //KAB_EMBEDDED
568 mExtensionManager->saveSettings(); 568 mExtensionManager->saveSettings();
569 mViewManager->saveSettings(); 569 mViewManager->saveSettings();
570 570
571 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 571 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
572 KABPrefs::instance()->writeConfig(); 572 KABPrefs::instance()->writeConfig();
573 qDebug("KA: KABCore::saveSettings() "); 573 qDebug("KA: KABCore::saveSettings() ");
574} 574}
575 575
576KABC::AddressBook *KABCore::addressBook() const 576KABC::AddressBook *KABCore::addressBook() const
577{ 577{
578 return mAddressBook; 578 return mAddressBook;
579} 579}
580 580
581KConfig *KABCore::config() 581KConfig *KABCore::config()
582{ 582{
583#ifndef KAB_EMBEDDED 583#ifndef KAB_EMBEDDED
584 return KABPrefs::instance()->config(); 584 return KABPrefs::instance()->config();
585#else //KAB_EMBEDDED 585#else //KAB_EMBEDDED
586 return KABPrefs::instance()->getConfig(); 586 return KABPrefs::instance()->getConfig();
587#endif //KAB_EMBEDDED 587#endif //KAB_EMBEDDED
588} 588}
589 589
590KActionCollection *KABCore::actionCollection() const 590KActionCollection *KABCore::actionCollection() const
591{ 591{
592 return mGUIClient->actionCollection(); 592 return mGUIClient->actionCollection();
593} 593}
594 594
@@ -1984,507 +1984,508 @@ void KABCore::initActions()
1984 "kaddressbook_select_all" ); 1984 "kaddressbook_select_all" );
1985 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1985 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1986 SLOT( undo() ), actionCollection(), 1986 SLOT( undo() ), actionCollection(),
1987 "kaddressbook_undo" ); 1987 "kaddressbook_undo" );
1988 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1988 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1989 this, SLOT( redo() ), actionCollection(), 1989 this, SLOT( redo() ), actionCollection(),
1990 "kaddressbook_redo" ); 1990 "kaddressbook_redo" );
1991 } else { 1991 } else {
1992 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1992 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1993 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1993 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1994 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1994 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1995 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1995 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1996 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1996 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1997 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1997 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1998 } 1998 }
1999 1999
2000 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2000 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2001 Key_Delete, this, SLOT( deleteContacts() ), 2001 Key_Delete, this, SLOT( deleteContacts() ),
2002 actionCollection(), "edit_delete" ); 2002 actionCollection(), "edit_delete" );
2003 2003
2004 mActionUndo->setEnabled( false ); 2004 mActionUndo->setEnabled( false );
2005 mActionRedo->setEnabled( false ); 2005 mActionRedo->setEnabled( false );
2006 2006
2007 // settings menu 2007 // settings menu
2008#ifdef KAB_EMBEDDED 2008#ifdef KAB_EMBEDDED
2009//US special menuentry to configure the addressbook resources. On KDE 2009//US special menuentry to configure the addressbook resources. On KDE
2010// you do that through the control center !!! 2010// you do that through the control center !!!
2011 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2011 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2012 SLOT( configureResources() ), actionCollection(), 2012 SLOT( configureResources() ), actionCollection(),
2013 "kaddressbook_configure_resources" ); 2013 "kaddressbook_configure_resources" );
2014#endif //KAB_EMBEDDED 2014#endif //KAB_EMBEDDED
2015 2015
2016 if ( mIsPart ) { 2016 if ( mIsPart ) {
2017 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2017 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2018 SLOT( openConfigDialog() ), actionCollection(), 2018 SLOT( openConfigDialog() ), actionCollection(),
2019 "kaddressbook_configure" ); 2019 "kaddressbook_configure" );
2020 2020
2021 //US not implemented yet 2021 //US not implemented yet
2022 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2022 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2023 // this, SLOT( configureKeyBindings() ), actionCollection(), 2023 // this, SLOT( configureKeyBindings() ), actionCollection(),
2024 // "kaddressbook_configure_shortcuts" ); 2024 // "kaddressbook_configure_shortcuts" );
2025#ifdef KAB_EMBEDDED 2025#ifdef KAB_EMBEDDED
2026 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2026 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2027 mActionConfigureToolbars->setEnabled( false ); 2027 mActionConfigureToolbars->setEnabled( false );
2028#endif //KAB_EMBEDDED 2028#endif //KAB_EMBEDDED
2029 2029
2030 } else { 2030 } else {
2031 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 2031 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
2032 2032
2033 //US not implemented yet 2033 //US not implemented yet
2034 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 2034 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
2035 } 2035 }
2036 2036
2037 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2037 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2038 actionCollection(), "options_show_jump_bar" ); 2038 actionCollection(), "options_show_jump_bar" );
2039 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2039 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2040 2040
2041 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2041 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2042 actionCollection(), "options_show_details" ); 2042 actionCollection(), "options_show_details" );
2043 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2043 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2044 2044
2045 2045
2046 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2046 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2047 SLOT( toggleBeamReceive() ), actionCollection(), 2047 SLOT( toggleBeamReceive() ), actionCollection(),
2048 "kaddressbook_beam_rec" ); 2048 "kaddressbook_beam_rec" );
2049 2049
2050 2050
2051 // misc 2051 // misc
2052 // only enable LDAP lookup if we can handle the protocol 2052 // only enable LDAP lookup if we can handle the protocol
2053#ifndef KAB_EMBEDDED 2053#ifndef KAB_EMBEDDED
2054 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2054 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2055 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2055 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2056 this, SLOT( openLDAPDialog() ), actionCollection(), 2056 this, SLOT( openLDAPDialog() ), actionCollection(),
2057 "ldap_lookup" ); 2057 "ldap_lookup" );
2058 } 2058 }
2059#else //KAB_EMBEDDED 2059#else //KAB_EMBEDDED
2060 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2060 //qDebug("KABCore::initActions() LDAP has to be implemented");
2061#endif //KAB_EMBEDDED 2061#endif //KAB_EMBEDDED
2062 2062
2063 2063
2064 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2064 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2065 SLOT( setWhoAmI() ), actionCollection(), 2065 SLOT( setWhoAmI() ), actionCollection(),
2066 "set_personal" ); 2066 "set_personal" );
2067 2067
2068 2068
2069 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2069 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2070 SLOT( setCategories() ), actionCollection(), 2070 SLOT( setCategories() ), actionCollection(),
2071 "edit_set_categories" ); 2071 "edit_set_categories" );
2072 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2072 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2073 SLOT( editCategories() ), actionCollection(), 2073 SLOT( editCategories() ), actionCollection(),
2074 "edit__categories" ); 2074 "edit__categories" );
2075 2075
2076 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2076 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2077 SLOT( removeVoice() ), actionCollection(), 2077 SLOT( removeVoice() ), actionCollection(),
2078 "remove_voice" ); 2078 "remove_voice" );
2079 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2079 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2080 SLOT( setFormattedName() ), actionCollection(), 2080 SLOT( setFormattedName() ), actionCollection(),
2081 "set_formatted" ); 2081 "set_formatted" );
2082 2082
2083 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2083 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2084 SLOT( manageCategories() ), actionCollection(), 2084 SLOT( manageCategories() ), actionCollection(),
2085 "remove_voice" ); 2085 "remove_voice" );
2086 2086
2087 2087
2088 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2088 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2089 SLOT( importFromOL() ), actionCollection(), 2089 SLOT( importFromOL() ), actionCollection(),
2090 "import_OL" ); 2090 "import_OL" );
2091#ifdef KAB_EMBEDDED 2091#ifdef KAB_EMBEDDED
2092 mActionLicence = new KAction( i18n( "Licence" ), 0, 2092 mActionLicence = new KAction( i18n( "Licence" ), 0,
2093 this, SLOT( showLicence() ), actionCollection(), 2093 this, SLOT( showLicence() ), actionCollection(),
2094 "licence_about_data" ); 2094 "licence_about_data" );
2095 mActionFaq = new KAction( i18n( "Faq" ), 0, 2095 mActionFaq = new KAction( i18n( "Faq" ), 0,
2096 this, SLOT( faq() ), actionCollection(), 2096 this, SLOT( faq() ), actionCollection(),
2097 "faq_about_data" ); 2097 "faq_about_data" );
2098 mActionWN = new KAction( i18n( "What's New?" ), 0, 2098 mActionWN = new KAction( i18n( "What's New?" ), 0,
2099 this, SLOT( whatsnew() ), actionCollection(), 2099 this, SLOT( whatsnew() ), actionCollection(),
2100 "wn" ); 2100 "wn" );
2101 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2101 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2102 this, SLOT( synchowto() ), actionCollection(), 2102 this, SLOT( synchowto() ), actionCollection(),
2103 "sync" ); 2103 "sync" );
2104 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2104 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2105 this, SLOT( kdesynchowto() ), actionCollection(), 2105 this, SLOT( kdesynchowto() ), actionCollection(),
2106 "kdesync" ); 2106 "kdesync" );
2107 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2107 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2108 this, SLOT( multisynchowto() ), actionCollection(), 2108 this, SLOT( multisynchowto() ), actionCollection(),
2109 "multisync" ); 2109 "multisync" );
2110 2110
2111 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2111 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2112 this, SLOT( createAboutData() ), actionCollection(), 2112 this, SLOT( createAboutData() ), actionCollection(),
2113 "kaddressbook_about_data" ); 2113 "kaddressbook_about_data" );
2114#endif //KAB_EMBEDDED 2114#endif //KAB_EMBEDDED
2115 2115
2116 clipboardDataChanged(); 2116 clipboardDataChanged();
2117 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2117 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2118 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2118 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2119} 2119}
2120 2120
2121//US we need this function, to plug all actions into the correct menues. 2121//US we need this function, to plug all actions into the correct menues.
2122// KDE uses a XML format to plug the actions, but we work her without this overhead. 2122// KDE uses a XML format to plug the actions, but we work her without this overhead.
2123void KABCore::addActionsManually() 2123void KABCore::addActionsManually()
2124{ 2124{
2125//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2125//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2126 2126
2127#ifdef KAB_EMBEDDED 2127#ifdef KAB_EMBEDDED
2128 QPopupMenu *fileMenu = new QPopupMenu( this ); 2128 QPopupMenu *fileMenu = new QPopupMenu( this );
2129 QPopupMenu *editMenu = new QPopupMenu( this ); 2129 QPopupMenu *editMenu = new QPopupMenu( this );
2130 QPopupMenu *helpMenu = new QPopupMenu( this ); 2130 QPopupMenu *helpMenu = new QPopupMenu( this );
2131 2131
2132 KToolBar* tb = mMainWindow->toolBar(); 2132 KToolBar* tb = mMainWindow->toolBar();
2133 mMainWindow->setToolBarsMovable (false ); 2133 mMainWindow->setToolBarsMovable (false );
2134#ifndef DESKTOP_VERSION 2134#ifndef DESKTOP_VERSION
2135 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2135 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2136#endif 2136#endif
2137 QMenuBar* mb = mMainWindow->menuBar(); 2137 QMenuBar* mb = mMainWindow->menuBar();
2138 2138
2139 //US setup menubar. 2139 //US setup menubar.
2140 //Disable the following block if you do not want to have a menubar. 2140 //Disable the following block if you do not want to have a menubar.
2141 mb->insertItem( i18n("&File"), fileMenu ); 2141 mb->insertItem( i18n("&File"), fileMenu );
2142 mb->insertItem( i18n("&Edit"), editMenu ); 2142 mb->insertItem( i18n("&Edit"), editMenu );
2143 mb->insertItem( i18n("&View"), viewMenu ); 2143 mb->insertItem( i18n("&View"), viewMenu );
2144 mb->insertItem( i18n("&Settings"), settingsMenu ); 2144 mb->insertItem( i18n("&Settings"), settingsMenu );
2145#ifdef DESKTOP_VERSION 2145#ifdef DESKTOP_VERSION
2146 mb->insertItem( i18n("Synchronize"), syncMenu ); 2146 mb->insertItem( i18n("Synchronize"), syncMenu );
2147#else 2147#else
2148 mb->insertItem( i18n("Sync"), syncMenu ); 2148 mb->insertItem( i18n("Sync"), syncMenu );
2149#endif 2149#endif
2150 //mb->insertItem( i18n("&Change"), changeMenu ); 2150 //mb->insertItem( i18n("&Change"), changeMenu );
2151 mb->insertItem( i18n("&Help"), helpMenu ); 2151 mb->insertItem( i18n("&Help"), helpMenu );
2152 mIncSearchWidget = new IncSearchWidget( tb ); 2152 mIncSearchWidget = new IncSearchWidget( tb );
2153 // tb->insertWidget(-1, 0, mIncSearchWidget); 2153 // tb->insertWidget(-1, 0, mIncSearchWidget);
2154#ifndef DESKTOP_VERSION 2154#ifndef DESKTOP_VERSION
2155 } else { 2155 } else {
2156 //US setup toolbar 2156 //US setup toolbar
2157 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2157 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2158 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2158 QPopupMenu *popupBarTB = new QPopupMenu( this );
2159 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2159 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2160 tb->insertWidget(-1, 0, menuBarTB); 2160 tb->insertWidget(-1, 0, menuBarTB);
2161 mIncSearchWidget = new IncSearchWidget( tb ); 2161 mIncSearchWidget = new IncSearchWidget( tb );
2162 tb->enableMoving(false); 2162 tb->enableMoving(false);
2163 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2163 popupBarTB->insertItem( i18n("&File"), fileMenu );
2164 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2164 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2165 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2165 popupBarTB->insertItem( i18n("&View"), viewMenu );
2166 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2166 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2167 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2167 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2168 mViewManager->getFilterAction()->plug ( popupBarTB); 2168 mViewManager->getFilterAction()->plug ( popupBarTB);
2169 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2169 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2170 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2170 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2171 if (QApplication::desktop()->width() > 320 ) { 2171 if (QApplication::desktop()->width() > 320 ) {
2172 // mViewManager->getFilterAction()->plug ( tb); 2172 // mViewManager->getFilterAction()->plug ( tb);
2173 } 2173 }
2174 } 2174 }
2175#endif 2175#endif
2176 mIncSearchWidget->setSize();
2176 // mActionQuit->plug ( mMainWindow->toolBar()); 2177 // mActionQuit->plug ( mMainWindow->toolBar());
2177 2178
2178 2179
2179 2180
2180 //US Now connect the actions with the menue entries. 2181 //US Now connect the actions with the menue entries.
2181#ifdef DESKTOP_VERSION 2182#ifdef DESKTOP_VERSION
2182 mActionPrint->plug( fileMenu ); 2183 mActionPrint->plug( fileMenu );
2183 mActionPrintDetails->plug( fileMenu ); 2184 mActionPrintDetails->plug( fileMenu );
2184 fileMenu->insertSeparator(); 2185 fileMenu->insertSeparator();
2185#endif 2186#endif
2186 mActionMail->plug( fileMenu ); 2187 mActionMail->plug( fileMenu );
2187 fileMenu->insertSeparator(); 2188 fileMenu->insertSeparator();
2188 2189
2189 mActionNewContact->plug( editMenu ); 2190 mActionNewContact->plug( editMenu );
2190 mActionNewContact->plug( tb ); 2191 mActionNewContact->plug( tb );
2191 2192
2192 mActionEditAddressee->plug( editMenu ); 2193 mActionEditAddressee->plug( editMenu );
2193 editMenu->insertSeparator(); 2194 editMenu->insertSeparator();
2194 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2195 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2195 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2196 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2196 mActionEditAddressee->plug( tb ); 2197 mActionEditAddressee->plug( tb );
2197 2198
2198 // fileMenu->insertSeparator(); 2199 // fileMenu->insertSeparator();
2199 mActionSave->plug( fileMenu ); 2200 mActionSave->plug( fileMenu );
2200 fileMenu->insertItem( "&Import", ImportMenu ); 2201 fileMenu->insertItem( "&Import", ImportMenu );
2201 fileMenu->insertItem( "&Export", ExportMenu ); 2202 fileMenu->insertItem( "&Export", ExportMenu );
2202 editMenu->insertItem( i18n("&Change"), changeMenu ); 2203 editMenu->insertItem( i18n("&Change"), changeMenu );
2203 editMenu->insertSeparator(); 2204 editMenu->insertSeparator();
2204#ifndef DESKTOP_VERSION 2205#ifndef DESKTOP_VERSION
2205 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2206 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2206#endif 2207#endif
2207#if 0 2208#if 0
2208 // PENDING fix MailVCard 2209 // PENDING fix MailVCard
2209 fileMenu->insertSeparator(); 2210 fileMenu->insertSeparator();
2210 mActionMailVCard->plug( fileMenu ); 2211 mActionMailVCard->plug( fileMenu );
2211#endif 2212#endif
2212#ifndef DESKTOP_VERSION 2213#ifndef DESKTOP_VERSION
2213 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2214 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2214 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2215 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2215 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2216 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2216#endif 2217#endif
2217 fileMenu->insertSeparator(); 2218 fileMenu->insertSeparator();
2218 mActionQuit->plug( fileMenu ); 2219 mActionQuit->plug( fileMenu );
2219#ifdef _OL_IMPORT_ 2220#ifdef _OL_IMPORT_
2220 mActionImportOL->plug( ImportMenu ); 2221 mActionImportOL->plug( ImportMenu );
2221#endif 2222#endif
2222 // edit menu 2223 // edit menu
2223 mActionUndo->plug( editMenu ); 2224 mActionUndo->plug( editMenu );
2224 mActionRedo->plug( editMenu ); 2225 mActionRedo->plug( editMenu );
2225 editMenu->insertSeparator(); 2226 editMenu->insertSeparator();
2226 mActionCut->plug( editMenu ); 2227 mActionCut->plug( editMenu );
2227 mActionCopy->plug( editMenu ); 2228 mActionCopy->plug( editMenu );
2228 mActionPaste->plug( editMenu ); 2229 mActionPaste->plug( editMenu );
2229 mActionDelete->plug( editMenu ); 2230 mActionDelete->plug( editMenu );
2230 editMenu->insertSeparator(); 2231 editMenu->insertSeparator();
2231 mActionSelectAll->plug( editMenu ); 2232 mActionSelectAll->plug( editMenu );
2232 2233
2233 mActionSetFormattedName->plug( changeMenu ); 2234 mActionSetFormattedName->plug( changeMenu );
2234 mActionRemoveVoice->plug( changeMenu ); 2235 mActionRemoveVoice->plug( changeMenu );
2235 // settingsmings menu 2236 // settingsmings menu
2236//US special menuentry to configure the addressbook resources. On KDE 2237//US special menuentry to configure the addressbook resources. On KDE
2237// you do that through the control center !!! 2238// you do that through the control center !!!
2238 // settingsMenu->insertSeparator(); 2239 // settingsMenu->insertSeparator();
2239 2240
2240 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2241 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2241 mActionConfigResources->plug( settingsMenu,1 ); 2242 mActionConfigResources->plug( settingsMenu,1 );
2242 settingsMenu->insertSeparator(2); 2243 settingsMenu->insertSeparator(2);
2243 2244
2244 if ( mIsPart ) { 2245 if ( mIsPart ) {
2245 //US not implemented yet 2246 //US not implemented yet
2246 //mActionConfigShortcuts->plug( settingsMenu ); 2247 //mActionConfigShortcuts->plug( settingsMenu );
2247 //mActionConfigureToolbars->plug( settingsMenu ); 2248 //mActionConfigureToolbars->plug( settingsMenu );
2248 2249
2249 } else { 2250 } else {
2250 //US not implemented yet 2251 //US not implemented yet
2251 //mActionKeyBindings->plug( settingsMenu ); 2252 //mActionKeyBindings->plug( settingsMenu );
2252 } 2253 }
2253 2254
2254 mActionEditCategories->plug( settingsMenu ); 2255 mActionEditCategories->plug( settingsMenu );
2255 mActionManageCategories->plug( settingsMenu ); 2256 mActionManageCategories->plug( settingsMenu );
2256 mActionJumpBar->plug( viewMenu,0 ); 2257 mActionJumpBar->plug( viewMenu,0 );
2257 mActionDetails->plug( viewMenu,0 ); 2258 mActionDetails->plug( viewMenu,0 );
2258 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2259 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2259 mActionDetails->plug( tb ); 2260 mActionDetails->plug( tb );
2260 settingsMenu->insertSeparator(); 2261 settingsMenu->insertSeparator();
2261#ifndef DESKTOP_VERSION 2262#ifndef DESKTOP_VERSION
2262 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2263 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2263 settingsMenu->insertSeparator(); 2264 settingsMenu->insertSeparator();
2264#endif 2265#endif
2265 2266
2266 mActionWhoAmI->plug( settingsMenu ); 2267 mActionWhoAmI->plug( settingsMenu );
2267 //mActionEditCategories->plug( changeMenu ); 2268 //mActionEditCategories->plug( changeMenu );
2268 mActionCategories->plug( changeMenu ); 2269 mActionCategories->plug( changeMenu );
2269 //mActionManageCategories->plug( changeMenu ); 2270 //mActionManageCategories->plug( changeMenu );
2270 2271
2271 //mActionCategories->plug( settingsMenu ); 2272 //mActionCategories->plug( settingsMenu );
2272 2273
2273 2274
2274 mActionWN->plug( helpMenu ); 2275 mActionWN->plug( helpMenu );
2275 mActionSyncHowto->plug( helpMenu ); 2276 mActionSyncHowto->plug( helpMenu );
2276 mActionKdeSyncHowto->plug( helpMenu ); 2277 mActionKdeSyncHowto->plug( helpMenu );
2277 mActionMultiSyncHowto->plug( helpMenu ); 2278 mActionMultiSyncHowto->plug( helpMenu );
2278 mActionFaq->plug( helpMenu ); 2279 mActionFaq->plug( helpMenu );
2279 mActionLicence->plug( helpMenu ); 2280 mActionLicence->plug( helpMenu );
2280 mActionAboutKAddressbook->plug( helpMenu ); 2281 mActionAboutKAddressbook->plug( helpMenu );
2281 2282
2282 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2283 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2283 2284
2284 mActionSave->plug( tb ); 2285 mActionSave->plug( tb );
2285 mViewManager->getFilterAction()->plug ( tb); 2286 mViewManager->getFilterAction()->plug ( tb);
2286 //LR hide filteraction on started in 480x640 2287 //LR hide filteraction on started in 480x640
2287 if (QApplication::desktop()->width() == 480 ) { 2288 if (QApplication::desktop()->width() == 480 ) {
2288 mViewManager->getFilterAction()->setComboWidth( 0 ); 2289 mViewManager->getFilterAction()->setComboWidth( 0 );
2289 } 2290 }
2290 mActionUndo->plug( tb ); 2291 mActionUndo->plug( tb );
2291 mActionDelete->plug( tb ); 2292 mActionDelete->plug( tb );
2292 mActionRedo->plug( tb ); 2293 mActionRedo->plug( tb );
2293 } else { 2294 } else {
2294 mActionSave->plug( tb ); 2295 mActionSave->plug( tb );
2295 tb->enableMoving(false); 2296 tb->enableMoving(false);
2296 } 2297 }
2297 //mActionQuit->plug ( tb ); 2298 //mActionQuit->plug ( tb );
2298 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2299 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2299 2300
2300 //US link the searchwidget first to this. 2301 //US link the searchwidget first to this.
2301 // The real linkage to the toolbar happens later. 2302 // The real linkage to the toolbar happens later.
2302//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2303//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2303//US tb->insertItem( mIncSearchWidget ); 2304//US tb->insertItem( mIncSearchWidget );
2304/*US 2305/*US
2305 mIncSearchWidget = new IncSearchWidget( tb ); 2306 mIncSearchWidget = new IncSearchWidget( tb );
2306 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2307 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2307 SLOT( incrementalSearch( const QString& ) ) ); 2308 SLOT( incrementalSearch( const QString& ) ) );
2308 2309
2309 mJumpButtonBar = new JumpButtonBar( this, this ); 2310 mJumpButtonBar = new JumpButtonBar( this, this );
2310 2311
2311//US topLayout->addWidget( mJumpButtonBar ); 2312//US topLayout->addWidget( mJumpButtonBar );
2312 this->layout()->add( mJumpButtonBar ); 2313 this->layout()->add( mJumpButtonBar );
2313*/ 2314*/
2314 2315
2315#endif //KAB_EMBEDDED 2316#endif //KAB_EMBEDDED
2316 2317
2317 mActionExport2phone->plug( ExportMenu ); 2318 mActionExport2phone->plug( ExportMenu );
2318 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2319 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2319 syncManager->fillSyncMenu(); 2320 syncManager->fillSyncMenu();
2320 2321
2321} 2322}
2322void KABCore::showLicence() 2323void KABCore::showLicence()
2323{ 2324{
2324 KApplication::showLicence(); 2325 KApplication::showLicence();
2325} 2326}
2326 2327
2327void KABCore::manageCategories( ) 2328void KABCore::manageCategories( )
2328{ 2329{
2329 KABCatPrefs* cp = new KABCatPrefs(); 2330 KABCatPrefs* cp = new KABCatPrefs();
2330 cp->show(); 2331 cp->show();
2331 int w =cp->sizeHint().width() ; 2332 int w =cp->sizeHint().width() ;
2332 int h = cp->sizeHint().height() ; 2333 int h = cp->sizeHint().height() ;
2333 int dw = QApplication::desktop()->width(); 2334 int dw = QApplication::desktop()->width();
2334 int dh = QApplication::desktop()->height(); 2335 int dh = QApplication::desktop()->height();
2335 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2336 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2336 if ( !cp->exec() ) { 2337 if ( !cp->exec() ) {
2337 delete cp; 2338 delete cp;
2338 return; 2339 return;
2339 } 2340 }
2340 int count = 0; 2341 int count = 0;
2341 int cc = 0; 2342 int cc = 0;
2342 message( i18n("Please wait, processing categories...")); 2343 message( i18n("Please wait, processing categories..."));
2343 if ( cp->addCat() ) { 2344 if ( cp->addCat() ) {
2344 KABC::AddressBook::Iterator it; 2345 KABC::AddressBook::Iterator it;
2345 QStringList catList = KABPrefs::instance()->mCustomCategories; 2346 QStringList catList = KABPrefs::instance()->mCustomCategories;
2346 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2347 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2347 ++cc; 2348 ++cc;
2348 if ( cc %10 == 0) 2349 if ( cc %10 == 0)
2349 message(i18n("Processing contact #%1").arg(cc)); 2350 message(i18n("Processing contact #%1").arg(cc));
2350 QStringList catIncList = (*it).categories(); 2351 QStringList catIncList = (*it).categories();
2351 int i; 2352 int i;
2352 for( i = 0; i< catIncList.count(); ++i ) { 2353 for( i = 0; i< catIncList.count(); ++i ) {
2353 if ( !catList.contains (catIncList[i])) { 2354 if ( !catList.contains (catIncList[i])) {
2354 catList.append( catIncList[i] ); 2355 catList.append( catIncList[i] );
2355 //qDebug("add cat %s ", catIncList[i].latin1()); 2356 //qDebug("add cat %s ", catIncList[i].latin1());
2356 ++count; 2357 ++count;
2357 } 2358 }
2358 } 2359 }
2359 } 2360 }
2360 catList.sort(); 2361 catList.sort();
2361 KABPrefs::instance()->mCustomCategories = catList; 2362 KABPrefs::instance()->mCustomCategories = catList;
2362 KABPrefs::instance()->writeConfig(); 2363 KABPrefs::instance()->writeConfig();
2363 message(QString::number( count )+ i18n(" categories added to list! ")); 2364 message(QString::number( count )+ i18n(" categories added to list! "));
2364 } else { 2365 } else {
2365 QStringList catList = KABPrefs::instance()->mCustomCategories; 2366 QStringList catList = KABPrefs::instance()->mCustomCategories;
2366 QStringList catIncList; 2367 QStringList catIncList;
2367 QStringList newCatList; 2368 QStringList newCatList;
2368 KABC::AddressBook::Iterator it; 2369 KABC::AddressBook::Iterator it;
2369 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2370 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2370 ++cc; 2371 ++cc;
2371 if ( cc %10 == 0) 2372 if ( cc %10 == 0)
2372 message(i18n("Processing contact #%1").arg(cc)); 2373 message(i18n("Processing contact #%1").arg(cc));
2373 QStringList catIncList = (*it).categories(); 2374 QStringList catIncList = (*it).categories();
2374 int i; 2375 int i;
2375 if ( catIncList.count() ) { 2376 if ( catIncList.count() ) {
2376 newCatList.clear(); 2377 newCatList.clear();
2377 for( i = 0; i< catIncList.count(); ++i ) { 2378 for( i = 0; i< catIncList.count(); ++i ) {
2378 if ( catList.contains (catIncList[i])) { 2379 if ( catList.contains (catIncList[i])) {
2379 newCatList.append( catIncList[i] ); 2380 newCatList.append( catIncList[i] );
2380 } 2381 }
2381 } 2382 }
2382 newCatList.sort(); 2383 newCatList.sort();
2383 (*it).setCategories( newCatList ); 2384 (*it).setCategories( newCatList );
2384 mAddressBook->insertAddressee( (*it) ); 2385 mAddressBook->insertAddressee( (*it) );
2385 } 2386 }
2386 } 2387 }
2387 setModified( true ); 2388 setModified( true );
2388 mViewManager->refreshView(); 2389 mViewManager->refreshView();
2389 message( i18n("Removing categories done!")); 2390 message( i18n("Removing categories done!"));
2390 } 2391 }
2391 delete cp; 2392 delete cp;
2392} 2393}
2393void KABCore::removeVoice() 2394void KABCore::removeVoice()
2394{ 2395{
2395 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2396 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2396 return; 2397 return;
2397 XXPortSelectDialog dlg( this, false, this ); 2398 XXPortSelectDialog dlg( this, false, this );
2398 if ( !dlg.exec() ) 2399 if ( !dlg.exec() )
2399 return; 2400 return;
2400 mAddressBook->setUntagged(); 2401 mAddressBook->setUntagged();
2401 dlg.tagSelected(); 2402 dlg.tagSelected();
2402 message(i18n("Removing voice..."), false ); 2403 message(i18n("Removing voice..."), false );
2403 KABC::AddressBook::Iterator it; 2404 KABC::AddressBook::Iterator it;
2404 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2405 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2405 if ( (*it).tagged() ) { 2406 if ( (*it).tagged() ) {
2406 (*it).removeVoice(); 2407 (*it).removeVoice();
2407 } 2408 }
2408 } 2409 }
2409 message(i18n("Refreshing view...") ); 2410 message(i18n("Refreshing view...") );
2410 qApp->processEvents(); 2411 qApp->processEvents();
2411 mViewManager->refreshView( "" ); 2412 mViewManager->refreshView( "" );
2412 Addressee add; 2413 Addressee add;
2413 mDetails->setAddressee( add ); 2414 mDetails->setAddressee( add );
2414 message(i18n("Remove voice completed!") ); 2415 message(i18n("Remove voice completed!") );
2415 2416
2416 2417
2417 2418
2418} 2419}
2419 2420
2420void KABCore::setFormattedName() 2421void KABCore::setFormattedName()
2421{ 2422{
2422 KABFormatPrefs setpref; 2423 KABFormatPrefs setpref;
2423 if ( !setpref.exec() ) { 2424 if ( !setpref.exec() ) {
2424 return; 2425 return;
2425 } 2426 }
2426 XXPortSelectDialog dlg( this, false, this ); 2427 XXPortSelectDialog dlg( this, false, this );
2427 if ( !dlg.exec() ) 2428 if ( !dlg.exec() )
2428 return; 2429 return;
2429 mAddressBook->setUntagged(); 2430 mAddressBook->setUntagged();
2430 dlg.tagSelected(); 2431 dlg.tagSelected();
2431 int count = 0; 2432 int count = 0;
2432 KABC::AddressBook::Iterator it; 2433 KABC::AddressBook::Iterator it;
2433 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2434 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2434 if ( (*it).tagged() ) { 2435 if ( (*it).tagged() ) {
2435 ++count; 2436 ++count;
2436 if ( count %10 == 0 ) 2437 if ( count %10 == 0 )
2437 message(i18n("Changing contact #%1").arg( count ) ); 2438 message(i18n("Changing contact #%1").arg( count ) );
2438 qApp->processEvents(); 2439 qApp->processEvents();
2439 QString fName; 2440 QString fName;
2440 if ( setpref.simple->isChecked() ) 2441 if ( setpref.simple->isChecked() )
2441 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2442 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2442 else if ( setpref.full->isChecked() ) 2443 else if ( setpref.full->isChecked() )
2443 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2444 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2444 else if ( setpref.reverse->isChecked() ) 2445 else if ( setpref.reverse->isChecked() )
2445 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2446 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2446 else 2447 else
2447 fName = (*it).organization(); 2448 fName = (*it).organization();
2448 if ( setpref.setCompany->isChecked() ) 2449 if ( setpref.setCompany->isChecked() )
2449 if ( fName.isEmpty() || fName =="," ) 2450 if ( fName.isEmpty() || fName =="," )
2450 fName = (*it).organization(); 2451 fName = (*it).organization();
2451 (*it).setFormattedName( fName ); 2452 (*it).setFormattedName( fName );
2452 } 2453 }
2453 } 2454 }
2454 message(i18n("Refreshing view...") ); 2455 message(i18n("Refreshing view...") );
2455 qApp->processEvents(); 2456 qApp->processEvents();
2456 mViewManager->refreshView( "" ); 2457 mViewManager->refreshView( "" );
2457 Addressee add; 2458 Addressee add;
2458 mDetails->setAddressee( add ); 2459 mDetails->setAddressee( add );
2459 message(i18n("Setting formatted name completed!") ); 2460 message(i18n("Setting formatted name completed!") );
2460} 2461}
2461 2462
2462void KABCore::clipboardDataChanged() 2463void KABCore::clipboardDataChanged()
2463{ 2464{
2464 2465
2465 if ( mReadWrite ) 2466 if ( mReadWrite )
2466 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2467 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2467 2468
2468} 2469}
2469 2470
2470void KABCore::updateActionMenu() 2471void KABCore::updateActionMenu()
2471{ 2472{
2472 UndoStack *undo = UndoStack::instance(); 2473 UndoStack *undo = UndoStack::instance();
2473 RedoStack *redo = RedoStack::instance(); 2474 RedoStack *redo = RedoStack::instance();
2474 2475
2475 if ( undo->isEmpty() ) 2476 if ( undo->isEmpty() )
2476 mActionUndo->setText( i18n( "Undo" ) ); 2477 mActionUndo->setText( i18n( "Undo" ) );
2477 else 2478 else
2478 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2479 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2479 2480
2480 mActionUndo->setEnabled( !undo->isEmpty() ); 2481 mActionUndo->setEnabled( !undo->isEmpty() );
2481 2482
2482 if ( !redo->top() ) 2483 if ( !redo->top() )
2483 mActionRedo->setText( i18n( "Redo" ) ); 2484 mActionRedo->setText( i18n( "Redo" ) );
2484 else 2485 else
2485 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2486 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2486 2487
2487 mActionRedo->setEnabled( !redo->isEmpty() ); 2488 mActionRedo->setEnabled( !redo->isEmpty() );
2488} 2489}
2489 2490
2490void KABCore::configureKeyBindings() 2491void KABCore::configureKeyBindings()
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 86f0f3d..0614d06 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -515,223 +515,223 @@ void ViewManager::dropped( QDropEvent *e )
515 KABC::VCardConverter converter; 515 KABC::VCardConverter converter;
516 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 516 QStringList list = QStringList::split( "\r\n\r\n", vcards );
517 QStringList::Iterator it; 517 QStringList::Iterator it;
518 for ( it = list.begin(); it != list.end(); ++it ) { 518 for ( it = list.begin(); it != list.end(); ++it ) {
519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
521 if ( a.isEmpty() ) { 521 if ( a.isEmpty() ) {
522 mCore->addressBook()->insertAddressee( addr ); 522 mCore->addressBook()->insertAddressee( addr );
523 emit modified(); 523 emit modified();
524 } 524 }
525 } 525 }
526 } 526 }
527 527
528 mActiveView->refresh(); 528 mActiveView->refresh();
529 } 529 }
530#else //KAB_EMBEDDED 530#else //KAB_EMBEDDED
531qDebug("ViewManager::dropped() has to be changed!!" ); 531qDebug("ViewManager::dropped() has to be changed!!" );
532#endif //KAB_EMBEDDED 532#endif //KAB_EMBEDDED
533 533
534} 534}
535 535
536void ViewManager::startDrag() 536void ViewManager::startDrag()
537{ 537{
538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
539 539
540#ifndef KAB_EMBEDDED 540#ifndef KAB_EMBEDDED
541 541
542 // Get the list of all the selected addressees 542 // Get the list of all the selected addressees
543 KABC::Addressee::List addrList; 543 KABC::Addressee::List addrList;
544 QStringList uidList = selectedUids(); 544 QStringList uidList = selectedUids();
545 QStringList::Iterator iter; 545 QStringList::Iterator iter;
546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
547 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 547 addrList.append( mCore->addressBook()->findByUid( *iter ) );
548 548
549 KMultipleDrag *drag = new KMultipleDrag( this ); 549 KMultipleDrag *drag = new KMultipleDrag( this );
550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
551 KABC::Addressee::List::Iterator it; 551 KABC::Addressee::List::Iterator it;
552 QStringList vcards; 552 QStringList vcards;
553 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 553 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
554 QString vcard = QString::null; 554 QString vcard = QString::null;
555 KABC::VCardConverter converter; 555 KABC::VCardConverter converter;
556 if ( converter.addresseeToVCard( *it, vcard ) ) 556 if ( converter.addresseeToVCard( *it, vcard ) )
557 vcards.append( vcard ); 557 vcards.append( vcard );
558 } 558 }
559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
560 560
561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
562 drag->dragCopy(); 562 drag->dragCopy();
563 563
564#else //KAB_EMBEDDED 564#else //KAB_EMBEDDED
565qDebug("ViewManager::startDrag() has to be changed!!" ); 565qDebug("ViewManager::startDrag() has to be changed!!" );
566#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
567 567
568} 568}
569void ViewManager::doSearch( const QString& s,KABC::Field *field ) 569void ViewManager::doSearch( const QString& s,KABC::Field *field )
570{ 570{
571 if ( mActiveView ) 571 if ( mActiveView )
572 mActiveView->doSearch( s, field ); 572 mActiveView->doSearch( s, field );
573 573
574} 574}
575void ViewManager::setActiveFilter( int index ) 575void ViewManager::setActiveFilter( int index )
576{ 576{
577 Filter currentFilter; 577 Filter currentFilter;
578 578
579 if ( ( index - 1 ) < 0 ) 579 if ( ( index - 1 ) < 0 )
580 currentFilter = Filter(); 580 currentFilter = Filter();
581 else 581 else
582 currentFilter = mFilterList[ index - 1 ]; 582 currentFilter = mFilterList[ index - 1 ];
583 583
584 // Check if we have a view. Since the filter combo is created before 584 // Check if we have a view. Since the filter combo is created before
585 // the view, this slot could be called before there is a valid view. 585 // the view, this slot could be called before there is a valid view.
586 if ( mActiveView ) { 586 if ( mActiveView ) {
587 mActiveView->setFilter( currentFilter ); 587 mActiveView->setFilter( currentFilter );
588 mActiveView->refresh(); 588 mActiveView->refresh();
589 emit selected( QString::null ); 589 emit selected( QString::null );
590 } 590 }
591} 591}
592 592
593void ViewManager::configureFilters() 593void ViewManager::configureFilters()
594{ 594{
595 FilterDialog dlg( this ); 595 FilterDialog dlg( this );
596 596
597 dlg.setFilters( mFilterList ); 597 dlg.setFilters( mFilterList );
598 598
599 if ( dlg.exec() ) 599 if ( dlg.exec() )
600 mFilterList = dlg.filters(); 600 mFilterList = dlg.filters();
601 601
602 uint pos = mActionSelectFilter->currentItem(); 602 uint pos = mActionSelectFilter->currentItem();
603 mActionSelectFilter->setItems( filterNames() ); 603 mActionSelectFilter->setItems( filterNames() );
604 mActionSelectFilter->setCurrentItem( pos ); 604 mActionSelectFilter->setCurrentItem( pos );
605 setActiveFilter( pos ); 605 setActiveFilter( pos );
606 int cw = 150; 606 int cw = 150;
607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
608 cw = 0; 608 cw = 0;
609 mActionSelectFilter->setComboWidth( cw ); 609 mActionSelectFilter->setComboWidth( cw );
610 saveSettings(); 610 saveSettings();
611} 611}
612 612
613QStringList ViewManager::filterNames() const 613QStringList ViewManager::filterNames() const
614{ 614{
615 QStringList names( i18n( "No Filter" ) ); 615 QStringList names( i18n( "No Filter" ) );
616 616
617 Filter::List::ConstIterator it; 617 Filter::List::ConstIterator it;
618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
619 names.append( (*it).name() ); 619 names.append( (*it).name() );
620 620
621 return names; 621 return names;
622} 622}
623Filter ViewManager::getFilterByName( const QString &name ) const 623Filter ViewManager::getFilterByName( const QString &name ) const
624{ 624{
625 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
627 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
628 return (*it); 628 return (*it);
629 629
630 return Filter(); 630 return Filter();
631} 631}
632 632
633int ViewManager::filterPosition( const QString &name ) const 633int ViewManager::filterPosition( const QString &name ) const
634{ 634{
635 int pos = 0; 635 int pos = 0;
636 636
637 Filter::List::ConstIterator it; 637 Filter::List::ConstIterator it;
638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
639 if ( name == (*it).name() ) 639 if ( name == (*it).name() )
640 return pos + 1; 640 return pos + 1;
641 641
642 return 0; 642 return 0;
643} 643}
644 644
645void ViewManager::initActions() 645void ViewManager::initActions()
646{ 646{
647//US <ActionList name="view_loadedviews"/> 647//US <ActionList name="view_loadedviews"/>
648//US <Separator/> 648//US <Separator/>
649 649
650#ifdef KAB_EMBEDDED 650#ifdef KAB_EMBEDDED
651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
654#endif //KAB_EMBEDDED 654#endif //KAB_EMBEDDED
655 655
656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
657#if KDE_VERSION >= 309 657#if KDE_VERSION >= 309
658 mActionSelectView->setMenuAccelsEnabled( false ); 658 mActionSelectView->setMenuAccelsEnabled( false );
659#endif 659#endif
660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
661 SLOT( selectView( const QString& ) ) ); 661 SLOT( selectView( const QString& ) ) );
662 662
663 663
664#ifdef KAB_EMBEDDED 664#ifdef KAB_EMBEDDED
665 mActionSelectView->plug(viewmenu); 665 mActionSelectView->plug(viewmenu);
666 viewmenu->insertSeparator(); 666 viewmenu->insertSeparator();
667#endif //KAB_EMBEDDED 667#endif //KAB_EMBEDDED
668 668
669 KAction *action; 669 KAction *action;
670 670
671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
672 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 672 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
673#ifndef KAB_EMBEDDED 673#ifndef KAB_EMBEDDED
674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
675#else //KAB_EMBEDDED 675#else //KAB_EMBEDDED
676 action->plug(viewmenu); 676 action->plug(viewmenu);
677#endif //KAB_EMBEDDED 677#endif //KAB_EMBEDDED
678 678
679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
680 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 680 SLOT( addView() ), mCore->actionCollection(), "view_add" );
681#ifndef KAB_EMBEDDED 681#ifndef KAB_EMBEDDED
682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
683#else //KAB_EMBEDDED 683#else //KAB_EMBEDDED
684 action->plug(viewmenu); 684 action->plug(viewmenu);
685#endif //KAB_EMBEDDED 685#endif //KAB_EMBEDDED
686 686
687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
688 this, SLOT( deleteView() ), 688 this, SLOT( deleteView() ),
689 mCore->actionCollection(), "view_delete" ); 689 mCore->actionCollection(), "view_delete" );
690#ifndef KAB_EMBEDDED 690#ifndef KAB_EMBEDDED
691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
692#else //KAB_EMBEDDED 692#else //KAB_EMBEDDED
693 mActionDeleteView->plug(viewmenu); 693 mActionDeleteView->plug(viewmenu);
694 viewmenu->insertSeparator(); 694 viewmenu->insertSeparator();
695#endif //KAB_EMBEDDED 695#endif //KAB_EMBEDDED
696 696
697#ifndef KAB_EMBEDDED 697#ifndef KAB_EMBEDDED
698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
699 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 699 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
700 "view_refresh" ); 700 "view_refresh" );
701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
702#else //KAB_EMBEDDED 702#else //KAB_EMBEDDED
703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 703 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
704 SLOT( refreshView()), mCore->actionCollection(), 704 SLOT( refreshView()), mCore->actionCollection(),
705 "view_refresh" ); 705 "view_refresh" );
706 action->plug(viewmenu); 706 action->plug(viewmenu);
707 viewmenu->insertSeparator(); 707 //viewmenu->insertSeparator();
708#endif //KAB_EMBEDDED 708#endif //KAB_EMBEDDED
709 709
710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 710 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
711 SLOT( configureFilters() ), mCore->actionCollection(), 711 SLOT( configureFilters() ), mCore->actionCollection(),
712 "options_edit_filters" ); 712 "options_edit_filters" );
713 713
714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 714 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
715#if KDE_VERSION >= 309 715#if KDE_VERSION >= 309
716 mActionSelectFilter->setMenuAccelsEnabled( false ); 716 mActionSelectFilter->setMenuAccelsEnabled( false );
717#endif 717#endif
718 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 718 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
719 SLOT( setActiveFilter( int ) ) ); 719 SLOT( setActiveFilter( int ) ) );
720 720
721#ifdef KAB_EMBEDDED 721#ifdef KAB_EMBEDDED
722 action->plug(settingsmenu); 722 action->plug(settingsmenu);
723 mActionSelectFilter->plug(viewmenu,0); 723 mActionSelectFilter->plug(viewmenu,0);
724#endif //KAB_EMBEDDED 724#endif //KAB_EMBEDDED
725 725
726} 726}
727 727
728void ViewManager::initGUI() 728void ViewManager::initGUI()
729{ 729{
730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 730 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
731 mViewWidgetStack = new QWidgetStack( this ); 731 mViewWidgetStack = new QWidgetStack( this );
732 layout->addWidget( mViewWidgetStack ); 732 layout->addWidget( mViewWidgetStack );
733} 733}
734 734
735#ifndef KAB_EMBEDDED 735#ifndef KAB_EMBEDDED
736#include "viewmanager.moc" 736#include "viewmanager.moc"
737#endif //KAB_EMBEDDED 737#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp
index c243fa0..7386207 100644
--- a/kaddressbook/views/colorlistbox.cpp
+++ b/kaddressbook/views/colorlistbox.cpp
@@ -1,230 +1,235 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#include <qpainter.h> 21#include <qpainter.h>
22 22
23#include <kcolordialog.h> 23#include <kcolordialog.h>
24 24
25#ifndef KAB_EMBEDDED 25#ifndef KAB_EMBEDDED
26#include <kcolordrag.h> 26#include <kcolordrag.h>
27#endif //KAB_EMBEDDED 27#endif //KAB_EMBEDDED
28 28
29#include "colorlistbox.h" 29#include "colorlistbox.h"
30 30
31ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) 31ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f )
32 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) 32 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
33{ 33{
34 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); 34 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
35 connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) );
35 setAcceptDrops( true); 36 setAcceptDrops( true);
36} 37}
37 38
38 39
39void ColorListBox::setEnabled( bool state ) 40void ColorListBox::setEnabled( bool state )
40{ 41{
41 if( state == isEnabled() ) 42 if( state == isEnabled() )
42 { 43 {
43 return; 44 return;
44 } 45 }
45 46
46 QListBox::setEnabled( state ); 47 QListBox::setEnabled( state );
47 for( uint i=0; i<count(); i++ ) 48 for( uint i=0; i<count(); i++ )
48 { 49 {
49 updateItem( i ); 50 updateItem( i );
50 } 51 }
51} 52}
52 53
53 54
54void ColorListBox::setColor( uint index, const QColor &color ) 55void ColorListBox::setColor( uint index, const QColor &color )
55{ 56{
56 if( index < count() ) 57 if( index < count() )
57 { 58 {
58 ColorListItem *colorItem = (ColorListItem*)item(index); 59 ColorListItem *colorItem = (ColorListItem*)item(index);
59 colorItem->setColor(color); 60 colorItem->setColor(color);
60 updateItem( colorItem ); 61 updateItem( colorItem );
61 } 62 }
62} 63}
63 64
64 65
65QColor ColorListBox::color( uint index ) const 66QColor ColorListBox::color( uint index ) const
66{ 67{
67 if( index < count() ) 68 if( index < count() )
68 { 69 {
69 ColorListItem *colorItem = (ColorListItem*)item(index); 70 ColorListItem *colorItem = (ColorListItem*)item(index);
70 return( colorItem->color() ); 71 return( colorItem->color() );
71 } 72 }
72 else 73 else
73 { 74 {
74 return( black ); 75 return( black );
75 } 76 }
76} 77}
77 78void ColorListBox::slotNewColor(QListBoxItem * i)
79{
80 if ( i )
81 newColor( index( i ) );
82}
78 83
79void ColorListBox::newColor( int index ) 84void ColorListBox::newColor( int index )
80{ 85{
81 if( isEnabled() == false ) 86 if( isEnabled() == false )
82 { 87 {
83 return; 88 return;
84 } 89 }
85 90
86 if( (uint)index < count() ) 91 if( (uint)index < count() )
87 { 92 {
88 QColor c = color( index ); 93 QColor c = color( index );
89#ifndef KAB_EMBEDDED 94#ifndef KAB_EMBEDDED
90 if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) 95 if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
91 { 96 {
92 setColor( index, c ); 97 setColor( index, c );
93 } 98 }
94#else //KAB_EMBEDDED 99#else //KAB_EMBEDDED
95 KColorDialog* k = new KColorDialog( this ); 100 KColorDialog* k = new KColorDialog( this );
96 k->setColor( c ); 101 k->setColor( c );
97 int res = k->exec(); 102 int res = k->exec();
98 if ( res ) { 103 if ( res ) {
99 setColor( index, k->getColor() ); 104 setColor( index, k->getColor() );
100 } 105 }
101 delete k; 106 delete k;
102#endif //KAB_EMBEDDED 107#endif //KAB_EMBEDDED
103 108
104 } 109 }
105} 110}
106 111
107 112
108void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) 113void ColorListBox::dragEnterEvent( QDragEnterEvent *e )
109{ 114{
110#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
111 if( KColorDrag::canDecode(e) && isEnabled() ) 116 if( KColorDrag::canDecode(e) && isEnabled() )
112 { 117 {
113 mCurrentOnDragEnter = currentItem(); 118 mCurrentOnDragEnter = currentItem();
114 e->accept( true ); 119 e->accept( true );
115 } 120 }
116 else 121 else
117 { 122 {
118 mCurrentOnDragEnter = -1; 123 mCurrentOnDragEnter = -1;
119 e->accept( false ); 124 e->accept( false );
120 } 125 }
121#else //KAB_EMBEDDED 126#else //KAB_EMBEDDED
122qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); 127qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported");
123#endif //KAB_EMBEDDED 128#endif //KAB_EMBEDDED
124 129
125} 130}
126 131
127 132
128void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) 133void ColorListBox::dragLeaveEvent( QDragLeaveEvent * )
129{ 134{
130#ifndef KAB_EMBEDDED 135#ifndef KAB_EMBEDDED
131 136
132 if( mCurrentOnDragEnter != -1 ) 137 if( mCurrentOnDragEnter != -1 )
133 { 138 {
134 setCurrentItem( mCurrentOnDragEnter ); 139 setCurrentItem( mCurrentOnDragEnter );
135 mCurrentOnDragEnter = -1; 140 mCurrentOnDragEnter = -1;
136 } 141 }
137#else //KAB_EMBEDDED 142#else //KAB_EMBEDDED
138qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); 143qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported");
139#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
140} 145}
141 146
142 147
143void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) 148void ColorListBox::dragMoveEvent( QDragMoveEvent *e )
144{ 149{
145#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
146 if( KColorDrag::canDecode(e) && isEnabled() ) 151 if( KColorDrag::canDecode(e) && isEnabled() )
147 { 152 {
148 ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); 153 ColorListItem *item = (ColorListItem*)itemAt( e->pos() );
149 if( item != 0 ) 154 if( item != 0 )
150 { 155 {
151 setCurrentItem ( item ); 156 setCurrentItem ( item );
152 } 157 }
153 } 158 }
154#else //KAB_EMBEDDED 159#else //KAB_EMBEDDED
155qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); 160qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported");
156#endif //KAB_EMBEDDED 161#endif //KAB_EMBEDDED
157 162
158} 163}
159 164
160 165
161void ColorListBox::dropEvent( QDropEvent *e ) 166void ColorListBox::dropEvent( QDropEvent *e )
162{ 167{
163#ifndef KAB_EMBEDDED 168#ifndef KAB_EMBEDDED
164 QColor color; 169 QColor color;
165 if( KColorDrag::decode( e, color ) ) 170 if( KColorDrag::decode( e, color ) )
166 { 171 {
167 int index = currentItem(); 172 int index = currentItem();
168 if( index != -1 ) 173 if( index != -1 )
169 { 174 {
170 ColorListItem *colorItem = (ColorListItem*)item(index); 175 ColorListItem *colorItem = (ColorListItem*)item(index);
171 colorItem->setColor(color); 176 colorItem->setColor(color);
172 triggerUpdate( false ); // Redraw item 177 triggerUpdate( false ); // Redraw item
173 } 178 }
174 mCurrentOnDragEnter = -1; 179 mCurrentOnDragEnter = -1;
175 } 180 }
176 181
177#else //KAB_EMBEDDED 182#else //KAB_EMBEDDED
178qDebug("ColorListBox::dropEvent drag&drop currently not supported"); 183qDebug("ColorListBox::dropEvent drag&drop currently not supported");
179#endif //KAB_EMBEDDED 184#endif //KAB_EMBEDDED
180 185
181} 186}
182 187
183 188
184 189
185ColorListItem::ColorListItem( const QString &text, const QColor &color ) 190ColorListItem::ColorListItem( const QString &text, const QColor &color )
186 : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) 191 : QListBoxItem(), mColor( color ), mBoxWidth( 30 )
187{ 192{
188 setText( text ); 193 setText( text );
189} 194}
190 195
191 196
192const QColor &ColorListItem::color( void ) 197const QColor &ColorListItem::color( void )
193{ 198{
194 return( mColor ); 199 return( mColor );
195} 200}
196 201
197 202
198void ColorListItem::setColor( const QColor &color ) 203void ColorListItem::setColor( const QColor &color )
199{ 204{
200 mColor = color; 205 mColor = color;
201} 206}
202 207
203 208
204void ColorListItem::paint( QPainter *p ) 209void ColorListItem::paint( QPainter *p )
205{ 210{
206 QFontMetrics fm = p->fontMetrics(); 211 QFontMetrics fm = p->fontMetrics();
207 int h = fm.height(); 212 int h = fm.height();
208 213
209 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); 214 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() );
210 215
211 p->setPen( Qt::black ); 216 p->setPen( Qt::black );
212 p->drawRect( 3, 1, mBoxWidth, h-1 ); 217 p->drawRect( 3, 1, mBoxWidth, h-1 );
213 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); 218 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor );
214} 219}
215 220
216 221
217int ColorListItem::height(const QListBox *lb ) const 222int ColorListItem::height(const QListBox *lb ) const
218{ 223{
219 return( lb->fontMetrics().lineSpacing()+1 ); 224 return( lb->fontMetrics().lineSpacing()+1 );
220} 225}
221 226
222 227
223int ColorListItem::width(const QListBox *lb ) const 228int ColorListItem::width(const QListBox *lb ) const
224{ 229{
225 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); 230 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 );
226} 231}
227 232
228#ifndef KAB_EMBEDDED 233#ifndef KAB_EMBEDDED
229#include "colorlistbox.moc" 234#include "colorlistbox.moc"
230#endif //KAB_EMBEDDED 235#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h
index 4a0e705..bb91484 100644
--- a/kaddressbook/views/colorlistbox.h
+++ b/kaddressbook/views/colorlistbox.h
@@ -1,76 +1,77 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#ifndef _COLOR_LISTBOX_H_ 21#ifndef _COLOR_LISTBOX_H_
22#define _COLOR_LISTBOX_H_ 22#define _COLOR_LISTBOX_H_
23 23
24#include <klistbox.h> 24#include <klistbox.h>
25 25
26class QDragEnterEvent; 26class QDragEnterEvent;
27class QDragLeaveEvent; 27class QDragLeaveEvent;
28class QDragMoveEvent; 28class QDragMoveEvent;
29class QDropEvent; 29class QDropEvent;
30 30
31class ColorListBox : public KListBox 31class ColorListBox : public KListBox
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35 public: 35 public:
36 ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); 36 ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 );
37 void setColor( uint index, const QColor &color ); 37 void setColor( uint index, const QColor &color );
38 QColor color( uint index ) const; 38 QColor color( uint index ) const;
39 39
40 public slots: 40 public slots:
41 virtual void setEnabled( bool state ); 41 virtual void setEnabled( bool state );
42 42
43 protected: 43 protected:
44 void dragEnterEvent( QDragEnterEvent *e ); 44 void dragEnterEvent( QDragEnterEvent *e );
45 void dragLeaveEvent( QDragLeaveEvent *e ); 45 void dragLeaveEvent( QDragLeaveEvent *e );
46 void dragMoveEvent( QDragMoveEvent *e ); 46 void dragMoveEvent( QDragMoveEvent *e );
47 void dropEvent( QDropEvent *e ); 47 void dropEvent( QDropEvent *e );
48 48
49 private slots: 49 private slots:
50 void newColor( int index ); 50 void newColor( int index );
51 void slotNewColor(QListBoxItem * i);
51 52
52 private: 53 private:
53 int mCurrentOnDragEnter; 54 int mCurrentOnDragEnter;
54 55
55}; 56};
56 57
57 58
58class ColorListItem : public QListBoxItem 59class ColorListItem : public QListBoxItem
59{ 60{
60 public: 61 public:
61 ColorListItem( const QString &text, const QColor &color=Qt::black ); 62 ColorListItem( const QString &text, const QColor &color=Qt::black );
62 const QColor &color( void ); 63 const QColor &color( void );
63 void setColor( const QColor &color ); 64 void setColor( const QColor &color );
64 65
65 protected: 66 protected:
66 virtual void paint( QPainter * ); 67 virtual void paint( QPainter * );
67 virtual int height( const QListBox * ) const; 68 virtual int height( const QListBox * ) const;
68 virtual int width( const QListBox * ) const; 69 virtual int width( const QListBox * ) const;
69 70
70 private: 71 private:
71 QColor mColor; 72 QColor mColor;
72 int mBoxWidth; 73 int mBoxWidth;
73}; 74};
74 75
75#endif 76#endif
76 77
diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp
index 366e54c..e0fbd21 100644
--- a/kaddressbook/views/configurecardviewdialog.cpp
+++ b/kaddressbook/views/configurecardviewdialog.cpp
@@ -26,340 +26,344 @@
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qvbox.h> 28#include <qvbox.h>
29#include <qgroupbox.h> 29#include <qgroupbox.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qwhatsthis.h> 32#include <qwhatsthis.h>
33 33
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kglobalsettings.h> 36#include <kglobalsettings.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kfontdialog.h> 40#include <kfontdialog.h>
41 41
42#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
43#include <kpushbutton.h> 43#include <kpushbutton.h>
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
47 47
48#include "colorlistbox.h" 48#include "colorlistbox.h"
49 49
50#include "configurecardviewdialog.h" 50#include "configurecardviewdialog.h"
51 51
52///////////////////////////////// 52/////////////////////////////////
53// ConfigureCardViewDialog 53// ConfigureCardViewDialog
54 54
55ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, 55ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent,
56 const char *name ) 56 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 57 : ViewConfigureWidget( ab, parent, name )
58{ 58{
59#ifndef KAB_EMBEDDED 59#ifndef KAB_EMBEDDED
60 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 60 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
61 DesktopIcon( "looknfeel" ) ); 61 DesktopIcon( "looknfeel" ) );
62#else //KAB_EMBEDDED 62#else //KAB_EMBEDDED
63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
64 KGlobal::iconLoader()->loadIcon( "looknfeel", 64 KGlobal::iconLoader()->loadIcon( "looknfeel",
65 KIcon::Panel ) ); 65 KIcon::Panel ) );
66#endif //KAB_EMBEDDED 66#endif //KAB_EMBEDDED
67 67
68 mAdvancedPage = new CardViewLookNFeelPage( page ); 68 mAdvancedPage = new CardViewLookNFeelPage( page );
69} 69}
70 70
71ConfigureCardViewWidget::~ConfigureCardViewWidget() 71ConfigureCardViewWidget::~ConfigureCardViewWidget()
72{ 72{
73} 73}
74 74
75void ConfigureCardViewWidget::restoreSettings( KConfig *config ) 75void ConfigureCardViewWidget::restoreSettings( KConfig *config )
76{ 76{
77 ViewConfigureWidget::restoreSettings( config ); 77 ViewConfigureWidget::restoreSettings( config );
78 78
79 mAdvancedPage->restoreSettings( config ); 79 mAdvancedPage->restoreSettings( config );
80} 80}
81 81
82void ConfigureCardViewWidget::saveSettings( KConfig *config ) 82void ConfigureCardViewWidget::saveSettings( KConfig *config )
83{ 83{
84 ViewConfigureWidget::saveSettings( config ); 84 ViewConfigureWidget::saveSettings( config );
85 85
86 mAdvancedPage->saveSettings( config ); 86 mAdvancedPage->saveSettings( config );
87} 87}
88 88
89//////////////////////// 89////////////////////////
90// CardViewLookNFeelPage 90// CardViewLookNFeelPage
91CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) 91CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name )
92 : QVBox( parent, name ) 92 : QVBox( parent, name )
93{ 93{
94 initGUI(); 94 initGUI();
95} 95}
96 96
97CardViewLookNFeelPage::~CardViewLookNFeelPage() 97CardViewLookNFeelPage::~CardViewLookNFeelPage()
98{ 98{
99} 99}
100 100
101void CardViewLookNFeelPage::restoreSettings( KConfig *config ) 101void CardViewLookNFeelPage::restoreSettings( KConfig *config )
102{ 102{
103 // colors 103 // colors
104 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 104 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
105 QColor c; 105 QColor c;
106qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); 106qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable");
107 107
108#ifndef KAB_EMBEDDED 108#ifndef KAB_EMBEDDED
109 c = KGlobalSettings::baseColor(); 109 c = KGlobalSettings::baseColor();
110#else //KAB_EMBEDDED 110#else //KAB_EMBEDDED
111 c = QColor(0,0,0); 111 c = QColor(0,0,0);
112#endif //KAB_EMBEDDED 112#endif //KAB_EMBEDDED
113 113
114 c = colorGroup().background(); 114 c = colorGroup().background();
115 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 115 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
116 config->readColorEntry( "BackgroundColor", &c ) ) ); 116 config->readColorEntry( "BackgroundColor", &c ) ) );
117 c = colorGroup().foreground(); 117 c = colorGroup().foreground();
118 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 118 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
119 config->readColorEntry( "TextColor", &c ) ) ); 119 config->readColorEntry( "TextColor", &c ) ) );
120 c = colorGroup().button(); 120 c = colorGroup().button();
121 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), 121 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"),
122 config->readColorEntry( "HeaderColor", &c ) ) ); 122 config->readColorEntry( "HeaderColor", &c ) ) );
123 c = colorGroup().buttonText(); 123 c = colorGroup().buttonText();
124 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 124 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
125 config->readColorEntry( "HeaderTextColor", &c ) ) ); 125 config->readColorEntry( "HeaderTextColor", &c ) ) );
126 c = colorGroup().highlight(); 126 c = colorGroup().highlight();
127 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 127 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
128 config->readColorEntry( "HighlightColor", &c ) ) ); 128 config->readColorEntry( "HighlightColor", &c ) ) );
129 c = colorGroup().highlightedText(); 129 c = colorGroup().highlightedText();
130 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 130 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
131 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 131 config->readColorEntry( "HighlightedTextColor", &c ) ) );
132 132
133 enableColors(); 133 enableColors();
134 134
135 // fonts 135 // fonts
136 QFont fnt = font(); 136 QFont fnt = font();
137 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 137 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
138 fnt.setBold( true ); 138 fnt.setBold( true );
139 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 139 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
140 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 140 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
141 enableFonts(); 141 enableFonts();
142 142
143 // layout 143 // layout
144 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); 144 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) );
145 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); 145 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) );
146 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); 146 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) );
147 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); 147 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) );
148 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); 148 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) );
149 149
150 // behaviour 150 // behaviour
151 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); 151 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) );
152 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); 152 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) );
153} 153}
154 154
155void CardViewLookNFeelPage::saveSettings( KConfig *config ) 155void CardViewLookNFeelPage::saveSettings( KConfig *config )
156{ 156{
157 // colors 157 // colors
158 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 158 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
159 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 159 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
160 { 160 {
161 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 161 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
162 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 162 config->writeEntry( "TextColor", lbColors->color( 1 ) );
163 config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); 163 config->writeEntry( "HeaderColor", lbColors->color( 2 ) );
164 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 164 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
165 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 165 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
166 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 166 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
167 } 167 }
168 // fonts 168 // fonts
169 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 169 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
170 if ( cbEnableCustomFonts->isChecked() ) 170 if ( cbEnableCustomFonts->isChecked() )
171 { 171 {
172 config->writeEntry( "TextFont", lTextFont->font() ); 172 config->writeEntry( "TextFont", lTextFont->font() );
173 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 173 config->writeEntry( "HeaderFont", lHeaderFont->font() );
174 } 174 }
175 // layout 175 // layout
176 config->writeEntry( "ItemMargin", sbMargin->value() ); 176 config->writeEntry( "ItemMargin", sbMargin->value() );
177 config->writeEntry( "ItemSpacing", sbSpacing->value() ); 177 config->writeEntry( "ItemSpacing", sbSpacing->value() );
178 config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); 178 config->writeEntry( "SeparatorWidth", sbSepWidth->value() );
179 config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); 179 config->writeEntry("DrawBorder", cbDrawBorders->isChecked());
180 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); 180 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked());
181 181
182 // behaviour 182 // behaviour
183 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); 183 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked());
184 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); 184 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked());
185} 185}
186 186
187void CardViewLookNFeelPage::setTextFont() 187void CardViewLookNFeelPage::setTextFont()
188{ 188{
189 QFont f( lTextFont->font() ); 189 QFont f( lTextFont->font() );
190#ifndef KAB_EMBEDDED 190#ifndef KAB_EMBEDDED
191 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 191 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
192 updateFontLabel( f, lTextFont ); 192 updateFontLabel( f, lTextFont );
193#else //KAB_EMBEDDED 193#else //KAB_EMBEDDED
194 bool ok; 194 bool ok;
195 QFont fout = KFontDialog::getFont( f, ok); 195 QFont fout = KFontDialog::getFont( f, ok);
196 if ( ok ) 196 if ( ok )
197 updateFontLabel( fout, lTextFont ); 197 updateFontLabel( fout, lTextFont );
198#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
199} 199}
200 200
201void CardViewLookNFeelPage::setHeaderFont() 201void CardViewLookNFeelPage::setHeaderFont()
202{ 202{
203 QFont f( lHeaderFont->font() ); 203 QFont f( lHeaderFont->font() );
204#ifndef KAB_EMBEDDED 204#ifndef KAB_EMBEDDED
205 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 205 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
206 updateFontLabel( f, lHeaderFont ); 206 updateFontLabel( f, lHeaderFont );
207#else //KAB_EMBEDDED 207#else //KAB_EMBEDDED
208 bool ok; 208 bool ok;
209 QFont fout = KFontDialog::getFont( f, ok); 209 QFont fout = KFontDialog::getFont( f, ok);
210 if ( ok ) 210 if ( ok )
211 updateFontLabel( fout, lHeaderFont ); 211 updateFontLabel( fout, lHeaderFont );
212#endif //KAB_EMBEDDED 212#endif //KAB_EMBEDDED
213} 213}
214 214
215void CardViewLookNFeelPage::enableFonts() 215void CardViewLookNFeelPage::enableFonts()
216{ 216{
217 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 217 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
218 if ( cbEnableCustomFonts->isChecked() )
219 vbFonts->setFocus();
218} 220}
219 221
220void CardViewLookNFeelPage::enableColors() 222void CardViewLookNFeelPage::enableColors()
221{ 223{
222 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 224 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
225 if ( cbEnableCustomColors->isChecked() )
226 lbColors->setFocus();
223} 227}
224 228
225void CardViewLookNFeelPage::initGUI() 229void CardViewLookNFeelPage::initGUI()
226{ 230{
227 int spacing = KDialog::spacingHint(); 231 int spacing = KDialog::spacingHint();
228 int margin = KDialog::marginHint(); 232 int margin = KDialog::marginHint();
229 233
230 QTabWidget *tabs = new QTabWidget( this ); 234 QTabWidget *tabs = new QTabWidget( this );
231 235
232 // Layout 236 // Layout
233 QVBox *loTab = new QVBox( this, "layouttab" ); 237 QVBox *loTab = new QVBox( this, "layouttab" );
234 238
235 loTab->setSpacing( spacing ); 239 loTab->setSpacing( spacing );
236 loTab->setMargin( margin ); 240 loTab->setMargin( margin );
237 241
238 QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); 242 QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab );
239 243
240 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); 244 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral );
241 245
242 QHBox *hbSW = new QHBox( gbGeneral ); 246 QHBox *hbSW = new QHBox( gbGeneral );
243 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); 247 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW );
244 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); 248 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW );
245 lSW->setBuddy( sbSepWidth); 249 lSW->setBuddy( sbSepWidth);
246 250
247 QHBox *hbPadding = new QHBox( gbGeneral ); 251 QHBox *hbPadding = new QHBox( gbGeneral );
248 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); 252 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding );
249 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); 253 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding );
250 lSpacing->setBuddy( sbSpacing ); 254 lSpacing->setBuddy( sbSpacing );
251 255
252 QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); 256 QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab );
253 257
254 QHBox *hbMargin = new QHBox( gbCards ); 258 QHBox *hbMargin = new QHBox( gbCards );
255 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); 259 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin );
256 sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); 260 sbMargin = new QSpinBox( 0, 100, 1, hbMargin );
257 lMargin->setBuddy( sbMargin ); 261 lMargin->setBuddy( sbMargin );
258 262
259 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); 263 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards );
260 264
261 loTab->setStretchFactor( new QWidget( loTab ), 1 ); 265 loTab->setStretchFactor( new QWidget( loTab ), 1 );
262 266
263 QWhatsThis::add( sbMargin, i18n( 267 QWhatsThis::add( sbMargin, i18n(
264 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " 268 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, "
265 "incrementing the item margin will add space between the focus rectangle and the item data." 269 "incrementing the item margin will add space between the focus rectangle and the item data."
266 ) ); 270 ) );
267 QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); 271 QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) );
268 QWhatsThis::add( sbSpacing, i18n( 272 QWhatsThis::add( sbSpacing, i18n(
269 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " 273 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view "
270 "borders, other items or column separators." 274 "borders, other items or column separators."
271 ) ); 275 ) );
272 QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); 276 QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) );
273 QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); 277 QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") );
274 QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); 278 QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) );
275 279
276 tabs->addTab( loTab, i18n("&Layout") ); 280 tabs->addTab( loTab, i18n("&Layout") );
277 281
278 // Colors 282 // Colors
279 QVBox *colorTab = new QVBox( this, "colortab" ); 283 QVBox *colorTab = new QVBox( this, "colortab" );
280 colorTab->setSpacing( spacing ); 284 colorTab->setSpacing( spacing );
281 colorTab->setMargin( spacing ); 285 colorTab->setMargin( spacing );
282 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 286 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
283 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 287 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
284 lbColors = new ColorListBox( colorTab ); 288 lbColors = new ColorListBox( colorTab );
285 tabs->addTab( colorTab, i18n("&Colors") ); 289 tabs->addTab( colorTab, i18n("&Colors") );
286 290
287 QWhatsThis::add( cbEnableCustomColors, i18n( 291 QWhatsThis::add( cbEnableCustomColors, i18n(
288 "If custom colors are enabled, you may choose the colors for the view below. " 292 "If custom colors are enabled, you may choose the colors for the view below. "
289 "Otherwise colors from your current KDE color scheme are used." 293 "Otherwise colors from your current KDE color scheme are used."
290 ) ); 294 ) );
291 QWhatsThis::add( lbColors, i18n( 295 QWhatsThis::add( lbColors, i18n(
292 "Double click or press RETURN on a item to select a color for the related strings in the view." 296 "Double click or press RETURN on a item to select a color for the related strings in the view."
293 ) ); 297 ) );
294 298
295 // Fonts 299 // Fonts
296 QVBox *fntTab = new QVBox( this, "fonttab" ); 300 QVBox *fntTab = new QVBox( this, "fonttab" );
297 301
298 fntTab->setSpacing( spacing ); 302 fntTab->setSpacing( spacing );
299 fntTab->setMargin( spacing ); 303 fntTab->setMargin( spacing );
300 304
301 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 305 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
302 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 306 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
303 307
304 vbFonts = new QWidget( fntTab ); 308 vbFonts = new QWidget( fntTab );
305 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 309 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 );
306 gFnts->setSpacing( spacing ); 310 gFnts->setSpacing( spacing );
307 gFnts->setAutoAdd( true ); 311 gFnts->setAutoAdd( true );
308 gFnts->setColStretch( 1, 1 ); 312 gFnts->setColStretch( 1, 1 );
309 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 313 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
310 lTextFont = new QLabel( vbFonts ); 314 lTextFont = new QLabel( vbFonts );
311 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 315 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
312#ifndef KAB_EMBEDDED 316#ifndef KAB_EMBEDDED
313 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 317 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
314#else //KAB_EMBEDDED 318#else //KAB_EMBEDDED
315 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 319 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
316#endif //KAB_EMBEDDED 320#endif //KAB_EMBEDDED
317 321
318 lTFnt->setBuddy( btnFont ); 322 lTFnt->setBuddy( btnFont );
319 323
320 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 324 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
321 325
322 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 326 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
323 lHeaderFont = new QLabel( vbFonts ); 327 lHeaderFont = new QLabel( vbFonts );
324 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 328 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
325#ifndef KAB_EMBEDDED 329#ifndef KAB_EMBEDDED
326 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 330 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
327#else //KAB_EMBEDDED 331#else //KAB_EMBEDDED
328 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 332 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
329#endif //KAB_EMBEDDED 333#endif //KAB_EMBEDDED
330 lHFnt->setBuddy( btnHeaderFont ); 334 lHFnt->setBuddy( btnHeaderFont );
331 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 335 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
332 336
333 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 337 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
334 338
335 QWhatsThis::add( cbEnableCustomFonts, i18n( 339 QWhatsThis::add( cbEnableCustomFonts, i18n(
336 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 340 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
337 "Otherwise the default KDE font will be used, in bold style for the header and " 341 "Otherwise the default KDE font will be used, in bold style for the header and "
338 "normal style for the data." 342 "normal style for the data."
339 ) ); 343 ) );
340 344
341 tabs->addTab( fntTab, i18n("&Fonts") ); 345 tabs->addTab( fntTab, i18n("&Fonts") );
342 346
343 // Behaviour 347 // Behaviour
344 QVBox *behaviourTab = new QVBox( this ); 348 QVBox *behaviourTab = new QVBox( this );
345 behaviourTab->setMargin( margin ); 349 behaviourTab->setMargin( margin );
346 behaviourTab->setSpacing( spacing ); 350 behaviourTab->setSpacing( spacing );
347 351
348 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); 352 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab );
349 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); 353 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab );
350 354
351 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); 355 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 );
352 356
353 tabs->addTab( behaviourTab, i18n("Be&havior") ); 357 tabs->addTab( behaviourTab, i18n("Be&havior") );
354 358
355} 359}
356 360
357void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 361void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l )
358{ 362{
359 l->setFont( fnt ); 363 l->setFont( fnt );
360 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 364 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
361} 365}
362 366
363#ifndef KAB_EMBEDDED 367#ifndef KAB_EMBEDDED
364#include "configurecardviewdialog.moc" 368#include "configurecardviewdialog.moc"
365#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp
index 8bcceb2..0e36abd 100644
--- a/kaddressbook/views/configuretableviewdialog.cpp
+++ b/kaddressbook/views/configuretableviewdialog.cpp
@@ -21,321 +21,325 @@
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcheckbox.h> 29#include <qcheckbox.h>
30#include <qvbox.h> 30#include <qvbox.h>
31#include <qbuttongroup.h> 31#include <qbuttongroup.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qwhatsthis.h> 33#include <qwhatsthis.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35 35
36#include <kglobal.h> 36#include <kglobal.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <klineedit.h> 38#include <klineedit.h>
39#include <kurlrequester.h> 39#include <kurlrequester.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kfontdialog.h> 41#include <kfontdialog.h>
42 42
43#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
44#include <kimageio.h> 44#include <kimageio.h>
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#endif //KAB_EMBEDDED 46#endif //KAB_EMBEDDED
47 47
48#include <kconfig.h> 48#include <kconfig.h>
49 49
50#include "colorlistbox.h" 50#include "colorlistbox.h"
51 51
52#include "configuretableviewdialog.h" 52#include "configuretableviewdialog.h"
53 53
54ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, 54ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
55 QWidget *parent, 55 QWidget *parent,
56 const char *name ) 56 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 57 : ViewConfigureWidget( ab, parent, name )
58{ 58{
59 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 59 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
60 KGlobal::iconLoader()->loadIcon( "looknfeel", 60 KGlobal::iconLoader()->loadIcon( "looknfeel",
61 KIcon::Panel ) ); 61 KIcon::Panel ) );
62 62
63 mPage = new LookAndFeelPage( page ); 63 mPage = new LookAndFeelPage( page );
64} 64}
65 65
66ConfigureTableViewWidget::~ConfigureTableViewWidget() 66ConfigureTableViewWidget::~ConfigureTableViewWidget()
67{ 67{
68} 68}
69 69
70void ConfigureTableViewWidget::restoreSettings( KConfig *config ) 70void ConfigureTableViewWidget::restoreSettings( KConfig *config )
71{ 71{
72 ViewConfigureWidget::restoreSettings( config ); 72 ViewConfigureWidget::restoreSettings( config );
73 73
74 mPage->restoreSettings( config ); 74 mPage->restoreSettings( config );
75} 75}
76 76
77void ConfigureTableViewWidget::saveSettings( KConfig *config ) 77void ConfigureTableViewWidget::saveSettings( KConfig *config )
78{ 78{
79 ViewConfigureWidget::saveSettings( config ); 79 ViewConfigureWidget::saveSettings( config );
80 80
81 mPage->saveSettings( config ); 81 mPage->saveSettings( config );
82} 82}
83 83
84 84
85 85
86LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) 86LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
87 : QVBox(parent, name) 87 : QVBox(parent, name)
88{ 88{
89 initGUI(); 89 initGUI();
90 90
91 // Set initial state 91 // Set initial state
92 enableBackgroundToggled(mBackgroundBox->isChecked()); 92 enableBackgroundToggled(mBackgroundBox->isChecked());
93} 93}
94 94
95void LookAndFeelPage::restoreSettings( KConfig *config ) 95void LookAndFeelPage::restoreSettings( KConfig *config )
96{ 96{
97 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); 97 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
98 mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); 98 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
99 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); 99 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
100 100
101 if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) 101 if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
102 mNoneButton->setChecked(true); 102 mNoneButton->setChecked(true);
103 103
104 mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); 104 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
105 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); 105 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName"));
106 106
107 // colors 107 // colors
108 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 108 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
109 QColor c; 109 QColor c;
110qDebug("LookAndFeelPage::restoreSettings make base color configurable"); 110qDebug("LookAndFeelPage::restoreSettings make base color configurable");
111 111
112#ifndef KAB_EMBEDDED 112#ifndef KAB_EMBEDDED
113 c = KGlobalSettings::baseColor(); 113 c = KGlobalSettings::baseColor();
114#else //KAB_EMBEDDED 114#else //KAB_EMBEDDED
115 c = QColor(0,0,0); 115 c = QColor(0,0,0);
116#endif //KAB_EMBEDDED 116#endif //KAB_EMBEDDED
117 117
118 c = colorGroup().background(); 118 c = colorGroup().background();
119 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 119 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
120 config->readColorEntry( "BackgroundColor", &c ) ) ); 120 config->readColorEntry( "BackgroundColor", &c ) ) );
121 c = colorGroup().foreground(); 121 c = colorGroup().foreground();
122 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 122 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
123 config->readColorEntry( "TextColor", &c ) ) ); 123 config->readColorEntry( "TextColor", &c ) ) );
124 c = colorGroup().button(); 124 c = colorGroup().button();
125 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), 125 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"),
126 config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); 126 config->readColorEntry( "HeaderBackgroundColor", &c ) ) );
127 c = colorGroup().buttonText(); 127 c = colorGroup().buttonText();
128 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 128 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
129 config->readColorEntry( "HeaderTextColor", &c ) ) ); 129 config->readColorEntry( "HeaderTextColor", &c ) ) );
130 c = colorGroup().highlight(); 130 c = colorGroup().highlight();
131 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 131 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
132 config->readColorEntry( "HighlightColor", &c ) ) ); 132 config->readColorEntry( "HighlightColor", &c ) ) );
133 c = colorGroup().highlightedText(); 133 c = colorGroup().highlightedText();
134 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 134 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
135 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 135 config->readColorEntry( "HighlightedTextColor", &c ) ) );
136 c = colorGroup().background(); 136 c = colorGroup().background();
137 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), 137 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"),
138 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); 138 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) );
139 139
140 enableColors(); 140 enableColors();
141 141
142 // fonts 142 // fonts
143 QFont fnt = font(); 143 QFont fnt = font();
144 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 144 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
145 fnt.setBold( true ); 145 fnt.setBold( true );
146 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 146 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
147 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 147 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
148 enableFonts(); 148 enableFonts();
149 149
150} 150}
151 151
152void LookAndFeelPage::saveSettings( KConfig *config ) 152void LookAndFeelPage::saveSettings( KConfig *config )
153{ 153{
154 config->writeEntry("ABackground", mAlternateButton->isChecked()); 154 config->writeEntry("ABackground", mAlternateButton->isChecked());
155 config->writeEntry("SingleLine", mLineButton->isChecked()); 155 config->writeEntry("SingleLine", mLineButton->isChecked());
156 config->writeEntry("ToolTips", mToolTipBox->isChecked()); 156 config->writeEntry("ToolTips", mToolTipBox->isChecked());
157 config->writeEntry("Background", mBackgroundBox->isChecked()); 157 config->writeEntry("Background", mBackgroundBox->isChecked());
158 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); 158 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text());
159 159
160 // colors 160 // colors
161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
163 { 163 {
164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
165 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 165 config->writeEntry( "TextColor", lbColors->color( 1 ) );
166 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); 166 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) );
167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
170 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); 170 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) );
171 } 171 }
172 // fonts 172 // fonts
173 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 173 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
174 if ( cbEnableCustomFonts->isChecked() ) 174 if ( cbEnableCustomFonts->isChecked() )
175 { 175 {
176 config->writeEntry( "TextFont", lTextFont->font() ); 176 config->writeEntry( "TextFont", lTextFont->font() );
177 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 177 config->writeEntry( "HeaderFont", lHeaderFont->font() );
178 } 178 }
179 179
180} 180}
181 181
182void LookAndFeelPage::setTextFont() 182void LookAndFeelPage::setTextFont()
183{ 183{
184 QFont f( lTextFont->font() ); 184 QFont f( lTextFont->font() );
185#ifndef KAB_EMBEDDED 185#ifndef KAB_EMBEDDED
186 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 186 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
187 updateFontLabel( f, lTextFont ); 187 updateFontLabel( f, lTextFont );
188#else //KAB_EMBEDDED 188#else //KAB_EMBEDDED
189 bool ok; 189 bool ok;
190 QFont fout = KFontDialog::getFont( f, ok); 190 QFont fout = KFontDialog::getFont( f, ok);
191 if ( ok ) 191 if ( ok )
192 updateFontLabel( fout, lTextFont ); 192 updateFontLabel( fout, lTextFont );
193#endif //KAB_EMBEDDED 193#endif //KAB_EMBEDDED
194} 194}
195 195
196void LookAndFeelPage::setHeaderFont() 196void LookAndFeelPage::setHeaderFont()
197{ 197{
198 QFont f( lHeaderFont->font() ); 198 QFont f( lHeaderFont->font() );
199#ifndef KAB_EMBEDDED 199#ifndef KAB_EMBEDDED
200 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 200 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
201 updateFontLabel( f, lHeaderFont ); 201 updateFontLabel( f, lHeaderFont );
202#else //KAB_EMBEDDED 202#else //KAB_EMBEDDED
203 bool ok; 203 bool ok;
204 QFont fout = KFontDialog::getFont( f, ok); 204 QFont fout = KFontDialog::getFont( f, ok);
205 if ( ok ) 205 if ( ok )
206 updateFontLabel( fout, lHeaderFont ); 206 updateFontLabel( fout, lHeaderFont );
207#endif //KAB_EMBEDDED 207#endif //KAB_EMBEDDED
208} 208}
209 209
210void LookAndFeelPage::enableFonts() 210void LookAndFeelPage::enableFonts()
211{ 211{
212 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 212 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
213 if ( cbEnableCustomFonts->isChecked() )
214 vbFonts->setFocus();
213} 215}
214 216
215void LookAndFeelPage::enableColors() 217void LookAndFeelPage::enableColors()
216{ 218{
217 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 219 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
220 if ( cbEnableCustomColors->isChecked() )
221 lbColors->setFocus();
218} 222}
219 223
220void LookAndFeelPage::initGUI() 224void LookAndFeelPage::initGUI()
221{ 225{
222 int spacing = KDialog::spacingHint(); 226 int spacing = KDialog::spacingHint();
223 int margin = KDialog::marginHint(); 227 int margin = KDialog::marginHint();
224 228
225 QTabWidget *tabs = new QTabWidget( this ); 229 QTabWidget *tabs = new QTabWidget( this );
226 230
227 // General 231 // General
228 QVBox *generalTab = new QVBox( this, "generaltab" ); 232 QVBox *generalTab = new QVBox( this, "generaltab" );
229 233
230 generalTab->setSpacing( spacing ); 234 generalTab->setSpacing( spacing );
231 generalTab->setMargin( margin ); 235 generalTab->setMargin( margin );
232 236
233 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 237 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal,
234 i18n("Row Separator"), generalTab); 238 i18n("Row Separator"), generalTab);
235 239
236 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), 240 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
237 group, "mAlternateButton"); 241 group, "mAlternateButton");
238 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); 242 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
239 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); 243 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
240 244
241 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, 245 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab,
242 "mBackgroundBox"); 246 "mBackgroundBox");
243 connect(mBackgroundBox, SIGNAL(toggled(bool)), 247 connect(mBackgroundBox, SIGNAL(toggled(bool)),
244 SLOT(enableBackgroundToggled(bool))); 248 SLOT(enableBackgroundToggled(bool)));
245 // LR image not implemented 249 // LR image not implemented
246 mBackgroundBox->setEnabled( false ); 250 mBackgroundBox->setEnabled( false );
247 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); 251 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName");
248#ifndef KAB_EMBEDDED 252#ifndef KAB_EMBEDDED
249 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | 253 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
250 KFile::LocalOnly); 254 KFile::LocalOnly);
251 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); 255 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
252#endif //KAB_EMBEDDED 256#endif //KAB_EMBEDDED
253 257
254 // ToolTip Checkbox 258 // ToolTip Checkbox
255 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, 259 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab,
256 "mToolTipBox"); 260 "mToolTipBox");
257 261
258 tabs->addTab( generalTab, i18n("&General") ); 262 tabs->addTab( generalTab, i18n("&General") );
259 263
260 // Colors 264 // Colors
261 QVBox *colorTab = new QVBox( this, "colortab" ); 265 QVBox *colorTab = new QVBox( this, "colortab" );
262 colorTab->setSpacing( spacing ); 266 colorTab->setSpacing( spacing );
263 colorTab->setMargin( spacing ); 267 colorTab->setMargin( spacing );
264 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 268 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
265 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 269 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
266 lbColors = new ColorListBox( colorTab ); 270 lbColors = new ColorListBox( colorTab );
267 tabs->addTab( colorTab, i18n("&Colors") ); 271 tabs->addTab( colorTab, i18n("&Colors") );
268 272
269 QWhatsThis::add( cbEnableCustomColors, i18n( 273 QWhatsThis::add( cbEnableCustomColors, i18n(
270 "If custom colors are enabled, you may choose the colors for the view below. " 274 "If custom colors are enabled, you may choose the colors for the view below. "
271 "Otherwise colors from your current KDE color scheme are used." 275 "Otherwise colors from your current KDE color scheme are used."
272 ) ); 276 ) );
273 QWhatsThis::add( lbColors, i18n( 277 QWhatsThis::add( lbColors, i18n(
274 "Double click or press RETURN on a item to select a color for the related strings in the view." 278 "Double click or press RETURN on a item to select a color for the related strings in the view."
275 ) ); 279 ) );
276 280
277 // Fonts 281 // Fonts
278 QVBox *fntTab = new QVBox( this, "fonttab" ); 282 QVBox *fntTab = new QVBox( this, "fonttab" );
279 283
280 fntTab->setSpacing( spacing ); 284 fntTab->setSpacing( spacing );
281 fntTab->setMargin( spacing ); 285 fntTab->setMargin( spacing );
282 286
283 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 287 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
284 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 288 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
285 289
286 vbFonts = new QWidget( fntTab ); 290 vbFonts = new QWidget( fntTab );
287 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 291 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 );
288 gFnts->setSpacing( spacing ); 292 gFnts->setSpacing( spacing );
289 gFnts->setAutoAdd( true ); 293 gFnts->setAutoAdd( true );
290 gFnts->setColStretch( 1, 1 ); 294 gFnts->setColStretch( 1, 1 );
291 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 295 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
292 lTextFont = new QLabel( vbFonts ); 296 lTextFont = new QLabel( vbFonts );
293 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 297 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
294#ifndef KAB_EMBEDDED 298#ifndef KAB_EMBEDDED
295 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 299 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
296#else //KAB_EMBEDDED 300#else //KAB_EMBEDDED
297 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 301 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
298#endif //KAB_EMBEDDED 302#endif //KAB_EMBEDDED
299 303
300 lTFnt->setBuddy( btnFont ); 304 lTFnt->setBuddy( btnFont );
301 305
302 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 306 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
303 307
304 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 308 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
305 lHeaderFont = new QLabel( vbFonts ); 309 lHeaderFont = new QLabel( vbFonts );
306 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 310 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken );
307#ifndef KAB_EMBEDDED 311#ifndef KAB_EMBEDDED
308 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 312 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
309#else //KAB_EMBEDDED 313#else //KAB_EMBEDDED
310 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 314 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
311#endif //KAB_EMBEDDED 315#endif //KAB_EMBEDDED
312 lHFnt->setBuddy( btnHeaderFont ); 316 lHFnt->setBuddy( btnHeaderFont );
313 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 317 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
314 318
315 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 319 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
316 320
317 QWhatsThis::add( cbEnableCustomFonts, i18n( 321 QWhatsThis::add( cbEnableCustomFonts, i18n(
318 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 322 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
319 "Otherwise the default KDE font will be used, in bold style for the header and " 323 "Otherwise the default KDE font will be used, in bold style for the header and "
320 "normal style for the data." 324 "normal style for the data."
321 ) ); 325 ) );
322 326
323 tabs->addTab( fntTab, i18n("&Fonts") ); 327 tabs->addTab( fntTab, i18n("&Fonts") );
324 328
325} 329}
326 330
327void LookAndFeelPage::enableBackgroundToggled(bool enabled) 331void LookAndFeelPage::enableBackgroundToggled(bool enabled)
328{ 332{
329 mBackgroundName->setEnabled(enabled); 333 mBackgroundName->setEnabled(enabled);
330} 334}
331 335
332 336
333void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 337void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l )
334{ 338{
335 l->setFont( fnt ); 339 l->setFont( fnt );
336 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 340 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
337} 341}
338 342
339#ifndef KAB_EMBEDDED 343#ifndef KAB_EMBEDDED
340#include "configuretableviewdialog.moc" 344#include "configuretableviewdialog.moc"
341#endif //KAB_EMBEDDED 345#endif //KAB_EMBEDDED
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index deadfc9..de964da 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,650 +1,689 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 73 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
79 79
80 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
81 81
82 oldToday = -1; 82 oldToday = -1;
83} 83}
84 84
85MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
86{ 86{
87 delete minutes; 87 delete minutes;
88} 88}
89 89
90int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
91{ 91{
92 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
93 93
94 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 95 DateList::ConstIterator it;
96 int col = 0; 96 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 98 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
101 ++col; 101 ++col;
102 } 102 }
103 103
104 return -1; 104 return -1;
105} 105}
106void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
107{ 107{
108 updateLocation(); 108 updateLocation();
109} 109}
110void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
111{ 111{
112 112
113 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 116 recalculate = true;
117 117
118 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 124
125 oldTime = tim; 125 oldTime = tim;
126 oldToday = today; 126 oldToday = today;
127 127
128 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
130 return; 130 return;
131 } else { 131 } else {
132 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
133 } 133 }
134 134
135 if(recalculate) 135 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
138 raise(); 138 raise();
139 139
140 if(recalculate) 140 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 143
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 171 mAllAgendaPopup = 0;
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 mAllAgendaPopup = 0;
190 blockResize = false; 191 blockResize = false;
191 mColumns = columns; 192 mColumns = columns;
192 mRows = 1; 193 mRows = 1;
193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
194 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
195 mAllDayMode = true; 196 mAllDayMode = true;
196#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
198#endif 199#endif
199 mHolidayMask = 0; 200 mHolidayMask = 0;
200 init(); 201 init();
201} 202}
202 203
203 204
204KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
205{ 206{
206 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
207 208
208} 209}
209 210
210Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
211{ 212{
212 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
213} 214}
214 215
215 216
216QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
217{ 218{
218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
219} 220}
220 221
221 222
222void KOAgenda::init() 223void KOAgenda::init()
223{ 224{
224 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
226 227
227 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
229 QString pathString = ""; 230 QString pathString = "";
230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
231 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
232 pathString += "icons16/"; 233 pathString += "icons16/";
233 } else 234 } else
234 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
235 236
236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
238 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
245#ifndef _WIN32_ 246#ifndef _WIN32_
246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
247 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
248#endif 249#endif
249 mGridSpacingX = 80; 250 mGridSpacingX = 80;
250 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
251 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
252 mScrollDelay = 30; 253 mScrollDelay = 30;
253 mScrollOffset = 10; 254 mScrollOffset = 10;
254 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
255 //enableClipper(true); 256 //enableClipper(true);
256 257
257 // Grab key strokes for keyboard navigation of agenda. Seems to have no 258 // Grab key strokes for keyboard navigation of agenda. Seems to have no
258 // effect. Has to be fixed. 259 // effect. Has to be fixed.
259 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
260 261
261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
264 265
265 mStartCellX = 0; 266 mStartCellX = 0;
266 mStartCellY = 0; 267 mStartCellY = 0;
267 mCurrentCellX = 0; 268 mCurrentCellX = 0;
268 mCurrentCellY = 0; 269 mCurrentCellY = 0;
269 270
270 mSelectionCellX = 0; 271 mSelectionCellX = 0;
271 mSelectionYTop = 0; 272 mSelectionYTop = 0;
272 mSelectionHeight = 0; 273 mSelectionHeight = 0;
273 274
274 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
275 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
276 277
277 mClickedItem = 0; 278 mClickedItem = 0;
278 279
279 mActionItem = 0; 280 mActionItem = 0;
280 mActionType = NOP; 281 mActionType = NOP;
281 mItemMoved = false; 282 mItemMoved = false;
282 283
283 mSelectedItem = 0; 284 mSelectedItem = 0;
284 285
285 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
286 287
287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
288 289
289 viewport()->update(); 290 viewport()->update();
290 291
291 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
292// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
293 294
294 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // Disable horizontal scrollbar. This is a hack. The geometry should be
295 // controlled in a way that the contents horizontally always fits. Then it is 296 // controlled in a way that the contents horizontally always fits. Then it is
296 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
297 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
298 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
299 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
300 else 301 else
301 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
302 303
303 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
304 305
305 calculateWorkingHours(); 306 calculateWorkingHours();
306 307
307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
308 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
309 310
310 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
311 if(mAllDayMode) 312 if(mAllDayMode)
312 mMarcusBains = 0; 313 mMarcusBains = 0;
313 else { 314 else {
314 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
315 addChild(mMarcusBains); 316 addChild(mMarcusBains);
316 } 317 }
317 mPopupKind = 0; 318 mPopupKind = 0;
318 mPopupItem = 0; 319 mPopupItem = 0;
319} 320}
320 321
321void KOAgenda::clear() 322void KOAgenda::clear()
322{ 323{
323 KOAgendaItem *item; 324 KOAgendaItem *item;
324 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
325 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
326 //item->hide(); 327 //item->hide();
327 } 328 }
328 mItems.clear(); 329 mItems.clear();
329 mSelectedItem = 0; 330 mSelectedItem = 0;
330 clearSelection(); 331 clearSelection();
331} 332}
332 333
333void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
334{ 335{
335 mSelectionCellX = 0; 336 mSelectionCellX = 0;
336 mSelectionYTop = 0; 337 mSelectionYTop = 0;
337 mSelectionHeight = 0; 338 mSelectionHeight = 0;
338} 339}
339 340
340void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
341{ 342{
342 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
343} 344}
344 345
345 346
346void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
347{ 348{
348 if (columns == 0) { 349 if (columns == 0) {
349 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
350 return; 351 return;
351 } 352 }
352 clear(); 353 clear();
353 mColumns = columns; 354 mColumns = columns;
354 computeSizes(); 355 computeSizes();
355} 356}
356 357
357/* 358/*
358 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
359 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
360*/ 361*/
361bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
362{ 363{
363 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
364 switch(event->type()) { 365 switch(event->type()) {
365 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
366 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
367 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
368 case QEvent::MouseMove: 369 case QEvent::MouseMove:
369 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
370 371
371 case (QEvent::Leave): 372 case (QEvent::Leave):
372 if (!mActionItem) 373 if (!mActionItem)
373 setCursor(arrowCursor); 374 setCursor(arrowCursor);
374 return true; 375 return true;
375 376
376 default: 377 default:
377 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
378 } 379 }
379} 380}
380void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
381{ 382{
382 mPopupTimer->stop(); 383 mPopupTimer->stop();
383 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 ) {
384 if (mActionItem ) { 385 if (mActionItem ) {
385 endItemAction(); 386 endItemAction();
386 } 387 }
387 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
388 if (mPopupItem) { 389 if (mPopupItem) {
389 selectItem(mPopupItem); 390 selectItem(mPopupItem);
391 if ( mAllAgendaPopup )
392 mAllAgendaPopup->installEventFilter( this );
390 emit showIncidencePopupSignal(mPopupItem->incidence()); 393 emit showIncidencePopupSignal(mPopupItem->incidence());
391 394
392 } 395 }
393 } else if ( mPopupKind == 2 ) { 396 } else if ( mPopupKind == 2 ) {
394 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 397 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
395 endSelectAction( false ); // do not emit new event signal 398 endSelectAction( false ); // do not emit new event signal
396 mLeftMouseDown = false; // no more leftMouse computation 399 mLeftMouseDown = false; // no more leftMouse computation
397 } 400 }
401 mNewItemPopup->installEventFilter( this );
398 mNewItemPopup->popup( mPopupPos); 402 mNewItemPopup->popup( mPopupPos);
403
399 } 404 }
400 mLeftMouseDown = false; 405 mLeftMouseDown = false;
401 mPopupItem = 0; 406 mPopupItem = 0;
402 mPopupKind = 0; 407 mPopupKind = 0;
403} 408}
404 409
405bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 410bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
406{ 411{
407 //qDebug("KOAgenda::eventFilter_mous "); 412 static int startX = 0;
413 static int startY = 0;
414 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
415 static bool blockMoving = true;
416
417 //qDebug("KOAgenda::eventFilter_mous ");
418 if ( object == mNewItemPopup ) {
419 //qDebug("mNewItemPopup ");
420 if ( me->type() == QEvent::MouseButtonRelease ) {
421 mNewItemPopup->removeEventFilter( this );
422 int dX = me->globalPos().x() - mPopupPos.x();;
423 if ( dX < 0 )
424 dX = -dX;
425 int dY = me->globalPos().y() - mPopupPos.y();
426 if ( dY < 0 )
427 dY = -dY;
428 if ( dX > blockmoveDist || dY > blockmoveDist ) {
429 mNewItemPopup->hide();
430 }
431 }
432 return true;
433 }
434 if ( object == mAllAgendaPopup ) {
435 //qDebug(" mAllAgendaPopup ");
436 if ( me->type() == QEvent::MouseButtonRelease ) {
437 mAllAgendaPopup->removeEventFilter( this );
438 int dX = me->globalPos().x() - mPopupPos.x();;
439 if ( dX < 0 )
440 dX = -dX;
441 int dY = me->globalPos().y() - mPopupPos.y();
442 if ( dY < 0 )
443 dY = -dY;
444 if ( dX > blockmoveDist || dY > blockmoveDist ) {
445 mAllAgendaPopup->hide();
446 }
447 }
448 return true;
449 }
408 QPoint viewportPos; 450 QPoint viewportPos;
409 if (object != viewport()) { 451 if (object != viewport()) {
410 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 452 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
411 } else { 453 } else {
412 viewportPos = me->pos(); 454 viewportPos = me->pos();
413 } 455 }
414 static int startX = 0; 456
415 static int startY = 0;
416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
417 static bool blockMoving = true;
418 switch (me->type()) { 457 switch (me->type()) {
419 case QEvent::MouseButtonPress: 458 case QEvent::MouseButtonPress:
420 if (me->button() == LeftButton) { 459 if (me->button() == LeftButton) {
421 mPopupTimer->start( 600 ); 460 mPopupTimer->start( 600 );
422 mLeftMouseDown = true; 461 mLeftMouseDown = true;
423 } 462 }
424 blockMoving = true; 463 blockMoving = true;
425 startX = viewportPos.x(); 464 startX = viewportPos.x();
426 startY = viewportPos.y(); 465 startY = viewportPos.y();
466 mPopupPos = me->globalPos();
427 if (object != viewport()) { 467 if (object != viewport()) {
428 mPopupItem = (KOAgendaItem *)object; 468 mPopupItem = (KOAgendaItem *)object;
429 mPopupKind = 1; 469 mPopupKind = 1;
430 if (me->button() == RightButton) { 470 if (me->button() == RightButton) {
431 popupMenu(); 471 popupMenu();
432 } else if (me->button() == LeftButton) { 472 } else if (me->button() == LeftButton) {
433 mActionItem = (KOAgendaItem *)object; 473 mActionItem = (KOAgendaItem *)object;
434 if (mActionItem) { 474 if (mActionItem) {
435 if ( mSelectionHeight > 0 ) { 475 if ( mSelectionHeight > 0 ) {
436 int selectionCellX = mSelectionCellX * mGridSpacingX; 476 int selectionCellX = mSelectionCellX * mGridSpacingX;
437 int selectionYTop = mSelectionYTop; 477 int selectionYTop = mSelectionYTop;
438 int gridSpacingX = mGridSpacingX; 478 int gridSpacingX = mGridSpacingX;
439 int selectionHeight = mSelectionHeight; 479 int selectionHeight = mSelectionHeight;
440 clearSelection(); 480 clearSelection();
441 repaintContents( selectionCellX, selectionYTop, 481 repaintContents( selectionCellX, selectionYTop,
442 gridSpacingX, selectionHeight,false ); 482 gridSpacingX, selectionHeight,false );
443 } 483 }
444 selectItem(mActionItem); 484 selectItem(mActionItem);
445 Incidence *incidence = mActionItem->incidence(); 485 Incidence *incidence = mActionItem->incidence();
446 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 486 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
447 mActionItem = 0; 487 mActionItem = 0;
448 } else { 488 } else {
449 startItemAction(viewportPos); 489 startItemAction(viewportPos);
450 } 490 }
451 } 491 }
452 } 492 }
453 } else { // ---------- viewport() 493 } else { // ---------- viewport()
454 mPopupItem = 0; 494 mPopupItem = 0;
455 mPopupKind = 2; 495 mPopupKind = 2;
456 selectItem(0); 496 selectItem(0);
457 mActionItem = 0; 497 mActionItem = 0;
458 mPopupPos = viewport()->mapToGlobal( me->pos() );
459 if (me->button() == RightButton) { 498 if (me->button() == RightButton) {
460 int x,y; 499 int x,y;
461 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 500 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
462 int gx,gy; 501 int gx,gy;
463 contentsToGrid(x,y,gx,gy); 502 contentsToGrid(x,y,gx,gy);
464 mCurrentCellX = gx; 503 mCurrentCellX = gx;
465 mCurrentCellY = gy; 504 mCurrentCellY = gy;
466 mStartCellX = gx; 505 mStartCellX = gx;
467 mStartCellY = gy; 506 mStartCellY = gy;
468 popupMenu(); 507 popupMenu();
469 } else if (me->button() == LeftButton) { 508 } else if (me->button() == LeftButton) {
470 setCursor(arrowCursor); 509 setCursor(arrowCursor);
471 startSelectAction(viewportPos); 510 startSelectAction(viewportPos);
472 } 511 }
473 } 512 }
474 break; 513 break;
475 514
476 case QEvent::MouseButtonRelease: 515 case QEvent::MouseButtonRelease:
477 if (me->button() == LeftButton ) { 516 if (me->button() == LeftButton ) {
478 mPopupTimer->stop(); 517 mPopupTimer->stop();
479 } 518 }
480 if (object != viewport()) { 519 if (object != viewport()) {
481 if (me->button() == LeftButton && mLeftMouseDown) { 520 if (me->button() == LeftButton && mLeftMouseDown) {
482 if (mActionItem) { 521 if (mActionItem) {
483 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 522 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
484 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 523 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
485 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 524 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
486 mScrollUpTimer.stop(); 525 mScrollUpTimer.stop();
487 mScrollDownTimer.stop(); 526 mScrollDownTimer.stop();
488 mActionItem->resetMove(); 527 mActionItem->resetMove();
489 placeSubCells( mActionItem ); 528 placeSubCells( mActionItem );
490 // emit startDragSignal( mActionItem->incidence() ); 529 // emit startDragSignal( mActionItem->incidence() );
491 setCursor( arrowCursor ); 530 setCursor( arrowCursor );
492 mActionItem = 0; 531 mActionItem = 0;
493 mActionType = NOP; 532 mActionType = NOP;
494 mItemMoved = 0; 533 mItemMoved = 0;
495 mLeftMouseDown = false; 534 mLeftMouseDown = false;
496 return true; 535 return true;
497 } 536 }
498 endItemAction(); 537 endItemAction();
499 } 538 }
500 } 539 }
501 540
502 } else { // ---------- viewport() 541 } else { // ---------- viewport()
503 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 542 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
504 endSelectAction( true ); // emit new event signal 543 endSelectAction( true ); // emit new event signal
505 } 544 }
506 } 545 }
507 if (me->button() == LeftButton) 546 if (me->button() == LeftButton)
508 mLeftMouseDown = false; 547 mLeftMouseDown = false;
509 548
510 break; 549 break;
511 550
512 case QEvent::MouseMove: 551 case QEvent::MouseMove:
513 //qDebug("mm "); 552 //qDebug("mm ");
514 if ( !mLeftMouseDown ) 553 if ( !mLeftMouseDown )
515 return false; 554 return false;
516 if ( blockMoving ) { 555 if ( blockMoving ) {
517 int dX, dY; 556 int dX, dY;
518 dX = startX - viewportPos.x(); 557 dX = startX - viewportPos.x();
519 if ( dX < 0 ) 558 if ( dX < 0 )
520 dX = -dX; 559 dX = -dX;
521 dY = viewportPos.y() - startY; 560 dY = viewportPos.y() - startY;
522 if ( dY < 0 ) 561 if ( dY < 0 )
523 dY = -dY; 562 dY = -dY;
524 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 563 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
525 if ( dX > blockmoveDist || dY > blockmoveDist ) { 564 if ( dX > blockmoveDist || dY > blockmoveDist ) {
526 blockMoving = false; 565 blockMoving = false;
527 } 566 }
528 } 567 }
529 if ( ! blockMoving ) 568 if ( ! blockMoving )
530 mPopupTimer->stop(); 569 mPopupTimer->stop();
531 if (object != viewport()) { 570 if (object != viewport()) {
532 KOAgendaItem *moveItem = (KOAgendaItem *)object; 571 KOAgendaItem *moveItem = (KOAgendaItem *)object;
533 if (!moveItem->incidence()->isReadOnly() ) { 572 if (!moveItem->incidence()->isReadOnly() ) {
534 if (!mActionItem) 573 if (!mActionItem)
535 setNoActionCursor(moveItem,viewportPos); 574 setNoActionCursor(moveItem,viewportPos);
536 else { 575 else {
537 if ( !blockMoving ) 576 if ( !blockMoving )
538 performItemAction(viewportPos); 577 performItemAction(viewportPos);
539 } 578 }
540 } 579 }
541 } else { // ---------- viewport() 580 } else { // ---------- viewport()
542 mPopupPos = viewport()->mapToGlobal( me->pos() ); 581 mPopupPos = viewport()->mapToGlobal( me->pos() );
543 if ( mActionType == SELECT ) { 582 if ( mActionType == SELECT ) {
544 performSelectAction( viewportPos ); 583 performSelectAction( viewportPos );
545 } 584 }
546 } 585 }
547 break; 586 break;
548 587
549 case QEvent::MouseButtonDblClick: 588 case QEvent::MouseButtonDblClick:
550 mPopupTimer->stop(); 589 mPopupTimer->stop();
551 if (object == viewport()) { 590 if (object == viewport()) {
552 selectItem(0); 591 selectItem(0);
553 int x,y; 592 int x,y;
554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 593 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
555 int gx,gy; 594 int gx,gy;
556 contentsToGrid(x,y,gx,gy); 595 contentsToGrid(x,y,gx,gy);
557 emit newEventSignal(gx,gy); 596 emit newEventSignal(gx,gy);
558 } else { 597 } else {
559 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 598 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
560 selectItem(doubleClickedItem); 599 selectItem(doubleClickedItem);
561 if ( KOPrefs::instance()->mEditOnDoubleClick ) 600 if ( KOPrefs::instance()->mEditOnDoubleClick )
562 emit editIncidenceSignal(doubleClickedItem->incidence()); 601 emit editIncidenceSignal(doubleClickedItem->incidence());
563 else 602 else
564 emit showIncidenceSignal(doubleClickedItem->incidence()); 603 emit showIncidenceSignal(doubleClickedItem->incidence());
565 } 604 }
566 break; 605 break;
567 606
568 default: 607 default:
569 break; 608 break;
570 } 609 }
571 return true; 610 return true;
572#if 0 611#if 0
573 //qDebug("KOAgenda::eventFilter_mous "); 612 //qDebug("KOAgenda::eventFilter_mous ");
574 QPoint viewportPos; 613 QPoint viewportPos;
575 if (object != viewport()) { 614 if (object != viewport()) {
576 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 615 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
577 } else { 616 } else {
578 viewportPos = me->pos(); 617 viewportPos = me->pos();
579 } 618 }
580 static int startX = 0; 619 static int startX = 0;
581 static int startY = 0; 620 static int startY = 0;
582 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 621 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
583 static bool blockMoving = true; 622 static bool blockMoving = true;
584 static bool leftMouseDown = false; 623 static bool leftMouseDown = false;
585 bool rightButtonPressed = false; 624 bool rightButtonPressed = false;
586 switch (me->type()) { 625 switch (me->type()) {
587 case QEvent::MouseButtonPress: 626 case QEvent::MouseButtonPress:
588 if (me->button() == LeftButton) { 627 if (me->button() == LeftButton) {
589 leftMouseDown = true; 628 leftMouseDown = true;
590 } 629 }
591 else if (me->button() == RightButton) { 630 else if (me->button() == RightButton) {
592 leftMouseDown = false; 631 leftMouseDown = false;
593 } 632 }
594 blockMoving = true; 633 blockMoving = true;
595 startX = viewportPos.x(); 634 startX = viewportPos.x();
596 startY = viewportPos.y(); 635 startY = viewportPos.y();
597 if (object != viewport()) { // item clicked ************** 636 if (object != viewport()) { // item clicked **************
598 if (me->button() == RightButton) { 637 if (me->button() == RightButton) {
599 leftMouseDown = false; 638 leftMouseDown = false;
600 mClickedItem = (KOAgendaItem *)object; 639 mClickedItem = (KOAgendaItem *)object;
601 if (mActionItem ) { 640 if (mActionItem ) {
602 endItemAction(); 641 endItemAction();
603 } 642 }
604 if (mClickedItem) { 643 if (mClickedItem) {
605 selectItem(mClickedItem); 644 selectItem(mClickedItem);
606 emit showIncidencePopupSignal(mClickedItem->incidence()); 645 emit showIncidencePopupSignal(mClickedItem->incidence());
607 } 646 }
608 return true; 647 return true;
609 } else if (me->button() == LeftButton) { 648 } else if (me->button() == LeftButton) {
610 mActionItem = (KOAgendaItem *)object; 649 mActionItem = (KOAgendaItem *)object;
611 if (mActionItem) { 650 if (mActionItem) {
612 if ( mSelectionHeight > 0 ) { 651 if ( mSelectionHeight > 0 ) {
613 int selectionCellX = mSelectionCellX * mGridSpacingX; 652 int selectionCellX = mSelectionCellX * mGridSpacingX;
614 int selectionYTop = mSelectionYTop; 653 int selectionYTop = mSelectionYTop;
615 int gridSpacingX = mGridSpacingX; 654 int gridSpacingX = mGridSpacingX;
616 int selectionHeight = mSelectionHeight; 655 int selectionHeight = mSelectionHeight;
617 clearSelection(); 656 clearSelection();
618 repaintContents( selectionCellX, selectionYTop, 657 repaintContents( selectionCellX, selectionYTop,
619 gridSpacingX, selectionHeight,false ); 658 gridSpacingX, selectionHeight,false );
620 } 659 }
621 selectItem(mActionItem); 660 selectItem(mActionItem);
622 Incidence *incidence = mActionItem->incidence(); 661 Incidence *incidence = mActionItem->incidence();
623 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 662 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
624 mActionItem = 0; 663 mActionItem = 0;
625 } else { 664 } else {
626 startItemAction(viewportPos); 665 startItemAction(viewportPos);
627 } 666 }
628 } 667 }
629 } 668 }
630 } else { // ---------- viewport() 669 } else { // ---------- viewport()
631 selectItem(0); 670 selectItem(0);
632 mActionItem = 0; 671 mActionItem = 0;
633 if (me->button() == LeftButton ) { 672 if (me->button() == LeftButton ) {
634 setCursor(arrowCursor); 673 setCursor(arrowCursor);
635 startSelectAction(viewportPos); 674 startSelectAction(viewportPos);
636 } else if (me->button() == RightButton ) { 675 } else if (me->button() == RightButton ) {
637 setCursor(arrowCursor); 676 setCursor(arrowCursor);
638 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 677 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
639 endSelectAction( false ); // do not emit new event signal 678 endSelectAction( false ); // do not emit new event signal
640 leftMouseDown = false; // no more leftMouse computation 679 leftMouseDown = false; // no more leftMouse computation
641 } 680 }
642 int x,y; 681 int x,y;
643 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 682 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
644 int gx,gy; 683 int gx,gy;
645 contentsToGrid(x,y,gx,gy); 684 contentsToGrid(x,y,gx,gy);
646 mCurrentCellX = gx; 685 mCurrentCellX = gx;
647 mCurrentCellY = gy; 686 mCurrentCellY = gy;
648 mStartCellX = gx; 687 mStartCellX = gx;
649 mStartCellY = gy; 688 mStartCellY = gy;
650 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 689 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 35c08b6..4f1fdb9 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,296 +1,298 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h"
34 35
35class QPopupMenu; 36class QPopupMenu;
36class QTime; 37class QTime;
37class KConfig; 38class KConfig;
38class QFrame; 39class QFrame;
39class KOAgenda; 40class KOAgenda;
40class KCal::Event; 41class KCal::Event;
41class KCal::Todo; 42class KCal::Todo;
42 43
43using namespace KCal; 44using namespace KCal;
44 45
45class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
46 Q_OBJECT 47 Q_OBJECT
47 public: 48 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
50 51
51 public slots: 52 public slots:
52 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
53 void updateLoc(); 54 void updateLoc();
54 55
55 private: 56 private:
56 int todayColumn(); 57 int todayColumn();
57 QTimer *minutes; 58 QTimer *minutes;
58 QLabel *mTimeBox; 59 QLabel *mTimeBox;
59 KOAgenda *agenda; 60 KOAgenda *agenda;
60 QTime oldTime; 61 QTime oldTime;
61 int oldToday; 62 int oldToday;
62}; 63};
63 64
64 65
65class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
66{ 67{
67 Q_OBJECT 68 Q_OBJECT
68 public: 69 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 72
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
77 78
78 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
80 81
81 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
82 83
83 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
85 86
86 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 88 QTime gyToTime (int y);
88 89
89 void setStartHour(int startHour); 90 void setStartHour(int startHour);
90 91
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 95 int YTop,int YBottom);
95 96
96 void changeColumns(int columns); 97 void changeColumns(int columns);
97 98
98 int columns() { return mColumns; } 99 int columns() { return mColumns; }
99 int rows() { return mRows; } 100 int rows() { return mRows; }
100 101
101 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
103 104
104// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
105 106
106 void clear(); 107 void clear();
107 108
108 void clearSelection(); 109 void clearSelection();
109 void hideUnused(); 110 void hideUnused();
110 111
111 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
114 void updateConfig(); 115 void updateConfig();
115 116
116 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
117 118
118 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 121 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 123 void finishUpdate();
123 void printSelection(); 124 void printSelection();
124 void storePosition(); 125 void storePosition();
125 void restorePosition(); 126 void restorePosition();
126 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
127 128
128 public slots: 129 public slots:
129 void popupMenu(); 130 void popupMenu();
130 void newItem( int ); 131 void newItem( int );
131 void moveChild( QWidget *, int, int ); 132 void moveChild( QWidget *, int, int );
132 void scrollUp(); 133 void scrollUp();
133 void scrollDown(); 134 void scrollDown();
134 void updateTodo( Todo * t, int , bool ); 135 void updateTodo( Todo * t, int , bool );
135 void popupAlarm(); 136 void popupAlarm();
136 137
137 void checkScrollBoundaries(int); 138 void checkScrollBoundaries(int);
138 139
139 /** Deselect selected items. This function does not emit any signals. */ 140 /** Deselect selected items. This function does not emit any signals. */
140 void deselectItem(); 141 void deselectItem();
141 /** Select item. If the argument is 0, the currently selected item gets 142 /** Select item. If the argument is 0, the currently selected item gets
142 deselected. This function emits the itemSelected(bool) signal to inform 143 deselected. This function emits the itemSelected(bool) signal to inform
143 about selection/deseelction of events. */ 144 about selection/deseelction of events. */
144 void selectItem(KOAgendaItem *); 145 void selectItem(KOAgendaItem *);
145 void finishResize(); 146 void finishResize();
146 147
147 signals: 148 signals:
148 void showDateView( int, int); 149 void showDateView( int, int);
149 void newEventSignal(); 150 void newEventSignal();
150 void newEventSignal(int gx,int gy); 151 void newEventSignal(int gx,int gy);
151 void newTodoSignal(int gx,int gy); 152 void newTodoSignal(int gx,int gy);
152 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 153 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
153 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 154 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
154 void newStartSelectSignal(); 155 void newStartSelectSignal();
155 void showIncidenceSignal(Incidence *); 156 void showIncidenceSignal(Incidence *);
156 void editIncidenceSignal(Incidence *); 157 void editIncidenceSignal(Incidence *);
157 void deleteIncidenceSignal(Incidence *); 158 void deleteIncidenceSignal(Incidence *);
158 void showIncidencePopupSignal(Incidence *); 159 void showIncidencePopupSignal(Incidence *);
159 160
160 void itemModified(KOAgendaItem *item, int ); 161 void itemModified(KOAgendaItem *item, int );
161 void incidenceSelected(Incidence *); 162 void incidenceSelected(Incidence *);
162 163
163 void lowerYChanged(int); 164 void lowerYChanged(int);
164 void upperYChanged(int); 165 void upperYChanged(int);
165 166
166 void startDragSignal(Incidence *); 167 void startDragSignal(Incidence *);
167 void addToCalSignal(Incidence *, Incidence *); 168 void addToCalSignal(Incidence *, Incidence *);
168 void resizedSignal(); 169 void resizedSignal();
169 170
170 protected: 171 protected:
172 KOEventPopupMenu * mAllAgendaPopup;
171 QPainter mPixPainter; 173 QPainter mPixPainter;
172 QPixmap mPaintPixmap; 174 QPixmap mPaintPixmap;
173 QPixmap mHighlightPixmap; 175 QPixmap mHighlightPixmap;
174 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 176 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
175 virtual void resizeEvent ( QResizeEvent * ); 177 virtual void resizeEvent ( QResizeEvent * );
176 178
177 /** Handles mouse events. Called from eventFilter */ 179 /** Handles mouse events. Called from eventFilter */
178 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 180 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
179 181
180 /** Start selecting time span. */ 182 /** Start selecting time span. */
181 void startSelectAction(QPoint viewportPos); 183 void startSelectAction(QPoint viewportPos);
182 184
183 /** Select time span. */ 185 /** Select time span. */
184 void performSelectAction(QPoint viewportPos); 186 void performSelectAction(QPoint viewportPos);
185 187
186 /** Emd selecting time span. */ 188 /** Emd selecting time span. */
187 void endSelectAction( bool emitNewEvent = false ); 189 void endSelectAction( bool emitNewEvent = false );
188 190
189 /** Start moving/resizing agenda item */ 191 /** Start moving/resizing agenda item */
190 void startItemAction(QPoint viewportPos); 192 void startItemAction(QPoint viewportPos);
191 193
192 /** Move/resize agenda item */ 194 /** Move/resize agenda item */
193 void performItemAction(QPoint viewportPos); 195 void performItemAction(QPoint viewportPos);
194 196
195 /** End moving/resizing agenda item */ 197 /** End moving/resizing agenda item */
196 void endItemAction(); 198 void endItemAction();
197 199
198 /** Set cursor, when no item action is in progress */ 200 /** Set cursor, when no item action is in progress */
199 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 201 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
200 202
201 /** Place agenda item in agenda and adjust other cells if necessary */ 203 /** Place agenda item in agenda and adjust other cells if necessary */
202 void placeSubCells(KOAgendaItem *placeItem); 204 void placeSubCells(KOAgendaItem *placeItem);
203 205
204 /** Process the keyevent, including the ignored keyevents of eventwidgets. 206 /** Process the keyevent, including the ignored keyevents of eventwidgets.
205 * Implements pgup/pgdn and cursor key navigation in the view. 207 * Implements pgup/pgdn and cursor key navigation in the view.
206 */ 208 */
207 void keyPressEvent( QKeyEvent * ); 209 void keyPressEvent( QKeyEvent * );
208 210
209 void calculateWorkingHours(); 211 void calculateWorkingHours();
210 212
211 virtual void contentsMousePressEvent ( QMouseEvent * ); 213 virtual void contentsMousePressEvent ( QMouseEvent * );
212 214
213 private: 215 private:
214 void init(); 216 void init();
215 void marcus_bains(); 217 void marcus_bains();
216 bool mAllDayMode; 218 bool mAllDayMode;
217 bool blockResize; 219 bool blockResize;
218 bool mLeftMouseDown; 220 bool mLeftMouseDown;
219 KOAgendaItem *mPopupItem; 221 KOAgendaItem *mPopupItem;
220 QTimer* mPopupTimer; 222 QTimer* mPopupTimer;
221 int mPopupKind; 223 int mPopupKind;
222 QPoint mPopupPos; 224 QPoint mPopupPos;
223 QTimer mResizeTimer; 225 QTimer mResizeTimer;
224 double mContentPosition; 226 double mContentPosition;
225 227
226 // Width and height of agenda cells 228 // Width and height of agenda cells
227 int mGridSpacingX; 229 int mGridSpacingX;
228 int mGridSpacingY; 230 int mGridSpacingY;
229 231
230 // size of border, where mouse action will resize the KOAgendaItem 232 // size of border, where mouse action will resize the KOAgendaItem
231 int mResizeBorderWidth; 233 int mResizeBorderWidth;
232 234
233 // size of border, where mouse mve will cause a scroll of the agenda 235 // size of border, where mouse mve will cause a scroll of the agenda
234 int mScrollBorderWidth; 236 int mScrollBorderWidth;
235 int mScrollDelay; 237 int mScrollDelay;
236 int mScrollOffset; 238 int mScrollOffset;
237 239
238 QTimer mScrollUpTimer; 240 QTimer mScrollUpTimer;
239 QTimer mScrollDownTimer; 241 QTimer mScrollDownTimer;
240 242
241 // Number of Columns/Rows of agenda grid 243 // Number of Columns/Rows of agenda grid
242 int mColumns; 244 int mColumns;
243 int mRows; 245 int mRows;
244 246
245 // Cells to store Move and Resize coordiantes 247 // Cells to store Move and Resize coordiantes
246 int mStartCellX; 248 int mStartCellX;
247 int mStartCellY; 249 int mStartCellY;
248 int mCurrentCellX; 250 int mCurrentCellX;
249 int mCurrentCellY; 251 int mCurrentCellY;
250 252
251 // Working Hour coordiantes 253 // Working Hour coordiantes
252 bool mWorkingHoursEnable; 254 bool mWorkingHoursEnable;
253 int mWorkingHoursYTop; 255 int mWorkingHoursYTop;
254 int mWorkingHoursYBottom; 256 int mWorkingHoursYBottom;
255 257
256 // Selection 258 // Selection
257 int mSelectionCellX; 259 int mSelectionCellX;
258 int mSelectionYTop; 260 int mSelectionYTop;
259 int mSelectionHeight; 261 int mSelectionHeight;
260 262
261 // List of dates to be displayed 263 // List of dates to be displayed
262 DateList mSelectedDates; 264 DateList mSelectedDates;
263 265
264 // The KOAgendaItem, which has been right-clicked last 266 // The KOAgendaItem, which has been right-clicked last
265 KOAgendaItem *mClickedItem; 267 KOAgendaItem *mClickedItem;
266 268
267 // The KOAgendaItem, which is being moved/resized 269 // The KOAgendaItem, which is being moved/resized
268 QGuardedPtr<KOAgendaItem> mActionItem; 270 QGuardedPtr<KOAgendaItem> mActionItem;
269 271
270 // Currently selected item 272 // Currently selected item
271 QGuardedPtr<KOAgendaItem> mSelectedItem; 273 QGuardedPtr<KOAgendaItem> mSelectedItem;
272 274
273 // The Marcus Bains Line widget. 275 // The Marcus Bains Line widget.
274 MarcusBains *mMarcusBains; 276 MarcusBains *mMarcusBains;
275 void computeSizes(); 277 void computeSizes();
276 278
277 MouseActionType mActionType; 279 MouseActionType mActionType;
278 280
279 bool mItemMoved; 281 bool mItemMoved;
280 282
281 // List of all Items contained in agenda 283 // List of all Items contained in agenda
282 QPtrList<KOAgendaItem> mItems; 284 QPtrList<KOAgendaItem> mItems;
283 QPtrList<KOAgendaItem> mUnusedItems; 285 QPtrList<KOAgendaItem> mUnusedItems;
284 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 286 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
285 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 287 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
286 QPopupMenu *mNewItemPopup; 288 QPopupMenu *mNewItemPopup;
287 289
288 int mOldLowerScrollValue; 290 int mOldLowerScrollValue;
289 int mOldUpperScrollValue; 291 int mOldUpperScrollValue;
290 KOAgendaItem * getItemForTodo ( Todo * todo ); 292 KOAgendaItem * getItemForTodo ( Todo * todo );
291 QMemArray<bool> *mHolidayMask; 293 QMemArray<bool> *mHolidayMask;
292 int mCurPixWid; 294 int mCurPixWid;
293 int mCurPixHei; 295 int mCurPixHei;
294}; 296};
295 297
296#endif // KOAGENDA_H 298#endif // KOAGENDA_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8d32152..95388ef 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -316,548 +316,550 @@ void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
316 mMouseDownY = e->pos().y(); 316 mMouseDownY = e->pos().y();
317 mOrgCap = topLevelWidget()->caption(); 317 mOrgCap = topLevelWidget()->caption();
318} 318}
319 319
320void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 320void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
321{ 321{
322 int diff = mMouseDownY - e->pos().y(); 322 int diff = mMouseDownY - e->pos().y();
323 if ( diff < 10 && diff > -10 ) 323 if ( diff < 10 && diff > -10 )
324 return; 324 return;
325 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 325 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
326 if ( tSize < 4 ) 326 if ( tSize < 4 )
327 tSize = 4; 327 tSize = 4;
328 if ( tSize > 22 ) 328 if ( tSize > 22 )
329 tSize = 22; 329 tSize = 22;
330 tSize = (tSize-2)/2; 330 tSize = (tSize-2)/2;
331 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 331 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
332 332
333} 333}
334void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 334void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
335{ 335{
336 topLevelWidget()->setCaption( mOrgCap ); 336 topLevelWidget()->setCaption( mOrgCap );
337 int diff = mMouseDownY - e->pos().y(); 337 int diff = mMouseDownY - e->pos().y();
338 if ( diff < 10 && diff > -10 ) 338 if ( diff < 10 && diff > -10 )
339 return; 339 return;
340 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 340 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
341 if ( tSize < 4 ) 341 if ( tSize < 4 )
342 tSize = 4; 342 tSize = 4;
343 if ( tSize > 22 ) 343 if ( tSize > 22 )
344 tSize = 22; 344 tSize = 22;
345 tSize = (tSize/2)*2; 345 tSize = (tSize/2)*2;
346 if ( tSize == KOPrefs::instance()->mHourSize ) 346 if ( tSize == KOPrefs::instance()->mHourSize )
347 return; 347 return;
348 KOPrefs::instance()->mHourSize = tSize; 348 KOPrefs::instance()->mHourSize = tSize;
349 emit scaleChanged(); 349 emit scaleChanged();
350} 350}
351 351
352/** This is called in response to repaint() */ 352/** This is called in response to repaint() */
353void TimeLabels::paintEvent(QPaintEvent*) 353void TimeLabels::paintEvent(QPaintEvent*)
354{ 354{
355 355
356 // kdDebug() << "paintevent..." << endl; 356 // kdDebug() << "paintevent..." << endl;
357 // this is another hack! 357 // this is another hack!
358 // QPainter painter(this); 358 // QPainter painter(this);
359 //QString c 359 //QString c
360 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 360 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
361} 361}
362 362
363//////////////////////////////////////////////////////////////////////////// 363////////////////////////////////////////////////////////////////////////////
364 364
365EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 365EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
366 : QFrame(parent,name) 366 : QFrame(parent,name)
367{ 367{
368 mColumns = 1; 368 mColumns = 1;
369 mTopBox = 0; 369 mTopBox = 0;
370 mLocation = loc; 370 mLocation = loc;
371 mTopLayout = 0; 371 mTopLayout = 0;
372 mPaintWidget = 0; 372 mPaintWidget = 0;
373 mXOffset = 0; 373 mXOffset = 0;
374 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 374 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
375 else mPixmap = SmallIcon("1downarrow"); 375 else mPixmap = SmallIcon("1downarrow");
376 mEnabled.resize(mColumns); 376 mEnabled.resize(mColumns);
377 mEnabled.fill( false ); 377 mEnabled.fill( false );
378 setMinimumHeight(mPixmap.height()); 378 setMinimumHeight(mPixmap.height());
379} 379}
380 380
381EventIndicator::~EventIndicator() 381EventIndicator::~EventIndicator()
382{ 382{
383} 383}
384 384
385void EventIndicator::drawContents(QPainter *p) 385void EventIndicator::drawContents(QPainter *p)
386{ 386{
387 387
388 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 388 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
389 KDGanttSplitterHandle* han = 0; 389 KDGanttSplitterHandle* han = 0;
390 if ( mPaintWidget ) 390 if ( mPaintWidget )
391 han = mPaintWidget->firstHandle(); 391 han = mPaintWidget->firstHandle();
392 if ( ! han ) { 392 if ( ! han ) {
393 int i; 393 int i;
394 for(i=0;i<mColumns;++i) { 394 for(i=0;i<mColumns;++i) {
395 if (mEnabled[i]) { 395 if (mEnabled[i]) {
396 int cellWidth = contentsRect().right()/mColumns; 396 int cellWidth = contentsRect().right()/mColumns;
397 int xOffset = KOGlobals::self()->reverseLayout() ? 397 int xOffset = KOGlobals::self()->reverseLayout() ?
398 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 398 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
399 i*cellWidth + (cellWidth -mPixmap.width()) /2; 399 i*cellWidth + (cellWidth -mPixmap.width()) /2;
400 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 400 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
401 } 401 }
402 } 402 }
403 } else { 403 } else {
404 han->repaint(); 404 han->repaint();
405 //mPaintWidget->setBackgroundColor( red ); 405 //mPaintWidget->setBackgroundColor( red );
406 406
407 QPainter pa( han ); 407 QPainter pa( han );
408 int i; 408 int i;
409 bool setColor = false; 409 bool setColor = false;
410 for(i=0;i<mColumns;++i) { 410 for(i=0;i<mColumns;++i) {
411 if (mEnabled[i]) { 411 if (mEnabled[i]) {
412 setColor = true; 412 setColor = true;
413 413
414 int cellWidth = contentsRect().right()/mColumns; 414 int cellWidth = contentsRect().right()/mColumns;
415 int xOffset = KOGlobals::self()->reverseLayout() ? 415 int xOffset = KOGlobals::self()->reverseLayout() ?
416 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 416 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
417 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 417 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
418 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 418 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
419 //qDebug("222draw pix %d ",xOffset ); 419 //qDebug("222draw pix %d ",xOffset );
420 420
421 } 421 }
422 422
423 } 423 }
424 pa.end(); 424 pa.end();
425 425
426 } 426 }
427} 427}
428 428
429void EventIndicator::setXOffset( int x ) 429void EventIndicator::setXOffset( int x )
430{ 430{
431 mXOffset = x; 431 mXOffset = x;
432} 432}
433void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 433void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
434{ 434{
435 mPaintWidget = w; 435 mPaintWidget = w;
436 setMaximumHeight(0); 436 setMaximumHeight(0);
437 setMinimumHeight(0); 437 setMinimumHeight(0);
438} 438}
439void EventIndicator::changeColumns(int columns) 439void EventIndicator::changeColumns(int columns)
440{ 440{
441 mColumns = columns; 441 mColumns = columns;
442 mEnabled.resize(mColumns); 442 mEnabled.resize(mColumns);
443 443
444 update(); 444 update();
445} 445}
446 446
447void EventIndicator::enableColumn(int column, bool enable) 447void EventIndicator::enableColumn(int column, bool enable)
448{ 448{
449 mEnabled[column] = enable; 449 mEnabled[column] = enable;
450} 450}
451 451
452 452
453//////////////////////////////////////////////////////////////////////////// 453////////////////////////////////////////////////////////////////////////////
454//////////////////////////////////////////////////////////////////////////// 454////////////////////////////////////////////////////////////////////////////
455//////////////////////////////////////////////////////////////////////////// 455////////////////////////////////////////////////////////////////////////////
456 456
457KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 457KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
458 KOEventView (cal,parent,name) 458 KOEventView (cal,parent,name)
459{ 459{
460 mBlockUpdating = true; 460 mBlockUpdating = true;
461 mStartHour = 8; 461 mStartHour = 8;
462 mSelectedDates.append(QDate::currentDate()); 462 mSelectedDates.append(QDate::currentDate());
463 463
464 mLayoutDayLabels = 0; 464 mLayoutDayLabels = 0;
465 mDayLabelsFrame = 0; 465 mDayLabelsFrame = 0;
466 mDayLabels = 0; 466 mDayLabels = 0;
467 bool isRTL = KOGlobals::self()->reverseLayout(); 467 bool isRTL = KOGlobals::self()->reverseLayout();
468 QPixmap expandPix; 468 QPixmap expandPix;
469 if ( KOPrefs::instance()->mVerticalScreen ) { 469 if ( KOPrefs::instance()->mVerticalScreen ) {
470 expandPix = SmallIcon( "1updownarrow" ); 470 expandPix = SmallIcon( "1updownarrow" );
471 } else { 471 } else {
472 expandPix = SmallIcon("1leftrightarrow" ); 472 expandPix = SmallIcon("1leftrightarrow" );
473 } 473 }
474 474
475 QBoxLayout *topLayout = new QVBoxLayout(this); 475 QBoxLayout *topLayout = new QVBoxLayout(this);
476 476
477 // Create day name labels for agenda columns 477 // Create day name labels for agenda columns
478 // Create agenda splitter 478 // Create agenda splitter
479 479
480 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 480 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
481 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 481 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
482 topLayout->addWidget( mSplitterAgenda ); 482 topLayout->addWidget( mSplitterAgenda );
483 mAllDayFrame = new QHBox(mSplitterAgenda); 483 mAllDayFrame = new QHBox(mSplitterAgenda);
484 mAllDayFrame->setFocusPolicy(NoFocus); 484 mAllDayFrame->setFocusPolicy(NoFocus);
485 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 485 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
486 agendaFrame->setFocusPolicy(NoFocus); 486 agendaFrame->setFocusPolicy(NoFocus);
487 487
488 // Create all-day agenda widget 488 // Create all-day agenda widget
489 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 489 mDummyAllDayLeft = new QVBox( mAllDayFrame );
490 490
491 mExpandButton = new QPushButton(mDummyAllDayLeft); 491 mExpandButton = new QPushButton(mDummyAllDayLeft);
492 mExpandButton->setPixmap( expandPix ); 492 mExpandButton->setPixmap( expandPix );
493 int widebut = mExpandButton->sizeHint().width()+4; 493 int widebut = mExpandButton->sizeHint().width()+4;
494 int heibut = mExpandButton->sizeHint().height()+4; 494 int heibut = mExpandButton->sizeHint().height()+4;
495 if ( heibut > widebut ) 495 if ( heibut > widebut )
496 widebut = heibut ; 496 widebut = heibut ;
497 497
498 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 498 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
499 // QSizePolicy::Fixed ) ); 499 // QSizePolicy::Fixed ) );
500 mExpandButton->setFixedSize( widebut, widebut); 500 mExpandButton->setFixedSize( widebut, widebut);
501 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 501 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
502 mExpandButton->setFocusPolicy(NoFocus); 502 mExpandButton->setFocusPolicy(NoFocus);
503 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 503 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
504 mAllDayAgenda->setFocusPolicy(NoFocus); 504 mAllDayAgenda->setFocusPolicy(NoFocus);
505 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 505 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
506 506
507 // Create event context menu for all day agenda 507 // Create event context menu for all day agenda
508 mAllDayAgendaPopup = eventPopup(); 508 //mAllDayAgendaPopup = eventPopup();
509 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
510 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
511 509
512 // Create agenda frame 510 // Create agenda frame
513 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 511 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
514 // QHBox *agendaFrame = new QHBox(splitterAgenda); 512 // QHBox *agendaFrame = new QHBox(splitterAgenda);
515 513
516 // create event indicator bars 514 // create event indicator bars
517 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 515 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
518#ifndef DESKTOP_VERSION 516#ifndef DESKTOP_VERSION
519 // FIX 517 // FIX
520 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 518 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
521#endif 519#endif
522 mDayLabelsFrame = new QHBox(agendaFrame); 520 mDayLabelsFrame = new QHBox(agendaFrame);
523 //topLayout->addWidget(mDayLabelsFrame); 521 //topLayout->addWidget(mDayLabelsFrame);
524 mDayLabels = new QFrame (mDayLabelsFrame); 522 mDayLabels = new QFrame (mDayLabelsFrame);
525 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 523 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
526 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 524 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
527 agendaLayout->addWidget(mEventIndicatorTop,1,1); 525 agendaLayout->addWidget(mEventIndicatorTop,1,1);
528 526
529 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 527 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
530 agendaFrame); 528 agendaFrame);
531 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 529 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
532 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 530 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
533 agendaLayout->addWidget(dummyAgendaRight,1,2); 531 agendaLayout->addWidget(dummyAgendaRight,1,2);
534 532
535 // Create time labels 533 // Create time labels
536 mTimeLabels = new TimeLabels(24,agendaFrame); 534 mTimeLabels = new TimeLabels(24,agendaFrame);
537 agendaLayout->addWidget(mTimeLabels,2,0); 535 agendaLayout->addWidget(mTimeLabels,2,0);
538 connect(mTimeLabels,SIGNAL( scaleChanged()), 536 connect(mTimeLabels,SIGNAL( scaleChanged()),
539 this,SLOT(updateConfig())); 537 this,SLOT(updateConfig()));
540 538
541 // Create agenda 539 // Create agenda
542 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 540 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
543 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 541 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
544 agendaLayout->setColStretch(1,1); 542 agendaLayout->setColStretch(1,1);
545 mAgenda->setFocusPolicy(NoFocus); 543 mAgenda->setFocusPolicy(NoFocus);
546 // Create event context menu for agenda 544 // Create event context menu for agenda
547 mAgendaPopup = eventPopup(); 545 mAllAgendaPopup = eventPopup();
548 546
549 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 547 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
550 i18n("Toggle Alarm"),mAgenda, 548 i18n("Toggle Alarm"),mAgenda,
551 SLOT(popupAlarm()),true); 549 SLOT(popupAlarm()),true);
552 550
553 551
554 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 552 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
555 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 553 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
556 554
555 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
556 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
557 mAgenda->setPopup( mAllAgendaPopup );
558 mAllDayAgenda->setPopup( mAllAgendaPopup );
557 // make connections between dependent widgets 559 // make connections between dependent widgets
558 mTimeLabels->setAgenda(mAgenda); 560 mTimeLabels->setAgenda(mAgenda);
559 561
560 // Update widgets to reflect user preferences 562 // Update widgets to reflect user preferences
561 // updateConfig(); 563 // updateConfig();
562 564
563 // createDayLabels(); 565 // createDayLabels();
564 566
565 // these blank widgets make the All Day Event box line up with the agenda 567 // these blank widgets make the All Day Event box line up with the agenda
566 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 568 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
567 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 569 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
568 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 570 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
569 571
570 // Scrolling 572 // Scrolling
571 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 573 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
572 mTimeLabels, SLOT(positionChanged())); 574 mTimeLabels, SLOT(positionChanged()));
573 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 575 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
574 SLOT(setContentsPos(int))); 576 SLOT(setContentsPos(int)));
575 577
576 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 578 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
577 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 579 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
578 580
579 // Create/Show/Edit/Delete Event 581 // Create/Show/Edit/Delete Event
580 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 582 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
581 SLOT(newEvent(int,int))); 583 SLOT(newEvent(int,int)));
582 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 584 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
583 SLOT(newTodo(int,int))); 585 SLOT(newTodo(int,int)));
584 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 586 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
585 SLOT(newEvent(int,int,int,int))); 587 SLOT(newEvent(int,int,int,int)));
586 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 588 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
587 SLOT(newEventAllDay(int,int))); 589 SLOT(newEventAllDay(int,int)));
588 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 590 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
589 SLOT(newTodoAllDay(int,int))); 591 SLOT(newTodoAllDay(int,int)));
590 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 592 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
591 SLOT(newEventAllDay(int,int))); 593 SLOT(newEventAllDay(int,int)));
592 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 594 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
593 SLOT(newTimeSpanSelected(int,int,int,int))); 595 SLOT(newTimeSpanSelected(int,int,int,int)));
594 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 596 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
595 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 597 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
596 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 598 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
597 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 599 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
598 600
599 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 601 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
600 SIGNAL(editIncidenceSignal(Incidence *))); 602 SIGNAL(editIncidenceSignal(Incidence *)));
601 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 603 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
602 SIGNAL(editIncidenceSignal(Incidence *))); 604 SIGNAL(editIncidenceSignal(Incidence *)));
603 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 605 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
604 SIGNAL(showIncidenceSignal(Incidence *))); 606 SIGNAL(showIncidenceSignal(Incidence *)));
605 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 607 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
606 SIGNAL(showIncidenceSignal(Incidence *))); 608 SIGNAL(showIncidenceSignal(Incidence *)));
607 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 609 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
608 SIGNAL(deleteIncidenceSignal(Incidence *))); 610 SIGNAL(deleteIncidenceSignal(Incidence *)));
609 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 611 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
610 SIGNAL(deleteIncidenceSignal(Incidence *))); 612 SIGNAL(deleteIncidenceSignal(Incidence *)));
611 613
612 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 614 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
613 SLOT(updateEventDates(KOAgendaItem *, int ))); 615 SLOT(updateEventDates(KOAgendaItem *, int )));
614 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 616 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
615 SLOT(updateEventDates(KOAgendaItem *, int))); 617 SLOT(updateEventDates(KOAgendaItem *, int)));
616 618
617 // event indicator update 619 // event indicator update
618 connect(mAgenda,SIGNAL(lowerYChanged(int)), 620 connect(mAgenda,SIGNAL(lowerYChanged(int)),
619 SLOT(updateEventIndicatorTop(int))); 621 SLOT(updateEventIndicatorTop(int)));
620 connect(mAgenda,SIGNAL(upperYChanged(int)), 622 connect(mAgenda,SIGNAL(upperYChanged(int)),
621 SLOT(updateEventIndicatorBottom(int))); 623 SLOT(updateEventIndicatorBottom(int)));
622 // drag signals 624 // drag signals
623 /* 625 /*
624 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 626 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
625 SLOT(startDrag(Event *))); 627 SLOT(startDrag(Event *)));
626 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 628 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
627 SLOT(startDrag(Event *))); 629 SLOT(startDrag(Event *)));
628 */ 630 */
629 // synchronize selections 631 // synchronize selections
630 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 632 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
631 mAllDayAgenda, SLOT( deselectItem() ) ); 633 mAllDayAgenda, SLOT( deselectItem() ) );
632 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 634 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
633 mAgenda, SLOT( deselectItem() ) ); 635 mAgenda, SLOT( deselectItem() ) );
634 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 636 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
635 SIGNAL( incidenceSelected( Incidence * ) ) ); 637 SIGNAL( incidenceSelected( Incidence * ) ) );
636 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 638 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
637 SIGNAL( incidenceSelected( Incidence * ) ) ); 639 SIGNAL( incidenceSelected( Incidence * ) ) );
638 connect( mAgenda, SIGNAL( resizedSignal() ), 640 connect( mAgenda, SIGNAL( resizedSignal() ),
639 SLOT( updateConfig( ) ) ); 641 SLOT( updateConfig( ) ) );
640 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 642 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
641 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 643 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
642 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 644 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
643 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 645 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
644 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 646 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
645 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 647 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
646 648
647 649
648} 650}
649 651
650void KOAgendaView::toggleAllDay() 652void KOAgendaView::toggleAllDay()
651{ 653{
652 if ( mSplitterAgenda->firstHandle() ) 654 if ( mSplitterAgenda->firstHandle() )
653 mSplitterAgenda->firstHandle()->toggle(); 655 mSplitterAgenda->firstHandle()->toggle();
654} 656}
655void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 657void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
656{ 658{
657 calendar()->addIncidence( inc ); 659 calendar()->addIncidence( inc );
658 660
659 if ( incOld ) { 661 if ( incOld ) {
660 if ( incOld->type() == "Todo" ) 662 if ( incOld->type() == "Todo" )
661 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 663 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
662 else 664 else
663 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 665 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
664 } 666 }
665 667
666} 668}
667 669
668KOAgendaView::~KOAgendaView() 670KOAgendaView::~KOAgendaView()
669{ 671{
670 delete mAgendaPopup; 672 delete mAllAgendaPopup;
671 delete mAllDayAgendaPopup; 673 //delete mAllDayAgendaPopup;
672 delete KOAgendaItem::paintPix(); 674 delete KOAgendaItem::paintPix();
673 delete KOAgendaItem::paintPixSel(); 675 delete KOAgendaItem::paintPixSel();
674} 676}
675void KOAgendaView::resizeEvent( QResizeEvent* e ) 677void KOAgendaView::resizeEvent( QResizeEvent* e )
676{ 678{
677 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 679 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
678 bool uc = false; 680 bool uc = false;
679 int ow = e->oldSize().width(); 681 int ow = e->oldSize().width();
680 int oh = e->oldSize().height(); 682 int oh = e->oldSize().height();
681 int w = e->size().width(); 683 int w = e->size().width();
682 int h = e->size().height(); 684 int h = e->size().height();
683 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 685 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
684 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 686 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
685 uc = true; 687 uc = true;
686 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 688 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
687 } 689 }
688 mUpcomingWidth = e->size().width() ; 690 mUpcomingWidth = e->size().width() ;
689 if ( mBlockUpdating || uc ) { 691 if ( mBlockUpdating || uc ) {
690 mBlockUpdating = false; 692 mBlockUpdating = false;
691 //mAgenda->setMinimumSize(800 , 600 ); 693 //mAgenda->setMinimumSize(800 , 600 );
692 //qDebug("mAgenda->resize+++++++++++++++ "); 694 //qDebug("mAgenda->resize+++++++++++++++ ");
693 updateConfig(); 695 updateConfig();
694 //qDebug("KOAgendaView::Updating now possible "); 696 //qDebug("KOAgendaView::Updating now possible ");
695 } else 697 } else
696 createDayLabels(); 698 createDayLabels();
697 //qDebug("resizeEvent end "); 699 //qDebug("resizeEvent end ");
698 700
699} 701}
700void KOAgendaView::slotDaylabelClicked( int num ) 702void KOAgendaView::slotDaylabelClicked( int num )
701{ 703{
702 704
703 QDate firstDate = mSelectedDates.first(); 705 QDate firstDate = mSelectedDates.first();
704 if ( num == -1 ) 706 if ( num == -1 )
705 emit showDateView( 6, firstDate ); 707 emit showDateView( 6, firstDate );
706 else if (num >= 0 ) { 708 else if (num >= 0 ) {
707 if ( mSelectedDates.count() == 1) 709 if ( mSelectedDates.count() == 1)
708 emit showDateView( 9, firstDate.addDays( num ) ); 710 emit showDateView( 9, firstDate.addDays( num ) );
709 else 711 else
710 emit showDateView( 3, firstDate.addDays( num ) ); 712 emit showDateView( 3, firstDate.addDays( num ) );
711 } 713 }
712 else 714 else
713 showDateView( 10, firstDate.addDays(1) ); 715 showDateView( 10, firstDate.addDays(1) );
714} 716}
715 717
716KOAgendaButton* KOAgendaView::getNewDaylabel() 718KOAgendaButton* KOAgendaView::getNewDaylabel()
717{ 719{
718 720
719 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 721 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
720 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 722 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
721 mDayLabelsList.append( dayLabel ); 723 mDayLabelsList.append( dayLabel );
722 mLayoutDayLabels->addWidget(dayLabel); 724 mLayoutDayLabels->addWidget(dayLabel);
723 return dayLabel ; 725 return dayLabel ;
724} 726}
725 727
726void KOAgendaView::createDayLabels() 728void KOAgendaView::createDayLabels()
727{ 729{
728 730
729 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 731 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
730 // qDebug(" KOAgendaView::createDayLabels() blocked "); 732 // qDebug(" KOAgendaView::createDayLabels() blocked ");
731 return; 733 return;
732 734
733 } 735 }
734 int newHight; 736 int newHight;
735 737
736 // ### Before deleting and recreating we could check if mSelectedDates changed... 738 // ### Before deleting and recreating we could check if mSelectedDates changed...
737 // It would remove some flickering and gain speed (since this is called by 739 // It would remove some flickering and gain speed (since this is called by
738 // each updateView() call) 740 // each updateView() call)
739 741
740 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 742 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
741 if ( QApplication::desktop()->width() <= 320 ) 743 if ( QApplication::desktop()->width() <= 320 )
742 maxWid -= 10; 744 maxWid -= 10;
743 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 745 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
744 if ( maxWid < 0 ) 746 if ( maxWid < 0 )
745 maxWid = 20; 747 maxWid = 20;
746 748
747 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 749 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
748 QFontMetrics fm ( dlf ); 750 QFontMetrics fm ( dlf );
749 int selCount = mSelectedDates.count(); 751 int selCount = mSelectedDates.count();
750 QString dayTest = "Mon 20"; 752 QString dayTest = "Mon 20";
751 //QString dayTest = "Mon 20"; 753 //QString dayTest = "Mon 20";
752 int wid = fm.width( dayTest ); 754 int wid = fm.width( dayTest );
753 //maxWid -= ( selCount * 3 ); //working for QLabels 755 //maxWid -= ( selCount * 3 ); //working for QLabels
754 maxWid -= ( selCount * 3 ); //working for QPushButton 756 maxWid -= ( selCount * 3 ); //working for QPushButton
755 if ( maxWid < 0 ) 757 if ( maxWid < 0 )
756 maxWid = 20; 758 maxWid = 20;
757 int needWid = wid * selCount; 759 int needWid = wid * selCount;
758 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 760 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
759 //if ( needWid > maxWid ) 761 //if ( needWid > maxWid )
760 // qDebug("DAYLABELS TOOOOOOO BIG "); 762 // qDebug("DAYLABELS TOOOOOOO BIG ");
761 while ( needWid > maxWid ) { 763 while ( needWid > maxWid ) {
762 dayTest = dayTest.left( dayTest.length() - 1 ); 764 dayTest = dayTest.left( dayTest.length() - 1 );
763 wid = fm.width( dayTest ); 765 wid = fm.width( dayTest );
764 needWid = wid * selCount; 766 needWid = wid * selCount;
765 } 767 }
766 int maxLen = dayTest.length(); 768 int maxLen = dayTest.length();
767 int fontPoint = dlf.pointSize(); 769 int fontPoint = dlf.pointSize();
768 if ( maxLen < 2 ) { 770 if ( maxLen < 2 ) {
769 int fontPoint = dlf.pointSize(); 771 int fontPoint = dlf.pointSize();
770 while ( fontPoint > 4 ) { 772 while ( fontPoint > 4 ) {
771 --fontPoint; 773 --fontPoint;
772 dlf.setPointSize( fontPoint ); 774 dlf.setPointSize( fontPoint );
773 QFontMetrics f( dlf ); 775 QFontMetrics f( dlf );
774 wid = f.width( "30" ); 776 wid = f.width( "30" );
775 needWid = wid * selCount; 777 needWid = wid * selCount;
776 if ( needWid < maxWid ) 778 if ( needWid < maxWid )
777 break; 779 break;
778 } 780 }
779 maxLen = 2; 781 maxLen = 2;
780 } 782 }
781 //qDebug("Max len %d ", dayTest.length() ); 783 //qDebug("Max len %d ", dayTest.length() );
782 784
783 QFontMetrics tempF( dlf ); 785 QFontMetrics tempF( dlf );
784 newHight = tempF.height(); 786 newHight = tempF.height();
785 mDayLabels->setFont( dlf ); 787 mDayLabels->setFont( dlf );
786 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 788 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
787 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 789 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
788 //mLayoutDayLabels->addSpacing( 2 ); 790 //mLayoutDayLabels->addSpacing( 2 );
789 // QFont lFont = dlf; 791 // QFont lFont = dlf;
790 bool appendLabels = false; 792 bool appendLabels = false;
791 KOAgendaButton *dayLabel; 793 KOAgendaButton *dayLabel;
792 dayLabel = mDayLabelsList.first(); 794 dayLabel = mDayLabelsList.first();
793 if ( !dayLabel ) { 795 if ( !dayLabel ) {
794 appendLabels = true; 796 appendLabels = true;
795 dayLabel = getNewDaylabel(); 797 dayLabel = getNewDaylabel();
796 } 798 }
797 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 799 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
798 dayLabel->setFont( dlf ); 800 dayLabel->setFont( dlf );
799 dayLabel->setNum( -1 ); 801 dayLabel->setNum( -1 );
800 //dayLabel->setAlignment(QLabel::AlignHCenter); 802 //dayLabel->setAlignment(QLabel::AlignHCenter);
801#if 0 803#if 0
802 if ( QApplication::desktop()->width() <= 320 ) 804 if ( QApplication::desktop()->width() <= 320 )
803 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); 805 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
804 else 806 else
805#endif 807#endif
806 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 808 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
807 dayLabel->show(); 809 dayLabel->show();
808 DateList::ConstIterator dit; 810 DateList::ConstIterator dit;
809 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 811 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
810 int counter = -1; 812 int counter = -1;
811 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 813 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
812 ++counter; 814 ++counter;
813 QDate date = *dit; 815 QDate date = *dit;
814 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 816 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
815 if ( ! appendLabels ) { 817 if ( ! appendLabels ) {
816 dayLabel = mDayLabelsList.next(); 818 dayLabel = mDayLabelsList.next();
817 if ( !dayLabel ) 819 if ( !dayLabel )
818 appendLabels = true; 820 appendLabels = true;
819 } 821 }
820 if ( appendLabels ) { 822 if ( appendLabels ) {
821 dayLabel = getNewDaylabel(); 823 dayLabel = getNewDaylabel();
822 } 824 }
823 dayLabel->setMinimumWidth( 1 ); 825 dayLabel->setMinimumWidth( 1 );
824 dayLabel->setMaximumWidth( 10240 ); 826 dayLabel->setMaximumWidth( 10240 );
825 dayLabel->setFont( dlf ); 827 dayLabel->setFont( dlf );
826 dayLabel->show(); 828 dayLabel->show();
827 dayLabel->setAutoRepeat( false ); 829 dayLabel->setAutoRepeat( false );
828 dayLabel->setNum( counter ); 830 dayLabel->setNum( counter );
829 QString str; 831 QString str;
830 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 832 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
831 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 833 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
832 switch ( maxLen ) { 834 switch ( maxLen ) {
833 case 2: 835 case 2:
834 str = QString::number( date.day() ); 836 str = QString::number( date.day() );
835 break; 837 break;
836 838
837 case 3: 839 case 3:
838 str = dayName.left( 1 ) +QString::number( date.day()); 840 str = dayName.left( 1 ) +QString::number( date.day());
839 841
840 break; 842 break;
841 case 4: 843 case 4:
842 str = dayName.left( 1 ) + " " +QString::number( date.day()); 844 str = dayName.left( 1 ) + " " +QString::number( date.day());
843 845
844 break; 846 break;
845 case 5: 847 case 5:
846 str = dayName.left( 2 ) + " " +QString::number( date.day()); 848 str = dayName.left( 2 ) + " " +QString::number( date.day());
847 849
848 break; 850 break;
849 case 6: 851 case 6:
850 str = dayName.left( 3 ) + " " +QString::number( date.day()); 852 str = dayName.left( 3 ) + " " +QString::number( date.day());
851 break; 853 break;
852 854
853 default: 855 default:
854 break; 856 break;
855 } 857 }
856 if ( oneday ) { 858 if ( oneday ) {
857 QString addString; 859 QString addString;
858 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 860 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
859 addString = i18n("Today"); 861 addString = i18n("Today");
860 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 862 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
861 addString = i18n("Tomorrow"); 863 addString = i18n("Tomorrow");
862 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 864 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
863 addString = i18n("Yesterday"); 865 addString = i18n("Yesterday");
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 30c9b05..c6e6602 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -82,211 +82,211 @@ class TimeLabels : public QScrollView {
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 KOAgenda *agenda() { return mAgenda;} 169 KOAgenda *agenda() { return mAgenda;}
170 virtual void printPreview(CalPrinter *calPrinter, 170 virtual void printPreview(CalPrinter *calPrinter,
171 const QDate &, const QDate &); 171 const QDate &, const QDate &);
172 172
173 /** start-datetime of selection */ 173 /** start-datetime of selection */
174 QDateTime selectionStart() {return mTimeSpanBegin;} 174 QDateTime selectionStart() {return mTimeSpanBegin;}
175 /** end-datetime of selection */ 175 /** end-datetime of selection */
176 QDateTime selectionEnd() {return mTimeSpanEnd;} 176 QDateTime selectionEnd() {return mTimeSpanEnd;}
177 /** returns true if selection is for whole day */ 177 /** returns true if selection is for whole day */
178 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 178 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
179 /** make selected start/end invalid */ 179 /** make selected start/end invalid */
180 void deleteSelectedDateTime(); 180 void deleteSelectedDateTime();
181 void repaintAgenda(); 181 void repaintAgenda();
182 public slots: 182 public slots:
183 void setInitStartHour(); 183 void setInitStartHour();
184 virtual void updateView(); 184 virtual void updateView();
185 virtual void updateConfig(); 185 virtual void updateConfig();
186 virtual void showDates(const QDate &start, const QDate &end); 186 virtual void showDates(const QDate &start, const QDate &end);
187 virtual void showEvents(QPtrList<Event> eventList); 187 virtual void showEvents(QPtrList<Event> eventList);
188 188
189 void updateTodo( Todo *, int ); 189 void updateTodo( Todo *, int );
190 void changeEventDisplay(Event *, int); 190 void changeEventDisplay(Event *, int);
191 191
192 void clearSelection(); 192 void clearSelection();
193 193
194 void newTodo(int gx,int gy); 194 void newTodo(int gx,int gy);
195 void newEvent(int gx,int gy); 195 void newEvent(int gx,int gy);
196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
197 void newEventAllDay(int gx, int gy); 197 void newEventAllDay(int gx, int gy);
198 void newTodoAllDay(int gx, int gy); 198 void newTodoAllDay(int gx, int gy);
199 199
200 void startDrag(Event *); 200 void startDrag(Event *);
201 201
202 void readSettings(); 202 void readSettings();
203 void readSettings(KConfig *); 203 void readSettings(KConfig *);
204 void writeSettings(KConfig *); 204 void writeSettings(KConfig *);
205 205
206 void setContentsPos(int y); 206 void setContentsPos(int y);
207 207
208 void scrollOneHourUp(); 208 void scrollOneHourUp();
209 void scrollOneHourDown(); 209 void scrollOneHourDown();
210 void addToCalSlot(Incidence *, Incidence *); 210 void addToCalSlot(Incidence *, Incidence *);
211 void slotShowDateView( int, int ); 211 void slotShowDateView( int, int );
212 212
213 signals: 213 signals:
214 void showDateView( int, QDate ); 214 void showDateView( int, QDate );
215 void newTodoSignal( QDateTime ,bool ); 215 void newTodoSignal( QDateTime ,bool );
216 void toggleExpand(); 216 void toggleExpand();
217 void selectWeekNum( int ); 217 void selectWeekNum( int );
218 void todoMoved( Todo *, int ); 218 void todoMoved( Todo *, int );
219 void incidenceChanged(Incidence * , int ); 219 void incidenceChanged(Incidence * , int );
220 // void cloneIncidenceSignal(Incidence *); 220 // void cloneIncidenceSignal(Incidence *);
221 221
222 protected: 222 protected:
223 KOAgendaButton* getNewDaylabel(); 223 KOAgendaButton* getNewDaylabel();
224 bool mBlockUpdating; 224 bool mBlockUpdating;
225 int mUpcomingWidth; 225 int mUpcomingWidth;
226 /** Fill agenda beginning with date startDate */ 226 /** Fill agenda beginning with date startDate */
227 void fillAgenda(const QDate &startDate); 227 void fillAgenda(const QDate &startDate);
228 void resizeEvent( QResizeEvent* e ); 228 void resizeEvent( QResizeEvent* e );
229 /** Fill agenda using the current set value for the start date */ 229 /** Fill agenda using the current set value for the start date */
230 void fillAgenda(); 230 void fillAgenda();
231 231
232 /** Create labels for the selected dates. */ 232 /** Create labels for the selected dates. */
233 void createDayLabels(); 233 void createDayLabels();
234 234
235 /** 235 /**
236 Set the masks on the agenda widgets indicating, which days are holidays. 236 Set the masks on the agenda widgets indicating, which days are holidays.
237 */ 237 */
238 void setHolidayMasks(); 238 void setHolidayMasks();
239 239
240 protected slots: 240 protected slots:
241 void slotDaylabelClicked( int ); 241 void slotDaylabelClicked( int );
242 /** Update event belonging to agenda item */ 242 /** Update event belonging to agenda item */
243 void updateEventDates(KOAgendaItem *item, int mode = -1); 243 void updateEventDates(KOAgendaItem *item, int mode = -1);
244 //void updateMovedTodo(); 244 //void updateMovedTodo();
245 245
246 void updateEventIndicatorTop(int newY); 246 void updateEventIndicatorTop(int newY);
247 void updateEventIndicatorBottom(int newY); 247 void updateEventIndicatorBottom(int newY);
248 248
249 /** Updates data for selected timespan */ 249 /** Updates data for selected timespan */
250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
251 /** Updates data for selected timespan for all day event*/ 251 /** Updates data for selected timespan for all day event*/
252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
253 253
254 private: 254 private:
255 // view widgets 255 // view widgets
256 QFrame *mDayLabels; 256 QFrame *mDayLabels;
257 QHBox *mDayLabelsFrame; 257 QHBox *mDayLabelsFrame;
258 QBoxLayout *mLayoutDayLabels; 258 QBoxLayout *mLayoutDayLabels;
259 QFrame *mAllDayFrame; 259 QFrame *mAllDayFrame;
260 KOAgenda *mAllDayAgenda; 260 KOAgenda *mAllDayAgenda;
261 KOAgenda *mAgenda; 261 KOAgenda *mAgenda;
262 TimeLabels *mTimeLabels; 262 TimeLabels *mTimeLabels;
263 QWidget *mDummyAllDayLeft; 263 QWidget *mDummyAllDayLeft;
264 264
265 KDGanttMinimizeSplitter* mSplitterAgenda; 265 KDGanttMinimizeSplitter* mSplitterAgenda;
266 QPushButton *mExpandButton; 266 QPushButton *mExpandButton;
267 267
268 DateList mSelectedDates; // List of dates to be displayed 268 DateList mSelectedDates; // List of dates to be displayed
269 int mViewType; 269 int mViewType;
270 270
271 bool mWeekStartsMonday; 271 bool mWeekStartsMonday;
272 int mStartHour; 272 int mStartHour;
273 273
274 KOEventPopupMenu *mAgendaPopup; 274 KOEventPopupMenu *mAllAgendaPopup;
275 KOEventPopupMenu *mAllDayAgendaPopup; 275 //KOEventPopupMenu *mAllDayAgendaPopup;
276 276
277 EventIndicator *mEventIndicatorTop; 277 EventIndicator *mEventIndicatorTop;
278 EventIndicator *mEventIndicatorBottom; 278 EventIndicator *mEventIndicatorBottom;
279 279
280 QMemArray<int> mMinY; 280 QMemArray<int> mMinY;
281 QMemArray<int> mMaxY; 281 QMemArray<int> mMaxY;
282 282
283 QMemArray<bool> mHolidayMask; 283 QMemArray<bool> mHolidayMask;
284 284
285 QPtrList<KOAgendaButton> mDayLabelsList; 285 QPtrList<KOAgendaButton> mDayLabelsList;
286 QDateTime mTimeSpanBegin; 286 QDateTime mTimeSpanBegin;
287 QDateTime mTimeSpanEnd; 287 QDateTime mTimeSpanEnd;
288 bool mTimeSpanInAllDay; 288 bool mTimeSpanInAllDay;
289 void keyPressEvent ( QKeyEvent * e ); 289 void keyPressEvent ( QKeyEvent * e );
290}; 290};
291 291
292#endif // KOAGENDAVIEW_H 292#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ccc4b01..0a315cb 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -18,403 +18,414 @@
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qvbox.h> 29#include <qvbox.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include "koprefs.h" 31#include "koprefs.h"
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 44#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#else 47#else
48#include <qapplication.h> 48#include <qapplication.h>
49#endif 49#endif
50#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
51#include "calprinter.h" 51#include "calprinter.h"
52#endif 52#endif
53#include "docprefs.h" 53#include "docprefs.h"
54 54
55#include "kotodoview.h" 55#include "kotodoview.h"
56using namespace KOrg; 56using namespace KOrg;
57 57
58 58
59class KOTodoViewWhatsThis :public QWhatsThis 59class KOTodoViewWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& p) 65 virtual QString text( const QPoint& p)
66 { 66 {
67 return _view->getWhatsThisText(p) ; 67 return _view->getWhatsThisText(p) ;
68 } 68 }
69private: 69private:
70 QWidget* _wid; 70 QWidget* _wid;
71 KOTodoView * _view; 71 KOTodoView * _view;
72}; 72};
73 73
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 75 const char *name) :
76 KListView(parent,name) 76 KListView(parent,name)
77{ 77{
78 mName = QString ( name ); 78 mName = QString ( name );
79 mCalendar = calendar; 79 mCalendar = calendar;
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mOldCurrent = 0; 83 mOldCurrent = 0;
84 mMousePressed = false; 84 mMousePressed = false;
85 85
86 setAcceptDrops(true); 86 setAcceptDrops(true);
87 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
88 int size = 16; 88 int size = 16;
89 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
90 size = 12; 90 size = 12;
91 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
92 92
93} 93}
94 94
95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
96{ 96{
97#ifndef KORG_NODND 97#ifndef KORG_NODND
98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
100 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
101 e->ignore(); 101 e->ignore();
102 return; 102 return;
103 } 103 }
104 104
105 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
106#endif 106#endif
107} 107}
108 108
109 109
110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
111{ 111{
112#ifndef KORG_NODND 112#ifndef KORG_NODND
113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
165 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210
211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p);
213 bool rootClicked = true;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 int X = p.x();
218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
219 if (X > header()->sectionPos(0) +
220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
221 itemMargin() ||
222 X < header()->sectionPos(0)) {
223 rootClicked = false;
224 }
225 }
210#ifndef KORG_NODND 226#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 227 mMousePressed = false;
212 QListViewItem *i = itemAt(p); 228 if (! rootClicked ) {
213 mMousePressed = false;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 229 mPressPos = e->pos();
223 mMousePressed = true; 230 mMousePressed = true;
224 }
225 } 231 }
226 }
227#endif 232#endif
228 QListView::contentsMousePressEvent(e); 233 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
234#ifndef DESKTOP_VERSION
235 if (!( e->button() == RightButton && rootClicked) )
236 QListView::contentsMousePressEvent(e);
237#else
238 QListView::contentsMousePressEvent(e);
239#endif
229} 240}
230void KOTodoListView::paintEvent(QPaintEvent* e) 241void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 242{
232 emit paintNeeded(); 243 emit paintNeeded();
233 QListView::paintEvent( e); 244 QListView::paintEvent( e);
234} 245}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 246void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 247{
237 248
238#ifndef KORG_NODND 249#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 250 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 251 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 252 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 253 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 254 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 255 if (item) {
245 DndFactory factory( mCalendar ); 256 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 257 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 258 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 259 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 260 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 261 if (vd->drag()) {
251 if ( !internalDrop ) { 262 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 263 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 264 qDebug("Dnd: External move: Delete drag source ");
254 } else 265 } else
255 qDebug("Dnd: Internal move "); 266 qDebug("Dnd: Internal move ");
256 267
257 } else { 268 } else {
258 if ( !internalDrop ) { 269 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 270 qDebug("Dnd: External Copy");
260 } else 271 } else
261 qDebug("DnD: Internal copy: Copy pending"); 272 qDebug("DnD: Internal copy: Copy pending");
262 } 273 }
263 } 274 }
264 } 275 }
265#endif 276#endif
266} 277}
267void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 278void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
268{ 279{
269 if ( !e->isAutoRepeat() ) { 280 if ( !e->isAutoRepeat() ) {
270 mFlagKeyPressed = false; 281 mFlagKeyPressed = false;
271 } 282 }
272} 283}
273 284
274 285
275void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 286void KOTodoListView::keyPressEvent ( QKeyEvent * e )
276{ 287{
277 qApp->processEvents(); 288 qApp->processEvents();
278 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 289 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
279 e->ignore(); 290 e->ignore();
280 // qDebug(" ignore %d",e->isAutoRepeat() ); 291 // qDebug(" ignore %d",e->isAutoRepeat() );
281 return; 292 return;
282 } 293 }
283 if (! e->isAutoRepeat() ) 294 if (! e->isAutoRepeat() )
284 mFlagKeyPressed = true; 295 mFlagKeyPressed = true;
285 QListViewItem* cn; 296 QListViewItem* cn;
286 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 297 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
287 cn = currentItem(); 298 cn = currentItem();
288 if ( cn ) { 299 if ( cn ) {
289 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 300 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
290 if ( ci ){ 301 if ( ci ){
291 if ( e->state() == ShiftButton ) 302 if ( e->state() == ShiftButton )
292 ci->setOn( false ); 303 ci->setOn( false );
293 else 304 else
294 ci->setOn( true ); 305 ci->setOn( true );
295 cn = cn->itemBelow(); 306 cn = cn->itemBelow();
296 if ( cn ) { 307 if ( cn ) {
297 setCurrentItem ( cn ); 308 setCurrentItem ( cn );
298 ensureItemVisible ( cn ); 309 ensureItemVisible ( cn );
299 } 310 }
300 311
301 } 312 }
302 } 313 }
303 314
304 return; 315 return;
305 } 316 }
306 317
307 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 318 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
308 switch ( e->key() ) { 319 switch ( e->key() ) {
309 case Qt::Key_Down: 320 case Qt::Key_Down:
310 case Qt::Key_Up: 321 case Qt::Key_Up:
311 QListView::keyPressEvent ( e ); 322 QListView::keyPressEvent ( e );
312 break; 323 break;
313 case Qt::Key_Left: 324 case Qt::Key_Left:
314 case Qt::Key_Right: 325 case Qt::Key_Right:
315 QListView::keyPressEvent ( e ); 326 QListView::keyPressEvent ( e );
316 e->accept(); 327 e->accept();
317 return; 328 return;
318 break; 329 break;
319 default: 330 default:
320 e->ignore(); 331 e->ignore();
321 break; 332 break;
322 } 333 }
323 return; 334 return;
324 } 335 }
325 e->ignore(); 336 e->ignore();
326} 337}
327void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 338void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
328{ 339{
329 QListView::contentsMouseReleaseEvent(e); 340 QListView::contentsMouseReleaseEvent(e);
330 mMousePressed = false; 341 mMousePressed = false;
331} 342}
332 343
333void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 344void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
334{ 345{
335 if (!e) return; 346 if (!e) return;
336 347
337 QPoint vp = contentsToViewport(e->pos()); 348 QPoint vp = contentsToViewport(e->pos());
338 349
339 QListViewItem *item = itemAt(vp); 350 QListViewItem *item = itemAt(vp);
340 351
341 emit double_Clicked(item); 352 emit double_Clicked(item);
342 if (!item) return; 353 if (!item) return;
343 354
344 emit doubleClicked(item,vp,0); 355 emit doubleClicked(item,vp,0);
345} 356}
346 357
347///////////////////////////////////////////////////////////////////////////// 358/////////////////////////////////////////////////////////////////////////////
348 359
349KOQuickTodo::KOQuickTodo(QWidget *parent) : 360KOQuickTodo::KOQuickTodo(QWidget *parent) :
350 QLineEdit(parent) 361 QLineEdit(parent)
351{ 362{
352 setText(i18n("Click to add a new Todo")); 363 setText(i18n("Click to add a new Todo"));
353} 364}
354 365
355void KOQuickTodo::focusInEvent(QFocusEvent *ev) 366void KOQuickTodo::focusInEvent(QFocusEvent *ev)
356{ 367{
357 if ( text()==i18n("Click to add a new Todo") ) 368 if ( text()==i18n("Click to add a new Todo") )
358 setText(""); 369 setText("");
359 QLineEdit::focusInEvent(ev); 370 QLineEdit::focusInEvent(ev);
360} 371}
361 372
362void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 373void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
363{ 374{
364 setText(i18n("Click to add a new Todo")); 375 setText(i18n("Click to add a new Todo"));
365 QLineEdit::focusOutEvent(ev); 376 QLineEdit::focusOutEvent(ev);
366} 377}
367 378
368///////////////////////////////////////////////////////////////////////////// 379/////////////////////////////////////////////////////////////////////////////
369 380
370KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 381KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
371 KOrg::BaseView(calendar,parent,name) 382 KOrg::BaseView(calendar,parent,name)
372{ 383{
373 mPendingUpdateBeforeRepaint = false; 384 mPendingUpdateBeforeRepaint = false;
374 isFlatDisplay = false; 385 isFlatDisplay = false;
375 mNavigator = 0; 386 mNavigator = 0;
376 QBoxLayout *topLayout = new QVBoxLayout(this); 387 QBoxLayout *topLayout = new QVBoxLayout(this);
377 mName = QString ( name ); 388 mName = QString ( name );
378 mBlockUpdate = false; 389 mBlockUpdate = false;
379 mQuickAdd = new KOQuickTodo(this); 390 mQuickAdd = new KOQuickTodo(this);
380 topLayout->addWidget(mQuickAdd); 391 topLayout->addWidget(mQuickAdd);
381 392
382 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 393 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
383 394
384 mTodoListView = new KOTodoListView(calendar,this, name ); 395 mTodoListView = new KOTodoListView(calendar,this, name );
385 topLayout->addWidget(mTodoListView); 396 topLayout->addWidget(mTodoListView);
386 //mTodoListView->header()->setMaximumHeight(30); 397 //mTodoListView->header()->setMaximumHeight(30);
387 mTodoListView->setRootIsDecorated(true); 398 mTodoListView->setRootIsDecorated(true);
388 mTodoListView->setAllColumnsShowFocus(true); 399 mTodoListView->setAllColumnsShowFocus(true);
389 400
390 mTodoListView->setShowSortIndicator(true); 401 mTodoListView->setShowSortIndicator(true);
391 402
392 mTodoListView->addColumn(i18n("Todo")); 403 mTodoListView->addColumn(i18n("Todo"));
393 mTodoListView->addColumn(i18n("Prio")); 404 mTodoListView->addColumn(i18n("Prio"));
394 mTodoListView->setColumnAlignment(1,AlignHCenter); 405 mTodoListView->setColumnAlignment(1,AlignHCenter);
395 mTodoListView->addColumn(i18n("Complete")); 406 mTodoListView->addColumn(i18n("Complete"));
396 mTodoListView->setColumnAlignment(2,AlignCenter); 407 mTodoListView->setColumnAlignment(2,AlignCenter);
397 408
398 mTodoListView->addColumn(i18n("Due Date")); 409 mTodoListView->addColumn(i18n("Due Date"));
399 mTodoListView->setColumnAlignment(3,AlignLeft); 410 mTodoListView->setColumnAlignment(3,AlignLeft);
400 mTodoListView->addColumn(i18n("Due Time")); 411 mTodoListView->addColumn(i18n("Due Time"));
401 mTodoListView->setColumnAlignment(4,AlignHCenter); 412 mTodoListView->setColumnAlignment(4,AlignHCenter);
402 413
403 mTodoListView->addColumn(i18n("Start Date")); 414 mTodoListView->addColumn(i18n("Start Date"));
404 mTodoListView->setColumnAlignment(5,AlignLeft); 415 mTodoListView->setColumnAlignment(5,AlignLeft);
405 mTodoListView->addColumn(i18n("Start Time")); 416 mTodoListView->addColumn(i18n("Start Time"));
406 mTodoListView->setColumnAlignment(6,AlignHCenter); 417 mTodoListView->setColumnAlignment(6,AlignHCenter);
407 418
408 mTodoListView->addColumn(i18n("Cancelled")); 419 mTodoListView->addColumn(i18n("Cancelled"));
409 mTodoListView->addColumn(i18n("Categories")); 420 mTodoListView->addColumn(i18n("Categories"));
410#if 0 421#if 0
411 mTodoListView->addColumn(i18n("Sort Id")); 422 mTodoListView->addColumn(i18n("Sort Id"));
412 mTodoListView->setColumnAlignment(4,AlignHCenter); 423 mTodoListView->setColumnAlignment(4,AlignHCenter);
413#endif 424#endif
414 425
415 mTodoListView->setMinimumHeight( 60 ); 426 mTodoListView->setMinimumHeight( 60 );
416 mTodoListView->setItemsRenameable( true ); 427 mTodoListView->setItemsRenameable( true );
417 mTodoListView->setRenameable( 0 ); 428 mTodoListView->setRenameable( 0 );
418 mTodoListView->setColumnWidth( 0, 120 ); 429 mTodoListView->setColumnWidth( 0, 120 );
419 mTodoListView->setColumnWidthMode(0, QListView::Manual); 430 mTodoListView->setColumnWidthMode(0, QListView::Manual);
420 mTodoListView->setColumnWidthMode(1, QListView::Manual); 431 mTodoListView->setColumnWidthMode(1, QListView::Manual);
@@ -874,396 +885,404 @@ void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
874 const QDate &td) 885 const QDate &td)
875{ 886{
876#ifndef KORG_NOPRINTER 887#ifndef KORG_NOPRINTER
877 calPrinter->preview(CalPrinter::Todolist, fd, td); 888 calPrinter->preview(CalPrinter::Todolist, fd, td);
878#endif 889#endif
879} 890}
880 891
881void KOTodoView::editItem(QListViewItem *item ) 892void KOTodoView::editItem(QListViewItem *item )
882{ 893{
883 // qDebug("editItem(QListViewItem *item ) "); 894 // qDebug("editItem(QListViewItem *item ) ");
884 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 895 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
885} 896}
886 897
887void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 898void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
888{ 899{
889 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 900 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
890} 901}
891 902
892void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 903void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
893{ 904{
894 pendingSubtodo = 0; 905 pendingSubtodo = 0;
895 mActiveItem = (KOTodoViewItem *)item; 906 mActiveItem = (KOTodoViewItem *)item;
896 if (item) { 907 if (item) {
897 switch (column){ 908 switch (column){
898 case 1: 909 case 1:
899 mPriorityPopupMenu->popup(QCursor::pos ()); break; 910 mPriorityPopupMenu->popup(QCursor::pos ()); break;
900 case 2: 911 case 2:
901 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 912 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
902 case 3: 913 case 3:
903 moveTodo(); 914 moveTodo();
904 break; 915 break;
905 case 8: 916 case 8:
906 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 917 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
907 default: 918 default:
908 mItemPopupMenu->popup(QCursor::pos()); 919 mItemPopupMenu->popup(QCursor::pos());
909 } 920 }
910 } else mPopupMenu->popup(QCursor::pos()); 921 } else mPopupMenu->popup(QCursor::pos());
911} 922}
912void KOTodoView::newTodo() 923void KOTodoView::newTodo()
913{ 924{
914 emit newTodoSignal(); 925 emit newTodoSignal();
915} 926}
916 927
917void KOTodoView::newSubTodo() 928void KOTodoView::newSubTodo()
918{ 929{
919 if (mActiveItem) { 930 if (mActiveItem) {
920 emit newSubTodoSignal(mActiveItem->todo()); 931 emit newSubTodoSignal(mActiveItem->todo());
921 } 932 }
922} 933}
923void KOTodoView::unparentTodo() 934void KOTodoView::unparentTodo()
924{ 935{
925 if (mActiveItem) { 936 if (mActiveItem) {
926 emit unparentTodoSignal(mActiveItem->todo()); 937 emit unparentTodoSignal(mActiveItem->todo());
927 } 938 }
928} 939}
929 940
930void KOTodoView::reparentTodo() 941void KOTodoView::reparentTodo()
931{ 942{
932 if (mActiveItem) { 943 if (mActiveItem) {
933 qDebug("KOTodoView::reparentTodo() "); 944 qDebug("KOTodoView::reparentTodo() ");
934 topLevelWidget()->setCaption(i18n("Click on new parent item")); 945 topLevelWidget()->setCaption(i18n("Click on new parent item"));
935 pendingSubtodo = mActiveItem; 946 pendingSubtodo = mActiveItem;
936 } 947 }
937} 948}
938void KOTodoView::editTodo() 949void KOTodoView::editTodo()
939{ 950{
940 if (mActiveItem) { 951 if (mActiveItem) {
941 emit editTodoSignal(mActiveItem->todo()); 952 emit editTodoSignal(mActiveItem->todo());
942 } 953 }
943} 954}
944void KOTodoView::cloneTodo() 955void KOTodoView::cloneTodo()
945{ 956{
946 if (mActiveItem) { 957 if (mActiveItem) {
947 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 958 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
948 } 959 }
949} 960}
950void KOTodoView::cancelTodo() 961void KOTodoView::cancelTodo()
951{ 962{
952 if (mActiveItem) { 963 if (mActiveItem) {
953 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 964 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
954 } 965 }
955} 966}
956void KOTodoView::moveTodo() 967void KOTodoView::moveTodo()
957{ 968{
958 if (mActiveItem) { 969 if (mActiveItem) {
959 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 970 emit moveTodoSignal((Incidence*)mActiveItem->todo());
960 } 971 }
961} 972}
962void KOTodoView::beamTodo() 973void KOTodoView::beamTodo()
963{ 974{
964 if (mActiveItem) { 975 if (mActiveItem) {
965 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 976 emit beamTodoSignal((Incidence*)mActiveItem->todo());
966 } 977 }
967} 978}
968 979
969 980
970void KOTodoView::showTodo() 981void KOTodoView::showTodo()
971{ 982{
972 if (mActiveItem) { 983 if (mActiveItem) {
973 emit showTodoSignal(mActiveItem->todo()); 984 emit showTodoSignal(mActiveItem->todo());
974 } 985 }
975} 986}
976 987
977void KOTodoView::deleteTodo() 988void KOTodoView::deleteTodo()
978{ 989{
979 if (mActiveItem) { 990 if (mActiveItem) {
980 emit deleteTodoSignal(mActiveItem->todo()); 991 emit deleteTodoSignal(mActiveItem->todo());
981 } 992 }
982} 993}
983 994
984void KOTodoView::setNewPriority(int index) 995void KOTodoView::setNewPriority(int index)
985{ 996{
986 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 997 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
987 mActiveItem->todo()->setPriority(mPriority[index]); 998 mActiveItem->todo()->setPriority(mPriority[index]);
988 mActiveItem->construct(); 999 mActiveItem->construct();
989 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1000 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
990 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1001 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
991 } 1002 }
992} 1003}
993 1004
994void KOTodoView::setNewPercentage(int index) 1005void KOTodoView::setNewPercentage(int index)
995{ 1006{
996 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1007 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
997 1008
998 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1009 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
999 mActiveItem->setOn( true ); 1010 mActiveItem->setOn( true );
1000 return; 1011 return;
1001 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1012 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1002 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1013 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1003 if ( par && par->isOn() ) 1014 if ( par && par->isOn() )
1004 par->setOn( false ); 1015 par->setOn( false );
1005 } 1016 }
1006 if (mPercentage[index] == 100) { 1017 if (mPercentage[index] == 100) {
1007 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1018 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1008 } else { 1019 } else {
1009 mActiveItem->todo()->setCompleted(false); 1020 mActiveItem->todo()->setCompleted(false);
1010 } 1021 }
1011 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1022 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1012 mActiveItem->construct(); 1023 mActiveItem->construct();
1013 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1024 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1014 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1025 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1015 } 1026 }
1016} 1027}
1017 1028
1018 1029
1019QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1030QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1020{ 1031{
1021 QPopupMenu* tempMenu = new QPopupMenu (this); 1032 QPopupMenu* tempMenu = new QPopupMenu (this);
1022 QStringList checkedCategories = todoItem->todo()->categories (); 1033 QStringList checkedCategories = todoItem->todo()->categories ();
1023 1034
1024 tempMenu->setCheckable (true); 1035 tempMenu->setCheckable (true);
1025 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1036 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1026 it != KOPrefs::instance()->mCustomCategories.end (); 1037 it != KOPrefs::instance()->mCustomCategories.end ();
1027 ++it) { 1038 ++it) {
1028 int index = tempMenu->insertItem (*it); 1039 int index = tempMenu->insertItem (*it);
1029 mCategory[index] = *it; 1040 mCategory[index] = *it;
1030 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1041 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1031 } 1042 }
1032 1043
1033 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1044 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1034 return tempMenu; 1045 return tempMenu;
1035 1046
1036 1047
1037} 1048}
1038void KOTodoView::changedCategories(int index) 1049void KOTodoView::changedCategories(int index)
1039{ 1050{
1040 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1051 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1041 QStringList categories = mActiveItem->todo()->categories (); 1052 QStringList categories = mActiveItem->todo()->categories ();
1042 QString colcat = categories.first(); 1053 QString colcat = categories.first();
1043 if (categories.find (mCategory[index]) != categories.end ()) 1054 if (categories.find (mCategory[index]) != categories.end ())
1044 categories.remove (mCategory[index]); 1055 categories.remove (mCategory[index]);
1045 else 1056 else
1046 categories.insert (categories.end(), mCategory[index]); 1057 categories.insert (categories.end(), mCategory[index]);
1047 categories.sort (); 1058 categories.sort ();
1048 if ( !colcat.isEmpty() ) { 1059 if ( !colcat.isEmpty() ) {
1049 if ( categories.find ( colcat ) != categories.end () ) { 1060 if ( categories.find ( colcat ) != categories.end () ) {
1050 categories.remove( colcat ); 1061 categories.remove( colcat );
1051 categories.prepend( colcat ); 1062 categories.prepend( colcat );
1052 } 1063 }
1053 } 1064 }
1054 mActiveItem->todo()->setCategories (categories); 1065 mActiveItem->todo()->setCategories (categories);
1055 mActiveItem->construct(); 1066 mActiveItem->construct();
1056 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1067 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1057 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1068 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1058 } 1069 }
1059} 1070}
1060void KOTodoView::itemDoubleClicked(QListViewItem *item) 1071void KOTodoView::itemDoubleClicked(QListViewItem *item)
1061{ 1072{
1062 if ( pendingSubtodo != 0 ) { 1073 if ( pendingSubtodo != 0 ) {
1063 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1074 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1064 } 1075 }
1065 pendingSubtodo = 0; 1076 pendingSubtodo = 0;
1077 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1078 //qDebug("ROW %d ", row);
1066 if (!item) { 1079 if (!item) {
1067 newTodo(); 1080 newTodo();
1068 return; 1081 return;
1082 } else {
1083 if ( row == 1 ) {
1084 mActiveItem = (KOTodoViewItem *) item;
1085 newSubTodo();
1086 return;
1087 }
1069 } 1088 }
1070 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1089 if ( KOPrefs::instance()->mEditOnDoubleClick )
1071 editItem( item ); 1090 editItem( item );
1072 else 1091 else
1073 showItem( item , QPoint(), 0 ); 1092 showItem( item , QPoint(), 0 );
1074} 1093}
1075void KOTodoView::itemClicked(QListViewItem *item) 1094void KOTodoView::itemClicked(QListViewItem *item)
1076{ 1095{
1077 1096 //qDebug("KOTodoView::itemClicked %d", item);
1078 if (!item) { 1097 if (!item) {
1079 if ( pendingSubtodo != 0 ) { 1098 if ( pendingSubtodo != 0 ) {
1080 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1099 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1081 } 1100 }
1082 pendingSubtodo = 0; 1101 pendingSubtodo = 0;
1083 return; 1102 return;
1084 } 1103 }
1085 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1104 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1086 if ( pendingSubtodo != 0 ) { 1105 if ( pendingSubtodo != 0 ) {
1087 bool allowReparent = true; 1106 bool allowReparent = true;
1088 QListViewItem *par = item; 1107 QListViewItem *par = item;
1089 while ( par ) { 1108 while ( par ) {
1090 if ( par == pendingSubtodo ) { 1109 if ( par == pendingSubtodo ) {
1091 allowReparent = false; 1110 allowReparent = false;
1092 break; 1111 break;
1093 } 1112 }
1094 par = par->parent(); 1113 par = par->parent();
1095 } 1114 }
1096 if ( !allowReparent ) { 1115 if ( !allowReparent ) {
1097 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1116 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1098 qDebug("Recursive reparenting not possible "); 1117 qDebug("Recursive reparenting not possible ");
1099 pendingSubtodo = 0; 1118 pendingSubtodo = 0;
1100 } else { 1119 } else {
1101 Todo* newParent = todoItem->todo(); 1120 Todo* newParent = todoItem->todo();
1102 Todo* newSub = pendingSubtodo->todo(); 1121 Todo* newSub = pendingSubtodo->todo();
1103 pendingSubtodo = 0; 1122 pendingSubtodo = 0;
1104 emit reparentTodoSignal( newParent,newSub ); 1123 emit reparentTodoSignal( newParent,newSub );
1105 return; 1124 return;
1106 } 1125 }
1107 } 1126 }
1108#if 0 1127#if 0
1109 // handled by the item itself 1128 // handled by the item itself
1110 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1129 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1111 qDebug("com %d ",completed ); 1130 qDebug("com %d ",completed );
1112 qDebug("itemclicked "); 1131 qDebug("itemclicked ");
1113 if (todoItem->isOn()) { 1132 if (todoItem->isOn()) {
1114 qDebug("on "); 1133 qDebug("on ");
1115 if (!completed) { 1134 if (!completed) {
1116 qDebug("set true "); 1135 qDebug("set true ");
1117 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1136 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1118 } 1137 }
1119 } else { 1138 } else {
1120 qDebug("not on "); 1139 qDebug("not on ");
1121 if (completed) { 1140 if (completed) {
1122 qDebug("set false "); 1141 qDebug("set false ");
1123 todoItem->todo()->setCompleted(false); 1142 todoItem->todo()->setCompleted(false);
1124 } 1143 }
1125 } 1144 }
1126#endif 1145#endif
1127} 1146}
1128 1147
1129void KOTodoView::setDocumentId( const QString &id ) 1148void KOTodoView::setDocumentId( const QString &id )
1130{ 1149{
1131 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1150 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1132 1151
1133 mDocPrefs->setDoc( id ); 1152 mDocPrefs->setDoc( id );
1134} 1153}
1135 1154
1136void KOTodoView::itemStateChanged( QListViewItem *item ) 1155void KOTodoView::itemStateChanged( QListViewItem *item )
1137{ 1156{
1138 if (!item) return; 1157 if (!item) return;
1139 1158
1140 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1159 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1141 1160
1142// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1161// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1143 1162
1144 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1163 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1145} 1164}
1146 1165
1147void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1166void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1148{ 1167{
1149 mTodoListView->saveLayout(config,group); 1168 mTodoListView->saveLayout(config,group);
1150} 1169}
1151 1170
1152void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1171void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1153{ 1172{
1154 mTodoListView->restoreLayout(config,group); 1173 mTodoListView->restoreLayout(config,group);
1155} 1174}
1156 1175
1157void KOTodoView::processSelectionChange() 1176void KOTodoView::processSelectionChange()
1158{ 1177{
1159// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1178// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1160 1179
1161 KOTodoViewItem *item = 1180 KOTodoViewItem *item =
1162 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1181 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1163 1182
1164 if ( !item ) { 1183 if ( !item ) {
1165 emit incidenceSelected( 0 ); 1184 emit incidenceSelected( 0 );
1166 } else { 1185 } else {
1167 emit incidenceSelected( item->todo() ); 1186 emit incidenceSelected( item->todo() );
1168 } 1187 }
1169} 1188}
1170 1189
1171void KOTodoView::modified(bool b) 1190void KOTodoView::modified(bool b)
1172{ 1191{
1173 emit isModified(b); 1192 emit isModified(b);
1174} 1193}
1175void KOTodoView::setTodoModified( Todo* todo ) 1194void KOTodoView::setTodoModified( Todo* todo )
1176{ 1195{
1177 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1196 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1178} 1197}
1179void KOTodoView::clearSelection() 1198void KOTodoView::clearSelection()
1180{ 1199{
1181 mTodoListView->selectAll( false ); 1200 mTodoListView->selectAll( false );
1182} 1201}
1183void KOTodoView::setAllOpen() 1202void KOTodoView::setAllOpen()
1184{ 1203{
1185 if ( isFlatDisplay ) { 1204 if ( isFlatDisplay ) {
1186 isFlatDisplay = false; 1205 isFlatDisplay = false;
1187 mPopupMenu->setItemChecked( 8,false ); 1206 mPopupMenu->setItemChecked( 8,false );
1188 updateView(); 1207 updateView();
1189 } 1208 }
1190 setOpen(mTodoListView->firstChild(), true); 1209 setOpen(mTodoListView->firstChild(), true);
1191} 1210}
1192void KOTodoView::setAllClose() 1211void KOTodoView::setAllClose()
1193{ 1212{
1194 if ( isFlatDisplay ) { 1213 if ( isFlatDisplay ) {
1195 isFlatDisplay = false; 1214 isFlatDisplay = false;
1196 mPopupMenu->setItemChecked( 8,false ); 1215 mPopupMenu->setItemChecked( 8,false );
1197 updateView(); 1216 updateView();
1198 } 1217 }
1199 setOpen(mTodoListView->firstChild(), false); 1218 setOpen(mTodoListView->firstChild(), false);
1200} 1219}
1201void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1220void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1202{ 1221{
1203 1222
1204 while ( item ) { 1223 while ( item ) {
1205 setOpen( item->firstChild(), setOpenI ); 1224 setOpen( item->firstChild(), setOpenI );
1206 item->setOpen( setOpenI ); 1225 item->setOpen( setOpenI );
1207 item = item->nextSibling(); 1226 item = item->nextSibling();
1208 } 1227 }
1209} 1228}
1210 1229
1211void KOTodoView::displayAllFlat() 1230void KOTodoView::displayAllFlat()
1212{ 1231{
1213 pendingSubtodo = 0; 1232 pendingSubtodo = 0;
1214 if ( mBlockUpdate ) { 1233 if ( mBlockUpdate ) {
1215 return; 1234 return;
1216 } 1235 }
1217 mPopupMenu->setItemChecked( 8,true ); 1236 mPopupMenu->setItemChecked( 8,true );
1218 isFlatDisplay = true; 1237 isFlatDisplay = true;
1219 QPtrList<Todo> todoList = calendar()->todos(); 1238 QPtrList<Todo> todoList = calendar()->todos();
1220 mTodoMap.clear(); 1239 mTodoMap.clear();
1221 mTodoListView->clear(); 1240 mTodoListView->clear();
1222 Todo *todo; 1241 Todo *todo;
1223 for(todo = todoList.first(); todo; todo = todoList.next()) { 1242 for(todo = todoList.first(); todo; todo = todoList.next()) {
1224 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1243 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1225 mTodoMap.insert(todo,todoItem); 1244 mTodoMap.insert(todo,todoItem);
1226 } 1245 }
1227 mTodoListView->setFocus(); 1246 mTodoListView->setFocus();
1228 processSelectionChange(); 1247 processSelectionChange();
1229} 1248}
1230 1249
1231void KOTodoView::setAllFlat() 1250void KOTodoView::setAllFlat()
1232{ 1251{
1233 if ( isFlatDisplay ) { 1252 if ( isFlatDisplay ) {
1234 isFlatDisplay = false; 1253 isFlatDisplay = false;
1235 mPopupMenu->setItemChecked( 8,false ); 1254 mPopupMenu->setItemChecked( 8,false );
1236 updateView(); 1255 updateView();
1237 return; 1256 return;
1238 } 1257 }
1239 displayAllFlat(); 1258 displayAllFlat();
1240} 1259}
1241 1260
1242void KOTodoView::purgeCompleted() 1261void KOTodoView::purgeCompleted()
1243{ 1262{
1244 emit purgeCompletedSignal(); 1263 emit purgeCompletedSignal();
1245} 1264}
1246void KOTodoView::toggleQuickTodo() 1265void KOTodoView::toggleQuickTodo()
1247{ 1266{
1248 if ( mQuickAdd->isVisible() ) { 1267 if ( mQuickAdd->isVisible() ) {
1249 mQuickAdd->hide(); 1268 mQuickAdd->hide();
1250 KOPrefs::instance()->mEnableQuickTodo = false; 1269 KOPrefs::instance()->mEnableQuickTodo = false;
1251 } 1270 }
1252 else { 1271 else {
1253 mQuickAdd->show(); 1272 mQuickAdd->show();
1254 KOPrefs::instance()->mEnableQuickTodo = true; 1273 KOPrefs::instance()->mEnableQuickTodo = true;
1255 } 1274 }
1256 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1275 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1257 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1276 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1258} 1277}
1259 1278
1260void KOTodoView::toggleRunning() 1279void KOTodoView::toggleRunning()
1261{ 1280{
1262 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1281 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1263 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1282 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1264 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1283 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1265 updateView(); 1284 updateView();
1266} 1285}
1267 1286
1268void KOTodoView::toggleCompleted() 1287void KOTodoView::toggleCompleted()
1269{ 1288{
diff --git a/microkde/kcolordialog.cpp b/microkde/kcolordialog.cpp
index 9a76e5e..a3d8973 100644
--- a/microkde/kcolordialog.cpp
+++ b/microkde/kcolordialog.cpp
@@ -1,92 +1,93 @@
1#include "kcolordialog.h" 1#include "kcolordialog.h"
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qslider.h> 5#include <qslider.h>
6#include <qhbox.h> 6#include <qhbox.h>
7#include <qapplication.h> 7#include <qapplication.h>
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9 9
10#include <kglobal.h> 10#include <kglobal.h>
11QColor KColorDialog::getColor( ) const 11QColor KColorDialog::getColor( ) const
12{ 12{
13 QColor c ( r->value(), g->value(), b->value() ); 13 QColor c ( r->value(), g->value(), b->value() );
14 lar->setText ( "R: " + QString::number ( c.red() ) ); 14 lar->setText ( "R: " + QString::number ( c.red() ) );
15 lag->setText ( "G: " + QString::number ( c.green() ) ); 15 lag->setText ( "G: " + QString::number ( c.green() ) );
16 lab->setText ( "B: " + QString::number ( c.blue() ) ); 16 lab->setText ( "B: " + QString::number ( c.blue() ) );
17 return c; 17 return c;
18} 18}
19void KColorDialog::setColor( const QColor & d ) 19void KColorDialog::setColor( const QColor & d )
20{ 20{
21 r->setValue(d.red() ); 21 r->setValue(d.red() );
22 g->setValue(d.green() ); 22 g->setValue(d.green() );
23 b->setValue(d.blue() ); 23 b->setValue(d.blue() );
24 old_color->setPalette( QPalette( d.dark(), d ) ); 24 old_color->setPalette( QPalette( d.dark(), d ) );
25 lar->setText ( "R: " + QString::number ( d.red() ) ); 25 lar->setText ( "R: " + QString::number ( d.red() ) );
26 lag->setText ( "G: " + QString::number ( d.green() ) ); 26 lag->setText ( "G: " + QString::number ( d.green() ) );
27 lab->setText ( "B: " + QString::number ( d.blue() ) ); 27 lab->setText ( "B: " + QString::number ( d.blue() ) );
28 28
29} 29}
30KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true ) 30KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true )
31{ 31{
32 setCaption( i18n("Choose Color") ); 32 setCaption( i18n("Choose Color") );
33 33
34 setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er. 34 setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er.
35 QGridLayout* lay = new QGridLayout ( this, 4, 2 ); 35 QGridLayout* lay = new QGridLayout ( this, 4, 2 );
36 lay->setSpacing( 6 ); 36 lay->setSpacing( 6 );
37 lay->setMargin( 11 ); 37 lay->setMargin( 11 );
38 38
39 old_color = new QLabel("Old color",this); 39 old_color = new QLabel("Old color",this);
40 old_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); 40 old_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
41 old_color->setLineWidth( 1 ); 41 old_color->setLineWidth( 1 );
42 lay->addWidget(old_color, 0, 0); 42 lay->addWidget(old_color, 0, 0);
43 43
44 new_color = new QLabel("New color", this); 44 new_color = new QLabel("New color", this);
45 new_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); 45 new_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
46 new_color->setLineWidth( 1 ); 46 new_color->setLineWidth( 1 );
47 lay->addWidget(new_color, 0, 1); 47 lay->addWidget(new_color, 0, 1);
48 new_color->setAlignment( AlignCenter ); 48 new_color->setAlignment( AlignCenter );
49 49
50 QHBox* hb = new QHBox ( this ); 50 QHBox* hb = new QHBox ( this );
51 lar = new QLabel( hb ); 51 lar = new QLabel( hb );
52 lag = new QLabel( hb ); 52 lag = new QLabel( hb );
53 lab = new QLabel( hb ); 53 lab = new QLabel( hb );
54 lay->addMultiCellWidget( hb,1,1, 0,1 ); 54 lay->addMultiCellWidget( hb,1,1, 0,1 );
55 55
56 QLabel* lr = new QLabel ( "Red:", this ); 56 QLabel* lr = new QLabel ( "Red:", this );
57 lay->addWidget( lr,2,0 ); 57 lay->addWidget( lr,2,0 );
58 r = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 58 r = new QSlider ( 0, 255, 1, 1, Horizontal, this );
59 lay->addWidget(r ,2,1 ); 59 lay->addWidget(r ,2,1 );
60 60
61 QLabel* lg = new QLabel( "Green:",this ); 61 QLabel* lg = new QLabel( "Green:",this );
62 lay->addWidget(lg ,3,0 ); 62 lay->addWidget(lg ,3,0 );
63 g = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 63 g = new QSlider ( 0, 255, 1, 1, Horizontal, this );
64 lay->addWidget( g ,3,1 ); 64 lay->addWidget( g ,3,1 );
65 65
66 QLabel* lb = new QLabel ( "Blue:",this ); 66 QLabel* lb = new QLabel ( "Blue:",this );
67 lay->addWidget( lb,4,0 ); 67 lay->addWidget( lb,4,0 );
68 b = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 68 b = new QSlider ( 0, 255, 1, 1, Horizontal, this );
69 lay->addWidget(b ,4,1 ); 69 lay->addWidget(b ,4,1 );
70 70
71 QColor d = backgroundColor(); 71 QColor d = backgroundColor();
72 r->setValue(d.red() ); 72 r->setValue(d.red() );
73 g->setValue(d.green() ); 73 g->setValue(d.green() );
74 b->setValue(d.blue() ); 74 b->setValue(d.blue() );
75 old_color->setPalette( QPalette( d.dark() , d ) ); 75 old_color->setPalette( QPalette( d.dark() , d ) );
76 // kannst du wieder reinnehmen, aber es geht auch so. 76 // kannst du wieder reinnehmen, aber es geht auch so.
77 QPushButton * ok = new QPushButton (i18n(" OK "), this ); 77 QPushButton * ok = new QPushButton (i18n(" OK "), this );
78 ok->setDefault( true );
78 QPushButton * cancel = new QPushButton (i18n(" Cancel "), this ); 79 QPushButton * cancel = new QPushButton (i18n(" Cancel "), this );
79 80
80 lay->addWidget(ok ,5,0 ); 81 lay->addWidget(ok ,5,0 );
81 lay->addWidget(cancel ,5,1 ); 82 lay->addWidget(cancel ,5,1 );
82 connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() )); 83 connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() ));
83 connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() )); 84 connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() ));
84 connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 85 connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
85 connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 86 connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
86 connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 87 connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
87} 88}
88void KColorDialog::updateColor( int ) 89void KColorDialog::updateColor( int )
89{ 90{
90 QColor c = getColor( ) ; 91 QColor c = getColor( ) ;
91 new_color->setPalette( QPalette( c.dark(), c ) ); 92 new_color->setPalette( QPalette( c.dark(), c ) );
92} 93}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 35d4916..36ede81 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -972,384 +972,385 @@ void KToolBar::setIconText(IconText icontext, bool update)
972 mw->setUpdatesEnabled( TRUE ); 972 mw->setUpdatesEnabled( TRUE );
973 } 973 }
974} 974}
975 975
976 976
977KToolBar::IconText KToolBar::iconText() const 977KToolBar::IconText KToolBar::iconText() const
978{ 978{
979 return d->m_iconText; 979 return d->m_iconText;
980} 980}
981 981
982 982
983void KToolBar::setIconSize(int size) 983void KToolBar::setIconSize(int size)
984{ 984{
985 setIconSize( size, true ); 985 setIconSize( size, true );
986} 986}
987 987
988void KToolBar::setIconSize(int size, bool update) 988void KToolBar::setIconSize(int size, bool update)
989{ 989{
990 bool doUpdate=false; 990 bool doUpdate=false;
991 991
992 if ( size != d->m_iconSize ) { 992 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 993 d->m_iconSize = size;
994 doUpdate=true; 994 doUpdate=true;
995 } 995 }
996 996
997 if (update == false) 997 if (update == false)
998 return; 998 return;
999 999
1000 if (doUpdate) 1000 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1001 emit modechange(); // tell buttons what happened
1002 1002
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1004 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1005 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1006 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1007 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1008 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1009 mw->setUpdatesEnabled( TRUE );
1010 } 1010 }
1011} 1011}
1012 1012
1013 1013
1014int KToolBar::iconSize() const 1014int KToolBar::iconSize() const
1015{ 1015{
1016/*US 1016/*US
1017 if ( !d->m_iconSize ) // default value? 1017 if ( !d->m_iconSize ) // default value?
1018 { 1018 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1019 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1021 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1023 }
1024 return d->m_iconSize; 1024 return d->m_iconSize;
1025*/ 1025*/
1026 int ret = 18; 1026 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 ) 1027 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1028 ret = 30;
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 return;
1164 QString configGroup = _configGroup; 1165 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1166 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1167 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1168 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1169
1169 QString position, icontext; 1170 QString position, icontext;
1170 int index; 1171 int index;
1171 getAttributes( position, icontext, index ); 1172 getAttributes( position, icontext, index );
1172 1173
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1174 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1175
1175 KConfigGroupSaver saver(config, configGroup); 1176 KConfigGroupSaver saver(config, configGroup);
1176 1177
1177 if ( position != d->PositionDefault ) 1178 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1179 config->writeEntry("Position", position);
1179 else 1180 else
1180 config->deleteEntry("Position"); 1181 config->deleteEntry("Position");
1181 1182
1182 if ( icontext != d->IconTextDefault ) 1183 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1184 config->writeEntry("IconText", icontext);
1184 else 1185 else
1185 config->deleteEntry("IconText"); 1186 config->deleteEntry("IconText");
1186 1187
1187 if ( iconSize() != d->IconSizeDefault ) 1188 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1189 config->writeEntry("IconSize", iconSize());
1189 else 1190 else
1190 config->deleteEntry("IconSize"); 1191 config->deleteEntry("IconSize");
1191 1192
1192 if ( isHidden() != d->HiddenDefault ) 1193 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1194 config->writeEntry("Hidden", isHidden());
1194 else 1195 else
1195 config->deleteEntry("Hidden"); 1196 config->deleteEntry("Hidden");
1196 1197
1197 if ( index != d->IndexDefault ) 1198 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1199 config->writeEntry( "Index", index );
1199 else 1200 else
1200 config->deleteEntry("Index"); 1201 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1202//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1203/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1204 config->writeEntry( "Offset", offset() );
1204 else 1205 else
1205*/ 1206*/
1206 config->deleteEntry("Offset"); 1207 config->deleteEntry("Offset");
1207 1208
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1209//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1210/*
1210 if ( newLine() != d->NewLineDefault ) 1211 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1212 config->writeEntry( "NewLine", newLine() );
1212 else 1213 else
1213*/ 1214*/
1214 config->deleteEntry("NewLine"); 1215 config->deleteEntry("NewLine");
1215} 1216}
1216 1217
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1218void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1219{
1219 d->m_xmlguiClient = client; 1220 d->m_xmlguiClient = client;
1220} 1221}
1221 1222
1222void KToolBar::setText( const QString & txt ) 1223void KToolBar::setText( const QString & txt )
1223{ 1224{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1225//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1226 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1227}
1227 1228
1228 1229
1229QString KToolBar::text() const 1230QString KToolBar::text() const
1230{ 1231{
1231 return label(); 1232 return label();
1232} 1233}
1233 1234
1234 1235
1235void KToolBar::doConnections( KToolBarButton *button ) 1236void KToolBar::doConnections( KToolBarButton *button )
1236{ 1237{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1238 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1239 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1240 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1241 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1242 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1243 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1244}
1244 1245
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1246void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1247{
1247 if ( !mainWindow() ) 1248 if ( !mainWindow() )
1248 return; 1249 return;
1249 QMainWindow *mw = mainWindow(); 1250 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1251 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1252 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1253 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1254 switch ( i ) {
1254 case -1: 1255 case -1:
1255 return; // popup cancelled 1256 return; // popup cancelled
1256 case CONTEXT_LEFT: 1257 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1258//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1259 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1260 break;
1260 case CONTEXT_RIGHT: 1261 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1262//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1263 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1264 break;
1264 case CONTEXT_TOP: 1265 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1266//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1267 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1268 break;
1268 case CONTEXT_BOTTOM: 1269 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1270//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1271 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1272 break;
1272 case CONTEXT_FLOAT: 1273 case CONTEXT_FLOAT:
1273 break; 1274 break;
1274 case CONTEXT_FLAT: 1275 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1276//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1277 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1278 break;
1278 case CONTEXT_ICONS: 1279 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1280 setIconText( IconOnly );
1280 break; 1281 break;
1281 case CONTEXT_TEXTRIGHT: 1282 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1283 setIconText( IconTextRight );
1283 break; 1284 break;
1284 case CONTEXT_TEXT: 1285 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1286 setIconText( TextOnly );
1286 break; 1287 break;
1287 case CONTEXT_TEXTUNDER: 1288 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1289 setIconText( IconTextBottom );
1289 break; 1290 break;
1290 default: 1291 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1292 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1293 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1294 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1295 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1296 }
1296/*US 1297/*US
1297 if ( mw->inherits("KMainWindow") ) 1298 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1299 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1300*/
1300 } 1301 }
1301 } 1302 }
1302} 1303}
1303 1304
1304 1305
1305void KToolBar::rebuildLayout() 1306void KToolBar::rebuildLayout()
1306{ 1307{
1307 1308
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1309 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1310 w->blockSignals(false);
1310 d->idleButtons.clear(); 1311 d->idleButtons.clear();
1311 1312
1312 layoutTimer->stop(); 1313 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1314 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1315 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1316 l->setMargin( 1 );
1316 // clear the old layout 1317 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1318 QLayoutIterator it = l->iterator();
1318 1319
1319 while ( it.current() ) { 1320 while ( it.current() ) {
1320 it.deleteCurrent(); 1321 it.deleteCurrent();
1321 } 1322 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1323 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1324 if ( w == rightAligned ) {
1324 continue; 1325 continue;
1325 } 1326 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1327 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1328 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1329 l->addSpacing( 6 );
1329 w->hide(); 1330 w->hide();
1330 continue; 1331 continue;
1331 } 1332 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1333 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1334 continue;
1334 l->addWidget( w ); 1335 l->addWidget( w );
1335 w->show(); 1336 w->show();
1336 } 1337 }
1337 if ( rightAligned ) { 1338 if ( rightAligned ) {
1338 l->addStretch(); 1339 l->addStretch();
1339 l->addWidget( rightAligned ); 1340 l->addWidget( rightAligned );
1340 rightAligned->show(); 1341 rightAligned->show();
1341 } 1342 }
1342 1343
1343 if ( fullSize() ) { 1344 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1345 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1346 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1347 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1348 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1349 if ( !rightAligned )
1349 l->addStretch(); 1350 l->addStretch();
1350 if ( stretchableWidget ) 1351 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1352 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1353 }
1353 l->invalidate(); 1354 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1355 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1356 //#endif //DESKTOP_VERSION
@@ -1415,384 +1416,385 @@ void KToolBar::repaintMe()
1415 setUpdatesEnabled( true ); 1416 setUpdatesEnabled( true );
1416 QToolBar::repaint( true ); 1417 QToolBar::repaint( true );
1417 //qDebug(" KToolBar::repaintMe() "); 1418 //qDebug(" KToolBar::repaintMe() ");
1418} 1419}
1419 1420
1420void KToolBar::showEvent( QShowEvent *e ) 1421void KToolBar::showEvent( QShowEvent *e )
1421{ 1422{
1422 QToolBar::showEvent( e ); 1423 QToolBar::showEvent( e );
1423 rebuildLayout(); 1424 rebuildLayout();
1424} 1425}
1425 1426
1426void KToolBar::setStretchableWidget( QWidget *w ) 1427void KToolBar::setStretchableWidget( QWidget *w )
1427{ 1428{
1428 QToolBar::setStretchableWidget( w ); 1429 QToolBar::setStretchableWidget( w );
1429 stretchableWidget = w; 1430 stretchableWidget = w;
1430} 1431}
1431 1432
1432QSizePolicy KToolBar::sizePolicy() const 1433QSizePolicy KToolBar::sizePolicy() const
1433{ 1434{
1434 if ( orientation() == Horizontal ) 1435 if ( orientation() == Horizontal )
1435 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1436 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1436 else 1437 else
1437 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1438 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1438} 1439}
1439 1440
1440QSize KToolBar::sizeHint() const 1441QSize KToolBar::sizeHint() const
1441{ 1442{
1442 return QToolBar::sizeHint(); 1443 return QToolBar::sizeHint();
1443#if 0 1444#if 0
1444 QWidget::polish(); 1445 QWidget::polish();
1445 static int iii = 0; 1446 static int iii = 0;
1446 ++iii; 1447 ++iii;
1447 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1448 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1448 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1449 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1449 switch( barPos() ) 1450 switch( barPos() )
1450 { 1451 {
1451 case KToolBar::Top: 1452 case KToolBar::Top:
1452 case KToolBar::Bottom: 1453 case KToolBar::Bottom:
1453 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1454 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1454 { 1455 {
1455 if ( w->inherits( "KToolBarSeparator" ) && 1456 if ( w->inherits( "KToolBarSeparator" ) &&
1456 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1457 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1457 { 1458 {
1458 minSize += QSize(6, 0); 1459 minSize += QSize(6, 0);
1459 } 1460 }
1460 else 1461 else
1461 { 1462 {
1462 QSize sh = w->sizeHint(); 1463 QSize sh = w->sizeHint();
1463 if (!sh.isValid()) 1464 if (!sh.isValid())
1464 sh = w->minimumSize(); 1465 sh = w->minimumSize();
1465 minSize = minSize.expandedTo(QSize(0, sh.height())); 1466 minSize = minSize.expandedTo(QSize(0, sh.height()));
1466 minSize += QSize(sh.width()+1, 0); 1467 minSize += QSize(sh.width()+1, 0);
1467 } 1468 }
1468 } 1469 }
1469/*US 1470/*US
1470 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1471 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1471*/ 1472*/
1472 minSize += QSize(margin*2, margin*2); 1473 minSize += QSize(margin*2, margin*2);
1473 break; 1474 break;
1474 1475
1475 case KToolBar::Left: 1476 case KToolBar::Left:
1476 case KToolBar::Right: 1477 case KToolBar::Right:
1477 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1478 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1478 { 1479 {
1479 if ( w->inherits( "KToolBarSeparator" ) && 1480 if ( w->inherits( "KToolBarSeparator" ) &&
1480 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1481 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1481 { 1482 {
1482 minSize += QSize(0, 6); 1483 minSize += QSize(0, 6);
1483 } 1484 }
1484 else 1485 else
1485 { 1486 {
1486 QSize sh = w->sizeHint(); 1487 QSize sh = w->sizeHint();
1487 if (!sh.isValid()) 1488 if (!sh.isValid())
1488 sh = w->minimumSize(); 1489 sh = w->minimumSize();
1489 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1490 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1490 minSize += QSize(0, sh.height()+1); 1491 minSize += QSize(0, sh.height()+1);
1491 } 1492 }
1492 } 1493 }
1493/*US 1494/*US
1494 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1495 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1495*/ 1496*/
1496 minSize += QSize(margin*2, margin*2); 1497 minSize += QSize(margin*2, margin*2);
1497 break; 1498 break;
1498 1499
1499 default: 1500 default:
1500 minSize = QToolBar::sizeHint(); 1501 minSize = QToolBar::sizeHint();
1501 break; 1502 break;
1502 } 1503 }
1503 return minSize; 1504 return minSize;
1504#endif 1505#endif
1505} 1506}
1506 1507
1507QSize KToolBar::minimumSize() const 1508QSize KToolBar::minimumSize() const
1508{ 1509{
1509 return minimumSizeHint(); 1510 return minimumSizeHint();
1510} 1511}
1511 1512
1512QSize KToolBar::minimumSizeHint() const 1513QSize KToolBar::minimumSizeHint() const
1513{ 1514{
1514 return sizeHint(); 1515 return sizeHint();
1515} 1516}
1516 1517
1517bool KToolBar::highlight() const 1518bool KToolBar::highlight() const
1518{ 1519{
1519 return d->m_highlight; 1520 return d->m_highlight;
1520} 1521}
1521 1522
1522void KToolBar::hide() 1523void KToolBar::hide()
1523{ 1524{
1524 QToolBar::hide(); 1525 QToolBar::hide();
1525} 1526}
1526 1527
1527void KToolBar::show() 1528void KToolBar::show()
1528{ 1529{
1529 QToolBar::show(); 1530 QToolBar::show();
1530} 1531}
1531 1532
1532void KToolBar::resizeEvent( QResizeEvent *e ) 1533void KToolBar::resizeEvent( QResizeEvent *e )
1533{ 1534{
1534 bool b = isUpdatesEnabled(); 1535 bool b = isUpdatesEnabled();
1535 setUpdatesEnabled( FALSE ); 1536 setUpdatesEnabled( FALSE );
1536 QToolBar::resizeEvent( e ); 1537 QToolBar::resizeEvent( e );
1537 if (b) 1538 if (b)
1538 d->repaintTimer.start( 100, true ); 1539 d->repaintTimer.start( 100, true );
1539} 1540}
1540 1541
1541void KToolBar::slotIconChanged(int group) 1542void KToolBar::slotIconChanged(int group)
1542{ 1543{
1543 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1544 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1544 return; 1545 return;
1545 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1546 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1546 return; 1547 return;
1547 1548
1548 emit modechange(); 1549 emit modechange();
1549 if (isVisible()) 1550 if (isVisible())
1550 updateGeometry(); 1551 updateGeometry();
1551} 1552}
1552 1553
1553void KToolBar::slotReadConfig() 1554void KToolBar::slotReadConfig()
1554{ 1555{
1555 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1556 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1556 // Read appearance settings (hmm, we used to do both here, 1557 // Read appearance settings (hmm, we used to do both here,
1557 // but a well behaved application will call applyMainWindowSettings 1558 // but a well behaved application will call applyMainWindowSettings
1558 // anyway, right ?) 1559 // anyway, right ?)
1559 applyAppearanceSettings(KGlobal::config(), QString::null ); 1560 applyAppearanceSettings(KGlobal::config(), QString::null );
1560} 1561}
1561 1562
1562void KToolBar::slotAppearanceChanged() 1563void KToolBar::slotAppearanceChanged()
1563{ 1564{
1564 // Read appearance settings from global file. 1565 // Read appearance settings from global file.
1565 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1566 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1566 // And remember to save the new look later 1567 // And remember to save the new look later
1567/*US 1568/*US
1568 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1569 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1569 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1570 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1570*/ 1571*/
1571} 1572}
1572 1573
1573//static 1574//static
1574bool KToolBar::highlightSetting() 1575bool KToolBar::highlightSetting()
1575{ 1576{
1576 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1577 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1577 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1578 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1578 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1579 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1579} 1580}
1580 1581
1581//static 1582//static
1582bool KToolBar::transparentSetting() 1583bool KToolBar::transparentSetting()
1583{ 1584{
1584 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1585 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1585 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1586 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1586 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1587 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1587} 1588}
1588 1589
1589//static 1590//static
1590KToolBar::IconText KToolBar::iconTextSetting() 1591KToolBar::IconText KToolBar::iconTextSetting()
1591{ 1592{
1592 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1593 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1593 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1594 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1594 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1595 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1595 if ( icontext == "IconTextRight" ) 1596 if ( icontext == "IconTextRight" )
1596 return IconTextRight; 1597 return IconTextRight;
1597 else if ( icontext == "IconTextBottom" ) 1598 else if ( icontext == "IconTextBottom" )
1598 return IconTextBottom; 1599 return IconTextBottom;
1599 else if ( icontext == "TextOnly" ) 1600 else if ( icontext == "TextOnly" )
1600 return TextOnly; 1601 return TextOnly;
1601 else 1602 else
1602 return IconOnly; 1603 return IconOnly;
1603} 1604}
1604 1605
1605void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1606void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1606{ 1607{
1608 return;
1607 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1609 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1608 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1610 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1609 // We have application-specific settings in the XML file, 1611 // We have application-specific settings in the XML file,
1610 // and nothing in the application's config file 1612 // and nothing in the application's config file
1611 // -> don't apply the global defaults, the XML ones are preferred 1613 // -> don't apply the global defaults, the XML ones are preferred
1612 // See applySettings for a full explanation 1614 // See applySettings for a full explanation
1613/*US :we do not support xml files 1615/*US :we do not support xml files
1614 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1616 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1615 !config->hasGroup(configGroup) ) 1617 !config->hasGroup(configGroup) )
1616 { 1618 {
1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1619 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1618 return; 1620 return;
1619 } 1621 }
1620*/ 1622*/
1621 if ( !config->hasGroup(configGroup) ) 1623 if ( !config->hasGroup(configGroup) )
1622 { 1624 {
1623 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1625 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1624 return; 1626 return;
1625 } 1627 }
1626 1628
1627 1629
1628 KConfig *gconfig = KGlobal::config(); 1630 KConfig *gconfig = KGlobal::config();
1629/*US 1631/*US
1630 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1632 static const QString &attrIconText = KGlobal::staticQString("IconText");
1631 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1633 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1632 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1634 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1633 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1635 static const QString &attrSize = KGlobal::staticQString("IconSize");
1634*/ 1636*/
1635 // we actually do this in two steps. 1637 // we actually do this in two steps.
1636 // First, we read in the global styles [Toolbar style] (from the KControl module). 1638 // First, we read in the global styles [Toolbar style] (from the KControl module).
1637 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1639 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1638 bool highlight; 1640 bool highlight;
1639 int transparent; 1641 int transparent;
1640 QString icontext; 1642 QString icontext;
1641 int iconsize = 0; 1643 int iconsize = 0;
1642 1644
1643 // this is the first iteration 1645 // this is the first iteration
1644 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1646 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1645 { // start block for KConfigGroupSaver 1647 { // start block for KConfigGroupSaver
1646 KConfigGroupSaver saver(gconfig, grpToolbar); 1648 KConfigGroupSaver saver(gconfig, grpToolbar);
1647 1649
1648 // first, get the generic settings 1650 // first, get the generic settings
1649//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1651//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1650 highlight = gconfig->readBoolEntry("Highlighting", true); 1652 highlight = gconfig->readBoolEntry("Highlighting", true);
1651//US transparent = gconfig->readBoolEntry(attrTrans, true); 1653//US transparent = gconfig->readBoolEntry(attrTrans, true);
1652 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1654 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1653 1655
1654 // we read in the IconText property *only* if we intend on actually 1656 // we read in the IconText property *only* if we intend on actually
1655 // honoring it 1657 // honoring it
1656 if (d->m_honorStyle) 1658 if (d->m_honorStyle)
1657//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1659//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1658 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1660 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1659 else 1661 else
1660 d->IconTextDefault = "IconOnly"; 1662 d->IconTextDefault = "IconOnly";
1661 1663
1662 // Use the default icon size for toolbar icons. 1664 // Use the default icon size for toolbar icons.
1663//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1665//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1664 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1666 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1665 1667
1666 if ( !forceGlobal && config->hasGroup(configGroup) ) 1668 if ( !forceGlobal && config->hasGroup(configGroup) )
1667 { 1669 {
1668 config->setGroup(configGroup); 1670 config->setGroup(configGroup);
1669 1671
1670 // first, get the generic settings 1672 // first, get the generic settings
1671//US highlight = config->readBoolEntry(attrHighlight, highlight); 1673//US highlight = config->readBoolEntry(attrHighlight, highlight);
1672 highlight = config->readBoolEntry("Highlighting", highlight); 1674 highlight = config->readBoolEntry("Highlighting", highlight);
1673//US transparent = config->readBoolEntry(attrTrans, transparent); 1675//US transparent = config->readBoolEntry(attrTrans, transparent);
1674 transparent = config->readBoolEntry("TransparentMoving", transparent); 1676 transparent = config->readBoolEntry("TransparentMoving", transparent);
1675 // now we always read in the IconText property 1677 // now we always read in the IconText property
1676//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1678//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1677 icontext = config->readEntry("IconText", d->IconTextDefault); 1679 icontext = config->readEntry("IconText", d->IconTextDefault);
1678 1680
1679 // now get the size 1681 // now get the size
1680//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1682//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1681 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1683 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1682 } 1684 }
1683 else 1685 else
1684 { 1686 {
1685 iconsize = d->IconSizeDefault; 1687 iconsize = d->IconSizeDefault;
1686 icontext = d->IconTextDefault; 1688 icontext = d->IconTextDefault;
1687 } 1689 }
1688 1690
1689 // revert back to the old group 1691 // revert back to the old group
1690 } // end block for KConfigGroupSaver 1692 } // end block for KConfigGroupSaver
1691 1693
1692 bool doUpdate = false; 1694 bool doUpdate = false;
1693 1695
1694 IconText icon_text; 1696 IconText icon_text;
1695 if ( icontext == "IconTextRight" ) 1697 if ( icontext == "IconTextRight" )
1696 icon_text = IconTextRight; 1698 icon_text = IconTextRight;
1697 else if ( icontext == "IconTextBottom" ) 1699 else if ( icontext == "IconTextBottom" )
1698 icon_text = IconTextBottom; 1700 icon_text = IconTextBottom;
1699 else if ( icontext == "TextOnly" ) 1701 else if ( icontext == "TextOnly" )
1700 icon_text = TextOnly; 1702 icon_text = TextOnly;
1701 else 1703 else
1702 icon_text = IconOnly; 1704 icon_text = IconOnly;
1703 1705
1704 // check if the icon/text has changed 1706 // check if the icon/text has changed
1705 if (icon_text != d->m_iconText) { 1707 if (icon_text != d->m_iconText) {
1706 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1708 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1707 setIconText(icon_text, false); 1709 setIconText(icon_text, false);
1708 doUpdate = true; 1710 doUpdate = true;
1709 } 1711 }
1710 1712
1711 // ...and check if the icon size has changed 1713 // ...and check if the icon size has changed
1712 if (iconsize != d->m_iconSize) { 1714 if (iconsize != d->m_iconSize) {
1713 setIconSize(iconsize, false); 1715 setIconSize(iconsize, false);
1714 doUpdate = true; 1716 doUpdate = true;
1715 } 1717 }
1716 1718
1717 QMainWindow *mw = mainWindow(); 1719 QMainWindow *mw = mainWindow();
1718 1720
1719 // ...and if we should highlight 1721 // ...and if we should highlight
1720 if ( highlight != d->m_highlight ) { 1722 if ( highlight != d->m_highlight ) {
1721 d->m_highlight = highlight; 1723 d->m_highlight = highlight;
1722 doUpdate = true; 1724 doUpdate = true;
1723 } 1725 }
1724 1726
1725 // ...and if we should move transparently 1727 // ...and if we should move transparently
1726 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1728 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1727 mw->setOpaqueMoving( !transparent ); 1729 mw->setOpaqueMoving( !transparent );
1728 } 1730 }
1729 1731
1730 if (doUpdate) 1732 if (doUpdate)
1731 emit modechange(); // tell buttons what happened 1733 emit modechange(); // tell buttons what happened
1732 if (isVisible ()) 1734 if (isVisible ())
1733 updateGeometry(); 1735 updateGeometry();
1734} 1736}
1735 1737
1736void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1738void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1737{ 1739{
1738 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1740 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1739 1741
1740 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1742 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1741 1743
1742 /* 1744 /*
1743 Let's explain this a bit more in details. 1745 Let's explain this a bit more in details.
1744 The order in which we apply settings is : 1746 The order in which we apply settings is :
1745 Global config / <appnamerc> user settings if no XMLGUI is used 1747 Global config / <appnamerc> user settings if no XMLGUI is used
1746 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1748 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1747 1749
1748 So in the first case, we simply read everything from KConfig as below, 1750 So in the first case, we simply read everything from KConfig as below,
1749 but in the second case we don't do anything here if there is no app-specific config, 1751 but in the second case we don't do anything here if there is no app-specific config,
1750 and the XMLGUI uses the static methods of this class to get the global defaults. 1752 and the XMLGUI uses the static methods of this class to get the global defaults.
1751 1753
1752 Global config doesn't include position (index, offset, newline and hidden/shown). 1754 Global config doesn't include position (index, offset, newline and hidden/shown).
1753 */ 1755 */
1754 1756
1755 // First the appearance stuff - the one which has a global config 1757 // First the appearance stuff - the one which has a global config
1756 applyAppearanceSettings( config, _configGroup ); 1758 applyAppearanceSettings( config, _configGroup );
1757 1759
1758 // ...and now the position stuff 1760 // ...and now the position stuff
1759 if ( config->hasGroup(configGroup) ) 1761 if ( config->hasGroup(configGroup) )
1760 { 1762 {
1761 KConfigGroupSaver cgs(config, configGroup); 1763 KConfigGroupSaver cgs(config, configGroup);
1762/*US 1764/*US
1763 static const QString &attrPosition = KGlobal::staticQString("Position"); 1765 static const QString &attrPosition = KGlobal::staticQString("Position");
1764 static const QString &attrIndex = KGlobal::staticQString("Index"); 1766 static const QString &attrIndex = KGlobal::staticQString("Index");
1765 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1767 static const QString &attrOffset = KGlobal::staticQString("Offset");
1766 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1768 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1767 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1769 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1768 1770
1769 QString position = config->readEntry(attrPosition, d->PositionDefault); 1771 QString position = config->readEntry(attrPosition, d->PositionDefault);
1770 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1772 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1771 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1773 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1772 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1774 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1773 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1775 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1774*/ 1776*/
1775 1777
1776 QString position = config->readEntry("Position", d->PositionDefault); 1778 QString position = config->readEntry("Position", d->PositionDefault);
1777 int index = config->readNumEntry("Index", d->IndexDefault); 1779 int index = config->readNumEntry("Index", d->IndexDefault);
1778 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1780 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1779 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1781 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1780 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1782 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1781 1783
1782/*US Dock pos(DockTop); 1784/*US Dock pos(DockTop);
1783 if ( position == "Top" ) 1785 if ( position == "Top" )
1784 pos = DockTop; 1786 pos = DockTop;
1785 else if ( position == "Bottom" ) 1787 else if ( position == "Bottom" )
1786 pos = DockBottom; 1788 pos = DockBottom;
1787 else if ( position == "Left" ) 1789 else if ( position == "Left" )
1788 pos = DockLeft; 1790 pos = DockLeft;
1789 else if ( position == "Right" ) 1791 else if ( position == "Right" )
1790 pos = DockRight; 1792 pos = DockRight;
1791 else if ( position == "Floating" ) 1793 else if ( position == "Floating" )
1792 pos = DockTornOff; 1794 pos = DockTornOff;
1793 else if ( position == "Flat" ) 1795 else if ( position == "Flat" )
1794 pos = DockMinimized; 1796 pos = DockMinimized;
1795*/ 1797*/
1796 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1798 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1797 if ( position == "Top" ) 1799 if ( position == "Top" )
1798 pos = QMainWindow::Top; 1800 pos = QMainWindow::Top;