summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.h
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index 5bb4226..2be3e2b 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -1,186 +1,190 @@
1#ifndef PHONEEDITWIDGET_H 1#ifndef PHONEEDITWIDGET_H
2#define PHONEEDITWIDGET_H 2#define PHONEEDITWIDGET_H
3/* 3/*
4 This file is part of KAddressBook. 4 This file is part of KAddressBook.
5 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 5 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <kdialogbase.h> 26#include <kdialogbase.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qpopupmenu.h> 30#include <q3popupmenu.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include <QDesktopWidget>
32 33
33#include <qptrlist.h> 34#include <q3ptrlist.h>
34#include <qscrollview.h> 35#include <q3scrollview.h>
36//Added by qt3to4:
37#include <Q3HBoxLayout>
38#include <Q3VBoxLayout>
35 39
36#include "addresseeconfig.h" 40#include "addresseeconfig.h"
37#include "typecombo.h" 41#include "typecombo.h"
38 42
39class QButtonGroup; 43class Q3ButtonGroup;
40class QCheckBox; 44class QCheckBox;
41class PhoneTypeNumberEdit; 45class PhoneTypeNumberEdit;
42 46
43#include <klineedit.h> 47#include <klineedit.h>
44#include <kcombobox.h> 48#include <kcombobox.h>
45#include <kabc/phonenumber.h> 49#include <kabc/phonenumber.h>
46 50
47typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; 51typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
48 52
49/** 53/**
50 Widget for editing phone numbers. 54 Widget for editing phone numbers.
51*/ 55*/
52class PhoneEditWidget : public QWidget 56class PhoneEditWidget : public QWidget
53{ 57{
54 Q_OBJECT 58 Q_OBJECT
55 59
56 public: 60 public:
57 PhoneEditWidget( QWidget *parent, const char *name = 0 ); 61 PhoneEditWidget( QWidget *parent, const char *name = 0 );
58 ~PhoneEditWidget(); 62 ~PhoneEditWidget();
59 63
60 void setPhoneNumbers( const KABC::PhoneNumber::List &list ); 64 void setPhoneNumbers( const KABC::PhoneNumber::List &list );
61 KABC::PhoneNumber::List phoneNumbers(); 65 KABC::PhoneNumber::List phoneNumbers();
62 66
63 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); 67 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* );
64 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); 68 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int );
65 69
66 signals: 70 signals:
67 void modified(); 71 void modified();
68 void typeChange( int oldType, int newType ); 72 void typeChange( int oldType, int newType );
69 73
70 private slots: 74 private slots:
71 void bottomVisible(); 75 void bottomVisible();
72 void addNumberInt( int ); 76 void addNumberInt( int );
73 void deleteEdit( PhoneTypeNumberEdit* ew ); 77 void deleteEdit( PhoneTypeNumberEdit* ew );
74 void addNumber(); 78 void addNumber();
75 void pendingDelete(); 79 void pendingDelete();
76 protected: 80 protected:
77 81
78 private: 82 private:
79 QScrollView* sv; 83 Q3ScrollView* sv;
80 QPopupMenu *mPopup; 84 Q3PopupMenu *mPopup;
81 int mPopupCount; 85 int mPopupCount;
82 PhoneTypeNumberEdit* mPendingDelete; 86 PhoneTypeNumberEdit* mPendingDelete;
83 void setDefaults(); 87 void setDefaults();
84 PhoneTypeNumberEdit* appendEditCombo(); 88 PhoneTypeNumberEdit* appendEditCombo();
85 QWidget* mw; 89 QWidget* mw;
86 QVBoxLayout* mainLayout; 90 Q3VBoxLayout* mainLayout;
87 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; 91 Q3PtrList <PhoneTypeNumberEdit> mTypeNumberEditList;
88 92
89}; 93};
90 94
91 95
92class PhoneTypeNumberEdit : public QWidget 96class PhoneTypeNumberEdit : public QWidget
93{ 97{
94 Q_OBJECT 98 Q_OBJECT
95public: 99public:
96 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) 100 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent )
97 { 101 {
98 QHBoxLayout * lay = new QHBoxLayout( this ); 102 Q3HBoxLayout * lay = new Q3HBoxLayout( this );
99 lay->setSpacing( 2 ); 103 lay->setSpacing( 2 );
100 lay->setMargin( 0 ); 104 lay->setMargin( 0 );
101 mMinusButton = new QPushButton ( this ); 105 mMinusButton = new QPushButton ( this );
102 mMinusButton->setPixmap ( SmallIcon("minus")); 106 mMinusButton->setPixmap ( SmallIcon("minus"));
103 mCombo = new KComboBox( this ); 107 mCombo = new KComboBox( this );
104 if ( QApplication::desktop()->width() <= 640 ) 108 if ( QApplication::desktop()->width() <= 640 )
105 mCombo->setSizeLimit ( 6 ); 109 mCombo->setMaxVisibleItems ( 6 );
106 mNumber = new KLineEdit( this ); 110 mNumber = new KLineEdit( this );
107 mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); 111 mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6);
108 lay->addWidget( mMinusButton ); 112 lay->addWidget( mMinusButton );
109 lay->addWidget( mCombo ); 113 lay->addWidget( mCombo );
110 lay->addWidget( mNumber ); 114 lay->addWidget( mNumber );
111 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); 115 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) );
112 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); 116 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) );
113 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), 117 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ),
114 this, SLOT ( textChanged ( const QString & ) ) ); 118 this, SLOT ( textChanged ( const QString & ) ) );
115 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); 119 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() );
116 } 120 }
117 ~PhoneTypeNumberEdit() { 121 ~PhoneTypeNumberEdit() {
118 // qDebug("~PhoneTypeNumberEdit() "); 122 // qDebug("~PhoneTypeNumberEdit() ");
119 } 123 }
120 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) 124 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber )
121 { 125 {
122 mPhoneNumber = phoneNumber; 126 mPhoneNumber = phoneNumber;
123 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 127 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
124 mCombo->setCurrentItem( index ); 128 mCombo->setCurrentItem( index );
125 mNumber->setText( mPhoneNumber.number() ); 129 mNumber->setText( mPhoneNumber.number() );
126 show(); 130 show();
127 mNumber->setFocus(); 131 mNumber->setFocus();
128 } 132 }
129 KABC::PhoneNumber phoneNumber() 133 KABC::PhoneNumber phoneNumber()
130 { 134 {
131 mPhoneNumber.setNumber( mNumber->text() ); 135 mPhoneNumber.setNumber( mNumber->text() );
132 int index = mCombo->currentItem(); 136 int index = mCombo->currentItem();
133 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 137 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
134 return mPhoneNumber; 138 return mPhoneNumber;
135 } 139 }
136 bool isValid() 140 bool isValid()
137 { 141 {
138 if ( mNumber->text().isEmpty() )return false; 142 if ( mNumber->text().isEmpty() )return false;
139 return true; 143 return true;
140 } 144 }
141 int currentType() 145 int currentType()
142 { 146 {
143 return mCombo->currentItem(); 147 return mCombo->currentItem();
144 } 148 }
145 private slots: 149 private slots:
146 void typeExternalChanged( int oldType, int newType ) 150 void typeExternalChanged( int oldType, int newType )
147 { 151 {
148 if ( mPhoneNumber.type() == newType ) { 152 if ( mPhoneNumber.type() == newType ) {
149 mPhoneNumber.setType(oldType); 153 mPhoneNumber.setType(oldType);
150 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 154 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
151 mCombo->setCurrentItem( index ); 155 mCombo->setCurrentItem( index );
152 } 156 }
153 } 157 }
154 void deleteNumber() 158 void deleteNumber()
155 { 159 {
156 emit deleteMe( this ); 160 emit deleteMe( this );
157 } 161 }
158 void comboTypeChange( int index ) 162 void comboTypeChange( int index )
159 { 163 {
160 int old = mPhoneNumber.type(); 164 int old = mPhoneNumber.type();
161 int newT = PhoneNumber::supportedTypeList()[index]; 165 int newT = PhoneNumber::supportedTypeList()[index];
162 if ( old != newT ) { 166 if ( old != newT ) {
163 emit modified(); 167 emit modified();
164 if ( newT != PhoneNumber::Voice ) 168 if ( newT != PhoneNumber::Voice )
165 emit typeChange ( old, newT ); 169 emit typeChange ( old, newT );
166 mPhoneNumber.setType(newT ); 170 mPhoneNumber.setType(newT );
167 } 171 }
168 172
169 } 173 }
170 void textChanged ( const QString & ) 174 void textChanged ( const QString & )
171 { 175 {
172 emit modified(); 176 emit modified();
173 } 177 }
174 signals: 178 signals:
175void typeChange( int oldType, int newType ); 179void typeChange( int oldType, int newType );
176 void modified(); 180 void modified();
177 void deleteMe( PhoneTypeNumberEdit* ); 181 void deleteMe( PhoneTypeNumberEdit* );
178 182
179private: 183private:
180 KABC::PhoneNumber mPhoneNumber; 184 KABC::PhoneNumber mPhoneNumber;
181 QPushButton* mMinusButton; 185 QPushButton* mMinusButton;
182 KComboBox *mCombo; 186 KComboBox *mCombo;
183 KLineEdit *mNumber; 187 KLineEdit *mNumber;
184}; 188};
185 189
186#endif 190#endif