author | zautrix <zautrix> | 2005-10-28 11:31:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 11:31:59 (UTC) |
commit | b27cb619bb9005ad4345d38bbee3b1c3d0eda1b2 (patch) (side-by-side diff) | |
tree | a7ac6002208ddedcd9dc13cd0e91294519883007 /kaddressbook/phoneeditwidget.cpp | |
parent | 5ceebb8563f134c789e9082d1bc49723beb28c8c (diff) | |
download | kdepimpi-b27cb619bb9005ad4345d38bbee3b1c3d0eda1b2.zip kdepimpi-b27cb619bb9005ad4345d38bbee3b1c3d0eda1b2.tar.gz kdepimpi-b27cb619bb9005ad4345d38bbee3b1c3d0eda1b2.tar.bz2 |
commit
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 112 |
1 files changed, 111 insertions, 1 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 2bce39a..b20275d 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp @@ -21,44 +21,154 @@ without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qlabel.h> #include <qtooltip.h> #include <qpushbutton.h> #include <qcheckbox.h> #include <qstring.h> #include <qlistbox.h> #include <qlistview.h> #include <qbuttongroup.h> +#include <qhbox.h> #include <kbuttonbox.h> #include <klistview.h> #include <kapplication.h> #include <qapplication.h> #include <kconfig.h> #include <klineedit.h> #include <kcombobox.h> #include <klocale.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <kabc/phonenumber.h> #include "typecombo.h" #include "phoneeditwidget.h" PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) + : QScrollView(parent,name) +{ + setFrameStyle ( QFrame::Panel | QFrame::Plain ); + setLineWidth ( 1 ); + setMidLineWidth ( 1 ); + mw = new QWidget ( viewport() ); + addChild(mw); + setResizePolicy( AutoOneFit ); + mainLayout = new QVBoxLayout ( mw ); + mainLayout->setMargin( 2 ); + mainLayout->setSpacing( 2 ); + QWidget* hb = new QWidget ( mw ); + mainLayout->add( hb ); + QHBoxLayout* hbLayout = new QHBoxLayout ( hb ); + QPushButton *addBut = new QPushButton ( "add", hb ); + hbLayout->add( addBut ); + addBut->setPixmap ( SmallIcon("plus")); + addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); + connect(addBut,SIGNAL(clicked()),SLOT(addNumber())); + //QLabel * temp = new QLabel( i18n("Phone Type"), hb ); + QLabel *temp = new QLabel( i18n("Phone Number"),hb ); + temp->setAlignment( Qt::AlignCenter ); + temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); + hbLayout->add( temp ); + appendEditCombo(); + appendEditCombo(); + appendEditCombo(); + setDefaults(); +} + +PhoneEditWidget::~PhoneEditWidget() +{ +} +void PhoneEditWidget::setDefaults() +{ + PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); + KABC::PhoneNumber phoneNumber; + phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); + edit->setPhoneNumber( phoneNumber ); + edit = mTypeNumberEditList.next(); + phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); + edit->setPhoneNumber( phoneNumber ); + edit = mTypeNumberEditList.next(); + phoneNumber.setType( KABC::PhoneNumber::Cell ); + edit->setPhoneNumber( phoneNumber ); + edit = mTypeNumberEditList.next(); + while ( edit ) { + edit->hide(); + edit = mTypeNumberEditList.next(); + } +} +void PhoneEditWidget::addNumber() +{ + +} +PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() +{ + PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); + connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); + connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); + connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); + + mainLayout->add( edit ); + mTypeNumberEditList.append( edit ); + return edit; +} + +void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) +{ + if ( li.isEmpty() ) { + setDefaults(); + return; + } + KABC::PhoneNumber::List::Iterator it; + KABC::PhoneNumber::List list = li; + PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); + for ( it = list.begin(); it != list.end(); ++it ) { + if ( edit ) { + edit->setPhoneNumber( (*it ) ); + edit = mTypeNumberEditList.next(); + } else { + PhoneTypeNumberEdit* editNew = appendEditCombo(); + editNew->setPhoneNumber( (*it ) ); + } + } + while ( edit ) { + edit->hide(); + edit = mTypeNumberEditList.next(); + } + //mainLayout->invalidate (); + mw->update(); +} +KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() +{ + KABC::PhoneNumber::List retList; + + PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); + while ( edit ) { + if ( edit->isValid() ) { + retList.append( edit->phoneNumber()); + } + edit = mTypeNumberEditList.next(); + + } + return retList; +} + +#if 0 +PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { QGridLayout *layout = new QGridLayout( this, 4, 1 ); //US layout->setSpacing( KDialog::spacingHint() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); QLabel* label = new QLabel( this ); //US loadIcon call is ambiguous. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); @@ -541,16 +651,16 @@ KABC::PhoneNumber PhoneTypeDialog::phoneNumber() QCheckBox *box = (QCheckBox*)mGroup->find( i ); if ( box->isChecked() ) type += mTypeList[ i ]; } if ( mPreferredBox->isChecked() ) mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); else mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); return mPhoneNumber; } - +#endif #ifndef KAB_EMBEDDED #include "phoneeditwidget.moc" #endif //KAB_EMBEDDED |