author | zautrix <zautrix> | 2005-10-28 16:38:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 16:38:18 (UTC) |
commit | d6eb485cf2ff7a14918f51a5b21b5306f9908fdb (patch) (side-by-side diff) | |
tree | 6382df41981bad0d38a384868cfacc04c7b4a149 /kaddressbook | |
parent | 869e4921d8b052c376b2769de44674a8c2d68221 (diff) | |
download | kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.zip kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.tar.gz kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.tar.bz2 |
fixx
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index d895ea1..f52cedb 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp @@ -14,130 +14,130 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software 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 <qcursor.h> #include <qtimer.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 ) : 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 ); - mainLayout->setMargin( 2 ); - mainLayout->setSpacing( 2 ); + mainLayout->setMargin( 0 ); + mainLayout->setSpacing( 0 ); 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))); } PhoneEditWidget::~PhoneEditWidget() { } void PhoneEditWidget::setDefaults() { mTypeNumberEditList.clear(); PhoneTypeNumberEdit* edit = appendEditCombo(); KABC::PhoneNumber phoneNumber; phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); edit->setPhoneNumber( phoneNumber ); edit = appendEditCombo(); phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); edit->setPhoneNumber( phoneNumber ); edit = appendEditCombo(); phoneNumber.setType( KABC::PhoneNumber::Cell ); edit->setPhoneNumber( phoneNumber ); } 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() { PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index df5aff9..0477b6c 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h @@ -146,134 +146,135 @@ class PhoneEditWidget : public QWidget KABC::PhoneNumber::List mPhoneList; }; /** Dialog for editing lists of phonenumbers. */ class PhoneEditDialog : public KDialogBase { Q___OBJECT public: PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); ~PhoneEditDialog(); const KABC::PhoneNumber::List &phoneNumbers(); bool changed() const; protected s__lots: void slotAddPhoneNumber(); void slotRemovePhoneNumber(); void slotEditPhoneNumber(); void slotSelectionChanged(); private: KABC::PhoneNumber::List mPhoneNumberList; KABC::PhoneNumber::TypeList mTypeList; KComboBox *mTypeBox; KListView *mListView; QPushButton *mRemoveButton; QPushButton *mEditButton; bool mChanged; }; /** Dialog for editing phone number types. */ class PhoneTypeDialog : public KDialogBase { Q___OBJECT public: PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); KABC::PhoneNumber phoneNumber(); private: KABC::PhoneNumber mPhoneNumber; KABC::PhoneNumber::TypeList mTypeList; QButtonGroup *mGroup; QCheckBox *mPreferredBox; KLineEdit *mNumber; }; #endif class PhoneTypeNumberEdit : public QWidget { Q_OBJECT public: PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) { QHBoxLayout * lay = new QHBoxLayout( this ); - lay->setSpacing( KDialogBase::spacingHintSmall() ); - lay->setMargin( KDialogBase::marginHintSmall() ); + lay->setSpacing( 2 ); + lay->setMargin( 0 ); mMinusButton = new QPushButton ( this ); mMinusButton->setPixmap ( SmallIcon("minus")); mCombo = new KComboBox( this ); mNumber = new KLineEdit( this ); + mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); 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 ) ) ); connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( textChanged ( const QString & ) ) ); mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); } ~PhoneTypeNumberEdit() { // qDebug("~PhoneTypeNumberEdit() "); } void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) { mPhoneNumber = phoneNumber; int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); mCombo->setCurrentItem( index ); mNumber->setText( mPhoneNumber.number() ); show(); mNumber->setFocus(); } KABC::PhoneNumber phoneNumber() { mPhoneNumber.setNumber( mNumber->text() ); int index = mCombo->currentItem(); mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); return mPhoneNumber; } bool isValid() { if ( mNumber->text().isEmpty() )return false; return true; } int currentType() { return mCombo->currentItem(); } 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() { emit deleteMe( this ); } void comboTypeChange( int index ) { int old = mPhoneNumber.type(); int newT = PhoneNumber::supportedTypeList()[index]; if ( old != newT ) { emit modified(); if ( newT != PhoneNumber::Voice ) emit typeChange ( old, newT ); mPhoneNumber.setType(newT ); } } void textChanged ( const QString & ) { |