summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.cpp80
1 files changed, 58 insertions, 22 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 997fc05..9e7e221 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -32,4 +32,5 @@
#include <qbuttongroup.h>
#include <qhbox.h>
+#include <qcursor.h>
#include <kbuttonbox.h>
@@ -52,30 +53,41 @@
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 );
+ : QWidget(parent,name)
+{
+ QGridLayout* gridLayout = new QGridLayout ( this, 2,2 );
+
+ QLabel *temp = new QLabel( "", this );
+ temp->setAlignment( Qt::AlignCenter );
+ temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
+ gridLayout->addWidget( temp, 1, 0 );
+ QPushButton *addBut = new QPushButton ( "add", this );
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 );
+ gridLayout->addWidget( addBut, 0, 0 );
+
+ sv = new QScrollView( this );
+ sv->setFrameStyle ( QFrame::Panel | QFrame::Plain );
+ sv->setLineWidth ( 1 );
+ sv->setMidLineWidth ( 1 );
+ mw = new QWidget ( sv->viewport() );
+ sv->addChild(mw);
+ sv->setResizePolicy( QScrollView::AutoOneFit );
+ mainLayout = new QVBoxLayout ( mw );
+ mainLayout->setMargin( 2 );
+ mainLayout->setSpacing( 2 );
+ gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
setDefaults();
mTypeNumberEditList.setAutoDelete( true );
+ mPopup = new QPopupMenu( this );
+ QStringList list = PhoneNumber::supportedTypeListNames();
+ mPopupCount = list.count();
+ int i = 0;
+ while ( i < mPopupCount ) {
+ mPopup->insertItem( list[ i ], i );
+ ++i;
+ }
+ connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
+
}
@@ -98,7 +110,31 @@ void PhoneEditWidget::setDefaults()
}
+void PhoneEditWidget::addNumberInt( int index )
+{
+ PhoneTypeNumberEdit* edit = appendEditCombo();
+ KABC::PhoneNumber phoneNumber;
+ phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
+ edit->setPhoneNumber( phoneNumber );
+ //verticalScrollBar()->setValue( 1024);
+ QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
+}
+void PhoneEditWidget::bottomVisible()
+{
+ sv->setContentsPos ( 0, 1024 );
+}
void PhoneEditWidget::addNumber()
{
-
+ int i = 0;
+ while ( i < mPopupCount ) {
+ mPopup->setItemEnabled( i, true );
+ ++i;
+ }
+ PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
+ while ( edit ) {
+ if ( edit->currentType() < mPopupCount -1 )
+ mPopup->setItemEnabled( edit->currentType(), false );
+ edit = mTypeNumberEditList.next();
+ }
+ mPopup->popup( QCursor::pos() );
}
PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()