author | zautrix <zautrix> | 2005-04-02 12:16:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-02 12:16:34 (UTC) |
commit | 997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (side-by-side diff) | |
tree | f788b37459574b5cea0d2ab874882c6a396c240d | |
parent | e0d51120d2f0c178115746e0c1357af40f95bc77 (diff) | |
download | kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2 |
more fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/configurecardviewdialog.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 6 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 57 | ||||
-rw-r--r-- | korganizer/koagenda.h | 4 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 18 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 49 | ||||
-rw-r--r-- | microkde/kcolordialog.cpp | 1 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 2 |
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 lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; simple = new QRadioButton(i18n("Simple: James Bond"), format ); full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); company = new QRadioButton(i18n("Organization: MI6"), format ); simple->setChecked( true ); setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); lay->addWidget( setCompany ); QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); //resize( 200, 200 ); } public: QRadioButton* simple, *full, *reverse, *company; QCheckBox* setCompany; }; class KAex2phonePrefs : public QDialog { public: KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); // lay->addWidget( mWriteToSim ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); lab->setAlignment (AlignHCenter); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteToSim; }; bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ mReadWrite( readWrite ), mModified( false ), mMainWindow(client) #else //KAB_EMBEDDED KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ), mModified( false ) #endif //KAB_EMBEDDED { // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); // syncManager->setBlockSave(false); mIncSearchWidget = 0; mMiniSplitter = 0; mExtensionBarSplitter = 0; mIsPart = !parent->inherits( "KAddressBookMain" ); mAddressBook = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false ); #ifndef KAB_EMBEDDED mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); #endif //KAB_EMBEDDED connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), SLOT( addressBookChanged() ) ); #if 0 // LR moved to addressbook init method mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, "X-Profession", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, "X-AssistantsName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, "X-ManagersName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, "X-SpousesName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, "X-Office", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, "X-IMAddress", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, "X-Anniversary", "KADDRESSBOOK" ); //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, "X-Gender", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, "X-Children", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, "X-FreeBusyUrl", "KADDRESSBOOK" ); #endif initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( const QString& ) ), SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearchJump( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 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&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mMessageTimer = new QTimer( this ); connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); mBRdisabled = false; #ifndef DESKTOP_VERSION infrared = 0; #endif //toggleBeamReceive( ); - //mMainWindow->toolBar()->show(); + mMainWindow->toolBar()->show(); // we have a toolbar repainting error on the Zaurus when starting KA/Pi QTimer::singleShot( 10, this , SLOT ( updateToolBar())); } void KABCore::updateToolBar() { static int iii = 0; ++iii; mMainWindow->toolBar()->repaintMe(); if ( iii < 4 ) QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; #ifndef DESKTOP_VERSION if ( infrared ) delete infrared; #endif } void KABCore::receive( const QCString& cmsg, const QByteArray& data ) { //qDebug("KA: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; recieve( fileName ); return; } } void KABCore::toggleBeamReceive( ) { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("KA: AB disable BeamReceive "); delete infrared; infrared = 0; mActionBR->setChecked(false); return; } qDebug("KA: AB enable BeamReceive "); mActionBR->setChecked(true); infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); #endif } void KABCore::disableBR(bool b) { #ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive( ); } mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; //toggleBeamReceive( ); } } #endif } void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); int count = mAddressBook->importFromFile( fn, true ); if ( count ) setModified( true ); mViewManager->refreshView(); message(i18n("%1 contact(s) received!").arg( count )); topLevelWidget()->showMaximized(); topLevelWidget()->raise(); } void KABCore::restoreSettings() { mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; bool state; if (mMultipleViewsAtOnce) state = KABPrefs::instance()->mDetailsPageVisible; else state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); /*US QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } */ mViewManager->restoreSettings(); mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); #ifdef DESKTOP_VERSION int wid = width(); if ( wid < 10 ) wid = 400; #else int wid = QApplication::desktop()->width(); if ( wid < 640 ) wid = QApplication::desktop()->height(); #endif QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { //splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } } void KABCore::saveSettings() { KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); if ( mExtensionBarSplitter ) KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); #ifndef KAB_EMBEDDED KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); #endif //KAB_EMBEDDED mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); KABPrefs::instance()->writeConfig(); qDebug("KA: KABCore::saveSettings() "); } KABC::AddressBook *KABCore::addressBook() const { return mAddressBook; } KConfig *KABCore::config() { #ifndef KAB_EMBEDDED return KABPrefs::instance()->config(); #else //KAB_EMBEDDED return KABPrefs::instance()->getConfig(); #endif //KAB_EMBEDDED } KActionCollection *KABCore::actionCollection() const { return mGUIClient->actionCollection(); } @@ -1984,507 +1984,508 @@ void KABCore::initActions() "kaddressbook_select_all" ); mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, SLOT( undo() ), actionCollection(), "kaddressbook_undo" ); mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, this, SLOT( redo() ), actionCollection(), "kaddressbook_redo" ); } else { mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); } mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", Key_Delete, this, SLOT( deleteContacts() ), actionCollection(), "edit_delete" ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); // settings menu #ifdef KAB_EMBEDDED //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, SLOT( configureResources() ), actionCollection(), "kaddressbook_configure_resources" ); #endif //KAB_EMBEDDED if ( mIsPart ) { mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, SLOT( openConfigDialog() ), actionCollection(), "kaddressbook_configure" ); //US not implemented yet //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, // this, SLOT( configureKeyBindings() ), actionCollection(), // "kaddressbook_configure_shortcuts" ); #ifdef KAB_EMBEDDED mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); mActionConfigureToolbars->setEnabled( false ); #endif //KAB_EMBEDDED } else { mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); //US not implemented yet //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); } mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, actionCollection(), "options_show_jump_bar" ); connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, actionCollection(), "options_show_details" ); connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, SLOT( toggleBeamReceive() ), actionCollection(), "kaddressbook_beam_rec" ); // misc // only enable LDAP lookup if we can handle the protocol #ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, this, SLOT( openLDAPDialog() ), actionCollection(), "ldap_lookup" ); } #else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); #endif //KAB_EMBEDDED mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, SLOT( setWhoAmI() ), actionCollection(), "set_personal" ); mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, SLOT( setCategories() ), actionCollection(), "edit_set_categories" ); mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, SLOT( editCategories() ), actionCollection(), "edit__categories" ); mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, SLOT( removeVoice() ), actionCollection(), "remove_voice" ); mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, SLOT( setFormattedName() ), actionCollection(), "set_formatted" ); mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, SLOT( manageCategories() ), actionCollection(), "remove_voice" ); mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, SLOT( importFromOL() ), actionCollection(), "import_OL" ); #ifdef KAB_EMBEDDED mActionLicence = new KAction( i18n( "Licence" ), 0, this, SLOT( showLicence() ), actionCollection(), "licence_about_data" ); mActionFaq = new KAction( i18n( "Faq" ), 0, this, SLOT( faq() ), actionCollection(), "faq_about_data" ); mActionWN = new KAction( i18n( "What's New?" ), 0, this, SLOT( whatsnew() ), actionCollection(), "wn" ); mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, this, SLOT( synchowto() ), actionCollection(), "sync" ); mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, this, SLOT( kdesynchowto() ), actionCollection(), "kdesync" ); mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, this, SLOT( multisynchowto() ), actionCollection(), "multisync" ); mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, this, SLOT( createAboutData() ), actionCollection(), "kaddressbook_about_data" ); #endif //KAB_EMBEDDED clipboardDataChanged(); connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); } //US we need this function, to plug all actions into the correct menues. // KDE uses a XML format to plug the actions, but we work her without this overhead. void KABCore::addActionsManually() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #ifdef KAB_EMBEDDED QPopupMenu *fileMenu = new QPopupMenu( this ); QPopupMenu *editMenu = new QPopupMenu( this ); QPopupMenu *helpMenu = new QPopupMenu( this ); KToolBar* tb = mMainWindow->toolBar(); mMainWindow->setToolBarsMovable (false ); #ifndef DESKTOP_VERSION if ( KABPrefs::instance()->mFullMenuBarVisible ) { #endif QMenuBar* mb = mMainWindow->menuBar(); //US setup menubar. //Disable the following block if you do not want to have a menubar. mb->insertItem( i18n("&File"), fileMenu ); mb->insertItem( i18n("&Edit"), editMenu ); mb->insertItem( i18n("&View"), viewMenu ); mb->insertItem( i18n("&Settings"), settingsMenu ); #ifdef DESKTOP_VERSION mb->insertItem( i18n("Synchronize"), syncMenu ); #else mb->insertItem( i18n("Sync"), syncMenu ); #endif //mb->insertItem( i18n("&Change"), changeMenu ); mb->insertItem( i18n("&Help"), helpMenu ); mIncSearchWidget = new IncSearchWidget( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget); #ifndef DESKTOP_VERSION } else { //US setup toolbar QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); QPopupMenu *popupBarTB = new QPopupMenu( this ); menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); tb->insertWidget(-1, 0, menuBarTB); mIncSearchWidget = new IncSearchWidget( tb ); tb->enableMoving(false); popupBarTB->insertItem( i18n("&File"), fileMenu ); popupBarTB->insertItem( i18n("&Edit"), editMenu ); popupBarTB->insertItem( i18n("&View"), viewMenu ); popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); mViewManager->getFilterAction()->plug ( popupBarTB); //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); popupBarTB->insertItem( i18n("&Help"), helpMenu ); if (QApplication::desktop()->width() > 320 ) { // mViewManager->getFilterAction()->plug ( tb); } } #endif + mIncSearchWidget->setSize(); // mActionQuit->plug ( mMainWindow->toolBar()); //US Now connect the actions with the menue entries. #ifdef DESKTOP_VERSION mActionPrint->plug( fileMenu ); mActionPrintDetails->plug( fileMenu ); fileMenu->insertSeparator(); #endif mActionMail->plug( fileMenu ); fileMenu->insertSeparator(); mActionNewContact->plug( editMenu ); mActionNewContact->plug( tb ); mActionEditAddressee->plug( editMenu ); editMenu->insertSeparator(); // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || // (!KABPrefs::instance()->mMultipleViewsAtOnce )) mActionEditAddressee->plug( tb ); // fileMenu->insertSeparator(); mActionSave->plug( fileMenu ); fileMenu->insertItem( "&Import", ImportMenu ); fileMenu->insertItem( "&Export", ExportMenu ); editMenu->insertItem( i18n("&Change"), changeMenu ); editMenu->insertSeparator(); #ifndef DESKTOP_VERSION if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); #endif #if 0 // PENDING fix MailVCard fileMenu->insertSeparator(); mActionMailVCard->plug( fileMenu ); #endif #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug( beamMenu ); if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); if ( Ir::supported() ) mActionBeam->plug( beamMenu ); #endif fileMenu->insertSeparator(); mActionQuit->plug( fileMenu ); #ifdef _OL_IMPORT_ mActionImportOL->plug( ImportMenu ); #endif // edit menu mActionUndo->plug( editMenu ); mActionRedo->plug( editMenu ); editMenu->insertSeparator(); mActionCut->plug( editMenu ); mActionCopy->plug( editMenu ); mActionPaste->plug( editMenu ); mActionDelete->plug( editMenu ); editMenu->insertSeparator(); mActionSelectAll->plug( editMenu ); mActionSetFormattedName->plug( changeMenu ); mActionRemoveVoice->plug( changeMenu ); // settingsmings menu //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! // settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu, 0 ); mActionConfigResources->plug( settingsMenu,1 ); settingsMenu->insertSeparator(2); if ( mIsPart ) { //US not implemented yet //mActionConfigShortcuts->plug( settingsMenu ); //mActionConfigureToolbars->plug( settingsMenu ); } else { //US not implemented yet //mActionKeyBindings->plug( settingsMenu ); } mActionEditCategories->plug( settingsMenu ); mActionManageCategories->plug( settingsMenu ); mActionJumpBar->plug( viewMenu,0 ); mActionDetails->plug( viewMenu,0 ); //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug(settingsMenu ); settingsMenu->insertSeparator(); #endif mActionWhoAmI->plug( settingsMenu ); //mActionEditCategories->plug( changeMenu ); mActionCategories->plug( changeMenu ); //mActionManageCategories->plug( changeMenu ); //mActionCategories->plug( settingsMenu ); mActionWN->plug( helpMenu ); mActionSyncHowto->plug( helpMenu ); mActionKdeSyncHowto->plug( helpMenu ); mActionMultiSyncHowto->plug( helpMenu ); mActionFaq->plug( helpMenu ); mActionLicence->plug( helpMenu ); mActionAboutKAddressbook->plug( helpMenu ); if (KGlobal::getDesktopSize() > KGlobal::Small ) { mActionSave->plug( tb ); mViewManager->getFilterAction()->plug ( tb); //LR hide filteraction on started in 480x640 if (QApplication::desktop()->width() == 480 ) { mViewManager->getFilterAction()->setComboWidth( 0 ); } mActionUndo->plug( tb ); mActionDelete->plug( tb ); mActionRedo->plug( tb ); } else { mActionSave->plug( tb ); tb->enableMoving(false); } //mActionQuit->plug ( tb ); - // tb->insertWidget(-1, 0, mIncSearchWidget, 6); + //tb->insertWidget(-1, 0, mIncSearchWidget, 6); //US link the searchwidget first to this. // The real linkage to the toolbar happens later. //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); //US tb->insertItem( mIncSearchWidget ); /*US mIncSearchWidget = new IncSearchWidget( tb ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); mJumpButtonBar = new JumpButtonBar( this, this ); //US topLayout->addWidget( mJumpButtonBar ); this->layout()->add( mJumpButtonBar ); */ #endif //KAB_EMBEDDED mActionExport2phone->plug( ExportMenu ); connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); syncManager->fillSyncMenu(); } void KABCore::showLicence() { KApplication::showLicence(); } void KABCore::manageCategories( ) { KABCatPrefs* cp = new KABCatPrefs(); cp->show(); int w =cp->sizeHint().width() ; int h = cp->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( !cp->exec() ) { delete cp; return; } int count = 0; int cc = 0; message( i18n("Please wait, processing categories...")); if ( cp->addCat() ) { KABC::AddressBook::Iterator it; QStringList catList = KABPrefs::instance()->mCustomCategories; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++cc; if ( cc %10 == 0) message(i18n("Processing contact #%1").arg(cc)); QStringList catIncList = (*it).categories(); int i; for( i = 0; i< catIncList.count(); ++i ) { if ( !catList.contains (catIncList[i])) { catList.append( catIncList[i] ); //qDebug("add cat %s ", catIncList[i].latin1()); ++count; } } } catList.sort(); KABPrefs::instance()->mCustomCategories = catList; KABPrefs::instance()->writeConfig(); message(QString::number( count )+ i18n(" categories added to list! ")); } else { QStringList catList = KABPrefs::instance()->mCustomCategories; QStringList catIncList; QStringList newCatList; KABC::AddressBook::Iterator it; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++cc; if ( cc %10 == 0) message(i18n("Processing contact #%1").arg(cc)); QStringList catIncList = (*it).categories(); int i; if ( catIncList.count() ) { newCatList.clear(); for( i = 0; i< catIncList.count(); ++i ) { if ( catList.contains (catIncList[i])) { newCatList.append( catIncList[i] ); } } newCatList.sort(); (*it).setCategories( newCatList ); mAddressBook->insertAddressee( (*it) ); } } setModified( true ); mViewManager->refreshView(); message( i18n("Removing categories done!")); } delete cp; } void KABCore::removeVoice() { 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 ) return; XXPortSelectDialog dlg( this, false, this ); if ( !dlg.exec() ) return; mAddressBook->setUntagged(); dlg.tagSelected(); message(i18n("Removing voice..."), false ); KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( (*it).tagged() ) { (*it).removeVoice(); } } message(i18n("Refreshing view...") ); qApp->processEvents(); mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); message(i18n("Remove voice completed!") ); } void KABCore::setFormattedName() { KABFormatPrefs setpref; if ( !setpref.exec() ) { return; } XXPortSelectDialog dlg( this, false, this ); if ( !dlg.exec() ) return; mAddressBook->setUntagged(); dlg.tagSelected(); int count = 0; KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( (*it).tagged() ) { ++count; if ( count %10 == 0 ) message(i18n("Changing contact #%1").arg( count ) ); qApp->processEvents(); QString fName; if ( setpref.simple->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); else if ( setpref.full->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); else if ( setpref.reverse->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); else fName = (*it).organization(); if ( setpref.setCompany->isChecked() ) if ( fName.isEmpty() || fName =="," ) fName = (*it).organization(); (*it).setFormattedName( fName ); } } message(i18n("Refreshing view...") ); qApp->processEvents(); mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); message(i18n("Setting formatted name completed!") ); } void KABCore::clipboardDataChanged() { if ( mReadWrite ) mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); } void KABCore::updateActionMenu() { UndoStack *undo = UndoStack::instance(); RedoStack *redo = RedoStack::instance(); if ( undo->isEmpty() ) mActionUndo->setText( i18n( "Undo" ) ); else mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); mActionUndo->setEnabled( !undo->isEmpty() ); if ( !redo->top() ) mActionRedo->setText( i18n( "Redo" ) ); else mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); mActionRedo->setEnabled( !redo->isEmpty() ); } void 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 ) KABC::VCardConverter converter; QStringList list = QStringList::split( "\r\n\r\n", vcards ); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); if ( a.isEmpty() ) { mCore->addressBook()->insertAddressee( addr ); emit modified(); } } } mActiveView->refresh(); } #else //KAB_EMBEDDED qDebug("ViewManager::dropped() has to be changed!!" ); #endif //KAB_EMBEDDED } void ViewManager::startDrag() { kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; #ifndef KAB_EMBEDDED // Get the list of all the selected addressees KABC::Addressee::List addrList; QStringList uidList = selectedUids(); QStringList::Iterator iter; for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) addrList.append( mCore->addressBook()->findByUid( *iter ) ); KMultipleDrag *drag = new KMultipleDrag( this ); drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); KABC::Addressee::List::Iterator it; QStringList vcards; for ( it = addrList.begin(); it != addrList.end(); ++it ) { QString vcard = QString::null; KABC::VCardConverter converter; if ( converter.addresseeToVCard( *it, vcard ) ) vcards.append( vcard ); } drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); drag->dragCopy(); #else //KAB_EMBEDDED qDebug("ViewManager::startDrag() has to be changed!!" ); #endif //KAB_EMBEDDED } void ViewManager::doSearch( const QString& s,KABC::Field *field ) { if ( mActiveView ) mActiveView->doSearch( s, field ); } void ViewManager::setActiveFilter( int index ) { Filter currentFilter; if ( ( index - 1 ) < 0 ) currentFilter = Filter(); else currentFilter = mFilterList[ index - 1 ]; // Check if we have a view. Since the filter combo is created before // the view, this slot could be called before there is a valid view. if ( mActiveView ) { mActiveView->setFilter( currentFilter ); mActiveView->refresh(); emit selected( QString::null ); } } void ViewManager::configureFilters() { FilterDialog dlg( this ); dlg.setFilters( mFilterList ); if ( dlg.exec() ) mFilterList = dlg.filters(); uint pos = mActionSelectFilter->currentItem(); mActionSelectFilter->setItems( filterNames() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); int cw = 150; if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) cw = 0; mActionSelectFilter->setComboWidth( cw ); saveSettings(); } QStringList ViewManager::filterNames() const { QStringList names( i18n( "No Filter" ) ); Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) names.append( (*it).name() ); return names; } Filter ViewManager::getFilterByName( const QString &name ) const { Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) if ( name == (*it).name() ) return (*it); return Filter(); } int ViewManager::filterPosition( const QString &name ) const { int pos = 0; Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) if ( name == (*it).name() ) return pos + 1; return 0; } void ViewManager::initActions() { //US <ActionList name="view_loadedviews"/> //US <Separator/> #ifdef KAB_EMBEDDED QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); #endif //KAB_EMBEDDED mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); #if KDE_VERSION >= 309 mActionSelectView->setMenuAccelsEnabled( false ); #endif connect( mActionSelectView, SIGNAL( activated( const QString& ) ), SLOT( selectView( const QString& ) ) ); #ifdef KAB_EMBEDDED mActionSelectView->plug(viewmenu); viewmenu->insertSeparator(); #endif //KAB_EMBEDDED KAction *action; action = new KAction( i18n( "Modify View..." ), "configure", 0, this, SLOT( editView() ), mCore->actionCollection(), "view_modify" ); #ifndef KAB_EMBEDDED 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." ) ); #else //KAB_EMBEDDED action->plug(viewmenu); #endif //KAB_EMBEDDED action = new KAction( i18n( "Add View..." ), "window_new", 0, this, SLOT( addView() ), mCore->actionCollection(), "view_add" ); #ifndef KAB_EMBEDDED 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." ) ); #else //KAB_EMBEDDED action->plug(viewmenu); #endif //KAB_EMBEDDED mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, this, SLOT( deleteView() ), mCore->actionCollection(), "view_delete" ); #ifndef KAB_EMBEDDED mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); #else //KAB_EMBEDDED mActionDeleteView->plug(viewmenu); viewmenu->insertSeparator(); #endif //KAB_EMBEDDED #ifndef KAB_EMBEDDED action = new KAction( i18n( "Refresh View" ), "reload", 0, this, SLOT( refreshView(const QString &) ), mCore->actionCollection(), "view_refresh" ); action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); #else //KAB_EMBEDDED action = new KAction( i18n( "Refresh View" ), "reload", 0, this, SLOT( refreshView()), mCore->actionCollection(), "view_refresh" ); action->plug(viewmenu); - viewmenu->insertSeparator(); + //viewmenu->insertSeparator(); #endif //KAB_EMBEDDED action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, SLOT( configureFilters() ), mCore->actionCollection(), "options_edit_filters" ); mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); #if KDE_VERSION >= 309 mActionSelectFilter->setMenuAccelsEnabled( false ); #endif connect( mActionSelectFilter, SIGNAL( activated( int ) ), SLOT( setActiveFilter( int ) ) ); #ifdef KAB_EMBEDDED action->plug(settingsmenu); mActionSelectFilter->plug(viewmenu,0); #endif //KAB_EMBEDDED } void ViewManager::initGUI() { QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); mViewWidgetStack = new QWidgetStack( this ); layout->addWidget( mViewWidgetStack ); } #ifndef KAB_EMBEDDED #include "viewmanager.moc" #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 @@ /* * kmail: KDE mail client * This file: Copyright (C) 2000 Espen Sand, espen@kde.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include <qpainter.h> #include <kcolordialog.h> #ifndef KAB_EMBEDDED #include <kcolordrag.h> #endif //KAB_EMBEDDED #include "colorlistbox.h" ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) { connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); + connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); setAcceptDrops( true); } void ColorListBox::setEnabled( bool state ) { if( state == isEnabled() ) { return; } QListBox::setEnabled( state ); for( uint i=0; i<count(); i++ ) { updateItem( i ); } } void ColorListBox::setColor( uint index, const QColor &color ) { if( index < count() ) { ColorListItem *colorItem = (ColorListItem*)item(index); colorItem->setColor(color); updateItem( colorItem ); } } QColor ColorListBox::color( uint index ) const { if( index < count() ) { ColorListItem *colorItem = (ColorListItem*)item(index); return( colorItem->color() ); } else { return( black ); } } - +void ColorListBox::slotNewColor(QListBoxItem * i) +{ + if ( i ) + newColor( index( i ) ); +} void ColorListBox::newColor( int index ) { if( isEnabled() == false ) { return; } if( (uint)index < count() ) { QColor c = color( index ); #ifndef KAB_EMBEDDED if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) { setColor( index, c ); } #else //KAB_EMBEDDED KColorDialog* k = new KColorDialog( this ); k->setColor( c ); int res = k->exec(); if ( res ) { setColor( index, k->getColor() ); } delete k; #endif //KAB_EMBEDDED } } void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) { #ifndef KAB_EMBEDDED if( KColorDrag::canDecode(e) && isEnabled() ) { mCurrentOnDragEnter = currentItem(); e->accept( true ); } else { mCurrentOnDragEnter = -1; e->accept( false ); } #else //KAB_EMBEDDED qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) { #ifndef KAB_EMBEDDED if( mCurrentOnDragEnter != -1 ) { setCurrentItem( mCurrentOnDragEnter ); mCurrentOnDragEnter = -1; } #else //KAB_EMBEDDED qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) { #ifndef KAB_EMBEDDED if( KColorDrag::canDecode(e) && isEnabled() ) { ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); if( item != 0 ) { setCurrentItem ( item ); } } #else //KAB_EMBEDDED qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dropEvent( QDropEvent *e ) { #ifndef KAB_EMBEDDED QColor color; if( KColorDrag::decode( e, color ) ) { int index = currentItem(); if( index != -1 ) { ColorListItem *colorItem = (ColorListItem*)item(index); colorItem->setColor(color); triggerUpdate( false ); // Redraw item } mCurrentOnDragEnter = -1; } #else //KAB_EMBEDDED qDebug("ColorListBox::dropEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } ColorListItem::ColorListItem( const QString &text, const QColor &color ) : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) { setText( text ); } const QColor &ColorListItem::color( void ) { return( mColor ); } void ColorListItem::setColor( const QColor &color ) { mColor = color; } void ColorListItem::paint( QPainter *p ) { QFontMetrics fm = p->fontMetrics(); int h = fm.height(); p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); p->setPen( Qt::black ); p->drawRect( 3, 1, mBoxWidth, h-1 ); p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); } int ColorListItem::height(const QListBox *lb ) const { return( lb->fontMetrics().lineSpacing()+1 ); } int ColorListItem::width(const QListBox *lb ) const { return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); } #ifndef KAB_EMBEDDED #include "colorlistbox.moc" #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 @@ /* * kmail: KDE mail client * This file: Copyright (C) 2000 Espen Sand, espen@kde.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef _COLOR_LISTBOX_H_ #define _COLOR_LISTBOX_H_ #include <klistbox.h> class QDragEnterEvent; class QDragLeaveEvent; class QDragMoveEvent; class QDropEvent; class ColorListBox : public KListBox { Q_OBJECT public: ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); void setColor( uint index, const QColor &color ); QColor color( uint index ) const; public slots: virtual void setEnabled( bool state ); protected: void dragEnterEvent( QDragEnterEvent *e ); void dragLeaveEvent( QDragLeaveEvent *e ); void dragMoveEvent( QDragMoveEvent *e ); void dropEvent( QDropEvent *e ); private slots: void newColor( int index ); + void slotNewColor(QListBoxItem * i); private: int mCurrentOnDragEnter; }; class ColorListItem : public QListBoxItem { public: ColorListItem( const QString &text, const QColor &color=Qt::black ); const QColor &color( void ); void setColor( const QColor &color ); protected: virtual void paint( QPainter * ); virtual int height( const QListBox * ) const; virtual int width( const QListBox * ) const; private: QColor mColor; int mBoxWidth; }; #endif 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 @@ #include <qlabel.h> #include <qcheckbox.h> #include <qvbox.h> #include <qgroupbox.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qwhatsthis.h> #include <kdebug.h> #include <kglobal.h> #include <kglobalsettings.h> #include <klocale.h> #include <kiconloader.h> #include <kconfig.h> #include <kfontdialog.h> #ifndef KAB_EMBEDDED #include <kpushbutton.h> #else //KAB_EMBEDDED #include <qpushbutton.h> #endif //KAB_EMBEDDED #include "colorlistbox.h" #include "configurecardviewdialog.h" ///////////////////////////////// // ConfigureCardViewDialog ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ) : ViewConfigureWidget( ab, parent, name ) { #ifndef KAB_EMBEDDED QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, DesktopIcon( "looknfeel" ) ); #else //KAB_EMBEDDED QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, KGlobal::iconLoader()->loadIcon( "looknfeel", KIcon::Panel ) ); #endif //KAB_EMBEDDED mAdvancedPage = new CardViewLookNFeelPage( page ); } ConfigureCardViewWidget::~ConfigureCardViewWidget() { } void ConfigureCardViewWidget::restoreSettings( KConfig *config ) { ViewConfigureWidget::restoreSettings( config ); mAdvancedPage->restoreSettings( config ); } void ConfigureCardViewWidget::saveSettings( KConfig *config ) { ViewConfigureWidget::saveSettings( config ); mAdvancedPage->saveSettings( config ); } //////////////////////// // CardViewLookNFeelPage CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) : QVBox( parent, name ) { initGUI(); } CardViewLookNFeelPage::~CardViewLookNFeelPage() { } void CardViewLookNFeelPage::restoreSettings( KConfig *config ) { // colors cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); QColor c; qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); #ifndef KAB_EMBEDDED c = KGlobalSettings::baseColor(); #else //KAB_EMBEDDED c = QColor(0,0,0); #endif //KAB_EMBEDDED c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Background Color"), config->readColorEntry( "BackgroundColor", &c ) ) ); c = colorGroup().foreground(); lbColors->insertItem( new ColorListItem( i18n("Text Color"), config->readColorEntry( "TextColor", &c ) ) ); c = colorGroup().button(); lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), config->readColorEntry( "HeaderColor", &c ) ) ); c = colorGroup().buttonText(); lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), config->readColorEntry( "HeaderTextColor", &c ) ) ); c = colorGroup().highlight(); lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), config->readColorEntry( "HighlightColor", &c ) ) ); c = colorGroup().highlightedText(); lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), config->readColorEntry( "HighlightedTextColor", &c ) ) ); enableColors(); // fonts QFont fnt = font(); updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); fnt.setBold( true ); updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); enableFonts(); // layout sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); // behaviour cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); } void CardViewLookNFeelPage::saveSettings( KConfig *config ) { // colors config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. { config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); config->writeEntry( "TextColor", lbColors->color( 1 ) ); config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); } // fonts config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); if ( cbEnableCustomFonts->isChecked() ) { config->writeEntry( "TextFont", lTextFont->font() ); config->writeEntry( "HeaderFont", lHeaderFont->font() ); } // layout config->writeEntry( "ItemMargin", sbMargin->value() ); config->writeEntry( "ItemSpacing", sbSpacing->value() ); config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); // behaviour config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); } void CardViewLookNFeelPage::setTextFont() { QFont f( lTextFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) updateFontLabel( f, lTextFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lTextFont ); #endif //KAB_EMBEDDED } void CardViewLookNFeelPage::setHeaderFont() { QFont f( lHeaderFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) updateFontLabel( f, lHeaderFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lHeaderFont ); #endif //KAB_EMBEDDED } void CardViewLookNFeelPage::enableFonts() { vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); + if ( cbEnableCustomFonts->isChecked() ) + vbFonts->setFocus(); } void CardViewLookNFeelPage::enableColors() { lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + if ( cbEnableCustomColors->isChecked() ) + lbColors->setFocus(); } void CardViewLookNFeelPage::initGUI() { int spacing = KDialog::spacingHint(); int margin = KDialog::marginHint(); QTabWidget *tabs = new QTabWidget( this ); // Layout QVBox *loTab = new QVBox( this, "layouttab" ); loTab->setSpacing( spacing ); loTab->setMargin( margin ); QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); QHBox *hbSW = new QHBox( gbGeneral ); QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); lSW->setBuddy( sbSepWidth); QHBox *hbPadding = new QHBox( gbGeneral ); QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); lSpacing->setBuddy( sbSpacing ); QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); QHBox *hbMargin = new QHBox( gbCards ); QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); lMargin->setBuddy( sbMargin ); cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); loTab->setStretchFactor( new QWidget( loTab ), 1 ); QWhatsThis::add( sbMargin, i18n( "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " "incrementing the item margin will add space between the focus rectangle and the item data." ) ); QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); QWhatsThis::add( sbSpacing, i18n( "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " "borders, other items or column separators." ) ); QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); tabs->addTab( loTab, i18n("&Layout") ); // Colors QVBox *colorTab = new QVBox( this, "colortab" ); colorTab->setSpacing( spacing ); colorTab->setMargin( spacing ); cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); lbColors = new ColorListBox( colorTab ); tabs->addTab( colorTab, i18n("&Colors") ); QWhatsThis::add( cbEnableCustomColors, i18n( "If custom colors are enabled, you may choose the colors for the view below. " "Otherwise colors from your current KDE color scheme are used." ) ); QWhatsThis::add( lbColors, i18n( "Double click or press RETURN on a item to select a color for the related strings in the view." ) ); // Fonts QVBox *fntTab = new QVBox( this, "fonttab" ); fntTab->setSpacing( spacing ); fntTab->setMargin( spacing ); cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); vbFonts = new QWidget( fntTab ); QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); gFnts->setSpacing( spacing ); gFnts->setAutoAdd( true ); gFnts->setColStretch( 1, 1 ); QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); lTextFont = new QLabel( vbFonts ); lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lTFnt->setBuddy( btnFont ); connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); lHeaderFont = new QLabel( vbFonts ); lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lHFnt->setBuddy( btnHeaderFont ); connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); QWhatsThis::add( cbEnableCustomFonts, i18n( "If custom fonts are enabled, you may choose which fonts to use for this view below. " "Otherwise the default KDE font will be used, in bold style for the header and " "normal style for the data." ) ); tabs->addTab( fntTab, i18n("&Fonts") ); // Behaviour QVBox *behaviourTab = new QVBox( this ); behaviourTab->setMargin( margin ); behaviourTab->setSpacing( spacing ); cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); tabs->addTab( behaviourTab, i18n("Be&havior") ); } void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) { l->setFont( fnt ); l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); } #ifndef KAB_EMBEDDED #include "configurecardviewdialog.moc" #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 @@ without including the source code for Qt in the source distribution. */ #include <qstring.h> #include <qwidget.h> #include <qlayout.h> #include <qlabel.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qtabwidget.h> #include <qwhatsthis.h> #include <qpushbutton.h> #include <kglobal.h> #include <klocale.h> #include <klineedit.h> #include <kurlrequester.h> #include <kiconloader.h> #include <kfontdialog.h> #ifndef KAB_EMBEDDED #include <kimageio.h> #else //KAB_EMBEDDED #endif //KAB_EMBEDDED #include <kconfig.h> #include "colorlistbox.h" #include "configuretableviewdialog.h" ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ) : ViewConfigureWidget( ab, parent, name ) { QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, KGlobal::iconLoader()->loadIcon( "looknfeel", KIcon::Panel ) ); mPage = new LookAndFeelPage( page ); } ConfigureTableViewWidget::~ConfigureTableViewWidget() { } void ConfigureTableViewWidget::restoreSettings( KConfig *config ) { ViewConfigureWidget::restoreSettings( config ); mPage->restoreSettings( config ); } void ConfigureTableViewWidget::saveSettings( KConfig *config ) { ViewConfigureWidget::saveSettings( config ); mPage->saveSettings( config ); } LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) : QVBox(parent, name) { initGUI(); // Set initial state enableBackgroundToggled(mBackgroundBox->isChecked()); } void LookAndFeelPage::restoreSettings( KConfig *config ) { mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) mNoneButton->setChecked(true); mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); // colors cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); QColor c; qDebug("LookAndFeelPage::restoreSettings make base color configurable"); #ifndef KAB_EMBEDDED c = KGlobalSettings::baseColor(); #else //KAB_EMBEDDED c = QColor(0,0,0); #endif //KAB_EMBEDDED c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Background Color"), config->readColorEntry( "BackgroundColor", &c ) ) ); c = colorGroup().foreground(); lbColors->insertItem( new ColorListItem( i18n("Text Color"), config->readColorEntry( "TextColor", &c ) ) ); c = colorGroup().button(); lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); c = colorGroup().buttonText(); lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), config->readColorEntry( "HeaderTextColor", &c ) ) ); c = colorGroup().highlight(); lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), config->readColorEntry( "HighlightColor", &c ) ) ); c = colorGroup().highlightedText(); lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), config->readColorEntry( "HighlightedTextColor", &c ) ) ); c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); enableColors(); // fonts QFont fnt = font(); updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); fnt.setBold( true ); updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); enableFonts(); } void LookAndFeelPage::saveSettings( KConfig *config ) { config->writeEntry("ABackground", mAlternateButton->isChecked()); config->writeEntry("SingleLine", mLineButton->isChecked()); config->writeEntry("ToolTips", mToolTipBox->isChecked()); config->writeEntry("Background", mBackgroundBox->isChecked()); config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); // colors config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. { config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); config->writeEntry( "TextColor", lbColors->color( 1 ) ); config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); } // fonts config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); if ( cbEnableCustomFonts->isChecked() ) { config->writeEntry( "TextFont", lTextFont->font() ); config->writeEntry( "HeaderFont", lHeaderFont->font() ); } } void LookAndFeelPage::setTextFont() { QFont f( lTextFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) updateFontLabel( f, lTextFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lTextFont ); #endif //KAB_EMBEDDED } void LookAndFeelPage::setHeaderFont() { QFont f( lHeaderFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) updateFontLabel( f, lHeaderFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lHeaderFont ); #endif //KAB_EMBEDDED } void LookAndFeelPage::enableFonts() { vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); + if ( cbEnableCustomFonts->isChecked() ) + vbFonts->setFocus(); } void LookAndFeelPage::enableColors() { - lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + if ( cbEnableCustomColors->isChecked() ) + lbColors->setFocus(); } void LookAndFeelPage::initGUI() { int spacing = KDialog::spacingHint(); int margin = KDialog::marginHint(); QTabWidget *tabs = new QTabWidget( this ); // General QVBox *generalTab = new QVBox( this, "generaltab" ); generalTab->setSpacing( spacing ); generalTab->setMargin( margin ); QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, i18n("Row Separator"), generalTab); mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), group, "mAlternateButton"); mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, "mBackgroundBox"); connect(mBackgroundBox, SIGNAL(toggled(bool)), SLOT(enableBackgroundToggled(bool))); // LR image not implemented mBackgroundBox->setEnabled( false ); mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); #ifndef KAB_EMBEDDED mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); #endif //KAB_EMBEDDED // ToolTip Checkbox mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, "mToolTipBox"); tabs->addTab( generalTab, i18n("&General") ); // Colors QVBox *colorTab = new QVBox( this, "colortab" ); colorTab->setSpacing( spacing ); colorTab->setMargin( spacing ); cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); lbColors = new ColorListBox( colorTab ); tabs->addTab( colorTab, i18n("&Colors") ); QWhatsThis::add( cbEnableCustomColors, i18n( "If custom colors are enabled, you may choose the colors for the view below. " "Otherwise colors from your current KDE color scheme are used." ) ); QWhatsThis::add( lbColors, i18n( "Double click or press RETURN on a item to select a color for the related strings in the view." ) ); // Fonts QVBox *fntTab = new QVBox( this, "fonttab" ); fntTab->setSpacing( spacing ); fntTab->setMargin( spacing ); cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); vbFonts = new QWidget( fntTab ); QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); gFnts->setSpacing( spacing ); gFnts->setAutoAdd( true ); gFnts->setColStretch( 1, 1 ); QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); lTextFont = new QLabel( vbFonts ); lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lTFnt->setBuddy( btnFont ); connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); lHeaderFont = new QLabel( vbFonts ); lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lHFnt->setBuddy( btnHeaderFont ); connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); QWhatsThis::add( cbEnableCustomFonts, i18n( "If custom fonts are enabled, you may choose which fonts to use for this view below. " "Otherwise the default KDE font will be used, in bold style for the header and " "normal style for the data." ) ); tabs->addTab( fntTab, i18n("&Fonts") ); } void LookAndFeelPage::enableBackgroundToggled(bool enabled) { mBackgroundName->setEnabled(enabled); } void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) { l->setFont( fnt ); l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); } #ifndef KAB_EMBEDDED #include "configuretableviewdialog.moc" #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 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> Marcus Bains line. Copyright (c) 2001 Ali Rahimi This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef _WIN32_ #define protected public #include <qwidget.h> #undef protected #endif #include <qintdict.h> #include <qdatetime.h> #include <qapplication.h> #include <qpopupmenu.h> #include <qcursor.h> #include <qpainter.h> #include <kdebug.h> #include <klocale.h> #include <kiconloader.h> #include <kglobal.h> #include "koagendaitem.h" #include "koprefs.h" #include "koglobals.h" #include "koagenda.h" #include <libkcal/event.h> #include <libkcal/todo.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif //extern bool globalFlagBlockPainting; extern int globalFlagBlockAgenda; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; extern int globalFlagBlockStartup; //////////////////////////////////////////////////////////////////////////// MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) : QFrame(_agenda->viewport(),name), agenda(_agenda) { setLineWidth(0); setMargin(0); setBackgroundColor(Qt::red); minutes = new QTimer(this); connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); minutes->start(0, true); mTimeBox = new QLabel(this); mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); QPalette pal = mTimeBox->palette(); pal.setColor(QColorGroup::Foreground, Qt::red); mTimeBox->setPalette(pal); //mTimeBox->setAutoMask(true); agenda->addChild(mTimeBox); oldToday = -1; } MarcusBains::~MarcusBains() { delete minutes; } int MarcusBains::todayColumn() { QDate currentDate = QDate::currentDate(); DateList dateList = agenda->dateList(); DateList::ConstIterator it; int col = 0; for(it = dateList.begin(); it != dateList.end(); ++it) { if((*it) == currentDate) return KOGlobals::self()->reverseLayout() ? agenda->columns() - 1 - col : col; ++col; } return -1; } void MarcusBains::updateLoc() { updateLocation(); } void MarcusBains::updateLocation(bool recalculate) { QTime tim = QTime::currentTime(); //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); if((tim.hour() == 0) && (oldTime.hour()==23)) recalculate = true; int mins = tim.hour()*60 + tim.minute(); int minutesPerCell = 24 * 60 / agenda->rows(); int y = mins*agenda->gridSpacingY()/minutesPerCell; int today = recalculate ? todayColumn() : oldToday; int x = agenda->gridSpacingX()*today; bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); oldTime = tim; oldToday = today; if(disabled || (today<0)) { hide(); mTimeBox->hide(); return; } else { show(); mTimeBox->show(); } if(recalculate) setFixedSize(agenda->gridSpacingX(),1); agenda->moveChild(this, x, y); raise(); if(recalculate) //mTimeBox->setFont(QFont("helvetica",10)); mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); mTimeBox->adjustSize(); // the -2 below is there because there is a bug in this program // somewhere, where the last column of this widget is a few pixels // narrower than the other columns. int offs = (today==agenda->columns()-1) ? -4 : 0; agenda->moveChild(mTimeBox, x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, y-mTimeBox->height()); mTimeBox->raise(); //mTimeBox->setAutoMask(true); minutes->start(5000,true); } //////////////////////////////////////////////////////////////////////////// /* Create an agenda widget with rows rows and columns columns. */ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, const char *name,WFlags f) : QScrollView(parent,name,f) { - + mAllAgendaPopup = 0; mColumns = columns; mRows = rows; mGridSpacingY = rowSize; mAllDayMode = false; #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); } /* Create an agenda widget with columns columns and one row. This is used for all-day events. */ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : QScrollView(parent,name,f) { + mAllAgendaPopup = 0; blockResize = false; mColumns = columns; mRows = 1; //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); mGridSpacingY = KOPrefs::instance()->mAllDaySize; mAllDayMode = true; #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mHolidayMask = 0; init(); } KOAgenda::~KOAgenda() { if(mMarcusBains) delete mMarcusBains; } Incidence *KOAgenda::selectedIncidence() const { return (mSelectedItem ? mSelectedItem->incidence() : 0); } QDate KOAgenda::selectedIncidenceDate() const { return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); } void KOAgenda::init() { mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); mNewItemPopup = new QPopupMenu( this ); connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) pathString += "icons16/"; } else pathString += "iconsmini/"; - + mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); mNewItemPopup->insertSeparator ( ); mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); #ifndef _WIN32_ int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase viewport()->setWFlags ( wflags); #endif mGridSpacingX = 80; mResizeBorderWidth = 8; mScrollBorderWidth = 8; mScrollDelay = 30; mScrollOffset = 10; mPaintPixmap.resize( 20,20); //enableClipper(true); // Grab key strokes for keyboard navigation of agenda. Seems to have no // effect. Has to be fixed. setFocusPolicy(WheelFocus); connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); mStartCellX = 0; mStartCellY = 0; mCurrentCellX = 0; mCurrentCellY = 0; mSelectionCellX = 0; mSelectionYTop = 0; mSelectionHeight = 0; mOldLowerScrollValue = -1; mOldUpperScrollValue = -1; mClickedItem = 0; mActionItem = 0; mActionType = NOP; mItemMoved = false; mSelectedItem = 0; // mItems.setAutoDelete(true); resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); viewport()->update(); setMinimumSize(30, 1); // setMaximumHeight(mGridSpacingY * mRows + 5); // Disable horizontal scrollbar. This is a hack. The geometry should be // controlled in a way that the contents horizontally always fits. Then it is // not necessary to turn off the scrollbar. setHScrollBarMode(AlwaysOff); if ( ! mAllDayMode ) setVScrollBarMode(AlwaysOn); else setVScrollBarMode(AlwaysOff); setStartHour(KOPrefs::instance()->mDayBegins); calculateWorkingHours(); connect(verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(checkScrollBoundaries(int))); // Create the Marcus Bains line. if(mAllDayMode) mMarcusBains = 0; else { mMarcusBains = new MarcusBains(this); addChild(mMarcusBains); } mPopupKind = 0; mPopupItem = 0; } void KOAgenda::clear() { KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { mUnusedItems.append( item ); //item->hide(); } mItems.clear(); mSelectedItem = 0; clearSelection(); } void KOAgenda::clearSelection() { mSelectionCellX = 0; mSelectionYTop = 0; mSelectionHeight = 0; } void KOAgenda::marcus_bains() { if(mMarcusBains) mMarcusBains->updateLocation(true); } void KOAgenda::changeColumns(int columns) { if (columns == 0) { qDebug("KOAgenda::changeColumns() called with argument 0 "); return; } clear(); mColumns = columns; computeSizes(); } /* This is the eventFilter function, which gets all events from the KOAgendaItems contained in the agenda. It has to handle moving and resizing for all items. */ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) { // kdDebug() << "KOAgenda::eventFilter" << endl; switch(event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: case QEvent::MouseMove: return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); case (QEvent::Leave): if (!mActionItem) setCursor(arrowCursor); return true; default: return QScrollView::eventFilter(object,event); } } void KOAgenda::popupMenu() { mPopupTimer->stop(); if ( mPopupKind == 1 ) { if (mActionItem ) { endItemAction(); } mLeftMouseDown = false; // no more leftMouse computation if (mPopupItem) { selectItem(mPopupItem); + if ( mAllAgendaPopup ) + mAllAgendaPopup->installEventFilter( this ); emit showIncidencePopupSignal(mPopupItem->incidence()); } } else if ( mPopupKind == 2 ) { if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action endSelectAction( false ); // do not emit new event signal mLeftMouseDown = false; // no more leftMouse computation } + mNewItemPopup->installEventFilter( this ); mNewItemPopup->popup( mPopupPos); + } mLeftMouseDown = false; mPopupItem = 0; mPopupKind = 0; } bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) { - //qDebug("KOAgenda::eventFilter_mous "); + static int startX = 0; + static int startY = 0; + static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); + static bool blockMoving = true; + + //qDebug("KOAgenda::eventFilter_mous "); + if ( object == mNewItemPopup ) { + //qDebug("mNewItemPopup "); + if ( me->type() == QEvent::MouseButtonRelease ) { + mNewItemPopup->removeEventFilter( this ); + int dX = me->globalPos().x() - mPopupPos.x();; + if ( dX < 0 ) + dX = -dX; + int dY = me->globalPos().y() - mPopupPos.y(); + if ( dY < 0 ) + dY = -dY; + if ( dX > blockmoveDist || dY > blockmoveDist ) { + mNewItemPopup->hide(); + } + } + return true; + } + if ( object == mAllAgendaPopup ) { + //qDebug(" mAllAgendaPopup "); + if ( me->type() == QEvent::MouseButtonRelease ) { + mAllAgendaPopup->removeEventFilter( this ); + int dX = me->globalPos().x() - mPopupPos.x();; + if ( dX < 0 ) + dX = -dX; + int dY = me->globalPos().y() - mPopupPos.y(); + if ( dY < 0 ) + dY = -dY; + if ( dX > blockmoveDist || dY > blockmoveDist ) { + mAllAgendaPopup->hide(); + } + } + return true; + } QPoint viewportPos; if (object != viewport()) { viewportPos = ((QWidget *)object)->mapToParent(me->pos()); } else { viewportPos = me->pos(); } - static int startX = 0; - static int startY = 0; - static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); - static bool blockMoving = true; + switch (me->type()) { case QEvent::MouseButtonPress: if (me->button() == LeftButton) { mPopupTimer->start( 600 ); mLeftMouseDown = true; } blockMoving = true; startX = viewportPos.x(); - startY = viewportPos.y(); + startY = viewportPos.y(); + mPopupPos = me->globalPos(); if (object != viewport()) { mPopupItem = (KOAgendaItem *)object; mPopupKind = 1; if (me->button() == RightButton) { popupMenu(); } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { if ( mSelectionHeight > 0 ) { int selectionCellX = mSelectionCellX * mGridSpacingX; int selectionYTop = mSelectionYTop; int gridSpacingX = mGridSpacingX; int selectionHeight = mSelectionHeight; clearSelection(); repaintContents( selectionCellX, selectionYTop, gridSpacingX, selectionHeight,false ); } selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } } } } else { // ---------- viewport() mPopupItem = 0; mPopupKind = 2; selectItem(0); mActionItem = 0; - mPopupPos = viewport()->mapToGlobal( me->pos() ); if (me->button() == RightButton) { int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); mCurrentCellX = gx; mCurrentCellY = gy; mStartCellX = gx; mStartCellY = gy; popupMenu(); } else if (me->button() == LeftButton) { setCursor(arrowCursor); startSelectAction(viewportPos); } } break; case QEvent::MouseButtonRelease: if (me->button() == LeftButton ) { mPopupTimer->stop(); } if (object != viewport()) { if (me->button() == LeftButton && mLeftMouseDown) { if (mActionItem) { QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { mScrollUpTimer.stop(); mScrollDownTimer.stop(); mActionItem->resetMove(); placeSubCells( mActionItem ); // emit startDragSignal( mActionItem->incidence() ); setCursor( arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; mLeftMouseDown = false; return true; } endItemAction(); } } } else { // ---------- viewport() if (me->button() == LeftButton && mLeftMouseDown ) { //left click endSelectAction( true ); // emit new event signal } } if (me->button() == LeftButton) mLeftMouseDown = false; break; case QEvent::MouseMove: //qDebug("mm "); if ( !mLeftMouseDown ) return false; if ( blockMoving ) { int dX, dY; dX = startX - viewportPos.x(); if ( dX < 0 ) dX = -dX; dY = viewportPos.y() - startY; if ( dY < 0 ) dY = -dY; //qDebug("%d %d %d ", dX, dY , blockmoveDist ); if ( dX > blockmoveDist || dY > blockmoveDist ) { blockMoving = false; } } if ( ! blockMoving ) mPopupTimer->stop(); if (object != viewport()) { KOAgendaItem *moveItem = (KOAgendaItem *)object; if (!moveItem->incidence()->isReadOnly() ) { if (!mActionItem) setNoActionCursor(moveItem,viewportPos); else { if ( !blockMoving ) performItemAction(viewportPos); } } } else { // ---------- viewport() mPopupPos = viewport()->mapToGlobal( me->pos() ); if ( mActionType == SELECT ) { performSelectAction( viewportPos ); } } break; case QEvent::MouseButtonDblClick: mPopupTimer->stop(); if (object == viewport()) { selectItem(0); int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); emit newEventSignal(gx,gy); } else { KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; selectItem(doubleClickedItem); if ( KOPrefs::instance()->mEditOnDoubleClick ) emit editIncidenceSignal(doubleClickedItem->incidence()); else emit showIncidenceSignal(doubleClickedItem->incidence()); } break; default: break; } return true; #if 0 //qDebug("KOAgenda::eventFilter_mous "); QPoint viewportPos; if (object != viewport()) { viewportPos = ((QWidget *)object)->mapToParent(me->pos()); } else { viewportPos = me->pos(); } static int startX = 0; static int startY = 0; static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); static bool blockMoving = true; static bool leftMouseDown = false; bool rightButtonPressed = false; switch (me->type()) { case QEvent::MouseButtonPress: if (me->button() == LeftButton) { leftMouseDown = true; } else if (me->button() == RightButton) { leftMouseDown = false; } blockMoving = true; startX = viewportPos.x(); startY = viewportPos.y(); if (object != viewport()) { // item clicked ************** if (me->button() == RightButton) { leftMouseDown = false; mClickedItem = (KOAgendaItem *)object; if (mActionItem ) { endItemAction(); } if (mClickedItem) { selectItem(mClickedItem); emit showIncidencePopupSignal(mClickedItem->incidence()); } return true; } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { if ( mSelectionHeight > 0 ) { int selectionCellX = mSelectionCellX * mGridSpacingX; int selectionYTop = mSelectionYTop; int gridSpacingX = mGridSpacingX; int selectionHeight = mSelectionHeight; clearSelection(); repaintContents( selectionCellX, selectionYTop, gridSpacingX, selectionHeight,false ); } selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } } } } else { // ---------- viewport() selectItem(0); mActionItem = 0; if (me->button() == LeftButton ) { setCursor(arrowCursor); startSelectAction(viewportPos); } else if (me->button() == RightButton ) { setCursor(arrowCursor); if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action endSelectAction( false ); // do not emit new event signal leftMouseDown = false; // no more leftMouse computation } int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); mCurrentCellX = gx; mCurrentCellY = gy; mStartCellX = gx; mStartCellY = gy; 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 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KOAGENDA_H #define KOAGENDA_H #include <qscrollview.h> #include <qtimer.h> #include <qmemarray.h> #include <qpainter.h> #include <qpixmap.h> #include <qguardedptr.h> #include "koagendaitem.h" +#include "koeventview.h" class QPopupMenu; class QTime; class KConfig; class QFrame; class KOAgenda; class KCal::Event; class KCal::Todo; using namespace KCal; class MarcusBains : public QFrame { Q_OBJECT public: MarcusBains(KOAgenda *agenda=0,const char *name=0); virtual ~MarcusBains(); public slots: void updateLocation(bool recalculate=false); void updateLoc(); private: int todayColumn(); QTimer *minutes; QLabel *mTimeBox; KOAgenda *agenda; QTime oldTime; int oldToday; }; class KOAgenda : public QScrollView { Q_OBJECT public: enum MouseActionType { NOP, MOVE, SELECT, RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, const char * name=0, WFlags f=0 ); KOAgenda ( int columns, QWidget * parent=0, const char * name=0, WFlags f=0 ); virtual ~KOAgenda(); Incidence *selectedIncidence() const; QDate selectedIncidenceDate() const; virtual bool eventFilter ( QObject *, QEvent * ); void contentsToGrid (int x, int y, int& gx, int& gy); void gridToContents (int gx, int gy, int& x, int& y); int timeToY (const QTime &time); QTime gyToTime (int y); void setStartHour(int startHour); KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, int YTop,int YBottom); void changeColumns(int columns); int columns() { return mColumns; } int rows() { return mRows; } int gridSpacingX() const { return mGridSpacingX; } int gridSpacingY() const { return mGridSpacingY; } // virtual QSizePolicy sizePolicy() const; void clear(); void clearSelection(); void hideUnused(); /** Calculates the minimum width */ virtual int minimumWidth() const; /** Update configuration from preference settings */ void updateConfig(); void checkScrollBoundaries(); void setHolidayMask(QMemArray<bool> *); void setDateList(const DateList &selectedDates); DateList dateList() const; void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); void finishUpdate(); void printSelection(); void storePosition(); void restorePosition(); - + void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } public slots: void popupMenu(); void newItem( int ); void moveChild( QWidget *, int, int ); void scrollUp(); void scrollDown(); void updateTodo( Todo * t, int , bool ); void popupAlarm(); void checkScrollBoundaries(int); /** Deselect selected items. This function does not emit any signals. */ void deselectItem(); /** Select item. If the argument is 0, the currently selected item gets deselected. This function emits the itemSelected(bool) signal to inform about selection/deseelction of events. */ void selectItem(KOAgendaItem *); void finishResize(); signals: void showDateView( int, int); void newEventSignal(); void newEventSignal(int gx,int gy); void newTodoSignal(int gx,int gy); void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); void newStartSelectSignal(); void showIncidenceSignal(Incidence *); void editIncidenceSignal(Incidence *); void deleteIncidenceSignal(Incidence *); void showIncidencePopupSignal(Incidence *); void itemModified(KOAgendaItem *item, int ); void incidenceSelected(Incidence *); void lowerYChanged(int); void upperYChanged(int); void startDragSignal(Incidence *); void addToCalSignal(Incidence *, Incidence *); void resizedSignal(); protected: + KOEventPopupMenu * mAllAgendaPopup; QPainter mPixPainter; QPixmap mPaintPixmap; QPixmap mHighlightPixmap; void drawContents(QPainter *p,int cx, int cy, int cw, int ch); virtual void resizeEvent ( QResizeEvent * ); /** Handles mouse events. Called from eventFilter */ virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); /** Start selecting time span. */ void startSelectAction(QPoint viewportPos); /** Select time span. */ void performSelectAction(QPoint viewportPos); /** Emd selecting time span. */ void endSelectAction( bool emitNewEvent = false ); /** Start moving/resizing agenda item */ void startItemAction(QPoint viewportPos); /** Move/resize agenda item */ void performItemAction(QPoint viewportPos); /** End moving/resizing agenda item */ void endItemAction(); /** Set cursor, when no item action is in progress */ void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); /** Place agenda item in agenda and adjust other cells if necessary */ void placeSubCells(KOAgendaItem *placeItem); /** Process the keyevent, including the ignored keyevents of eventwidgets. * Implements pgup/pgdn and cursor key navigation in the view. */ void keyPressEvent( QKeyEvent * ); void calculateWorkingHours(); virtual void contentsMousePressEvent ( QMouseEvent * ); private: void init(); void marcus_bains(); bool mAllDayMode; bool blockResize; bool mLeftMouseDown; KOAgendaItem *mPopupItem; QTimer* mPopupTimer; int mPopupKind; QPoint mPopupPos; QTimer mResizeTimer; double mContentPosition; // Width and height of agenda cells int mGridSpacingX; int mGridSpacingY; // size of border, where mouse action will resize the KOAgendaItem int mResizeBorderWidth; // size of border, where mouse mve will cause a scroll of the agenda int mScrollBorderWidth; int mScrollDelay; int mScrollOffset; QTimer mScrollUpTimer; QTimer mScrollDownTimer; // Number of Columns/Rows of agenda grid int mColumns; int mRows; // Cells to store Move and Resize coordiantes int mStartCellX; int mStartCellY; int mCurrentCellX; int mCurrentCellY; // Working Hour coordiantes bool mWorkingHoursEnable; int mWorkingHoursYTop; int mWorkingHoursYBottom; // Selection int mSelectionCellX; int mSelectionYTop; int mSelectionHeight; // List of dates to be displayed DateList mSelectedDates; // The KOAgendaItem, which has been right-clicked last KOAgendaItem *mClickedItem; // The KOAgendaItem, which is being moved/resized QGuardedPtr<KOAgendaItem> mActionItem; // Currently selected item QGuardedPtr<KOAgendaItem> mSelectedItem; // The Marcus Bains Line widget. MarcusBains *mMarcusBains; void computeSizes(); MouseActionType mActionType; bool mItemMoved; // List of all Items contained in agenda QPtrList<KOAgendaItem> mItems; QPtrList<KOAgendaItem> mUnusedItems; KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems QPopupMenu *mNewItemPopup; int mOldLowerScrollValue; int mOldUpperScrollValue; KOAgendaItem * getItemForTodo ( Todo * todo ); QMemArray<bool> *mHolidayMask; int mCurPixWid; int mCurPixHei; }; #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) mMouseDownY = e->pos().y(); mOrgCap = topLevelWidget()->caption(); } void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) { int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize-2)/2; topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); } void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) { topLevelWidget()->setCaption( mOrgCap ); int diff = mMouseDownY - e->pos().y(); if ( diff < 10 && diff > -10 ) return; int tSize = KOPrefs::instance()->mHourSize + (diff/10); if ( tSize < 4 ) tSize = 4; if ( tSize > 22 ) tSize = 22; tSize = (tSize/2)*2; if ( tSize == KOPrefs::instance()->mHourSize ) return; KOPrefs::instance()->mHourSize = tSize; emit scaleChanged(); } /** This is called in response to repaint() */ void TimeLabels::paintEvent(QPaintEvent*) { // kdDebug() << "paintevent..." << endl; // this is another hack! // QPainter painter(this); //QString c repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); } //////////////////////////////////////////////////////////////////////////// EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) : QFrame(parent,name) { mColumns = 1; mTopBox = 0; mLocation = loc; mTopLayout = 0; mPaintWidget = 0; mXOffset = 0; if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); else mPixmap = SmallIcon("1downarrow"); mEnabled.resize(mColumns); mEnabled.fill( false ); setMinimumHeight(mPixmap.height()); } EventIndicator::~EventIndicator() { } void EventIndicator::drawContents(QPainter *p) { // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; KDGanttSplitterHandle* han = 0; if ( mPaintWidget ) han = mPaintWidget->firstHandle(); if ( ! han ) { int i; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : i*cellWidth + (cellWidth -mPixmap.width()) /2; p->drawPixmap(QPoint(1+xOffset,0),mPixmap); } } } else { han->repaint(); //mPaintWidget->setBackgroundColor( red ); QPainter pa( han ); int i; bool setColor = false; for(i=0;i<mColumns;++i) { if (mEnabled[i]) { setColor = true; int cellWidth = contentsRect().right()/mColumns; int xOffset = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : i*cellWidth + cellWidth/2 -mPixmap.width()/2; pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); //qDebug("222draw pix %d ",xOffset ); } } pa.end(); } } void EventIndicator::setXOffset( int x ) { mXOffset = x; } void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) { mPaintWidget = w; setMaximumHeight(0); setMinimumHeight(0); } void EventIndicator::changeColumns(int columns) { mColumns = columns; mEnabled.resize(mColumns); update(); } void EventIndicator::enableColumn(int column, bool enable) { mEnabled[column] = enable; } //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : KOEventView (cal,parent,name) { mBlockUpdating = true; mStartHour = 8; mSelectedDates.append(QDate::currentDate()); mLayoutDayLabels = 0; mDayLabelsFrame = 0; mDayLabels = 0; bool isRTL = KOGlobals::self()->reverseLayout(); QPixmap expandPix; if ( KOPrefs::instance()->mVerticalScreen ) { expandPix = SmallIcon( "1updownarrow" ); } else { expandPix = SmallIcon("1leftrightarrow" ); } QBoxLayout *topLayout = new QVBoxLayout(this); // Create day name labels for agenda columns // Create agenda splitter mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); topLayout->addWidget( mSplitterAgenda ); mAllDayFrame = new QHBox(mSplitterAgenda); mAllDayFrame->setFocusPolicy(NoFocus); QWidget *agendaFrame = new QWidget(mSplitterAgenda); agendaFrame->setFocusPolicy(NoFocus); // Create all-day agenda widget mDummyAllDayLeft = new QVBox( mAllDayFrame ); mExpandButton = new QPushButton(mDummyAllDayLeft); mExpandButton->setPixmap( expandPix ); int widebut = mExpandButton->sizeHint().width()+4; int heibut = mExpandButton->sizeHint().height()+4; if ( heibut > widebut ) widebut = heibut ; //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, // QSizePolicy::Fixed ) ); mExpandButton->setFixedSize( widebut, widebut); connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); mExpandButton->setFocusPolicy(NoFocus); mAllDayAgenda = new KOAgenda(1,mAllDayFrame); mAllDayAgenda->setFocusPolicy(NoFocus); QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); // Create event context menu for all day agenda - mAllDayAgendaPopup = eventPopup(); - connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), - mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); + //mAllDayAgendaPopup = eventPopup(); // Create agenda frame QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); // QHBox *agendaFrame = new QHBox(splitterAgenda); // create event indicator bars mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); #ifndef DESKTOP_VERSION // FIX mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); #endif mDayLabelsFrame = new QHBox(agendaFrame); //topLayout->addWidget(mDayLabelsFrame); mDayLabels = new QFrame (mDayLabelsFrame); mLayoutDayLabels = new QHBoxLayout(mDayLabels); agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); agendaLayout->addWidget(mEventIndicatorTop,1,1); mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, agendaFrame); agendaLayout->addWidget(mEventIndicatorBottom,3,1); QWidget *dummyAgendaRight = new QWidget(agendaFrame); agendaLayout->addWidget(dummyAgendaRight,1,2); // Create time labels mTimeLabels = new TimeLabels(24,agendaFrame); agendaLayout->addWidget(mTimeLabels,2,0); connect(mTimeLabels,SIGNAL( scaleChanged()), this,SLOT(updateConfig())); // Create agenda mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); agendaLayout->setColStretch(1,1); mAgenda->setFocusPolicy(NoFocus); // Create event context menu for agenda - mAgendaPopup = eventPopup(); + mAllAgendaPopup = eventPopup(); - mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), + mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), i18n("Toggle Alarm"),mAgenda, SLOT(popupAlarm()),true); connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), - mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); + mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); + connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), + mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); + mAgenda->setPopup( mAllAgendaPopup ); + mAllDayAgenda->setPopup( mAllAgendaPopup ); // make connections between dependent widgets mTimeLabels->setAgenda(mAgenda); // Update widgets to reflect user preferences // updateConfig(); // createDayLabels(); // these blank widgets make the All Day Event box line up with the agenda dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); // Scrolling connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), mTimeLabels, SLOT(positionChanged())); connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), SLOT(setContentsPos(int))); connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); // Create/Show/Edit/Delete Event connect(mAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEvent(int,int))); connect(mAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodo(int,int))); connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEvent(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), SLOT(newEventAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), SLOT(newTodoAllDay(int,int))); connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), SLOT(newEventAllDay(int,int))); connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelected(int,int,int,int))); connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), SIGNAL(editIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), SIGNAL(showIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), SIGNAL(deleteIncidenceSignal(Incidence *))); connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int ))); connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), SLOT(updateEventDates(KOAgendaItem *, int))); // event indicator update connect(mAgenda,SIGNAL(lowerYChanged(int)), SLOT(updateEventIndicatorTop(int))); connect(mAgenda,SIGNAL(upperYChanged(int)), SLOT(updateEventIndicatorBottom(int))); // drag signals /* connect(mAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), SLOT(startDrag(Event *))); */ // synchronize selections connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAllDayAgenda, SLOT( deselectItem() ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), mAgenda, SLOT( deselectItem() ) ); connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), SIGNAL( incidenceSelected( Incidence * ) ) ); connect( mAgenda, SIGNAL( resizedSignal() ), SLOT( updateConfig( ) ) ); connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), SLOT( addToCalSlot(Incidence * , Incidence *) ) ); // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); } void KOAgendaView::toggleAllDay() { if ( mSplitterAgenda->firstHandle() ) mSplitterAgenda->firstHandle()->toggle(); } void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) { calendar()->addIncidence( inc ); if ( incOld ) { if ( incOld->type() == "Todo" ) emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); else emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); } } KOAgendaView::~KOAgendaView() { - delete mAgendaPopup; - delete mAllDayAgendaPopup; + delete mAllAgendaPopup; + //delete mAllDayAgendaPopup; delete KOAgendaItem::paintPix(); delete KOAgendaItem::paintPixSel(); } void KOAgendaView::resizeEvent( QResizeEvent* e ) { //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); bool uc = false; int ow = e->oldSize().width(); int oh = e->oldSize().height(); int w = e->size().width(); int h = e->size().height(); if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) uc = true; //qDebug("view changed %d %d %d %d ", ow, oh , w , h); } mUpcomingWidth = e->size().width() ; if ( mBlockUpdating || uc ) { mBlockUpdating = false; //mAgenda->setMinimumSize(800 , 600 ); //qDebug("mAgenda->resize+++++++++++++++ "); updateConfig(); //qDebug("KOAgendaView::Updating now possible "); } else createDayLabels(); //qDebug("resizeEvent end "); } void KOAgendaView::slotDaylabelClicked( int num ) { QDate firstDate = mSelectedDates.first(); if ( num == -1 ) emit showDateView( 6, firstDate ); else if (num >= 0 ) { if ( mSelectedDates.count() == 1) emit showDateView( 9, firstDate.addDays( num ) ); else emit showDateView( 3, firstDate.addDays( num ) ); } else showDateView( 10, firstDate.addDays(1) ); } KOAgendaButton* KOAgendaView::getNewDaylabel() { KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); return dayLabel ; } void KOAgendaView::createDayLabels() { if ( mBlockUpdating || globalFlagBlockLabel == 1) { // qDebug(" KOAgendaView::createDayLabels() blocked "); return; } int newHight; // ### Before deleting and recreating we could check if mSelectedDates changed... // It would remove some flickering and gain speed (since this is called by // each updateView() call) int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; if ( QApplication::desktop()->width() <= 320 ) maxWid -= 10; mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); if ( maxWid < 0 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); int selCount = mSelectedDates.count(); QString dayTest = "Mon 20"; //QString dayTest = "Mon 20"; int wid = fm.width( dayTest ); //maxWid -= ( selCount * 3 ); //working for QLabels maxWid -= ( selCount * 3 ); //working for QPushButton if ( maxWid < 0 ) maxWid = 20; int needWid = wid * selCount; //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); //if ( needWid > maxWid ) // qDebug("DAYLABELS TOOOOOOO BIG "); while ( needWid > maxWid ) { dayTest = dayTest.left( dayTest.length() - 1 ); wid = fm.width( dayTest ); needWid = wid * selCount; } int maxLen = dayTest.length(); int fontPoint = dlf.pointSize(); if ( maxLen < 2 ) { int fontPoint = dlf.pointSize(); while ( fontPoint > 4 ) { --fontPoint; dlf.setPointSize( fontPoint ); QFontMetrics f( dlf ); wid = f.width( "30" ); needWid = wid * selCount; if ( needWid < maxWid ) break; } maxLen = 2; } //qDebug("Max len %d ", dayTest.length() ); QFontMetrics tempF( dlf ); newHight = tempF.height(); mDayLabels->setFont( dlf ); // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; // mLayoutDayLabels->addSpacing(mTimeLabels->width()); //mLayoutDayLabels->addSpacing( 2 ); // QFont lFont = dlf; bool appendLabels = false; KOAgendaButton *dayLabel; dayLabel = mDayLabelsList.first(); if ( !dayLabel ) { appendLabels = true; dayLabel = getNewDaylabel(); } dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); dayLabel->setFont( dlf ); dayLabel->setNum( -1 ); //dayLabel->setAlignment(QLabel::AlignHCenter); #if 0 if ( QApplication::desktop()->width() <= 320 ) dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); else #endif dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); dayLabel->show(); DateList::ConstIterator dit; bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); int counter = -1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { ++counter; QDate date = *dit; // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { dayLabel = getNewDaylabel(); } dayLabel->setMinimumWidth( 1 ); dayLabel->setMaximumWidth( 10240 ); dayLabel->setFont( dlf ); dayLabel->show(); dayLabel->setAutoRepeat( false ); dayLabel->setNum( counter ); QString str; int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); switch ( maxLen ) { case 2: str = QString::number( date.day() ); break; case 3: str = dayName.left( 1 ) +QString::number( date.day()); break; case 4: str = dayName.left( 1 ) + " " +QString::number( date.day()); break; case 5: str = dayName.left( 2 ) + " " +QString::number( date.day()); break; case 6: str = dayName.left( 3 ) + " " +QString::number( date.day()); break; default: break; } if ( oneday ) { QString addString; if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 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 { /** updates widget's internal state */ void updateConfig(); /** */ void setAgenda(KOAgenda* agenda); /** */ virtual void paintEvent(QPaintEvent* e); void contentsMousePressEvent ( QMouseEvent * ) ; void contentsMouseReleaseEvent ( QMouseEvent * ); void contentsMouseMoveEvent ( QMouseEvent * ); public slots: /** update time label positions */ void positionChanged(); signals: void scaleChanged(); protected: void drawContents(QPainter *p,int cx, int cy, int cw, int ch); private: QPixmap myPix; bool mRedrawNeeded; int mMiniWidth; int mMouseDownY; QString mOrgCap; int mRows; int mCellHeight; /** */ KOAgenda* mAgenda; }; class EventIndicator : public QFrame { Q_OBJECT public: enum Location { Top, Bottom }; EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); virtual ~EventIndicator(); void changeColumns(int columns); void setPaintWidget( KDGanttMinimizeSplitter* ); void setXOffset( int ); void enableColumn(int column, bool enable); protected: void drawContents(QPainter *); private: int mXOffset; KDGanttMinimizeSplitter* mPaintWidget; int mColumns; QHBox *mTopBox; QBoxLayout *mTopLayout; Location mLocation; QPixmap mPixmap; QMemArray<bool> mEnabled; }; /** KOAgendaView is the agenda-like view used to display events in an one or multi-day view. */ class KOAgendaView : public KOEventView { Q_OBJECT public: KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); virtual ~KOAgendaView(); void setStartHour( int ); void toggleAllDay(); /** Returns maximum number of days supported by the koagendaview */ virtual int maxDatesHint(); /** Returns number of currently shown dates. */ virtual int currentDateCount(); /** returns the currently selected events */ virtual QPtrList<Incidence> selectedIncidences(); /** returns the currently selected events */ virtual DateList selectedDates(); /** Remove all events from view */ void clearView(); KOAgenda *agenda() { return mAgenda;} virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); /** start-datetime of selection */ QDateTime selectionStart() {return mTimeSpanBegin;} /** end-datetime of selection */ QDateTime selectionEnd() {return mTimeSpanEnd;} /** returns true if selection is for whole day */ bool selectedIsAllDay() {return mTimeSpanInAllDay;} /** make selected start/end invalid */ void deleteSelectedDateTime(); void repaintAgenda(); public slots: void setInitStartHour(); virtual void updateView(); virtual void updateConfig(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void updateTodo( Todo *, int ); void changeEventDisplay(Event *, int); void clearSelection(); void newTodo(int gx,int gy); void newEvent(int gx,int gy); void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); void newEventAllDay(int gx, int gy); void newTodoAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); void slotShowDateView( int, int ); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void selectWeekNum( int ); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: KOAgendaButton* getNewDaylabel(); bool mBlockUpdating; int mUpcomingWidth; /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ void fillAgenda(); /** Create labels for the selected dates. */ void createDayLabels(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ void setHolidayMasks(); protected slots: void slotDaylabelClicked( int ); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); //void updateMovedTodo(); void updateEventIndicatorTop(int newY); void updateEventIndicatorBottom(int newY); /** Updates data for selected timespan */ void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); /** Updates data for selected timespan for all day event*/ void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); private: // view widgets QFrame *mDayLabels; QHBox *mDayLabelsFrame; QBoxLayout *mLayoutDayLabels; QFrame *mAllDayFrame; KOAgenda *mAllDayAgenda; KOAgenda *mAgenda; TimeLabels *mTimeLabels; QWidget *mDummyAllDayLeft; KDGanttMinimizeSplitter* mSplitterAgenda; QPushButton *mExpandButton; DateList mSelectedDates; // List of dates to be displayed int mViewType; bool mWeekStartsMonday; int mStartHour; - KOEventPopupMenu *mAgendaPopup; - KOEventPopupMenu *mAllDayAgendaPopup; + KOEventPopupMenu *mAllAgendaPopup; + //KOEventPopupMenu *mAllDayAgendaPopup; EventIndicator *mEventIndicatorTop; EventIndicator *mEventIndicatorBottom; QMemArray<int> mMinY; QMemArray<int> mMaxY; QMemArray<bool> mHolidayMask; QPtrList<KOAgendaButton> mDayLabelsList; QDateTime mTimeSpanBegin; QDateTime mTimeSpanEnd; bool mTimeSpanInAllDay; void keyPressEvent ( QKeyEvent * e ); }; #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 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qheader.h> #include <qcursor.h> #include <qwhatsthis.h> #include <qvbox.h> #include <kdebug.h> #include "koprefs.h" #include <klocale.h> #include <kglobal.h> #include <kiconloader.h> #include <kmessagebox.h> #include <libkcal/icaldrag.h> #include <libkcal/vcaldrag.h> #include <libkcal/calfilter.h> #include <libkcal/dndfactory.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <libkcal/kincidenceformatter.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "docprefs.h" #include "kotodoview.h" using namespace KOrg; class KOTodoViewWhatsThis :public QWhatsThis { public: KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; protected: virtual QString text( const QPoint& p) { return _view->getWhatsThisText(p) ; } private: QWidget* _wid; KOTodoView * _view; }; KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, const char *name) : KListView(parent,name) { mName = QString ( name ); mCalendar = calendar; #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif mOldCurrent = 0; mMousePressed = false; setAcceptDrops(true); viewport()->setAcceptDrops(true); int size = 16; if (qApp->desktop()->width() < 300 ) size = 12; setTreeStepSize( size + 6 ); } void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && !QTextDrag::canDecode( e ) ) { e->ignore(); return; } mOldCurrent = currentItem(); #endif } void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && !QTextDrag::canDecode( e ) ) { e->ignore(); return; } e->accept(); #endif } void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; setCurrentItem(mOldCurrent); setSelected(mOldCurrent,true); #endif } void KOTodoListView::contentsDropEvent(QDropEvent *e) { #ifndef KORG_NODND // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && !QTextDrag::canDecode( e ) ) { e->ignore(); return; } DndFactory factory( mCalendar ); Todo *todo = factory.createDropTodo(e); if (todo) { e->acceptAction(); KOTodoViewItem *destination = (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); Todo *destinationEvent = 0; if (destination) destinationEvent = destination->todo(); Todo *existingTodo = mCalendar->todo(todo->uid()); if(existingTodo) { Incidence *to = destinationEvent; while(to) { if (to->uid() == todo->uid()) { KMessageBox::sorry(this, i18n("Cannot move To-Do to itself\nor a child of itself"), i18n("Drop To-Do")); delete todo; return; } to = to->relatedTo(); } internalDrop = true; if ( destinationEvent ) reparentTodoSignal( destinationEvent, existingTodo ); else unparentTodoSignal(existingTodo); delete todo; } else { mCalendar->addTodo(todo); emit todoDropped(todo, KOGlobals::EVENTADDED); if ( destinationEvent ) reparentTodoSignal( destinationEvent, todo ); } } else { QString text; if (QTextDrag::decode(e,text)) { //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); qDebug("Dropped : " + text); QStringList emails = QStringList::split(",",text); for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { int pos = (*it).find("<"); QString name = (*it).left(pos); QString email = (*it).mid(pos); if (!email.isEmpty() && todoi) { todoi->todo()->addAttendee(new Attendee(name,email)); } } } else { qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); e->ignore(); } } #endif } void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) { + + QPoint p(contentsToViewport(e->pos())); + QListViewItem *i = itemAt(p); + bool rootClicked = true; + if (i) { + // if the user clicked into the root decoration of the item, don't + // try to start a drag! + int X = p.x(); + //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); + if (X > header()->sectionPos(0) + + treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + + itemMargin() || + X < header()->sectionPos(0)) { + rootClicked = false; + } + } #ifndef KORG_NODND - QPoint p(contentsToViewport(e->pos())); - QListViewItem *i = itemAt(p); - mMousePressed = false; - if (i) { - // if the user clicked into the root decoration of the item, don't - // try to start a drag! - if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + - treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + - itemMargin() || - p.x() < header()->sectionPos(header()->mapToIndex(0))) { - if (e->button()==Qt::LeftButton) { + mMousePressed = false; + if (! rootClicked ) { mPressPos = e->pos(); mMousePressed = true; - } } - } #endif - QListView::contentsMousePressEvent(e); + //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); +#ifndef DESKTOP_VERSION + if (!( e->button() == RightButton && rootClicked) ) + QListView::contentsMousePressEvent(e); +#else + QListView::contentsMousePressEvent(e); +#endif } void KOTodoListView::paintEvent(QPaintEvent* e) { emit paintNeeded(); QListView::paintEvent( e); } void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { #ifndef KORG_NODND //QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()*3) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { DndFactory factory( mCalendar ); ICalDrag *vd = factory.createDrag( ((KOTodoViewItem *)item)->todo(),viewport()); internalDrop = false; // we cannot do any senseful here, because the DnD is still broken in Qt if (vd->drag()) { if ( !internalDrop ) { //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); qDebug("Dnd: External move: Delete drag source "); } else qDebug("Dnd: Internal move "); } else { if ( !internalDrop ) { qDebug("Dnd: External Copy"); } else qDebug("DnD: Internal copy: Copy pending"); } } } #endif } void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) { if ( !e->isAutoRepeat() ) { mFlagKeyPressed = false; } } void KOTodoListView::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) mFlagKeyPressed = true; QListViewItem* cn; if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { cn = currentItem(); if ( cn ) { KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); if ( ci ){ if ( e->state() == ShiftButton ) ci->setOn( false ); else ci->setOn( true ); cn = cn->itemBelow(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); } } } return; } if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { switch ( e->key() ) { case Qt::Key_Down: case Qt::Key_Up: QListView::keyPressEvent ( e ); break; case Qt::Key_Left: case Qt::Key_Right: QListView::keyPressEvent ( e ); e->accept(); return; break; default: e->ignore(); break; } return; } e->ignore(); } void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) { QListView::contentsMouseReleaseEvent(e); mMousePressed = false; } void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); emit double_Clicked(item); if (!item) return; emit doubleClicked(item,vp,0); } ///////////////////////////////////////////////////////////////////////////// KOQuickTodo::KOQuickTodo(QWidget *parent) : QLineEdit(parent) { setText(i18n("Click to add a new Todo")); } void KOQuickTodo::focusInEvent(QFocusEvent *ev) { if ( text()==i18n("Click to add a new Todo") ) setText(""); QLineEdit::focusInEvent(ev); } void KOQuickTodo::focusOutEvent(QFocusEvent *ev) { setText(i18n("Click to add a new Todo")); QLineEdit::focusOutEvent(ev); } ///////////////////////////////////////////////////////////////////////////// KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : KOrg::BaseView(calendar,parent,name) { mPendingUpdateBeforeRepaint = false; isFlatDisplay = false; mNavigator = 0; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickAdd = new KOQuickTodo(this); topLayout->addWidget(mQuickAdd); if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); mTodoListView = new KOTodoListView(calendar,this, name ); topLayout->addWidget(mTodoListView); //mTodoListView->header()->setMaximumHeight(30); mTodoListView->setRootIsDecorated(true); mTodoListView->setAllColumnsShowFocus(true); mTodoListView->setShowSortIndicator(true); mTodoListView->addColumn(i18n("Todo")); mTodoListView->addColumn(i18n("Prio")); mTodoListView->setColumnAlignment(1,AlignHCenter); mTodoListView->addColumn(i18n("Complete")); mTodoListView->setColumnAlignment(2,AlignCenter); mTodoListView->addColumn(i18n("Due Date")); mTodoListView->setColumnAlignment(3,AlignLeft); mTodoListView->addColumn(i18n("Due Time")); mTodoListView->setColumnAlignment(4,AlignHCenter); mTodoListView->addColumn(i18n("Start Date")); mTodoListView->setColumnAlignment(5,AlignLeft); mTodoListView->addColumn(i18n("Start Time")); mTodoListView->setColumnAlignment(6,AlignHCenter); mTodoListView->addColumn(i18n("Cancelled")); mTodoListView->addColumn(i18n("Categories")); #if 0 mTodoListView->addColumn(i18n("Sort Id")); mTodoListView->setColumnAlignment(4,AlignHCenter); #endif mTodoListView->setMinimumHeight( 60 ); mTodoListView->setItemsRenameable( true ); mTodoListView->setRenameable( 0 ); mTodoListView->setColumnWidth( 0, 120 ); mTodoListView->setColumnWidthMode(0, QListView::Manual); mTodoListView->setColumnWidthMode(1, QListView::Manual); @@ -874,396 +885,404 @@ void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Todolist, fd, td); #endif } void KOTodoView::editItem(QListViewItem *item ) { // qDebug("editItem(QListViewItem *item ) "); emit editTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) { emit showTodoSignal(((KOTodoViewItem *)item)->todo()); } void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) { pendingSubtodo = 0; mActiveItem = (KOTodoViewItem *)item; if (item) { switch (column){ case 1: mPriorityPopupMenu->popup(QCursor::pos ()); break; case 2: mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; case 3: moveTodo(); break; case 8: getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; default: mItemPopupMenu->popup(QCursor::pos()); } } else mPopupMenu->popup(QCursor::pos()); } void KOTodoView::newTodo() { emit newTodoSignal(); } void KOTodoView::newSubTodo() { if (mActiveItem) { emit newSubTodoSignal(mActiveItem->todo()); } } void KOTodoView::unparentTodo() { if (mActiveItem) { emit unparentTodoSignal(mActiveItem->todo()); } } void KOTodoView::reparentTodo() { if (mActiveItem) { qDebug("KOTodoView::reparentTodo() "); topLevelWidget()->setCaption(i18n("Click on new parent item")); pendingSubtodo = mActiveItem; } } void KOTodoView::editTodo() { if (mActiveItem) { emit editTodoSignal(mActiveItem->todo()); } } void KOTodoView::cloneTodo() { if (mActiveItem) { emit cloneTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::cancelTodo() { if (mActiveItem) { emit cancelTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::moveTodo() { if (mActiveItem) { emit moveTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::beamTodo() { if (mActiveItem) { emit beamTodoSignal((Incidence*)mActiveItem->todo()); } } void KOTodoView::showTodo() { if (mActiveItem) { emit showTodoSignal(mActiveItem->todo()); } } void KOTodoView::deleteTodo() { if (mActiveItem) { emit deleteTodoSignal(mActiveItem->todo()); } } void KOTodoView::setNewPriority(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { mActiveItem->todo()->setPriority(mPriority[index]); mActiveItem->construct(); todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } } void KOTodoView::setNewPercentage(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { mActiveItem->setOn( true ); return; } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); if ( par && par->isOn() ) par->setOn( false ); } if (mPercentage[index] == 100) { mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); } else { mActiveItem->todo()->setCompleted(false); } mActiveItem->todo()->setPercentComplete(mPercentage[index]); mActiveItem->construct(); todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); } } QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) { QPopupMenu* tempMenu = new QPopupMenu (this); QStringList checkedCategories = todoItem->todo()->categories (); tempMenu->setCheckable (true); for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); it != KOPrefs::instance()->mCustomCategories.end (); ++it) { int index = tempMenu->insertItem (*it); mCategory[index] = *it; if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); } connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); return tempMenu; } void KOTodoView::changedCategories(int index) { if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { QStringList categories = mActiveItem->todo()->categories (); QString colcat = categories.first(); if (categories.find (mCategory[index]) != categories.end ()) categories.remove (mCategory[index]); else categories.insert (categories.end(), mCategory[index]); categories.sort (); if ( !colcat.isEmpty() ) { if ( categories.find ( colcat ) != categories.end () ) { categories.remove( colcat ); categories.prepend( colcat ); } } mActiveItem->todo()->setCategories (categories); mActiveItem->construct(); mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); } } void KOTodoView::itemDoubleClicked(QListViewItem *item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; + int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); + //qDebug("ROW %d ", row); if (!item) { newTodo(); return; + } else { + if ( row == 1 ) { + mActiveItem = (KOTodoViewItem *) item; + newSubTodo(); + return; + } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::itemClicked(QListViewItem *item) { - + //qDebug("KOTodoView::itemClicked %d", item); if (!item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; return; } KOTodoViewItem *todoItem = (KOTodoViewItem *)item; if ( pendingSubtodo != 0 ) { bool allowReparent = true; QListViewItem *par = item; while ( par ) { if ( par == pendingSubtodo ) { allowReparent = false; break; } par = par->parent(); } if ( !allowReparent ) { topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); qDebug("Recursive reparenting not possible "); pendingSubtodo = 0; } else { Todo* newParent = todoItem->todo(); Todo* newSub = pendingSubtodo->todo(); pendingSubtodo = 0; emit reparentTodoSignal( newParent,newSub ); return; } } #if 0 // handled by the item itself bool completed = todoItem->todo()->isCompleted(); // Completed or not? qDebug("com %d ",completed ); qDebug("itemclicked "); if (todoItem->isOn()) { qDebug("on "); if (!completed) { qDebug("set true "); todoItem->todo()->setCompleted(QDateTime::currentDateTime()); } } else { qDebug("not on "); if (completed) { qDebug("set false "); todoItem->todo()->setCompleted(false); } } #endif } void KOTodoView::setDocumentId( const QString &id ) { kdDebug() << "KOTodoView::setDocumentId()" << endl; mDocPrefs->setDoc( id ); } void KOTodoView::itemStateChanged( QListViewItem *item ) { if (!item) return; KOTodoViewItem *todoItem = (KOTodoViewItem *)item; // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); } void KOTodoView::saveLayout(KConfig *config, const QString &group) const { mTodoListView->saveLayout(config,group); } void KOTodoView::restoreLayout(KConfig *config, const QString &group) { mTodoListView->restoreLayout(config,group); } void KOTodoView::processSelectionChange() { // kdDebug() << "KOTodoView::processSelectionChange()" << endl; KOTodoViewItem *item = static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); if ( !item ) { emit incidenceSelected( 0 ); } else { emit incidenceSelected( item->todo() ); } } void KOTodoView::modified(bool b) { emit isModified(b); } void KOTodoView::setTodoModified( Todo* todo ) { todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); } void KOTodoView::clearSelection() { mTodoListView->selectAll( false ); } void KOTodoView::setAllOpen() { if ( isFlatDisplay ) { isFlatDisplay = false; mPopupMenu->setItemChecked( 8,false ); updateView(); } setOpen(mTodoListView->firstChild(), true); } void KOTodoView::setAllClose() { if ( isFlatDisplay ) { isFlatDisplay = false; mPopupMenu->setItemChecked( 8,false ); updateView(); } setOpen(mTodoListView->firstChild(), false); } void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) { while ( item ) { setOpen( item->firstChild(), setOpenI ); item->setOpen( setOpenI ); item = item->nextSibling(); } } void KOTodoView::displayAllFlat() { pendingSubtodo = 0; if ( mBlockUpdate ) { return; } mPopupMenu->setItemChecked( 8,true ); isFlatDisplay = true; QPtrList<Todo> todoList = calendar()->todos(); mTodoMap.clear(); mTodoListView->clear(); Todo *todo; for(todo = todoList.first(); todo; todo = todoList.next()) { KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); mTodoMap.insert(todo,todoItem); } mTodoListView->setFocus(); processSelectionChange(); } void KOTodoView::setAllFlat() { if ( isFlatDisplay ) { isFlatDisplay = false; mPopupMenu->setItemChecked( 8,false ); updateView(); return; } displayAllFlat(); } void KOTodoView::purgeCompleted() { emit purgeCompletedSignal(); } void KOTodoView::toggleQuickTodo() { if ( mQuickAdd->isVisible() ) { mQuickAdd->hide(); KOPrefs::instance()->mEnableQuickTodo = false; } else { mQuickAdd->show(); KOPrefs::instance()->mEnableQuickTodo = true; } mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); } void KOTodoView::toggleRunning() { KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); updateView(); } void KOTodoView::toggleCompleted() { 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 @@ #include "kcolordialog.h" #include <qdialog.h> #include <qlayout.h> #include <qlabel.h> #include <qslider.h> #include <qhbox.h> #include <qapplication.h> #include <qpushbutton.h> #include <kglobal.h> QColor KColorDialog::getColor( ) const { QColor c ( r->value(), g->value(), b->value() ); lar->setText ( "R: " + QString::number ( c.red() ) ); lag->setText ( "G: " + QString::number ( c.green() ) ); lab->setText ( "B: " + QString::number ( c.blue() ) ); return c; } void KColorDialog::setColor( const QColor & d ) { r->setValue(d.red() ); g->setValue(d.green() ); b->setValue(d.blue() ); old_color->setPalette( QPalette( d.dark(), d ) ); lar->setText ( "R: " + QString::number ( d.red() ) ); lag->setText ( "G: " + QString::number ( d.green() ) ); lab->setText ( "B: " + QString::number ( d.blue() ) ); } KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true ) { setCaption( i18n("Choose Color") ); setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er. QGridLayout* lay = new QGridLayout ( this, 4, 2 ); lay->setSpacing( 6 ); lay->setMargin( 11 ); old_color = new QLabel("Old color",this); old_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); old_color->setLineWidth( 1 ); lay->addWidget(old_color, 0, 0); new_color = new QLabel("New color", this); new_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); new_color->setLineWidth( 1 ); lay->addWidget(new_color, 0, 1); new_color->setAlignment( AlignCenter ); QHBox* hb = new QHBox ( this ); lar = new QLabel( hb ); lag = new QLabel( hb ); lab = new QLabel( hb ); lay->addMultiCellWidget( hb,1,1, 0,1 ); QLabel* lr = new QLabel ( "Red:", this ); lay->addWidget( lr,2,0 ); r = new QSlider ( 0, 255, 1, 1, Horizontal, this ); lay->addWidget(r ,2,1 ); QLabel* lg = new QLabel( "Green:",this ); lay->addWidget(lg ,3,0 ); g = new QSlider ( 0, 255, 1, 1, Horizontal, this ); lay->addWidget( g ,3,1 ); QLabel* lb = new QLabel ( "Blue:",this ); lay->addWidget( lb,4,0 ); b = new QSlider ( 0, 255, 1, 1, Horizontal, this ); lay->addWidget(b ,4,1 ); QColor d = backgroundColor(); r->setValue(d.red() ); g->setValue(d.green() ); b->setValue(d.blue() ); old_color->setPalette( QPalette( d.dark() , d ) ); // kannst du wieder reinnehmen, aber es geht auch so. QPushButton * ok = new QPushButton (i18n(" OK "), this ); + ok->setDefault( true ); QPushButton * cancel = new QPushButton (i18n(" Cancel "), this ); lay->addWidget(ok ,5,0 ); lay->addWidget(cancel ,5,1 ); connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() )); connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() )); connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); } void KColorDialog::updateColor( int ) { QColor c = getColor( ) ; new_color->setPalette( QPalette( c.dark(), c ) ); } 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) mw->setUpdatesEnabled( TRUE ); } } KToolBar::IconText KToolBar::iconText() const { return d->m_iconText; } void KToolBar::setIconSize(int size) { setIconSize( size, true ); } void KToolBar::setIconSize(int size, bool update) { bool doUpdate=false; if ( size != d->m_iconSize ) { d->m_iconSize = size; doUpdate=true; } if (update == false) return; if (doUpdate) emit modechange(); // tell buttons what happened // ugly hack to force a QMainWindow::triggerLayout( TRUE ) if ( mainWindow() ) { QMainWindow *mw = mainWindow(); mw->setUpdatesEnabled( FALSE ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setUpdatesEnabled( TRUE ); } } int KToolBar::iconSize() const { /*US if ( !d->m_iconSize ) // default value? { if (!::qstrcmp(QObject::name(), "mainToolBar")) return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); else return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); } return d->m_iconSize; */ int ret = 18; if ( QApplication::desktop()->width() > 320 ) ret = 30; return ret; } void KToolBar::setEnableContextMenu(bool enable ) { d->m_enableContext = enable; } bool KToolBar::contextMenuEnabled() const { return d->m_enableContext; } void KToolBar::setItemNoStyle(int id, bool no_style ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if (button) button->setNoStyle( no_style ); } void KToolBar::setFlat (bool flag) { if ( !mainWindow() ) return; if ( flag ) //US mainWindow()->moveDockWindow( this, DockMinimized ); mainWindow()->moveToolBar( this, QMainWindow::Minimized ); else //US mainWindow()->moveDockWindow( this, DockTop ); mainWindow()->moveToolBar( this, QMainWindow::Top ); // And remember to save the new look later /*US if ( mainWindow()->inherits( "KMainWindow" ) ) static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); */ } int KToolBar::count() const { return id2widget.count(); } void KToolBar::saveState() { /*US // first, try to save to the xml file if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { // go down one level to get to the right tags QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); elem = elem.firstChild().toElement(); QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); QDomElement current; // now try to find our toolbar d->modified = false; for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { current = elem; if ( current.tagName().lower() != "toolbar" ) continue; QString curname(current.attribute( "name" )); if ( curname == barname ) { saveState( current ); break; } } // if we didn't make changes, then just return if ( !d->modified ) return; // now we load in the (non-merged) local file QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); QDomDocument local; local.setContent(local_xml); // make sure we don't append if this toolbar already exists locally bool just_append = true; elem = local.documentElement().toElement(); KXMLGUIFactory::removeDOMComments( elem ); elem = elem.firstChild().toElement(); for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { if ( elem.tagName().lower() != "toolbar" ) continue; QString curname(elem.attribute( "name" )); if ( curname == barname ) { just_append = false; local.documentElement().replaceChild( current, elem ); break; } } if (just_append) local.documentElement().appendChild( current ); KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); return; } */ // if that didn't work, we save to the config file KConfig *config = KGlobal::config(); saveSettings(config, QString::null); config->sync(); } QString KToolBar::settingsGroup() { QString configGroup; if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) configGroup = "Toolbar style"; else configGroup = QString(name()) + " Toolbar style"; if ( this->mainWindow() ) { configGroup.prepend(" "); configGroup.prepend( this->mainWindow()->name() ); } return configGroup; } void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) { + return; QString configGroup = _configGroup; if (configGroup.isEmpty()) configGroup = settingsGroup(); //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; QString position, icontext; int index; getAttributes( position, icontext, index ); //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; KConfigGroupSaver saver(config, configGroup); if ( position != d->PositionDefault ) config->writeEntry("Position", position); else config->deleteEntry("Position"); if ( icontext != d->IconTextDefault ) config->writeEntry("IconText", icontext); else config->deleteEntry("IconText"); if ( iconSize() != d->IconSizeDefault ) config->writeEntry("IconSize", iconSize()); else config->deleteEntry("IconSize"); if ( isHidden() != d->HiddenDefault ) config->writeEntry("Hidden", isHidden()); else config->deleteEntry("Hidden"); if ( index != d->IndexDefault ) config->writeEntry( "Index", index ); else config->deleteEntry("Index"); //US the older version of KDE (used on the Zaurus) has no Offset property /* if ( offset() != d->OffsetDefault ) config->writeEntry( "Offset", offset() ); else */ config->deleteEntry("Offset"); //US the older version of KDE (used on the Zaurus) has no NewLine property /* if ( newLine() != d->NewLineDefault ) config->writeEntry( "NewLine", newLine() ); else */ config->deleteEntry("NewLine"); } void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) { d->m_xmlguiClient = client; } void KToolBar::setText( const QString & txt ) { //US setLabel( txt + " ( " + kapp->caption() + " ) " ); setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); } QString KToolBar::text() const { return label(); } void KToolBar::doConnections( KToolBarButton *button ) { connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); } void KToolBar::mousePressEvent ( QMouseEvent *m ) { if ( !mainWindow() ) return; QMainWindow *mw = mainWindow(); if ( mw->toolBarsMovable() && d->m_enableContext ) { if ( m->button() == RightButton ) { int i = contextMenu()->exec( m->globalPos(), 0 ); switch ( i ) { case -1: return; // popup cancelled case CONTEXT_LEFT: //US mw->moveDockWindow( this, DockLeft ); mw->moveToolBar( this, QMainWindow::Left ); break; case CONTEXT_RIGHT: //US mw->moveDockWindow( this, DockRight ); mw->moveToolBar( this, QMainWindow::Right ); break; case CONTEXT_TOP: //US mw->moveDockWindow( this, DockTop ); mw->moveToolBar( this, QMainWindow::Top ); break; case CONTEXT_BOTTOM: //US mw->moveDockWindow( this, DockBottom ); mw->moveToolBar( this, QMainWindow::Bottom ); break; case CONTEXT_FLOAT: break; case CONTEXT_FLAT: //US mw->moveDockWindow( this, DockMinimized ); mw->moveToolBar( this, QMainWindow::Minimized ); break; case CONTEXT_ICONS: setIconText( IconOnly ); break; case CONTEXT_TEXTRIGHT: setIconText( IconTextRight ); break; case CONTEXT_TEXT: setIconText( TextOnly ); break; case CONTEXT_TEXTUNDER: setIconText( IconTextBottom ); break; default: if ( i >= CONTEXT_ICONSIZES ) setIconSize( i - CONTEXT_ICONSIZES ); else return; // assume this was an action handled elsewhere, no need for setSettingsDirty() } /*US if ( mw->inherits("KMainWindow") ) static_cast<KMainWindow *>(mw)->setSettingsDirty(); */ } } } void KToolBar::rebuildLayout() { for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) w->blockSignals(false); d->idleButtons.clear(); layoutTimer->stop(); QApplication::sendPostedEvents( this, QEvent::ChildInserted ); QBoxLayout *l = boxLayout(); l->setMargin( 1 ); // clear the old layout QLayoutIterator it = l->iterator(); while ( it.current() ) { it.deleteCurrent(); } for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( w == rightAligned ) { continue; } if ( w->inherits( "KToolBarSeparator" ) && !( (KToolBarSeparator*)w )->showLine() ) { l->addSpacing( 6 ); w->hide(); continue; } if ( w->inherits( "QPopupMenu" ) ) continue; l->addWidget( w ); w->show(); } if ( rightAligned ) { l->addStretch(); l->addWidget( rightAligned ); rightAligned->show(); } if ( fullSize() ) { // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). //if ( !stretchableWidget && widgets.last() && // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) // setStretchableWidget( widgets.last() ); if ( !rightAligned ) l->addStretch(); if ( stretchableWidget ) l->setStretchFactor( stretchableWidget, 10 ); } l->invalidate(); QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); //#endif //DESKTOP_VERSION @@ -1415,384 +1416,385 @@ void KToolBar::repaintMe() setUpdatesEnabled( true ); QToolBar::repaint( true ); //qDebug(" KToolBar::repaintMe() "); } void KToolBar::showEvent( QShowEvent *e ) { QToolBar::showEvent( e ); rebuildLayout(); } void KToolBar::setStretchableWidget( QWidget *w ) { QToolBar::setStretchableWidget( w ); stretchableWidget = w; } QSizePolicy KToolBar::sizePolicy() const { if ( orientation() == Horizontal ) return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); else return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); } QSize KToolBar::sizeHint() const { return QToolBar::sizeHint(); #if 0 QWidget::polish(); static int iii = 0; ++iii; qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); switch( barPos() ) { case KToolBar::Top: case KToolBar::Bottom: for ( QWidget *w = widgets.first(); w; w =widgets.next() ) { if ( w->inherits( "KToolBarSeparator" ) && !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) { minSize += QSize(6, 0); } else { QSize sh = w->sizeHint(); if (!sh.isValid()) sh = w->minimumSize(); minSize = minSize.expandedTo(QSize(0, sh.height())); minSize += QSize(sh.width()+1, 0); } } /*US minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); */ minSize += QSize(margin*2, margin*2); break; case KToolBar::Left: case KToolBar::Right: for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( w->inherits( "KToolBarSeparator" ) && !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) { minSize += QSize(0, 6); } else { QSize sh = w->sizeHint(); if (!sh.isValid()) sh = w->minimumSize(); minSize = minSize.expandedTo(QSize(sh.width(), 0)); minSize += QSize(0, sh.height()+1); } } /*US minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); */ minSize += QSize(margin*2, margin*2); break; default: minSize = QToolBar::sizeHint(); break; } return minSize; #endif } QSize KToolBar::minimumSize() const { return minimumSizeHint(); } QSize KToolBar::minimumSizeHint() const { return sizeHint(); } bool KToolBar::highlight() const { return d->m_highlight; } void KToolBar::hide() { QToolBar::hide(); } void KToolBar::show() { QToolBar::show(); } void KToolBar::resizeEvent( QResizeEvent *e ) { bool b = isUpdatesEnabled(); setUpdatesEnabled( FALSE ); QToolBar::resizeEvent( e ); if (b) d->repaintTimer.start( 100, true ); } void KToolBar::slotIconChanged(int group) { if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) return; if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) return; emit modechange(); if (isVisible()) updateGeometry(); } void KToolBar::slotReadConfig() { //kdDebug(220) << "KToolBar::slotReadConfig" << endl; // Read appearance settings (hmm, we used to do both here, // but a well behaved application will call applyMainWindowSettings // anyway, right ?) applyAppearanceSettings(KGlobal::config(), QString::null ); } void KToolBar::slotAppearanceChanged() { // Read appearance settings from global file. applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); // And remember to save the new look later /*US if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); */ } //static bool KToolBar::highlightSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); } //static bool KToolBar::transparentSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); } //static KToolBar::IconText KToolBar::iconTextSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); if ( icontext == "IconTextRight" ) return IconTextRight; else if ( icontext == "IconTextBottom" ) return IconTextBottom; else if ( icontext == "TextOnly" ) return TextOnly; else return IconOnly; } void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) { + return; QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; // We have application-specific settings in the XML file, // and nothing in the application's config file // -> don't apply the global defaults, the XML ones are preferred // See applySettings for a full explanation /*US :we do not support xml files if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && !config->hasGroup(configGroup) ) { //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; return; } */ if ( !config->hasGroup(configGroup) ) { //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; return; } KConfig *gconfig = KGlobal::config(); /*US static const QString &attrIconText = KGlobal::staticQString("IconText"); static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); static const QString &attrSize = KGlobal::staticQString("IconSize"); */ // we actually do this in two steps. // First, we read in the global styles [Toolbar style] (from the KControl module). // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] bool highlight; int transparent; QString icontext; int iconsize = 0; // this is the first iteration QString grpToolbar(QString::fromLatin1("Toolbar style")); { // start block for KConfigGroupSaver KConfigGroupSaver saver(gconfig, grpToolbar); // first, get the generic settings //US highlight = gconfig->readBoolEntry(attrHighlight, true); highlight = gconfig->readBoolEntry("Highlighting", true); //US transparent = gconfig->readBoolEntry(attrTrans, true); transparent = gconfig->readBoolEntry("TransparentMoving", true); // we read in the IconText property *only* if we intend on actually // honoring it if (d->m_honorStyle) //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); else d->IconTextDefault = "IconOnly"; // Use the default icon size for toolbar icons. //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); if ( !forceGlobal && config->hasGroup(configGroup) ) { config->setGroup(configGroup); // first, get the generic settings //US highlight = config->readBoolEntry(attrHighlight, highlight); highlight = config->readBoolEntry("Highlighting", highlight); //US transparent = config->readBoolEntry(attrTrans, transparent); transparent = config->readBoolEntry("TransparentMoving", transparent); // now we always read in the IconText property //US icontext = config->readEntry(attrIconText, d->IconTextDefault); icontext = config->readEntry("IconText", d->IconTextDefault); // now get the size //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); } else { iconsize = d->IconSizeDefault; icontext = d->IconTextDefault; } // revert back to the old group } // end block for KConfigGroupSaver bool doUpdate = false; IconText icon_text; if ( icontext == "IconTextRight" ) icon_text = IconTextRight; else if ( icontext == "IconTextBottom" ) icon_text = IconTextBottom; else if ( icontext == "TextOnly" ) icon_text = TextOnly; else icon_text = IconOnly; // check if the icon/text has changed if (icon_text != d->m_iconText) { //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; setIconText(icon_text, false); doUpdate = true; } // ...and check if the icon size has changed if (iconsize != d->m_iconSize) { setIconSize(iconsize, false); doUpdate = true; } QMainWindow *mw = mainWindow(); // ...and if we should highlight if ( highlight != d->m_highlight ) { d->m_highlight = highlight; doUpdate = true; } // ...and if we should move transparently if ( mw && transparent != (!mw->opaqueMoving()) ) { mw->setOpaqueMoving( !transparent ); } if (doUpdate) emit modechange(); // tell buttons what happened if (isVisible ()) updateGeometry(); } void KToolBar::applySettings(KConfig *config, const QString &_configGroup) { //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; /* Let's explain this a bit more in details. The order in which we apply settings is : Global config / <appnamerc> user settings if no XMLGUI is used Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used So in the first case, we simply read everything from KConfig as below, but in the second case we don't do anything here if there is no app-specific config, and the XMLGUI uses the static methods of this class to get the global defaults. Global config doesn't include position (index, offset, newline and hidden/shown). */ // First the appearance stuff - the one which has a global config applyAppearanceSettings( config, _configGroup ); // ...and now the position stuff if ( config->hasGroup(configGroup) ) { KConfigGroupSaver cgs(config, configGroup); /*US static const QString &attrPosition = KGlobal::staticQString("Position"); static const QString &attrIndex = KGlobal::staticQString("Index"); static const QString &attrOffset = KGlobal::staticQString("Offset"); static const QString &attrNewLine = KGlobal::staticQString("NewLine"); static const QString &attrHidden = KGlobal::staticQString("Hidden"); QString position = config->readEntry(attrPosition, d->PositionDefault); int index = config->readNumEntry(attrIndex, d->IndexDefault); int offset = config->readNumEntry(attrOffset, d->OffsetDefault); bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); */ QString position = config->readEntry("Position", d->PositionDefault); int index = config->readNumEntry("Index", d->IndexDefault); int offset = config->readNumEntry("Offset", d->OffsetDefault); bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); /*US Dock pos(DockTop); if ( position == "Top" ) pos = DockTop; else if ( position == "Bottom" ) pos = DockBottom; else if ( position == "Left" ) pos = DockLeft; else if ( position == "Right" ) pos = DockRight; else if ( position == "Floating" ) pos = DockTornOff; else if ( position == "Flat" ) pos = DockMinimized; */ QMainWindow::ToolBarDock pos(QMainWindow::Top); if ( position == "Top" ) pos = QMainWindow::Top; |