-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 @@ -9,121 +9,113 @@ 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 @@ -40,23 +40,24 @@ class AddresseeEditorDialog : public KDialogBase 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 @@ -50,32 +50,33 @@ #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> @@ -185,33 +186,34 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const 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 @@ -777,39 +779,39 @@ void KABCore::newContact() 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; @@ -854,43 +856,34 @@ void KABCore::editContact2() { 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" ) ); } @@ -1075,50 +1068,51 @@ void KABCore::addressBookChanged() "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& ) ), diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index b84ec22..c823f1f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -346,34 +346,34 @@ class KABCore : public QWidget // 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; diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index 2ea2053..c953058 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp @@ -64,32 +64,39 @@ void KDialogBase::init( const QString &caption, int buttonMask, } 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 ) { @@ -102,53 +109,55 @@ void KDialogBase::init( const QString &caption, int buttonMask, 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 ); } @@ -183,32 +192,35 @@ 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 ) diff --git a/microkde/kdialogbase.h b/microkde/kdialogbase.h index 199d2fa..7b44bfb 100644 --- a/microkde/kdialogbase.h +++ b/microkde/kdialogbase.h @@ -92,48 +92,50 @@ class KDialogBase : public KDialog * 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 *mCancelButton; + QPushButton *mDefaultButton; }; #endif |