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 @@ -17,52 +17,162 @@ 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 <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 ) ); label->setAlignment( AlignCenter ); //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); layout->addWidget( label, 0, 0 ); @@ -537,20 +647,20 @@ KABC::PhoneNumber PhoneTypeDialog::phoneNumber() mPhoneNumber.setNumber( mNumber->text() ); int type = 0; for ( int i = 0; i < mGroup->count(); ++i ) { 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 |