-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 34 | ||||
-rw-r--r-- | kaddressbook/addresseeeditordialog.h | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 44 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 4 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 12 | ||||
-rw-r--r-- | microkde/kdialogbase.h | 4 |
6 files changed, 50 insertions, 49 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index 102138e..790f148 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -13,63 +13,62 @@ 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(); @@ -83,47 +82,40 @@ bool AddresseeEditorDialog::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 @@ -44,19 +44,20 @@ class AddresseeEditorDialog : public KDialogBase 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 @@ -54,24 +54,25 @@ #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> @@ -189,25 +190,26 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const #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(); @@ -781,31 +783,31 @@ void KABCore::newContact() 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 ); @@ -858,35 +860,26 @@ void KABCore::editContact( const QString &uid ) 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 @@ -1079,42 +1072,43 @@ void KABCore::addressBookChanged() ++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 ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index b84ec22..c823f1f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -350,26 +350,26 @@ class KABCore : public QWidget 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; diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index 2ea2053..c953058 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp @@ -68,24 +68,31 @@ void KDialogBase::init( const QString &caption, int buttonMask, 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 { @@ -106,45 +113,47 @@ QTabWidget *KDialogBase::tabWidget() 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; } @@ -187,24 +196,27 @@ QPushButton *KDialogBase::findButton( ButtonCode id ) 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 ) { diff --git a/microkde/kdialogbase.h b/microkde/kdialogbase.h index 199d2fa..7b44bfb 100644 --- a/microkde/kdialogbase.h +++ b/microkde/kdialogbase.h @@ -96,24 +96,25 @@ class KDialogBase : public KDialog /** * 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 ); @@ -124,16 +125,17 @@ class KDialogBase : public KDialog void initLayout(); QWidget *mMainWidget; QTabWidget *mTabWidget; QFrame *mPlainPage; QBoxLayout *mTopLayout; QPushButton *mUser1Button; QPushButton *mUser2Button; QPushButton *mCloseButton; QPushButton *mOkButton; QPushButton *mApplyButton; - QPushButton *mCancelButton; + QPushButton *mCancelButton; + QPushButton *mDefaultButton; }; #endif |