Diffstat (limited to 'kaddressbook/views/contactlistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 9accf78..227645d 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -1,429 +1,435 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qheader.h> | 24 | #include <q3header.h> |
25 | #include <qiconset.h> | 25 | #include <qicon.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <q3dragobject.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qbrush.h> | 30 | #include <qbrush.h> |
31 | #include <qevent.h> | 31 | #include <qevent.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //Added by qt3to4: | ||
34 | #include <QDropEvent> | ||
35 | #include <QPixmap> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QKeyEvent> | ||
33 | 38 | ||
34 | #include <klocale.h> | 39 | #include <klocale.h> |
35 | #include <kglobalsettings.h> | 40 | #include <kglobalsettings.h> |
36 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
37 | #include <kdebug.h> | 42 | #include <kdebug.h> |
38 | #include <kconfig.h> | 43 | #include <kconfig.h> |
39 | #include <kapplication.h> | 44 | #include <kapplication.h> |
40 | #include <kurl.h> | 45 | #include <kurl.h> |
41 | 46 | ||
42 | #include "kaddressbooktableview.h" | 47 | #include "kaddressbooktableview.h" |
43 | 48 | ||
44 | #include "contactlistview.h" | 49 | #include "contactlistview.h" |
45 | 50 | ||
46 | ///////////////////////////////// | 51 | ///////////////////////////////// |
47 | // DynamicTip Methods | 52 | // DynamicTip Methods |
48 | 53 | ||
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 | ||
91 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) | 97 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) |
92 | .arg(a.formattedName()); | 98 | .arg(a.formattedName()); |
93 | 99 | ||
94 | s += '\n'; | 100 | s += '\n'; |
95 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) | 101 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) |
96 | .arg(a.organization()); | 102 | .arg(a.organization()); |
97 | 103 | ||
98 | QString notes = a.note().stripWhiteSpace(); | 104 | QString notes = a.note().stripWhiteSpace(); |
99 | if ( !notes.isEmpty() ) { | 105 | if ( !notes.isEmpty() ) { |
100 | notes += '\n'; | 106 | notes += '\n'; |
101 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); | 107 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); |
102 | QFontMetrics fm( font() ); | 108 | QFontMetrics fm( font() ); |
103 | 109 | ||
104 | // Begin word wrap code based on QMultiLineEdit code | 110 | // Begin word wrap code based on QMultiLineEdit code |
105 | int i = 0; | 111 | int i = 0; |
106 | bool doBreak = false; | 112 | bool doBreak = false; |
107 | int linew = 0; | 113 | int linew = 0; |
108 | int lastSpace = -1; | 114 | int lastSpace = -1; |
109 | int a = 0; | 115 | int a = 0; |
110 | int lastw = 0; | 116 | int lastw = 0; |
111 | 117 | ||
112 | while ( i < int(notes.length()) ) { | 118 | while ( i < int(notes.length()) ) { |
113 | doBreak = FALSE; | 119 | doBreak = FALSE; |
114 | if ( notes[i] != '\n' ) | 120 | if ( notes[i] != '\n' ) |
115 | linew += fm.width( notes[i] ); | 121 | linew += fm.width( notes[i] ); |
116 | 122 | ||
117 | if ( lastSpace >= a && notes[i] != '\n' ) | 123 | if ( lastSpace >= a && notes[i] != '\n' ) |
118 | if (linew >= parentWidget()->width()) { | 124 | if (linew >= parentWidget()->width()) { |
119 | doBreak = TRUE; | 125 | doBreak = TRUE; |
120 | if ( lastSpace > a ) { | 126 | if ( lastSpace > a ) { |
121 | i = lastSpace; | 127 | i = lastSpace; |
122 | linew = lastw; | 128 | linew = lastw; |
123 | } | 129 | } |
124 | else | 130 | else |
125 | i = QMAX( a, i-1 ); | 131 | i = QMAX( a, i-1 ); |
126 | } | 132 | } |
127 | 133 | ||
128 | if ( notes[i] == '\n' || doBreak ) { | 134 | if ( notes[i] == '\n' || doBreak ) { |
129 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; | 135 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; |
130 | 136 | ||
131 | a = i + 1; | 137 | a = i + 1; |
132 | lastSpace = a; | 138 | lastSpace = a; |
133 | linew = 0; | 139 | linew = 0; |
134 | } | 140 | } |
135 | 141 | ||
136 | if ( notes[i].isSpace() ) { | 142 | if ( notes[i].isSpace() ) { |
137 | lastSpace = i; | 143 | lastSpace = i; |
138 | lastw = linew; | 144 | lastw = linew; |
139 | } | 145 | } |
140 | 146 | ||
141 | if ( lastSpace <= a ) { | 147 | if ( lastSpace <= a ) { |
142 | lastw = linew; | 148 | lastw = linew; |
143 | } | 149 | } |
144 | 150 | ||
145 | ++i; | 151 | ++i; |
146 | } | 152 | } |
147 | } | 153 | } |
148 | 154 | ||
149 | tip( r, s ); | 155 | tip( r, s ); |
150 | } | 156 | } |
151 | else | 157 | else |
152 | hide(); | 158 | hide(); |
153 | ishidden = !ishidden; | 159 | ishidden = !ishidden; |
154 | 160 | */ | |
155 | } | 161 | } |
156 | 162 | ||
157 | /////////////////////////// | 163 | /////////////////////////// |
158 | // ContactListViewItem Methods | 164 | // ContactListViewItem Methods |
159 | 165 | ||
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 | } |
225 | 231 | ||
226 | 232 | ||
227 | void ContactListViewItem::refresh() | 233 | void ContactListViewItem::refresh() |
228 | { | 234 | { |
229 | // Update our addressee, since it may have changed else were | 235 | // Update our addressee, since it may have changed else were |
230 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 236 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
231 | if (mAddressee.isEmpty()) | 237 | if (mAddressee.isEmpty()) |
232 | return; | 238 | return; |
233 | 239 | ||
234 | int i = 0; | 240 | int i = 0; |
235 | KABC::Field::List::ConstIterator it; | 241 | KABC::Field::List::ConstIterator it; |
236 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 242 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
237 | setText( i++, (*it)->value( mAddressee ) ); | 243 | setText( i++, (*it)->value( mAddressee ) ); |
238 | } | 244 | } |
239 | } | 245 | } |
240 | 246 | ||
241 | /////////////////////////////// | 247 | /////////////////////////////// |
242 | // ContactListView | 248 | // ContactListView |
243 | 249 | ||
244 | ContactListView::ContactListView(KAddressBookTableView *view, | 250 | ContactListView::ContactListView(KAddressBookTableView *view, |
245 | KABC::AddressBook* /* doc */, | 251 | KABC::AddressBook* /* doc */, |
246 | QWidget *parent, | 252 | QWidget *parent, |
247 | const char *name ) | 253 | const char *name ) |
248 | : KListView( parent, name ), | 254 | : KListView( parent, name ), |
249 | pabWidget( view ), | 255 | pabWidget( view ), |
250 | oldColumn( 0 ) | 256 | oldColumn( 0 ) |
251 | { | 257 | { |
252 | mFlagBlockKeyPressed = false; | 258 | mFlagBlockKeyPressed = false; |
253 | mFlagKeyPressed = false; | 259 | mFlagKeyPressed = false; |
254 | mABackground = true; | 260 | mABackground = true; |
255 | mSingleLine = false; | 261 | mSingleLine = false; |
256 | mToolTips = true; | 262 | mToolTips = true; |
257 | 263 | ||
258 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 264 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
259 | 265 | ||
260 | 266 | ||
261 | 267 | ||
262 | 268 | ||
263 | setAlternateBackgroundEnabled(mABackground); | 269 | setAlternateBackgroundEnabled(mABackground); |
264 | setAcceptDrops( true ); | 270 | setAcceptDrops( true ); |
265 | viewport()->setAcceptDrops( true ); | 271 | viewport()->setAcceptDrops( true ); |
266 | setAllColumnsShowFocus( true ); | 272 | setAllColumnsShowFocus( true ); |
267 | setShowSortIndicator(true); | 273 | setShowSortIndicator(true); |
268 | 274 | ||
269 | setSelectionModeExt( KListView::Extended ); | 275 | setSelectionModeExt( KListView::Extended ); |
270 | setDropVisualizer(false); | 276 | setDropVisualizer(false); |
271 | // setFrameStyle(QFrame::NoFrame); | 277 | // setFrameStyle(QFrame::NoFrame); |
272 | //setLineWidth ( 0 ); | 278 | //setLineWidth ( 0 ); |
273 | //setMidLineWidth ( 0 ); | 279 | //setMidLineWidth ( 0 ); |
274 | //setMargin ( 0 ); | 280 | //setMargin ( 0 ); |
275 | #ifndef KAB_EMBEDDED | 281 | #ifndef KAB_EMBEDDED |
276 | connect(this, SIGNAL(dropped(QDropEvent*)), | 282 | connect(this, SIGNAL(dropped(QDropEvent*)), |
277 | this, SLOT(itemDropped(QDropEvent*))); | 283 | this, SLOT(itemDropped(QDropEvent*))); |
278 | #endif //KAB_EMBEDDED | 284 | #endif //KAB_EMBEDDED |
279 | 285 | ||
280 | 286 | ||
281 | new DynamicTip( this ); | 287 | new DynamicTip( this ); |
282 | } | 288 | } |
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 | ||
316 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 322 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
317 | { | 323 | { |
318 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 324 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
319 | 325 | ||
320 | // Get the brush, which will have the background pixmap if there is one. | 326 | // Get the brush, which will have the background pixmap if there is one. |
321 | if (b.pixmap()) | 327 | if (b.pixmap()) |
322 | { | 328 | { |
323 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 329 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
324 | *(b.pixmap()), | 330 | *(b.pixmap()), |
325 | rect.left() + contentsX(), | 331 | rect.left() + contentsX(), |
326 | rect.top() + contentsY() ); | 332 | rect.top() + contentsY() ); |
327 | } | 333 | } |
328 | 334 | ||
329 | else | 335 | else |
330 | { | 336 | { |
331 | // Do a normal paint | 337 | // Do a normal paint |
332 | KListView::paintEmptyArea(p, rect); | 338 | KListView::paintEmptyArea(p, rect); |
333 | } | 339 | } |
334 | } | 340 | } |
335 | 341 | ||
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 | } |
381 | else | 387 | else |
382 | { | 388 | { |
383 | setAlternateBackground(QColor()); | 389 | setAlternateBackground(QColor()); |
384 | } | 390 | } |
385 | } | 391 | } |
386 | 392 | ||
387 | void ContactListView::setBackgroundPixmap(const QString &filename) | 393 | void ContactListView::setBackgroundPixmap(const QString &filename) |
388 | { | 394 | { |
389 | if (filename.isEmpty()) | 395 | if (filename.isEmpty()) |
390 | { | 396 | { |
391 | unsetPalette(); | 397 | unsetPalette(); |
392 | } | 398 | } |
393 | else | 399 | else |
394 | { | 400 | { |
395 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 401 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
396 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 402 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
397 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 403 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
398 | } | 404 | } |
399 | 405 | ||
400 | } | 406 | } |
401 | 407 | ||
402 | void ContactListView::keyPressEvent ( QKeyEvent * e ) | 408 | 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 |