summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/kaddressbookiconview.cpp
Unidiff
Diffstat (limited to 'kaddressbook/views/kaddressbookiconview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index fdc0db9..f4c68b8 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -20,48 +20,49 @@
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 <qiconview.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#include <kabc/addressbook.h> 38#include <kabc/addressbook.h>
39#include "kabprefs.h" 39#include "kabprefs.h"
40#include "viewmanager.h" 40#include "viewmanager.h"
41#include "kaddressbookiconview.h" 41#include "kaddressbookiconview.h"
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qapplication.h>
44#include <kglobal.h> 45#include <kglobal.h>
45/*US transfered to the headerfile 46/*US transfered to the headerfile
46class IconViewFactory : public ViewFactory 47class IconViewFactory : public ViewFactory
47{ 48{
48 public: 49 public:
49 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
50 { 51 {
51 return new KAddressBookIconView( ab, parent, name ); 52 return new KAddressBookIconView( ab, parent, name );
52 } 53 }
53 54
54 QString type() const { return "Icon"; } 55 QString type() const { return "Icon"; }
55 56
56 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
57}; 58};
58 59
59*/ 60*/
60 61
61extern "C" { 62extern "C" {
62 void *init_libkaddrbk_iconview() 63 void *init_libkaddrbk_iconview()
63 { 64 {
64 return ( new IconViewFactory ); 65 return ( new IconViewFactory );
65 } 66 }
66} 67}
67 68
@@ -190,48 +191,58 @@ KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
190 191
191 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 192 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
192 layout->addWidget(mIconView); 193 layout->addWidget(mIconView);
193 194
194 // Connect up the signals 195 // Connect up the signals
195 196
196//US method executed is part of KIconView 197//US method executed is part of KIconView
197//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
198//US this, SLOT(addresseeExecuted(QIconViewItem *))); 199//US this, SLOT(addresseeExecuted(QIconViewItem *)));
199 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
200 this, SLOT(addresseeExecuted(QIconViewItem *))); 201 this, SLOT(addresseeExecuted(QIconViewItem *)));
201 202
202 connect(mIconView, SIGNAL(selectionChanged()), 203 connect(mIconView, SIGNAL(selectionChanged()),
203 this, SLOT(addresseeSelected())); 204 this, SLOT(addresseeSelected()));
204 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
205 this, SIGNAL(dropped(QDropEvent*))); 206 this, SIGNAL(dropped(QDropEvent*)));
206 connect(mIconView, SIGNAL(startAddresseeDrag()), 207 connect(mIconView, SIGNAL(startAddresseeDrag()),
207 this, SIGNAL(startDrag())); 208 this, SIGNAL(startDrag()));
208} 209}
209 210
210KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
211{ 212{
212} 213}
213 214
215void KAddressBookIconView::scrollUP()
216{
217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
218 QApplication::postEvent( mIconView, ev );
219}
220void KAddressBookIconView::scrollDOWN()
221{
222 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
223 QApplication::postEvent( mIconView, ev );
224}
214void KAddressBookIconView::readConfig(KConfig *config) 225void KAddressBookIconView::readConfig(KConfig *config)
215{ 226{
216 KAddressBookView::readConfig(config); 227 KAddressBookView::readConfig(config);
217 228
218//US method executed is part of KIconView 229//US method executed is part of KIconView
219//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 230//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
220//US this, SLOT(addresseeExecuted(QIconViewItem *))); 231//US this, SLOT(addresseeExecuted(QIconViewItem *)));
221 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 232 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
222 this, SLOT(addresseeExecuted(QIconViewItem *))); 233 this, SLOT(addresseeExecuted(QIconViewItem *)));
223 234
224//US method executed is part of KIconView. Use selectionChanged instead 235//US method executed is part of KIconView. Use selectionChanged instead
225/*US 236/*US
226 if (KABPrefs::instance()->mHonorSingleClick) 237 if (KABPrefs::instance()->mHonorSingleClick)
227 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 238 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
228 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
229 else 240 else
230 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 241 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
231 this, SLOT(addresseeExecuted(QIconViewItem *))); 242 this, SLOT(addresseeExecuted(QIconViewItem *)));
232*/ 243*/
233 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 244 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
234 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
235 246
236} 247}
237void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 248void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
@@ -259,48 +270,54 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
259 if (re.match(field->value( *it ).lower()) != -1) 270 if (re.match(field->value( *it ).lower()) != -1)
260#endif 271#endif
261 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 272 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
262 273
263 274
264 } 275 }
265 } else { 276 } else {
266 KABC::Field::List fieldList = fields(); 277 KABC::Field::List fieldList = fields();
267 KABC::Field::List::ConstIterator fieldIt; 278 KABC::Field::List::ConstIterator fieldIt;
268 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
269 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 280 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
270#if QT_VERSION >= 300 281#if QT_VERSION >= 300
271 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 282 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
272#else 283#else
273 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 284 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
274#endif 285#endif
275 { 286 {
276 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 287 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
277 continue; 288 continue;
278 } 289 }
279 } 290 }
280 } 291 }
281 } 292 }
282 mIconView->arrangeItemsInGrid( true ); 293 mIconView->arrangeItemsInGrid( true );
294 if ( mIconView->firstItem() ) {
295 mIconView->setCurrentItem ( mIconView->firstItem() );
296 mIconView->setSelected ( mIconView->firstItem() , true );
297 }
298 else
299 emit selected(QString::null);
283} 300}
284QStringList KAddressBookIconView::selectedUids() 301QStringList KAddressBookIconView::selectedUids()
285{ 302{
286 QStringList uidList; 303 QStringList uidList;
287 QIconViewItem *item; 304 QIconViewItem *item;
288 AddresseeIconViewItem *aItem; 305 AddresseeIconViewItem *aItem;
289 306
290 for (item = mIconView->firstItem(); item; item = item->nextItem()) 307 for (item = mIconView->firstItem(); item; item = item->nextItem())
291 { 308 {
292 if (item->isSelected()) 309 if (item->isSelected())
293 { 310 {
294#ifndef KAB_EMBEDDED 311#ifndef KAB_EMBEDDED
295 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 312 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
296#else //KAB_EMBEDDED 313#else //KAB_EMBEDDED
297 aItem = (AddresseeIconViewItem*)(item); 314 aItem = (AddresseeIconViewItem*)(item);
298#endif //KAB_EMBEDDED 315#endif //KAB_EMBEDDED
299 if (aItem) 316 if (aItem)
300 uidList << aItem->addressee().uid(); 317 uidList << aItem->addressee().uid();
301 } 318 }
302 } 319 }
303 320
304 return uidList; 321 return uidList;
305} 322}
306 323