author | zautrix <zautrix> | 2004-07-05 09:24:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-05 09:24:56 (UTC) |
commit | 5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0 (patch) (side-by-side diff) | |
tree | f41b695d2b18bf7d7ff84d0d8b39faf15d229669 | |
parent | c2d4beeaeda44694a3e1c0b72a5808d2f518b286 (diff) | |
download | kdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.zip kdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.tar.gz kdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.tar.bz2 |
Removed strange handling of addresseeeditor
-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 32 | ||||
-rw-r--r-- | kaddressbook/addresseeeditordialog.h | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 42 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 4 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 12 | ||||
-rw-r--r-- | microkde/kdialogbase.h | 2 |
6 files changed, 47 insertions, 46 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index 102138e..790f148 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -1,129 +1,121 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 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. */ #include <qlayout.h> +#include <qapplication.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include "addresseeeditorwidget.h" #include "kabcore.h" #include "addresseeeditordialog.h" AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, const char *name ) : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, - KDialogBase::Ok, parent, name, false ) + KDialogBase::Ok, parent, name, true ) { -#ifdef KAB_EMBEDDED - resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); -#endif //KAB_EMBEDDED - kdDebug(5720) << "AddresseeEditorDialog()" << endl; QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page ); mEditorWidget = new AddresseeEditorWidget( core, false, page ); connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), SLOT( widgetModified() ) ); layout->addWidget( mEditorWidget ); enableButton( KDialogBase::Apply, false ); + if ( QApplication::desktop()->width() < 480 ) { + hideButtons(); + } } AddresseeEditorDialog::~AddresseeEditorDialog() { - kdDebug(5720) << "~AddresseeEditorDialog()" << endl; - - emit editorDestroyed( mEditorWidget->addressee().uid() ); + qDebug("----------------------------------------------- "); + //emit editorDestroyed( mEditorWidget->addressee().uid() ); } void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) { enableButton( KDialogBase::Apply, false ); mEditorWidget->setAddressee( addr ); } KABC::Addressee AddresseeEditorDialog::addressee() { return mEditorWidget->addressee(); } bool AddresseeEditorDialog::dirty() { return mEditorWidget->dirty(); } void AddresseeEditorDialog::slotApply() { if ( mEditorWidget->dirty() ) { mEditorWidget->save(); emit contactModified( mEditorWidget->addressee() ); } enableButton( KDialogBase::Apply, false ); KDialogBase::slotApply(); } +void AddresseeEditorDialog:: accept () +{ + slotOk(); + +} void AddresseeEditorDialog::slotOk() { slotApply(); KDialogBase::slotOk(); - // Destroy this dialog -#ifndef KAB_EMBEDDED - delayedDestruct(); -#else //KAB_EMBEDDED - delete this; -#endif //KAB_EMBEDDED } void AddresseeEditorDialog::widgetModified() { enableButton( KDialogBase::Apply, true ); } void AddresseeEditorDialog::slotCancel() { KDialogBase::slotCancel(); - // Destroy this dialog -#ifndef KAB_EMBEDDED - delayedDestruct(); -#else //KAB_EMBEDDED - delete this; -#endif //KAB_EMBEDDED } #ifndef KAB_EMBEDDED #include "addresseeeditordialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/addresseeeditordialog.h b/kaddressbook/addresseeeditordialog.h index 1a00d3a..a1521e2 100644 --- a/kaddressbook/addresseeeditordialog.h +++ b/kaddressbook/addresseeeditordialog.h @@ -24,39 +24,40 @@ #ifndef ADDRESSEEEDITORDIALOG_H #define ADDRESSEEEDITORDIALOG_H #include <kdialogbase.h> #include <kabc/addressbook.h> class AddresseeEditorWidget; class QWidget; class KABCore; class AddresseeEditorDialog : public KDialogBase { Q_OBJECT public: AddresseeEditorDialog( KABCore *core, QWidget *parent, const char *name = 0 ); ~AddresseeEditorDialog(); void setAddressee( const KABC::Addressee& ); KABC::Addressee addressee(); bool dirty(); signals: void contactModified( const KABC::Addressee& ); void editorDestroyed( const QString& ); protected slots: virtual void slotApply(); virtual void slotOk(); virtual void slotCancel(); + virtual void accept () ; void widgetModified(); private: AddresseeEditorWidget *mEditorWidget; }; #endif diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 8d08713..b06e1bc 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -34,64 +34,65 @@ #include <qlayout.h> #include <qregexp.h> #include <qvbox.h> #include <kabc/addresseelist.h> #include <kabc/errorhandler.h> #include <kabc/resource.h> #include <kabc/vcardconverter.h> #include <kapplication.h> #include <kactionclasses.h> #include <kcmultidialog.h> #include <kdebug.h> #include <kdeversion.h> #include <kkeydialog.h> #include <kmessagebox.h> #include <kprinter.h> #include <kprotocolinfo.h> #include <kresources/selectdialog.h> #include <kstandarddirs.h> #include <ktempfile.h> #include <kxmlguiclient.h> #include <kaboutdata.h> #include <libkdepim/categoryselectdialog.h> #include "addresseeutil.h" #include "addresseeeditordialog.h" #include "extensionmanager.h" #include "kstdaction.h" #include "kaddressbookservice.h" #include "ldapsearchdialog.h" #include "printing/printingwizard.h" #else // KAB_EMBEDDED +#include <kapplication.h> #include "KDGanttMinimizeSplitter.h" #include "kaddressbookmain.h" #include "kactioncollection.h" #include <qapp.h> #include <qmenubar.h> //#include <qtoolbar.h> #include <qmessagebox.h> #include <kdebug.h> #include <kiconloader.h> // needed for SmallIcon #include <kresources/kcmkresources.h> #include <ktoolbar.h> #include <kcmkabconfig.h> //US#include <qpe/resource.h> // needed for Resource::loadPixmap //#include <qlabel.h> #endif // KAB_EMBEDDED #include <kcmkabconfig.h> #include <kresources/selectdialog.h> #include <kmessagebox.h> #include <picture.h> #include <resource.h> //US#include <qsplitter.h> #include <qvbox.h> #include <qlayout.h> #include <qclipboard.h> #include <libkdepim/categoryselectdialog.h> @@ -169,65 +170,66 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( const QString& ) ), SLOT( editContact( 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( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED - + mEditorDialog = 0; + createAddresseeEditorDialog( this ); setModified( false ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); #ifdef KAB_EMBEDDED //US we define here our own global actioncollection. // delete mActionCollection; #endif //KAB_EMBEDDED } void KABCore::restoreSettings() { bool state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); state = KABPrefs::instance()->mDetailsPageVisible; mActionDetails->setChecked( state ); setDetailsVisible( state ); QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { @@ -761,71 +763,71 @@ void KABCore::contactModified( const KABC::Addressee &addr ) } UndoStack::instance()->push( command ); RedoStack::instance()->clear(); setModified( true ); } void KABCore::newContact() { AddresseeEditorDialog *dialog = 0; QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> it( kabcResources ); KABC::Resource *resource; while ( ( resource = it.current() ) != 0 ) { ++it; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); resource = static_cast<KABC::Resource*>( res ); if ( resource ) { KABC::Addressee addr; addr.setResource( resource ); - dialog = createAddresseeEditorDialog( this ); - dialog->setAddressee( addr ); + mEditorDialog->setAddressee( addr ); + KApplication::execDialog ( mEditorDialog ); } else return; - mEditorDict.insert( dialog->addressee().uid(), dialog ); + // mEditorDict.insert( dialog->addressee().uid(), dialog ); dialog->show(); } void KABCore::addEmail( QString aStr ) { #ifndef KAB_EMBEDDED QString fullName, email; KABC::Addressee::parseEmailAddress( aStr, fullName, email ); // Try to lookup the addressee matching the email address bool found = false; QStringList emailList; KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { emailList = (*it).emails(); if ( emailList.contains( email ) > 0 ) { found = true; (*it).setNameFromString( fullName ); editContact( (*it).uid() ); } } if ( !found ) { KABC::Addressee addr; addr.setNameFromString( fullName ); addr.insertEmail( email, true ); mAddressBook->insertAddressee( addr ); mViewManager->refreshView( addr.uid() ); @@ -838,75 +840,66 @@ void KABCore::addEmail( QString aStr ) void KABCore::importVCard( const KURL &url, bool showPreview ) { mXXPortManager->importVCard( url, showPreview ); } void KABCore::importVCard( const QString &vCard, bool showPreview ) { mXXPortManager->importVCard( vCard, showPreview ); } //US added a second method without defaultparameter void KABCore::editContact2() { editContact( QString::null ); } void KABCore::editContact( const QString &uid ) { if ( mExtensionManager->isQuickEditVisible() ) return; // First, locate the contact entry QString localUID = uid; if ( localUID.isNull() ) { QStringList uidList = mViewManager->selectedUids(); if ( uidList.count() > 0 ) localUID = *( uidList.at( 0 ) ); } KABC::Addressee addr = mAddressBook->findByUid( localUID ); if ( !addr.isEmpty() ) { - AddresseeEditorDialog *dialog = mEditorDict.find( addr.uid() ); - if ( !dialog ) { - dialog = createAddresseeEditorDialog( this ); - - mEditorDict.insert( addr.uid(), dialog ); - - dialog->setAddressee( addr ); - } - - dialog->raise(); - dialog->show(); + mEditorDialog->setAddressee( addr ); + KApplication::execDialog ( mEditorDialog ); } } void KABCore::save() { if ( !mModified ) return; QString text = i18n( "There was an error while attempting to save\n the " "address book. Please check that some \nother application is " "not using it. " ); statusMessage(i18n("Saving addressbook ... ")); #ifndef KAB_EMBEDDED KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); if ( !b || !b->save() ) { KMessageBox::error( this, text, i18n( "Unable to Save" ) ); } #else //KAB_EMBEDDED KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); if ( !b || !b->save() ) { QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); } #endif //KAB_EMBEDDED statusMessage(i18n("Addressbook saved!")); setModified( false ); } void KABCore::statusMessage(QString mess , int time ) { //topLevelWidget()->setCaption( mess ); // pending setting timer to revome message } @@ -1059,82 +1052,83 @@ void KABCore::addGUIClient( KXMLGUIClient *client ) KMessageBox::error( this, "no KXMLGUICLient"); } void KABCore::configurationChanged() { mExtensionManager->reconfigure(); } void KABCore::addressBookChanged() { #ifndef KAB_EMBEDDED QDictIterator<AddresseeEditorDialog> it( mEditorDict ); while ( it.current() ) { if ( it.current()->dirty() ) { QString text = i18n( "Data has been changed externally. Unsaved " "changes will be lost." ); KMessageBox::information( this, text ); } it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); ++it; } mViewManager->refreshView(); #else //KAB_EMBEDDED qDebug("KABCore::addressBookChanged() finsih method"); #endif //KAB_EMBEDDED } AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, const char *name ) { - AddresseeEditorDialog *dialog = new AddresseeEditorDialog( this, parent, + + if ( mEditorDialog == 0 ) { + mEditorDialog = new AddresseeEditorDialog( this, parent, name ? name : "editorDialog" ); -//US - dialog->setMaximumSize( 640, 480 ); - dialog->showMaximized(); - connect( dialog, SIGNAL( contactModified( const KABC::Addressee& ) ), + connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), SLOT( contactModified( const KABC::Addressee& ) ) ); - connect( dialog, SIGNAL( editorDestroyed( const QString& ) ), - SLOT( slotEditorDestroyed( const QString& ) ) ); + //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), + // SLOT( slotEditorDestroyed( const QString& ) ) ); + } - return dialog; + return mEditorDialog; } void KABCore::slotEditorDestroyed( const QString &uid ) { - mEditorDict.remove( uid ); + qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); + //mEditorDict.remove( uid ); } void KABCore::initGUI() { #ifndef KAB_EMBEDDED QHBoxLayout *topLayout = new QHBoxLayout( this ); topLayout->setSpacing( KDialogBase::spacingHint() ); mExtensionBarSplitter = new QSplitter( this ); mExtensionBarSplitter->setOrientation( Qt::Vertical ); mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); QVBox *viewSpace = new QVBox( mDetailsSplitter ); mIncSearchWidget = new IncSearchWidget( viewSpace ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); mViewManager = new ViewManager( this, viewSpace ); viewSpace->setStretchFactor( mViewManager, 1 ); mDetails = new ViewContainer( mDetailsSplitter ); mJumpButtonBar = new JumpButtonBar( this, this ); mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); topLayout->addWidget( mExtensionBarSplitter ); topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); topLayout->addWidget( mJumpButtonBar ); topLayout->setStretchFactor( mJumpButtonBar, 1 ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index b84ec22..c823f1f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -330,66 +330,66 @@ class KABCore : public QWidget void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); private: void initGUI(); void initActions(); AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, const char *name = 0 ); KXMLGUIClient *mGUIClient; KABC::AddressBook *mAddressBook; ViewManager *mViewManager; // QSplitter *mDetailsSplitter; KDGanttMinimizeSplitter *mExtensionBarSplitter; ViewContainer *mDetails; KDGanttMinimizeSplitter* mMiniSplitter; XXPortManager *mXXPortManager; JumpButtonBar *mJumpButtonBar; IncSearchWidget *mIncSearchWidget; ExtensionManager *mExtensionManager; KCMultiDialog *mConfigureDialog; #ifndef KAB_EMBEDDED KCMultiDialog *mConfigureDialog; LDAPSearchDialog *mLdapSearchDialog; #endif //KAB_EMBEDDED - QDict<AddresseeEditorDialog> mEditorDict; - + // QDict<AddresseeEditorDialog> mEditorDict; + AddresseeEditorDialog *mEditorDialog; bool mReadWrite; bool mModified; bool mIsPart; //US file menu KAction *mActionMail; KAction* mActionPrint; KAction* mActionNewContact; KAction *mActionSave; KAction *mActionEditAddressee; KAction *mActionMailVCard; KAction *mActionQuit; //US edit menu KAction *mActionCopy; KAction *mActionCut; KAction *mActionPaste; KAction *mActionSelectAll; KAction *mActionUndo; KAction *mActionRedo; KAction *mActionDelete; //US settings menu KAction *mActionConfigResources; KAction *mActionConfigKAddressbook; KAction *mActionConfigShortcuts; KAction *mActionConfigureToolbars; KAction *mActionKeyBindings; KToggleAction *mActionJumpBar; KToggleAction *mActionDetails; KAction *mActionWhoAmI; KAction *mActionCategories; diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index 2ea2053..c953058 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp @@ -48,184 +48,196 @@ KDialogBase::~KDialogBase() } void KDialogBase::init( const QString &caption, int buttonMask, const QString &user1 ,const QString &user2 ) { mMainWidget = 0; mTabWidget = 0; mPlainPage = 0; mTopLayout = 0; if ( !caption.isEmpty() ) { setCaption( caption ); } if ( buttonMask & User1 ) { mUser1Button = new QPushButton( user1, this ); connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); } else { mUser1Button = 0; } if ( buttonMask & User2 ) { mUser2Button = new QPushButton( user2, this ); connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); } else { mUser2Button = 0; } if ( buttonMask & Ok ) { mOkButton = new QPushButton( i18n("Ok"), this ); connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); } else { mOkButton = 0; } + if ( buttonMask & Default ) { + qDebug("buttonMask & Default "); + mDefaultButton = new QPushButton( i18n("Default"), this ); + connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); + } else { + mDefaultButton = 0; + } if ( buttonMask & Apply ) { mApplyButton = new QPushButton( i18n("Apply"), this ); connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); } else { mApplyButton = 0; } if ( buttonMask & Cancel ) { mCancelButton = new QPushButton( i18n("Cancel"), this ); connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); } else { mCancelButton = 0; } if ( buttonMask & Close ) { mCloseButton = new QPushButton( i18n("Close"), this ); connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); } else { mCloseButton = 0; } } QTabWidget *KDialogBase::tabWidget() { if ( !mTabWidget ) { mTabWidget = new QTabWidget( this ); setMainWidget( mTabWidget ); } return mTabWidget; } void KDialogBase::hideButtons() { if ( mUser1Button ) mUser1Button->hide() ; if ( mUser2Button ) mUser2Button->hide() ; if ( mOkButton ) mOkButton->hide() ; if ( mApplyButton ) mApplyButton->hide() ; + if ( mDefaultButton ) mDefaultButton->hide(); if ( mCancelButton ) mCancelButton->hide() ; if ( mCloseButton ) mCloseButton->hide() ; } void KDialogBase::initLayout() { delete mTopLayout; mTopLayout = new QVBoxLayout( this ); mTopLayout->setMargin( marginHint() ); mTopLayout->setSpacing( spacingHint() ); mTopLayout->addWidget( mMainWidget ); QBoxLayout *buttonLayout = new QHBoxLayout; mTopLayout->addLayout( buttonLayout ); if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); if ( mOkButton ) buttonLayout->addWidget( mOkButton ); if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); + if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); } QFrame *KDialogBase::addPage( const QString &name ) { // kdDebug() << "KDialogBase::addPage(): " << name << endl; QFrame *frame = new QFrame( tabWidget() ); tabWidget()->addTab( frame, name ); return frame; } QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) { return addPage( name ); } void KDialogBase::setMainWidget( QWidget *widget ) { kdDebug() << "KDialogBase::setMainWidget()" << endl; mMainWidget = widget; initLayout(); } void KDialogBase::setButtonText( ButtonCode id, const QString &text ) { QPushButton *button = findButton( id ); if ( button ) { button->setText( text ); } } void KDialogBase::enableButton( ButtonCode id, bool state ) { QPushButton *button = findButton( id ); if ( button ) { button->setEnabled( state ); } } QPushButton *KDialogBase::findButton( ButtonCode id ) { QPushButton *button = 0; switch ( id ) { case Ok: button = mOkButton; break; case Apply: button = mApplyButton; break; case User1: button = mUser1Button; break; case User2: button = mUser2Button; break; case Cancel: button = mCancelButton; break; + case Default: + button = mDefaultButton; + break; case Close: button = mCloseButton; break; default: break; } return button; } void KDialogBase::enableButtonOK( bool state ) { enableButton( Ok, state ); } void KDialogBase::enableButtonApply( bool state ) { enableButton( Apply, state ); } void KDialogBase::showButton( ButtonCode id, bool show ) { QPushButton *button = findButton( id ); if ( button ) { if ( show ) button->show(); else button->hide(); } } int KDialogBase::pageIndex( QWidget *widget ) const { return 0; } diff --git a/microkde/kdialogbase.h b/microkde/kdialogbase.h index 199d2fa..7b44bfb 100644 --- a/microkde/kdialogbase.h +++ b/microkde/kdialogbase.h @@ -76,64 +76,66 @@ class KDialogBase : public KDialog bool showPage( int index ); void hideButtons(); QFrame *plainPage(); signals: void user1Clicked(); void user2Clicked(); /** * The Apply button was pressed. This signal is only emitted if * @ref slotApply() is not replaced. */ void applyClicked(); /** * The OK button was pressed. This signal is only emitted if * @ref slotOk() is not replaced. */ void okClicked(); /** * The Cancel button was pressed. This signal is only emitted if * @ref slotCancel() is not replaced. */ void cancelClicked(); /** * The Close button was pressed. This signal is only emitted if * @ref slotClose() is not replaced. */ void closeClicked(); + void defaultClicked(); protected slots: virtual void slotOk(); virtual void slotApply(); virtual void slotCancel(); virtual void slotClose(); virtual void slotUser1(); virtual void slotUser2(); protected: QPushButton *findButton( ButtonCode ); private: QTabWidget *tabWidget(); void init( const QString &caption, int buttonMask, const QString &user1=QString::null, const QString &user2=QString::null ); void initLayout(); QWidget *mMainWidget; QTabWidget *mTabWidget; QFrame *mPlainPage; QBoxLayout *mTopLayout; QPushButton *mUser1Button; QPushButton *mUser2Button; QPushButton *mCloseButton; QPushButton *mOkButton; QPushButton *mApplyButton; QPushButton *mCancelButton; + QPushButton *mDefaultButton; }; #endif |