-rw-r--r-- | kabc/addresseedialog.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp index 671787e..bda1b9e 100644 --- a/kabc/addresseedialog.cpp +++ b/kabc/addresseedialog.cpp | |||
@@ -19,13 +19,16 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qgroupbox.h> | 23 | #include <q3groupbox.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qvbox.h> | 26 | #include <q3vbox.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | //Added by qt3to4: | ||
29 | #include <Q3ValueList> | ||
30 | #include <Q3VBoxLayout> | ||
28 | 31 | ||
29 | #include <klocale.h> | 32 | #include <klocale.h> |
30 | #include <kdebug.h> | 33 | #include <kdebug.h> |
31 | #include <kglobalsettings.h> | 34 | #include <kglobalsettings.h> |
@@ -37,10 +40,10 @@ | |||
37 | //#include "addresseedialog.moc" | 40 | //#include "addresseedialog.moc" |
38 | 41 | ||
39 | using namespace KABC; | 42 | using namespace KABC; |
40 | 43 | ||
41 | AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : | 44 | AddresseeItem::AddresseeItem( Q3ListView *parent, const Addressee &addressee ) : |
42 | QListViewItem( parent ), | 45 | Q3ListViewItem( parent ), |
43 | mAddressee( addressee ) | 46 | mAddressee( addressee ) |
44 | { | 47 | { |
45 | setText( Name,addressee.realName()); | 48 | setText( Name,addressee.realName()); |
46 | setText( Email, addressee.preferredEmail() ); | 49 | setText( Email, addressee.preferredEmail() ); |
@@ -70,9 +73,9 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | |||
70 | setMainWidget( mMiniSplitter ); | 73 | setMainWidget( mMiniSplitter ); |
71 | 74 | ||
72 | QWidget *listWidget = new QWidget( mMiniSplitter ); | 75 | QWidget *listWidget = new QWidget( mMiniSplitter ); |
73 | 76 | ||
74 | QVBoxLayout *listLayout = new QVBoxLayout (listWidget) ; | 77 | Q3VBoxLayout *listLayout = new Q3VBoxLayout (listWidget) ; |
75 | //topLayout->addLayout( listLayout ); | 78 | //topLayout->addLayout( listLayout ); |
76 | 79 | ||
77 | mAddresseeList = new KListView( listWidget ); | 80 | mAddresseeList = new KListView( listWidget ); |
78 | mAddresseeList->addColumn( i18n("Name") ); | 81 | mAddresseeList->addColumn( i18n("Name") ); |
@@ -80,12 +83,12 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | |||
80 | mAddresseeList->addColumn( i18n("Category") ); | 83 | mAddresseeList->addColumn( i18n("Category") ); |
81 | mAddresseeList->setAllColumnsShowFocus( true ); | 84 | mAddresseeList->setAllColumnsShowFocus( true ); |
82 | mAddresseeList->setFullWidth( true ); | 85 | mAddresseeList->setFullWidth( true ); |
83 | listLayout->addWidget( mAddresseeList ); | 86 | listLayout->addWidget( mAddresseeList ); |
84 | connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), | 87 | connect( mAddresseeList, SIGNAL( doubleClicked( Q3ListViewItem * ) ), |
85 | SLOT( slotOk() ) ); | 88 | SLOT( slotOk() ) ); |
86 | //QHBox* searchBox = new QHBox ( listWidget ); | 89 | //QHBox* searchBox = new QHBox ( listWidget ); |
87 | QHBox * hb = new QHBox ( listWidget ); | 90 | Q3HBox * hb = new Q3HBox ( listWidget ); |
88 | listLayout->addWidget ( hb ); | 91 | listLayout->addWidget ( hb ); |
89 | mAddresseeEdit = new QLineEdit( hb ); | 92 | mAddresseeEdit = new QLineEdit( hb ); |
90 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), | 93 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), |
91 | SLOT( loadAddressBook() ) ); | 94 | SLOT( loadAddressBook() ) ); |
@@ -100,22 +103,22 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | |||
100 | mSelectedList->setAllColumnsShowFocus( true ); | 103 | mSelectedList->setAllColumnsShowFocus( true ); |
101 | mSelectedList->setFullWidth( true ); | 104 | mSelectedList->setFullWidth( true ); |
102 | //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), | 105 | //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), |
103 | // SLOT( removeSelected() ) ); | 106 | // SLOT( removeSelected() ) ); |
104 | connect( mSelectedList, SIGNAL( clicked( QListViewItem * ) ), | 107 | connect( mSelectedList, SIGNAL( clicked( Q3ListViewItem * ) ), |
105 | SLOT( removeSelected() ) ); | 108 | SLOT( removeSelected() ) ); |
106 | connect( mSelectedList, SIGNAL( returnPressed( QListViewItem *) ), | 109 | connect( mSelectedList, SIGNAL( returnPressed( Q3ListViewItem *) ), |
107 | SLOT( removeSelected() ) ); | 110 | SLOT( removeSelected() ) ); |
108 | 111 | ||
109 | #if 0 | 112 | #if 0 |
110 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); | 113 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); |
111 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); | 114 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); |
112 | 115 | ||
113 | #endif | 116 | #endif |
114 | connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), | 117 | connect( mAddresseeList, SIGNAL( clicked( Q3ListViewItem * ) ), |
115 | SLOT( addSelected( QListViewItem * ) ) ); | 118 | SLOT( addSelected( Q3ListViewItem * ) ) ); |
116 | connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), | 119 | connect( mAddresseeList, SIGNAL( returnPressed( Q3ListViewItem * ) ), |
117 | SLOT( selectNextItem( QListViewItem * ) ) ); | 120 | SLOT( selectNextItem( Q3ListViewItem * ) ) ); |
118 | 121 | ||
119 | } | 122 | } |
120 | 123 | ||
121 | mAddressBook = StdAddressBook::self( true ); | 124 | mAddressBook = StdAddressBook::self( true ); |
@@ -125,9 +128,9 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | |||
125 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), | 128 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), |
126 | SLOT( addressBookChanged() ) ); | 129 | SLOT( addressBookChanged() ) ); |
127 | #endif | 130 | #endif |
128 | loadAddressBook(); | 131 | loadAddressBook(); |
129 | QValueList<int> splitterSize; | 132 | Q3ValueList<int> splitterSize; |
130 | splitterSize.append( ( width() / 5 ) * 3 ); | 133 | splitterSize.append( ( width() / 5 ) * 3 ); |
131 | splitterSize.append( ( width() / 5 ) *2 ); | 134 | splitterSize.append( ( width() / 5 ) *2 ); |
132 | mMiniSplitter->setSizes( splitterSize ); | 135 | mMiniSplitter->setSizes( splitterSize ); |
133 | } | 136 | } |
@@ -171,9 +174,9 @@ void AddresseeDialog::loadAddressBook() | |||
171 | AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); | 174 | AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); |
172 | } | 175 | } |
173 | } | 176 | } |
174 | 177 | ||
175 | void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) | 178 | void AddresseeDialog::addCompletionItem( const QString &str, Q3ListViewItem *item ) |
176 | { | 179 | { |
177 | if ( str.isEmpty() ) return; | 180 | if ( str.isEmpty() ) return; |
178 | 181 | ||
179 | mItemDict.insert( str, item ); | 182 | mItemDict.insert( str, item ); |
@@ -183,41 +186,41 @@ void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item | |||
183 | void AddresseeDialog::selectItem( const QString &str ) | 186 | void AddresseeDialog::selectItem( const QString &str ) |
184 | { | 187 | { |
185 | if ( str.isEmpty() ) return; | 188 | if ( str.isEmpty() ) return; |
186 | 189 | ||
187 | QListViewItem *item = mItemDict.find( str ); | 190 | Q3ListViewItem *item = mItemDict.find( str ); |
188 | if ( item ) { | 191 | if ( item ) { |
189 | mAddresseeList->blockSignals( true ); | 192 | mAddresseeList->blockSignals( true ); |
190 | mAddresseeList->setSelected( item, true ); | 193 | mAddresseeList->setSelected( item, true ); |
191 | mAddresseeList->ensureItemVisible( item ); | 194 | mAddresseeList->ensureItemVisible( item ); |
192 | mAddresseeList->blockSignals( false ); | 195 | mAddresseeList->blockSignals( false ); |
193 | } | 196 | } |
194 | } | 197 | } |
195 | 198 | ||
196 | void AddresseeDialog::updateEdit( QListViewItem *item ) | 199 | void AddresseeDialog::updateEdit( Q3ListViewItem *item ) |
197 | { | 200 | { |
198 | mAddresseeEdit->setText( item->text( 0 ) ); | 201 | mAddresseeEdit->setText( item->text( 0 ) ); |
199 | mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); | 202 | mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); |
200 | } | 203 | } |
201 | 204 | ||
202 | void AddresseeDialog::selectNextItem( QListViewItem *item ) | 205 | void AddresseeDialog::selectNextItem( Q3ListViewItem *item ) |
203 | { | 206 | { |
204 | addSelected( item ); | 207 | addSelected( item ); |
205 | QListViewItem *next = item->nextSibling(); | 208 | Q3ListViewItem *next = item->nextSibling(); |
206 | if ( next ) { | 209 | if ( next ) { |
207 | next->setSelected( true ); | 210 | next->setSelected( true ); |
208 | item->setSelected( false ); | 211 | item->setSelected( false ); |
209 | mAddresseeList->setCurrentItem( next ); | 212 | mAddresseeList->setCurrentItem( next ); |
210 | } | 213 | } |
211 | } | 214 | } |
212 | void AddresseeDialog::addSelected( QListViewItem *item ) | 215 | void AddresseeDialog::addSelected( Q3ListViewItem *item ) |
213 | { | 216 | { |
214 | AddresseeItem *addrItem = (AddresseeItem *)( item ); | 217 | AddresseeItem *addrItem = (AddresseeItem *)( item ); |
215 | if ( !addrItem ) return; | 218 | if ( !addrItem ) return; |
216 | 219 | ||
217 | Addressee a = addrItem->addressee(); | 220 | Addressee a = addrItem->addressee(); |
218 | 221 | ||
219 | QListViewItem *selectedItem = mSelectedDict.find( a.uid() ); | 222 | Q3ListViewItem *selectedItem = mSelectedDict.find( a.uid() ); |
220 | if ( !selectedItem ) { | 223 | if ( !selectedItem ) { |
221 | selectedItem = new AddresseeItem( mSelectedList, a ); | 224 | selectedItem = new AddresseeItem( mSelectedList, a ); |
222 | mSelectedDict.insert( a.uid(), selectedItem ); | 225 | mSelectedDict.insert( a.uid(), selectedItem ); |
223 | } | 226 | } |
@@ -225,12 +228,12 @@ void AddresseeDialog::addSelected( QListViewItem *item ) | |||
225 | } | 228 | } |
226 | 229 | ||
227 | void AddresseeDialog::removeSelected() | 230 | void AddresseeDialog::removeSelected() |
228 | { | 231 | { |
229 | QListViewItem *item = mSelectedList->selectedItem(); | 232 | Q3ListViewItem *item = mSelectedList->selectedItem(); |
230 | AddresseeItem *addrItem = (AddresseeItem *)( item ); | 233 | AddresseeItem *addrItem = (AddresseeItem *)( item ); |
231 | if ( !addrItem ) return; | 234 | if ( !addrItem ) return; |
232 | QListViewItem *next = item->nextSibling(); | 235 | Q3ListViewItem *next = item->nextSibling(); |
233 | mSelectedDict.remove( addrItem->addressee().uid() ); | 236 | mSelectedDict.remove( addrItem->addressee().uid() ); |
234 | delete addrItem; | 237 | delete addrItem; |
235 | if ( next ) | 238 | if ( next ) |
236 | next->setSelected( true ); | 239 | next->setSelected( true ); |
@@ -254,9 +257,9 @@ Addressee::List AddresseeDialog::addressees() | |||
254 | Addressee::List al; | 257 | Addressee::List al; |
255 | AddresseeItem *aItem = 0; | 258 | AddresseeItem *aItem = 0; |
256 | 259 | ||
257 | if ( mMultiple ) { | 260 | if ( mMultiple ) { |
258 | QListViewItem *item = mSelectedList->firstChild(); | 261 | Q3ListViewItem *item = mSelectedList->firstChild(); |
259 | while( item ) { | 262 | while( item ) { |
260 | aItem = (AddresseeItem *)( item ); | 263 | aItem = (AddresseeItem *)( item ); |
261 | if ( aItem ) al.append( aItem->addressee() ); | 264 | if ( aItem ) al.append( aItem->addressee() ); |
262 | item = item->nextSibling(); | 265 | item = item->nextSibling(); |