summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/views
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
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
@@ -1,1750 +1,1758 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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//BEGIN Includes 24//BEGIN Includes
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 {
49 public: 57 public:
50 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) 58 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name )
51 { 59 {
52 setPalette( QToolTip::palette() ); 60 setPalette( QToolTip::palette() );
53 setFrameStyle( Panel|Plain ); 61 setFrameStyle( Panel|Plain );
54 setMidLineWidth(0); 62 setMidLineWidth(0);
55 setIndent(1); 63 setIndent(1);
56 } 64 }
57 65
58 ~CardViewTip() {}; 66 ~CardViewTip() {};
59 protected: 67 protected:
60 void leaveEvent( QEvent * ) 68 void leaveEvent( QEvent * )
61 { 69 {
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;
91 99
92 else if (cItem1->caption() > cItem2->caption()) 100 else if (cItem1->caption() > cItem2->caption())
93 return 1; 101 return 1;
94 102
95 return 0; 103 return 0;
96 } 104 }
97 105
98 private: 106 private:
99 /*int find( const CardViewItem * ) 107 /*int find( const CardViewItem * )
100 { 108 {
101 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); 109 qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!");
102 }*/ 110 }*/
103}; 111};
104 112
105////////////////////////////////////// 113//////////////////////////////////////
106// CardViewSeparator 114// CardViewSeparator
107class CardViewSeparator 115class CardViewSeparator
108{ 116{
109 friend class CardView; 117 friend class CardView;
110 118
111 public: 119 public:
112 CardViewSeparator(CardView *view) 120 CardViewSeparator(CardView *view)
113 : mView(view) 121 : mView(view)
114 { 122 {
115 mRect = QRect(0, 0, view->separatorWidth(), 0); 123 mRect = QRect(0, 0, view->separatorWidth(), 0);
116 } 124 }
117 125
118 ~CardViewSeparator() {} 126 ~CardViewSeparator() {}
119 127
120 void paintSeparator(QPainter *p, QColorGroup &cg) 128 void paintSeparator(QPainter *p, QColorGroup &cg)
121 { 129 {
122 p->fillRect(0, 0, mRect.width(), mRect.height(), 130 p->fillRect(0, 0, mRect.width(), mRect.height(),
123 cg.brush(QColorGroup::Button)); 131 cg.brush(QColorGroup::Button));
124 } 132 }
125 133
126 void repaintSeparator() 134 void repaintSeparator()
127 { 135 {
128 mView->repaintContents(mRect); 136 mView->repaintContents(mRect);
129 } 137 }
130 138
131 private: 139 private:
132 CardView *mView; 140 CardView *mView;
133 QRect mRect; 141 QRect mRect;
134}; 142};
135 143
136//END Helpers 144//END Helpers
137 145
138//BEGIN Private Data 146//BEGIN Private Data
139 147
140class CardViewPrivate 148class CardViewPrivate
141{ 149{
142 public: 150 public:
143 CardViewPrivate() 151 CardViewPrivate()
144 : mSelectionMode( CardView::Multi ), 152 : mSelectionMode( CardView::Multi ),
145 mDrawCardBorder( true ), 153 mDrawCardBorder( true ),
146 mDrawFieldLabels( true ), 154 mDrawFieldLabels( true ),
147 mDrawSeparators( true), 155 mDrawSeparators( true),
148 mSepWidth( 2 ), 156 mSepWidth( 2 ),
149 mShowEmptyFields( false ), 157 mShowEmptyFields( false ),
150 mLayoutDirty( true ), 158 mLayoutDirty( true ),
151 mLastClickOnItem( false ), 159 mLastClickOnItem( false ),
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
177 uint mItemSpacing; // spacing between items, column seperators and border 185 uint mItemSpacing; // spacing between items, column seperators and border
178 int mItemWidth; // width of all items 186 int mItemWidth; // width of all items
179 uint mMaxFieldLines; // Max lines to dispaly pr field 187 uint mMaxFieldLines; // Max lines to dispaly pr field
180 CardViewItem *mCurrentItem; 188 CardViewItem *mCurrentItem;
181 QPoint mLastClickPos; 189 QPoint mLastClickPos;
182 QTimer *mTimer; // times out if mouse rests for more than 500 msecs 190 QTimer *mTimer; // times out if mouse rests for more than 500 msecs
183 CardViewTip *mTip; // passed to the item under a resting cursor to display full text 191 CardViewTip *mTip; // passed to the item under a resting cursor to display full text
184 bool mOnSeparator; // set/reset on mouse movement 192 bool mOnSeparator; // set/reset on mouse movement
185 // for resizing by dragging the separators 193 // for resizing by dragging the separators
186 int mResizeAnchor; // uint, ulong? the mouse down separator left 194 int mResizeAnchor; // uint, ulong? the mouse down separator left
187 int mRubberBandAnchor; // for erasing rubber bands 195 int mRubberBandAnchor; // for erasing rubber bands
188 // data used for resizing. 196 // data used for resizing.
189 // as they are beeded by each mouse move while resizing, we store them here, 197 // as they are beeded by each mouse move while resizing, we store them here,
190 // saving 8 calculations in each mouse move. 198 // saving 8 calculations in each mouse move.
191 int colspace; // amount of space between items pr column 199 int colspace; // amount of space between items pr column
192 uint first; // the first col to anchor at for painting rubber bands 200 uint first; // the first col to anchor at for painting rubber bands
193 int firstX; // X position of first in pixel 201 int firstX; // X position of first in pixel
194 int pressed; // the colummn that was pressed on at resizing start 202 int pressed; // the colummn that was pressed on at resizing start
195 int span; // pressed - first 203 int span; // pressed - first
196 // key completion 204 // key completion
197 QString mCompText; // current completion string 205 QString mCompText; // current completion string
198 QDateTime mCompUpdated; // ...was updated at this time 206 QDateTime mCompUpdated; // ...was updated at this time
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)
224{ 232{
225 d->mCaption = caption; 233 d->mCaption = caption;
226 234
227 initialize(); 235 initialize();
228} 236}
229 237
230CardViewItem::~CardViewItem() 238CardViewItem::~CardViewItem()
231{ 239{
232 // Remove ourself from the view 240 // Remove ourself from the view
233 if (mView != 0) 241 if (mView != 0)
234 mView->takeItem(this); 242 mView->takeItem(this);
235 243
236 delete d; 244 delete d;
237 d = 0; 245 d = 0;
238} 246}
239 247
240void CardViewItem::initialize() 248void CardViewItem::initialize()
241{ 249{
242 d->mSelected = false; 250 d->mSelected = false;
243 d->mFieldList.setAutoDelete(true); 251 d->mFieldList.setAutoDelete(true);
244 d->maxLabelWidth = 0; 252 d->maxLabelWidth = 0;
245 d->hcache=0; 253 d->hcache=0;
246 254
247 //calcRect(); 255 //calcRect();
248 256
249 // Add ourself to the view 257 // Add ourself to the view
250 if (mView != 0) 258 if (mView != 0)
251 mView->insertItem(this); 259 mView->insertItem(this);
252} 260}
253 261
254void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) 262void CardViewItem::paintCard(QPainter *p, QColorGroup &cg)
255{ 263{
256 264
257 if (!mView) 265 if (!mView)
258 return; 266 return;
259 267
260 QPen pen; 268 QPen pen;
261 QBrush brush; 269 QBrush brush;
262 QFontMetrics fm = *(mView->d->mFm); 270 QFontMetrics fm = *(mView->d->mFm);
263 QFontMetrics bFm = *(mView->d->mBFm); 271 QFontMetrics bFm = *(mView->d->mBFm);
264 bool drawLabels = mView->d->mDrawFieldLabels; 272 bool drawLabels = mView->d->mDrawFieldLabels;
265 bool drawBorder = mView->d->mDrawCardBorder; 273 bool drawBorder = mView->d->mDrawCardBorder;
266 int mg = mView->itemMargin(); 274 int mg = mView->itemMargin();
267 int w = mView->itemWidth() - (mg*2); 275 int w = mView->itemWidth() - (mg*2);
268 int h = height() - (mg*2); 276 int h = height() - (mg*2);
269 const int colonWidth( fm.width(":") ); 277 const int colonWidth( fm.width(":") );
270 int labelXPos = 2 + mg; 278 int labelXPos = 2 + mg;
271 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); 279 int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 );
272 int valueXPos = labelWidth + 4 + mg; 280 int valueXPos = labelWidth + 4 + mg;
273 int valueWidth = w - labelWidth - 4 - mg; 281 int valueWidth = w - labelWidth - 4 - mg;
274 282
275 p->setFont( mView->font() ); 283 p->setFont( mView->font() );
276 labelWidth -= colonWidth; // extra space for the colon 284 labelWidth -= colonWidth; // extra space for the colon
277 285
278 if (!drawLabels) 286 if (!drawLabels)
279 { 287 {
280 valueXPos = labelXPos; 288 valueXPos = labelXPos;
281 valueWidth = w - 4; 289 valueWidth = w - 4;
282 } 290 }
283 291
284 // Draw a simple box 292 // Draw a simple box
285 if (isSelected()) 293 if (isSelected())
286 pen = QPen(cg.highlight(), 1); 294 pen = QPen(cg.highlight(), 1);
287 else 295 else
288 pen = QPen(cg.button(), 1); 296 pen = QPen(cg.button(), 1);
289 p->setPen(pen); 297 p->setPen(pen);
290 298
291 // Draw the border - this is only draw if the user asks for it. 299 // Draw the border - this is only draw if the user asks for it.
292 if (drawBorder) 300 if (drawBorder)
293 p->drawRect( mg, mg, w, h ); 301 p->drawRect( mg, mg, w, h );
294 302
295 // set the proper pen color for the caption box 303 // set the proper pen color for the caption box
296 if (isSelected()) 304 if (isSelected())
297 brush = cg.brush(QColorGroup::Highlight); 305 brush = cg.brush(QColorGroup::Highlight);
298 else 306 else
299 brush = cg.brush(QColorGroup::Button); 307 brush = cg.brush(QColorGroup::Button);
300 308
301 p->fillRect(mg, mg, w, 4 + bFm.height(), brush); 309 p->fillRect(mg, mg, w, 4 + bFm.height(), brush);
302 310
303 // Now paint the caption 311 // Now paint the caption
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 )
329 continue; 337 continue;
330 338
331 if (drawLabels) 339 if (drawLabels)
332 { 340 {
333 label = trimString((*iter)->first, labelWidth, fm); 341 label = trimString((*iter)->first, labelWidth, fm);
334 p->drawText(labelXPos, yPos, label + ":"); 342 p->drawText(labelXPos, yPos, label + ":");
335 } 343 }
336/* US original 344/* US original
337 for (cln=0; cln <= maxLines; cln++) 345 for (cln=0; cln <= maxLines; cln++)
338 { 346 {
339 tmp = value.section('\n',cln,cln); 347 tmp = value.section('\n',cln,cln);
340 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 348 if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
341 else break; 349 else break;
342 } 350 }
343*/ 351*/
344 352
345//US new implementation 353//US new implementation
346 QStringList strlst = QStringList::split('\n', value, true); 354 QStringList strlst = QStringList::split('\n', value, true);
347 355
348 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++) 356 for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++)
349 { 357 {
350 tmp = strlst[cln]; 358 tmp = strlst[cln];
351 359
352 if ( !tmp.isEmpty() ) 360 if ( !tmp.isEmpty() )
353 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); 361 p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) );
354 else 362 else
355 break; 363 break;
356 364
357 } 365 }
358 366
359 if ( cln == 0 ) cln = 1; 367 if ( cln == 0 ) cln = 1;
360 yPos += cln * fh + 2; 368 yPos += cln * fh + 2;
361 } 369 }
362 370
363 // if we are the current item and the view has focus, draw focus rect 371 // if we are the current item and the view has focus, draw focus rect
364 if ( mView->currentItem() == this && mView->hasFocus() ) 372 if ( mView->currentItem() == this && mView->hasFocus() )
365 { 373 {
366/*US 374/*US
367 mView->style().drawPrimitive( QStyle::PE_FocusRect, p, 375 mView->style().drawPrimitive( QStyle::PE_FocusRect, p,
368 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg, 376 QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg,
369 QStyle::Style_FocusAtBorder, 377 QStyle::Style_FocusAtBorder,
370 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) ); 378 QStyleOption( isSelected() ? cg.highlight() : cg.base() ) );
371*/ 379*/
372 380
373 const QColor pHighl = isSelected() ? cg.highlight() : cg.base(); 381 const QColor pHighl = isSelected() ? cg.highlight() : cg.base();
374 const QRect r(0, 0, mView->itemWidth(), h+(2*mg)); 382 const QRect r(0, 0, mView->itemWidth(), h+(2*mg));
375#ifndef DESKTOP_VERSION 383#ifndef DESKTOP_VERSION
376 mView->style().drawFocusRect(p, r, cg, &pHighl, true); 384 mView->style().drawFocusRect(p, r, cg, &pHighl, true);
377#endif 385#endif
378 } 386 }
379} 387}
380 388
381const QString &CardViewItem::caption() const 389const QString &CardViewItem::caption() const
382{ 390{
383 return d->mCaption; 391 return d->mCaption;
384} 392}
385 393
386 394
387int CardViewItem::height( bool allowCache ) const 395int CardViewItem::height( bool allowCache ) const
388{ 396{
389 // use cache 397 // use cache
390 if ( allowCache && d->hcache ) 398 if ( allowCache && d->hcache )
391 return d->hcache; 399 return d->hcache;
392 400
393 // Base height: 401 // Base height:
394 // 2 for line width 402 // 2 for line width
395 // 2 for top caption pad 403 // 2 for top caption pad
396 // 2 for bottom caption pad 404 // 2 for bottom caption pad
397 // 2 pad for the end 405 // 2 pad for the end
398 // + 2 times the advised margin 406 // + 2 times the advised margin
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;
429} 437}
430 438
431void CardViewItem::setSelected(bool selected) 439void CardViewItem::setSelected(bool selected)
432{ 440{
433 d->mSelected = selected; 441 d->mSelected = selected;
434} 442}
435 443
436void CardViewItem::insertField(const QString &label, const QString &value) 444void CardViewItem::insertField(const QString &label, const QString &value)
437{ 445{
438 CardViewItem::Field *f = new CardViewItem::Field(label, value); 446 CardViewItem::Field *f = new CardViewItem::Field(label, value);
439 d->mFieldList.append(f); 447 d->mFieldList.append(f);
440 d->hcache=0; 448 d->hcache=0;
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)
466 mView->setLayoutDirty(true); 474 mView->setLayoutDirty(true);
467} 475}
468 476
469void CardViewItem::clearFields() 477void CardViewItem::clearFields()
470{ 478{
471 d->mFieldList.clear(); 479 d->mFieldList.clear();
472 d->hcache = 0; 480 d->hcache = 0;
473 481
474 if (mView) 482 if (mView)
475 mView->setLayoutDirty(true); 483 mView->setLayoutDirty(true);
476} 484}
477 485
478QString CardViewItem::trimString(const QString &text, int width, 486QString CardViewItem::trimString(const QString &text, int width,
479 QFontMetrics &fm) 487 QFontMetrics &fm)
480{ 488{
481 if (fm.width(text) <= width) 489 if (fm.width(text) <= width)
482 return text; 490 return text;
483 491
484 QString dots = "..."; 492 QString dots = "...";
485 int dotWidth = fm.width(dots); 493 int dotWidth = fm.width(dots);
486 QString trimmed; 494 QString trimmed;
487 int charNum = 0; 495 int charNum = 0;
488 496
489 while (fm.width(trimmed) + dotWidth < width) 497 while (fm.width(trimmed) + dotWidth < width)
490 { 498 {
491 trimmed += text[charNum]; 499 trimmed += text[charNum];
492 charNum++; 500 charNum++;
493 } 501 }
494 502
495 // Now trim the last char, since it put the width over the top 503 // Now trim the last char, since it put the width over the top
496 trimmed = trimmed.left(trimmed.length()-1); 504 trimmed = trimmed.left(trimmed.length()-1);
497 trimmed += dots; 505 trimmed += dots;
498 506
499 return trimmed; 507 return trimmed;
500} 508}
501 509
502CardViewItem *CardViewItem::nextItem() 510CardViewItem *CardViewItem::nextItem()
503{ 511{
504 CardViewItem *item = 0; 512 CardViewItem *item = 0;
505 513
506 if (mView) 514 if (mView)
507 item = mView->itemAfter(this); 515 item = mView->itemAfter(this);
508 516
509 return item; 517 return item;
510} 518}
511 519
512void CardViewItem::repaintCard() 520void CardViewItem::repaintCard()
513{ 521{
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;
539 int mrg = mView->itemMargin(); 547 int mrg = mView->itemMargin();
540 int y = mView->d->mBFm->height() + 6 + mrg; 548 int y = mView->d->mBFm->height() + 6 + mrg;
541 int w = mView->itemWidth() - (2*mrg); 549 int w = mView->itemWidth() - (2*mrg);
542 int lw; 550 int lw;
543 bool drawLabels = mView->drawFieldLabels(); 551 bool drawLabels = mView->drawFieldLabels();
544 bool isLabel = drawLabels && itempos.x() < w/2 ? true : false; 552 bool isLabel = drawLabels && itempos.x() < w/2 ? true : false;
545 553
546 if ( itempos.y() < y ) 554 if ( itempos.y() < y )
547 { 555 {
548 if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 ) 556 if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 )
549 return; 557 return;
550 // this is the caption 558 // this is the caption
551 s = caption(); 559 s = caption();
552 trimmed = mView->d->mBFm->width( s ) > w - 4; 560 trimmed = mView->d->mBFm->width( s ) > w - 4;
553 y = 2 + mrg; 561 y = 2 + mrg;
554 lw = 0; 562 lw = 0;
555 isLabel=true; 563 isLabel=true;
556 } else { 564 } else {
557 // find the field 565 // find the field
558 Field *f = fieldAt( itempos ); 566 Field *f = fieldAt( itempos );
559 if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) ) 567 if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) )
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);
602 if ( pnt.x() < 0 ) 610 if ( pnt.x() < 0 )
603 pnt.setX( 0 ); 611 pnt.setX( 0 );
604 if ( pnt.x() + tip->width() > mView->visibleWidth() ) 612 if ( pnt.x() + tip->width() > mView->visibleWidth() )
605 pnt.setX( mView->visibleWidth() - tip->width() ); 613 pnt.setX( mView->visibleWidth() - tip->width() );
606 if ( pnt.y() + tip->height() > mView->visibleHeight() ) 614 if ( pnt.y() + tip->height() > mView->visibleHeight() )
607 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); 615 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) );
608 // show 616 // show
609 tip->move( pnt ); 617 tip->move( pnt );
610 tip->show(); 618 tip->show();
611 } 619 }
612} 620}
613 621
614CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const 622CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
615{ 623{
616 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; 624 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin;
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}
678 686
679void CardView::insertItem(CardViewItem *item) 687void CardView::insertItem(CardViewItem *item)
680{ 688{
681 d->mItemList.inSort(item); 689 d->mItemList.inSort(item);
682 setLayoutDirty(true); 690 setLayoutDirty(true);
683} 691}
684 692
685void CardView::takeItem(CardViewItem *item) 693void CardView::takeItem(CardViewItem *item)
686{ 694{
687 if ( d->mCurrentItem == item ) 695 if ( d->mCurrentItem == item )
688 d->mCurrentItem = item->nextItem(); 696 d->mCurrentItem = item->nextItem();
689 d->mItemList.take(d->mItemList.findRef(item)); 697 d->mItemList.take(d->mItemList.findRef(item));
690 698
691 setLayoutDirty(true); 699 setLayoutDirty(true);
692} 700}
693 701
694void CardView::clear() 702void CardView::clear()
695{ 703{
696 d->mItemList.clear(); 704 d->mItemList.clear();
697 705
698 setLayoutDirty(true); 706 setLayoutDirty(true);
699} 707}
700 708
701CardViewItem *CardView::currentItem() 709CardViewItem *CardView::currentItem()
702{ 710{
703 if ( ! d->mCurrentItem && d->mItemList.count() ) 711 if ( ! d->mCurrentItem && d->mItemList.count() )
704 d->mCurrentItem = d->mItemList.first(); 712 d->mCurrentItem = d->mItemList.first();
705 return d->mCurrentItem; 713 return d->mCurrentItem;
706} 714}
707 715
708void CardView::setCurrentItem( CardViewItem *item ) 716void CardView::setCurrentItem( CardViewItem *item )
709{ 717{
710 if ( !item ) 718 if ( !item )
711 return; 719 return;
712 else if ( item->cardView() != this ) 720 else if ( item->cardView() != this )
713 { 721 {
714 kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl; 722 kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl;
715 return; 723 return;
716 } 724 }
717 else if ( item == currentItem() ) 725 else if ( item == currentItem() )
718 { 726 {
719 return; 727 return;
720 } 728 }
721 729
722 if ( d->mSelectionMode == Single ) 730 if ( d->mSelectionMode == Single )
723 { 731 {
724 setSelected( item, true ); 732 setSelected( item, true );
725 } 733 }
726 else 734 else
727 { 735 {
728 CardViewItem *it = d->mCurrentItem; 736 CardViewItem *it = d->mCurrentItem;
729 d->mCurrentItem = item; 737 d->mCurrentItem = 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
755 return 0; 763 return 0;
756} 764}
757 765
758QRect CardView::itemRect(const CardViewItem *item) 766QRect CardView::itemRect(const CardViewItem *item)
759{ 767{
760 //return item->d->mRect; 768 //return item->d->mRect;
761 return QRect(item->d->x, item->d->y, d->mItemWidth, item->height()); 769 return QRect(item->d->x, item->d->y, d->mItemWidth, item->height());
762} 770}
763 771
764void CardView::ensureItemVisible(const CardViewItem *item) 772void CardView::ensureItemVisible(const CardViewItem *item)
765{ 773{
766 ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0); 774 ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0);
767 ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0); 775 ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0);
768} 776}
769 777
770void CardView::repaintItem(const CardViewItem *item) 778void CardView::repaintItem(const CardViewItem *item)
771{ 779{
772 //repaintContents(item->d->mRect); 780 //repaintContents(item->d->mRect);
773 repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) ); 781 repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) );
774} 782}
775 783
776void CardView::setSelectionMode(CardView::SelectionMode mode) 784void CardView::setSelectionMode(CardView::SelectionMode mode)
777{ 785{
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);
803 } 811 }
804 else if (d->mSelectionMode != CardView::Single) 812 else if (d->mSelectionMode != CardView::Single)
805 { 813 {
806 for (iter.toFirst(); iter.current(); ++iter) 814 for (iter.toFirst(); iter.current(); ++iter)
807 { 815 {
808 (*iter)->setSelected(true); 816 (*iter)->setSelected(true);
809 } 817 }
810 818
811 if (d->mItemList.count() > 0) 819 if (d->mItemList.count() > 0)
812 { 820 {
813 // emit, since there must have been at least one selected 821 // emit, since there must have been at least one selected
814 emit selectionChanged(); 822 emit selectionChanged();
815 //repaint();//??? 823 //repaint();//???
816 viewport()->update(); 824 viewport()->update();
817 } 825 }
818 } 826 }
819} 827}
820 828
821void CardView::setSelected(CardViewItem *item, bool selected) 829void CardView::setSelected(CardViewItem *item, bool selected)
822{ 830{
823 if ((item == 0) || (item->isSelected() == selected)) 831 if ((item == 0) || (item->isSelected() == selected))
824 return; 832 return;
825 833
826 if ( selected && d->mCurrentItem != item ) 834 if ( selected && d->mCurrentItem != item )
827 { 835 {
828 CardViewItem *it = d->mCurrentItem; 836 CardViewItem *it = d->mCurrentItem;
829 d->mCurrentItem = item; 837 d->mCurrentItem = item;
830 if ( it ) 838 if ( it )
831 it->repaintCard(); 839 it->repaintCard();
832 } 840 }
833 841
834 if (d->mSelectionMode == CardView::Single) 842 if (d->mSelectionMode == CardView::Single)
835 { 843 {
836 bool b = signalsBlocked(); 844 bool b = signalsBlocked();
837 blockSignals(true); 845 blockSignals(true);
838 selectAll(false); 846 selectAll(false);
839 blockSignals(b); 847 blockSignals(b);
840 848
841 if (selected) 849 if (selected)
842 { 850 {
843 item->setSelected(selected); 851 item->setSelected(selected);
844 item->repaintCard(); 852 item->repaintCard();
845 emit selectionChanged(); 853 emit selectionChanged();
846 emit selectionChanged(item); 854 emit selectionChanged(item);
847 } 855 }
848 else 856 else
849 { 857 {
850 emit selectionChanged(); 858 emit selectionChanged();
851 emit selectionChanged(0); 859 emit selectionChanged(0);
852 } 860 }
853 } 861 }
854 else if (d->mSelectionMode == CardView::Multi) 862 else if (d->mSelectionMode == CardView::Multi)
855 { 863 {
856 item->setSelected(selected); 864 item->setSelected(selected);
857 item->repaintCard(); 865 item->repaintCard();
858 emit selectionChanged(); 866 emit selectionChanged();
859 } 867 }
860 else if (d->mSelectionMode == CardView::Extended) 868 else if (d->mSelectionMode == CardView::Extended)
861 { 869 {
862 bool b = signalsBlocked(); 870 bool b = signalsBlocked();
863 blockSignals(true); 871 blockSignals(true);
864 selectAll(false); 872 selectAll(false);
865 blockSignals(b); 873 blockSignals(b);
866 874
867 item->setSelected(selected); 875 item->setSelected(selected);
868 item->repaintCard(); 876 item->repaintCard();
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();
894} 902}
895 903
896int CardView::childCount() const 904int CardView::childCount() const
897{ 905{
898 return d->mItemList.count(); 906 return d->mItemList.count();
899} 907}
900/*US 908/*US
901CardViewItem *CardView::findItem(const QString &text, const QString &label, 909CardViewItem *CardView::findItem(const QString &text, const QString &label,
902 Qt::StringComparisonMode compare) 910 Qt::StringComparisonMode compare)
903{ 911{
904 // IF the text is empty, we will return null, since empty text will 912 // IF the text is empty, we will return null, since empty text will
905 // match anything! 913 // match anything!
906 if (text.isEmpty()) 914 if (text.isEmpty())
907 return 0; 915 return 0;
908 916
909 QPtrListIterator<CardViewItem> iter(d->mItemList); 917 QPtrListIterator<CardViewItem> iter(d->mItemList);
910 if (compare & Qt::BeginsWith) 918 if (compare & Qt::BeginsWith)
911 { 919 {
912 QString value; 920 QString value;
913 for (iter.toFirst(); iter.current(); ++iter) 921 for (iter.toFirst(); iter.current(); ++iter)
914 { 922 {
915 value = (*iter)->fieldValue(label).upper(); 923 value = (*iter)->fieldValue(label).upper();
916 if (value.startsWith(text.upper())) 924 if (value.startsWith(text.upper()))
917 return *iter; 925 return *iter;
918 } 926 }
919 } 927 }
920 else 928 else
921 { 929 {
922 kdDebug(5720) << "CardView::findItem: search method not implemented" << endl; 930 kdDebug(5720) << "CardView::findItem: search method not implemented" << endl;
923 } 931 }
924 932
925 return 0; 933 return 0;
926} 934}
927*/ 935*/
928 936
929uint CardView::columnWidth() 937uint CardView::columnWidth()
930{ 938{
931 return d->mDrawSeparators ? 939 return d->mDrawSeparators ?
932 d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth : 940 d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth :
933 d->mItemWidth + d->mItemSpacing; 941 d->mItemWidth + d->mItemSpacing;
934} 942}
935 943
936void CardView::drawContents(QPainter *p, int clipx, int clipy, 944void CardView::drawContents(QPainter *p, int clipx, int clipy,
937 int clipw, int cliph) 945 int clipw, int cliph)
938{ 946{
939 //QScrollView::drawContents(p, clipx, clipy, clipw, cliph); 947 //QScrollView::drawContents(p, clipx, clipy, clipw, cliph);
940 if (d->mLayoutDirty) 948 if (d->mLayoutDirty)
941 calcLayout(); 949 calcLayout();
942 950
943 //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy 951 //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy
944 // << ", " << clipw << ", " << cliph << endl; 952 // << ", " << clipw << ", " << cliph << endl;
945 953
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 {
1029 maxHeight = QMAX(maxHeight, yPos); 1037 maxHeight = QMAX(maxHeight, yPos);
1030 1038
1031 // Drawing in this column would be greater than the height 1039 // Drawing in this column would be greater than the height
1032 // of the scroll view, so move to next column 1040 // of the scroll view, so move to next column
1033 yPos = cardSpacing; 1041 yPos = cardSpacing;
1034 xPos += cardSpacing + maxWidth; 1042 xPos += cardSpacing + maxWidth;
1035 if (d->mDrawSeparators) 1043 if (d->mDrawSeparators)
1036 { 1044 {
1037 // Create a separator since the user asked 1045 // Create a separator since the user asked
1038 sep = new CardViewSeparator(this); 1046 sep = new CardViewSeparator(this);
1039 sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin)); 1047 sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin));
1040 xPos += d->mSepWidth + cardSpacing; 1048 xPos += d->mSepWidth + cardSpacing;
1041 d->mSeparatorList.append(sep); 1049 d->mSeparatorList.append(sep);
1042 } 1050 }
1043 1051
1044 maxWidth = 0; 1052 maxWidth = 0;
1045 } 1053 }
1046 1054
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);
1072} 1080}
1073 1081
1074uint CardView::itemMargin() 1082uint CardView::itemMargin()
1075{ 1083{
1076 return d->mItemMargin; 1084 return d->mItemMargin;
1077} 1085}
1078 1086
1079void CardView::setItemMargin( uint margin ) 1087void CardView::setItemMargin( uint margin )
1080{ 1088{
1081 if ( margin == d->mItemMargin ) 1089 if ( margin == d->mItemMargin )
1082 return; 1090 return;
1083 1091
1084 d->mItemMargin = margin; 1092 d->mItemMargin = margin;
1085 setLayoutDirty( true ); 1093 setLayoutDirty( true );
1086} 1094}
1087 1095
1088uint CardView::itemSpacing() 1096uint CardView::itemSpacing()
1089{ 1097{
1090 return d->mItemSpacing; 1098 return d->mItemSpacing;
1091} 1099}
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();
1117 d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/; 1125 d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/;
1118 int ccw = d->mItemWidth + d->colspace + d->mSepWidth; 1126 int ccw = d->mItemWidth + d->colspace + d->mSepWidth;
1119 d->first = (contentsX()+d->mSepWidth)/ccw; 1127 d->first = (contentsX()+d->mSepWidth)/ccw;
1120 d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw; 1128 d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw;
1121 d->span = d->pressed - d->first; 1129 d->span = d->pressed - d->first;
1122 d->firstX = d->first * ccw; 1130 d->firstX = d->first * ccw;
1123 if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0) 1131 if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0)
1124 } 1132 }
1125 else 1133 else
1126 { 1134 {
1127 selectAll(false); 1135 selectAll(false);
1128 } 1136 }
1129 return; 1137 return;
1130 } 1138 }
1131 1139
1132 d->mLastClickOnItem = true; 1140 d->mLastClickOnItem = true;
1133 1141
1134 CardViewItem *other = d->mCurrentItem; 1142 CardViewItem *other = d->mCurrentItem;
1135 setCurrentItem( item ); 1143 setCurrentItem( item );
1136 1144
1137 // Always emit the selection 1145 // Always emit the selection
1138 emit clicked(item); 1146 emit clicked(item);
1139 1147
1140 // Check the selection type and update accordingly 1148 // Check the selection type and update accordingly
1141 if (d->mSelectionMode == CardView::Single) 1149 if (d->mSelectionMode == CardView::Single)
1142 { 1150 {
1143 // make sure it isn't already selected 1151 // make sure it isn't already selected
1144 if (item->isSelected()) 1152 if (item->isSelected())
1145 return; 1153 return;
1146 1154
1147 bool b = signalsBlocked(); 1155 bool b = signalsBlocked();
1148 blockSignals(true); 1156 blockSignals(true);
1149 selectAll(false); 1157 selectAll(false);
1150 blockSignals(b); 1158 blockSignals(b);
1151 1159
1152 item->setSelected(true); 1160 item->setSelected(true);
1153 item->repaintCard(); 1161 item->repaintCard();
1154 emit selectionChanged(item); 1162 emit selectionChanged(item);
1155 } 1163 }
1156 1164
1157 else if (d->mSelectionMode == CardView::Multi) 1165 else if (d->mSelectionMode == CardView::Multi)
1158 { 1166 {
1159 // toggle the selection 1167 // toggle the selection
1160 item->setSelected(!item->isSelected()); 1168 item->setSelected(!item->isSelected());
1161 item->repaintCard(); 1169 item->repaintCard();
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;
1187 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; 1195 //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl;
1188 CardViewItem *aItem; 1196 CardViewItem *aItem;
1189 for ( ; from <= to; from++ ) 1197 for ( ; from <= to; from++ )
1190 { 1198 {
1191 aItem = d->mItemList.at( from ); 1199 aItem = d->mItemList.at( from );
1192 aItem->setSelected( s ); 1200 aItem->setSelected( s );
1193 repaintItem( aItem ); 1201 repaintItem( aItem );
1194 } 1202 }
1195 emit selectionChanged(); 1203 emit selectionChanged();
1196 } 1204 }
1197 else if ((e->button() & Qt::LeftButton) && 1205 else if ((e->button() & Qt::LeftButton) &&
1198 (e->state() & Qt::ControlButton)) 1206 (e->state() & Qt::ControlButton))
1199 { 1207 {
1200 item->setSelected(!item->isSelected()); 1208 item->setSelected(!item->isSelected());
1201 item->repaintCard(); 1209 item->repaintCard();
1202 emit selectionChanged(); 1210 emit selectionChanged();
1203 } 1211 }
1204 1212
1205 else if (e->button() & Qt::LeftButton) 1213 else if (e->button() & Qt::LeftButton)
1206 { 1214 {
1207 bool b = signalsBlocked(); 1215 bool b = signalsBlocked();
1208 blockSignals(true); 1216 blockSignals(true);
1209 selectAll(false); 1217 selectAll(false);
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() );
1235 setContentsPos( newX, contentsY() ); 1243 setContentsPos( newX, contentsY() );
1236 } 1244 }
1237 // set new item width 1245 // set new item width
1238 setItemWidth( newiw ); 1246 setItemWidth( newiw );
1239 // reset anchors 1247 // reset anchors
1240 d->mResizeAnchor = 0; 1248 d->mResizeAnchor = 0;
1241 d->mRubberBandAnchor = 0; 1249 d->mRubberBandAnchor = 0;
1242 return; 1250 return;
1243 } 1251 }
1244 1252
1245 // If there are accel keys, we will not emit signals 1253 // If there are accel keys, we will not emit signals
1246 if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) 1254 if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton))
1247 return; 1255 return;
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
1273 emit doubleClicked(item); 1281 emit doubleClicked(item);
1274} 1282}
1275 1283
1276void CardView::contentsMouseMoveEvent( QMouseEvent *e ) 1284void CardView::contentsMouseMoveEvent( QMouseEvent *e )
1277{ 1285{
1278 // resizing 1286 // resizing
1279 if ( d->mResizeAnchor ) 1287 if ( d->mResizeAnchor )
1280 { 1288 {
1281 int x = e->x(); 1289 int x = e->x();
1282 if ( x != d->mRubberBandAnchor ) 1290 if ( x != d->mRubberBandAnchor )
1283 drawRubberBands( x ); 1291 drawRubberBands( x );
1284 return; 1292 return;
1285 } 1293 }
1286 1294
1287 if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && 1295 if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) &&
1288 ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { 1296 ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) {
1289 1297
1290 startDrag(); 1298 startDrag();
1291 return; 1299 return;
1292 } 1300 }
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();
1340 } 1348 }
1341} 1349}
1342 1350
1343void CardView::focusOutEvent( QFocusEvent * ) 1351void CardView::focusOutEvent( QFocusEvent * )
1344{ 1352{
1345 if (d->mCurrentItem) 1353 if (d->mCurrentItem)
1346 d->mCurrentItem->repaintCard(); 1354 d->mCurrentItem->repaintCard();
1347} 1355}
1348 1356
1349void CardView::keyPressEvent( QKeyEvent *e ) 1357void CardView::keyPressEvent( QKeyEvent *e )
1350{ 1358{
1351 if ( ! ( childCount() && d->mCurrentItem ) ) 1359 if ( ! ( childCount() && d->mCurrentItem ) )
1352 { 1360 {
1353 e->ignore(); 1361 e->ignore();
1354 return; 1362 return;
1355 } 1363 }
1356 if ( mFlagBlockKeyPressed ) 1364 if ( mFlagBlockKeyPressed )
1357 return; 1365 return;
1358 qApp->processEvents(); 1366 qApp->processEvents();
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
1504 if ( to - from > 1 ) 1512 if ( to - from > 1 )
1505 { 1513 {
1506 bool b = signalsBlocked(); 1514 bool b = signalsBlocked();
1507 blockSignals(true); 1515 blockSignals(true);
1508 selectAll(false); 1516 selectAll(false);
1509 blockSignals(b); 1517 blockSignals(b);
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 );
1535 emit selectionChanged(); 1543 emit selectionChanged();
1536 } 1544 }
1537 } 1545 }
1538 } 1546 }
1539} 1547}
1540 1548
1541void CardView::contentsWheelEvent( QWheelEvent * e ) 1549void CardView::contentsWheelEvent( QWheelEvent * e )
1542{ 1550{
1543 scrollBy(2*e->delta()/-3, 0); 1551 scrollBy(2*e->delta()/-3, 0);
1544} 1552}
1545 1553
1546void CardView::setLayoutDirty(bool dirty) 1554void CardView::setLayoutDirty(bool dirty)
1547{ 1555{
1548 if (d->mLayoutDirty != dirty) 1556 if (d->mLayoutDirty != dirty)
1549 { 1557 {
1550 d->mLayoutDirty = dirty; 1558 d->mLayoutDirty = dirty;
1551 repaint(); 1559 repaint();
1552 } 1560 }
1553} 1561}
1554 1562
1555void CardView::setDrawCardBorder(bool enabled) 1563void CardView::setDrawCardBorder(bool enabled)
1556{ 1564{
1557 if (enabled != d->mDrawCardBorder) 1565 if (enabled != d->mDrawCardBorder)
1558 { 1566 {
1559 d->mDrawCardBorder = enabled; 1567 d->mDrawCardBorder = enabled;
1560 repaint(); 1568 repaint();
1561 } 1569 }
1562} 1570}
1563 1571
1564bool CardView::drawCardBorder() const 1572bool CardView::drawCardBorder() const
1565{ 1573{
1566 return d->mDrawCardBorder; 1574 return d->mDrawCardBorder;
1567} 1575}
1568 1576
1569void CardView::setDrawColSeparators(bool enabled) 1577void CardView::setDrawColSeparators(bool enabled)
1570{ 1578{
1571 if (enabled != d->mDrawSeparators) 1579 if (enabled != d->mDrawSeparators)
1572 { 1580 {
1573 d->mDrawSeparators = enabled; 1581 d->mDrawSeparators = enabled;
1574 setLayoutDirty(true); 1582 setLayoutDirty(true);
1575 } 1583 }
1576} 1584}
1577 1585
1578bool CardView::drawColSeparators() const 1586bool CardView::drawColSeparators() const
1579{ 1587{
1580 return d->mDrawSeparators; 1588 return d->mDrawSeparators;
1581} 1589}
1582 1590
1583void CardView::setDrawFieldLabels(bool enabled) 1591void CardView::setDrawFieldLabels(bool enabled)
1584{ 1592{
1585 if (enabled != d->mDrawFieldLabels) 1593 if (enabled != d->mDrawFieldLabels)
1586 { 1594 {
1587 d->mDrawFieldLabels = enabled; 1595 d->mDrawFieldLabels = enabled;
1588 repaint(); 1596 repaint();
1589 } 1597 }
1590} 1598}
1591 1599
1592bool CardView::drawFieldLabels() const 1600bool CardView::drawFieldLabels() const
1593{ 1601{
1594 return d->mDrawFieldLabels; 1602 return d->mDrawFieldLabels;
1595} 1603}
1596 1604
1597void CardView::setShowEmptyFields(bool show) 1605void CardView::setShowEmptyFields(bool show)
1598{ 1606{
1599 if (show != d->mShowEmptyFields) 1607 if (show != d->mShowEmptyFields)
1600 { 1608 {
1601 d->mShowEmptyFields = show; 1609 d->mShowEmptyFields = show;
1602 setLayoutDirty(true); 1610 setLayoutDirty(true);
1603 } 1611 }
1604} 1612}
1605 1613
1606bool CardView::showEmptyFields() const 1614bool CardView::showEmptyFields() const
1607{ 1615{
1608 return d->mShowEmptyFields; 1616 return d->mShowEmptyFields;
1609} 1617}
1610 1618
1611void CardView::startDrag() 1619void CardView::startDrag()
1612{ 1620{
1613 // The default implementation is a no-op. It must be 1621 // The default implementation is a no-op. It must be
1614 // reimplemented in a subclass to be useful 1622 // reimplemented in a subclass to be useful
1615} 1623}
1616void CardView::tryShowFullText() 1624void CardView::tryShowFullText()
1617{ 1625{
1618 d->mTimer->stop(); 1626 d->mTimer->stop();
1619 // if we have an item 1627 // if we have an item
1620 QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); 1628 QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) );
1621 CardViewItem *item = itemAt( cpos ); 1629 CardViewItem *item = itemAt( cpos );
1622 if ( item ) 1630 if ( item )
1623 { 1631 {
1624 // query it for a value to display 1632 // query it for a value to display
1625 //QString s = item ? item->caption() : "(no item)"; 1633 //QString s = item ? item->caption() : "(no item)";
1626 //kdDebug()<<"MOUSE REST: "<<s<<endl; 1634 //kdDebug()<<"MOUSE REST: "<<s<<endl;
1627 QPoint ipos = cpos - itemRect( item ).topLeft(); 1635 QPoint ipos = cpos - itemRect( item ).topLeft();
1628 item->showFullString( ipos, d->mTip ); 1636 item->showFullString( ipos, d->mTip );
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;
1656 x = d->firstX + tmpcw - d->mSepWidth - contentsX(); 1664 x = d->firstX + tmpcw - d->mSepWidth - contentsX();
1657 do { 1665 do {
1658 p.drawRect( x, 0, 2, h ); 1666 p.drawRect( x, 0, 2, h );
1659 x += tmpcw; 1667 x += tmpcw;
1660 n++; 1668 n++;
1661 } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); 1669 } while ( x < visibleWidth() && n < d->mSeparatorList.count() );
1662 d->mRubberBandAnchor = pos; 1670 d->mRubberBandAnchor = pos;
1663} 1671}
1664 1672
1665 1673
1666int CardView::itemWidth() const 1674int CardView::itemWidth() const
1667{ 1675{
1668 return d->mItemWidth; 1676 return d->mItemWidth;
1669} 1677}
1670 1678
1671void CardView::setItemWidth( int w ) 1679void CardView::setItemWidth( int w )
1672{ 1680{
1673 if ( w == d->mItemWidth ) 1681 if ( w == d->mItemWidth )
1674 return; 1682 return;
1675 if ( w < MIN_ITEM_WIDTH ) 1683 if ( w < MIN_ITEM_WIDTH )
1676 w = MIN_ITEM_WIDTH; 1684 w = MIN_ITEM_WIDTH;
1677 d->mItemWidth = w; 1685 d->mItemWidth = w;
1678 setLayoutDirty( true ); 1686 setLayoutDirty( true );
1679#ifndef KAB_EMBEDDED 1687#ifndef KAB_EMBEDDED
1680 updateContents(); 1688 updateContents();
1681#else //KAB_EMBEDDED 1689#else //KAB_EMBEDDED
1682//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); 1690//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() );
1683qDebug("CardView::setItemWidth has to be verified"); 1691qDebug("CardView::setItemWidth has to be verified");
1684 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); 1692 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
1685#endif //KAB_EMBEDDED 1693#endif //KAB_EMBEDDED
1686} 1694}
1687 1695
1688void CardView::setHeaderFont( const QFont &fnt ) 1696void CardView::setHeaderFont( const QFont &fnt )
1689{ 1697{
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;
1715 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... 1723 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es...
1716} 1724}
1717 1725
1718int CardView::maxFieldLines() const 1726int CardView::maxFieldLines() const
1719{ 1727{
1720 return d->mMaxFieldLines; 1728 return d->mMaxFieldLines;
1721} 1729}
1722 1730
1723void CardView::setMaxFieldLines( int howmany ) 1731void CardView::setMaxFieldLines( int howmany )
1724{ 1732{
1725 d->mMaxFieldLines = howmany ? howmany : INT_MAX; 1733 d->mMaxFieldLines = howmany ? howmany : INT_MAX;
1726 // FIXME update, forcing the items to recalc height!! 1734 // FIXME update, forcing the items to recalc height!!
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,476 +1,484 @@
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
22* card should be unique, since they will be used to index the values. 30* card should be unique, since they will be used to index the values.
23*/ 31*/
24class CardViewItem 32class CardViewItem
25{ 33{
26 friend class CardView; 34 friend class CardView;
27 35
28 public: 36 public:
29 /** A single field in the card view. The first item is the label 37 /** A single field in the card view. The first item is the label
30 * and the second item is the value. 38 * and the second item is the value.
31 */ 39 */
32 typedef QPair<QString, QString> Field; 40 typedef QPair<QString, QString> Field;
33 41
34 /** Constructor. 42 /** Constructor.
35 * 43 *
36 * @param parent The CardView that this card should be displayed on. 44 * @param parent The CardView that this card should be displayed on.
37 * @param caption The caption of the card. This is the text that will 45 * @param caption The caption of the card. This is the text that will
38 * appear at the top of the card. This is also the string that will 46 * appear at the top of the card. This is also the string that will
39 * be used to sort the cards in the view. 47 * be used to sort the cards in the view.
40 */ 48 */
41 CardViewItem(CardView *parent, QString caption = QString::null); 49 CardViewItem(CardView *parent, QString caption = QString::null);
42 virtual ~CardViewItem(); 50 virtual ~CardViewItem();
43 51
44 /** @return The caption of the card, or QString::null if none was ever 52 /** @return The caption of the card, or QString::null if none was ever
45 * set. 53 * set.
46 */ 54 */
47 const QString &caption() const; 55 const QString &caption() const;
48 56
49 /** Sets the caption of the card. This is the text that will 57 /** Sets the caption of the card. This is the text that will
50 * appear at the top of the card. This is also the string that will 58 * appear at the top of the card. This is also the string that will
51 * be used to sort the cards in the view. 59 * be used to sort the cards in the view.
52 */ 60 */
53 void setCaption(const QString &caption); 61 void setCaption(const QString &caption);
54 62
55 /** Paints the card using the given painter and color group. The 63 /** Paints the card using the given painter and color group. The
56 * card will handle painting itself selected if it is selected. 64 * card will handle painting itself selected if it is selected.
57 */ 65 */
58 virtual void paintCard(QPainter *p, QColorGroup &cg); 66 virtual void paintCard(QPainter *p, QColorGroup &cg);
59 67
60 /** Repaints the card. This is done by sending a repaint event to the 68 /** Repaints the card. This is done by sending a repaint event to the
61 * view with the clip rect defined as this card. 69 * view with the clip rect defined as this card.
62 */ 70 */
63 virtual void repaintCard(); 71 virtual void repaintCard();
64 72
65 /** Adds a field to the card. 73 /** Adds a field to the card.
66 * 74 *
67 * @param label The label of the field. The field labels must be unique 75 * @param label The label of the field. The field labels must be unique
68 * within a card. 76 * within a card.
69 * @param The value of the field. 77 * @param The value of the field.
70 */ 78 */
71 void insertField(const QString &label, const QString &value); 79 void insertField(const QString &label, const QString &value);
72 80
73 /** Removes the field with label <i>label</i> from the card. 81 /** Removes the field with label <i>label</i> from the card.
74 */ 82 */
75 void removeField(const QString &label); 83 void removeField(const QString &label);
76 84
77 /** @return The value of the field with label <i>label</i>. 85 /** @return The value of the field with label <i>label</i>.
78 */ 86 */
79 QString fieldValue(const QString &label); 87 QString fieldValue(const QString &label);
80 88
81 /** Removes all the fields from this card. 89 /** Removes all the fields from this card.
82 */ 90 */
83 void clearFields(); 91 void clearFields();
84 92
85 /** @return The next card item. The order of the items will be the same 93 /** @return The next card item. The order of the items will be the same
86 * as the display order in the view. 0 will be returned if this is the 94 * as the display order in the view. 0 will be returned if this is the
87 * last card. 95 * last card.
88 */ 96 */
89 CardViewItem *nextItem(); 97 CardViewItem *nextItem();
90 98
91 /** @return True if this card is currently selected, false otherwise. 99 /** @return True if this card is currently selected, false otherwise.
92 */ 100 */
93 bool isSelected() const; 101 bool isSelected() const;
94 102
95 /** Called by the parent card view when the mouse has been resting for 103 /** Called by the parent card view when the mouse has been resting for
96 * a certain amount of time. If the label or value at pos is obscured 104 * a certain amount of time. If the label or value at pos is obscured
97 * (trimmed) make the label display the full text. 105 * (trimmed) make the label display the full text.
98 */ 106 */
99 void showFullString( const QPoint &pos, CardViewTip *tip ); 107 void showFullString( const QPoint &pos, CardViewTip *tip );
100 108
101 /** @return a pointer to the Field at the position itempos 109 /** @return a pointer to the Field at the position itempos
102 * in this item. 0 is returned if itempos is in the caption. 110 * in this item. 0 is returned if itempos is in the caption.
103 * @param itempos the position in item coordinates 111 * @param itempos the position in item coordinates
104 */ 112 */
105 Field *fieldAt( const QPoint &itempos ) const; 113 Field *fieldAt( const QPoint &itempos ) const;
106 114
107 CardView *cardView() { return mView; }; 115 CardView *cardView() { return mView; };
108 116
109 /** @return The height of this item as rendered, in pixels. 117 /** @return The height of this item as rendered, in pixels.
110 118
111 if @p allowCache is true, the item may use an internally 119 if @p allowCache is true, the item may use an internally
112 cached value rather than recalculating from scratch. The 120 cached value rather than recalculating from scratch. The
113 argument is mainly to allow the cardView to change global settings (like 121 argument is mainly to allow the cardView to change global settings (like
114 maxFieldLines) that might influence the items heights 122 maxFieldLines) that might influence the items heights
115 */ 123 */
116 int height( bool allowCache=true ) const; 124 int height( bool allowCache=true ) const;
117 125
118 protected: 126 protected:
119 /** Sets the card as selected. This is usually only called from the 127 /** Sets the card as selected. This is usually only called from the
120 * card view. 128 * card view.
121 */ 129 */
122 void setSelected(bool selected); 130 void setSelected(bool selected);
123 131
124 private: 132 private:
125 /** Sets the default values. 133 /** Sets the default values.
126 */ 134 */
127 void initialize(); 135 void initialize();
128 136
129 /** Trims a string to the width <i>width</i> using the font metrics 137 /** Trims a string to the width <i>width</i> using the font metrics
130 * to determine the width of each char. If the string is longer than 138 * to determine the width of each char. If the string is longer than
131 * <i>width</i>, then the string will be trimmed and a '...' will 139 * <i>width</i>, then the string will be trimmed and a '...' will
132 * be appended. 140 * be appended.
133 */ 141 */
134 QString trimString(const QString &text, int width, QFontMetrics &fm); 142 QString trimString(const QString &text, int width, QFontMetrics &fm);
135 143
136 CardViewItemPrivate *d; 144 CardViewItemPrivate *d;
137 CardView *mView; 145 CardView *mView;
138}; 146};
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
164 * to be called if you created the item with a proper parent. Once 172 * to be called if you created the item with a proper parent. Once
165 * inserted, the CardView takes ownership of the item. 173 * inserted, the CardView takes ownership of the item.
166 */ 174 */
167 void insertItem(CardViewItem *item); 175 void insertItem(CardViewItem *item);
168 176
169 /** Takes the item from the view. The item will not be deleted and 177 /** Takes the item from the view. The item will not be deleted and
170 * ownership of the item is returned to the caller. 178 * ownership of the item is returned to the caller.
171 */ 179 */
172 void takeItem(CardViewItem *item); 180 void takeItem(CardViewItem *item);
173 181
174 /** Clears the view and deletes all card view items 182 /** Clears the view and deletes all card view items
175 */ 183 */
176 void clear(); 184 void clear();
177 185
178 /** @return The current item, the item that has the focus. 186 /** @return The current item, the item that has the focus.
179 * Whenever the view has focus, this item has a focus rectangle painted 187 * Whenever the view has focus, this item has a focus rectangle painted
180 * at it's border. 188 * at it's border.
181 * @sa setCurrentItem() 189 * @sa setCurrentItem()
182 */ 190 */
183 CardViewItem *currentItem(); 191 CardViewItem *currentItem();
184 192
185 /** Sets the CardViewItem @p item to the current item in the view. 193 /** Sets the CardViewItem @p item to the current item in the view.
186 */ 194 */
187 void setCurrentItem( CardViewItem *item ); 195 void setCurrentItem( CardViewItem *item );
188 196
189 /** @return The item found at the given point, or 0 if there is no item 197 /** @return The item found at the given point, or 0 if there is no item
190 * at that point. 198 * at that point.
191 */ 199 */
192 CardViewItem *itemAt(const QPoint &viewPos); 200 CardViewItem *itemAt(const QPoint &viewPos);
193 201
194 /** @return The bounding rect of the given item. 202 /** @return The bounding rect of the given item.
195 */ 203 */
196 QRect itemRect(const CardViewItem *item); 204 QRect itemRect(const CardViewItem *item);
197 205
198 /** Ensures that the given item is in the viewable area of the widget 206 /** Ensures that the given item is in the viewable area of the widget
199 */ 207 */
200 void ensureItemVisible(const CardViewItem *item); 208 void ensureItemVisible(const CardViewItem *item);
201 209
202 /** Repaints the given item. 210 /** Repaints the given item.
203 */ 211 */
204 void repaintItem(const CardViewItem *item); 212 void repaintItem(const CardViewItem *item);
205 213
206 enum SelectionMode { Single, Multi, Extended, NoSelection }; 214 enum SelectionMode { Single, Multi, Extended, NoSelection };
207 215
208 /** Sets the selection mode. 216 /** Sets the selection mode.
209 * 217 *
210 * @see QListView 218 * @see QListView
211 */ 219 */
212 void setSelectionMode(SelectionMode mode); 220 void setSelectionMode(SelectionMode mode);
213 221
214 /** @return The current selection mode. 222 /** @return The current selection mode.
215 */ 223 */
216 SelectionMode selectionMode() const; 224 SelectionMode selectionMode() const;
217 225
218 /** Selects or deselects the given item. This method honors the current 226 /** Selects or deselects the given item. This method honors the current
219 * selection mode, so if other items are selected, they may be unselected. 227 * selection mode, so if other items are selected, they may be unselected.
220 */ 228 */
221 void setSelected(CardViewItem *item, bool selected); 229 void setSelected(CardViewItem *item, bool selected);
222 230
223 /** Selects or deselects all items. 231 /** Selects or deselects all items.
224 */ 232 */
225 void selectAll(bool state); 233 void selectAll(bool state);
226 234
227 /** @return True if the given item is selected, false otherwise. 235 /** @return True if the given item is selected, false otherwise.
228 */ 236 */
229 bool isSelected(CardViewItem *item) const; 237 bool isSelected(CardViewItem *item) const;
230 238
231 /** @return The first selected item. In single select mode, this will be 239 /** @return The first selected item. In single select mode, this will be
232 * the only selected item, in other modes this will be the first selected 240 * the only selected item, in other modes this will be the first selected
233 * item, but others may exist. 0 if no item is selected. 241 * item, but others may exist. 0 if no item is selected.
234 */ 242 */
235 CardViewItem *selectedItem() const; 243 CardViewItem *selectedItem() const;
236 244
237 /** @return The first item in the view. This may be 0 if no items have 245 /** @return The first item in the view. This may be 0 if no items have
238 * been inserted. This method combined with CardViewItem::nextItem() 246 * been inserted. This method combined with CardViewItem::nextItem()
239 * can be used to iterator through the list of items. 247 * can be used to iterator through the list of items.
240 */ 248 */
241 CardViewItem *firstItem() const; 249 CardViewItem *firstItem() const;
242 250
243 /** @return The item after the given item or 0 if the item is the last 251 /** @return The item after the given item or 0 if the item is the last
244 * item. 252 * item.
245 */ 253 */
246 CardViewItem *itemAfter(CardViewItem *item); 254 CardViewItem *itemAfter(CardViewItem *item);
247 255
248 /** @return The number of items in the view. 256 /** @return The number of items in the view.
249 */ 257 */
250 int childCount() const; 258 int childCount() const;
251 259
252 /** Attempts to find the first item matching the params. 260 /** Attempts to find the first item matching the params.
253 * 261 *
254 * @param text The text to match. 262 * @param text The text to match.
255 * @param label The label of the field to match against. 263 * @param label The label of the field to match against.
256 * @param compare The compare method to use in doing the search. 264 * @param compare The compare method to use in doing the search.
257 * 265 *
258 * @return The first matching item, or 0 if no items match. 266 * @return The first matching item, or 0 if no items match.
259 */ 267 */
260/*US 268/*US
261 CardViewItem *findItem(const QString &text, const QString &label, 269 CardViewItem *findItem(const QString &text, const QString &label,
262 Qt::StringComparisonMode compare = Qt::BeginsWith); 270 Qt::StringComparisonMode compare = Qt::BeginsWith);
263*/ 271*/
264 272
265 /** Returns the amounts of pixels required for one column. 273 /** Returns the amounts of pixels required for one column.
266 * This depends on wheather drawSeparators is enabled: 274 * This depends on wheather drawSeparators is enabled:
267 * If so, it is itemWidth + 2*itemSpacing + separatorWidth 275 * If so, it is itemWidth + 2*itemSpacing + separatorWidth
268 * If not, it is itemWidth + itemSpacing 276 * If not, it is itemWidth + itemSpacing
269 * @see itemWidth(), setItemWidth(), itemSpacing() and setItemSpacing() 277 * @see itemWidth(), setItemWidth(), itemSpacing() and setItemSpacing()
270 */ 278 */
271 uint columnWidth(); 279 uint columnWidth();
272 280
273 /** Sets if the border around a card should be draw. The border is a thing 281 /** Sets if the border around a card should be draw. The border is a thing
274 * (1 or 2 pixel) line that bounds the card. When drawn, it shows when 282 * (1 or 2 pixel) line that bounds the card. When drawn, it shows when
275 * a card is highlighted and when it isn't. 283 * a card is highlighted and when it isn't.
276 */ 284 */
277 void setDrawCardBorder(bool enabled); 285 void setDrawCardBorder(bool enabled);
278 286
279 /** @return True if borders are drawn, false otherwise. 287 /** @return True if borders are drawn, false otherwise.
280 */ 288 */
281 bool drawCardBorder() const; 289 bool drawCardBorder() const;
282 290
283 /** Sets if the column separator should be drawn. The column separator 291 /** Sets if the column separator should be drawn. The column separator
284 * is a thin verticle line (1 or 2 pixels) that is used to separate the 292 * is a thin verticle line (1 or 2 pixels) that is used to separate the
285 * columns in the list view. The separator is just for esthetics and it 293 * columns in the list view. The separator is just for esthetics and it
286 * does not serve a functional purpose. 294 * does not serve a functional purpose.
287 */ 295 */
288 void setDrawColSeparators(bool enabled); 296 void setDrawColSeparators(bool enabled);
289 297
290 /** @return True if column separators are drawn, false otherwise. 298 /** @return True if column separators are drawn, false otherwise.
291 */ 299 */
292 bool drawColSeparators() const; 300 bool drawColSeparators() const;
293 301
294 /** Sets if the field labels should be drawn. The field labels are the 302 /** Sets if the field labels should be drawn. The field labels are the
295 * unique strings used to identify the fields. Sometimes drawing these 303 * unique strings used to identify the fields. Sometimes drawing these
296 * labels makes sense as a source of clarity for the user, othertimes they 304 * labels makes sense as a source of clarity for the user, othertimes they
297 * waste too much space and do not assist the user. 305 * waste too much space and do not assist the user.
298 */ 306 */
299 void setDrawFieldLabels(bool enabled); 307 void setDrawFieldLabels(bool enabled);
300 308
301 /** @return True if the field labels are drawn, false otherwise. 309 /** @return True if the field labels are drawn, false otherwise.
302 */ 310 */
303 bool drawFieldLabels() const; 311 bool drawFieldLabels() const;
304 312
305 /** Sets if fields with no value should be drawn (of cause the label only, 313 /** Sets if fields with no value should be drawn (of cause the label only,
306 * but it allows for embedded editing sometimes...) 314 * but it allows for embedded editing sometimes...)
307 */ 315 */
308 void setShowEmptyFields(bool show); 316 void setShowEmptyFields(bool show);
309 317
310 /** @return Wheather empty fields should be shown 318 /** @return Wheather empty fields should be shown
311 */ 319 */
312 bool showEmptyFields() const; 320 bool showEmptyFields() const;
313 321
314 /** @return the advisory internal margin in items. Setting a value above 1 means 322 /** @return the advisory internal margin in items. Setting a value above 1 means
315 * a space between the item contents and the focus recttangle drawn around 323 * a space between the item contents and the focus recttangle drawn around
316 * the current item. The default value is 0. 324 * the current item. The default value is 0.
317 * The value should be used by CardViewItem and derived classes. 325 * The value should be used by CardViewItem and derived classes.
318 * Note that this should not be greater than half of the minimal item width, 326 * Note that this should not be greater than half of the minimal item width,
319 * which is 80. It is currently not checked, so setting a value greater than 40 327 * which is 80. It is currently not checked, so setting a value greater than 40
320 * will probably mean a crash in the items painting routine. 328 * will probably mean a crash in the items painting routine.
321 * @private Note: I looked for a value in QStyle::PixelMetric to use, but I could 329 * @private Note: I looked for a value in QStyle::PixelMetric to use, but I could
322 * not see a usefull one. One may turn up in a future version of Qt. 330 * not see a usefull one. One may turn up in a future version of Qt.
323 */ 331 */
324 uint itemMargin(); 332 uint itemMargin();
325 333
326 /** Sets the internal item margin. @see itemMargin(). 334 /** Sets the internal item margin. @see itemMargin().
327 */ 335 */
328 void setItemMargin( uint margin ); 336 void setItemMargin( uint margin );
329 337
330 /** @return the item spacing. 338 /** @return the item spacing.
331 * The item spacing is the space (in pixels) between each item in a 339 * The item spacing is the space (in pixels) between each item in a
332 * column, between the items and column separators if drawn, and between 340 * column, between the items and column separators if drawn, and between
333 * the items and the borders of the widget. The default value is set to 341 * the items and the borders of the widget. The default value is set to
334 * 10. 342 * 10.
335 * @private Note: There is no usefull QStyle::PixelMetric to use for this atm. 343 * @private Note: There is no usefull QStyle::PixelMetric to use for this atm.
336 * An option would be using KDialog::spacingHint(). 344 * An option would be using KDialog::spacingHint().
337 */ 345 */
338 uint itemSpacing(); 346 uint itemSpacing();
339 347
340 /** Sets the item spacing. 348 /** Sets the item spacing.
341 * @see itemSpacing() 349 * @see itemSpacing()
342 */ 350 */
343 void setItemSpacing( uint spacing ); 351 void setItemSpacing( uint spacing );
344 352
345 /** @return the width made available to the card items. */ 353 /** @return the width made available to the card items. */
346 int itemWidth() const; 354 int itemWidth() const;
347 355
348 /** Sets the width made available to card items. */ 356 /** Sets the width made available to card items. */
349 void setItemWidth( int width ); 357 void setItemWidth( int width );
350 358
351 /** Sets the header font */ 359 /** Sets the header font */
352 void setHeaderFont( const QFont &fnt ); 360 void setHeaderFont( const QFont &fnt );
353 361
354 /** @return the header font */ 362 /** @return the header font */
355 QFont headerFont() const; 363 QFont headerFont() const;
356 364
357 /** @reimp */ 365 /** @reimp */
358 void setFont( const QFont &fnt ); 366 void setFont( const QFont &fnt );
359 367
360 /** Sets the column separator width */ 368 /** Sets the column separator width */
361 void setSeparatorWidth( int width ); 369 void setSeparatorWidth( int width );
362 370
363 /** @return the column separator width */ 371 /** @return the column separator width */
364 int separatorWidth(); 372 int separatorWidth();
365 373
366 /** Sets the maximum number of lines to display pr field. 374 /** Sets the maximum number of lines to display pr field.
367 If set to 0 (the default) all lines will be displayed. 375 If set to 0 (the default) all lines will be displayed.
368 */ 376 */
369 void setMaxFieldLines( int howmany ); 377 void setMaxFieldLines( int howmany );
370 378
371 /** @return the maximum number of lines pr field */ 379 /** @return the maximum number of lines pr field */
372 int maxFieldLines() const; 380 int maxFieldLines() const;
373 381
374 signals: 382 signals:
375 /** Emitted whenever the selection changes. This means a user highlighted 383 /** Emitted whenever the selection changes. This means a user highlighted
376 * a new item or unhighlighted a currently selected item. 384 * a new item or unhighlighted a currently selected item.
377 */ 385 */
378 void selectionChanged(); 386 void selectionChanged();
379 387
380 /** Same as above method, only it carries the item that was selected. This 388 /** Same as above method, only it carries the item that was selected. This
381 * method will only be emitted in single select mode, since it defineds 389 * method will only be emitted in single select mode, since it defineds
382 * which item was selected. 390 * which item was selected.
383 */ 391 */
384 void selectionChanged(CardViewItem *); 392 void selectionChanged(CardViewItem *);
385 393
386 /** This method is emitted whenever an item is clicked. 394 /** This method is emitted whenever an item is clicked.
387 */ 395 */
388 void clicked(CardViewItem *); 396 void clicked(CardViewItem *);
389 397
390 /** Emitted whenever the user 'executes' an item. This is dependant on 398 /** Emitted whenever the user 'executes' an item. This is dependant on
391 * the KDE global config. This could be a single click or a doubleclick. 399 * the KDE global config. This could be a single click or a doubleclick.
392 * Also emitted when the return key is pressed on an item. 400 * Also emitted when the return key is pressed on an item.
393 */ 401 */
394 void executed(CardViewItem *); 402 void executed(CardViewItem *);
395 403
396 /** Emitted whenever the user double clicks on an item. 404 /** Emitted whenever the user double clicks on an item.
397 */ 405 */
398 void doubleClicked(CardViewItem *); 406 void doubleClicked(CardViewItem *);
399 407
400 /** Emitted when the current item changes 408 /** Emitted when the current item changes
401 */ 409 */
402 void currentChanged( CardViewItem * ); 410 void currentChanged( CardViewItem * );
403 411
404 /** Emitted when the return key is pressed in an item. 412 /** Emitted when the return key is pressed in an item.
405 */ 413 */
406 void returnPressed( CardViewItem * ); 414 void returnPressed( CardViewItem * );
407 415
408 protected: 416 protected:
409 bool mFlagKeyPressed; 417 bool mFlagKeyPressed;
410 bool mFlagBlockKeyPressed; 418 bool mFlagBlockKeyPressed;
411 virtual void keyPressEvent ( QKeyEvent * ); 419 virtual void keyPressEvent ( QKeyEvent * );
412 virtual void keyReleaseEvent ( QKeyEvent * ); 420 virtual void keyReleaseEvent ( QKeyEvent * );
413 /** Determines which cards intersect that region and tells them to paint 421 /** Determines which cards intersect that region and tells them to paint
414 * themselves. 422 * themselves.
415 */ 423 */
416 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); 424 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
417 425
418 /** Sets the layout to dirty and repaints. 426 /** Sets the layout to dirty and repaints.
419 */ 427 */
420 void resizeEvent(QResizeEvent *e); 428 void resizeEvent(QResizeEvent *e);
421 429
422 /** Changes the direction the canvas scolls. 430 /** Changes the direction the canvas scolls.
423 */ 431 */
424 void contentsWheelEvent(QWheelEvent *e); 432 void contentsWheelEvent(QWheelEvent *e);
425 433
426 /** Sets the layout to dirty and calls for a repaint. 434 /** Sets the layout to dirty and calls for a repaint.
427 */ 435 */
428 void setLayoutDirty(bool dirty); 436 void setLayoutDirty(bool dirty);
429 437
430 /** Does the math based on the bounding rect of the cards to properly 438 /** Does the math based on the bounding rect of the cards to properly
431 * lay the cards out on the screen. This is only done if the layout is 439 * lay the cards out on the screen. This is only done if the layout is
432 * marked as dirty. 440 * marked as dirty.
433 */ 441 */
434 void calcLayout(); 442 void calcLayout();
435 443
436// virtual void mousePressEvent(QMouseEvent *e); 444// virtual void mousePressEvent(QMouseEvent *e);
437// virtual void mouseReleaseEvent(QMouseEvent *e); 445// virtual void mouseReleaseEvent(QMouseEvent *e);
438// virtual void mouseMoveEvent(QMouseEvent *e); 446// virtual void mouseMoveEvent(QMouseEvent *e);
439 447
440 virtual void contentsMousePressEvent(QMouseEvent *e); 448 virtual void contentsMousePressEvent(QMouseEvent *e);
441 virtual void contentsMouseMoveEvent(QMouseEvent *e); 449 virtual void contentsMouseMoveEvent(QMouseEvent *e);
442 virtual void contentsMouseReleaseEvent(QMouseEvent *e); 450 virtual void contentsMouseReleaseEvent(QMouseEvent *e);
443 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); 451 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e);
444 452
445 virtual void enterEvent( QEvent * ); 453 virtual void enterEvent( QEvent * );
446 virtual void leaveEvent( QEvent * ); 454 virtual void leaveEvent( QEvent * );
447 455
448 virtual void focusInEvent( QFocusEvent * ); 456 virtual void focusInEvent( QFocusEvent * );
449 virtual void focusOutEvent( QFocusEvent * ); 457 virtual void focusOutEvent( QFocusEvent * );
450 458
451 459
452 /** Overload this method to be told when a drag should be started. 460 /** Overload this method to be told when a drag should be started.
453 * In most cases you will want to start a drag event with the currently 461 * In most cases you will want to start a drag event with the currently
454 * selected item. 462 * selected item.
455 */ 463 */
456 virtual void startDrag(); 464 virtual void startDrag();
457 465
458 private slots: 466 private slots:
459 /** Called by a timer to display a label with truncated text. 467 /** Called by a timer to display a label with truncated text.
460 * Pop up a label, if there is a field with obscured text or 468 * Pop up a label, if there is a field with obscured text or
461 * label at the cursor position. 469 * label at the cursor position.
462 */ 470 */
463 void tryShowFullText(); 471 void tryShowFullText();
464 472
465 private: 473 private:
466 /** draws and erases the rubber bands while columns are resized. 474 /** draws and erases the rubber bands while columns are resized.
467 * @p pos is the horizontal position inside the viewport to use as 475 * @p pos is the horizontal position inside the viewport to use as
468 * the anchor. 476 * the anchor.
469 * If pos is 0, only erase is done. 477 * If pos is 0, only erase is done.
470 */ 478 */
471 void drawRubberBands( int pos ); 479 void drawRubberBands( int pos );
472 480
473 CardViewPrivate *d; 481 CardViewPrivate *d;
474}; 482};
475 483
476#endif 484#endif
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
@@ -1,245 +1,250 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
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);
63 colorItem->setColor(color); 68 colorItem->setColor(color);
64 updateItem( colorItem ); 69 updateItem( colorItem );
65 } 70 }
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
94 if( (uint)index < count() ) 99 if( (uint)index < count() )
95 { 100 {
96 QColor c = color( index ); 101 QColor c = color( index );
97#ifndef KAB_EMBEDDED 102#ifndef KAB_EMBEDDED
98 if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) 103 if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
99 { 104 {
100 setColor( index, c ); 105 setColor( index, c );
101 } 106 }
102#else //KAB_EMBEDDED 107#else //KAB_EMBEDDED
103#ifdef DESKTOP_VERSION 108#ifdef DESKTOP_VERSION
104 QColor col = QColorDialog::getColor ( c ); 109 QColor col = QColorDialog::getColor ( c );
105 if ( col.isValid () ) { 110 if ( col.isValid () ) {
106 setColor( index, col ); 111 setColor( index, col );
107 } 112 }
108#else 113#else
109 KColorDialog* k = new KColorDialog( this ); 114 KColorDialog* k = new KColorDialog( this );
110 k->setColor( c ); 115 k->setColor( c );
111 int res = k->exec(); 116 int res = k->exec();
112 if ( res ) { 117 if ( res ) {
113 setColor( index, k->getColor() ); 118 setColor( index, k->getColor() );
114 } 119 }
115 delete k; 120 delete k;
116#endif 121#endif
117#endif //KAB_EMBEDDED 122#endif //KAB_EMBEDDED
118 123
119 } 124 }
120} 125}
121 126
122 127
123void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) 128void ColorListBox::dragEnterEvent( QDragEnterEvent *e )
124{ 129{
125#ifndef KAB_EMBEDDED 130#ifndef KAB_EMBEDDED
126 if( KColorDrag::canDecode(e) && isEnabled() ) 131 if( KColorDrag::canDecode(e) && isEnabled() )
127 { 132 {
128 mCurrentOnDragEnter = currentItem(); 133 mCurrentOnDragEnter = currentItem();
129 e->accept( true ); 134 e->accept( true );
130 } 135 }
131 else 136 else
132 { 137 {
133 mCurrentOnDragEnter = -1; 138 mCurrentOnDragEnter = -1;
134 e->accept( false ); 139 e->accept( false );
135 } 140 }
136#else //KAB_EMBEDDED 141#else //KAB_EMBEDDED
137qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); 142qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported");
138#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
139 144
140} 145}
141 146
142 147
143void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) 148void ColorListBox::dragLeaveEvent( QDragLeaveEvent * )
144{ 149{
145#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
146 151
147 if( mCurrentOnDragEnter != -1 ) 152 if( mCurrentOnDragEnter != -1 )
148 { 153 {
149 setCurrentItem( mCurrentOnDragEnter ); 154 setCurrentItem( mCurrentOnDragEnter );
150 mCurrentOnDragEnter = -1; 155 mCurrentOnDragEnter = -1;
151 } 156 }
152#else //KAB_EMBEDDED 157#else //KAB_EMBEDDED
153qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); 158qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported");
154#endif //KAB_EMBEDDED 159#endif //KAB_EMBEDDED
155} 160}
156 161
157 162
158void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) 163void ColorListBox::dragMoveEvent( QDragMoveEvent *e )
159{ 164{
160#ifndef KAB_EMBEDDED 165#ifndef KAB_EMBEDDED
161 if( KColorDrag::canDecode(e) && isEnabled() ) 166 if( KColorDrag::canDecode(e) && isEnabled() )
162 { 167 {
163 ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); 168 ColorListItem *item = (ColorListItem*)itemAt( e->pos() );
164 if( item != 0 ) 169 if( item != 0 )
165 { 170 {
166 setCurrentItem ( item ); 171 setCurrentItem ( item );
167 } 172 }
168 } 173 }
169#else //KAB_EMBEDDED 174#else //KAB_EMBEDDED
170qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); 175qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported");
171#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
172 177
173} 178}
174 179
175 180
176void ColorListBox::dropEvent( QDropEvent *e ) 181void ColorListBox::dropEvent( QDropEvent *e )
177{ 182{
178#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED
179 QColor color; 184 QColor color;
180 if( KColorDrag::decode( e, color ) ) 185 if( KColorDrag::decode( e, color ) )
181 { 186 {
182 int index = currentItem(); 187 int index = currentItem();
183 if( index != -1 ) 188 if( index != -1 )
184 { 189 {
185 ColorListItem *colorItem = (ColorListItem*)item(index); 190 ColorListItem *colorItem = (ColorListItem*)item(index);
186 colorItem->setColor(color); 191 colorItem->setColor(color);
187 triggerUpdate( false ); // Redraw item 192 triggerUpdate( false ); // Redraw item
188 } 193 }
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 )
214{ 219{
215 mColor = color; 220 mColor = color;
216} 221}
217 222
218 223
219void ColorListItem::paint( QPainter *p ) 224void 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
@@ -1,77 +1,82 @@
1/* 1/*
2 * kmail: KDE mail client 2 * kmail: KDE mail client
3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org 3 * This file: Copyright (C) 2000 Espen Sand, espen@kde.org
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
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#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
@@ -1,369 +1,372 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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
45#include <qpushbutton.h> 48#include <qpushbutton.h>
46#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
47 50
48#include "colorlistbox.h" 51#include "colorlistbox.h"
49 52
50#include "configurecardviewdialog.h" 53#include "configurecardviewdialog.h"
51 54
52///////////////////////////////// 55/////////////////////////////////
53// ConfigureCardViewDialog 56// ConfigureCardViewDialog
54 57
55ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, 58ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent,
56 const char *name ) 59 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 60 : ViewConfigureWidget( ab, parent, name )
58{ 61{
59#ifndef KAB_EMBEDDED 62#ifndef KAB_EMBEDDED
60 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
61 DesktopIcon( "looknfeel" ) ); 64 DesktopIcon( "looknfeel" ) );
62#else //KAB_EMBEDDED 65#else //KAB_EMBEDDED
63 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 66 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
64 KGlobal::iconLoader()->loadIcon( "looknfeel", 67 KGlobal::iconLoader()->loadIcon( "looknfeel",
65 KIcon::Panel ) ); 68 KIcon::Panel ) );
66#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
67 70
68 mAdvancedPage = new CardViewLookNFeelPage( page ); 71 mAdvancedPage = new CardViewLookNFeelPage( page );
69} 72}
70 73
71ConfigureCardViewWidget::~ConfigureCardViewWidget() 74ConfigureCardViewWidget::~ConfigureCardViewWidget()
72{ 75{
73} 76}
74 77
75void ConfigureCardViewWidget::restoreSettings( KConfig *config ) 78void ConfigureCardViewWidget::restoreSettings( KConfig *config )
76{ 79{
77 ViewConfigureWidget::restoreSettings( config ); 80 ViewConfigureWidget::restoreSettings( config );
78 81
79 mAdvancedPage->restoreSettings( config ); 82 mAdvancedPage->restoreSettings( 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 ) );
105 QColor c; 108 QColor c;
106qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); 109qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable");
107 110
108#ifndef KAB_EMBEDDED 111#ifndef KAB_EMBEDDED
109 c = KGlobalSettings::baseColor(); 112 c = KGlobalSettings::baseColor();
110#else //KAB_EMBEDDED 113#else //KAB_EMBEDDED
111 c = QColor(0,0,0); 114 c = QColor(0,0,0);
112#endif //KAB_EMBEDDED 115#endif //KAB_EMBEDDED
113 116
114 c = colorGroup().background(); 117 c = colorGroup().background();
115 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 118 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
116 config->readColorEntry( "BackgroundColor", &c ) ) ); 119 config->readColorEntry( "BackgroundColor", &c ) ) );
117 c = colorGroup().foreground(); 120 c = colorGroup().foreground();
118 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 121 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
119 config->readColorEntry( "TextColor", &c ) ) ); 122 config->readColorEntry( "TextColor", &c ) ) );
120 c = colorGroup().button(); 123 c = colorGroup().button();
121 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), 124 lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"),
122 config->readColorEntry( "HeaderColor", &c ) ) ); 125 config->readColorEntry( "HeaderColor", &c ) ) );
123 c = colorGroup().buttonText(); 126 c = colorGroup().buttonText();
124 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 127 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
125 config->readColorEntry( "HeaderTextColor", &c ) ) ); 128 config->readColorEntry( "HeaderTextColor", &c ) ) );
126 c = colorGroup().highlight(); 129 c = colorGroup().highlight();
127 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 130 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
128 config->readColorEntry( "HighlightColor", &c ) ) ); 131 config->readColorEntry( "HighlightColor", &c ) ) );
129 c = colorGroup().highlightedText(); 132 c = colorGroup().highlightedText();
130 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 133 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
131 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 134 config->readColorEntry( "HighlightedTextColor", &c ) ) );
132 135
133 enableColors(); 136 enableColors();
134 137
135 // fonts 138 // fonts
136 QFont fnt = font(); 139 QFont fnt = font();
137 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 140 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
138 fnt.setBold( true ); 141 fnt.setBold( true );
139 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 142 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
140 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 143 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
141 enableFonts(); 144 enableFonts();
142 145
143 // layout 146 // layout
144 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); 147 sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) );
145 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); 148 sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) );
146 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); 149 sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) );
147 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); 150 cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) );
148 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); 151 cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) );
149 152
150 // behaviour 153 // behaviour
151 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); 154 cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) );
152 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); 155 cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) );
153} 156}
154 157
155void CardViewLookNFeelPage::saveSettings( KConfig *config ) 158void CardViewLookNFeelPage::saveSettings( KConfig *config )
156{ 159{
157 // colors 160 // colors
158 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
159 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
160 { 163 {
161 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
162 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 165 config->writeEntry( "TextColor", lbColors->color( 1 ) );
163 config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); 166 config->writeEntry( "HeaderColor", lbColors->color( 2 ) );
164 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
165 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
166 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
167 } 170 }
168 // fonts 171 // fonts
169 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 172 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
170 if ( cbEnableCustomFonts->isChecked() ) 173 if ( cbEnableCustomFonts->isChecked() )
171 { 174 {
172 config->writeEntry( "TextFont", lTextFont->font() ); 175 config->writeEntry( "TextFont", lTextFont->font() );
173 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 176 config->writeEntry( "HeaderFont", lHeaderFont->font() );
174 } 177 }
175 // layout 178 // layout
176 config->writeEntry( "ItemMargin", sbMargin->value() ); 179 config->writeEntry( "ItemMargin", sbMargin->value() );
177 config->writeEntry( "ItemSpacing", sbSpacing->value() ); 180 config->writeEntry( "ItemSpacing", sbSpacing->value() );
178 config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); 181 config->writeEntry( "SeparatorWidth", sbSepWidth->value() );
179 config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); 182 config->writeEntry("DrawBorder", cbDrawBorders->isChecked());
180 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); 183 config->writeEntry("DrawSeparators", cbDrawSeps->isChecked());
181 184
182 // behaviour 185 // behaviour
183 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); 186 config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked());
184 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); 187 config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked());
185} 188}
186 189
187void CardViewLookNFeelPage::setTextFont() 190void CardViewLookNFeelPage::setTextFont()
188{ 191{
189 QFont f( lTextFont->font() ); 192 QFont f( lTextFont->font() );
190#ifndef KAB_EMBEDDED 193#ifndef KAB_EMBEDDED
191 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 194 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
192 updateFontLabel( f, lTextFont ); 195 updateFontLabel( f, lTextFont );
193#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
194 bool ok; 197 bool ok;
195 QFont fout = KFontDialog::getFont( f, ok); 198 QFont fout = KFontDialog::getFont( f, ok);
196 if ( ok ) 199 if ( ok )
197 updateFontLabel( fout, lTextFont ); 200 updateFontLabel( fout, lTextFont );
198#endif //KAB_EMBEDDED 201#endif //KAB_EMBEDDED
199} 202}
200 203
201void CardViewLookNFeelPage::setHeaderFont() 204void CardViewLookNFeelPage::setHeaderFont()
202{ 205{
203 QFont f( lHeaderFont->font() ); 206 QFont f( lHeaderFont->font() );
204#ifndef KAB_EMBEDDED 207#ifndef KAB_EMBEDDED
205 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 208 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
206 updateFontLabel( f, lHeaderFont ); 209 updateFontLabel( f, lHeaderFont );
207#else //KAB_EMBEDDED 210#else //KAB_EMBEDDED
208 bool ok; 211 bool ok;
209 QFont fout = KFontDialog::getFont( f, ok); 212 QFont fout = KFontDialog::getFont( f, ok);
210 if ( ok ) 213 if ( ok )
211 updateFontLabel( fout, lHeaderFont ); 214 updateFontLabel( fout, lHeaderFont );
212#endif //KAB_EMBEDDED 215#endif //KAB_EMBEDDED
213} 216}
214 217
215void CardViewLookNFeelPage::enableFonts() 218void CardViewLookNFeelPage::enableFonts()
216{ 219{
217 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 220 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
218 if ( cbEnableCustomFonts->isChecked() ) 221 if ( cbEnableCustomFonts->isChecked() )
219 vbFonts->setFocus(); 222 vbFonts->setFocus();
220} 223}
221 224
222void CardViewLookNFeelPage::enableColors() 225void CardViewLookNFeelPage::enableColors()
223{ 226{
224 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 227 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
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
@@ -1,117 +1,119 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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/**
44 Configure dialog for the card view. This dialog inherits from the 46 Configure dialog for the card view. This dialog inherits from the
45 standard view dialog in order to add a custom page for the card 47 standard view dialog in order to add a custom page for the card
46 view. 48 view.
47 */ 49 */
48class ConfigureCardViewWidget : public ViewConfigureWidget 50class ConfigureCardViewWidget : public ViewConfigureWidget
49{ 51{
50 public: 52 public:
51 ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ); 53 ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name );
52 virtual ~ConfigureCardViewWidget(); 54 virtual ~ConfigureCardViewWidget();
53 55
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 class CardViewLookNFeelPage *mAdvancedPage; 60 class CardViewLookNFeelPage *mAdvancedPage;
59}; 61};
60 62
61/** 63/**
62 Card View Advanced LookNFeel settings widget: 64 Card View Advanced LookNFeel settings widget:
63 this is a tabbed widget with 3 tabs: 65 this is a tabbed widget with 3 tabs:
64 Fonts 66 Fonts
65 * text font 67 * text font
66 * header font 68 * header font
67 69
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();
93 void setHeaderFont(); 95 void setHeaderFont();
94 void enableFonts(); 96 void enableFonts();
95 void enableColors(); 97 void enableColors();
96 98
97 private: 99 private:
98 void initGUI(); 100 void initGUI();
99 void updateFontLabel( QFont, QLabel * ); 101 void updateFontLabel( QFont, QLabel * );
100 102
101 QCheckBox *cbEnableCustomFonts, 103 QCheckBox *cbEnableCustomFonts,
102 *cbEnableCustomColors, 104 *cbEnableCustomColors,
103 *cbDrawSeps, *cbDrawBorders, 105 *cbDrawSeps, *cbDrawBorders,
104 *cbShowFieldLabels, *cbShowEmptyFields; 106 *cbShowFieldLabels, *cbShowEmptyFields;
105 class ColorListBox *lbColors; 107 class ColorListBox *lbColors;
106 QLabel *lTextFont, *lHeaderFont; 108 QLabel *lTextFont, *lHeaderFont;
107#ifndef KAB_EMBEDDED 109#ifndef KAB_EMBEDDED
108 class KPushButton *btnFont, *btnHeaderFont; 110 class KPushButton *btnFont, *btnHeaderFont;
109#else //KAB_EMBEDDED 111#else //KAB_EMBEDDED
110 class QPushButton *btnFont, *btnHeaderFont; 112 class QPushButton *btnFont, *btnHeaderFont;
111#endif //KAB_EMBEDDED 113#endif //KAB_EMBEDDED
112 class QSpinBox *sbMargin, *sbSpacing, *sbSepWidth; 114 class QSpinBox *sbMargin, *sbSpacing, *sbSepWidth;
113 115
114 class QWidget *vbFonts; 116 class QWidget *vbFonts;
115}; 117};
116 118
117#endif 119#endif
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
@@ -1,345 +1,348 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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
47 50
48#include <kconfig.h> 51#include <kconfig.h>
49 52
50#include "colorlistbox.h" 53#include "colorlistbox.h"
51 54
52#include "configuretableviewdialog.h" 55#include "configuretableviewdialog.h"
53 56
54ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, 57ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
55 QWidget *parent, 58 QWidget *parent,
56 const char *name ) 59 const char *name )
57 : ViewConfigureWidget( ab, parent, name ) 60 : ViewConfigureWidget( ab, parent, name )
58{ 61{
59 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 62 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
60 KGlobal::iconLoader()->loadIcon( "looknfeel", 63 KGlobal::iconLoader()->loadIcon( "looknfeel",
61 KIcon::Panel ) ); 64 KIcon::Panel ) );
62 65
63 mPage = new LookAndFeelPage( page ); 66 mPage = new LookAndFeelPage( page );
64} 67}
65 68
66ConfigureTableViewWidget::~ConfigureTableViewWidget() 69ConfigureTableViewWidget::~ConfigureTableViewWidget()
67{ 70{
68} 71}
69 72
70void ConfigureTableViewWidget::restoreSettings( KConfig *config ) 73void ConfigureTableViewWidget::restoreSettings( KConfig *config )
71{ 74{
72 ViewConfigureWidget::restoreSettings( config ); 75 ViewConfigureWidget::restoreSettings( config );
73 76
74 mPage->restoreSettings( config ); 77 mPage->restoreSettings( 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));
100 103
101 if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) 104 if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
102 mNoneButton->setChecked(true); 105 mNoneButton->setChecked(true);
103 106
104 mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); 107 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
105 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); 108 mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName"));
106 109
107 // colors 110 // colors
108 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); 111 cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) );
109 QColor c; 112 QColor c;
110 //qDebug("LookAndFeelPage::restoreSettings make base color configurable"); 113 //qDebug("LookAndFeelPage::restoreSettings make base color configurable");
111 114
112#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
113 c = KGlobalSettings::baseColor(); 116 c = KGlobalSettings::baseColor();
114#else //KAB_EMBEDDED 117#else //KAB_EMBEDDED
115 c = QColor(0,0,0); 118 c = QColor(0,0,0);
116#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED
117 120
118 c = colorGroup().background(); 121 c = colorGroup().background();
119 lbColors->insertItem( new ColorListItem( i18n("Background Color"), 122 lbColors->insertItem( new ColorListItem( i18n("Background Color"),
120 config->readColorEntry( "BackgroundColor", &c ) ) ); 123 config->readColorEntry( "BackgroundColor", &c ) ) );
121 c = colorGroup().foreground(); 124 c = colorGroup().foreground();
122 lbColors->insertItem( new ColorListItem( i18n("Text Color"), 125 lbColors->insertItem( new ColorListItem( i18n("Text Color"),
123 config->readColorEntry( "TextColor", &c ) ) ); 126 config->readColorEntry( "TextColor", &c ) ) );
124 c = colorGroup().button(); 127 c = colorGroup().button();
125 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), 128 lbColors->insertItem( new ColorListItem( i18n("Header Background Color"),
126 config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); 129 config->readColorEntry( "HeaderBackgroundColor", &c ) ) );
127 c = colorGroup().buttonText(); 130 c = colorGroup().buttonText();
128 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), 131 lbColors->insertItem( new ColorListItem( i18n("Header Text Color"),
129 config->readColorEntry( "HeaderTextColor", &c ) ) ); 132 config->readColorEntry( "HeaderTextColor", &c ) ) );
130 c = colorGroup().highlight(); 133 c = colorGroup().highlight();
131 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), 134 lbColors->insertItem( new ColorListItem( i18n("Highlight Color"),
132 config->readColorEntry( "HighlightColor", &c ) ) ); 135 config->readColorEntry( "HighlightColor", &c ) ) );
133 c = colorGroup().highlightedText(); 136 c = colorGroup().highlightedText();
134 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), 137 lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"),
135 config->readColorEntry( "HighlightedTextColor", &c ) ) ); 138 config->readColorEntry( "HighlightedTextColor", &c ) ) );
136 c = colorGroup().background(); 139 c = colorGroup().background();
137 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), 140 lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"),
138 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); 141 config->readColorEntry( "AlternatingBackgroundColor", &c ) ) );
139 142
140 enableColors(); 143 enableColors();
141 144
142 // fonts 145 // fonts
143 QFont fnt = font(); 146 QFont fnt = font();
144 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); 147 updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont );
145 fnt.setBold( true ); 148 fnt.setBold( true );
146 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); 149 updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont );
147 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); 150 cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) );
148 enableFonts(); 151 enableFonts();
149 152
150} 153}
151 154
152void LookAndFeelPage::saveSettings( KConfig *config ) 155void LookAndFeelPage::saveSettings( KConfig *config )
153{ 156{
154 config->writeEntry("ABackground", mAlternateButton->isChecked()); 157 config->writeEntry("ABackground", mAlternateButton->isChecked());
155 config->writeEntry("SingleLine", mLineButton->isChecked()); 158 config->writeEntry("SingleLine", mLineButton->isChecked());
156 config->writeEntry("ToolTips", mToolTipBox->isChecked()); 159 config->writeEntry("ToolTips", mToolTipBox->isChecked());
157 config->writeEntry("Background", mBackgroundBox->isChecked()); 160 config->writeEntry("Background", mBackgroundBox->isChecked());
158 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); 161 config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text());
159 162
160 // colors 163 // colors
161 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); 164 config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() );
162 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. 165 if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm.
163 { 166 {
164 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); 167 config->writeEntry( "BackgroundColor", lbColors->color( 0 ) );
165 config->writeEntry( "TextColor", lbColors->color( 1 ) ); 168 config->writeEntry( "TextColor", lbColors->color( 1 ) );
166 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); 169 config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) );
167 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); 170 config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
168 config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); 171 config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
169 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); 172 config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
170 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); 173 config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) );
171 } 174 }
172 // fonts 175 // fonts
173 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); 176 config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
174 if ( cbEnableCustomFonts->isChecked() ) 177 if ( cbEnableCustomFonts->isChecked() )
175 { 178 {
176 config->writeEntry( "TextFont", lTextFont->font() ); 179 config->writeEntry( "TextFont", lTextFont->font() );
177 config->writeEntry( "HeaderFont", lHeaderFont->font() ); 180 config->writeEntry( "HeaderFont", lHeaderFont->font() );
178 } 181 }
179 182
180} 183}
181 184
182void LookAndFeelPage::setTextFont() 185void LookAndFeelPage::setTextFont()
183{ 186{
184 QFont f( lTextFont->font() ); 187 QFont f( lTextFont->font() );
185#ifndef KAB_EMBEDDED 188#ifndef KAB_EMBEDDED
186 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) 189 if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
187 updateFontLabel( f, lTextFont ); 190 updateFontLabel( f, lTextFont );
188#else //KAB_EMBEDDED 191#else //KAB_EMBEDDED
189 bool ok; 192 bool ok;
190 QFont fout = KFontDialog::getFont( f, ok); 193 QFont fout = KFontDialog::getFont( f, ok);
191 if ( ok ) 194 if ( ok )
192 updateFontLabel( fout, lTextFont ); 195 updateFontLabel( fout, lTextFont );
193#endif //KAB_EMBEDDED 196#endif //KAB_EMBEDDED
194} 197}
195 198
196void LookAndFeelPage::setHeaderFont() 199void LookAndFeelPage::setHeaderFont()
197{ 200{
198 QFont f( lHeaderFont->font() ); 201 QFont f( lHeaderFont->font() );
199#ifndef KAB_EMBEDDED 202#ifndef KAB_EMBEDDED
200 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) 203 if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
201 updateFontLabel( f, lHeaderFont ); 204 updateFontLabel( f, lHeaderFont );
202#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
203 bool ok; 206 bool ok;
204 QFont fout = KFontDialog::getFont( f, ok); 207 QFont fout = KFontDialog::getFont( f, ok);
205 if ( ok ) 208 if ( ok )
206 updateFontLabel( fout, lHeaderFont ); 209 updateFontLabel( fout, lHeaderFont );
207#endif //KAB_EMBEDDED 210#endif //KAB_EMBEDDED
208} 211}
209 212
210void LookAndFeelPage::enableFonts() 213void LookAndFeelPage::enableFonts()
211{ 214{
212 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); 215 vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
213 if ( cbEnableCustomFonts->isChecked() ) 216 if ( cbEnableCustomFonts->isChecked() )
214 vbFonts->setFocus(); 217 vbFonts->setFocus();
215} 218}
216 219
217void LookAndFeelPage::enableColors() 220void LookAndFeelPage::enableColors()
218{ 221{
219 lbColors->setEnabled( cbEnableCustomColors->isChecked() ); 222 lbColors->setEnabled( cbEnableCustomColors->isChecked() );
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
250 mBackgroundBox->setEnabled( false ); 253 mBackgroundBox->setEnabled( false );
251 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); 254 mBackgroundName = new KURLRequester(generalTab, "mBackgroundName");
252#ifndef KAB_EMBEDDED 255#ifndef KAB_EMBEDDED
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
@@ -1,103 +1,105 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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;
42 44
43/** 45/**
44 Configure dialog for the table view. This dialog inherits from the 46 Configure dialog for the table view. This dialog inherits from the
45 standard view dialog in order to add a custom page for the table 47 standard view dialog in order to add a custom page for the table
46 view. 48 view.
47 */ 49 */
48class ConfigureTableViewWidget : public ViewConfigureWidget 50class ConfigureTableViewWidget : public ViewConfigureWidget
49{ 51{
50 public: 52 public:
51 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ); 53 ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name );
52 virtual ~ConfigureTableViewWidget(); 54 virtual ~ConfigureTableViewWidget();
53 55
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 );
79 void setTextFont(); 81 void setTextFont();
80 void setHeaderFont(); 82 void setHeaderFont();
81 void enableFonts(); 83 void enableFonts();
82 void enableColors(); 84 void enableColors();
83 85
84 private: 86 private:
85 void initGUI(); 87 void initGUI();
86 void updateFontLabel( QFont, QLabel * ); 88 void updateFontLabel( QFont, QLabel * );
87 89
88 QCheckBox *cbEnableCustomFonts, 90 QCheckBox *cbEnableCustomFonts,
89 *cbEnableCustomColors; 91 *cbEnableCustomColors;
90 class ColorListBox *lbColors; 92 class ColorListBox *lbColors;
91 QLabel *lTextFont, *lHeaderFont; 93 QLabel *lTextFont, *lHeaderFont;
92 class QPushButton *btnFont, *btnHeaderFont; 94 class QPushButton *btnFont, *btnHeaderFont;
93 class QWidget* vbFonts; 95 class QWidget* vbFonts;
94 96
95 QRadioButton *mAlternateButton; 97 QRadioButton *mAlternateButton;
96 QRadioButton *mLineButton; 98 QRadioButton *mLineButton;
97 QRadioButton *mNoneButton; 99 QRadioButton *mNoneButton;
98 QCheckBox *mToolTipBox; 100 QCheckBox *mToolTipBox;
99 KURLRequester *mBackgroundName; 101 KURLRequester *mBackgroundName;
100 QCheckBox *mBackgroundBox; 102 QCheckBox *mBackgroundBox;
101}; 103};
102 104
103#endif 105#endif
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
@@ -1,429 +1,435 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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
79 if (ishidden) { 85 if (ishidden) {
80 QString s; 86 QString s;
81 QRect r = plv->itemRect( lvi ); 87 QRect r = plv->itemRect( lvi );
82 r.moveBy( posVp.x(), posVp.y() ); 88 r.moveBy( posVp.x(), posVp.y() );
83 89
84 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() 90 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width()
85 // << "," << r.height() << endl; 91 // << "," << r.height() << endl;
86 92
87 KABC::Addressee a = plvi->addressee(); 93 KABC::Addressee a = plvi->addressee();
88 if (a.isEmpty()) 94 if (a.isEmpty())
89 return; 95 return;
90 96
91 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) 97 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel())
92 .arg(a.formattedName()); 98 .arg(a.formattedName());
93 99
94 s += '\n'; 100 s += '\n';
95 s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) 101 s += i18n("label: value", "%1: %2").arg(a.organizationLabel())
96 .arg(a.organization()); 102 .arg(a.organization());
97 103
98 QString notes = a.note().stripWhiteSpace(); 104 QString notes = a.note().stripWhiteSpace();
99 if ( !notes.isEmpty() ) { 105 if ( !notes.isEmpty() ) {
100 notes += '\n'; 106 notes += '\n';
101 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); 107 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel());
102 QFontMetrics fm( font() ); 108 QFontMetrics fm( font() );
103 109
104 // Begin word wrap code based on QMultiLineEdit code 110 // Begin word wrap code based on QMultiLineEdit code
105 int i = 0; 111 int i = 0;
106 bool doBreak = false; 112 bool doBreak = false;
107 int linew = 0; 113 int linew = 0;
108 int lastSpace = -1; 114 int lastSpace = -1;
109 int a = 0; 115 int a = 0;
110 int lastw = 0; 116 int lastw = 0;
111 117
112 while ( i < int(notes.length()) ) { 118 while ( i < int(notes.length()) ) {
113 doBreak = FALSE; 119 doBreak = FALSE;
114 if ( notes[i] != '\n' ) 120 if ( notes[i] != '\n' )
115 linew += fm.width( notes[i] ); 121 linew += fm.width( notes[i] );
116 122
117 if ( lastSpace >= a && notes[i] != '\n' ) 123 if ( lastSpace >= a && notes[i] != '\n' )
118 if (linew >= parentWidget()->width()) { 124 if (linew >= parentWidget()->width()) {
119 doBreak = TRUE; 125 doBreak = TRUE;
120 if ( lastSpace > a ) { 126 if ( lastSpace > a ) {
121 i = lastSpace; 127 i = lastSpace;
122 linew = lastw; 128 linew = lastw;
123 } 129 }
124 else 130 else
125 i = QMAX( a, i-1 ); 131 i = QMAX( a, i-1 );
126 } 132 }
127 133
128 if ( notes[i] == '\n' || doBreak ) { 134 if ( notes[i] == '\n' || doBreak ) {
129 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; 135 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n";
130 136
131 a = i + 1; 137 a = i + 1;
132 lastSpace = a; 138 lastSpace = a;
133 linew = 0; 139 linew = 0;
134 } 140 }
135 141
136 if ( notes[i].isSpace() ) { 142 if ( notes[i].isSpace() ) {
137 lastSpace = i; 143 lastSpace = i;
138 lastw = linew; 144 lastw = linew;
139 } 145 }
140 146
141 if ( lastSpace <= a ) { 147 if ( lastSpace <= a ) {
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;
213 219
214 if (parentListView->singleLine()) { 220 if (parentListView->singleLine()) {
215 p->setPen( parentListView->alternateColor() ); 221 p->setPen( parentListView->alternateColor() );
216 p->drawLine( 0, height() - 1, width, height() - 1 ); 222 p->drawLine( 0, height() - 1, width, height() - 1 );
217 } 223 }
218} 224}
219 225
220 226
221ContactListView *ContactListViewItem::parent() 227ContactListView *ContactListViewItem::parent()
222{ 228{
223 return parentListView; 229 return parentListView;
224} 230}
225 231
226 232
227void ContactListViewItem::refresh() 233void ContactListViewItem::refresh()
228{ 234{
229 // Update our addressee, since it may have changed else were 235 // Update our addressee, since it may have changed else were
230 mAddressee = mDocument->findByUid(mAddressee.uid()); 236 mAddressee = mDocument->findByUid(mAddressee.uid());
231 if (mAddressee.isEmpty()) 237 if (mAddressee.isEmpty())
232 return; 238 return;
233 239
234 int i = 0; 240 int i = 0;
235 KABC::Field::List::ConstIterator it; 241 KABC::Field::List::ConstIterator it;
236 for( it = mFields.begin(); it != mFields.end(); ++it ) { 242 for( it = mFields.begin(); it != mFields.end(); ++it ) {
237 setText( i++, (*it)->value( mAddressee ) ); 243 setText( i++, (*it)->value( mAddressee ) );
238 } 244 }
239} 245}
240 246
241/////////////////////////////// 247///////////////////////////////
242// ContactListView 248// ContactListView
243 249
244ContactListView::ContactListView(KAddressBookTableView *view, 250ContactListView::ContactListView(KAddressBookTableView *view,
245 KABC::AddressBook* /* doc */, 251 KABC::AddressBook* /* doc */,
246 QWidget *parent, 252 QWidget *parent,
247 const char *name ) 253 const char *name )
248 : KListView( parent, name ), 254 : KListView( parent, name ),
249 pabWidget( view ), 255 pabWidget( view ),
250 oldColumn( 0 ) 256 oldColumn( 0 )
251{ 257{
252 mFlagBlockKeyPressed = false; 258 mFlagBlockKeyPressed = false;
253 mFlagKeyPressed = false; 259 mFlagKeyPressed = false;
254 mABackground = true; 260 mABackground = true;
255 mSingleLine = false; 261 mSingleLine = false;
256 mToolTips = true; 262 mToolTips = true;
257 263
258 mAlternateColor = KGlobalSettings::alternateBackgroundColor(); 264 mAlternateColor = KGlobalSettings::alternateBackgroundColor();
259 265
260 266
261 267
262 268
263 setAlternateBackgroundEnabled(mABackground); 269 setAlternateBackgroundEnabled(mABackground);
264 setAcceptDrops( true ); 270 setAcceptDrops( true );
265 viewport()->setAcceptDrops( true ); 271 viewport()->setAcceptDrops( true );
266 setAllColumnsShowFocus( true ); 272 setAllColumnsShowFocus( true );
267 setShowSortIndicator(true); 273 setShowSortIndicator(true);
268 274
269 setSelectionModeExt( KListView::Extended ); 275 setSelectionModeExt( KListView::Extended );
270 setDropVisualizer(false); 276 setDropVisualizer(false);
271 // setFrameStyle(QFrame::NoFrame); 277 // setFrameStyle(QFrame::NoFrame);
272 //setLineWidth ( 0 ); 278 //setLineWidth ( 0 );
273 //setMidLineWidth ( 0 ); 279 //setMidLineWidth ( 0 );
274 //setMargin ( 0 ); 280 //setMargin ( 0 );
275#ifndef KAB_EMBEDDED 281#ifndef KAB_EMBEDDED
276 connect(this, SIGNAL(dropped(QDropEvent*)), 282 connect(this, SIGNAL(dropped(QDropEvent*)),
277 this, SLOT(itemDropped(QDropEvent*))); 283 this, SLOT(itemDropped(QDropEvent*)));
278#endif //KAB_EMBEDDED 284#endif //KAB_EMBEDDED
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 );
304 qDebug("scale %f ", scale); 310 qDebug("scale %f ", scale);
305 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 311 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
306 p.end(); 312 p.end();
307 qDebug("Why does it not print??? "); 313 qDebug("Why does it not print??? ");
308#endif 314#endif
309} 315}
310 316
311void ContactListView::setAlternateColor(const QColor &m_AlternateColor) 317void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
312{ 318{
313 mAlternateColor = m_AlternateColor; 319 mAlternateColor = m_AlternateColor;
314} 320}
315 321
316void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 322void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
317{ 323{
318 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); 324 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
319 325
320 // Get the brush, which will have the background pixmap if there is one. 326 // Get the brush, which will have the background pixmap if there is one.
321 if (b.pixmap()) 327 if (b.pixmap())
322 { 328 {
323 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), 329 p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
324 *(b.pixmap()), 330 *(b.pixmap()),
325 rect.left() + contentsX(), 331 rect.left() + contentsX(),
326 rect.top() + contentsY() ); 332 rect.top() + contentsY() );
327 } 333 }
328 334
329 else 335 else
330 { 336 {
331 // Do a normal paint 337 // Do a normal paint
332 KListView::paintEmptyArea(p, rect); 338 KListView::paintEmptyArea(p, rect);
333 } 339 }
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 )
369{ 375{
370 emit addresseeDropped(e); 376 emit addresseeDropped(e);
371} 377}
372 378
373void ContactListView::setAlternateBackgroundEnabled(bool enabled) 379void ContactListView::setAlternateBackgroundEnabled(bool enabled)
374{ 380{
375 mABackground = enabled; 381 mABackground = enabled;
376 382
377 if (mABackground) 383 if (mABackground)
378 { 384 {
379 setAlternateBackground(mAlternateColor); 385 setAlternateBackground(mAlternateColor);
380 } 386 }
381 else 387 else
382 { 388 {
383 setAlternateBackground(QColor()); 389 setAlternateBackground(QColor());
384 } 390 }
385} 391}
386 392
387void ContactListView::setBackgroundPixmap(const QString &filename) 393void ContactListView::setBackgroundPixmap(const QString &filename)
388{ 394{
389 if (filename.isEmpty()) 395 if (filename.isEmpty())
390 { 396 {
391 unsetPalette(); 397 unsetPalette();
392 } 398 }
393 else 399 else
394 { 400 {
395 qDebug("ContactListView::setBackgroundPixmap has to be verified"); 401 qDebug("ContactListView::setBackgroundPixmap has to be verified");
396//US setPaletteBackgroundPixmap(QPixmap(filename)); 402//US setPaletteBackgroundPixmap(QPixmap(filename));
397 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); 403 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename));
398 } 404 }
399 405
400} 406}
401 407
402void ContactListView::keyPressEvent ( QKeyEvent * e ) 408void ContactListView::keyPressEvent ( QKeyEvent * e )
403{ 409{
404 if ( mFlagBlockKeyPressed ) 410 if ( mFlagBlockKeyPressed )
405 return; 411 return;
406 qApp->processEvents(); 412 qApp->processEvents();
407 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 413 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
408 e->accept(); 414 e->accept();
409 return; 415 return;
410 } 416 }
411 if (! e->isAutoRepeat() ) 417 if (! e->isAutoRepeat() )
412 mFlagKeyPressed = true; 418 mFlagKeyPressed = true;
413 KListView::keyPressEvent ( e ); 419 KListView::keyPressEvent ( e );
414} 420}
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,134 +1,138 @@
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{
36 40
37public: 41public:
38 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, 42 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent,
39 KABC::AddressBook *doc, const KABC::Field::List &fields ); 43 KABC::AddressBook *doc, const KABC::Field::List &fields );
40 const KABC::Addressee &addressee() const { return mAddressee; } 44 const KABC::Addressee &addressee() const { return mAddressee; }
41 virtual void refresh(); 45 virtual void refresh();
42 virtual ContactListView* parent(); 46 virtual ContactListView* parent();
43 virtual QString key ( int, bool ) const; 47 virtual QString key ( int, bool ) const;
44 48
45 /** Adds the border around the cell if the user wants it. 49 /** Adds the border around the cell if the user wants it.
46 * This is how the single line config option is implemented. 50 * This is how the single line config option is implemented.
47 */ 51 */
48 virtual void paintCell(QPainter * p, const QColorGroup & cg, 52 virtual void paintCell(QPainter * p, const QColorGroup & cg,
49 int column, int width, int align ); 53 int column, int width, int align );
50 54
51private: 55private:
52 KABC::Addressee mAddressee; 56 KABC::Addressee mAddressee;
53 KABC::Field::List mFields; 57 KABC::Field::List mFields;
54 ContactListView *parentListView; 58 ContactListView *parentListView;
55 KABC::AddressBook *mDocument; 59 KABC::AddressBook *mDocument;
56}; 60};
57 61
58 62
59///////////////////////////////////////////// 63/////////////////////////////////////////////
60// ContactListView 64// ContactListView
61 65
62class ContactListView : public KListView 66class ContactListView : public KListView
63{ 67{
64 Q_OBJECT 68 Q_OBJECT
65 69
66public: 70public:
67 ContactListView(KAddressBookTableView *view, 71 ContactListView(KAddressBookTableView *view,
68 KABC::AddressBook *doc, 72 KABC::AddressBook *doc,
69 QWidget *parent, 73 QWidget *parent,
70 const char *name = 0L ); 74 const char *name = 0L );
71 virtual ~ContactListView() {} 75 virtual ~ContactListView() {}
72 //void resort(); 76 //void resort();
73 77
74 /** Returns true if tooltips should be displayed, false otherwise 78 /** Returns true if tooltips should be displayed, false otherwise
75 */ 79 */
76 bool tooltips() const { return mToolTips; } 80 bool tooltips() const { return mToolTips; }
77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } 81 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; }
78 82
79 bool alternateBackground() const { return mABackground; } 83 bool alternateBackground() const { return mABackground; }
80 void setAlternateBackgroundEnabled(bool enabled); 84 void setAlternateBackgroundEnabled(bool enabled);
81 85
82 bool singleLine() const { return mSingleLine; } 86 bool singleLine() const { return mSingleLine; }
83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } 87 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; }
84 88
85 const QColor &alternateColor() const { return mAlternateColor; } 89 const QColor &alternateColor() const { return mAlternateColor; }
86 void setAlternateColor(const QColor &mAlternateColor); 90 void setAlternateColor(const QColor &mAlternateColor);
87 91
88 /** Sets the background pixmap to <i>filename</i>. If the 92 /** Sets the background pixmap to <i>filename</i>. If the
89 * QString is empty (QString::isEmpty()), then the background 93 * QString is empty (QString::isEmpty()), then the background
90 * pixmap will be disabled. 94 * pixmap will be disabled.
91 */ 95 */
92 void setBackgroundPixmap(const QString &filename); 96 void setBackgroundPixmap(const QString &filename);
93 97
94protected: 98protected:
95 bool mFlagKeyPressed; 99 bool mFlagKeyPressed;
96 bool mFlagBlockKeyPressed; 100 bool mFlagBlockKeyPressed;
97 virtual void keyPressEvent ( QKeyEvent * ); 101 virtual void keyPressEvent ( QKeyEvent * );
98 virtual void keyReleaseEvent ( QKeyEvent * ); 102 virtual void keyReleaseEvent ( QKeyEvent * );
99 /** Paints the background pixmap in the empty area. This method is needed 103 /** Paints the background pixmap in the empty area. This method is needed
100 * since Qt::FixedPixmap will not scroll with the list view. 104 * since Qt::FixedPixmap will not scroll with the list view.
101 */ 105 */
102 virtual void paintEmptyArea( QPainter * p, const QRect & rect ); 106 virtual void paintEmptyArea( QPainter * p, const QRect & rect );
103 virtual void contentsMousePressEvent(QMouseEvent*); 107 virtual void contentsMousePressEvent(QMouseEvent*);
104 void contentsMouseMoveEvent( QMouseEvent *e ); 108 void contentsMouseMoveEvent( QMouseEvent *e );
105 void contentsDropEvent( QDropEvent *e ); 109 void contentsDropEvent( QDropEvent *e );
106 virtual bool acceptDrag(QDropEvent *e) const; 110 virtual bool acceptDrag(QDropEvent *e) const;
107 111
108protected slots: 112protected slots:
109 void itemDropped(QDropEvent *e); 113 void itemDropped(QDropEvent *e);
110 114
111public slots: 115public slots:
112 void printMe(); 116 void printMe();
113 117
114signals: 118signals:
115 void startAddresseeDrag(); 119 void startAddresseeDrag();
116 void addresseeDropped(QDropEvent *); 120 void addresseeDropped(QDropEvent *);
117 121
118private: 122private:
119 KAddressBookTableView *pabWidget; 123 KAddressBookTableView *pabWidget;
120 int oldColumn; 124 int oldColumn;
121 int column; 125 int column;
122 bool ascending; 126 bool ascending;
123 127
124 bool mABackground; 128 bool mABackground;
125 bool mSingleLine; 129 bool mSingleLine;
126 bool mToolTips; 130 bool mToolTips;
127 131
128 QColor mAlternateColor; 132 QColor mAlternateColor;
129 133
130 QPoint presspos; 134 QPoint presspos;
131}; 135};
132 136
133 137
134#endif 138#endif
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
@@ -1,525 +1,530 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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"
43 48
44#ifndef KAB_EMBEDDED 49#ifndef KAB_EMBEDDED
45extern "C" { 50extern "C" {
46 void *init_libkaddrbk_cardview() 51 void *init_libkaddrbk_cardview()
47 { 52 {
48 return ( new CardViewFactory ); 53 return ( new CardViewFactory );
49 } 54 }
50} 55}
51#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
52 57
53//////////////////////////////// 58////////////////////////////////
54// AddresseeCardViewItem (internal class) 59// AddresseeCardViewItem (internal class)
55class AddresseeCardViewItem : public CardViewItem 60class AddresseeCardViewItem : public CardViewItem
56{ 61{
57 public: 62 public:
58 AddresseeCardViewItem(const KABC::Field::List &fields, 63 AddresseeCardViewItem(const KABC::Field::List &fields,
59 bool showEmptyFields, 64 bool showEmptyFields,
60 KABC::AddressBook *doc, const KABC::Addressee &a, 65 KABC::AddressBook *doc, const KABC::Addressee &a,
61 CardView *parent) 66 CardView *parent)
62 : CardViewItem(parent, a.realName() ), 67 : CardViewItem(parent, a.realName() ),
63 mFields( fields ), mShowEmptyFields(showEmptyFields), 68 mFields( fields ), mShowEmptyFields(showEmptyFields),
64 mDocument(doc), mAddressee(a) 69 mDocument(doc), mAddressee(a)
65 { 70 {
66 if ( mFields.isEmpty() ) { 71 if ( mFields.isEmpty() ) {
67 mFields = KABC::Field::defaultFields(); 72 mFields = KABC::Field::defaultFields();
68 } 73 }
69 refresh(); 74 refresh();
70 } 75 }
71 76
72 const KABC::Addressee &addressee() const { return mAddressee; } 77 const KABC::Addressee &addressee() const { return mAddressee; }
73 78
74 void refresh() 79 void refresh()
75 { 80 {
76 // Update our addressee, since it may have changed elsewhere 81 // Update our addressee, since it may have changed elsewhere
77 mAddressee = mDocument->findByUid(mAddressee.uid()); 82 mAddressee = mDocument->findByUid(mAddressee.uid());
78 83
79 if (!mAddressee.isEmpty()) 84 if (!mAddressee.isEmpty())
80 { 85 {
81 clearFields(); 86 clearFields();
82 87
83 // Try all the selected fields until we find one with text. 88 // Try all the selected fields until we find one with text.
84 // This will limit the number of unlabeled icons in the view 89 // This will limit the number of unlabeled icons in the view
85 KABC::Field::List::Iterator iter; 90 KABC::Field::List::Iterator iter;
86 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 91 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
87 { 92 {
88 // insert empty fields or not? not doing so saves a bit of memory and CPU 93 // insert empty fields or not? not doing so saves a bit of memory and CPU
89 // (during geometry calculations), but prevents having equally 94 // (during geometry calculations), but prevents having equally
90 // wide label columns in all cards, unless CardViewItem/CardView search 95 // wide label columns in all cards, unless CardViewItem/CardView search
91 // globally for the widest label. (anders) 96 // globally for the widest label. (anders)
92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 97 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
93 insertField((*iter)->label(), (*iter)->value( mAddressee )); 98 insertField((*iter)->label(), (*iter)->value( mAddressee ));
94 } 99 }
95 100
96 // We might want to make this the first field. hmm... -mpilone 101 // We might want to make this the first field. hmm... -mpilone
97 setCaption( mAddressee.realName() ); 102 setCaption( mAddressee.realName() );
98 } 103 }
99 } 104 }
100 105
101 private: 106 private:
102 KABC::Field::List mFields; 107 KABC::Field::List mFields;
103 bool mShowEmptyFields; 108 bool mShowEmptyFields;
104 KABC::AddressBook *mDocument; 109 KABC::AddressBook *mDocument;
105 KABC::Addressee mAddressee; 110 KABC::Addressee mAddressee;
106}; 111};
107 112
108/////////////////////////////// 113///////////////////////////////
109// AddresseeCardView 114// AddresseeCardView
110 115
111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 116AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
112 : CardView(parent, name) 117 : CardView(parent, name)
113{ 118{
114 setAcceptDrops(true); 119 setAcceptDrops(true);
115} 120}
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()
164{ 169{
165 emit startAddresseeDrag(); 170 emit startAddresseeDrag();
166} 171}
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*)));
192 connect(mCardView, SIGNAL(startAddresseeDrag()), 197 connect(mCardView, SIGNAL(startAddresseeDrag()),
193 this, SIGNAL(startDrag())); 198 this, SIGNAL(startDrag()));
194 connect(this, SIGNAL(printView()), 199 connect(this, SIGNAL(printView()),
195 mCardView , SLOT(printMe())); 200 mCardView , SLOT(printMe()));
196} 201}
197 202
198KAddressBookCardView::~KAddressBookCardView() 203KAddressBookCardView::~KAddressBookCardView()
199{ 204{
200} 205}
201void KAddressBookCardView::setFocusAV() 206void KAddressBookCardView::setFocusAV()
202{ 207{
203 if ( mCardView ) 208 if ( mCardView )
204 mCardView->setFocus(); 209 mCardView->setFocus();
205 210
206} 211}
207void KAddressBookCardView::scrollUP() 212void KAddressBookCardView::scrollUP()
208{ 213{
209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 214 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
210 QApplication::postEvent( mCardView, ev ); 215 QApplication::postEvent( mCardView, ev );
211 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); 216 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
212 QApplication::postEvent( mCardView, ev ); 217 QApplication::postEvent( mCardView, ev );
213 218
214} 219}
215void KAddressBookCardView::scrollDOWN() 220void KAddressBookCardView::scrollDOWN()
216{ 221{
217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 222 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
218 QApplication::postEvent( mCardView, ev ); 223 QApplication::postEvent( mCardView, ev );
219 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); 224 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
220 QApplication::postEvent( mCardView, ev ); 225 QApplication::postEvent( mCardView, ev );
221} 226}
222void KAddressBookCardView::readConfig(KConfig *config) 227void KAddressBookCardView::readConfig(KConfig *config)
223{ 228{
224 KAddressBookView::readConfig(config); 229 KAddressBookView::readConfig(config);
225 230
226 // costum colors? 231 // costum colors?
227 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 232 if ( config->readBoolEntry( "EnableCustomColors", false ) )
228 { 233 {
229 QPalette p( mCardView->palette() ); 234 QPalette p( mCardView->palette() );
230 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 235 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
231 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 236 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::Text ); 237 c = p.color(QPalette::Normal, QColorGroup::Text );
233 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 238 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Button ); 239 c = p.color(QPalette::Normal, QColorGroup::Button );
235 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 240 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 241 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 242 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 243 c = p.color(QPalette::Normal, QColorGroup::Highlight );
239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 244 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 245 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 246 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
242 mCardView->viewport()->setPalette( p ); 247 mCardView->viewport()->setPalette( p );
243 } 248 }
244 else 249 else
245 { 250 {
246 // needed if turned off during a session. 251 // needed if turned off during a session.
247 mCardView->viewport()->setPalette( mCardView->palette() ); 252 mCardView->viewport()->setPalette( mCardView->palette() );
248 } 253 }
249 254
250 //custom fonts? 255 //custom fonts?
251 QFont f( font() ); 256 QFont f( font() );
252 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 257 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
253 { 258 {
254 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 259 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
255 f.setBold( true ); 260 f.setBold( true );
256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 261 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
257 } 262 }
258 else 263 else
259 { 264 {
260 mCardView->setFont( f ); 265 mCardView->setFont( f );
261 f.setBold( true ); 266 f.setBold( true );
262 mCardView->setHeaderFont( f ); 267 mCardView->setHeaderFont( f );
263 } 268 }
264 269
265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 270 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 271 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
267 true)); 272 true));
268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 273 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 274 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
270 275
271 mCardView->setShowEmptyFields( mShowEmptyFields ); 276 mCardView->setShowEmptyFields( mShowEmptyFields );
272 277
273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 278 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 279 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 280 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 281 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
277 282
278#if 0 283#if 0
279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 284 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 285 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 286 this, SLOT(addresseeExecuted(CardViewItem *)));
282 287
283 if (KABPrefs::instance()->mHonorSingleClick) 288 if (KABPrefs::instance()->mHonorSingleClick)
284 connect(mCardView, SIGNAL(executed(CardViewItem *)), 289 connect(mCardView, SIGNAL(executed(CardViewItem *)),
285 this, SLOT(addresseeExecuted(CardViewItem *))); 290 this, SLOT(addresseeExecuted(CardViewItem *)));
286 else 291 else
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 292 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 293 this, SLOT(addresseeExecuted(CardViewItem *)));
289#endif 294#endif
290 295
291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 296 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
292 this, SLOT(addresseeExecuted(CardViewItem *))); 297 this, SLOT(addresseeExecuted(CardViewItem *)));
293} 298}
294 299
295void KAddressBookCardView::writeConfig( KConfig *config ) 300void KAddressBookCardView::writeConfig( KConfig *config )
296{ 301{
297 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 302 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
298 KAddressBookView::writeConfig( config ); 303 KAddressBookView::writeConfig( config );
299} 304}
300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 305void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
301{ 306{
302 mCardView->clear(); 307 mCardView->clear();
303 if ( s.isEmpty() || s == "*" ) { 308 if ( s.isEmpty() || s == "*" ) {
304 refresh(); 309 refresh();
305 return; 310 return;
306 } 311 }
307 QRegExp re = getRegExp( s ); 312 QRegExp re = getRegExp( s );
308 if (!re.isValid()) 313 if (!re.isValid())
309 return; 314 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 315 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 316 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 317 KABC::Addressee::List::Iterator it;
313 if ( field ) { 318 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 319 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 320 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 321 continue;
317#if QT_VERSION >= 0x030000 322#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) == 0) 323 if (re.search(field->value( *it ).lower()) == 0)
319#else 324#else
320 if (re.match(field->value( *it ).lower()) == 0) 325 if (re.match(field->value( *it ).lower()) == 0)
321#endif 326#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 327 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 328 addressBook(), *it, mCardView);
324 329
325 } 330 }
326 } else { 331 } else {
327 KABC::Field::List fieldList = allFields(); 332 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 333 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 334 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 335 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 336 continue;
332 bool match = false; 337 bool match = false;
333 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 338 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
334#if QT_VERSION >= 0x030000 339#if QT_VERSION >= 0x030000
335 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 340 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
336#else 341#else
337 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 342 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
338#endif 343#endif
339 { 344 {
340 new AddresseeCardViewItem(fields(), mShowEmptyFields, 345 new AddresseeCardViewItem(fields(), mShowEmptyFields,
341 addressBook(), *it, mCardView); 346 addressBook(), *it, mCardView);
342 match = true; 347 match = true;
343 break; 348 break;
344 } 349 }
345 } 350 }
346 if ( ! match ) { 351 if ( ! match ) {
347 if ( (*it).matchPhoneNumber( &re ) ) { 352 if ( (*it).matchPhoneNumber( &re ) ) {
348 new AddresseeCardViewItem(fields(), mShowEmptyFields, 353 new AddresseeCardViewItem(fields(), mShowEmptyFields,
349 addressBook(), *it, mCardView); 354 addressBook(), *it, mCardView);
350 match = true; 355 match = true;
351 break; 356 break;
352 } 357 }
353 } 358 }
354 if ( ! match ) { 359 if ( ! match ) {
355 if ( (*it).matchAddress( &re ) ) { 360 if ( (*it).matchAddress( &re ) ) {
356 new AddresseeCardViewItem(fields(), mShowEmptyFields, 361 new AddresseeCardViewItem(fields(), mShowEmptyFields,
357 addressBook(), *it, mCardView); 362 addressBook(), *it, mCardView);
358 match = true; 363 match = true;
359 break; 364 break;
360 } 365 }
361 } 366 }
362 } 367 }
363 } 368 }
364 mCardView->viewport()->setUpdatesEnabled( true ); 369 mCardView->viewport()->setUpdatesEnabled( true );
365 mCardView->viewport()->update(); 370 mCardView->viewport()->update();
366 if ( mCardView->firstItem() ) { 371 if ( mCardView->firstItem() ) {
367 mCardView->setCurrentItem ( mCardView->firstItem() ); 372 mCardView->setCurrentItem ( mCardView->firstItem() );
368 mCardView->setSelected ( mCardView->firstItem() , true ); 373 mCardView->setSelected ( mCardView->firstItem() , true );
369 } 374 }
370 else 375 else
371 emit selected(QString::null); 376 emit selected(QString::null);
372} 377}
373QStringList KAddressBookCardView::selectedUids() 378QStringList KAddressBookCardView::selectedUids()
374{ 379{
375 QStringList uidList; 380 QStringList uidList;
376 CardViewItem *item; 381 CardViewItem *item;
377 AddresseeCardViewItem *aItem; 382 AddresseeCardViewItem *aItem;
378 383
379 for (item = mCardView->firstItem(); item; item = item->nextItem()) 384 for (item = mCardView->firstItem(); item; item = item->nextItem())
380 { 385 {
381 if (item->isSelected()) 386 if (item->isSelected())
382 { 387 {
383#ifndef KAB_EMBEDDED 388#ifndef KAB_EMBEDDED
384 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 389 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
385#else //KAB_EMBEDDED 390#else //KAB_EMBEDDED
386 aItem = (AddresseeCardViewItem*)(item); 391 aItem = (AddresseeCardViewItem*)(item);
387#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
388 if (aItem) 393 if (aItem)
389 uidList << aItem->addressee().uid(); 394 uidList << aItem->addressee().uid();
390 } 395 }
391 } 396 }
392 397
393 return uidList; 398 return uidList;
394} 399}
395 400
396void KAddressBookCardView::refresh(QString uid) 401void KAddressBookCardView::refresh(QString uid)
397{ 402{
398 CardViewItem *item; 403 CardViewItem *item;
399 AddresseeCardViewItem *aItem; 404 AddresseeCardViewItem *aItem;
400 405
401 if (uid.isNull()) 406 if (uid.isNull())
402 { 407 {
403 // Rebuild the view 408 // Rebuild the view
404 mCardView->viewport()->setUpdatesEnabled( false ); 409 mCardView->viewport()->setUpdatesEnabled( false );
405 mCardView->clear(); 410 mCardView->clear();
406 411
407 KABC::Addressee::List addresseeList = addressees(); 412 KABC::Addressee::List addresseeList = addressees();
408 KABC::Addressee::List::Iterator iter; 413 KABC::Addressee::List::Iterator iter;
409 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 414 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
410 { 415 {
411 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 416 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
412 continue; 417 continue;
413 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 418 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
414 addressBook(), *iter, mCardView); 419 addressBook(), *iter, mCardView);
415 } 420 }
416 mCardView->viewport()->setUpdatesEnabled( true ); 421 mCardView->viewport()->setUpdatesEnabled( true );
417 mCardView->viewport()->update(); 422 mCardView->viewport()->update();
418 423
419 // by default nothing is selected 424 // by default nothing is selected
420 emit selected(QString::null); 425 emit selected(QString::null);
421 } 426 }
422 else 427 else
423 { 428 {
424 // Try to find the one to refresh 429 // Try to find the one to refresh
425 bool found = false; 430 bool found = false;
426 for (item = mCardView->firstItem(); item && !found; 431 for (item = mCardView->firstItem(); item && !found;
427 item = item->nextItem()) 432 item = item->nextItem())
428 { 433 {
429#ifndef KAB_EMBEDDED 434#ifndef KAB_EMBEDDED
430 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 435 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
431#else //KAB_EMBEDDED 436#else //KAB_EMBEDDED
432 aItem = (AddresseeCardViewItem*)(item); 437 aItem = (AddresseeCardViewItem*)(item);
433#endif //KAB_EMBEDDED 438#endif //KAB_EMBEDDED
434 439
435 if ((aItem) && (aItem->addressee().uid() == uid)) 440 if ((aItem) && (aItem->addressee().uid() == uid))
436 { 441 {
437 aItem->refresh(); 442 aItem->refresh();
438 found = true; 443 found = true;
439 } 444 }
440 } 445 }
441 } 446 }
442} 447}
443 448
444void KAddressBookCardView::setSelected(QString uid, bool selected) 449void KAddressBookCardView::setSelected(QString uid, bool selected)
445{ 450{
446 CardViewItem *item; 451 CardViewItem *item;
447 AddresseeCardViewItem *aItem; 452 AddresseeCardViewItem *aItem;
448 453
449 if (uid.isNull()) 454 if (uid.isNull())
450 { 455 {
451 mCardView->selectAll(selected); 456 mCardView->selectAll(selected);
452 } 457 }
453 else 458 else
454 { 459 {
455 bool found = false; 460 bool found = false;
456 for (item = mCardView->firstItem(); item && !found; 461 for (item = mCardView->firstItem(); item && !found;
457 item = item->nextItem()) 462 item = item->nextItem())
458 { 463 {
459#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
460 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 465 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
461#else //KAB_EMBEDDED 466#else //KAB_EMBEDDED
462 aItem = (AddresseeCardViewItem*)(item); 467 aItem = (AddresseeCardViewItem*)(item);
463#endif //KAB_EMBEDDED 468#endif //KAB_EMBEDDED
464 469
465 if ((aItem) && (aItem->addressee().uid() == uid)) 470 if ((aItem) && (aItem->addressee().uid() == uid))
466 { 471 {
467 mCardView->setSelected(aItem, selected); 472 mCardView->setSelected(aItem, selected);
468 mCardView->ensureItemVisible(item); 473 mCardView->ensureItemVisible(item);
469 found = true; 474 found = true;
470 } 475 }
471 } 476 }
472 } 477 }
473} 478}
474 479
475//US added an additional method without parameter 480//US added an additional method without parameter
476void KAddressBookCardView::setSelected() 481void KAddressBookCardView::setSelected()
477{ 482{
478 setSelected(QString::null, true); 483 setSelected(QString::null, true);
479} 484}
480 485
481void KAddressBookCardView::addresseeExecuted(CardViewItem *item) 486void KAddressBookCardView::addresseeExecuted(CardViewItem *item)
482{ 487{
483#ifndef KAB_EMBEDDED 488#ifndef KAB_EMBEDDED
484 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); 489 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item);
485#else //KAB_EMBEDDED 490#else //KAB_EMBEDDED
486 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); 491 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item);
487#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
488 if (aItem) 493 if (aItem)
489 { 494 {
490 //kdDebug()<<"... even has a valid item:)"<<endl; 495 //kdDebug()<<"... even has a valid item:)"<<endl;
491 emit executed(aItem->addressee().uid()); 496 emit executed(aItem->addressee().uid());
492 } 497 }
493} 498}
494 499
495void KAddressBookCardView::addresseeSelected() 500void KAddressBookCardView::addresseeSelected()
496{ 501{
497 CardViewItem *item; 502 CardViewItem *item;
498 AddresseeCardViewItem *aItem; 503 AddresseeCardViewItem *aItem;
499 504
500 bool found = false; 505 bool found = false;
501 for (item = mCardView->firstItem(); item && !found; 506 for (item = mCardView->firstItem(); item && !found;
502 item = item->nextItem()) 507 item = item->nextItem())
503 { 508 {
504 if (item->isSelected()) 509 if (item->isSelected())
505 { 510 {
506#ifndef KAB_EMBEDDED 511#ifndef KAB_EMBEDDED
507 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 512 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
508#else //KAB_EMBEDDED 513#else //KAB_EMBEDDED
509 aItem = (AddresseeCardViewItem*)(item); 514 aItem = (AddresseeCardViewItem*)(item);
510#endif //KAB_EMBEDDED 515#endif //KAB_EMBEDDED
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
@@ -1,122 +1,125 @@
1#ifndef KADDRESSBOOKCARDVIEW_H 1#ifndef KADDRESSBOOKCARDVIEW_H
2#define KADDRESSBOOKCARDVIEW_H 2#define KADDRESSBOOKCARDVIEW_H
3 3
4/* 4/*
5 This file is part of KAddressBook. 5 This file is part of KAddressBook.
6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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;
40class QDropEvent; 43class QDropEvent;
41class KConfig; 44class KConfig;
42class AddresseeCardView; 45class AddresseeCardView;
43 46
44/** 47/**
45 This view uses the CardView class to create a card view. At some 48 This view uses the CardView class to create a card view. At some
46 point in the future I think this will be the default view of 49 point in the future I think this will be the default view of
47 KAddressBook. 50 KAddressBook.
48 */ 51 */
49class KAddressBookCardView : public KAddressBookView 52class KAddressBookCardView : public KAddressBookView
50{ 53{
51 Q_OBJECT 54 Q_OBJECT
52 55
53 public: 56 public:
54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, 57 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent,
55 const char *name = 0 ); 58 const char *name = 0 );
56 virtual ~KAddressBookCardView(); 59 virtual ~KAddressBookCardView();
57 void doSearch( const QString& s,KABC::Field *field ); 60 void doSearch( const QString& s,KABC::Field *field );
58 virtual QStringList selectedUids(); 61 virtual QStringList selectedUids();
59 virtual QString type() const { return "Card"; } 62 virtual QString type() const { return "Card"; }
60 63
61 virtual void readConfig(KConfig *config); 64 virtual void readConfig(KConfig *config);
62 virtual void writeConfig(KConfig *); 65 virtual void writeConfig(KConfig *);
63 virtual void scrollUP(); 66 virtual void scrollUP();
64 virtual void scrollDOWN(); 67 virtual void scrollDOWN();
65 virtual void setFocusAV(); 68 virtual void setFocusAV();
66 69
67 public slots: 70 public slots:
68 void refresh(QString uid = QString::null); 71 void refresh(QString uid = QString::null);
69 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); 72 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
70//US added an additional method without parameter 73//US added an additional method without parameter
71 void setSelected(); 74 void setSelected();
72 75
73 protected slots: 76 protected slots:
74 void addresseeExecuted(CardViewItem *item); 77 void addresseeExecuted(CardViewItem *item);
75 void addresseeSelected(); 78 void addresseeSelected();
76 79
77 private: 80 private:
78 AddresseeCardView *mCardView; 81 AddresseeCardView *mCardView;
79 bool mShowEmptyFields; 82 bool mShowEmptyFields;
80}; 83};
81 84
82class AddresseeCardView : public CardView 85class AddresseeCardView : public CardView
83{ 86{
84 Q_OBJECT 87 Q_OBJECT
85 public: 88 public:
86 AddresseeCardView(QWidget *parent, const char *name = 0); 89 AddresseeCardView(QWidget *parent, const char *name = 0);
87 ~AddresseeCardView(); 90 ~AddresseeCardView();
88public slots: 91public slots:
89 void printMe(); 92 void printMe();
90 93
91 signals: 94 signals:
92 void startAddresseeDrag(); 95 void startAddresseeDrag();
93 void addresseeDropped(QDropEvent *); 96 void addresseeDropped(QDropEvent *);
94 97
95 protected: 98 protected:
96 virtual void dragEnterEvent(QDragEnterEvent *); 99 virtual void dragEnterEvent(QDragEnterEvent *);
97 virtual void dropEvent(QDropEvent *); 100 virtual void dropEvent(QDropEvent *);
98 virtual void startDrag(); 101 virtual void startDrag();
99}; 102};
100 103
101 104
102class CardViewFactory : public ViewFactory 105class CardViewFactory : public ViewFactory
103{ 106{
104 public: 107 public:
105 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 108 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
106 { 109 {
107 return new KAddressBookCardView( ab, parent, name ); 110 return new KAddressBookCardView( ab, parent, name );
108 } 111 }
109 112
110 QString type() const { return "Card"; } 113 QString type() const { return "Card"; }
111 114
112 QString description() const { return i18n( "Rolodex style cards represent contacts." ); } 115 QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
113 116
114 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 117 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
115 const char *name = 0 ) 118 const char *name = 0 )
116 { 119 {
117 return new ConfigureCardViewWidget( ab, parent, name ); 120 return new ConfigureCardViewWidget( ab, parent, name );
118 } 121 }
119}; 122};
120 123
121 124
122#endif 125#endif
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
@@ -1,481 +1,489 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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:
50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 58 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
51 { 59 {
52 return new KAddressBookIconView( ab, parent, name ); 60 return new KAddressBookIconView( ab, parent, name );
53 } 61 }
54 62
55 QString type() const { return "Icon"; } 63 QString type() const { return "Icon"; }
56 64
57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 65 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
58}; 66};
59 67
60*/ 68*/
61 69
62extern "C" { 70extern "C" {
63 void *init_libkaddrbk_iconview() 71 void *init_libkaddrbk_iconview()
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 {
146 // Update our addressee, since it may have changed elsewhere 154 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 155 mAddressee = mDocument->findByUid(mAddressee.uid());
148 156
149 if (!mAddressee.isEmpty()) 157 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 158 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 159
152 QPixmap icon; 160 QPixmap icon;
153 161
154 KABC::Picture pic = mAddressee.photo(); 162 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 163 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 164 pic = mAddressee.logo();
157 165
158 if ( pic.isIntern() && !pic.data().isNull() ) { 166 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 167 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 168#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 169 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 170 icon = img.scaleWidth( 32 );
163 else 171 else
164 icon = img.scaleHeight( 32 ); 172 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 173#else //KAB_EMBEDDED
166 174
167 int wid = pic.data().width(); 175 int wid = pic.data().width();
168 int hei = pic.data().height(); 176 int hei = pic.data().height();
169 int max = 48; 177 int max = 48;
170 if ( wid > max || hei > max ) { 178 if ( wid > max || hei > max ) {
171 if ( wid > hei ) { 179 if ( wid > hei ) {
172 hei = (hei*max)/wid; 180 hei = (hei*max)/wid;
173 wid = max; 181 wid = max;
174 } else { 182 } else {
175 wid = (wid*max)/hei; 183 wid = (wid*max)/hei;
176 hei = max; 184 hei = max;
177 } 185 }
178 } 186 }
179 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 187 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
180 icon.convertFromImage(img.smoothScale(wid, hei)); 188 icon.convertFromImage(img.smoothScale(wid, hei));
181#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
182 190
183 } else { 191 } else {
184 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ); 192 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 );
185 } 193 }
186 setPixmap( icon ); 194 setPixmap( icon );
187 } 195 }
188 196
189 private: 197 private:
190 KABC::Field::List mFields; 198 KABC::Field::List mFields;
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}
227void KAddressBookIconView::setFocusAV() 235void KAddressBookIconView::setFocusAV()
228{ 236{
229 if ( mIconView ) 237 if ( mIconView )
230 mIconView->setFocus(); 238 mIconView->setFocus();
231} 239}
232 240
233 241
234void KAddressBookIconView::scrollUP() 242void KAddressBookIconView::scrollUP()
235{ 243{
236 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 244 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
237 QApplication::postEvent( mIconView, ev ); 245 QApplication::postEvent( mIconView, ev );
238} 246}
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())
277 return; 285 return;
278 KABC::Addressee::List addresseeList = addressees(); 286 KABC::Addressee::List addresseeList = addressees();
279 KABC::Addressee::List::Iterator it; 287 KABC::Addressee::List::Iterator it;
280 if ( field ) { 288 if ( field ) {
281 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 289 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
282 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 290 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
283 continue; 291 continue;
284#if QT_VERSION >= 0x030000 292#if QT_VERSION >= 0x030000
285 if (re.search(field->value( *it ).lower()) == 0) 293 if (re.search(field->value( *it ).lower()) == 0)
286#else 294#else
287 if (re.match(field->value( *it ).lower()) == 0) 295 if (re.match(field->value( *it ).lower()) == 0)
288#endif 296#endif
289 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 297 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
290 298
291 299
292 } 300 }
293 } else { 301 } else {
294 KABC::Field::List fieldList = allFields(); 302 KABC::Field::List fieldList = allFields();
295 KABC::Field::List::ConstIterator fieldIt; 303 KABC::Field::List::ConstIterator fieldIt;
296 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 304 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
297 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 305 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
298 continue; 306 continue;
299 bool match = false; 307 bool match = false;
300 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 308 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
301#if QT_VERSION >= 0x030000 309#if QT_VERSION >= 0x030000
302 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 310 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
303#else 311#else
304 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 312 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
305#endif 313#endif
306 { 314 {
307 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 315 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
308 match = true; 316 match = true;
309 break; 317 break;
310 } 318 }
311 } 319 }
312 if ( ! match ) { 320 if ( ! match ) {
313 if ( (*it).matchPhoneNumber( &re ) ) { 321 if ( (*it).matchPhoneNumber( &re ) ) {
314 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 322 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
315 match = true; 323 match = true;
316 break; 324 break;
317 } 325 }
318 } 326 }
319 if ( ! match ) { 327 if ( ! match ) {
320 if ( (*it).matchAddress( &re ) ) { 328 if ( (*it).matchAddress( &re ) ) {
321 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 329 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
322 match = true; 330 match = true;
323 break; 331 break;
324 } 332 }
325 } 333 }
326 } 334 }
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;
374 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 382 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
375 } 383 }
376 384
377 mIconView->arrangeItemsInGrid( true ); 385 mIconView->arrangeItemsInGrid( true );
378 386
379 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 387 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
380 { 388 {
381#ifndef KAB_EMBEDDED 389#ifndef KAB_EMBEDDED
382 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 390 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
383#else //KAB_EMBEDDED 391#else //KAB_EMBEDDED
384 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 392 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
385#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
386 mIconList.append( aivi ); 394 mIconList.append( aivi );
387 } 395 }
388 396
389 } else { 397 } else {
390 // Try to find the one to refresh 398 // Try to find the one to refresh
391 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 399 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
392#ifndef KAB_EMBEDDED 400#ifndef KAB_EMBEDDED
393 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 401 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
394#else //KAB_EMBEDDED 402#else //KAB_EMBEDDED
395 aItem = (AddresseeIconViewItem*)(item); 403 aItem = (AddresseeIconViewItem*)(item);
396#endif //KAB_EMBEDDED 404#endif //KAB_EMBEDDED
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 {
422#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
423 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 431 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
424#else //KAB_EMBEDDED 432#else //KAB_EMBEDDED
425 aItem = (AddresseeIconViewItem*)(item); 433 aItem = (AddresseeIconViewItem*)(item);
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);
466#endif //KAB_EMBEDDED 474#endif //KAB_EMBEDDED
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
@@ -1,134 +1,137 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
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 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
54 public: 57 public:
55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, 58 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 59 const char *name = 0 );
57 virtual ~KAddressBookIconView(); 60 virtual ~KAddressBookIconView();
58 61
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
124 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 127 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
125}; 128};
126/* 129/*
127extern "C" { 130extern "C" {
128 void *init_libkaddrbk_iconview() 131 void *init_libkaddrbk_iconview()
129 { 132 {
130 return ( new IconViewFactory ); 133 return ( new IconViewFactory );
131 } 134 }
132} 135}
133*/ 136*/
134#endif 137#endif
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,492 +1,496 @@
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();
58 62
59} 63}
60void KAddressBookTableView::scrollUP() 64void KAddressBookTableView::scrollUP()
61{ 65{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 66 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 67 QApplication::postEvent( mListView, ev );
64 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); 68 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
65 QApplication::postEvent( mListView, ev ); 69 QApplication::postEvent( mListView, ev );
66} 70}
67void KAddressBookTableView::scrollDOWN() 71void 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
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 147void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 148{
145 mListView->clear(); 149 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 150 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 151 refresh();
148 return; 152 return;
149 } 153 }
150 QRegExp re = getRegExp( s ); 154 QRegExp re = getRegExp( s );
151 if (!re.isValid()) 155 if (!re.isValid())
152 return; 156 return;
153 KABC::Addressee::List addresseeList = addressees(); 157 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 158 KABC::Addressee::List::Iterator it;
155 if ( field ) { 159 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 160 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 161 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 162 continue;
159#if QT_VERSION >= 0x030000 163#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 164 if (re.search(field->value( *it ).lower()) == 0)
161#else 165#else
162 if (re.match(field->value( *it ).lower()) == 0) 166 if (re.match(field->value( *it ).lower()) == 0)
163#endif 167#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 168 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 169
166 } 170 }
167 } else { 171 } else {
168 KABC::Field::List fieldList = allFields(); 172 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 173 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 174 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 175 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 176 continue;
173 bool match = false; 177 bool match = false;
174 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 178 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
175#if QT_VERSION >= 0x030000 179#if QT_VERSION >= 0x030000
176 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 180 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
177#else 181#else
178 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 182 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
179#endif 183#endif
180 { 184 {
181 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); 185 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
182 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 186 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
183 match = true; 187 match = true;
184 break; 188 break;
185 } 189 }
186 } 190 }
187 if ( ! match ) { 191 if ( ! match ) {
188 if ( (*it).matchPhoneNumber( &re ) ) { 192 if ( (*it).matchPhoneNumber( &re ) ) {
189 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 193 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
190 match = true; 194 match = true;
191 break; 195 break;
192 } 196 }
193 } 197 }
194 if ( ! match ) { 198 if ( ! match ) {
195 if ( (*it).matchAddress( &re ) ) { 199 if ( (*it).matchAddress( &re ) ) {
196 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 200 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
197 match = true; 201 match = true;
198 break; 202 break;
199 } 203 }
200 } 204 }
201 } 205 }
202 } 206 }
203 // Sometimes the background pixmap gets messed up when we add lots 207 // Sometimes the background pixmap gets messed up when we add lots
204 // of items. 208 // of items.
205 //mListView->repaint(); 209 //mListView->repaint();
206 if ( mListView->firstChild() ) { 210 if ( mListView->firstChild() ) {
207 mListView->setCurrentItem ( mListView->firstChild() ); 211 mListView->setCurrentItem ( mListView->firstChild() );
208 mListView->setSelected ( mListView->firstChild(), true ); 212 mListView->setSelected ( mListView->firstChild(), true );
209 } 213 }
210 else 214 else
211 emit selected(QString::null); 215 emit selected(QString::null);
212 216
213} 217}
214void KAddressBookTableView::writeConfig(KConfig *config) 218void KAddressBookTableView::writeConfig(KConfig *config)
215{ 219{
216 KAddressBookView::writeConfig(config); 220 KAddressBookView::writeConfig(config);
217 221
218 mListView->saveLayout(config, config->group()); 222 mListView->saveLayout(config, config->group());
219} 223}
220 224
221void KAddressBookTableView::readConfig(KConfig *config) 225void KAddressBookTableView::readConfig(KConfig *config)
222{ 226{
223 KAddressBookView::readConfig( config ); 227 KAddressBookView::readConfig( config );
224 // The config could have changed the fields, so we need to reconstruct 228 // The config could have changed the fields, so we need to reconstruct
225 // the listview. 229 // the listview.
226 reconstructListView(); 230 reconstructListView();
227 231
228 // costum colors? 232 // costum colors?
229 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 233 if ( config->readBoolEntry( "EnableCustomColors", false ) )
230 { 234 {
231 QPalette p( mListView->palette() ); 235 QPalette p( mListView->palette() );
232 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 236 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
233 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Text ); 238 c = p.color(QPalette::Normal, QColorGroup::Text );
235 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::Button ); 240 c = p.color(QPalette::Normal, QColorGroup::Button );
237 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 242 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
239 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 243 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 244 c = p.color(QPalette::Normal, QColorGroup::Highlight );
241 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 245 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
242 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 246 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
243 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 247 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
244#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED
245 c = KGlobalSettings::alternateBackgroundColor(); 249 c = KGlobalSettings::alternateBackgroundColor();
246#else //KAB_EMBEDDED 250#else //KAB_EMBEDDED
247 c = QColor(240, 240, 240); 251 c = QColor(240, 240, 240);
248#endif //KAB_EMBEDDED 252#endif //KAB_EMBEDDED
249 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 253 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
250 mListView->setAlternateColor(c); 254 mListView->setAlternateColor(c);
251 255
252 256
253 //US mListView->viewport()->setPalette( p ); 257 //US mListView->viewport()->setPalette( p );
254 mListView->setPalette( p ); 258 mListView->setPalette( p );
255 } 259 }
256 else 260 else
257 { 261 {
258 // needed if turned off during a session. 262 // needed if turned off during a session.
259 //US mListView->viewport()->setPalette( mListView->palette() ); 263 //US mListView->viewport()->setPalette( mListView->palette() );
260 mListView->setPalette( mListView->palette() ); 264 mListView->setPalette( mListView->palette() );
261 } 265 }
262 266
263 //custom fonts? 267 //custom fonts?
264 QFont f( font() ); 268 QFont f( font() );
265 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 269 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
266 { 270 {
267 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 271 mListView->setFont( config->readFontEntry( "TextFont", &f) );
268 f.setBold( true ); 272 f.setBold( true );
269 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 273 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
270 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 274 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
271 } 275 }
272 else 276 else
273 { 277 {
274 mListView->setFont( f ); 278 mListView->setFont( f );
275 f.setBold( true ); 279 f.setBold( true );
276 //US mListView->setHeaderFont( f ); 280 //US mListView->setHeaderFont( f );
277 mListView->header()->setFont( f ); 281 mListView->header()->setFont( f );
278 } 282 }
279 283
280 // Set the list view options 284 // Set the list view options
281 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 285 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
282 true)); 286 true));
283 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 287 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
284 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 288 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
285 289
286 if (config->readBoolEntry("Background", false)) 290 if (config->readBoolEntry("Background", false))
287 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 291 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
288 292
289 // Restore the layout of the listview 293 // Restore the layout of the listview
290 mListView->restoreLayout(config, config->group()); 294 mListView->restoreLayout(config, config->group());
291} 295}
292 296
293void KAddressBookTableView::refresh(QString uid) 297void KAddressBookTableView::refresh(QString uid)
294{ 298{
295 // For now just repopulate. In reality this method should 299 // For now just repopulate. In reality this method should
296 // check the value of uid, and if valid iterate through 300 // check the value of uid, and if valid iterate through
297 // the listview to find the entry, then tell it to refresh. 301 // the listview to find the entry, then tell it to refresh.
298 302
299 if (uid.isNull()) { 303 if (uid.isNull()) {
300 // Clear the list view 304 // Clear the list view
301 QString currentUID, nextUID; 305 QString currentUID, nextUID;
302#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
303 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 307 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
304#else //KAB_EMBEDDED 308#else //KAB_EMBEDDED
305 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 309 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
306#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
307 311
308 if ( currentItem ) { 312 if ( currentItem ) {
309#ifndef KAB_EMBEDDED 313#ifndef KAB_EMBEDDED
310 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 314 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
311#else //KAB_EMBEDDED 315#else //KAB_EMBEDDED
312 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 316 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
313#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
314 if ( nextItem ) 318 if ( nextItem )
315 nextUID = nextItem->addressee().uid(); 319 nextUID = nextItem->addressee().uid();
316 currentUID = currentItem->addressee().uid(); 320 currentUID = currentItem->addressee().uid();
317 } 321 }
318 322
319 mListView->clear(); 323 mListView->clear();
320 324
321 currentItem = 0; 325 currentItem = 0;
322 KABC::Addressee::List addresseeList = addressees(); 326 KABC::Addressee::List addresseeList = addressees();
323 KABC::Addressee::List::Iterator it; 327 KABC::Addressee::List::Iterator it;
324 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 328 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
325 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 329 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
326 continue; 330 continue;
327 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 331 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
328 if ( (*it).uid() == currentUID ) 332 if ( (*it).uid() == currentUID )
329 currentItem = item; 333 currentItem = item;
330 else if ( (*it).uid() == nextUID && !currentItem ) 334 else if ( (*it).uid() == nextUID && !currentItem )
331 currentItem = item; 335 currentItem = item;
332 } 336 }
333 337
334 // Sometimes the background pixmap gets messed up when we add lots 338 // Sometimes the background pixmap gets messed up when we add lots
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
382 if (ceItem != 0L) 386 if (ceItem != 0L)
383 uidList << ceItem->addressee().uid(); 387 uidList << ceItem->addressee().uid();
384 } 388 }
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);
410#else //KAB_EMBEDDED 414#else //KAB_EMBEDDED
411 ceItem = (ContactListViewItem*)(item); 415 ceItem = (ContactListViewItem*)(item);
412#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
413 417
414 418
415 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 419 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
416 { 420 {
417 mListView->setSelected(item, selected); 421 mListView->setSelected(item, selected);
418 422
419 if (selected) 423 if (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)
469 { 473 {
470 emit executed(ceItem->addressee().uid()); 474 emit executed(ceItem->addressee().uid());
471 } 475 }
472 } 476 }
473 else 477 else
474 { 478 {
475 emit executed(QString::null); 479 emit executed(QString::null);
476 } 480 }
477} 481}
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,118 +1,120 @@
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 *
44 * @short Table View 46 * @short Table View
45 * @author Don Sanders <dsanders@kde.org> 47 * @author Don Sanders <dsanders@kde.org>
46 * @version 0.1 48 * @version 0.1
47 */ 49 */
48class KAddressBookTableView : public KAddressBookView 50class KAddressBookTableView : public KAddressBookView
49{ 51{
50friend class ContactListView; 52friend class ContactListView;
51 53
52 Q_OBJECT 54 Q_OBJECT
53 55
54 public: 56 public:
55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, 57 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 58 const char *name = 0 );
57 virtual ~KAddressBookTableView(); 59 virtual ~KAddressBookTableView();
58 60
59 virtual void refresh(QString uid = QString::null); 61 virtual void refresh(QString uid = QString::null);
60 virtual QStringList selectedUids(); 62 virtual QStringList selectedUids();
61 virtual void setSelected(QString uid = QString::null, bool selected = false); 63 virtual void setSelected(QString uid = QString::null, bool selected = false);
62 virtual void readConfig(KConfig *config); 64 virtual void readConfig(KConfig *config);
63 virtual void writeConfig(KConfig *config); 65 virtual void writeConfig(KConfig *config);
64 virtual QString type() const { return "Table"; } 66 virtual QString type() const { return "Table"; }
65 void doSearch( const QString& s ,KABC::Field *field ); 67 void doSearch( const QString& s ,KABC::Field *field );
66 virtual void scrollUP(); 68 virtual void scrollUP();
67 virtual void scrollDOWN(); 69 virtual void scrollDOWN();
68 virtual void setFocusAV(); 70 virtual void setFocusAV();
69 71
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
98 QString type() const { return "Table"; } 100 QString type() const { return "Table"; }
99 101
100 QString description() const { return i18n( "A listing of contacts in a table. Each cell of " 102 QString description() const { return i18n( "A listing of contacts in a table. Each cell of "
101 "the table holds a field of the contact." ); } 103 "the table holds a field of the contact." ); }
102 104
103 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 105 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
104 const char *name = 0 ) 106 const char *name = 0 )
105 { 107 {
106 return new ConfigureTableViewWidget( ab, parent, name ); 108 return new ConfigureTableViewWidget( ab, parent, name );
107 } 109 }
108}; 110};
109/*US 111/*US
110extern "C" { 112extern "C" {
111 void *init_libkaddrbk_tableview() 113 void *init_libkaddrbk_tableview()
112 { 114 {
113 return ( new TableViewFactory ); 115 return ( new TableViewFactory );
114 } 116 }
115} 117}
116*/ 118*/
117 119
118#endif 120#endif