-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 34 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 79 |
2 files changed, 103 insertions, 10 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 310d628..9814cd5 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -155,5 +155,12 @@ void AddresseeEditorWidget::setupTab1() //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); - QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); + bool horLayout = false; + int maxCol = 1; + if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) { + horLayout = true; + maxCol = 3; + } + QGridLayout *layout = new QGridLayout( tab1, 8-maxCol, maxCol ); + layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); @@ -207,12 +214,23 @@ void AddresseeEditorWidget::setupTab1() connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); - layout->addWidget( button, 2, 0 ); - layout->addWidget( mOrgEdit, 2, 1 ); + if ( horLayout ) { + layout->addWidget( button, 1, 2 ); + layout->addWidget( mOrgEdit, 1, 3 ); + + } else { + layout->addWidget( button, 2, 0 ); + layout->addWidget( mOrgEdit, 2, 1 ); + } // File as (formatted name) - label = new QLabel( i18n( "Formatted name:" ), tab1 ); + label = new QLabel( i18n( "Format.n.:" ), tab1 ); mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); - layout->addWidget( label, 3, 0 ); - layout->addWidget( mFormattedNameLabel, 3, 1 ); + if ( horLayout ) { + layout->addWidget( label, 0,2 ); + layout->addWidget( mFormattedNameLabel, 0, 3 ); + } else { + layout->addWidget( label, 3, 0 ); + layout->addWidget( mFormattedNameLabel, 3, 1 ); + } /* LR // Left hand separator. This separator doesn't go all the way @@ -241,5 +259,5 @@ void AddresseeEditorWidget::setupTab1() iii = 8; #endif - layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); + layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, maxCol ); ++iii; /* LR @@ -322,5 +340,5 @@ void AddresseeEditorWidget::setupTab1() //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); - layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); + layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); // Build the layout and add to the tab widget diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index 7fe4bc0..0241cf0 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h @@ -25,4 +25,8 @@ #include <kdialogbase.h> +#include <kiconloader.h> +#include <qpushbutton.h> +#include <qlayout.h> + #include "addresseeconfig.h" @@ -32,7 +36,7 @@ class QButtonGroup; class QCheckBox; +#include <klineedit.h> +#include <kcombobox.h> class KListView; -class KLineEdit; -class KComboBox; typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; @@ -144,4 +148,75 @@ private: KLineEdit *mNumber; }; +class PhoneTypeNumberEdit : public QWidget +{ + Q_OBJECT +public: + PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) + { + QHBoxLayout * lay = new QHBoxLayout( this ); + lay->setSpacing( KDialogBase::spacingHintSmall() ); + lay->setMargin( KDialogBase::marginHintSmall() ); + mMinusButton = new QPushButton ( this ); + mMinusButton->setPixmap ( SmallIcon("minus")); + mCombo = new KComboBox( this ); + mNumber = new KLineEdit( this ); + lay->addWidget( mMinusButton ); + lay->addWidget( mCombo ); + lay->addWidget( mNumber ); + connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); + connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); + mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); + } + + void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) + { + mPhoneNumber = phoneNumber; + int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); + mCombo->setCurrentItem( index ); + mNumber->setText( mPhoneNumber.number() ); + show(); + + } + KABC::PhoneNumber phoneNumber() + { + mPhoneNumber.setNumber( mNumber->text() ); + int index = mCombo->currentItem(); + mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); + return mPhoneNumber; + + } + private slots: + void typeExternalChanged( int oldType, int newType ) + { + if ( mPhoneNumber.type() == newType ) { + mPhoneNumber.setType(oldType); + int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); + mCombo->setCurrentItem( index ); + } + + } + void deleteNumber() + { + hide(); + } + void comboTypeChange( int index ) + { + int old = mPhoneNumber.type(); + int newT = PhoneNumber::supportedTypeList()[index]; + if ( old != newT ) { + mPhoneNumber.setType(newT ); + emit typeChange ( old, newT ); + } + + } + signals: +void typeChange( int oldType, int newType ); + +private: + KABC::PhoneNumber mPhoneNumber; + QPushButton* mMinusButton; + KComboBox *mCombo; + KLineEdit *mNumber; +}; #endif |