summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2004-07-05 09:24:56 (UTC)
committer zautrix <zautrix>2004-07-05 09:24:56 (UTC)
commit5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0 (patch) (side-by-side diff)
treef41b695d2b18bf7d7ff84d0d8b39faf15d229669 /microkde
parentc2d4beeaeda44694a3e1c0b72a5808d2f518b286 (diff)
downloadkdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.zip
kdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.tar.gz
kdepimpi-5c5c1354afa5d24768ceefe5b7dd8733ff7bd5f0.tar.bz2
Removed strange handling of addresseeeditor
Diffstat (limited to 'microkde') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdialogbase.cpp12
-rw-r--r--microkde/kdialogbase.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp
index 2ea2053..c953058 100644
--- a/microkde/kdialogbase.cpp
+++ b/microkde/kdialogbase.cpp
@@ -1,278 +1,290 @@
#include <qtabwidget.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qframe.h>
#include "klocale.h"
#include "kdebug.h"
#include "kdialogbase.h"
KDialogBase::KDialogBase()
{
}
KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
const QString &caption,
int buttonMask, ButtonCode defaultButton,
bool separator,
const QString &user1,
const QString &user2,
const QString &user3) :
KDialog( parent, name, modal )
{
init( caption, buttonMask, user1, user2 );
if (findButton( defaultButton ) )
(findButton( defaultButton ) )->setFocus();
}
KDialogBase::KDialogBase( int dialogFace, const QString &caption,
int buttonMask, ButtonCode defaultButton,
QWidget *parent, const char *name, bool modal,
bool separator,
const QString &user1,
const QString &user2,
const QString &user3) :
KDialog( parent, name, modal )
{
init( caption, buttonMask, user1, user2 );
if (findButton( defaultButton ) )
(findButton( defaultButton ) )->setFocus();
}
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;
}
bool KDialogBase::showPage( int index )
{
tabWidget()->setCurrentPage( index );return false;
}
QFrame *KDialogBase::plainPage()
{
if ( !mPlainPage ) {
mPlainPage = new QFrame( this );
setMainWidget( mPlainPage );
}
return mPlainPage;
}
void KDialogBase::slotOk()
{
emit okClicked();
accept();
}
void KDialogBase::slotApply()
{
emit applyClicked();
}
void KDialogBase::slotCancel()
{
emit cancelClicked();
reject();
}
void KDialogBase::slotClose()
{
emit closeClicked();
reject();
}
void KDialogBase::slotUser1()
{
emit user1Clicked();
}
void KDialogBase::slotUser2()
{
emit user2Clicked();
}
diff --git a/microkde/kdialogbase.h b/microkde/kdialogbase.h
index 199d2fa..7b44bfb 100644
--- a/microkde/kdialogbase.h
+++ b/microkde/kdialogbase.h
@@ -1,139 +1,141 @@
#ifndef MINIKDE_KDIALOGBASE_H
#define MINIKDE_KDIALOGBASE_H
#include <qframe.h>
#include "kdialog.h"
class QPushButton;
class QLayout;
class QTabWidget;
class QBoxLayout;
class KDialogBase : public KDialog
{
Q_OBJECT
public:
enum ButtonCode
{
Help = 0x00000001,
Default = 0x00000002,
Ok = 0x00000004,
Apply = 0x00000008,
Try = 0x00000010,
Cancel = 0x00000020,
Close = 0x00000040,
User1 = 0x00000080,
User2 = 0x00000100,
User3 = 0x00000200,
No = 0x00000080,
Yes = 0x00000100,
Details = 0x00000400,
Filler = 0x40000000,
Stretch = 0x80000000
};
enum DialogType
{
TreeList,
Tabbed,
Plain,
Swallow,
IconList
};
KDialogBase();
KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true,
const QString &caption=QString::null,
int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
bool separator=false,
const QString &user1=QString::null,
const QString &user2=QString::null,
const QString &user3=QString::null);
KDialogBase( int dialogFace, const QString &caption,
int buttonMask, ButtonCode defaultButton,
QWidget *parent=0, const char *name=0, bool modal=true,
bool separator=false,
const QString &user1=QString::null,
const QString &user2=QString::null,
const QString &user3=QString::null);
virtual ~KDialogBase();
QFrame *addPage( const QString & );
QFrame *addPage( const QString &, int, const QPixmap & );
void setMainWidget( QWidget *widget );
void setButtonText( ButtonCode id, const QString &text );
void enableButton( ButtonCode id, bool state );
void enableButtonOK( bool state );
void enableButtonApply( bool state );
void showButton( ButtonCode, bool show );
int pageIndex( QWidget *widget ) const;
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