summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-10-28 13:24:38 (UTC)
committer zautrix <zautrix>2005-10-28 13:24:38 (UTC)
commit61a52cfdb0eda075dabde46984cf05b37856bbc2 (patch) (side-by-side diff)
treecd587a374d62fa9b50143305f762c0ed995bd50c /kaddressbook
parentcee83f70d8e4a6945f4456c55ab1b280d3425f0f (diff)
downloadkdepimpi-61a52cfdb0eda075dabde46984cf05b37856bbc2.zip
kdepimpi-61a52cfdb0eda075dabde46984cf05b37856bbc2.tar.gz
kdepimpi-61a52cfdb0eda075dabde46984cf05b37856bbc2.tar.bz2
commit
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp2
-rw-r--r--kaddressbook/phoneeditwidget.cpp80
-rw-r--r--kaddressbook/phoneeditwidget.h21
3 files changed, 73 insertions, 30 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 9814cd5..966efa5 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -1190,3 +1190,3 @@ void AddresseeEditorWidget::save()
mAddressee.insertPhoneNumber( *phoneIter );
-
+ mAddressee.makePhoneNumbersOLcompatible();
// Save the addresses
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 997fc05..9e7e221 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -33,2 +33,3 @@
#include <qhbox.h>
+#include <qcursor.h>
@@ -53,10 +54,23 @@
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 );
+ : 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()));
+ 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 );
@@ -64,17 +78,15 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
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 );
+ 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)));
+
}
@@ -99,5 +111,29 @@ 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() );
}
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index c730c7b..df5aff9 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -29,2 +29,3 @@
#include <qlayout.h>
+#include <qpopupmenu.h>
@@ -49,3 +50,3 @@ typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
*/
-class PhoneEditWidget : public QScrollView
+class PhoneEditWidget : public QWidget
{
@@ -68,2 +69,4 @@ class PhoneEditWidget : public QScrollView
private slots:
+ void bottomVisible();
+ void addNumberInt( int );
void deleteEdit( PhoneTypeNumberEdit* ew );
@@ -74,2 +77,5 @@ class PhoneEditWidget : public QScrollView
private:
+ QScrollView* sv;
+ QPopupMenu *mPopup;
+ int mPopupCount;
PhoneTypeNumberEdit* mPendingDelete;
@@ -228,3 +234,3 @@ public:
show();
-
+ mNumber->setFocus();
}
@@ -242,2 +248,6 @@ public:
}
+ int currentType()
+ {
+ return mCombo->currentItem();
+ }
private slots:
@@ -261,3 +271,4 @@ public:
emit modified();
- emit typeChange ( old, newT );
+ if ( newT != PhoneNumber::Voice )
+ emit typeChange ( old, newT );
mPhoneNumber.setType(newT );
@@ -266,6 +277,2 @@ public:
}
- int currentType()
- {
- return mCombo->currentItem();
- }
void textChanged ( const QString & )