Diffstat (limited to 'kaddressbook/views/kaddressbookiconview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index d6ddec3..3a41a4b 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -19,25 +19,33 @@ | |||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qiconview.h> | 25 | #include <q3iconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | //Added by qt3to4: | ||
39 | #include <QDropEvent> | ||
40 | #include <Q3ValueList> | ||
41 | #include <QPixmap> | ||
42 | #include <QKeyEvent> | ||
43 | #include <QEvent> | ||
44 | #include <Q3VBoxLayout> | ||
45 | |||
38 | #include <kabc/addressbook.h> | 46 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 47 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 48 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 49 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 50 | #include <qlayout.h> |
43 | #include <qregexp.h> | 51 | #include <qregexp.h> |
@@ -70,70 +78,70 @@ extern "C" { | |||
70 | // AddresseeIconView (internal class) | 78 | // AddresseeIconView (internal class) |
71 | #ifndef KAB_EMBEDDED | 79 | #ifndef KAB_EMBEDDED |
72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 80 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
73 | : KIconView(parent, name) | 81 | : KIconView(parent, name) |
74 | #else //KAB_EMBEDDED | 82 | #else //KAB_EMBEDDED |
75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 83 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
76 | : QIconView(parent, name) | 84 | : Q3IconView(parent, name) |
77 | #endif //KAB_EMBEDDED | 85 | #endif //KAB_EMBEDDED |
78 | 86 | ||
79 | { | 87 | { |
80 | setSelectionMode( QIconView::Extended ); | 88 | setSelectionMode( Q3IconView::Extended ); |
81 | setResizeMode( QIconView::Adjust ); | 89 | setResizeMode( Q3IconView::Adjust ); |
82 | setWordWrapIconText( true ); | 90 | setWordWrapIconText( true ); |
83 | setGridX( 100 ); | 91 | setGridX( 100 ); |
84 | setItemsMovable(false); | 92 | setItemsMovable(false); |
85 | setSorting(true, true); | 93 | setSorting(true, true); |
86 | 94 | ||
87 | 95 | ||
88 | //US ??? setMode( KIconView::Select ); | 96 | //US ??? setMode( KIconView::Select ); |
89 | 97 | ||
90 | #ifndef KAB_EMBEDDED | 98 | #ifndef KAB_EMBEDDED |
91 | 99 | ||
92 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 100 | connect(this, SIGNAL(dropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&)), |
93 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 101 | this, SLOT(itemDropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&))); |
94 | #endif //KAB_EMBEDDED | 102 | #endif //KAB_EMBEDDED |
95 | } | 103 | } |
96 | 104 | ||
97 | AddresseeIconView::~AddresseeIconView() | 105 | AddresseeIconView::~AddresseeIconView() |
98 | { | 106 | { |
99 | } | 107 | } |
100 | 108 | ||
101 | 109 | ||
102 | void AddresseeIconView::itemDropped(QDropEvent *e, | 110 | void AddresseeIconView::itemDropped(QDropEvent *e, |
103 | const QValueList<QIconDragItem> &) | 111 | const Q3ValueList<Q3IconDragItem> &) |
104 | { | 112 | { |
105 | emit addresseeDropped(e); | 113 | emit addresseeDropped(e); |
106 | } | 114 | } |
107 | 115 | ||
108 | QDragObject *AddresseeIconView::dragObject() | 116 | Q3DragObject *AddresseeIconView::dragObject() |
109 | { | 117 | { |
110 | emit startAddresseeDrag(); | 118 | emit startAddresseeDrag(); |
111 | 119 | ||
112 | // We never want IconView to start the drag | 120 | // We never want IconView to start the drag |
113 | return 0; | 121 | return 0; |
114 | } | 122 | } |
115 | //////////////////////////////// | 123 | //////////////////////////////// |
116 | // AddresseeIconViewItem (internal class) | 124 | // AddresseeIconViewItem (internal class) |
117 | #ifndef KAB_EMBEDDED | 125 | #ifndef KAB_EMBEDDED |
118 | class AddresseeIconViewItem : public KIconViewItem | 126 | class AddresseeIconViewItem : public KIconViewItem |
119 | #else //KAB_EMBEDDED | 127 | #else //KAB_EMBEDDED |
120 | class AddresseeIconViewItem : public QIconViewItem | 128 | class AddresseeIconViewItem : public Q3IconViewItem |
121 | #endif //KAB_EMBEDDED | 129 | #endif //KAB_EMBEDDED |
122 | { | 130 | { |
123 | public: | 131 | public: |
124 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
125 | AddresseeIconViewItem(const KABC::Field::List &fields, | 133 | AddresseeIconViewItem(const KABC::Field::List &fields, |
126 | KABC::AddressBook *doc, const KABC::Addressee &a, | 134 | KABC::AddressBook *doc, const KABC::Addressee &a, |
127 | QIconView *parent) | 135 | Q3IconView *parent) |
128 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 136 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
129 | #else //KAB_EMBEDDED | 137 | #else //KAB_EMBEDDED |
130 | AddresseeIconViewItem(const KABC::Field::List &fields, | 138 | AddresseeIconViewItem(const KABC::Field::List &fields, |
131 | KABC::AddressBook *doc, const KABC::Addressee &a, | 139 | KABC::AddressBook *doc, const KABC::Addressee &a, |
132 | QIconView *parent) | 140 | Q3IconView *parent) |
133 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 141 | : Q3IconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
134 | #endif //KAB_EMBEDDED | 142 | #endif //KAB_EMBEDDED |
135 | { | 143 | { |
136 | if ( mFields.isEmpty() ) { | 144 | if ( mFields.isEmpty() ) { |
137 | mFields = KABC::Field::defaultFields(); | 145 | mFields = KABC::Field::defaultFields(); |
138 | } | 146 | } |
139 | refresh(); | 147 | refresh(); |
@@ -197,24 +205,24 @@ class AddresseeIconViewItem : public QIconViewItem | |||
197 | 205 | ||
198 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 206 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
199 | QWidget *parent, const char *name) | 207 | QWidget *parent, const char *name) |
200 | : KAddressBookView( ab, parent, name ) | 208 | : KAddressBookView( ab, parent, name ) |
201 | { | 209 | { |
202 | // Init the GUI | 210 | // Init the GUI |
203 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 211 | Q3VBoxLayout *layout = new Q3VBoxLayout(viewWidget()); |
204 | 212 | ||
205 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 213 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
206 | layout->addWidget(mIconView); | 214 | layout->addWidget(mIconView); |
207 | 215 | ||
208 | // Connect up the signals | 216 | // Connect up the signals |
209 | 217 | ||
210 | //US method executed is part of KIconView | 218 | //US method executed is part of KIconView |
211 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 219 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
212 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
213 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 221 | connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
214 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 222 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
215 | 223 | ||
216 | connect(mIconView, SIGNAL(selectionChanged()), | 224 | connect(mIconView, SIGNAL(selectionChanged()), |
217 | this, SLOT(addresseeSelected())); | 225 | this, SLOT(addresseeSelected())); |
218 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 226 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
219 | this, SIGNAL(dropped(QDropEvent*))); | 227 | this, SIGNAL(dropped(QDropEvent*))); |
220 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 228 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
@@ -245,26 +253,26 @@ void KAddressBookIconView::readConfig(KConfig *config) | |||
245 | { | 253 | { |
246 | KAddressBookView::readConfig(config); | 254 | KAddressBookView::readConfig(config); |
247 | 255 | ||
248 | //US method executed is part of KIconView | 256 | //US method executed is part of KIconView |
249 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 257 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
250 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 258 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
251 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 259 | disconnect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
252 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 260 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
253 | 261 | ||
254 | //US method executed is part of KIconView. Use selectionChanged instead | 262 | //US method executed is part of KIconView. Use selectionChanged instead |
255 | /*US | 263 | /*US |
256 | if (KABPrefs::instance()->mHonorSingleClick) | 264 | if (KABPrefs::instance()->mHonorSingleClick) |
257 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 265 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
258 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 266 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
259 | else | 267 | else |
260 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 268 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
261 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 269 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
262 | */ | 270 | */ |
263 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 271 | connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
264 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 272 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
265 | 273 | ||
266 | } | 274 | } |
267 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 275 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
268 | { | 276 | { |
269 | mIconView->clear(); | 277 | mIconView->clear(); |
270 | mIconList.clear(); | 278 | mIconList.clear(); |
@@ -333,13 +341,13 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | |||
333 | else | 341 | else |
334 | emit selected(QString::null); | 342 | emit selected(QString::null); |
335 | } | 343 | } |
336 | QStringList KAddressBookIconView::selectedUids() | 344 | QStringList KAddressBookIconView::selectedUids() |
337 | { | 345 | { |
338 | QStringList uidList; | 346 | QStringList uidList; |
339 | QIconViewItem *item; | 347 | Q3IconViewItem *item; |
340 | AddresseeIconViewItem *aItem; | 348 | AddresseeIconViewItem *aItem; |
341 | 349 | ||
342 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 350 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
343 | { | 351 | { |
344 | if (item->isSelected()) | 352 | if (item->isSelected()) |
345 | { | 353 | { |
@@ -355,13 +363,13 @@ QStringList KAddressBookIconView::selectedUids() | |||
355 | 363 | ||
356 | return uidList; | 364 | return uidList; |
357 | } | 365 | } |
358 | 366 | ||
359 | void KAddressBookIconView::refresh(QString uid) | 367 | void KAddressBookIconView::refresh(QString uid) |
360 | { | 368 | { |
361 | QIconViewItem *item; | 369 | Q3IconViewItem *item; |
362 | AddresseeIconViewItem *aItem; | 370 | AddresseeIconViewItem *aItem; |
363 | 371 | ||
364 | if ( uid.isNull() ) { | 372 | if ( uid.isNull() ) { |
365 | // Rebuild the view | 373 | // Rebuild the view |
366 | mIconView->clear(); | 374 | mIconView->clear(); |
367 | mIconList.clear(); | 375 | mIconList.clear(); |
@@ -403,13 +411,13 @@ void KAddressBookIconView::refresh(QString uid) | |||
403 | refresh( QString::null ); | 411 | refresh( QString::null ); |
404 | } | 412 | } |
405 | } | 413 | } |
406 | 414 | ||
407 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 415 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
408 | { | 416 | { |
409 | QIconViewItem *item; | 417 | Q3IconViewItem *item; |
410 | AddresseeIconViewItem *aItem; | 418 | AddresseeIconViewItem *aItem; |
411 | 419 | ||
412 | if (uid.isNull()) | 420 | if (uid.isNull()) |
413 | { | 421 | { |
414 | mIconView->selectAll(selected); | 422 | mIconView->selectAll(selected); |
415 | } | 423 | } |
@@ -432,13 +440,13 @@ void KAddressBookIconView::setSelected(QString uid, bool selected) | |||
432 | found = true; | 440 | found = true; |
433 | } | 441 | } |
434 | } | 442 | } |
435 | } | 443 | } |
436 | } | 444 | } |
437 | 445 | ||
438 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 446 | void KAddressBookIconView::addresseeExecuted(Q3IconViewItem *item) |
439 | { | 447 | { |
440 | #ifndef KAB_EMBEDDED | 448 | #ifndef KAB_EMBEDDED |
441 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 449 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
442 | #else //KAB_EMBEDDED | 450 | #else //KAB_EMBEDDED |
443 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 451 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
444 | #endif //KAB_EMBEDDED | 452 | #endif //KAB_EMBEDDED |
@@ -447,13 +455,13 @@ void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | |||
447 | emit executed(aItem->addressee().uid()); | 455 | emit executed(aItem->addressee().uid()); |
448 | } | 456 | } |
449 | } | 457 | } |
450 | 458 | ||
451 | void KAddressBookIconView::addresseeSelected() | 459 | void KAddressBookIconView::addresseeSelected() |
452 | { | 460 | { |
453 | QIconViewItem *item; | 461 | Q3IconViewItem *item; |
454 | AddresseeIconViewItem *aItem; | 462 | AddresseeIconViewItem *aItem; |
455 | 463 | ||
456 | bool found = false; | 464 | bool found = false; |
457 | for (item = mIconView->firstItem(); item && !found; | 465 | for (item = mIconView->firstItem(); item && !found; |
458 | item = item->nextItem()) | 466 | item = item->nextItem()) |
459 | { | 467 | { |
@@ -473,9 +481,9 @@ void KAddressBookIconView::addresseeSelected() | |||
473 | } | 481 | } |
474 | 482 | ||
475 | if (!found) | 483 | if (!found) |
476 | emit selected(QString::null); | 484 | emit selected(QString::null); |
477 | } | 485 | } |
478 | 486 | ||
479 | #ifndef KAB_EMBEDDED | 487 | #ifndef KAB_EMBEDDED_ |
480 | #include "kaddressbookiconview.moc" | 488 | #include "moc_kaddressbookiconview.cpp" |
481 | #endif //KAB_EMBEDDED | 489 | #endif //KAB_EMBEDDED |