author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/views | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | kaddressbook/views/cardview.cpp | 114 | ||||
-rw-r--r-- | kaddressbook/views/cardview.h | 14 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 25 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.h | 15 | ||||
-rw-r--r-- | kaddressbook/views/configurecardviewdialog.cpp | 57 | ||||
-rw-r--r-- | kaddressbook/views/configurecardviewdialog.h | 6 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 35 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.h | 6 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 32 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 6 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 19 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 3 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 60 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 29 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 56 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 18 |
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 | |||
@@ -13,90 +13,98 @@ | |||
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 |
48 | class CardViewTip : public QLabel { | 56 | class 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 | // |
74 | class CardViewItemList : public QPtrList<CardViewItem> | 82 | class 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 | }*/ |
@@ -140,96 +148,96 @@ class CardViewSeparator | |||
140 | class CardViewPrivate | 148 | class 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 | ||
201 | class CardViewItemPrivate | 209 | class 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 | ||
222 | CardViewItem::CardViewItem(CardView *parent, QString caption) | 230 | CardViewItem::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 | ||
230 | CardViewItem::~CardViewItem() | 238 | CardViewItem::~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 | ||
@@ -292,49 +300,49 @@ void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) | |||
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 ) ); |
@@ -387,91 +395,91 @@ const QString &CardViewItem::caption() const | |||
387 | int CardViewItem::height( bool allowCache ) const | 395 | int 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 | ||
426 | bool CardViewItem::isSelected() const | 434 | bool CardViewItem::isSelected() const |
427 | { | 435 | { |
428 | return d->mSelected; | 436 | return d->mSelected; |
429 | } | 437 | } |
430 | 438 | ||
431 | void CardViewItem::setSelected(bool selected) | 439 | void CardViewItem::setSelected(bool selected) |
432 | { | 440 | { |
433 | d->mSelected = selected; | 441 | d->mSelected = selected; |
434 | } | 442 | } |
435 | 443 | ||
436 | void CardViewItem::insertField(const QString &label, const QString &value) | 444 | void 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 | ||
449 | void CardViewItem::removeField(const QString &label) | 457 | void 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 | ||
469 | void CardViewItem::clearFields() | 477 | void 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 | ||
@@ -502,188 +510,188 @@ QString CardViewItem::trimString(const QString &text, int width, | |||
502 | CardViewItem *CardViewItem::nextItem() | 510 | CardViewItem *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 | ||
512 | void CardViewItem::repaintCard() | 520 | void CardViewItem::repaintCard() |
513 | { | 521 | { |
514 | if (mView) | 522 | if (mView) |
515 | mView->repaintItem(this); | 523 | mView->repaintItem(this); |
516 | } | 524 | } |
517 | 525 | ||
518 | void CardViewItem::setCaption(const QString &caption) | 526 | void CardViewItem::setCaption(const QString &caption) |
519 | { | 527 | { |
520 | d->mCaption = caption; | 528 | d->mCaption = caption; |
521 | repaintCard(); | 529 | repaintCard(); |
522 | } | 530 | } |
523 | 531 | ||
524 | QString CardViewItem::fieldValue(const QString &label) | 532 | QString 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 | ||
535 | void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) | 543 | void 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 | ||
614 | CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const | 622 | CardViewItem::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 | ||
639 | CardView::CardView(QWidget *parent, const char *name) | 647 | CardView::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 | ||
671 | CardView::~CardView() | 679 | CardView::~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 | ||
679 | void CardView::insertItem(CardViewItem *item) | 687 | void 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 | ||
685 | void CardView::takeItem(CardViewItem *item) | 693 | void 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)); |
@@ -718,97 +726,97 @@ void CardView::setCurrentItem( CardViewItem *item ) | |||
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 | ||
739 | CardViewItem *CardView::itemAt(const QPoint &viewPos) | 747 | CardViewItem *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 | ||
758 | QRect CardView::itemRect(const CardViewItem *item) | 766 | QRect 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 | ||
764 | void CardView::ensureItemVisible(const CardViewItem *item) | 772 | void 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 | ||
770 | void CardView::repaintItem(const CardViewItem *item) | 778 | void 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 | ||
776 | void CardView::setSelectionMode(CardView::SelectionMode mode) | 784 | void 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 | ||
783 | CardView::SelectionMode CardView::selectionMode() const | 791 | CardView::SelectionMode CardView::selectionMode() const |
784 | { | 792 | { |
785 | return d->mSelectionMode; | 793 | return d->mSelectionMode; |
786 | } | 794 | } |
787 | 795 | ||
788 | void CardView::selectAll(bool state) | 796 | void 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(); |
@@ -857,49 +865,49 @@ void CardView::setSelected(CardViewItem *item, bool 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 | ||
873 | bool CardView::isSelected(CardViewItem *item) const | 881 | bool CardView::isSelected(CardViewItem *item) const |
874 | { | 882 | { |
875 | return (item && item->isSelected()); | 883 | return (item && item->isSelected()); |
876 | } | 884 | } |
877 | 885 | ||
878 | CardViewItem *CardView::selectedItem() const | 886 | CardViewItem *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 | ||
891 | CardViewItem *CardView::firstItem() const | 899 | CardViewItem *CardView::firstItem() const |
892 | { | 900 | { |
893 | return d->mItemList.first(); | 901 | return d->mItemList.first(); |
894 | } | 902 | } |
895 | 903 | ||
896 | int CardView::childCount() const | 904 | int CardView::childCount() const |
897 | { | 905 | { |
898 | return d->mItemList.count(); | 906 | return d->mItemList.count(); |
899 | } | 907 | } |
900 | /*US | 908 | /*US |
901 | CardViewItem *CardView::findItem(const QString &text, const QString &label, | 909 | CardViewItem *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! |
@@ -934,195 +942,195 @@ uint CardView::columnWidth() | |||
934 | } | 942 | } |
935 | 943 | ||
936 | void CardView::drawContents(QPainter *p, int clipx, int clipy, | 944 | void 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 | ||
994 | void CardView::resizeEvent(QResizeEvent *e) | 1002 | void 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 | ||
1001 | void CardView::calcLayout() | 1009 | void 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 | ||
1068 | CardViewItem *CardView::itemAfter(CardViewItem *item) | 1076 | CardViewItem *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 | ||
1074 | uint CardView::itemMargin() | 1082 | uint CardView::itemMargin() |
1075 | { | 1083 | { |
1076 | return d->mItemMargin; | 1084 | return d->mItemMargin; |
1077 | } | 1085 | } |
1078 | 1086 | ||
1079 | void CardView::setItemMargin( uint margin ) | 1087 | void 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 | ||
1088 | uint CardView::itemSpacing() | 1096 | uint CardView::itemSpacing() |
1089 | { | 1097 | { |
1090 | return d->mItemSpacing; | 1098 | return d->mItemSpacing; |
1091 | } | 1099 | } |
1092 | 1100 | ||
1093 | void CardView::setItemSpacing( uint spacing ) | 1101 | void 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 | ||
1102 | void CardView::contentsMousePressEvent(QMouseEvent *e) | 1110 | void 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 | } |
@@ -1150,397 +1158,397 @@ void CardView::contentsMousePressEvent(QMouseEvent *e) | |||
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 | ||
1220 | void CardView::contentsMouseReleaseEvent(QMouseEvent *e) | 1228 | void 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 | ||
1258 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1266 | void 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 | ||
1276 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) | 1284 | void 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 | ||
1316 | void CardView::enterEvent( QEvent * ) | 1324 | void CardView::enterEvent( QEvent * ) |
1317 | { | 1325 | { |
1318 | d->mTimer->start( 500 ); | 1326 | d->mTimer->start( 500 ); |
1319 | } | 1327 | } |
1320 | 1328 | ||
1321 | void CardView::leaveEvent( QEvent * ) | 1329 | void 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 | ||
1331 | void CardView::focusInEvent( QFocusEvent * ) | 1339 | void 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 | ||
1343 | void CardView::focusOutEvent( QFocusEvent * ) | 1351 | void 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 | ||
1349 | void CardView::keyPressEvent( QKeyEvent *e ) | 1357 | void 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 | ||
1541 | void CardView::contentsWheelEvent( QWheelEvent * e ) | 1549 | void CardView::contentsWheelEvent( QWheelEvent * e ) |
1542 | { | 1550 | { |
1543 | scrollBy(2*e->delta()/-3, 0); | 1551 | scrollBy(2*e->delta()/-3, 0); |
1544 | } | 1552 | } |
1545 | 1553 | ||
1546 | void CardView::setLayoutDirty(bool dirty) | 1554 | void CardView::setLayoutDirty(bool dirty) |
@@ -1617,51 +1625,51 @@ void 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 | ||
1632 | void CardView::drawRubberBands( int pos ) | 1640 | void 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 | ||
1666 | int CardView::itemWidth() const | 1674 | int CardView::itemWidth() const |
1667 | { | 1675 | { |
@@ -1678,73 +1686,73 @@ void CardView::setItemWidth( int 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() ); |
1683 | qDebug("CardView::setItemWidth has to be verified"); | 1691 | qDebug("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 | ||
1688 | void CardView::setHeaderFont( const QFont &fnt ) | 1696 | void 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 | ||
1695 | QFont CardView::headerFont() const | 1703 | QFont CardView::headerFont() const |
1696 | { | 1704 | { |
1697 | return d->mHeaderFont; | 1705 | return d->mHeaderFont; |
1698 | } | 1706 | } |
1699 | 1707 | ||
1700 | void CardView::setFont( const QFont &fnt ) | 1708 | void 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 | ||
1707 | int CardView::separatorWidth() | 1715 | int CardView::separatorWidth() |
1708 | { | 1716 | { |
1709 | return d->mSepWidth; | 1717 | return d->mSepWidth; |
1710 | } | 1718 | } |
1711 | 1719 | ||
1712 | void CardView::setSeparatorWidth( int width ) | 1720 | void 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 | ||
1718 | int CardView::maxFieldLines() const | 1726 | int CardView::maxFieldLines() const |
1719 | { | 1727 | { |
1720 | return d->mMaxFieldLines; | 1728 | return d->mMaxFieldLines; |
1721 | } | 1729 | } |
1722 | 1730 | ||
1723 | void CardView::setMaxFieldLines( int howmany ) | 1731 | void 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 | ||
1729 | void CardView::keyReleaseEvent ( QKeyEvent * e ) | 1737 | void 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,33 +1,41 @@ | |||
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 | ||
11 | class QLabel; | 19 | class QLabel; |
12 | class QPainter; | 20 | class QPainter; |
13 | class QResizeEvent; | 21 | class QResizeEvent; |
14 | class QMouseEvent; | 22 | class QMouseEvent; |
15 | class CardView; | 23 | class CardView; |
16 | class CardViewPrivate; | 24 | class CardViewPrivate; |
17 | class CardViewItemPrivate; | 25 | class CardViewItemPrivate; |
18 | class CardViewTip; | 26 | class 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 | */ |
24 | class CardViewItem | 32 | class 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 | ||
@@ -127,49 +135,49 @@ class CardViewItem | |||
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 | */ |
151 | class CardView : public QScrollView | 159 | class 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 | */ |
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,105 +1,110 @@ | |||
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 | ||
34 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) | 39 | ColorListBox::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 | ||
43 | void ColorListBox::setEnabled( bool state ) | 48 | void 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 | ||
58 | void ColorListBox::setColor( uint index, const QColor &color ) | 63 | void 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 | ||
69 | QColor ColorListBox::color( uint index ) const | 74 | QColor 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 | } |
81 | void ColorListBox::slotNewColor(QListBoxItem * i) | 86 | void ColorListBox::slotNewColor(Q3ListBoxItem * i) |
82 | { | 87 | { |
83 | if ( i ) | 88 | if ( i ) |
84 | newColor( index( i ) ); | 89 | newColor( index( i ) ); |
85 | } | 90 | } |
86 | 91 | ||
87 | void ColorListBox::newColor( int index ) | 92 | void 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 () ) { |
@@ -177,69 +182,69 @@ void 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 |
193 | qDebug("ColorListBox::dropEvent drag&drop currently not supported"); | 198 | qDebug("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 | ||
200 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) | 205 | ColorListItem::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 | ||
207 | const QColor &ColorListItem::color( void ) | 212 | const QColor &ColorListItem::color( void ) |
208 | { | 213 | { |
209 | return( mColor ); | 214 | return( mColor ); |
210 | } | 215 | } |
211 | 216 | ||
212 | 217 | ||
213 | void ColorListItem::setColor( const QColor &color ) | 218 | void ColorListItem::setColor( const QColor &color ) |
214 | { | 219 | { |
215 | mColor = color; | 220 | mColor = color; |
216 | } | 221 | } |
217 | 222 | ||
218 | 223 | ||
219 | void ColorListItem::paint( QPainter *p ) | 224 | void ColorListItem::paint( QPainter *p ) |
220 | { | 225 | { |
221 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
222 | int h = fm.height(); | 227 | int h = fm.height(); |
223 | 228 | ||
224 | p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); | 229 | p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); |
225 | 230 | ||
226 | p->setPen( Qt::black ); | 231 | p->setPen( Qt::black ); |
227 | p->drawRect( 3, 1, mBoxWidth, h-1 ); | 232 | p->drawRect( 3, 1, mBoxWidth, h-1 ); |
228 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); | 233 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); |
229 | } | 234 | } |
230 | 235 | ||
231 | 236 | ||
232 | int ColorListItem::height(const QListBox *lb ) const | 237 | int 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 | ||
238 | int ColorListItem::width(const QListBox *lb ) const | 243 | int 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 | ||
26 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
27 | class QDragLeaveEvent; | 32 | class QDragLeaveEvent; |
28 | class QDragMoveEvent; | 33 | class QDragMoveEvent; |
29 | class QDropEvent; | 34 | class QDropEvent; |
30 | 35 | ||
31 | class ColorListBox : public KListBox | 36 | class 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 | ||
59 | class ColorListItem : public QListBoxItem | 64 | class 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 | |||
@@ -4,53 +4,56 @@ | |||
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 | ||
55 | ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, | 58 | ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name ) | 59 | const char *name ) |
@@ -68,49 +71,49 @@ ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget | |||
68 | mAdvancedPage = new CardViewLookNFeelPage( page ); | 71 | mAdvancedPage = new CardViewLookNFeelPage( page ); |
69 | } | 72 | } |
70 | 73 | ||
71 | ConfigureCardViewWidget::~ConfigureCardViewWidget() | 74 | ConfigureCardViewWidget::~ConfigureCardViewWidget() |
72 | { | 75 | { |
73 | } | 76 | } |
74 | 77 | ||
75 | void ConfigureCardViewWidget::restoreSettings( KConfig *config ) | 78 | void 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 | ||
82 | void ConfigureCardViewWidget::saveSettings( KConfig *config ) | 85 | void 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 |
91 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) | 94 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) |
92 | : QVBox( parent, name ) | 95 | : Q3VBox( parent, name ) |
93 | { | 96 | { |
94 | initGUI(); | 97 | initGUI(); |
95 | } | 98 | } |
96 | 99 | ||
97 | CardViewLookNFeelPage::~CardViewLookNFeelPage() | 100 | CardViewLookNFeelPage::~CardViewLookNFeelPage() |
98 | { | 101 | { |
99 | } | 102 | } |
100 | 103 | ||
101 | void CardViewLookNFeelPage::restoreSettings( KConfig *config ) | 104 | void 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; |
106 | qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); | 109 | qDebug("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 ) ) ); |
@@ -213,157 +216,157 @@ void CardViewLookNFeelPage::setHeaderFont() | |||
213 | } | 216 | } |
214 | 217 | ||
215 | void CardViewLookNFeelPage::enableFonts() | 218 | void 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 | ||
222 | void CardViewLookNFeelPage::enableColors() | 225 | void 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 | ||
229 | void CardViewLookNFeelPage::initGUI() | 232 | void 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 | ||
361 | void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 364 | void 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 | |||
@@ -5,100 +5,102 @@ | |||
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 | ||
33 | class QString; | 35 | class QString; |
34 | class QWidget; | 36 | class QWidget; |
35 | class QCheckBox; | 37 | class QCheckBox; |
36 | class QLabel; | 38 | class QLabel; |
37 | class KConfig; | 39 | class KConfig; |
38 | 40 | ||
39 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
40 | 42 | ||
41 | class CardViewLookAndFeelPage; | 43 | class 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 | */ |
48 | class ConfigureCardViewWidget : public ViewConfigureWidget | 50 | class 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 | ||
80 | class CardViewLookNFeelPage : public QVBox { | 82 | class 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; |
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 | |||
@@ -6,53 +6,56 @@ | |||
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 | ||
54 | ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, | 57 | ConfigureTableViewWidget::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 | { |
@@ -63,49 +66,49 @@ ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, | |||
63 | mPage = new LookAndFeelPage( page ); | 66 | mPage = new LookAndFeelPage( page ); |
64 | } | 67 | } |
65 | 68 | ||
66 | ConfigureTableViewWidget::~ConfigureTableViewWidget() | 69 | ConfigureTableViewWidget::~ConfigureTableViewWidget() |
67 | { | 70 | { |
68 | } | 71 | } |
69 | 72 | ||
70 | void ConfigureTableViewWidget::restoreSettings( KConfig *config ) | 73 | void 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 | ||
77 | void ConfigureTableViewWidget::saveSettings( KConfig *config ) | 80 | void 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 | ||
86 | LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) | 89 | LookAndFeelPage::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 | ||
95 | void LookAndFeelPage::restoreSettings( KConfig *config ) | 98 | void 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 | ||
@@ -208,138 +211,138 @@ void LookAndFeelPage::setHeaderFont() | |||
208 | } | 211 | } |
209 | 212 | ||
210 | void LookAndFeelPage::enableFonts() | 213 | void 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 | ||
217 | void LookAndFeelPage::enableColors() | 220 | void 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 | ||
224 | void LookAndFeelPage::initGUI() | 227 | void 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 | ||
331 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) | 334 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) |
332 | { | 335 | { |
333 | mBackgroundName->setEnabled(enabled); | 336 | mBackgroundName->setEnabled(enabled); |
334 | } | 337 | } |
335 | 338 | ||
336 | 339 | ||
337 | void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 340 | void 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 | |||
@@ -5,86 +5,88 @@ | |||
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 | ||
31 | class QString; | 33 | class QString; |
32 | class QWidget; | 34 | class QWidget; |
33 | class QRadioButton; | 35 | class QRadioButton; |
34 | class QCheckBox; | 36 | class QCheckBox; |
35 | class KURLRequester; | 37 | class KURLRequester; |
36 | class KConfig; | 38 | class KConfig; |
37 | class QLabel; | 39 | class QLabel; |
38 | 40 | ||
39 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
40 | 42 | ||
41 | class LookAndFeelPage; | 43 | class 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 | */ |
48 | class ConfigureTableViewWidget : public ViewConfigureWidget | 50 | class 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 | */ |
66 | class LookAndFeelPage : public QVBox | 68 | class 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; |
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,90 +1,96 @@ | |||
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 | ||
49 | DynamicTip::DynamicTip( ContactListView *parent) | 54 | DynamicTip::DynamicTip( ContactListView *parent) |
50 | : QToolTip( parent ) | 55 | /* TODO:hacker:: QToolTip( parent ) */ |
51 | { | 56 | { |
52 | } | 57 | } |
53 | 58 | ||
54 | void DynamicTip::maybeTip( const QPoint &pos ) | 59 | void 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 | ||
@@ -130,95 +136,95 @@ void DynamicTip::maybeTip( const QPoint &pos ) | |||
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 | ||
160 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 166 | ContactListViewItem::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 | ||
170 | QString ContactListViewItem::key(int column, bool ascending) const | 176 | QString 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 | ||
203 | void ContactListViewItem::paintCell(QPainter * p, | 209 | void 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 | ||
221 | ContactListView *ContactListViewItem::parent() | 227 | ContactListView *ContactListViewItem::parent() |
222 | { | 228 | { |
223 | return parentListView; | 229 | return parentListView; |
224 | } | 230 | } |
@@ -267,49 +273,49 @@ ContactListView::ContactListView(KAddressBookTableView *view, | |||
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 | } |
283 | void ContactListView::printMe() | 289 | void 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 | ||
311 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 317 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
312 | { | 318 | { |
313 | mAlternateColor = m_AlternateColor; | 319 | mAlternateColor = m_AlternateColor; |
314 | } | 320 | } |
315 | 321 | ||
@@ -322,59 +328,59 @@ void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | |||
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 | ||
336 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 342 | void 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 |
344 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 350 | void 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 | ||
353 | bool ContactListView::acceptDrag(QDropEvent *e) const | 359 | bool 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 |
358 | qDebug("ContactListView::acceptDrag has to be fixed"); | 364 | qDebug("ContactListView::acceptDrag has to be fixed"); |
359 | return false; | 365 | return false; |
360 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
361 | } | 367 | } |
362 | 368 | ||
363 | void ContactListView::itemDropped(QDropEvent *e) | 369 | void ContactListView::itemDropped(QDropEvent *e) |
364 | { | 370 | { |
365 | contentsDropEvent(e); | 371 | contentsDropEvent(e); |
366 | } | 372 | } |
367 | 373 | ||
368 | void ContactListView::contentsDropEvent( QDropEvent *e ) | 374 | void ContactListView::contentsDropEvent( QDropEvent *e ) |
369 | { | 375 | { |
370 | emit addresseeDropped(e); | 376 | emit addresseeDropped(e); |
371 | } | 377 | } |
372 | 378 | ||
373 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) | 379 | void 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 | } |
@@ -403,27 +409,27 @@ void 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 | } |
415 | void ContactListView::keyReleaseEvent ( QKeyEvent * e ) | 421 | void 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,47 +1,51 @@ | |||
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 | ||
16 | class QDropEvent; | 20 | class QDropEvent; |
17 | class KAddressBookTableView; | 21 | class KAddressBookTableView; |
18 | class ContactListView; | 22 | class 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 | */ |
23 | class DynamicTip : public QToolTip | 27 | class 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 | ||
34 | class ContactListViewItem : public KListViewItem | 38 | class ContactListViewItem : public KListViewItem |
35 | { | 39 | { |
36 | 40 | ||
37 | public: | 41 | public: |
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 | */ |
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,54 +1,59 @@ | |||
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 |
45 | extern "C" { | 50 | extern "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) |
@@ -104,100 +109,100 @@ class AddresseeCardViewItem : public CardViewItem | |||
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 | ||
111 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 116 | AddresseeCardView::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 | ||
117 | AddresseeCardView::~AddresseeCardView() | 122 | AddresseeCardView::~AddresseeCardView() |
118 | { | 123 | { |
119 | } | 124 | } |
120 | void AddresseeCardView::printMe() | 125 | void 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 | ||
148 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 153 | void 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 |
154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 159 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
155 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
156 | } | 161 | } |
157 | 162 | ||
158 | void AddresseeCardView::dropEvent(QDropEvent *e) | 163 | void AddresseeCardView::dropEvent(QDropEvent *e) |
159 | { | 164 | { |
160 | emit addresseeDropped(e); | 165 | emit addresseeDropped(e); |
161 | } | 166 | } |
162 | 167 | ||
163 | void AddresseeCardView::startDrag() | 168 | void AddresseeCardView::startDrag() |
164 | { | 169 | { |
165 | emit startAddresseeDrag(); | 170 | emit startAddresseeDrag(); |
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | /////////////////////////////// | 174 | /////////////////////////////// |
170 | // KAddressBookCardView | 175 | // KAddressBookCardView |
171 | 176 | ||
172 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 177 | KAddressBookCardView::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 | ||
198 | KAddressBookCardView::~KAddressBookCardView() | 203 | KAddressBookCardView::~KAddressBookCardView() |
199 | { | 204 | { |
200 | } | 205 | } |
201 | void KAddressBookCardView::setFocusAV() | 206 | void KAddressBookCardView::setFocusAV() |
202 | { | 207 | { |
203 | if ( mCardView ) | 208 | if ( mCardView ) |
@@ -499,27 +504,27 @@ void KAddressBookCardView::addresseeSelected() | |||
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 | |||
@@ -4,48 +4,51 @@ | |||
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 | ||
38 | class QDragEnterEvent; | 41 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 42 | class QDragEntryEvent; |
40 | class QDropEvent; | 43 | class QDropEvent; |
41 | class KConfig; | 44 | class KConfig; |
42 | class AddresseeCardView; | 45 | class 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 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 52 | class KAddressBookCardView : public KAddressBookView |
50 | { | 53 | { |
51 | Q_OBJECT | 54 | Q_OBJECT |
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,157 +1,165 @@ | |||
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 |
47 | class IconViewFactory : public ViewFactory | 55 | class 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 | ||
62 | extern "C" { | 70 | extern "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 |
72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 80 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
73 | : KIconView(parent, name) | 81 | : KIconView(parent, name) |
74 | #else //KAB_EMBEDDED | 82 | #else //KAB_EMBEDDED |
75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 83 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
76 | : QIconView(parent, name) | 84 | : Q3IconView(parent, name) |
77 | #endif //KAB_EMBEDDED | 85 | #endif //KAB_EMBEDDED |
78 | 86 | ||
79 | { | 87 | { |
80 | setSelectionMode( QIconView::Extended ); | 88 | setSelectionMode( Q3IconView::Extended ); |
81 | setResizeMode( QIconView::Adjust ); | 89 | setResizeMode( Q3IconView::Adjust ); |
82 | setWordWrapIconText( true ); | 90 | setWordWrapIconText( true ); |
83 | setGridX( 100 ); | 91 | setGridX( 100 ); |
84 | setItemsMovable(false); | 92 | setItemsMovable(false); |
85 | setSorting(true, true); | 93 | setSorting(true, true); |
86 | 94 | ||
87 | 95 | ||
88 | //US ??? setMode( KIconView::Select ); | 96 | //US ??? setMode( KIconView::Select ); |
89 | 97 | ||
90 | #ifndef KAB_EMBEDDED | 98 | #ifndef KAB_EMBEDDED |
91 | 99 | ||
92 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 100 | connect(this, SIGNAL(dropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&)), |
93 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 101 | this, SLOT(itemDropped(QDropEvent*, const Q3ValueList<Q3IconDragItem>&))); |
94 | #endif //KAB_EMBEDDED | 102 | #endif //KAB_EMBEDDED |
95 | } | 103 | } |
96 | 104 | ||
97 | AddresseeIconView::~AddresseeIconView() | 105 | AddresseeIconView::~AddresseeIconView() |
98 | { | 106 | { |
99 | } | 107 | } |
100 | 108 | ||
101 | 109 | ||
102 | void AddresseeIconView::itemDropped(QDropEvent *e, | 110 | void AddresseeIconView::itemDropped(QDropEvent *e, |
103 | const QValueList<QIconDragItem> &) | 111 | const Q3ValueList<Q3IconDragItem> &) |
104 | { | 112 | { |
105 | emit addresseeDropped(e); | 113 | emit addresseeDropped(e); |
106 | } | 114 | } |
107 | 115 | ||
108 | QDragObject *AddresseeIconView::dragObject() | 116 | Q3DragObject *AddresseeIconView::dragObject() |
109 | { | 117 | { |
110 | emit startAddresseeDrag(); | 118 | emit startAddresseeDrag(); |
111 | 119 | ||
112 | // We never want IconView to start the drag | 120 | // We never want IconView to start the drag |
113 | return 0; | 121 | return 0; |
114 | } | 122 | } |
115 | //////////////////////////////// | 123 | //////////////////////////////// |
116 | // AddresseeIconViewItem (internal class) | 124 | // AddresseeIconViewItem (internal class) |
117 | #ifndef KAB_EMBEDDED | 125 | #ifndef KAB_EMBEDDED |
118 | class AddresseeIconViewItem : public KIconViewItem | 126 | class AddresseeIconViewItem : public KIconViewItem |
119 | #else //KAB_EMBEDDED | 127 | #else //KAB_EMBEDDED |
120 | class AddresseeIconViewItem : public QIconViewItem | 128 | class AddresseeIconViewItem : public Q3IconViewItem |
121 | #endif //KAB_EMBEDDED | 129 | #endif //KAB_EMBEDDED |
122 | { | 130 | { |
123 | public: | 131 | public: |
124 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
125 | AddresseeIconViewItem(const KABC::Field::List &fields, | 133 | AddresseeIconViewItem(const KABC::Field::List &fields, |
126 | KABC::AddressBook *doc, const KABC::Addressee &a, | 134 | KABC::AddressBook *doc, const KABC::Addressee &a, |
127 | QIconView *parent) | 135 | Q3IconView *parent) |
128 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 136 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
129 | #else //KAB_EMBEDDED | 137 | #else //KAB_EMBEDDED |
130 | AddresseeIconViewItem(const KABC::Field::List &fields, | 138 | AddresseeIconViewItem(const KABC::Field::List &fields, |
131 | KABC::AddressBook *doc, const KABC::Addressee &a, | 139 | KABC::AddressBook *doc, const KABC::Addressee &a, |
132 | QIconView *parent) | 140 | Q3IconView *parent) |
133 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 141 | : Q3IconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
134 | #endif //KAB_EMBEDDED | 142 | #endif //KAB_EMBEDDED |
135 | { | 143 | { |
136 | if ( mFields.isEmpty() ) { | 144 | if ( mFields.isEmpty() ) { |
137 | mFields = KABC::Field::defaultFields(); | 145 | mFields = KABC::Field::defaultFields(); |
138 | } | 146 | } |
139 | refresh(); | 147 | refresh(); |
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 | ||
@@ -179,110 +187,110 @@ class AddresseeIconViewItem : public QIconViewItem | |||
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 | ||
198 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 206 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
199 | QWidget *parent, const char *name) | 207 | QWidget *parent, const char *name) |
200 | : KAddressBookView( ab, parent, name ) | 208 | : KAddressBookView( ab, parent, name ) |
201 | { | 209 | { |
202 | // Init the GUI | 210 | // Init the GUI |
203 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 211 | Q3VBoxLayout *layout = new Q3VBoxLayout(viewWidget()); |
204 | 212 | ||
205 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 213 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
206 | layout->addWidget(mIconView); | 214 | layout->addWidget(mIconView); |
207 | 215 | ||
208 | // Connect up the signals | 216 | // Connect up the signals |
209 | 217 | ||
210 | //US method executed is part of KIconView | 218 | //US method executed is part of KIconView |
211 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 219 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
212 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
213 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 221 | connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
214 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 222 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
215 | 223 | ||
216 | connect(mIconView, SIGNAL(selectionChanged()), | 224 | connect(mIconView, SIGNAL(selectionChanged()), |
217 | this, SLOT(addresseeSelected())); | 225 | this, SLOT(addresseeSelected())); |
218 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 226 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
219 | this, SIGNAL(dropped(QDropEvent*))); | 227 | this, SIGNAL(dropped(QDropEvent*))); |
220 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 228 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
221 | this, SIGNAL(startDrag())); | 229 | this, SIGNAL(startDrag())); |
222 | } | 230 | } |
223 | 231 | ||
224 | KAddressBookIconView::~KAddressBookIconView() | 232 | KAddressBookIconView::~KAddressBookIconView() |
225 | { | 233 | { |
226 | } | 234 | } |
227 | void KAddressBookIconView::setFocusAV() | 235 | void KAddressBookIconView::setFocusAV() |
228 | { | 236 | { |
229 | if ( mIconView ) | 237 | if ( mIconView ) |
230 | mIconView->setFocus(); | 238 | mIconView->setFocus(); |
231 | } | 239 | } |
232 | 240 | ||
233 | 241 | ||
234 | void KAddressBookIconView::scrollUP() | 242 | void 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 | } |
239 | void KAddressBookIconView::scrollDOWN() | 247 | void 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 | } |
244 | void KAddressBookIconView::readConfig(KConfig *config) | 252 | void KAddressBookIconView::readConfig(KConfig *config) |
245 | { | 253 | { |
246 | KAddressBookView::readConfig(config); | 254 | KAddressBookView::readConfig(config); |
247 | 255 | ||
248 | //US method executed is part of KIconView | 256 | //US method executed is part of KIconView |
249 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 257 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
250 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 258 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
251 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 259 | disconnect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
252 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 260 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
253 | 261 | ||
254 | //US method executed is part of KIconView. Use selectionChanged instead | 262 | //US method executed is part of KIconView. Use selectionChanged instead |
255 | /*US | 263 | /*US |
256 | if (KABPrefs::instance()->mHonorSingleClick) | 264 | if (KABPrefs::instance()->mHonorSingleClick) |
257 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 265 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
258 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 266 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
259 | else | 267 | else |
260 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 268 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
261 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 269 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
262 | */ | 270 | */ |
263 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 271 | connect(mIconView, SIGNAL(selectionChanged(Q3IconViewItem *)), |
264 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 272 | this, SLOT(addresseeExecuted(Q3IconViewItem *))); |
265 | 273 | ||
266 | } | 274 | } |
267 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 275 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
268 | { | 276 | { |
269 | mIconView->clear(); | 277 | mIconView->clear(); |
270 | mIconList.clear(); | 278 | mIconList.clear(); |
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 |
@@ -315,167 +323,167 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | |||
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 | } |
336 | QStringList KAddressBookIconView::selectedUids() | 344 | QStringList KAddressBookIconView::selectedUids() |
337 | { | 345 | { |
338 | QStringList uidList; | 346 | QStringList uidList; |
339 | QIconViewItem *item; | 347 | Q3IconViewItem *item; |
340 | AddresseeIconViewItem *aItem; | 348 | AddresseeIconViewItem *aItem; |
341 | 349 | ||
342 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 350 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
343 | { | 351 | { |
344 | if (item->isSelected()) | 352 | if (item->isSelected()) |
345 | { | 353 | { |
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 | ||
359 | void KAddressBookIconView::refresh(QString uid) | 367 | void KAddressBookIconView::refresh(QString uid) |
360 | { | 368 | { |
361 | QIconViewItem *item; | 369 | Q3IconViewItem *item; |
362 | AddresseeIconViewItem *aItem; | 370 | AddresseeIconViewItem *aItem; |
363 | 371 | ||
364 | if ( uid.isNull() ) { | 372 | if ( uid.isNull() ) { |
365 | // Rebuild the view | 373 | // Rebuild the view |
366 | mIconView->clear(); | 374 | mIconView->clear(); |
367 | mIconList.clear(); | 375 | mIconList.clear(); |
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 | ||
407 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 415 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
408 | { | 416 | { |
409 | QIconViewItem *item; | 417 | Q3IconViewItem *item; |
410 | AddresseeIconViewItem *aItem; | 418 | AddresseeIconViewItem *aItem; |
411 | 419 | ||
412 | if (uid.isNull()) | 420 | if (uid.isNull()) |
413 | { | 421 | { |
414 | mIconView->selectAll(selected); | 422 | mIconView->selectAll(selected); |
415 | } | 423 | } |
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 | ||
438 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 446 | void KAddressBookIconView::addresseeExecuted(Q3IconViewItem *item) |
439 | { | 447 | { |
440 | #ifndef KAB_EMBEDDED | 448 | #ifndef KAB_EMBEDDED |
441 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 449 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
442 | #else //KAB_EMBEDDED | 450 | #else //KAB_EMBEDDED |
443 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 451 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
444 | #endif //KAB_EMBEDDED | 452 | #endif //KAB_EMBEDDED |
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 | ||
451 | void KAddressBookIconView::addresseeSelected() | 459 | void KAddressBookIconView::addresseeSelected() |
452 | { | 460 | { |
453 | QIconViewItem *item; | 461 | Q3IconViewItem *item; |
454 | AddresseeIconViewItem *aItem; | 462 | AddresseeIconViewItem *aItem; |
455 | 463 | ||
456 | bool found = false; | 464 | bool found = false; |
457 | for (item = mIconView->firstItem(); item && !found; | 465 | for (item = mIconView->firstItem(); item && !found; |
458 | item = item->nextItem()) | 466 | item = item->nextItem()) |
459 | { | 467 | { |
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 | |||
@@ -4,131 +4,134 @@ | |||
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 | ||
37 | class QIconViewItem; | 40 | class Q3IconViewItem; |
38 | class KConfig; | 41 | class KConfig; |
39 | class AddresseeIconView; | 42 | class AddresseeIconView; |
40 | class AddresseeIconViewItem; | 43 | class AddresseeIconViewItem; |
41 | class QIconDragItem; | 44 | class Q3IconDragItem; |
42 | class KAddressBookIconView; | 45 | class KAddressBookIconView; |
43 | 46 | ||
44 | namespace KABC { class AddressBook; } | 47 | namespace 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 | */ |
50 | class KAddressBookIconView : public KAddressBookView | 53 | class 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 |
91 | class AddresseeIconView : public KIconView | 94 | class AddresseeIconView : public KIconView |
92 | //MOC_SKIP_END | 95 | #endif |
93 | #else //KAB_EMBEDDED | 96 | #else //KAB_EMBEDDED |
94 | class AddresseeIconView : public QIconView | 97 | class 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 | ||
114 | class IconViewFactory : public ViewFactory | 117 | class 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 | /* |
127 | extern "C" { | 130 | extern "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,154 +1,158 @@ | |||
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 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 45 | KAddressBookTableView::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 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 55 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 56 | { |
53 | } | 57 | } |
54 | void KAddressBookTableView::setFocusAV() | 58 | void KAddressBookTableView::setFocusAV() |
55 | { | 59 | { |
56 | if ( mListView ) | 60 | if ( mListView ) |
57 | mListView->setFocus(); | 61 | mListView->setFocus(); |
58 | 62 | ||
59 | } | 63 | } |
60 | void KAddressBookTableView::scrollUP() | 64 | void 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 | } |
67 | void KAddressBookTableView::scrollDOWN() | 71 | void KAddressBookTableView::scrollDOWN() |
68 | { | 72 | { |
69 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 73 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
70 | QApplication::postEvent( mListView, ev ); | 74 | QApplication::postEvent( mListView, ev ); |
71 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); | 75 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); |
72 | QApplication::postEvent( mListView, ev ); | 76 | QApplication::postEvent( mListView, ev ); |
73 | } | 77 | } |
74 | void KAddressBookTableView::reconstructListView() | 78 | void 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 | ||
143 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 147 | void 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; |
@@ -323,170 +327,170 @@ void KAddressBookTableView::refresh(QString uid) | |||
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 | ||
366 | QStringList KAddressBookTableView::selectedUids() | 370 | QStringList 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 | ||
395 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 399 | void 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 | ||
426 | void KAddressBookTableView::addresseeSelected() | 430 | void 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 | ||
456 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 460 | void 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 | ||
479 | void KAddressBookTableView::addresseeDeleted() | 483 | void 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,55 +1,57 @@ | |||
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 | ||
29 | class QListViewItem; | 31 | class Q3ListViewItem; |
30 | class QListBox; | 32 | class Q3ListBox; |
31 | class QVBoxLayout; | 33 | class Q3VBoxLayout; |
32 | class KConfig; | 34 | class KConfig; |
33 | 35 | ||
34 | class ContactListViewItem; | 36 | class ContactListViewItem; |
35 | class ContactListView; | 37 | class ContactListView; |
36 | 38 | ||
37 | 39 | ||
38 | namespace KABC { class AddressBook; } | 40 | namespace 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 | */ |
48 | class KAddressBookTableView : public KAddressBookView | 50 | class KAddressBookTableView : public KAddressBookView |
49 | { | 51 | { |
50 | friend class ContactListView; | 52 | friend 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, |
@@ -58,52 +60,52 @@ friend class ContactListView; | |||
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 | ||
90 | class TableViewFactory : public ViewFactory | 92 | class 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 |