summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Unidiff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/cardview.cpp114
-rw-r--r--kaddressbook/views/cardview.h14
-rw-r--r--kaddressbook/views/colorlistbox.cpp25
-rw-r--r--kaddressbook/views/colorlistbox.h15
-rw-r--r--kaddressbook/views/configurecardviewdialog.cpp57
-rw-r--r--kaddressbook/views/configurecardviewdialog.h6
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp35
-rw-r--r--kaddressbook/views/configuretableviewdialog.h6
-rw-r--r--kaddressbook/views/contactlistview.cpp32
-rw-r--r--kaddressbook/views/contactlistview.h6
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp19
-rw-r--r--kaddressbook/views/kaddressbookcardview.h3
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp60
-rw-r--r--kaddressbook/views/kaddressbookiconview.h29
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp56
-rw-r--r--kaddressbook/views/kaddressbooktableview.h18
16 files changed, 283 insertions, 212 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index b6e053f..1a29f41 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -25,24 +25,32 @@
25#include "cardview.h" 25#include "cardview.h"
26 26
27#include <limits.h> 27#include <limits.h>
28 28
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qstyle.h> 33#include <qstyle.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qapplication.h> 36#include <qapplication.h>
37//Added by qt3to4:
38#include <QKeyEvent>
39#include <Q3PtrList>
40#include <QResizeEvent>
41#include <QFocusEvent>
42#include <QMouseEvent>
43#include <QEvent>
44#include <QWheelEvent>
37 45
38#include "kabprefs.h" 46#include "kabprefs.h"
39#include <kdebug.h> 47#include <kdebug.h>
40#include <kglobalsettings.h> 48#include <kglobalsettings.h>
41//END includes 49//END includes
42 50
43#define MIN_ITEM_WIDTH 80 51#define MIN_ITEM_WIDTH 80
44 52
45//BEGIN Helpers 53//BEGIN Helpers
46////////////////////////////////////// 54//////////////////////////////////////
47// CardViewTip 55// CardViewTip
48class CardViewTip : public QLabel { 56class CardViewTip : public QLabel {
@@ -62,29 +70,29 @@ class CardViewTip : public QLabel {
62 hide(); 70 hide();
63 } 71 }
64}; 72};
65 73
66////////////////////////////////////// 74//////////////////////////////////////
67// CardViewItemList 75// CardViewItemList
68 76
69 77
70// 78//
71// Warning: make sure you use findRef() instead of find() to find an 79// Warning: make sure you use findRef() instead of find() to find an
72// item! Only the pointer value is unique in the list. 80// item! Only the pointer value is unique in the list.
73// 81//
74class CardViewItemList : public QPtrList<CardViewItem> 82class CardViewItemList : public Q3PtrList<CardViewItem>
75{ 83{
76 protected: 84 protected:
77 virtual int compareItems(QPtrCollection::Item item1, 85 virtual int compareItems(Q3PtrCollection::Item item1,
78 QPtrCollection::Item item2) 86 Q3PtrCollection::Item item2)
79 { 87 {
80 CardViewItem *cItem1 = (CardViewItem*)item1; 88 CardViewItem *cItem1 = (CardViewItem*)item1;
81 CardViewItem *cItem2 = (CardViewItem*)item2; 89 CardViewItem *cItem2 = (CardViewItem*)item2;
82 90
83 if ( cItem1 == cItem2 ) 91 if ( cItem1 == cItem2 )
84 return 0; 92 return 0;
85 93
86 if ((cItem1 == 0) || (cItem2 == 0)) 94 if ((cItem1 == 0) || (cItem2 == 0))
87 return cItem1 ? -1 : 1; 95 return cItem1 ? -1 : 1;
88 96
89 if (cItem1->caption() < cItem2->caption()) 97 if (cItem1->caption() < cItem2->caption())
90 return -1; 98 return -1;
@@ -152,25 +160,25 @@ class CardViewPrivate
152 mItemMargin( 0 ), 160 mItemMargin( 0 ),
153 mItemSpacing( 10 ), 161 mItemSpacing( 10 ),
154 mItemWidth( 200 ), 162 mItemWidth( 200 ),
155 mMaxFieldLines( INT_MAX ), 163 mMaxFieldLines( INT_MAX ),
156 mCurrentItem( 0L ), 164 mCurrentItem( 0L ),
157 mLastClickPos( QPoint(0, 0) ), 165 mLastClickPos( QPoint(0, 0) ),
158 mResizeAnchor(0), 166 mResizeAnchor(0),
159 mRubberBandAnchor( 0 ), 167 mRubberBandAnchor( 0 ),
160 mCompText( QString::null ) 168 mCompText( QString::null )
161 {}; 169 {};
162 170
163 CardViewItemList mItemList; 171 CardViewItemList mItemList;
164 QPtrList<CardViewSeparator> mSeparatorList; 172 Q3PtrList<CardViewSeparator> mSeparatorList;
165 QFontMetrics *mFm; 173 QFontMetrics *mFm;
166 QFontMetrics *mBFm; // bold font 174 QFontMetrics *mBFm; // bold font
167 QFont mHeaderFont; // custom header font 175 QFont mHeaderFont; // custom header font
168 CardView::SelectionMode mSelectionMode; 176 CardView::SelectionMode mSelectionMode;
169 bool mDrawCardBorder; 177 bool mDrawCardBorder;
170 bool mDrawFieldLabels; 178 bool mDrawFieldLabels;
171 bool mDrawSeparators; 179 bool mDrawSeparators;
172 int mSepWidth; 180 int mSepWidth;
173 bool mShowEmptyFields; 181 bool mShowEmptyFields;
174 bool mLayoutDirty; 182 bool mLayoutDirty;
175 bool mLastClickOnItem; 183 bool mLastClickOnItem;
176 uint mItemMargin; // internal margin in items 184 uint mItemMargin; // internal margin in items
@@ -199,25 +207,25 @@ class CardViewPrivate
199}; 207};
200 208
201class CardViewItemPrivate 209class CardViewItemPrivate
202{ 210{
203 public: 211 public:
204 CardViewItemPrivate() : 212 CardViewItemPrivate() :
205 mSelected( false ), 213 mSelected( false ),
206 x( 0 ), 214 x( 0 ),
207 y( 0 ){}; 215 y( 0 ){};
208 216
209 217
210 QString mCaption; 218 QString mCaption;
211 QPtrList< CardViewItem::Field > mFieldList; 219 Q3PtrList< CardViewItem::Field > mFieldList;
212 bool mSelected; 220 bool mSelected;
213 int x; // horizontal position, set by the view 221 int x; // horizontal position, set by the view
214 int y; // vertical position, set by the view 222 int y; // vertical position, set by the view
215 int maxLabelWidth; // the width of the widest label, according to the view font. 223 int maxLabelWidth; // the width of the widest label, according to the view font.
216 int hcache; // height cache 224 int hcache; // height cache
217}; 225};
218//END Private Data 226//END Private Data
219 227
220//BEGIN CardViewItem 228//BEGIN CardViewItem
221 229
222CardViewItem::CardViewItem(CardView *parent, QString caption) 230CardViewItem::CardViewItem(CardView *parent, QString caption)
223 : d(new CardViewItemPrivate()), mView(parent) 231 : d(new CardViewItemPrivate()), mView(parent)
@@ -304,25 +312,25 @@ void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
304 p->save(); 312 p->save();
305 QFont bFont = mView->headerFont(); 313 QFont bFont = mView->headerFont();
306 //bFont.setBold(true); 314 //bFont.setBold(true);
307 p->setFont(bFont); 315 p->setFont(bFont);
308 if (isSelected()) 316 if (isSelected())
309 p->setPen(cg.highlightedText()); 317 p->setPen(cg.highlightedText());
310 else 318 else
311 p->setPen(cg.buttonText()); 319 p->setPen(cg.buttonText());
312 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm)); 320 p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm));
313 p->restore(); 321 p->restore();
314 322
315 // Go through the fields and draw them 323 // Go through the fields and draw them
316 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 324 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
317 QString label, value; 325 QString label, value;
318 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders) 326 int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders)
319 p->setPen(cg.text()); 327 p->setPen(cg.text());
320 328
321 int fh = fm.height(); 329 int fh = fm.height();
322 int cln( 0 ); 330 int cln( 0 );
323 QString tmp; 331 QString tmp;
324 int maxLines = mView->maxFieldLines(); 332 int maxLines = mView->maxFieldLines();
325 for (iter.toFirst(); iter.current(); ++iter) 333 for (iter.toFirst(); iter.current(); ++iter)
326 { 334 {
327 value = (*iter)->second; 335 value = (*iter)->second;
328 if ( value.isEmpty() && ! mView->d->mShowEmptyFields ) 336 if ( value.isEmpty() && ! mView->d->mShowEmptyFields )
@@ -399,30 +407,30 @@ int CardViewItem::height( bool allowCache ) const
399 int baseHeight = 8 + ( 2 * mView->itemMargin() ); 407 int baseHeight = 8 + ( 2 * mView->itemMargin() );
400 408
401 // size of font for each field 409 // size of font for each field
402 // 2 pad for each field 410 // 2 pad for each field
403 411
404 // anders: if the view does not show empty fields, check for value 412 // anders: if the view does not show empty fields, check for value
405 bool sef = mView->showEmptyFields(); 413 bool sef = mView->showEmptyFields();
406 int fh = mView->d->mFm->height();//lineSpacing(); // font height 414 int fh = mView->d->mFm->height();//lineSpacing(); // font height
407 //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property 415 //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property
408 int fieldHeight = 0; 416 int fieldHeight = 0;
409 int lines; 417 int lines;
410 int maxLines( mView->maxFieldLines() ); 418 int maxLines( mView->maxFieldLines() );
411 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 419 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
412 for (iter.toFirst(); iter.current(); ++iter) 420 for (iter.toFirst(); iter.current(); ++iter)
413 { 421 {
414 if ( !sef && (*iter)->second.isEmpty() ) 422 if ( !sef && (*iter)->second.isEmpty() )
415 continue; 423 continue;
416 lines = QMIN( (*iter)->second.contains('\n') + 1, maxLines ); 424 lines = QMIN( (*iter)->second.count('\n') + 1, maxLines );
417 fieldHeight += ( lines * fh ) + 2;//sp; 425 fieldHeight += ( lines * fh ) + 2;//sp;
418 } 426 }
419 427
420 // height of caption font (bold) 428 // height of caption font (bold)
421 fieldHeight += mView->d->mBFm->height(); 429 fieldHeight += mView->d->mBFm->height();
422 d->hcache = baseHeight + fieldHeight; 430 d->hcache = baseHeight + fieldHeight;
423 return d->hcache; 431 return d->hcache;
424} 432}
425 433
426bool CardViewItem::isSelected() const 434bool CardViewItem::isSelected() const
427{ 435{
428 return d->mSelected; 436 return d->mSelected;
@@ -441,25 +449,25 @@ void CardViewItem::insertField(const QString &label, const QString &value)
441 449
442 if (mView) 450 if (mView)
443 { 451 {
444 mView->setLayoutDirty(true); 452 mView->setLayoutDirty(true);
445 d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth ); 453 d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth );
446 } 454 }
447} 455}
448 456
449void CardViewItem::removeField(const QString &label) 457void CardViewItem::removeField(const QString &label)
450{ 458{
451 CardViewItem::Field *f; 459 CardViewItem::Field *f;
452 460
453 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 461 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
454 for (iter.toFirst(); iter.current(); ++iter) 462 for (iter.toFirst(); iter.current(); ++iter)
455 { 463 {
456 f = *iter; 464 f = *iter;
457 if (f->first == label) 465 if (f->first == label)
458 break; 466 break;
459 } 467 }
460 468
461 if (*iter) 469 if (*iter)
462 d->mFieldList.remove(*iter); 470 d->mFieldList.remove(*iter);
463 d->hcache = 0; 471 d->hcache = 0;
464 472
465 if (mView) 473 if (mView)
@@ -514,25 +522,25 @@ void CardViewItem::repaintCard()
514 if (mView) 522 if (mView)
515 mView->repaintItem(this); 523 mView->repaintItem(this);
516} 524}
517 525
518void CardViewItem::setCaption(const QString &caption) 526void CardViewItem::setCaption(const QString &caption)
519{ 527{
520 d->mCaption = caption; 528 d->mCaption = caption;
521 repaintCard(); 529 repaintCard();
522} 530}
523 531
524QString CardViewItem::fieldValue(const QString &label) 532QString CardViewItem::fieldValue(const QString &label)
525{ 533{
526 QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); 534 Q3PtrListIterator< CardViewItem::Field > iter(d->mFieldList);
527 for (iter.toFirst(); iter.current(); ++iter) 535 for (iter.toFirst(); iter.current(); ++iter)
528 if ((*iter)->first == label) 536 if ((*iter)->first == label)
529 return (*iter)->second; 537 return (*iter)->second;
530 538
531 return QString(); 539 return QString();
532} 540}
533 541
534 542
535void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) 543void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
536{ 544{
537 bool trimmed( false ); 545 bool trimmed( false );
538 QString s; 546 QString s;
@@ -560,42 +568,42 @@ void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
560 return; 568 return;
561 569
562 // y position: 570 // y position:
563 // header font height + 4px hader margin + 2px leading + item margin 571 // header font height + 4px hader margin + 2px leading + item margin
564 // + actual field index * (fontheight + 2px leading) 572 // + actual field index * (fontheight + 2px leading)
565 int maxLines = mView->maxFieldLines(); 573 int maxLines = mView->maxFieldLines();
566 bool se = mView->showEmptyFields(); 574 bool se = mView->showEmptyFields();
567 int fh = mView->d->mFm->height(); 575 int fh = mView->d->mFm->height();
568// { 576// {
569 Field *_f; 577 Field *_f;
570 for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next()) 578 for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next())
571 if ( se || ! _f->second.isEmpty() ) 579 if ( se || ! _f->second.isEmpty() )
572 y += ( QMIN(_f->second.contains('\n')+1, maxLines) * fh ) + 2; 580 y += ( QMIN(_f->second.count('\n')+1, maxLines) * fh ) + 2;
573// } 581// }
574 if ( isLabel && itempos.y() > y + fh ) 582 if ( isLabel && itempos.y() > y + fh )
575 return; 583 return;
576 // label or data? 584 // label or data?
577 s = isLabel ? f->first : f->second; 585 s = isLabel ? f->first : f->second;
578 // trimmed? 586 // trimmed?
579 int colonWidth = mView->d->mFm->width(":"); 587 int colonWidth = mView->d->mFm->width(":");
580 lw = drawLabels ? // label width 588 lw = drawLabels ? // label width
581 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : 589 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) :
582 0; 590 0;
583 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string 591 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string
584 if ( isLabel ) 592 if ( isLabel )
585 { 593 {
586 trimmed = mView->d->mFm->width( s ) > mw - colonWidth; 594 trimmed = mView->d->mFm->width( s ) > mw - colonWidth;
587 } else { 595 } else {
588 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); 596 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) );
589 trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); 597 trimmed = r.width() > mw || r.height()/fh > QMIN(s.count('\n') + 1, maxLines);
590 } 598 }
591 } 599 }
592 if ( trimmed ) 600 if ( trimmed )
593 { 601 {
594 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header 602 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header
595 tip->setText( s ); 603 tip->setText( s );
596 tip->adjustSize(); 604 tip->adjustSize();
597 // find a proper position 605 // find a proper position
598 int lx; 606 int lx;
599 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; 607 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/;
600 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); 608 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) ));
601 pnt += QPoint(lx, y); 609 pnt += QPoint(lx, y);
@@ -617,61 +625,61 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
617 int iy = itempos.y(); 625 int iy = itempos.y();
618 // skip below caption 626 // skip below caption
619 if ( iy <= ypos ) 627 if ( iy <= ypos )
620 return 0; 628 return 0;
621 // try find a field 629 // try find a field
622 bool showEmpty = mView->showEmptyFields(); 630 bool showEmpty = mView->showEmptyFields();
623 int fh = mView->d->mFm->height(); 631 int fh = mView->d->mFm->height();
624 int maxLines = mView->maxFieldLines(); 632 int maxLines = mView->maxFieldLines();
625 Field *f; 633 Field *f;
626 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) 634 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() )
627 { 635 {
628 if ( showEmpty || !f->second.isEmpty() ) 636 if ( showEmpty || !f->second.isEmpty() )
629 ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; 637 ypos += ( QMIN( f->second.count('\n')+1, maxLines ) *fh)+2;
630 if ( iy <= ypos ) 638 if ( iy <= ypos )
631 break; 639 break;
632 } 640 }
633 return f ? f : 0; 641 return f ? f : 0;
634} 642}
635//END CardViewItem 643//END CardViewItem
636 644
637//BEGIN CardView 645//BEGIN CardView
638 646
639CardView::CardView(QWidget *parent, const char *name) 647CardView::CardView(QWidget *parent, const char *name)
640 : QScrollView(parent, name), 648 : Q3ScrollView(parent, name),
641 d(new CardViewPrivate()) 649 d(new CardViewPrivate())
642{ 650{
643 mFlagKeyPressed = false; 651 mFlagKeyPressed = false;
644 mFlagBlockKeyPressed = false; 652 mFlagBlockKeyPressed = false;
645 d->mItemList.setAutoDelete(true); 653 d->mItemList.setAutoDelete(true);
646 d->mSeparatorList.setAutoDelete(true); 654 d->mSeparatorList.setAutoDelete(true);
647 655
648 QFont f = font(); 656 QFont f = font();
649 d->mFm = new QFontMetrics(f); 657 d->mFm = new QFontMetrics(f);
650 f.setBold(true); 658 f.setBold(true);
651 d->mHeaderFont = f; 659 d->mHeaderFont = f;
652 d->mBFm = new QFontMetrics(f); 660 d->mBFm = new QFontMetrics(f);
653 d->mTip = ( new CardViewTip( viewport() ) ), 661 d->mTip = ( new CardViewTip( viewport() ) ),
654 d->mTip->hide(); 662 d->mTip->hide();
655 d->mTimer = ( new QTimer(this, "mouseTimer") ), 663 d->mTimer = ( new QTimer(this, "mouseTimer") ),
656 664
657 viewport()->setMouseTracking( true ); 665 viewport()->setMouseTracking( true );
658 viewport()->setFocusProxy(this); 666 viewport()->setFocusProxy(this);
659 viewport()->setFocusPolicy(WheelFocus); 667 viewport()->setFocusPolicy(Qt::WheelFocus);
660 viewport()->setBackgroundMode(PaletteBase); 668 viewport()->setBackgroundMode(Qt::PaletteBase);
661 669
662 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); 670 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) );
663 671
664//US setBackgroundMode(PaletteBackground, PaletteBase); 672//US setBackgroundMode(PaletteBackground, PaletteBase);
665 setBackgroundMode(PaletteBackground); 673 setBackgroundMode(Qt::PaletteBackground);
666 674
667 // no reason for a vertical scrollbar 675 // no reason for a vertical scrollbar
668 setVScrollBarMode(AlwaysOff); 676 setVScrollBarMode(AlwaysOff);
669} 677}
670 678
671CardView::~CardView() 679CardView::~CardView()
672{ 680{
673 delete d->mFm; 681 delete d->mFm;
674 delete d->mBFm; 682 delete d->mBFm;
675 delete d; 683 delete d;
676 d = 0; 684 d = 0;
677} 685}
@@ -730,25 +738,25 @@ void CardView::setCurrentItem( CardViewItem *item )
730 if ( it ) 738 if ( it )
731 it->repaintCard(); 739 it->repaintCard();
732 item->repaintCard(); 740 item->repaintCard();
733 } 741 }
734 if ( ! d->mOnSeparator ) 742 if ( ! d->mOnSeparator )
735 ensureItemVisible( item ); 743 ensureItemVisible( item );
736 emit currentChanged( item ); 744 emit currentChanged( item );
737} 745}
738 746
739CardViewItem *CardView::itemAt(const QPoint &viewPos) 747CardViewItem *CardView::itemAt(const QPoint &viewPos)
740{ 748{
741 CardViewItem *item = 0; 749 CardViewItem *item = 0;
742 QPtrListIterator<CardViewItem> iter(d->mItemList); 750 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
743 bool found = false; 751 bool found = false;
744 for (iter.toFirst(); iter.current() && !found; ++iter) 752 for (iter.toFirst(); iter.current() && !found; ++iter)
745 { 753 {
746 item = *iter; 754 item = *iter;
747 //if (item->d->mRect.contains(viewPos)) 755 //if (item->d->mRect.contains(viewPos))
748 if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos)) 756 if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos))
749 found = true; 757 found = true;
750 } 758 }
751 759
752 if (found) 760 if (found)
753 return item; 761 return item;
754 762
@@ -778,25 +786,25 @@ void CardView::setSelectionMode(CardView::SelectionMode mode)
778 selectAll(false); 786 selectAll(false);
779 787
780 d->mSelectionMode = mode; 788 d->mSelectionMode = mode;
781} 789}
782 790
783CardView::SelectionMode CardView::selectionMode() const 791CardView::SelectionMode CardView::selectionMode() const
784{ 792{
785 return d->mSelectionMode; 793 return d->mSelectionMode;
786} 794}
787 795
788void CardView::selectAll(bool state) 796void CardView::selectAll(bool state)
789{ 797{
790 QPtrListIterator<CardViewItem> iter(d->mItemList); 798 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
791 if (!state) 799 if (!state)
792 { 800 {
793 for (iter.toFirst(); iter.current(); ++iter) 801 for (iter.toFirst(); iter.current(); ++iter)
794 { 802 {
795 if ((*iter)->isSelected()) 803 if ((*iter)->isSelected())
796 { 804 {
797 (*iter)->setSelected(false); 805 (*iter)->setSelected(false);
798 (*iter)->repaintCard(); 806 (*iter)->repaintCard();
799 } 807 }
800 } 808 }
801 //emit selectionChanged(); // WARNING FIXME 809 //emit selectionChanged(); // WARNING FIXME
802 emit selectionChanged(0); 810 emit selectionChanged(0);
@@ -869,25 +877,25 @@ void CardView::setSelected(CardViewItem *item, bool selected)
869 emit selectionChanged(); 877 emit selectionChanged();
870 } 878 }
871} 879}
872 880
873bool CardView::isSelected(CardViewItem *item) const 881bool CardView::isSelected(CardViewItem *item) const
874{ 882{
875 return (item && item->isSelected()); 883 return (item && item->isSelected());
876} 884}
877 885
878CardViewItem *CardView::selectedItem() const 886CardViewItem *CardView::selectedItem() const
879{ 887{
880 // find the first selected item 888 // find the first selected item
881 QPtrListIterator<CardViewItem> iter(d->mItemList); 889 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
882 for (iter.toFirst(); iter.current(); ++iter) 890 for (iter.toFirst(); iter.current(); ++iter)
883 { 891 {
884 if ((*iter)->isSelected()) 892 if ((*iter)->isSelected())
885 return *iter; 893 return *iter;
886 } 894 }
887 895
888 return 0; 896 return 0;
889} 897}
890 898
891CardViewItem *CardView::firstItem() const 899CardViewItem *CardView::firstItem() const
892{ 900{
893 return d->mItemList.first(); 901 return d->mItemList.first();
@@ -946,83 +954,83 @@ void CardView::drawContents(QPainter *p, int clipx, int clipy,
946 QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale 954 QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale
947 int cX, cY; 955 int cX, cY;
948 contentsToViewport ( clipx, clipy, cX, cY ); 956 contentsToViewport ( clipx, clipy, cX, cY );
949 QRect clipRect(clipx, clipy, clipw, cliph); 957 QRect clipRect(clipx, clipy, clipw, cliph);
950 QRect cardRect; 958 QRect cardRect;
951 QRect sepRect; 959 QRect sepRect;
952 CardViewItem *item; 960 CardViewItem *item;
953 CardViewSeparator *sep; 961 CardViewSeparator *sep;
954 // make sure the viewport is a pure background 962 // make sure the viewport is a pure background
955 viewport()->erase( QRect ( cX, cY , clipw, cliph ) ); 963 viewport()->erase( QRect ( cX, cY , clipw, cliph ) );
956 964
957 // Now tell the cards to draw, if they are in the clip region 965 // Now tell the cards to draw, if they are in the clip region
958 QPtrListIterator<CardViewItem> iter(d->mItemList); 966 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
959 for (iter.toFirst(); iter.current(); ++iter) 967 for (iter.toFirst(); iter.current(); ++iter)
960 { 968 {
961 item = *iter; 969 item = *iter;
962 cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() ); 970 cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() );
963 971
964 if (clipRect.intersects(cardRect) || clipRect.contains(cardRect)) 972 if (clipRect.intersects(cardRect) || clipRect.contains(cardRect))
965 { 973 {
966 //kdDebug() << "\trepainting card at: " << cardRect.x() << ", " 974 //kdDebug() << "\trepainting card at: " << cardRect.x() << ", "
967 // << cardRect.y() << endl; 975 // << cardRect.y() << endl;
968 976
969 // Tell the card to paint 977 // Tell the card to paint
970 p->save(); 978 p->save();
971 p->translate(cardRect.x(), cardRect.y()); 979 p->translate(cardRect.x(), cardRect.y());
972 item->paintCard(p, cg); 980 item->paintCard(p, cg);
973 p->restore(); 981 p->restore();
974 } 982 }
975 } 983 }
976 984
977 // Followed by the separators if they are in the clip region 985 // Followed by the separators if they are in the clip region
978 QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); 986 Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
979 for (sepIter.toFirst(); sepIter.current(); ++sepIter) 987 for (sepIter.toFirst(); sepIter.current(); ++sepIter)
980 { 988 {
981 sep = *sepIter; 989 sep = *sepIter;
982 sepRect = sep->mRect; 990 sepRect = sep->mRect;
983 991
984 if (clipRect.intersects(sepRect) || clipRect.contains(sepRect)) 992 if (clipRect.intersects(sepRect) || clipRect.contains(sepRect))
985 { 993 {
986 p->save(); 994 p->save();
987 p->translate(sepRect.x(), sepRect.y()); 995 p->translate(sepRect.x(), sepRect.y());
988 sep->paintSeparator(p, cg); 996 sep->paintSeparator(p, cg);
989 p->restore(); 997 p->restore();
990 } 998 }
991 } 999 }
992} 1000}
993 1001
994void CardView::resizeEvent(QResizeEvent *e) 1002void CardView::resizeEvent(QResizeEvent *e)
995{ 1003{
996 QScrollView::resizeEvent(e); 1004 Q3ScrollView::resizeEvent(e);
997 1005
998 setLayoutDirty(true); 1006 setLayoutDirty(true);
999} 1007}
1000 1008
1001void CardView::calcLayout() 1009void CardView::calcLayout()
1002{ 1010{
1003 //kdDebug() << "CardView::calcLayout:" << endl; 1011 //kdDebug() << "CardView::calcLayout:" << endl;
1004 1012
1005 // Start in the upper left corner and layout all the 1013 // Start in the upper left corner and layout all the
1006 // cars using their height and width 1014 // cars using their height and width
1007 int maxWidth = 0; 1015 int maxWidth = 0;
1008 int maxHeight = 0; 1016 int maxHeight = 0;
1009 int xPos = 0; 1017 int xPos = 0;
1010 int yPos = 0; 1018 int yPos = 0;
1011 int cardSpacing = d->mItemSpacing; 1019 int cardSpacing = d->mItemSpacing;
1012 1020
1013 // delete the old separators 1021 // delete the old separators
1014 d->mSeparatorList.clear(); 1022 d->mSeparatorList.clear();
1015 1023
1016 QPtrListIterator<CardViewItem> iter(d->mItemList); 1024 Q3PtrListIterator<CardViewItem> iter(d->mItemList);
1017 CardViewItem *item = 0; 1025 CardViewItem *item = 0;
1018 CardViewSeparator *sep = 0; 1026 CardViewSeparator *sep = 0;
1019 xPos += cardSpacing; 1027 xPos += cardSpacing;
1020 1028
1021 for (iter.toFirst(); iter.current(); ++iter) 1029 for (iter.toFirst(); iter.current(); ++iter)
1022 { 1030 {
1023 item = *iter; 1031 item = *iter;
1024 1032
1025 yPos += cardSpacing; 1033 yPos += cardSpacing;
1026 1034
1027 if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height()) 1035 if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height())
1028 { 1036 {
@@ -1047,25 +1055,25 @@ void CardView::calcLayout()
1047 item->d->x = xPos; 1055 item->d->x = xPos;
1048 item->d->y = yPos; 1056 item->d->y = yPos;
1049 1057
1050 yPos += item->height(); 1058 yPos += item->height();
1051 maxWidth = QMAX(maxWidth, d->mItemWidth); 1059 maxWidth = QMAX(maxWidth, d->mItemWidth);
1052 } 1060 }
1053 1061
1054 xPos += maxWidth; 1062 xPos += maxWidth;
1055 resizeContents( xPos + cardSpacing, maxHeight ); 1063 resizeContents( xPos + cardSpacing, maxHeight );
1056 1064
1057 // Update the height of all the separators now that we know the 1065 // Update the height of all the separators now that we know the
1058 // max height of a column 1066 // max height of a column
1059 QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); 1067 Q3PtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList);
1060 for (sepIter.toFirst(); sepIter.current(); ++sepIter) 1068 for (sepIter.toFirst(); sepIter.current(); ++sepIter)
1061 { 1069 {
1062 (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin); 1070 (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin);
1063 } 1071 }
1064 1072
1065 d->mLayoutDirty = false; 1073 d->mLayoutDirty = false;
1066} 1074}
1067 1075
1068CardViewItem *CardView::itemAfter(CardViewItem *item) 1076CardViewItem *CardView::itemAfter(CardViewItem *item)
1069{ 1077{
1070 /*int pos = */d->mItemList.findRef(item); 1078 /*int pos = */d->mItemList.findRef(item);
1071 return d->mItemList.next();//at(pos+1); 1079 return d->mItemList.next();//at(pos+1);
@@ -1092,25 +1100,25 @@ uint CardView::itemSpacing()
1092 1100
1093void CardView::setItemSpacing( uint spacing ) 1101void CardView::setItemSpacing( uint spacing )
1094{ 1102{
1095 if ( spacing == d->mItemSpacing ) 1103 if ( spacing == d->mItemSpacing )
1096 return; 1104 return;
1097 1105
1098 d->mItemSpacing = spacing; 1106 d->mItemSpacing = spacing;
1099 setLayoutDirty( true ); 1107 setLayoutDirty( true );
1100} 1108}
1101 1109
1102void CardView::contentsMousePressEvent(QMouseEvent *e) 1110void CardView::contentsMousePressEvent(QMouseEvent *e)
1103{ 1111{
1104 QScrollView::contentsMousePressEvent(e); 1112 Q3ScrollView::contentsMousePressEvent(e);
1105 1113
1106 QPoint pos = e->pos(); 1114 QPoint pos = e->pos();
1107 d->mLastClickPos = pos; 1115 d->mLastClickPos = pos;
1108 1116
1109 CardViewItem *item = itemAt(pos); 1117 CardViewItem *item = itemAt(pos);
1110 1118
1111 if (item == 0) 1119 if (item == 0)
1112 { 1120 {
1113 d->mLastClickOnItem = false; 1121 d->mLastClickOnItem = false;
1114 if ( d->mOnSeparator) 1122 if ( d->mOnSeparator)
1115 { 1123 {
1116 d->mResizeAnchor = e->x()+contentsX(); 1124 d->mResizeAnchor = e->x()+contentsX();
@@ -1162,25 +1170,25 @@ void CardView::contentsMousePressEvent(QMouseEvent *e)
1162 emit selectionChanged(); 1170 emit selectionChanged();
1163 } 1171 }
1164 1172
1165 else if (d->mSelectionMode == CardView::Extended) 1173 else if (d->mSelectionMode == CardView::Extended)
1166 { 1174 {
1167 if ((e->button() & Qt::LeftButton) && 1175 if ((e->button() & Qt::LeftButton) &&
1168 (e->state() & Qt::ShiftButton)) 1176 (e->state() & Qt::ShiftButton))
1169 { 1177 {
1170 if ( item == other ) return; 1178 if ( item == other ) return;
1171 1179
1172 bool s = ! item->isSelected(); 1180 bool s = ! item->isSelected();
1173 1181
1174 if ( s && ! (e->state() & ControlButton) ) 1182 if ( s && ! (e->state() & Qt::ControlButton) )
1175 { 1183 {
1176 bool b = signalsBlocked(); 1184 bool b = signalsBlocked();
1177 blockSignals(true); 1185 blockSignals(true);
1178 selectAll(false); 1186 selectAll(false);
1179 blockSignals(b); 1187 blockSignals(b);
1180 } 1188 }
1181 1189
1182 int from, to, a, b; 1190 int from, to, a, b;
1183 a = d->mItemList.findRef( item ); 1191 a = d->mItemList.findRef( item );
1184 b = d->mItemList.findRef( other ); 1192 b = d->mItemList.findRef( other );
1185 from = a < b ? a : b; 1193 from = a < b ? a : b;
1186 to = a > b ? a : b; 1194 to = a > b ? a : b;
@@ -1210,25 +1218,25 @@ void CardView::contentsMousePressEvent(QMouseEvent *e)
1210 blockSignals(b); 1218 blockSignals(b);
1211 1219
1212 item->setSelected(true); 1220 item->setSelected(true);
1213 item->repaintCard(); 1221 item->repaintCard();
1214 emit selectionChanged(); 1222 emit selectionChanged();
1215 } 1223 }
1216 } 1224 }
1217 1225
1218} 1226}
1219 1227
1220void CardView::contentsMouseReleaseEvent(QMouseEvent *e) 1228void CardView::contentsMouseReleaseEvent(QMouseEvent *e)
1221{ 1229{
1222 QScrollView::contentsMouseReleaseEvent(e); 1230 Q3ScrollView::contentsMouseReleaseEvent(e);
1223 1231
1224 if ( d->mResizeAnchor ) 1232 if ( d->mResizeAnchor )
1225 { 1233 {
1226 // finish the resizing: 1234 // finish the resizing:
1227 unsetCursor(); 1235 unsetCursor();
1228 // hide rubber bands 1236 // hide rubber bands
1229 int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); 1237 int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span);
1230 drawRubberBands( 0 ); 1238 drawRubberBands( 0 );
1231 // we should move to reflect the new position if we are scrolled. 1239 // we should move to reflect the new position if we are scrolled.
1232 if ( contentsX() ) 1240 if ( contentsX() )
1233 { 1241 {
1234 int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); 1242 int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() );
@@ -1248,25 +1256,25 @@ void CardView::contentsMouseReleaseEvent(QMouseEvent *e)
1248 1256
1249 // Get the item at this position 1257 // Get the item at this position
1250 CardViewItem *item = itemAt(e->pos()); 1258 CardViewItem *item = itemAt(e->pos());
1251 1259
1252 if (item && KABPrefs::instance()->mHonorSingleClick) 1260 if (item && KABPrefs::instance()->mHonorSingleClick)
1253 { 1261 {
1254 emit executed(item); 1262 emit executed(item);
1255 } 1263 }
1256} 1264}
1257 1265
1258void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1266void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1259{ 1267{
1260 QScrollView::contentsMouseDoubleClickEvent(e); 1268 Q3ScrollView::contentsMouseDoubleClickEvent(e);
1261 1269
1262 CardViewItem *item = itemAt(e->pos()); 1270 CardViewItem *item = itemAt(e->pos());
1263 1271
1264 if (item) 1272 if (item)
1265 { 1273 {
1266 d->mCurrentItem = item; 1274 d->mCurrentItem = item;
1267 } 1275 }
1268 1276
1269 if (item && !KABPrefs::instance()->mHonorSingleClick) 1277 if (item && !KABPrefs::instance()->mHonorSingleClick)
1270 { 1278 {
1271 emit executed(item); 1279 emit executed(item);
1272 } else 1280 } else
@@ -1293,47 +1301,47 @@ void CardView::contentsMouseMoveEvent( QMouseEvent *e )
1293 1301
1294 d->mTimer->start( 500 ); 1302 d->mTimer->start( 500 );
1295 1303
1296 // see if we are over a separator 1304 // see if we are over a separator
1297 // only if we actually have them painted? 1305 // only if we actually have them painted?
1298 if ( d->mDrawSeparators ) 1306 if ( d->mDrawSeparators )
1299 { 1307 {
1300 int colcontentw = d->mItemWidth + (2*d->mItemSpacing); 1308 int colcontentw = d->mItemWidth + (2*d->mItemSpacing);
1301 int colw = colcontentw + d->mSepWidth; 1309 int colw = colcontentw + d->mSepWidth;
1302 int m = e->x()%colw; 1310 int m = e->x()%colw;
1303 if ( m >= colcontentw && m > 0 ) 1311 if ( m >= colcontentw && m > 0 )
1304 { 1312 {
1305 setCursor( SplitVCursor ); // Why does this fail sometimes? 1313 setCursor( Qt::SplitVCursor ); // Why does this fail sometimes?
1306 d->mOnSeparator = true; 1314 d->mOnSeparator = true;
1307 } 1315 }
1308 else 1316 else
1309 { 1317 {
1310 setCursor( ArrowCursor ); 1318 setCursor( Qt::ArrowCursor );
1311 d->mOnSeparator = false; 1319 d->mOnSeparator = false;
1312 } 1320 }
1313 } 1321 }
1314} 1322}
1315 1323
1316void CardView::enterEvent( QEvent * ) 1324void CardView::enterEvent( QEvent * )
1317{ 1325{
1318 d->mTimer->start( 500 ); 1326 d->mTimer->start( 500 );
1319} 1327}
1320 1328
1321void CardView::leaveEvent( QEvent * ) 1329void CardView::leaveEvent( QEvent * )
1322{ 1330{
1323 d->mTimer->stop(); 1331 d->mTimer->stop();
1324 if (d->mOnSeparator) 1332 if (d->mOnSeparator)
1325 { 1333 {
1326 d->mOnSeparator = false; 1334 d->mOnSeparator = false;
1327 setCursor( ArrowCursor ); 1335 setCursor( Qt::ArrowCursor );
1328 } 1336 }
1329} 1337}
1330 1338
1331void CardView::focusInEvent( QFocusEvent * ) 1339void CardView::focusInEvent( QFocusEvent * )
1332{ 1340{
1333 if (!d->mCurrentItem && d->mItemList.count() ) 1341 if (!d->mCurrentItem && d->mItemList.count() )
1334 { 1342 {
1335 setCurrentItem( d->mItemList.first() ); 1343 setCurrentItem( d->mItemList.first() );
1336 } 1344 }
1337 else if ( d->mCurrentItem ) 1345 else if ( d->mCurrentItem )
1338 { 1346 {
1339 d->mCurrentItem->repaintCard(); 1347 d->mCurrentItem->repaintCard();
@@ -1359,145 +1367,145 @@ void CardView::keyPressEvent( QKeyEvent *e )
1359 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1367 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1360 e->accept(); 1368 e->accept();
1361 return; 1369 return;
1362 } 1370 }
1363 if (! e->isAutoRepeat() ) 1371 if (! e->isAutoRepeat() )
1364 mFlagKeyPressed = true; 1372 mFlagKeyPressed = true;
1365 uint pos = d->mItemList.findRef( d->mCurrentItem ); 1373 uint pos = d->mItemList.findRef( d->mCurrentItem );
1366 CardViewItem *aItem = 0L; // item that gets the focus 1374 CardViewItem *aItem = 0L; // item that gets the focus
1367 CardViewItem *old = d->mCurrentItem; 1375 CardViewItem *old = d->mCurrentItem;
1368 1376
1369 switch ( e->key() ) 1377 switch ( e->key() )
1370 { 1378 {
1371 case Key_Up: 1379 case Qt::Key_Up:
1372 if ( pos > 0 ) 1380 if ( pos > 0 )
1373 { 1381 {
1374 aItem = d->mItemList.at( pos - 1 ); 1382 aItem = d->mItemList.at( pos - 1 );
1375 setCurrentItem( aItem ); 1383 setCurrentItem( aItem );
1376 } 1384 }
1377 break; 1385 break;
1378 case Key_Down: 1386 case Qt::Key_Down:
1379 if ( pos < d->mItemList.count() - 1 ) 1387 if ( pos < d->mItemList.count() - 1 )
1380 { 1388 {
1381 aItem = d->mItemList.at( pos + 1 ); 1389 aItem = d->mItemList.at( pos + 1 );
1382 setCurrentItem( aItem ); 1390 setCurrentItem( aItem );
1383 } 1391 }
1384 break; 1392 break;
1385 case Key_Left: 1393 case Qt::Key_Left:
1386 { 1394 {
1387 // look for an item in the previous/next column, starting from 1395 // look for an item in the previous/next column, starting from
1388 // the vertical middle of the current item. 1396 // the vertical middle of the current item.
1389 // FIXME use nice calculatd measures!!! 1397 // FIXME use nice calculatd measures!!!
1390 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); 1398 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y );
1391 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); 1399 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) );
1392 aItem = itemAt( aPoint ); 1400 aItem = itemAt( aPoint );
1393 // maybe we hit some space below an item 1401 // maybe we hit some space below an item
1394 while ( !aItem && aPoint.y() > 27 ) 1402 while ( !aItem && aPoint.y() > 27 )
1395 { 1403 {
1396 aPoint -= QPoint( 0, 16 ); 1404 aPoint -= QPoint( 0, 16 );
1397 aItem = itemAt( aPoint ); 1405 aItem = itemAt( aPoint );
1398 } 1406 }
1399 if ( aItem ) 1407 if ( aItem )
1400 setCurrentItem( aItem ); 1408 setCurrentItem( aItem );
1401 } 1409 }
1402 break; 1410 break;
1403 case Key_Right: 1411 case Qt::Key_Right:
1404 { 1412 {
1405 // FIXME use nice calculated measures!!! 1413 // FIXME use nice calculated measures!!!
1406 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); 1414 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y );
1407 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); 1415 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) );
1408 aItem = itemAt( aPoint ); 1416 aItem = itemAt( aPoint );
1409 while ( !aItem && aPoint.y() > 27 ) 1417 while ( !aItem && aPoint.y() > 27 )
1410 { 1418 {
1411 aPoint -= QPoint( 0, 16 ); 1419 aPoint -= QPoint( 0, 16 );
1412 aItem = itemAt( aPoint ); 1420 aItem = itemAt( aPoint );
1413 } 1421 }
1414 if ( aItem ) 1422 if ( aItem )
1415 setCurrentItem( aItem ); 1423 setCurrentItem( aItem );
1416 } 1424 }
1417 break; 1425 break;
1418 case Key_Home: 1426 case Qt::Key_Home:
1419 aItem = d->mItemList.first(); 1427 aItem = d->mItemList.first();
1420 setCurrentItem( aItem ); 1428 setCurrentItem( aItem );
1421 break; 1429 break;
1422 case Key_End: 1430 case Qt::Key_End:
1423 aItem = d->mItemList.last(); 1431 aItem = d->mItemList.last();
1424 setCurrentItem( aItem ); 1432 setCurrentItem( aItem );
1425 break; 1433 break;
1426 case Key_Prior: // PageUp 1434 case Qt::Key_Prior: // PageUp
1427 { 1435 {
1428 // QListView: "Make the item above the top visible and current" 1436 // QListView: "Make the item above the top visible and current"
1429 // TODO if contentsY(), pick the top item of the leftmost visible column 1437 // TODO if contentsY(), pick the top item of the leftmost visible column
1430 if ( contentsX() <= 0 ) 1438 if ( contentsX() <= 0 )
1431 return; 1439 return;
1432 int cw = columnWidth(); 1440 int cw = columnWidth();
1433 int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing; 1441 int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing;
1434 aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) ); 1442 aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) );
1435 if ( aItem ) 1443 if ( aItem )
1436 setCurrentItem( aItem ); 1444 setCurrentItem( aItem );
1437 } 1445 }
1438 break; 1446 break;
1439 case Key_Next: // PageDown 1447 case Qt::Key_Next: // PageDown
1440 { 1448 {
1441 // QListView: "Make the item below the bottom visible and current" 1449 // QListView: "Make the item below the bottom visible and current"
1442 // find the first not fully visible column. 1450 // find the first not fully visible column.
1443 // TODO: consider if a partly visible (or even hidden) item at the 1451 // TODO: consider if a partly visible (or even hidden) item at the
1444 // bottom of the rightmost column exists 1452 // bottom of the rightmost column exists
1445 int cw = columnWidth(); 1453 int cw = columnWidth();
1446 int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1; 1454 int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1;
1447 // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden 1455 // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden
1448 if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) ) 1456 if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) )
1449 theCol += cw; 1457 theCol += cw;
1450 1458
1451 // make sure this is not too far right 1459 // make sure this is not too far right
1452 while ( theCol > contentsWidth() ) 1460 while ( theCol > contentsWidth() )
1453 theCol -= columnWidth(); 1461 theCol -= columnWidth();
1454 1462
1455 aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) ); 1463 aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) );
1456 1464
1457 if ( aItem ) 1465 if ( aItem )
1458 setCurrentItem( aItem ); 1466 setCurrentItem( aItem );
1459 } 1467 }
1460 break; 1468 break;
1461 case Key_Space: 1469 case Qt::Key_Space:
1462 setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() ); 1470 setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() );
1463 emit selectionChanged(); 1471 emit selectionChanged();
1464 break; 1472 break;
1465 case Key_Return: 1473 case Qt::Key_Return:
1466 case Key_Enter: 1474 case Qt::Key_Enter:
1467 { 1475 {
1468 emit returnPressed( d->mCurrentItem ); 1476 emit returnPressed( d->mCurrentItem );
1469 emit executed( d->mCurrentItem ); 1477 emit executed( d->mCurrentItem );
1470 } 1478 }
1471 break; 1479 break;
1472 default: 1480 default:
1473 if ( (e->state() & ControlButton) && e->key() == Key_A ) 1481 if ( (e->state() & Qt::ControlButton) && e->key() == Qt::Key_A )
1474 { 1482 {
1475 // select all 1483 // select all
1476 selectAll( true ); 1484 selectAll( true );
1477 break; 1485 break;
1478 } 1486 }
1479 // if we have a string, do autosearch 1487 // if we have a string, do autosearch
1480 else if ( ! e->text().isEmpty() && e->text()[0].isPrint() ) 1488 else if ( ! e->text().isEmpty() && e->text()[0].isPrint() )
1481 { 1489 {
1482 1490
1483 } 1491 }
1484 break; 1492 break;
1485 } 1493 }
1486 // handle selection 1494 // handle selection
1487 if ( aItem ) 1495 if ( aItem )
1488 { 1496 {
1489 if ( d->mSelectionMode == CardView::Extended ) 1497 if ( d->mSelectionMode == CardView::Extended )
1490 { 1498 {
1491 if ( (e->state() & ShiftButton) ) 1499 if ( (e->state() & Qt::ShiftButton) )
1492 { 1500 {
1493 // shift button: toggle range 1501 // shift button: toggle range
1494 // if control button is pressed, leave all items 1502 // if control button is pressed, leave all items
1495 // and toggle selection current->old current 1503 // and toggle selection current->old current
1496 // otherwise, ?????? 1504 // otherwise, ??????
1497 bool s = ! aItem->isSelected(); 1505 bool s = ! aItem->isSelected();
1498 int from, to, a, b; 1506 int from, to, a, b;
1499 a = d->mItemList.findRef( aItem ); 1507 a = d->mItemList.findRef( aItem );
1500 b = d->mItemList.findRef( old ); 1508 b = d->mItemList.findRef( old );
1501 from = a < b ? a : b; 1509 from = a < b ? a : b;
1502 to = a > b ? a : b; 1510 to = a > b ? a : b;
1503 1511
@@ -1510,25 +1518,25 @@ void CardView::keyPressEvent( QKeyEvent *e )
1510 } 1518 }
1511 1519
1512 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; 1520 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl;
1513 CardViewItem *item; 1521 CardViewItem *item;
1514 for ( ; from <= to; from++ ) 1522 for ( ; from <= to; from++ )
1515 { 1523 {
1516 item = d->mItemList.at( from ); 1524 item = d->mItemList.at( from );
1517 item->setSelected( s ); 1525 item->setSelected( s );
1518 repaintItem( item ); 1526 repaintItem( item );
1519 } 1527 }
1520 emit selectionChanged(); 1528 emit selectionChanged();
1521 } 1529 }
1522 else if ( (e->state() & ControlButton) ) 1530 else if ( (e->state() & Qt::ControlButton) )
1523 { 1531 {
1524 // control button: do nothing 1532 // control button: do nothing
1525 } 1533 }
1526 else 1534 else
1527 { 1535 {
1528 // no button: move selection to this item 1536 // no button: move selection to this item
1529 bool b = signalsBlocked(); 1537 bool b = signalsBlocked();
1530 blockSignals(true); 1538 blockSignals(true);
1531 selectAll(false); 1539 selectAll(false);
1532 blockSignals(b); 1540 blockSignals(b);
1533 1541
1534 setSelected( aItem, true ); 1542 setSelected( aItem, true );
@@ -1629,27 +1637,27 @@ void CardView::tryShowFullText()
1629 } 1637 }
1630} 1638}
1631 1639
1632void CardView::drawRubberBands( int pos ) 1640void CardView::drawRubberBands( int pos )
1633{ 1641{
1634 if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return; 1642 if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return;
1635 1643
1636 int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span; 1644 int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span;
1637 int x = d->firstX + tmpcw - d->mSepWidth - contentsX(); 1645 int x = d->firstX + tmpcw - d->mSepWidth - contentsX();
1638 int h = visibleHeight(); 1646 int h = visibleHeight();
1639 1647
1640 QPainter p( viewport() ); 1648 QPainter p( viewport() );
1641 p.setRasterOp( XorROP ); 1649 p.setCompositionMode( QPainter::CompositionMode_Xor );
1642 p.setPen( gray ); 1650 p.setPen( Qt::gray );
1643 p.setBrush( gray ); 1651 p.setBrush( Qt::gray );
1644 uint n = d->first; 1652 uint n = d->first;
1645 // erase 1653 // erase
1646 if ( d->mRubberBandAnchor ) 1654 if ( d->mRubberBandAnchor )
1647 do { 1655 do {
1648 p.drawRect( x, 0, 2, h ); 1656 p.drawRect( x, 0, 2, h );
1649 x += tmpcw; 1657 x += tmpcw;
1650 n++; 1658 n++;
1651 } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); 1659 } while ( x < visibleWidth() && n < d->mSeparatorList.count() );
1652 // paint new 1660 // paint new
1653 if ( ! pos ) return; 1661 if ( ! pos ) return;
1654 tmpcw = (pos - d->firstX)/d->span; 1662 tmpcw = (pos - d->firstX)/d->span;
1655 n = d->first; 1663 n = d->first;
@@ -1690,25 +1698,25 @@ void CardView::setHeaderFont( const QFont &fnt )
1690 d->mHeaderFont = fnt; 1698 d->mHeaderFont = fnt;
1691 delete d->mBFm; 1699 delete d->mBFm;
1692 d->mBFm = new QFontMetrics( fnt ); 1700 d->mBFm = new QFontMetrics( fnt );
1693} 1701}
1694 1702
1695QFont CardView::headerFont() const 1703QFont CardView::headerFont() const
1696{ 1704{
1697 return d->mHeaderFont; 1705 return d->mHeaderFont;
1698} 1706}
1699 1707
1700void CardView::setFont( const QFont &fnt ) 1708void CardView::setFont( const QFont &fnt )
1701{ 1709{
1702 QScrollView::setFont( fnt ); 1710 Q3ScrollView::setFont( fnt );
1703 delete d->mFm; 1711 delete d->mFm;
1704 d->mFm = new QFontMetrics( fnt ); 1712 d->mFm = new QFontMetrics( fnt );
1705} 1713}
1706 1714
1707int CardView::separatorWidth() 1715int CardView::separatorWidth()
1708{ 1716{
1709 return d->mSepWidth; 1717 return d->mSepWidth;
1710} 1718}
1711 1719
1712void CardView::setSeparatorWidth( int width ) 1720void CardView::setSeparatorWidth( int width )
1713{ 1721{
1714 d->mSepWidth = width; 1722 d->mSepWidth = width;
@@ -1727,24 +1735,24 @@ void CardView::setMaxFieldLines( int howmany )
1727} 1735}
1728 1736
1729void CardView::keyReleaseEvent ( QKeyEvent * e ) 1737void CardView::keyReleaseEvent ( QKeyEvent * e )
1730{ 1738{
1731 if ( mFlagBlockKeyPressed ) 1739 if ( mFlagBlockKeyPressed )
1732 return; 1740 return;
1733 if ( !e->isAutoRepeat() ) { 1741 if ( !e->isAutoRepeat() ) {
1734 mFlagBlockKeyPressed = true; 1742 mFlagBlockKeyPressed = true;
1735 qApp->processEvents(); 1743 qApp->processEvents();
1736 mFlagBlockKeyPressed = false; 1744 mFlagBlockKeyPressed = false;
1737 mFlagKeyPressed = false; 1745 mFlagKeyPressed = false;
1738 } 1746 }
1739 QScrollView::keyReleaseEvent ( e ); 1747 Q3ScrollView::keyReleaseEvent ( e );
1740} 1748}
1741 1749
1742 1750
1743 1751
1744 1752
1745 1753
1746//END Cardview 1754//END Cardview
1747 1755
1748#ifndef KAB_EMBEDDED 1756#ifndef KAB_EMBEDDED_
1749#include "cardview.moc" 1757#include "moc_cardview.cpp"
1750#endif //KAB_EMBEDDED 1758#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h
index 2ea3771..9c245ea 100644
--- a/kaddressbook/views/cardview.h
+++ b/kaddressbook/views/cardview.h
@@ -1,21 +1,29 @@
1#ifndef CARDVIEW_H 1#ifndef CARDVIEW_H
2#define CARDVIEW_H 2#define CARDVIEW_H
3 3
4#include <qscrollview.h> 4#include <q3scrollview.h>
5#include <qptrlist.h> 5#include <q3ptrlist.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qrect.h> 7#include <qrect.h>
8#include <qpair.h> 8#include <qpair.h>
9#include <qpoint.h> 9#include <qpoint.h>
10//Added by qt3to4:
11#include <QWheelEvent>
12#include <QResizeEvent>
13#include <QFocusEvent>
14#include <QLabel>
15#include <QMouseEvent>
16#include <QKeyEvent>
17#include <QEvent>
10 18
11class QLabel; 19class QLabel;
12class QPainter; 20class QPainter;
13class QResizeEvent; 21class QResizeEvent;
14class QMouseEvent; 22class QMouseEvent;
15class CardView; 23class CardView;
16class CardViewPrivate; 24class CardViewPrivate;
17class CardViewItemPrivate; 25class CardViewItemPrivate;
18class CardViewTip; 26class CardViewTip;
19 27
20/** Represents a single card (item) in the card view. A card has a caption 28/** Represents a single card (item) in the card view. A card has a caption
21* and a list of fields. A Field is a label<->value pair. The labels in a 29* and a list of fields. A Field is a label<->value pair. The labels in a
@@ -139,25 +147,25 @@ class CardViewItem
139 147
140/** The CardView is a method of displaying data in cards. This idea is 148/** The CardView is a method of displaying data in cards. This idea is
141* similar to the idea of a rolodex or business cards. Each card has a 149* similar to the idea of a rolodex or business cards. Each card has a
142* caption and a list of fields, which are label<->value pairs. The CardView 150* caption and a list of fields, which are label<->value pairs. The CardView
143* displays multiple cards in a grid. The Cards are sorted based on their 151* displays multiple cards in a grid. The Cards are sorted based on their
144* caption. 152* caption.
145* 153*
146* The CardView class is designed to mirror the API of the QListView or 154* The CardView class is designed to mirror the API of the QListView or
147* QIconView. The CardView is also completely independant of KAddressBook and 155* QIconView. The CardView is also completely independant of KAddressBook and
148* can be used elsewhere. With the exception of a few simple config checks, 156* can be used elsewhere. With the exception of a few simple config checks,
149* the CardView is also 100% independant of KDE. 157* the CardView is also 100% independant of KDE.
150*/ 158*/
151class CardView : public QScrollView 159class CardView : public Q3ScrollView
152{ 160{
153 friend class CardViewItem; 161 friend class CardViewItem;
154 162
155 Q_OBJECT 163 Q_OBJECT
156 164
157 public: 165 public:
158 /** Constructor. 166 /** Constructor.
159 */ 167 */
160 CardView(QWidget *parent, const char *name); 168 CardView(QWidget *parent, const char *name);
161 virtual ~CardView(); 169 virtual ~CardView();
162 170
163 /** Inserts the item into the card view. This method does not have 171 /** Inserts the item into the card view. This method does not have
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp
index 2bddca6..46a59a1 100644
--- a/kaddressbook/views/colorlistbox.cpp
+++ b/kaddressbook/views/colorlistbox.cpp
@@ -10,53 +10,58 @@
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#include <qpainter.h> 21#include <qpainter.h>
22//Added by qt3to4:
23#include <QDragEnterEvent>
24#include <QDropEvent>
25#include <QDragMoveEvent>
26#include <QDragLeaveEvent>
22 27
23#include <kcolordialog.h> 28#include <kcolordialog.h>
24 29
25#ifndef KAB_EMBEDDED 30#ifndef KAB_EMBEDDED
26#include <kcolordrag.h> 31#include <kcolordrag.h>
27#endif //KAB_EMBEDDED 32#endif //KAB_EMBEDDED
28 33
29#include "colorlistbox.h" 34#include "colorlistbox.h"
30#ifdef DESKTOP_VERSION 35#ifdef DESKTOP_VERSION
31#include <qcolordialog.h> 36#include <qcolordialog.h>
32#endif 37#endif
33 38
34ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) 39ColorListBox::ColorListBox( QWidget *parent, const char *name, Qt::WFlags f )
35 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) 40 :KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
36{ 41{
37 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); 42 connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
38 connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); 43 connect( this, SIGNAL(clicked(Q3ListBoxItem *)), this, SLOT(slotNewColor(Q3ListBoxItem *)) );
39 setAcceptDrops( true); 44 setAcceptDrops( true);
40} 45}
41 46
42 47
43void ColorListBox::setEnabled( bool state ) 48void ColorListBox::setEnabled( bool state )
44{ 49{
45 if( state == isEnabled() ) 50 if( state == isEnabled() )
46 { 51 {
47 return; 52 return;
48 } 53 }
49 54
50 QListBox::setEnabled( state ); 55 Q3ListBox::setEnabled( state );
51 for( uint i=0; i<count(); i++ ) 56 for( uint i=0; i<count(); i++ )
52 { 57 {
53 updateItem( i ); 58 updateItem( i );
54 } 59 }
55} 60}
56 61
57 62
58void ColorListBox::setColor( uint index, const QColor &color ) 63void ColorListBox::setColor( uint index, const QColor &color )
59{ 64{
60 if( index < count() ) 65 if( index < count() )
61 { 66 {
62 ColorListItem *colorItem = (ColorListItem*)item(index); 67 ColorListItem *colorItem = (ColorListItem*)item(index);
@@ -66,28 +71,28 @@ void ColorListBox::setColor( uint index, const QColor &color )
66} 71}
67 72
68 73
69QColor ColorListBox::color( uint index ) const 74QColor ColorListBox::color( uint index ) const
70{ 75{
71 if( index < count() ) 76 if( index < count() )
72 { 77 {
73 ColorListItem *colorItem = (ColorListItem*)item(index); 78 ColorListItem *colorItem = (ColorListItem*)item(index);
74 return( colorItem->color() ); 79 return( colorItem->color() );
75 } 80 }
76 else 81 else
77 { 82 {
78 return( black ); 83 return( Qt::black );
79 } 84 }
80} 85}
81void ColorListBox::slotNewColor(QListBoxItem * i) 86void ColorListBox::slotNewColor(Q3ListBoxItem * i)
82{ 87{
83 if ( i ) 88 if ( i )
84 newColor( index( i ) ); 89 newColor( index( i ) );
85} 90}
86 91
87void ColorListBox::newColor( int index ) 92void ColorListBox::newColor( int index )
88{ 93{
89 if( isEnabled() == false ) 94 if( isEnabled() == false )
90 { 95 {
91 return; 96 return;
92 } 97 }
93 98
@@ -189,25 +194,25 @@ void ColorListBox::dropEvent( QDropEvent *e )
189 mCurrentOnDragEnter = -1; 194 mCurrentOnDragEnter = -1;
190 } 195 }
191 196
192#else //KAB_EMBEDDED 197#else //KAB_EMBEDDED
193qDebug("ColorListBox::dropEvent drag&drop currently not supported"); 198qDebug("ColorListBox::dropEvent drag&drop currently not supported");
194#endif //KAB_EMBEDDED 199#endif //KAB_EMBEDDED
195 200
196} 201}
197 202
198 203
199 204
200ColorListItem::ColorListItem( const QString &text, const QColor &color ) 205ColorListItem::ColorListItem( const QString &text, const QColor &color )
201 : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) 206 : Q3ListBoxItem(), mColor( color ), mBoxWidth( 30 )
202{ 207{
203 setText( text ); 208 setText( text );
204} 209}
205 210
206 211
207const QColor &ColorListItem::color( void ) 212const QColor &ColorListItem::color( void )
208{ 213{
209 return( mColor ); 214 return( mColor );
210} 215}
211 216
212 217
213void ColorListItem::setColor( const QColor &color ) 218void ColorListItem::setColor( const QColor &color )
@@ -220,26 +225,26 @@ void ColorListItem::paint( QPainter *p )
220{ 225{
221 QFontMetrics fm = p->fontMetrics(); 226 QFontMetrics fm = p->fontMetrics();
222 int h = fm.height(); 227 int h = fm.height();
223 228
224 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); 229 p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() );
225 230
226 p->setPen( Qt::black ); 231 p->setPen( Qt::black );
227 p->drawRect( 3, 1, mBoxWidth, h-1 ); 232 p->drawRect( 3, 1, mBoxWidth, h-1 );
228 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); 233 p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor );
229} 234}
230 235
231 236
232int ColorListItem::height(const QListBox *lb ) const 237int ColorListItem::height(const Q3ListBox *lb ) const
233{ 238{
234 return( lb->fontMetrics().lineSpacing()+1 ); 239 return( lb->fontMetrics().lineSpacing()+1 );
235} 240}
236 241
237 242
238int ColorListItem::width(const QListBox *lb ) const 243int ColorListItem::width(const Q3ListBox *lb ) const
239{ 244{
240 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); 245 return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 );
241} 246}
242 247
243#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED_
244#include "colorlistbox.moc" 249#include "moc_colorlistbox.cpp"
245#endif //KAB_EMBEDDED 250#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h
index bb91484..31a8085 100644
--- a/kaddressbook/views/colorlistbox.h
+++ b/kaddressbook/views/colorlistbox.h
@@ -13,65 +13,70 @@
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#ifndef _COLOR_LISTBOX_H_ 21#ifndef _COLOR_LISTBOX_H_
22#define _COLOR_LISTBOX_H_ 22#define _COLOR_LISTBOX_H_
23 23
24#include <klistbox.h> 24#include <klistbox.h>
25//Added by qt3to4:
26#include <QDragMoveEvent>
27#include <QDragLeaveEvent>
28#include <QDropEvent>
29#include <QDragEnterEvent>
25 30
26class QDragEnterEvent; 31class QDragEnterEvent;
27class QDragLeaveEvent; 32class QDragLeaveEvent;
28class QDragMoveEvent; 33class QDragMoveEvent;
29class QDropEvent; 34class QDropEvent;
30 35
31class ColorListBox : public KListBox 36class ColorListBox : public KListBox
32{ 37{
33 Q_OBJECT 38 Q_OBJECT
34 39
35 public: 40 public:
36 ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); 41 ColorListBox( QWidget *parent=0, const char * name=0, Qt::WFlags f=0 );
37 void setColor( uint index, const QColor &color ); 42 void setColor( uint index, const QColor &color );
38 QColor color( uint index ) const; 43 QColor color( uint index ) const;
39 44
40 public slots: 45 public slots:
41 virtual void setEnabled( bool state ); 46 virtual void setEnabled( bool state );
42 47
43 protected: 48 protected:
44 void dragEnterEvent( QDragEnterEvent *e ); 49 void dragEnterEvent( QDragEnterEvent *e );
45 void dragLeaveEvent( QDragLeaveEvent *e ); 50 void dragLeaveEvent( QDragLeaveEvent *e );
46 void dragMoveEvent( QDragMoveEvent *e ); 51 void dragMoveEvent( QDragMoveEvent *e );
47 void dropEvent( QDropEvent *e ); 52 void dropEvent( QDropEvent *e );
48 53
49 private slots: 54 private slots:
50 void newColor( int index ); 55 void newColor( int index );
51 void slotNewColor(QListBoxItem * i); 56 void slotNewColor(Q3ListBoxItem * i);
52 57
53 private: 58 private:
54 int mCurrentOnDragEnter; 59 int mCurrentOnDragEnter;
55 60
56}; 61};
57 62
58 63
59class ColorListItem : public QListBoxItem 64class ColorListItem : public Q3ListBoxItem
60{ 65{
61 public: 66 public:
62 ColorListItem( const QString &text, const QColor &color=Qt::black ); 67 ColorListItem( const QString &text, const QColor &color=Qt::black );
63 const QColor &color( void ); 68 const QColor &color( void );
64 void setColor( const QColor &color ); 69 void setColor( const QColor &color );
65 70
66 protected: 71 protected:
67 virtual void paint( QPainter * ); 72 virtual void paint( QPainter * );
68 virtual int height( const QListBox * ) const; 73 virtual int height( const Q3ListBox * ) const;
69 virtual int width( const QListBox * ) const; 74 virtual int width( const Q3ListBox * ) const;
70 75
71 private: 76 private:
72 QColor mColor; 77 QColor mColor;
73 int mBoxWidth; 78 int mBoxWidth;
74}; 79};
75 80
76#endif 81#endif
77 82
diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp
index e0fbd21..b6327fe 100644
--- a/kaddressbook/views/configurecardviewdialog.cpp
+++ b/kaddressbook/views/configurecardviewdialog.cpp
@@ -16,29 +16,32 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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#include <qstring.h> 24#include <qstring.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qvbox.h> 28#include <q3vbox.h>
29#include <qgroupbox.h> 29#include <q3groupbox.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qwhatsthis.h> 32#include <q3whatsthis.h>
33//Added by qt3to4:
34#include <Q3GridLayout>
35#include <Q3Frame>
33 36
34#include <kdebug.h> 37#include <kdebug.h>
35#include <kglobal.h> 38#include <kglobal.h>
36#include <kglobalsettings.h> 39#include <kglobalsettings.h>
37#include <klocale.h> 40#include <klocale.h>
38#include <kiconloader.h> 41#include <kiconloader.h>
39#include <kconfig.h> 42#include <kconfig.h>
40#include <kfontdialog.h> 43#include <kfontdialog.h>
41 44
42#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
43#include <kpushbutton.h> 46#include <kpushbutton.h>
44#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
@@ -80,25 +83,25 @@ void ConfigureCardViewWidget::restoreSettings( KConfig *config )
80} 83}
81 84
82void ConfigureCardViewWidget::saveSettings( KConfig *config ) 85void ConfigureCardViewWidget::saveSettings( KConfig *config )
83{ 86{
84 ViewConfigureWidget::saveSettings( config ); 87 ViewConfigureWidget::saveSettings( config );
85 88
86 mAdvancedPage->saveSettings( config ); 89 mAdvancedPage->saveSettings( config );
87} 90}
88 91
89//////////////////////// 92////////////////////////
90// CardViewLookNFeelPage 93// CardViewLookNFeelPage
91CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) 94CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name )
92 : QVBox( parent, name ) 95 : Q3VBox( parent, name )
93{ 96{
94 initGUI(); 97 initGUI();
95} 98}
96 99
97CardViewLookNFeelPage::~CardViewLookNFeelPage() 100CardViewLookNFeelPage::~CardViewLookNFeelPage()
98{ 101{
99} 102}
100 103
101void CardViewLookNFeelPage::restoreSettings( KConfig *config ) 104void CardViewLookNFeelPage::restoreSettings( KConfig *config )
102{ 105{
103 // colors 106 // colors
104 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 107 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
@@ -225,145 +228,145 @@ void CardViewLookNFeelPage::enableColors()
225 if ( cbEnableCustomColors->isChecked() ) 228 if ( cbEnableCustomColors->isChecked() )
226 lbColors->setFocus(); 229 lbColors->setFocus();
227} 230}
228 231
229void CardViewLookNFeelPage::initGUI() 232void CardViewLookNFeelPage::initGUI()
230{ 233{
231 int spacing = KDialog::spacingHint(); 234 int spacing = KDialog::spacingHint();
232 int margin = KDialog::marginHint(); 235 int margin = KDialog::marginHint();
233 236
234 QTabWidget *tabs = new QTabWidget( this ); 237 QTabWidget *tabs = new QTabWidget( this );
235 238
236 // Layout 239 // Layout
237 QVBox *loTab = new QVBox( this, "layouttab" ); 240 Q3VBox *loTab = new Q3VBox( this, "layouttab" );
238 241
239 loTab->setSpacing( spacing ); 242 loTab->setSpacing( spacing );
240 loTab->setMargin( margin ); 243 loTab->setMargin( margin );
241 244
242 QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); 245 Q3GroupBox *gbGeneral = new Q3GroupBox( 1, Qt::Horizontal, i18n("General"), loTab );
243 246
244 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); 247 cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral );
245 248
246 QHBox *hbSW = new QHBox( gbGeneral ); 249 Q3HBox *hbSW = new Q3HBox( gbGeneral );
247 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); 250 QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW );
248 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); 251 sbSepWidth = new QSpinBox( 1, 50, 1, hbSW );
249 lSW->setBuddy( sbSepWidth); 252 lSW->setBuddy( sbSepWidth);
250 253
251 QHBox *hbPadding = new QHBox( gbGeneral ); 254 Q3HBox *hbPadding = new Q3HBox( gbGeneral );
252 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); 255 QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding );
253 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); 256 sbSpacing = new QSpinBox( 0, 100, 1, hbPadding );
254 lSpacing->setBuddy( sbSpacing ); 257 lSpacing->setBuddy( sbSpacing );
255 258
256 QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); 259 Q3GroupBox *gbCards = new Q3GroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab );
257 260
258 QHBox *hbMargin = new QHBox( gbCards ); 261 Q3HBox *hbMargin = new Q3HBox( gbCards );
259 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); 262 QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin );
260 sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); 263 sbMargin = new QSpinBox( 0, 100, 1, hbMargin );
261 lMargin->setBuddy( sbMargin ); 264 lMargin->setBuddy( sbMargin );
262 265
263 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); 266 cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards );
264 267
265 loTab->setStretchFactor( new QWidget( loTab ), 1 ); 268 loTab->setStretchFactor( new QWidget( loTab ), 1 );
266 269
267 QWhatsThis::add( sbMargin, i18n( 270 Q3WhatsThis::add( sbMargin, i18n(
268 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " 271 "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, "
269 "incrementing the item margin will add space between the focus rectangle and the item data." 272 "incrementing the item margin will add space between the focus rectangle and the item data."
270 ) ); 273 ) );
271 QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); 274 /* TODO:hacker: Q3WhatsThis::add( lMargin, Q3WhatsThis::textFor( sbMargin ) ); */
272 QWhatsThis::add( sbSpacing, i18n( 275 Q3WhatsThis::add( sbSpacing, i18n(
273 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " 276 "The Item Spacing decides the distance (in pixels) between the items and anything else: the view "
274 "borders, other items or column separators." 277 "borders, other items or column separators."
275 ) ); 278 ) );
276 QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); 279 /* TODO:hacker: Q3WhatsThis::add( lSpacing, Q3WhatsThis::textFor( sbSpacing ) ); */
277 QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); 280 Q3WhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") );
278 QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); 281 /* TODO:hacker: Q3WhatsThis::add( lSW, Q3WhatsThis::textFor( sbSepWidth ) ); */
279 282
280 tabs->addTab( loTab, i18n("&Layout") ); 283 tabs->addTab( loTab, i18n("&Layout") );
281 284
282 // Colors 285 // Colors
283 QVBox *colorTab = new QVBox( this, "colortab" ); 286 Q3VBox *colorTab = new Q3VBox( this, "colortab" );
284 colorTab->setSpacing( spacing ); 287 colorTab->setSpacing( spacing );
285 colorTab->setMargin( spacing ); 288 colorTab->setMargin( spacing );
286 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 289 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
287 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 290 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
288 lbColors = new ColorListBox( colorTab ); 291 lbColors = new ColorListBox( colorTab );
289 tabs->addTab( colorTab, i18n("&Colors") ); 292 tabs->addTab( colorTab, i18n("&Colors") );
290 293
291 QWhatsThis::add( cbEnableCustomColors, i18n( 294 Q3WhatsThis::add( cbEnableCustomColors, i18n(
292 "If custom colors are enabled, you may choose the colors for the view below. " 295 "If custom colors are enabled, you may choose the colors for the view below. "
293 "Otherwise colors from your current KDE color scheme are used." 296 "Otherwise colors from your current KDE color scheme are used."
294 ) ); 297 ) );
295 QWhatsThis::add( lbColors, i18n( 298 Q3WhatsThis::add( lbColors, i18n(
296 "Double click or press RETURN on a item to select a color for the related strings in the view." 299 "Double click or press RETURN on a item to select a color for the related strings in the view."
297 ) ); 300 ) );
298 301
299 // Fonts 302 // Fonts
300 QVBox *fntTab = new QVBox( this, "fonttab" ); 303 Q3VBox *fntTab = new Q3VBox( this, "fonttab" );
301 304
302 fntTab->setSpacing( spacing ); 305 fntTab->setSpacing( spacing );
303 fntTab->setMargin( spacing ); 306 fntTab->setMargin( spacing );
304 307
305 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 308 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
306 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 309 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
307 310
308 vbFonts = new QWidget( fntTab ); 311 vbFonts = new QWidget( fntTab );
309 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 312 Q3GridLayout *gFnts = new Q3GridLayout( vbFonts, 2, 3 );
310 gFnts->setSpacing( spacing ); 313 gFnts->setSpacing( spacing );
311 gFnts->setAutoAdd( true ); 314 gFnts->setAutoAdd( true );
312 gFnts->setColStretch( 1, 1 ); 315 gFnts->setColStretch( 1, 1 );
313 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 316 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
314 lTextFont = new QLabel( vbFonts ); 317 lTextFont = new QLabel( vbFonts );
315 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 318 lTextFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
316#ifndef KAB_EMBEDDED 319#ifndef KAB_EMBEDDED
317 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 320 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
318#else //KAB_EMBEDDED 321#else //KAB_EMBEDDED
319 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 322 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
320#endif //KAB_EMBEDDED 323#endif //KAB_EMBEDDED
321 324
322 lTFnt->setBuddy( btnFont ); 325 lTFnt->setBuddy( btnFont );
323 326
324 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 327 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
325 328
326 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 329 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
327 lHeaderFont = new QLabel( vbFonts ); 330 lHeaderFont = new QLabel( vbFonts );
328 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 331 lHeaderFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
329#ifndef KAB_EMBEDDED 332#ifndef KAB_EMBEDDED
330 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 333 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
331#else //KAB_EMBEDDED 334#else //KAB_EMBEDDED
332 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 335 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
333#endif //KAB_EMBEDDED 336#endif //KAB_EMBEDDED
334 lHFnt->setBuddy( btnHeaderFont ); 337 lHFnt->setBuddy( btnHeaderFont );
335 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 338 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
336 339
337 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 340 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
338 341
339 QWhatsThis::add( cbEnableCustomFonts, i18n( 342 Q3WhatsThis::add( cbEnableCustomFonts, i18n(
340 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 343 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
341 "Otherwise the default KDE font will be used, in bold style for the header and " 344 "Otherwise the default KDE font will be used, in bold style for the header and "
342 "normal style for the data." 345 "normal style for the data."
343 ) ); 346 ) );
344 347
345 tabs->addTab( fntTab, i18n("&Fonts") ); 348 tabs->addTab( fntTab, i18n("&Fonts") );
346 349
347 // Behaviour 350 // Behaviour
348 QVBox *behaviourTab = new QVBox( this ); 351 Q3VBox *behaviourTab = new Q3VBox( this );
349 behaviourTab->setMargin( margin ); 352 behaviourTab->setMargin( margin );
350 behaviourTab->setSpacing( spacing ); 353 behaviourTab->setSpacing( spacing );
351 354
352 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); 355 cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab );
353 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); 356 cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab );
354 357
355 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); 358 behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 );
356 359
357 tabs->addTab( behaviourTab, i18n("Be&havior") ); 360 tabs->addTab( behaviourTab, i18n("Be&havior") );
358 361
359} 362}
360 363
361void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 364void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l )
362{ 365{
363 l->setFont( fnt ); 366 l->setFont( fnt );
364 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 367 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
365} 368}
366 369
367#ifndef KAB_EMBEDDED 370#ifndef KAB_EMBEDDED_
368#include "configurecardviewdialog.moc" 371#include "moc_configurecardviewdialog.cpp"
369#endif //KAB_EMBEDDED 372#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configurecardviewdialog.h b/kaddressbook/views/configurecardviewdialog.h
index 7a62226..4af475d 100644
--- a/kaddressbook/views/configurecardviewdialog.h
+++ b/kaddressbook/views/configurecardviewdialog.h
@@ -17,27 +17,29 @@
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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 CONFIGURECARDVIEWDIALOG_H 24#ifndef CONFIGURECARDVIEWDIALOG_H
25#define CONFIGURECARDVIEWDIALOG_H 25#define CONFIGURECARDVIEWDIALOG_H
26 26
27#include "viewconfigurewidget.h" 27#include "viewconfigurewidget.h"
28 28
29#include <qvbox.h> 29#include <q3vbox.h>
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qfont.h> 31#include <qfont.h>
32//Added by qt3to4:
33#include <QLabel>
32 34
33class QString; 35class QString;
34class QWidget; 36class QWidget;
35class QCheckBox; 37class QCheckBox;
36class QLabel; 38class QLabel;
37class KConfig; 39class KConfig;
38 40
39namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
40 42
41class CardViewLookAndFeelPage; 43class CardViewLookAndFeelPage;
42 44
43/** 45/**
@@ -68,25 +70,25 @@ class ConfigureCardViewWidget : public ViewConfigureWidget
68 Colors 70 Colors
69 * background color 71 * background color
70 * text color 72 * text color
71 * highlight color 73 * highlight color
72 * title/sep text color 74 * title/sep text color
73 * title/sep bg color 75 * title/sep bg color
74 76
75 Layout 77 Layout
76 * item margin 78 * item margin
77 * item spacing 79 * item spacing
78*/ 80*/
79 81
80class CardViewLookNFeelPage : public QVBox { 82class CardViewLookNFeelPage : public Q3VBox {
81 83
82 Q_OBJECT 84 Q_OBJECT
83 85
84 public: 86 public:
85 CardViewLookNFeelPage( QWidget *parent=0, const char *name=0 ); 87 CardViewLookNFeelPage( QWidget *parent=0, const char *name=0 );
86 ~CardViewLookNFeelPage(); 88 ~CardViewLookNFeelPage();
87 89
88 void restoreSettings( KConfig* ); 90 void restoreSettings( KConfig* );
89 void saveSettings( KConfig* ); 91 void saveSettings( KConfig* );
90 92
91 private slots: 93 private slots:
92 void setTextFont(); 94 void setTextFont();
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp
index c329cd9..7ed897a 100644
--- a/kaddressbook/views/configuretableviewdialog.cpp
+++ b/kaddressbook/views/configuretableviewdialog.cpp
@@ -18,29 +18,32 @@
18 18
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#include <qstring.h> 24#include <qstring.h>
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcheckbox.h> 29#include <qcheckbox.h>
30#include <qvbox.h> 30#include <q3vbox.h>
31#include <qbuttongroup.h> 31#include <q3buttongroup.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qwhatsthis.h> 33#include <q3whatsthis.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35//Added by qt3to4:
36#include <Q3GridLayout>
37#include <Q3Frame>
35 38
36#include <kglobal.h> 39#include <kglobal.h>
37#include <klocale.h> 40#include <klocale.h>
38#include <klineedit.h> 41#include <klineedit.h>
39#include <kurlrequester.h> 42#include <kurlrequester.h>
40#include <kiconloader.h> 43#include <kiconloader.h>
41#include <kfontdialog.h> 44#include <kfontdialog.h>
42 45
43#ifndef KAB_EMBEDDED 46#ifndef KAB_EMBEDDED
44#include <kimageio.h> 47#include <kimageio.h>
45#else //KAB_EMBEDDED 48#else //KAB_EMBEDDED
46#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
@@ -75,25 +78,25 @@ void ConfigureTableViewWidget::restoreSettings( KConfig *config )
75} 78}
76 79
77void ConfigureTableViewWidget::saveSettings( KConfig *config ) 80void ConfigureTableViewWidget::saveSettings( KConfig *config )
78{ 81{
79 ViewConfigureWidget::saveSettings( config ); 82 ViewConfigureWidget::saveSettings( config );
80 83
81 mPage->saveSettings( config ); 84 mPage->saveSettings( config );
82} 85}
83 86
84 87
85 88
86LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) 89LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
87 : QVBox(parent, name) 90 : Q3VBox(parent, name)
88{ 91{
89 initGUI(); 92 initGUI();
90 93
91 // Set initial state 94 // Set initial state
92 enableBackgroundToggled(mBackgroundBox->isChecked()); 95 enableBackgroundToggled(mBackgroundBox->isChecked());
93} 96}
94 97
95void LookAndFeelPage::restoreSettings( KConfig *config ) 98void LookAndFeelPage::restoreSettings( KConfig *config )
96{ 99{
97 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); 100 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
98 mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); 101 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
99 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); 102 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
@@ -220,30 +223,30 @@ void LookAndFeelPage::enableColors()
220 if ( cbEnableCustomColors->isChecked() ) 223 if ( cbEnableCustomColors->isChecked() )
221 lbColors->setFocus(); 224 lbColors->setFocus();
222} 225}
223 226
224void LookAndFeelPage::initGUI() 227void LookAndFeelPage::initGUI()
225{ 228{
226 int spacing = KDialog::spacingHint(); 229 int spacing = KDialog::spacingHint();
227 int margin = KDialog::marginHint(); 230 int margin = KDialog::marginHint();
228 231
229 QTabWidget *tabs = new QTabWidget( this ); 232 QTabWidget *tabs = new QTabWidget( this );
230 233
231 // General 234 // General
232 QVBox *generalTab = new QVBox( this, "generaltab" ); 235 Q3VBox *generalTab = new Q3VBox( this, "generaltab" );
233 236
234 generalTab->setSpacing( spacing ); 237 generalTab->setSpacing( spacing );
235 generalTab->setMargin( margin ); 238 generalTab->setMargin( margin );
236 239
237 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 240 Q3ButtonGroup *group = new Q3ButtonGroup(1, Qt::Horizontal,
238 i18n("Row Separator"), generalTab); 241 i18n("Row Separator"), generalTab);
239 242
240 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), 243 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
241 group, "mAlternateButton"); 244 group, "mAlternateButton");
242 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); 245 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
243 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); 246 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
244 247
245 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, 248 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab,
246 "mBackgroundBox"); 249 "mBackgroundBox");
247 connect(mBackgroundBox, SIGNAL(toggled(bool)), 250 connect(mBackgroundBox, SIGNAL(toggled(bool)),
248 SLOT(enableBackgroundToggled(bool))); 251 SLOT(enableBackgroundToggled(bool)));
249 // LR image not implemented 252 // LR image not implemented
@@ -253,93 +256,93 @@ void LookAndFeelPage::initGUI()
253 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | 256 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
254 KFile::LocalOnly); 257 KFile::LocalOnly);
255 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); 258 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
256#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
257 260
258 // ToolTip Checkbox 261 // ToolTip Checkbox
259 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, 262 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab,
260 "mToolTipBox"); 263 "mToolTipBox");
261 264
262 tabs->addTab( generalTab, i18n("&General") ); 265 tabs->addTab( generalTab, i18n("&General") );
263 266
264 // Colors 267 // Colors
265 QVBox *colorTab = new QVBox( this, "colortab" ); 268 Q3VBox *colorTab = new Q3VBox( this, "colortab" );
266 colorTab->setSpacing( spacing ); 269 colorTab->setSpacing( spacing );
267 colorTab->setMargin( spacing ); 270 colorTab->setMargin( spacing );
268 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); 271 cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
269 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); 272 connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );
270 lbColors = new ColorListBox( colorTab ); 273 lbColors = new ColorListBox( colorTab );
271 tabs->addTab( colorTab, i18n("&Colors") ); 274 tabs->addTab( colorTab, i18n("&Colors") );
272 275
273 QWhatsThis::add( cbEnableCustomColors, i18n( 276 Q3WhatsThis::add( cbEnableCustomColors, i18n(
274 "If custom colors are enabled, you may choose the colors for the view below. " 277 "If custom colors are enabled, you may choose the colors for the view below. "
275 "Otherwise colors from your current KDE color scheme are used." 278 "Otherwise colors from your current KDE color scheme are used."
276 ) ); 279 ) );
277 QWhatsThis::add( lbColors, i18n( 280 Q3WhatsThis::add( lbColors, i18n(
278 "Double click or press RETURN on a item to select a color for the related strings in the view." 281 "Double click or press RETURN on a item to select a color for the related strings in the view."
279 ) ); 282 ) );
280 283
281 // Fonts 284 // Fonts
282 QVBox *fntTab = new QVBox( this, "fonttab" ); 285 Q3VBox *fntTab = new Q3VBox( this, "fonttab" );
283 286
284 fntTab->setSpacing( spacing ); 287 fntTab->setSpacing( spacing );
285 fntTab->setMargin( spacing ); 288 fntTab->setMargin( spacing );
286 289
287 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); 290 cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab );
288 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); 291 connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) );
289 292
290 vbFonts = new QWidget( fntTab ); 293 vbFonts = new QWidget( fntTab );
291 QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); 294 Q3GridLayout *gFnts = new Q3GridLayout( vbFonts, 2, 3 );
292 gFnts->setSpacing( spacing ); 295 gFnts->setSpacing( spacing );
293 gFnts->setAutoAdd( true ); 296 gFnts->setAutoAdd( true );
294 gFnts->setColStretch( 1, 1 ); 297 gFnts->setColStretch( 1, 1 );
295 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); 298 QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts );
296 lTextFont = new QLabel( vbFonts ); 299 lTextFont = new QLabel( vbFonts );
297 lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 300 lTextFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
298#ifndef KAB_EMBEDDED 301#ifndef KAB_EMBEDDED
299 btnFont = new KPushButton( i18n("Choose..."), vbFonts ); 302 btnFont = new KPushButton( i18n("Choose..."), vbFonts );
300#else //KAB_EMBEDDED 303#else //KAB_EMBEDDED
301 btnFont = new QPushButton( i18n("Choose..."), vbFonts ); 304 btnFont = new QPushButton( i18n("Choose..."), vbFonts );
302#endif //KAB_EMBEDDED 305#endif //KAB_EMBEDDED
303 306
304 lTFnt->setBuddy( btnFont ); 307 lTFnt->setBuddy( btnFont );
305 308
306 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); 309 connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) );
307 310
308 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); 311 QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts );
309 lHeaderFont = new QLabel( vbFonts ); 312 lHeaderFont = new QLabel( vbFonts );
310 lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); 313 lHeaderFont->setFrameStyle( Q3Frame::Panel|Q3Frame::Sunken );
311#ifndef KAB_EMBEDDED 314#ifndef KAB_EMBEDDED
312 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); 315 btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts );
313#else //KAB_EMBEDDED 316#else //KAB_EMBEDDED
314 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); 317 btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts );
315#endif //KAB_EMBEDDED 318#endif //KAB_EMBEDDED
316 lHFnt->setBuddy( btnHeaderFont ); 319 lHFnt->setBuddy( btnHeaderFont );
317 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); 320 connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) );
318 321
319 fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); 322 fntTab->setStretchFactor( new QWidget( fntTab ), 1 );
320 323
321 QWhatsThis::add( cbEnableCustomFonts, i18n( 324 Q3WhatsThis::add( cbEnableCustomFonts, i18n(
322 "If custom fonts are enabled, you may choose which fonts to use for this view below. " 325 "If custom fonts are enabled, you may choose which fonts to use for this view below. "
323 "Otherwise the default KDE font will be used, in bold style for the header and " 326 "Otherwise the default KDE font will be used, in bold style for the header and "
324 "normal style for the data." 327 "normal style for the data."
325 ) ); 328 ) );
326 329
327 tabs->addTab( fntTab, i18n("&Fonts") ); 330 tabs->addTab( fntTab, i18n("&Fonts") );
328 331
329} 332}
330 333
331void LookAndFeelPage::enableBackgroundToggled(bool enabled) 334void LookAndFeelPage::enableBackgroundToggled(bool enabled)
332{ 335{
333 mBackgroundName->setEnabled(enabled); 336 mBackgroundName->setEnabled(enabled);
334} 337}
335 338
336 339
337void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) 340void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l )
338{ 341{
339 l->setFont( fnt ); 342 l->setFont( fnt );
340 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); 343 l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) );
341} 344}
342 345
343#ifndef KAB_EMBEDDED 346#ifndef KAB_EMBEDDED_
344#include "configuretableviewdialog.moc" 347#include "moc_configuretableviewdialog.cpp"
345#endif //KAB_EMBEDDED 348#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/configuretableviewdialog.h b/kaddressbook/views/configuretableviewdialog.h
index 003ccf8..8125fc9 100644
--- a/kaddressbook/views/configuretableviewdialog.h
+++ b/kaddressbook/views/configuretableviewdialog.h
@@ -17,25 +17,27 @@
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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 CONFIGURETABLEVIEWDIALOG_H 24#ifndef CONFIGURETABLEVIEWDIALOG_H
25#define CONFIGURETABLEVIEWDIALOG_H 25#define CONFIGURETABLEVIEWDIALOG_H
26 26
27#include "viewconfigurewidget.h" 27#include "viewconfigurewidget.h"
28 28
29#include <qvbox.h> 29#include <q3vbox.h>
30//Added by qt3to4:
31#include <QLabel>
30 32
31class QString; 33class QString;
32class QWidget; 34class QWidget;
33class QRadioButton; 35class QRadioButton;
34class QCheckBox; 36class QCheckBox;
35class KURLRequester; 37class KURLRequester;
36class KConfig; 38class KConfig;
37class QLabel; 39class QLabel;
38 40
39namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
40 42
41class LookAndFeelPage; 43class LookAndFeelPage;
@@ -54,25 +56,25 @@ class ConfigureTableViewWidget : public ViewConfigureWidget
54 virtual void restoreSettings( KConfig* ); 56 virtual void restoreSettings( KConfig* );
55 virtual void saveSettings( KConfig* ); 57 virtual void saveSettings( KConfig* );
56 58
57 private: 59 private:
58 void initGUI(); 60 void initGUI();
59 61
60 LookAndFeelPage *mPage; 62 LookAndFeelPage *mPage;
61}; 63};
62 64
63/** 65/**
64 Internal class. It is only defined here for moc 66 Internal class. It is only defined here for moc
65*/ 67*/
66class LookAndFeelPage : public QVBox 68class LookAndFeelPage : public Q3VBox
67{ 69{
68 Q_OBJECT 70 Q_OBJECT
69 71
70 public: 72 public:
71 LookAndFeelPage( QWidget *parent, const char *name = 0 ); 73 LookAndFeelPage( QWidget *parent, const char *name = 0 );
72 ~LookAndFeelPage() {} 74 ~LookAndFeelPage() {}
73 75
74 void restoreSettings( KConfig* ); 76 void restoreSettings( KConfig* );
75 void saveSettings( KConfig* ); 77 void saveSettings( KConfig* );
76 78
77 protected slots: 79 protected slots:
78 void enableBackgroundToggled( bool ); 80 void enableBackgroundToggled( bool );
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 9accf78..227645d 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -12,67 +12,73 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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#include <qheader.h> 24#include <q3header.h>
25#include <qiconset.h> 25#include <qicon.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qdragobject.h> 27#include <q3dragobject.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qbrush.h> 30#include <qbrush.h>
31#include <qevent.h> 31#include <qevent.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//Added by qt3to4:
34#include <QDropEvent>
35#include <QPixmap>
36#include <QMouseEvent>
37#include <QKeyEvent>
33 38
34#include <klocale.h> 39#include <klocale.h>
35#include <kglobalsettings.h> 40#include <kglobalsettings.h>
36#include <kiconloader.h> 41#include <kiconloader.h>
37#include <kdebug.h> 42#include <kdebug.h>
38#include <kconfig.h> 43#include <kconfig.h>
39#include <kapplication.h> 44#include <kapplication.h>
40#include <kurl.h> 45#include <kurl.h>
41 46
42#include "kaddressbooktableview.h" 47#include "kaddressbooktableview.h"
43 48
44#include "contactlistview.h" 49#include "contactlistview.h"
45 50
46///////////////////////////////// 51/////////////////////////////////
47// DynamicTip Methods 52// DynamicTip Methods
48 53
49DynamicTip::DynamicTip( ContactListView *parent) 54DynamicTip::DynamicTip( ContactListView *parent)
50 : QToolTip( parent ) 55 /* TODO:hacker:: QToolTip( parent ) */
51{ 56{
52} 57}
53 58
54void DynamicTip::maybeTip( const QPoint &pos ) 59void DynamicTip::maybeTip( const QPoint &pos )
55{ 60{
61 /* TODO:hacker:
56 static bool ishidden = true; 62 static bool ishidden = true;
57 if (!parentWidget()->inherits( "ContactListView" )) 63 if (!parentWidget()->inherits( "ContactListView" ))
58 return; 64 return;
59 65
60 ContactListView *plv = (ContactListView*)parentWidget(); 66 ContactListView *plv = (ContactListView*)parentWidget();
61 if (!plv->tooltips()) 67 if (!plv->tooltips())
62 return; 68 return;
63 69
64 QPoint posVp = plv->viewport()->pos(); 70 QPoint posVp = plv->viewport()->pos();
65 71
66 QListViewItem *lvi = plv->itemAt( pos - posVp ); 72 Q3ListViewItem *lvi = plv->itemAt( pos - posVp );
67 if (!lvi) 73 if (!lvi)
68 return; 74 return;
69 75
70#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
71 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); 77 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi);
72#else //KAB_EMBEDDED 78#else //KAB_EMBEDDED
73 ContactListViewItem *plvi = (ContactListViewItem*)(lvi); 79 ContactListViewItem *plvi = (ContactListViewItem*)(lvi);
74#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
75 81
76 if (!plvi) 82 if (!plvi)
77 return; 83 return;
78 84
@@ -142,71 +148,71 @@ void DynamicTip::maybeTip( const QPoint &pos )
142 lastw = linew; 148 lastw = linew;
143 } 149 }
144 150
145 ++i; 151 ++i;
146 } 152 }
147 } 153 }
148 154
149 tip( r, s ); 155 tip( r, s );
150 } 156 }
151 else 157 else
152 hide(); 158 hide();
153 ishidden = !ishidden; 159 ishidden = !ishidden;
154 160 */
155} 161}
156 162
157/////////////////////////// 163///////////////////////////
158// ContactListViewItem Methods 164// ContactListViewItem Methods
159 165
160ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, 166ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
161 ContactListView *parent, 167 ContactListView *parent,
162 KABC::AddressBook *doc, 168 KABC::AddressBook *doc,
163 const KABC::Field::List &fields ) 169 const KABC::Field::List &fields )
164 : KListViewItem(parent), mAddressee(a), mFields( fields ), 170 : KListViewItem(parent), mAddressee(a), mFields( fields ),
165 parentListView( parent ), mDocument(doc) 171 parentListView( parent ), mDocument(doc)
166{ 172{
167 refresh(); 173 refresh();
168} 174}
169 175
170QString ContactListViewItem::key(int column, bool ascending) const 176QString ContactListViewItem::key(int column, bool ascending) const
171{ 177{
172#ifndef DESKTOP_VERSION 178#ifndef DESKTOP_VERSION
173 int lan = KGlobal::locale()->language(); 179 int lan = KGlobal::locale()->language();
174 //qDebug("language %d ", lan); 180 //qDebug("language %d ", lan);
175 if ( lan == 1 ) { //GERMAN 181 if ( lan == 1 ) { //GERMAN
176 QString ret = QListViewItem::key(column, ascending).lower().utf8(); 182 QString ret = Q3ListViewItem::key(column, ascending).lower().utf8();
177 int start = -1; 183 int start = -1;
178 while ( (start = ret.find( 'ä', start+1)) > 0 ) { 184 while ( (start = ret.find( 'ä', start+1)) > 0 ) {
179 ret.at(start-1) = 'a'; 185 ret.at(start-1) = 'a';
180 } 186 }
181 start = -1; 187 start = -1;
182 while ( (start = ret.find( 'ö', start+1)) > 0 ) { 188 while ( (start = ret.find( 'ö', start+1)) > 0 ) {
183 ret.at(start-1) = 'o'; 189 ret.at(start-1) = 'o';
184 } 190 }
185 start = -1; 191 start = -1;
186 while ( (start = ret.find( 'ü', start+1)) > 0 ) { 192 while ( (start = ret.find( 'ü', start+1)) > 0 ) {
187 ret.at(start-1) = 'o'; 193 ret.at(start-1) = 'o';
188 } 194 }
189 start = -1; 195 start = -1;
190 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 196 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
191 ret.at(start-1) = 's'; 197 ret.at(start-1) = 's';
192 } 198 }
193 //qDebug("conv string %s ", ret.latin1()); 199 //qDebug("conv string %s ", ret.latin1());
194 200
195 return ret; 201 return ret;
196 202
197 } 203 }
198 else 204 else
199#endif 205#endif
200 return QListViewItem::key(column, ascending).lower(); 206 return Q3ListViewItem::key(column, ascending).lower();
201} 207}
202 208
203void ContactListViewItem::paintCell(QPainter * p, 209void ContactListViewItem::paintCell(QPainter * p,
204 const QColorGroup & cg, 210 const QColorGroup & cg,
205 int column, 211 int column,
206 int width, 212 int width,
207 int align) 213 int align)
208{ 214{
209 KListViewItem::paintCell(p, cg, column, width, align); 215 KListViewItem::paintCell(p, cg, column, width, align);
210 216
211 if ( !p ) 217 if ( !p )
212 return; 218 return;
@@ -279,25 +285,25 @@ ContactListView::ContactListView(KAddressBookTableView *view,
279 285
280 286
281 new DynamicTip( this ); 287 new DynamicTip( this );
282} 288}
283void ContactListView::printMe() 289void ContactListView::printMe()
284{ 290{
285#ifdef DESKTOP_VERSION 291#ifdef DESKTOP_VERSION
286 QPrinter printer; 292 QPrinter printer;
287 if (!printer.setup() ) 293 if (!printer.setup() )
288 return; 294 return;
289 QPainter p; 295 QPainter p;
290 p.begin ( &printer ); 296 p.begin ( &printer );
291 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 297 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
292 float dx, dy; 298 float dx, dy;
293 int wid = (m.width() * 9)/10; 299 int wid = (m.width() * 9)/10;
294 dx = (float) wid/(float)contentsWidth (); 300 dx = (float) wid/(float)contentsWidth ();
295 dy = (float)(m.height()) / (float)contentsHeight (); 301 dy = (float)(m.height()) / (float)contentsHeight ();
296 float scale; 302 float scale;
297 // scale to fit the width or height of the paper 303 // scale to fit the width or height of the paper
298 if ( dx < dy ) 304 if ( dx < dy )
299 scale = dx; 305 scale = dx;
300 else 306 else
301 scale = dy; 307 scale = dy;
302 p.translate( m.width()/10,0 ); 308 p.translate( m.width()/10,0 );
303 p.scale( scale, scale ); 309 p.scale( scale, scale );
@@ -334,35 +340,35 @@ void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
334} 340}
335 341
336void ContactListView::contentsMousePressEvent(QMouseEvent* e) 342void ContactListView::contentsMousePressEvent(QMouseEvent* e)
337{ 343{
338 presspos = e->pos(); 344 presspos = e->pos();
339 KListView::contentsMousePressEvent(e); 345 KListView::contentsMousePressEvent(e);
340} 346}
341 347
342 348
343// To initiate a drag operation 349// To initiate a drag operation
344void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) 350void ContactListView::contentsMouseMoveEvent( QMouseEvent *e )
345{ 351{
346 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { 352 if ((e->state() & Qt::LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) {
347 emit startAddresseeDrag(); 353 emit startAddresseeDrag();
348 } 354 }
349 else 355 else
350 KListView::contentsMouseMoveEvent( e ); 356 KListView::contentsMouseMoveEvent( e );
351} 357}
352 358
353bool ContactListView::acceptDrag(QDropEvent *e) const 359bool ContactListView::acceptDrag(QDropEvent *e) const
354{ 360{
355#ifndef KAB_EMBEDDED 361#ifndef KAB_EMBEDDED
356 return QTextDrag::canDecode(e); 362 return Q3TextDrag::canDecode(e);
357#else //KAB_EMBEDDED 363#else //KAB_EMBEDDED
358qDebug("ContactListView::acceptDrag has to be fixed"); 364qDebug("ContactListView::acceptDrag has to be fixed");
359 return false; 365 return false;
360#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
361} 367}
362 368
363void ContactListView::itemDropped(QDropEvent *e) 369void ContactListView::itemDropped(QDropEvent *e)
364{ 370{
365 contentsDropEvent(e); 371 contentsDropEvent(e);
366} 372}
367 373
368void ContactListView::contentsDropEvent( QDropEvent *e ) 374void ContactListView::contentsDropEvent( QDropEvent *e )
@@ -415,15 +421,15 @@ void ContactListView::keyPressEvent ( QKeyEvent * e )
415void ContactListView::keyReleaseEvent ( QKeyEvent * e ) 421void ContactListView::keyReleaseEvent ( QKeyEvent * e )
416{ 422{
417 if ( mFlagBlockKeyPressed ) 423 if ( mFlagBlockKeyPressed )
418 return; 424 return;
419 if ( !e->isAutoRepeat() ) { 425 if ( !e->isAutoRepeat() ) {
420 mFlagBlockKeyPressed = true; 426 mFlagBlockKeyPressed = true;
421 qApp->processEvents(); 427 qApp->processEvents();
422 mFlagBlockKeyPressed = false; 428 mFlagBlockKeyPressed = false;
423 mFlagKeyPressed = false; 429 mFlagKeyPressed = false;
424 } 430 }
425 KListView::keyReleaseEvent ( e ); 431 KListView::keyReleaseEvent ( e );
426} 432}
427#ifndef KAB_EMBEDDED 433#ifndef KAB_EMBEDDED_
428#include "contactlistview.moc" 434#include "moc_contactlistview.cpp"
429#endif //KAB_EMBEDDED 435#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index 46477e1..c92b002 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -1,35 +1,39 @@
1#ifndef CONTACTLISTVIEW_H 1#ifndef CONTACTLISTVIEW_H
2#define CONTACTLISTVIEW_H 2#define CONTACTLISTVIEW_H
3 3
4#include <qcolor.h> 4#include <qcolor.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qtooltip.h> 6#include <qtooltip.h>
7#include <qstring.h> 7#include <qstring.h>
8//Added by qt3to4:
9#include <QDropEvent>
10#include <QMouseEvent>
11#include <QKeyEvent>
8 12
9#include <klistview.h> 13#include <klistview.h>
10 14
11#include <kabc/field.h> 15#include <kabc/field.h>
12#include <kabc/addressee.h> 16#include <kabc/addressee.h>
13#include <kabc/addressbook.h> 17#include <kabc/addressbook.h>
14 18
15 19
16class QDropEvent; 20class QDropEvent;
17class KAddressBookTableView; 21class KAddressBookTableView;
18class ContactListView; 22class ContactListView;
19 23
20/** The whole tooltip design needs a lot of work. Currently it is 24/** The whole tooltip design needs a lot of work. Currently it is
21* hacked together to function. 25* hacked together to function.
22*/ 26*/
23class DynamicTip : public QToolTip 27class DynamicTip /* TODO:hacker: : public QToolTip */
24{ 28{
25 public: 29 public:
26 DynamicTip( ContactListView * parent ); 30 DynamicTip( ContactListView * parent );
27 31
28 protected: 32 protected:
29 void maybeTip( const QPoint & ); 33 void maybeTip( const QPoint & );
30 34
31 private: 35 private:
32}; 36};
33 37
34class ContactListViewItem : public KListViewItem 38class ContactListViewItem : public KListViewItem
35{ 39{
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index b503652..1e5a556 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -12,31 +12,36 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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#include <qdragobject.h> 24#include <q3dragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <q3iconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h> 30#include <qapplication.h>
31//Added by qt3to4:
32#include <QDropEvent>
33#include <QKeyEvent>
34#include <Q3VBoxLayout>
35#include <QDragEnterEvent>
31 36
32#include <kabc/addressbook.h> 37#include <kabc/addressbook.h>
33#include <kabc/addressee.h> 38#include <kabc/addressee.h>
34#include <kconfig.h> 39#include <kconfig.h>
35#include <kdebug.h> 40#include <kdebug.h>
36#include <klocale.h> 41#include <klocale.h>
37 42
38#include "kabprefs.h" 43#include "kabprefs.h"
39#include "viewmanager.h" 44#include "viewmanager.h"
40 45
41 46
42#include "kaddressbookcardview.h" 47#include "kaddressbookcardview.h"
@@ -116,48 +121,48 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
116 121
117AddresseeCardView::~AddresseeCardView() 122AddresseeCardView::~AddresseeCardView()
118{ 123{
119} 124}
120void AddresseeCardView::printMe() 125void AddresseeCardView::printMe()
121{ 126{
122#ifdef DESKTOP_VERSION 127#ifdef DESKTOP_VERSION
123 QPrinter printer; 128 QPrinter printer;
124 if (!printer.setup() ) 129 if (!printer.setup() )
125 return; 130 return;
126 QPainter p; 131 QPainter p;
127 p.begin ( &printer ); 132 p.begin ( &printer );
128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 133 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
129 float dx, dy; 134 float dx, dy;
130 int wid = (m.width() * 9)/10; 135 int wid = (m.width() * 9)/10;
131 dx = (float) wid/(float)contentsWidth (); 136 dx = (float) wid/(float)contentsWidth ();
132 dy = (float)(m.height()) / (float)contentsHeight (); 137 dy = (float)(m.height()) / (float)contentsHeight ();
133 float scale; 138 float scale;
134 // scale to fit the width or height of the paper 139 // scale to fit the width or height of the paper
135 if ( dx < dy ) 140 if ( dx < dy )
136 scale = dx; 141 scale = dx;
137 else 142 else
138 scale = dy; 143 scale = dy;
139 p.translate( m.width()/10,0 ); 144 p.translate( m.width()/10,0 );
140 p.scale( scale, scale ); 145 p.scale( scale, scale );
141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 146 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
142 p.end(); 147 p.end();
143 repaint(); 148 repaint();
144#endif 149#endif
145} 150}
146 151
147 152
148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 153void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
149{ 154{
150#ifndef KAB_EMBEDDED 155#ifndef KAB_EMBEDDED
151 if (QTextDrag::canDecode(e)) 156 if (Q3TextDrag::canDecode(e))
152 e->accept(); 157 e->accept();
153#else //KAB_EMBEDDED 158#else //KAB_EMBEDDED
154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 159qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
155#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
156} 161}
157 162
158void AddresseeCardView::dropEvent(QDropEvent *e) 163void AddresseeCardView::dropEvent(QDropEvent *e)
159{ 164{
160 emit addresseeDropped(e); 165 emit addresseeDropped(e);
161} 166}
162 167
163void AddresseeCardView::startDrag() 168void AddresseeCardView::startDrag()
@@ -167,25 +172,25 @@ void AddresseeCardView::startDrag()
167 172
168 173
169/////////////////////////////// 174///////////////////////////////
170// KAddressBookCardView 175// KAddressBookCardView
171 176
172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 177KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
173 QWidget *parent, const char *name ) 178 QWidget *parent, const char *name )
174 : KAddressBookView( ab, parent, name ) 179 : KAddressBookView( ab, parent, name )
175{ 180{
176 mShowEmptyFields = false; 181 mShowEmptyFields = false;
177 182
178 // Init the GUI 183 // Init the GUI
179 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 184 Q3VBoxLayout *layout = new Q3VBoxLayout(viewWidget());
180 185
181 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 186 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
182 mCardView->setSelectionMode(CardView::Extended); 187 mCardView->setSelectionMode(CardView::Extended);
183 layout->addWidget(mCardView); 188 layout->addWidget(mCardView);
184 189
185 // Connect up the signals 190 // Connect up the signals
186 connect(mCardView, SIGNAL(executed(CardViewItem *)), 191 connect(mCardView, SIGNAL(executed(CardViewItem *)),
187 this, SLOT(addresseeExecuted(CardViewItem *))); 192 this, SLOT(addresseeExecuted(CardViewItem *)));
188 connect(mCardView, SIGNAL(selectionChanged()), 193 connect(mCardView, SIGNAL(selectionChanged()),
189 this, SLOT(addresseeSelected())); 194 this, SLOT(addresseeSelected()));
190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 195 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
191 this, SIGNAL(dropped(QDropEvent*))); 196 this, SIGNAL(dropped(QDropEvent*)));
@@ -511,15 +516,15 @@ void KAddressBookCardView::addresseeSelected()
511 if ( aItem ) 516 if ( aItem )
512 { 517 {
513 emit selected(aItem->addressee().uid()); 518 emit selected(aItem->addressee().uid());
514 found = true; 519 found = true;
515 } 520 }
516 } 521 }
517 } 522 }
518 523
519 if (!found) 524 if (!found)
520 emit selected(QString::null); 525 emit selected(QString::null);
521 526
522} 527}
523#ifndef KAB_EMBEDDED 528#ifndef KAB_EMBEDDED_
524#include "kaddressbookcardview.moc" 529#include "moc_kaddressbookcardview.cpp"
525#endif //KAB_EMBEDDED 530#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 2a71f7e..8f8e48b 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -16,24 +16,27 @@
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#include <qstring.h> 27#include <qstring.h>
28//Added by qt3to4:
29#include <QDragEnterEvent>
30#include <QDropEvent>
28#ifndef KAB_EMBEDDED 31#ifndef KAB_EMBEDDED
29#include <kiconview.h> 32#include <kiconview.h>
30#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
31#include <klocale.h> 34#include <klocale.h>
32#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
33 36
34#include "cardview.h" 37#include "cardview.h"
35#include "kaddressbookview.h" 38#include "kaddressbookview.h"
36#include "configurecardviewdialog.h" 39#include "configurecardviewdialog.h"
37 40
38class QDragEnterEvent; 41class QDragEnterEvent;
39class QDragEntryEvent; 42class QDragEntryEvent;
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
@@ -13,37 +13,45 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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>
44#include <qapplication.h> 52#include <qapplication.h>
45#include <kglobal.h> 53#include <kglobal.h>
46/*US transfered to the headerfile 54/*US transfered to the headerfile
47class IconViewFactory : public ViewFactory 55class IconViewFactory : public ViewFactory
48{ 56{
49 public: 57 public:
@@ -64,82 +72,82 @@ extern "C" {
64 { 72 {
65 return ( new IconViewFactory ); 73 return ( new IconViewFactory );
66 } 74 }
67} 75}
68 76
69//////////////////////////////// 77////////////////////////////////
70// AddresseeIconView (internal class) 78// AddresseeIconView (internal class)
71#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 80AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
73 : KIconView(parent, name) 81 : KIconView(parent, name)
74#else //KAB_EMBEDDED 82#else //KAB_EMBEDDED
75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 83AddresseeIconView::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
97AddresseeIconView::~AddresseeIconView() 105AddresseeIconView::~AddresseeIconView()
98{ 106{
99} 107}
100 108
101 109
102void AddresseeIconView::itemDropped(QDropEvent *e, 110void 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
108QDragObject *AddresseeIconView::dragObject() 116Q3DragObject *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
118class AddresseeIconViewItem : public KIconViewItem 126class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 127#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 128class 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();
140 } 148 }
141 149
142 const KABC::Addressee &addressee() const { return mAddressee; } 150 const KABC::Addressee &addressee() const { return mAddressee; }
143 151
144 void refresh() 152 void refresh()
145 { 153 {
@@ -191,36 +199,36 @@ class AddresseeIconViewItem : public QIconViewItem
191 KABC::AddressBook *mDocument; 199 KABC::AddressBook *mDocument;
192 KABC::Addressee mAddressee; 200 KABC::Addressee mAddressee;
193}; 201};
194 202
195/////////////////////////////// 203///////////////////////////////
196// KAddressBookView 204// KAddressBookView
197 205
198KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 206KAddressBookIconView::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()),
221 this, SIGNAL(startDrag())); 229 this, SIGNAL(startDrag()));
222} 230}
223 231
224KAddressBookIconView::~KAddressBookIconView() 232KAddressBookIconView::~KAddressBookIconView()
225{ 233{
226} 234}
@@ -239,38 +247,38 @@ void KAddressBookIconView::scrollUP()
239void KAddressBookIconView::scrollDOWN() 247void KAddressBookIconView::scrollDOWN()
240{ 248{
241 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 249 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
242 QApplication::postEvent( mIconView, ev ); 250 QApplication::postEvent( mIconView, ev );
243} 251}
244void KAddressBookIconView::readConfig(KConfig *config) 252void 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}
267void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 275void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
268{ 276{
269 mIconView->clear(); 277 mIconView->clear();
270 mIconList.clear(); 278 mIconList.clear();
271 if ( s.isEmpty() || s == "*" ) { 279 if ( s.isEmpty() || s == "*" ) {
272 refresh(); 280 refresh();
273 return; 281 return;
274 } 282 }
275 QRegExp re = getRegExp( s ); 283 QRegExp re = getRegExp( s );
276 if (!re.isValid()) 284 if (!re.isValid())
@@ -327,47 +335,47 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
327 } 335 }
328 mIconView->arrangeItemsInGrid( true ); 336 mIconView->arrangeItemsInGrid( true );
329 if ( mIconView->firstItem() ) { 337 if ( mIconView->firstItem() ) {
330 mIconView->setCurrentItem ( mIconView->firstItem() ); 338 mIconView->setCurrentItem ( mIconView->firstItem() );
331 mIconView->setSelected ( mIconView->firstItem() , true ); 339 mIconView->setSelected ( mIconView->firstItem() , true );
332 } 340 }
333 else 341 else
334 emit selected(QString::null); 342 emit selected(QString::null);
335} 343}
336QStringList KAddressBookIconView::selectedUids() 344QStringList 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 {
346#ifndef KAB_EMBEDDED 354#ifndef KAB_EMBEDDED
347 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 355 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
348#else //KAB_EMBEDDED 356#else //KAB_EMBEDDED
349 aItem = (AddresseeIconViewItem*)(item); 357 aItem = (AddresseeIconViewItem*)(item);
350#endif //KAB_EMBEDDED 358#endif //KAB_EMBEDDED
351 if (aItem) 359 if (aItem)
352 uidList << aItem->addressee().uid(); 360 uidList << aItem->addressee().uid();
353 } 361 }
354 } 362 }
355 363
356 return uidList; 364 return uidList;
357} 365}
358 366
359void KAddressBookIconView::refresh(QString uid) 367void 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();
368 376
369 KABC::Addressee::List addresseeList = addressees(); 377 KABC::Addressee::List addresseeList = addressees();
370 KABC::Addressee::List::Iterator iter; 378 KABC::Addressee::List::Iterator iter;
371 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 379 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
372 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 380 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
373 continue; 381 continue;
@@ -397,25 +405,25 @@ void KAddressBookIconView::refresh(QString uid)
397 if ((aItem) && (aItem->addressee().uid() == uid)) { 405 if ((aItem) && (aItem->addressee().uid() == uid)) {
398 aItem->refresh(); 406 aItem->refresh();
399 mIconView->arrangeItemsInGrid( true ); 407 mIconView->arrangeItemsInGrid( true );
400 return; 408 return;
401 } 409 }
402 } 410 }
403 refresh( QString::null ); 411 refresh( QString::null );
404 } 412 }
405} 413}
406 414
407void KAddressBookIconView::setSelected(QString uid, bool selected) 415void 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 }
416 else 424 else
417 { 425 {
418 bool found = false; 426 bool found = false;
419 for (item = mIconView->firstItem(); item && !found; 427 for (item = mIconView->firstItem(); item && !found;
420 item = item->nextItem()) 428 item = item->nextItem())
421 { 429 {
@@ -426,40 +434,40 @@ void KAddressBookIconView::setSelected(QString uid, bool selected)
426#endif //KAB_EMBEDDED 434#endif //KAB_EMBEDDED
427 435
428 if ((aItem) && (aItem->addressee().uid() == uid)) 436 if ((aItem) && (aItem->addressee().uid() == uid))
429 { 437 {
430 mIconView->setSelected(aItem, selected); 438 mIconView->setSelected(aItem, selected);
431 mIconView->ensureItemVisible( aItem ); 439 mIconView->ensureItemVisible( aItem );
432 found = true; 440 found = true;
433 } 441 }
434 } 442 }
435 } 443 }
436} 444}
437 445
438void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 446void 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
445 453
446 if (aItem) { 454 if (aItem) {
447 emit executed(aItem->addressee().uid()); 455 emit executed(aItem->addressee().uid());
448 } 456 }
449} 457}
450 458
451void KAddressBookIconView::addresseeSelected() 459void 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 {
460 if (item->isSelected()) 468 if (item->isSelected())
461 { 469 {
462#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
463 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 471 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
464#else //KAB_EMBEDDED 472#else //KAB_EMBEDDED
465 aItem = (AddresseeIconViewItem*)(item); 473 aItem = (AddresseeIconViewItem*)(item);
@@ -467,15 +475,15 @@ void KAddressBookIconView::addresseeSelected()
467 if (aItem) 475 if (aItem)
468 { 476 {
469 emit selected(aItem->addressee().uid()); 477 emit selected(aItem->addressee().uid());
470 found = true; 478 found = true;
471 } 479 }
472 } 480 }
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
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h
index b0b9fea..6fad4c6 100644
--- a/kaddressbook/views/kaddressbookiconview.h
+++ b/kaddressbook/views/kaddressbookiconview.h
@@ -16,38 +16,41 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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 KADDRESSBOOKICONVIEW_H 24#ifndef KADDRESSBOOKICONVIEW_H
25#define KADDRESSBOOKICONVIEW_H 25#define KADDRESSBOOKICONVIEW_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28//Added by qt3to4:
29#include <Q3ValueList>
30#include <QDropEvent>
28#ifndef KAB_EMBEDDED 31#ifndef KAB_EMBEDDED
29#include <kiconview.h> 32#include <kiconview.h>
30#else //KAB_EMBEDDED 33#else //KAB_EMBEDDED
31#include <qiconview.h> 34#include <q3iconview.h>
32#include <qptrlist.h> 35#include <q3ptrlist.h>
33#include <klocale.h> 36#include <klocale.h>
34#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
35#include "kaddressbookview.h" 38#include "kaddressbookview.h"
36 39
37class QIconViewItem; 40class Q3IconViewItem;
38class KConfig; 41class KConfig;
39class AddresseeIconView; 42class AddresseeIconView;
40class AddresseeIconViewItem; 43class AddresseeIconViewItem;
41class QIconDragItem; 44class Q3IconDragItem;
42class KAddressBookIconView; 45class KAddressBookIconView;
43 46
44namespace KABC { class AddressBook; } 47namespace KABC { class AddressBook; }
45 48
46/** This is an example kaddressbook view that is implemented using 49/** This is an example kaddressbook view that is implemented using
47* KIconView. This view is not the most useful view, but it displays 50* KIconView. This view is not the most useful view, but it displays
48* how simple implementing a new view can be. 51* how simple implementing a new view can be.
49*/ 52*/
50class KAddressBookIconView : public KAddressBookView 53class KAddressBookIconView : public KAddressBookView
51{ 54{
52 Q_OBJECT 55 Q_OBJECT
53 56
@@ -59,65 +62,65 @@ class KAddressBookIconView : public KAddressBookView
59 virtual QStringList selectedUids(); 62 virtual QStringList selectedUids();
60 virtual QString type() const { return "Icon"; } 63 virtual QString type() const { return "Icon"; }
61 void doSearch( const QString& s ,KABC::Field *field ); 64 void doSearch( const QString& s ,KABC::Field *field );
62 65
63 virtual void readConfig(KConfig *config); 66 virtual void readConfig(KConfig *config);
64 virtual void scrollUP(); 67 virtual void scrollUP();
65 virtual void scrollDOWN(); 68 virtual void scrollDOWN();
66 virtual void setFocusAV(); 69 virtual void setFocusAV();
67 70
68 public slots: 71 public slots:
69 void refresh(QString uid = QString::null); 72 void refresh(QString uid = QString::null);
70#ifndef KAB_EMBEDDED 73#ifndef KAB_EMBEDDED
71//MOC_SKIP_BEGIN 74#ifndef Q_MOC_RUN
72 void setSelected(QString uid = QString::null, bool selected = true); 75 void setSelected(QString uid = QString::null, bool selected = true);
73//MOC_SKIP_END 76#endif
74#else //KAB_EMBEDDED 77#else //KAB_EMBEDDED
75//US my MOC do not like default parameters ??? 78//US my MOC do not like default parameters ???
76 void setSelected(QString uid, bool selected); 79 void setSelected(QString uid, bool selected);
77#endif //KAB_EMBEDDED 80#endif //KAB_EMBEDDED
78 81
79 protected slots: 82 protected slots:
80 void addresseeExecuted(QIconViewItem *item); 83 void addresseeExecuted(Q3IconViewItem *item);
81 void addresseeSelected(); 84 void addresseeSelected();
82 85
83 private: 86 private:
84 AddresseeIconView *mIconView; 87 AddresseeIconView *mIconView;
85 QPtrList<AddresseeIconViewItem> mIconList; 88 Q3PtrList<AddresseeIconViewItem> mIconList;
86}; 89};
87 90
88 91
89#ifndef KAB_EMBEDDED 92#ifndef KAB_EMBEDDED
90//MOC_SKIP_BEGIN 93#ifndef Q_MOC_RUN
91class AddresseeIconView : public KIconView 94class AddresseeIconView : public KIconView
92//MOC_SKIP_END 95#endif
93#else //KAB_EMBEDDED 96#else //KAB_EMBEDDED
94class AddresseeIconView : public QIconView 97class AddresseeIconView : public Q3IconView
95#endif //KAB_EMBEDDED 98#endif //KAB_EMBEDDED
96{ 99{
97 Q_OBJECT 100 Q_OBJECT
98 101
99 public: 102 public:
100 AddresseeIconView(QWidget *parent, const char *name); 103 AddresseeIconView(QWidget *parent, const char *name);
101 ~AddresseeIconView(); 104 ~AddresseeIconView();
102 105
103 signals: 106 signals:
104 void addresseeDropped(QDropEvent *); 107 void addresseeDropped(QDropEvent *);
105 void startAddresseeDrag(); 108 void startAddresseeDrag();
106 109
107 protected: 110 protected:
108 virtual QDragObject *dragObject(); 111 virtual Q3DragObject *dragObject();
109 112
110 protected slots: 113 protected slots:
111 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); 114 void itemDropped(QDropEvent *, const Q3ValueList<Q3IconDragItem> &);
112}; 115};
113 116
114class IconViewFactory : public ViewFactory 117class IconViewFactory : public ViewFactory
115{ 118{
116 public: 119 public:
117 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 120 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
118 { 121 {
119 return new KAddressBookIconView( ab, parent, name ); 122 return new KAddressBookIconView( ab, parent, name );
120 } 123 }
121 124
122 QString type() const { return "Icon"; } 125 QString type() const { return "Icon"; }
123 126
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 272f2eb..7efaaa9 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,57 +1,61 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <q3vbox.h>
4#include <qlistbox.h> 4#include <q3listbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <q3dragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <q3url.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14//Added by qt3to4:
15#include <QDropEvent>
16#include <QKeyEvent>
17#include <Q3VBoxLayout>
14 18
15#include <kabc/addressbook.h> 19#include <kabc/addressbook.h>
16#include <kapplication.h> 20#include <kapplication.h>
17#include <kconfig.h> 21#include <kconfig.h>
18#include <kcolorbutton.h> 22#include <kcolorbutton.h>
19#include <kdebug.h> 23#include <kdebug.h>
20#include <kglobal.h> 24#include <kglobal.h>
21#include <kiconloader.h> 25#include <kiconloader.h>
22#include <klineedit.h> 26#include <klineedit.h>
23#include <klocale.h> 27#include <klocale.h>
24#include <kmessagebox.h> 28#include <kmessagebox.h>
25#include <kurl.h> 29#include <kurl.h>
26#include <kurlrequester.h> 30#include <kurlrequester.h>
27 31
28//US#include "configuretableviewdialog.h" 32//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 33#include "contactlistview.h"
30#include "kabprefs.h" 34#include "kabprefs.h"
31#include "undocmds.h" 35#include "undocmds.h"
32#include "viewmanager.h" 36#include "viewmanager.h"
33 37
34#include <qlayout.h> 38#include <qlayout.h>
35#include <qheader.h> 39#include <q3header.h>
36#include <qregexp.h> 40#include <qregexp.h>
37 41
38#include "kaddressbooktableview.h" 42#include "kaddressbooktableview.h"
39 43
40 44
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 45KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 46 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 47 : KAddressBookView( ab, parent, name )
44{ 48{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 49 mainLayout = new Q3VBoxLayout( viewWidget(), 2 );
46 50
47 // The list view will be created when the config is read. 51 // The list view will be created when the config is read.
48 mListView = 0; 52 mListView = 0;
49} 53}
50 54
51KAddressBookTableView::~KAddressBookTableView() 55KAddressBookTableView::~KAddressBookTableView()
52{ 56{
53} 57}
54void KAddressBookTableView::setFocusAV() 58void KAddressBookTableView::setFocusAV()
55{ 59{
56 if ( mListView ) 60 if ( mListView )
57 mListView->setFocus(); 61 mListView->setFocus();
@@ -68,75 +72,75 @@ void KAddressBookTableView::scrollDOWN()
68{ 72{
69 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 73 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
70 QApplication::postEvent( mListView, ev ); 74 QApplication::postEvent( mListView, ev );
71 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); 75 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
72 QApplication::postEvent( mListView, ev ); 76 QApplication::postEvent( mListView, ev );
73} 77}
74void KAddressBookTableView::reconstructListView() 78void KAddressBookTableView::reconstructListView()
75{ 79{
76 if (mListView) 80 if (mListView)
77 { 81 {
78 disconnect(mListView, SIGNAL(selectionChanged()), 82 disconnect(mListView, SIGNAL(selectionChanged()),
79 this, SLOT(addresseeSelected())); 83 this, SLOT(addresseeSelected()));
80 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 84 disconnect(mListView, SIGNAL(executed(Q3ListViewItem*)),
81 this, SLOT(addresseeExecuted(QListViewItem*))); 85 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 86 disconnect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 87 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 88 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
85 SIGNAL(startDrag())); 89 SIGNAL(startDrag()));
86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 90 disconnect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)),
87 this, SLOT(addresseeExecuted(QListViewItem*))); 91 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
88 92
89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 93 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
90 SIGNAL(dropped(QDropEvent*))); 94 SIGNAL(dropped(QDropEvent*)));
91 delete mListView; 95 delete mListView;
92 } 96 }
93 97
94 mListView = new ContactListView( this, addressBook(), viewWidget() ); 98 mListView = new ContactListView( this, addressBook(), viewWidget() );
95 99
96 connect(this, SIGNAL(printView()), 100 connect(this, SIGNAL(printView()),
97 mListView , SLOT(printMe())); 101 mListView , SLOT(printMe()));
98 //US set singleClick manually, because it is no global configparameter in embedded space 102 //US set singleClick manually, because it is no global configparameter in embedded space
99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 103 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
100 104
101 // Add the columns 105 // Add the columns
102 KABC::Field::List fieldList = fields(); 106 KABC::Field::List fieldList = fields();
103 KABC::Field::List::ConstIterator it; 107 KABC::Field::List::ConstIterator it;
104 108
105 int c = 0; 109 int c = 0;
106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 110 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
107 mListView->addColumn( (*it)->label() ); 111 mListView->addColumn( (*it)->label() );
108 mListView->setColumnWidthMode(c++, QListView::Manual); 112 mListView->setColumnWidthMode(c++, Q3ListView::Manual);
109//US 113//US
110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 114 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
111 } 115 }
112 116
113 connect(mListView, SIGNAL(selectionChanged()), 117 connect(mListView, SIGNAL(selectionChanged()),
114 this, SLOT(addresseeSelected())); 118 this, SLOT(addresseeSelected()));
115 connect(mListView, SIGNAL(startAddresseeDrag()), this, 119 connect(mListView, SIGNAL(startAddresseeDrag()), this,
116 SIGNAL(startDrag())); 120 SIGNAL(startDrag()));
117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 121 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
118 SIGNAL(dropped(QDropEvent*))); 122 SIGNAL(dropped(QDropEvent*)));
119 123
120 if (KABPrefs::instance()->mHonorSingleClick) { 124 if (KABPrefs::instance()->mHonorSingleClick) {
121 // qDebug("KAddressBookTableView::reconstructListView single"); 125 // qDebug("KAddressBookTableView::reconstructListView single");
122 connect(mListView, SIGNAL(executed(QListViewItem*)), 126 connect(mListView, SIGNAL(executed(Q3ListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
124 } else { 128 } else {
125 // qDebug("KAddressBookTableView::reconstructListView double"); 129 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 130 connect(mListView, SIGNAL(doubleClicked(Q3ListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 131 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
128 } 132 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 133 connect(mListView, SIGNAL(returnPressed(Q3ListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 134 this, SLOT(addresseeExecuted(Q3ListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 135 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 136 this, SLOT(addresseeDeleted()));
133 137
134//US performceimprovement. Refresh is done from the outside 138//US performceimprovement. Refresh is done from the outside
135//US refresh(); 139//US refresh();
136 140
137 mListView->setSorting( 0, true ); 141 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 142 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 143 mainLayout->activate();
140 mListView->show(); 144 mListView->show();
141} 145}
142 146
@@ -335,47 +339,47 @@ void KAddressBookTableView::refresh(QString uid)
335 // of items. 339 // of items.
336 mListView->repaint(); 340 mListView->repaint();
337 if ( !currentItem ) 341 if ( !currentItem )
338 currentItem = (ContactListViewItem *)mListView->firstChild(); 342 currentItem = (ContactListViewItem *)mListView->firstChild();
339 if ( currentItem ) { 343 if ( currentItem ) {
340 mListView->setCurrentItem( currentItem ); 344 mListView->setCurrentItem( currentItem );
341 mListView->ensureItemVisible( currentItem ); 345 mListView->ensureItemVisible( currentItem );
342 mListView->setSelected( currentItem, true ); 346 mListView->setSelected( currentItem, true );
343 } 347 }
344 } else { 348 } else {
345 // Only need to update on entry. Iterate through and try to find it 349 // Only need to update on entry. Iterate through and try to find it
346 ContactListViewItem *ceItem; 350 ContactListViewItem *ceItem;
347 QListViewItemIterator it( mListView ); 351 Q3ListViewItemIterator it( mListView );
348 while ( it.current() ) { 352 while ( it.current() ) {
349#ifndef KAB_EMBEDDED 353#ifndef KAB_EMBEDDED
350 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 354 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
351#else //KAB_EMBEDDED 355#else //KAB_EMBEDDED
352 ceItem = (ContactListViewItem*)( it.current() ); 356 ceItem = (ContactListViewItem*)( it.current() );
353#endif //KAB_EMBEDDED 357#endif //KAB_EMBEDDED
354 358
355 if ( ceItem && ceItem->addressee().uid() == uid ) { 359 if ( ceItem && ceItem->addressee().uid() == uid ) {
356 ceItem->refresh(); 360 ceItem->refresh();
357 return; 361 return;
358 } 362 }
359 ++it; 363 ++it;
360 } 364 }
361 365
362 refresh( QString::null ); 366 refresh( QString::null );
363 } 367 }
364} 368}
365 369
366QStringList KAddressBookTableView::selectedUids() 370QStringList KAddressBookTableView::selectedUids()
367{ 371{
368 QStringList uidList; 372 QStringList uidList;
369 QListViewItem *item; 373 Q3ListViewItem *item;
370 ContactListViewItem *ceItem; 374 ContactListViewItem *ceItem;
371 375
372 for(item = mListView->firstChild(); item; item = item->itemBelow()) 376 for(item = mListView->firstChild(); item; item = item->itemBelow())
373 { 377 {
374 if (mListView->isSelected( item )) 378 if (mListView->isSelected( item ))
375 { 379 {
376#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
377 ceItem = dynamic_cast<ContactListViewItem*>(item); 381 ceItem = dynamic_cast<ContactListViewItem*>(item);
378#else //KAB_EMBEDDED 382#else //KAB_EMBEDDED
379 ceItem = (ContactListViewItem*)(item); 383 ceItem = (ContactListViewItem*)(item);
380#endif //KAB_EMBEDDED 384#endif //KAB_EMBEDDED
381 385
@@ -385,25 +389,25 @@ QStringList KAddressBookTableView::selectedUids()
385 } 389 }
386 if ( uidList.count() == 0 ) 390 if ( uidList.count() == 0 )
387 if ( mListView->currentItem() ) { 391 if ( mListView->currentItem() ) {
388 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 392 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
389 uidList << ceItem->addressee().uid(); 393 uidList << ceItem->addressee().uid();
390 } 394 }
391 395
392 return uidList; 396 return uidList;
393} 397}
394 398
395void KAddressBookTableView::setSelected(QString uid, bool selected) 399void KAddressBookTableView::setSelected(QString uid, bool selected)
396{ 400{
397 QListViewItem *item; 401 Q3ListViewItem *item;
398 ContactListViewItem *ceItem; 402 ContactListViewItem *ceItem;
399 403
400 if (uid.isNull()) 404 if (uid.isNull())
401 { 405 {
402 mListView->selectAll(selected); 406 mListView->selectAll(selected);
403 } 407 }
404 else 408 else
405 { 409 {
406 for(item = mListView->firstChild(); item; item = item->itemBelow()) 410 for(item = mListView->firstChild(); item; item = item->itemBelow())
407 { 411 {
408#ifndef KAB_EMBEDDED 412#ifndef KAB_EMBEDDED
409 ceItem = dynamic_cast<ContactListViewItem*>(item); 413 ceItem = dynamic_cast<ContactListViewItem*>(item);
@@ -420,49 +424,49 @@ void KAddressBookTableView::setSelected(QString uid, bool selected)
420 mListView->ensureItemVisible(item); 424 mListView->ensureItemVisible(item);
421 } 425 }
422 } 426 }
423 } 427 }
424} 428}
425 429
426void KAddressBookTableView::addresseeSelected() 430void KAddressBookTableView::addresseeSelected()
427{ 431{
428 // We need to try to find the first selected item. This might not be the 432 // We need to try to find the first selected item. This might not be the
429 // last selected item, but when QListView is in multiselection mode, 433 // last selected item, but when QListView is in multiselection mode,
430 // there is no way to figure out which one was 434 // there is no way to figure out which one was
431 // selected last. 435 // selected last.
432 QListViewItem *item; 436 Q3ListViewItem *item;
433 bool found =false; 437 bool found =false;
434 for (item = mListView->firstChild(); item && !found; 438 for (item = mListView->firstChild(); item && !found;
435 item = item->nextSibling()) 439 item = item->nextSibling())
436 { 440 {
437 if (item->isSelected()) 441 if (item->isSelected())
438 { 442 {
439 found = true; 443 found = true;
440#ifndef KAB_EMBEDDED 444#ifndef KAB_EMBEDDED
441 ContactListViewItem *ceItem 445 ContactListViewItem *ceItem
442 = dynamic_cast<ContactListViewItem*>(item); 446 = dynamic_cast<ContactListViewItem*>(item);
443#else //KAB_EMBEDDED 447#else //KAB_EMBEDDED
444 ContactListViewItem *ceItem 448 ContactListViewItem *ceItem
445 = (ContactListViewItem*)(item); 449 = (ContactListViewItem*)(item);
446#endif //KAB_EMBEDDED 450#endif //KAB_EMBEDDED
447 451
448 if ( ceItem ) emit selected(ceItem->addressee().uid()); 452 if ( ceItem ) emit selected(ceItem->addressee().uid());
449 } 453 }
450 } 454 }
451 455
452 if (!found) 456 if (!found)
453 emit selected(QString::null); 457 emit selected(QString::null);
454} 458}
455 459
456void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 460void KAddressBookTableView::addresseeExecuted(Q3ListViewItem *item)
457{ 461{
458 if (item) 462 if (item)
459 { 463 {
460#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
461 ContactListViewItem *ceItem 465 ContactListViewItem *ceItem
462 = dynamic_cast<ContactListViewItem*>(item); 466 = dynamic_cast<ContactListViewItem*>(item);
463#else //KAB_EMBEDDED 467#else //KAB_EMBEDDED
464 ContactListViewItem *ceItem 468 ContactListViewItem *ceItem
465 = (ContactListViewItem*)(item); 469 = (ContactListViewItem*)(item);
466#endif //KAB_EMBEDDED 470#endif //KAB_EMBEDDED
467 471
468 if (ceItem) 472 if (ceItem)
@@ -478,15 +482,15 @@ void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
478 482
479void KAddressBookTableView::addresseeDeleted() 483void KAddressBookTableView::addresseeDeleted()
480{ 484{
481 485
482 emit deleteRequest(); 486 emit deleteRequest();
483 487
484} 488}
485 489
486 490
487 491
488 492
489 493
490#ifndef KAB_EMBEDDED 494#ifndef KAB_EMBEDDED_
491#include "kaddressbooktableview.moc" 495#include "moc_kaddressbooktableview.cpp"
492#endif //KAB_EMBEDDED 496#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h
index 38db7b4..c3cb038 100644
--- a/kaddressbook/views/kaddressbooktableview.h
+++ b/kaddressbook/views/kaddressbooktableview.h
@@ -1,43 +1,45 @@
1#ifndef KADDRESSBOOKTABLEVIEW_H 1#ifndef KADDRESSBOOKTABLEVIEW_H
2#define KADDRESSBOOKTABLEVIEW_H 2#define KADDRESSBOOKTABLEVIEW_H
3 3
4 4
5#ifndef KAB_EMBEDDED 5#ifndef KAB_EMBEDDED
6 6
7 7
8#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
9#include <config.h> 9#include <config.h>
10#endif 10#endif
11 11
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qlistview.h> 13#include <q3listview.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qdialog.h> 15#include <qdialog.h>
16#include <qtabdialog.h> 16#include <q3tabdialog.h>
17#include <qstringlist.h> 17#include <qstringlist.h>
18#include <qvaluelist.h> 18#include <q3valuelist.h>
19 19
20#include "undo.h" 20#include "undo.h"
21 21
22#else //KAB_EMBEDDED 22#else //KAB_EMBEDDED
23#include "views/configuretableviewdialog.h" 23#include "views/configuretableviewdialog.h"
24#endif //KAB_EMBEDDED 24#endif //KAB_EMBEDDED
25 25
26#include "klocale.h" 26#include "klocale.h"
27#include "kaddressbookview.h" 27#include "kaddressbookview.h"
28//Added by qt3to4:
29#include <Q3VBoxLayout>
28 30
29class QListViewItem; 31class Q3ListViewItem;
30class QListBox; 32class Q3ListBox;
31class QVBoxLayout; 33class Q3VBoxLayout;
32class KConfig; 34class KConfig;
33 35
34class ContactListViewItem; 36class ContactListViewItem;
35class ContactListView; 37class ContactListView;
36 38
37 39
38namespace KABC { class AddressBook; } 40namespace KABC { class AddressBook; }
39 41
40/** 42/**
41 * This class is the table view for kaddressbook. This view is a KListView 43 * This class is the table view for kaddressbook. This view is a KListView
42 * with multiple columns for the selected fields. 44 * with multiple columns for the selected fields.
43 * 45 *
@@ -70,28 +72,28 @@ friend class ContactListView;
70 public slots: 72 public slots:
71 virtual void reconstructListView(); 73 virtual void reconstructListView();
72 74
73 protected slots: 75 protected slots:
74 /** Called whenever the user selects an addressee in the list view. 76 /** Called whenever the user selects an addressee in the list view.
75 */ 77 */
76 void addresseeSelected(); 78 void addresseeSelected();
77 void addresseeDeleted(); 79 void addresseeDeleted();
78 80
79 /** Called whenever the user executes an addressee. In terms of the 81 /** Called whenever the user executes an addressee. In terms of the
80 * list view, this is probably a double click 82 * list view, this is probably a double click
81 */ 83 */
82 void addresseeExecuted(QListViewItem*); 84 void addresseeExecuted(Q3ListViewItem*);
83 85
84 private: 86 private:
85 QVBoxLayout *mainLayout; 87 Q3VBoxLayout *mainLayout;
86 ContactListView *mListView; 88 ContactListView *mListView;
87}; 89};
88 90
89 91
90class TableViewFactory : public ViewFactory 92class TableViewFactory : public ViewFactory
91{ 93{
92 public: 94 public:
93 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 95 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
94 { 96 {
95 return new KAddressBookTableView( ab, parent, name ); 97 return new KAddressBookTableView( ab, parent, name );
96 } 98 }
97 99