-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 09d9c03..9accf78 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -161,197 +161,197 @@ ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | |||
161 | ContactListView *parent, | 161 | ContactListView *parent, |
162 | KABC::AddressBook *doc, | 162 | KABC::AddressBook *doc, |
163 | const KABC::Field::List &fields ) | 163 | const KABC::Field::List &fields ) |
164 | : KListViewItem(parent), mAddressee(a), mFields( fields ), | 164 | : KListViewItem(parent), mAddressee(a), mFields( fields ), |
165 | parentListView( parent ), mDocument(doc) | 165 | parentListView( parent ), mDocument(doc) |
166 | { | 166 | { |
167 | refresh(); | 167 | refresh(); |
168 | } | 168 | } |
169 | 169 | ||
170 | QString ContactListViewItem::key(int column, bool ascending) const | 170 | QString ContactListViewItem::key(int column, bool ascending) const |
171 | { | 171 | { |
172 | #ifndef DESKTOP_VERSION | 172 | #ifndef DESKTOP_VERSION |
173 | int lan = KGlobal::locale()->language(); | 173 | int lan = KGlobal::locale()->language(); |
174 | //qDebug("language %d ", lan); | 174 | //qDebug("language %d ", lan); |
175 | if ( lan == 1 ) { //GERMAN | 175 | if ( lan == 1 ) { //GERMAN |
176 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); | 176 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); |
177 | int start = -1; | 177 | int start = -1; |
178 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { | 178 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { |
179 | ret.at(start-1) = 'a'; | 179 | ret.at(start-1) = 'a'; |
180 | } | 180 | } |
181 | start = -1; | 181 | start = -1; |
182 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { | 182 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { |
183 | ret.at(start-1) = 'o'; | 183 | ret.at(start-1) = 'o'; |
184 | } | 184 | } |
185 | start = -1; | 185 | start = -1; |
186 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { | 186 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { |
187 | ret.at(start-1) = 'o'; | 187 | ret.at(start-1) = 'o'; |
188 | } | 188 | } |
189 | start = -1; | 189 | start = -1; |
190 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { | 190 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { |
191 | ret.at(start-1) = 's'; | 191 | ret.at(start-1) = 's'; |
192 | } | 192 | } |
193 | //qDebug("conv string %s ", ret.latin1()); | 193 | //qDebug("conv string %s ", ret.latin1()); |
194 | 194 | ||
195 | return ret; | 195 | return ret; |
196 | 196 | ||
197 | } | 197 | } |
198 | else | 198 | else |
199 | #endif | 199 | #endif |
200 | return QListViewItem::key(column, ascending).lower(); | 200 | return QListViewItem::key(column, ascending).lower(); |
201 | } | 201 | } |
202 | 202 | ||
203 | void ContactListViewItem::paintCell(QPainter * p, | 203 | void ContactListViewItem::paintCell(QPainter * p, |
204 | const QColorGroup & cg, | 204 | const QColorGroup & cg, |
205 | int column, | 205 | int column, |
206 | int width, | 206 | int width, |
207 | int align) | 207 | int align) |
208 | { | 208 | { |
209 | KListViewItem::paintCell(p, cg, column, width, align); | 209 | KListViewItem::paintCell(p, cg, column, width, align); |
210 | 210 | ||
211 | if ( !p ) | 211 | if ( !p ) |
212 | return; | 212 | return; |
213 | 213 | ||
214 | if (parentListView->singleLine()) { | 214 | if (parentListView->singleLine()) { |
215 | p->setPen( parentListView->alternateColor() ); | 215 | p->setPen( parentListView->alternateColor() ); |
216 | p->drawLine( 0, height() - 1, width, height() - 1 ); | 216 | p->drawLine( 0, height() - 1, width, height() - 1 ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | ContactListView *ContactListViewItem::parent() | 221 | ContactListView *ContactListViewItem::parent() |
222 | { | 222 | { |
223 | return parentListView; | 223 | return parentListView; |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void ContactListViewItem::refresh() | 227 | void ContactListViewItem::refresh() |
228 | { | 228 | { |
229 | // Update our addressee, since it may have changed else were | 229 | // Update our addressee, since it may have changed else were |
230 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 230 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
231 | if (mAddressee.isEmpty()) | 231 | if (mAddressee.isEmpty()) |
232 | return; | 232 | return; |
233 | 233 | ||
234 | int i = 0; | 234 | int i = 0; |
235 | KABC::Field::List::ConstIterator it; | 235 | KABC::Field::List::ConstIterator it; |
236 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 236 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
237 | setText( i++, (*it)->value( mAddressee ) ); | 237 | setText( i++, (*it)->value( mAddressee ) ); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | /////////////////////////////// | 241 | /////////////////////////////// |
242 | // ContactListView | 242 | // ContactListView |
243 | 243 | ||
244 | ContactListView::ContactListView(KAddressBookTableView *view, | 244 | ContactListView::ContactListView(KAddressBookTableView *view, |
245 | KABC::AddressBook* /* doc */, | 245 | KABC::AddressBook* /* doc */, |
246 | QWidget *parent, | 246 | QWidget *parent, |
247 | const char *name ) | 247 | const char *name ) |
248 | : KListView( parent, name ), | 248 | : KListView( parent, name ), |
249 | pabWidget( view ), | 249 | pabWidget( view ), |
250 | oldColumn( 0 ) | 250 | oldColumn( 0 ) |
251 | { | 251 | { |
252 | mFlagBlockKeyPressed = false; | 252 | mFlagBlockKeyPressed = false; |
253 | mFlagKeyPressed = false; | 253 | mFlagKeyPressed = false; |
254 | mABackground = true; | 254 | mABackground = true; |
255 | mSingleLine = false; | 255 | mSingleLine = false; |
256 | mToolTips = true; | 256 | mToolTips = true; |
257 | #ifndef KAB_EMBEDDED | 257 | |
258 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 258 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
259 | #else //KAB_EMBEDDED | 259 | |
260 | mAlternateColor = QColor(240, 240, 240); | 260 | |
261 | #endif //KAB_EMBEDDED | 261 | |
262 | 262 | ||
263 | setAlternateBackgroundEnabled(mABackground); | 263 | setAlternateBackgroundEnabled(mABackground); |
264 | setAcceptDrops( true ); | 264 | setAcceptDrops( true ); |
265 | viewport()->setAcceptDrops( true ); | 265 | viewport()->setAcceptDrops( true ); |
266 | setAllColumnsShowFocus( true ); | 266 | setAllColumnsShowFocus( true ); |
267 | setShowSortIndicator(true); | 267 | setShowSortIndicator(true); |
268 | 268 | ||
269 | setSelectionModeExt( KListView::Extended ); | 269 | setSelectionModeExt( KListView::Extended ); |
270 | setDropVisualizer(false); | 270 | setDropVisualizer(false); |
271 | // setFrameStyle(QFrame::NoFrame); | 271 | // setFrameStyle(QFrame::NoFrame); |
272 | //setLineWidth ( 0 ); | 272 | //setLineWidth ( 0 ); |
273 | //setMidLineWidth ( 0 ); | 273 | //setMidLineWidth ( 0 ); |
274 | //setMargin ( 0 ); | 274 | //setMargin ( 0 ); |
275 | #ifndef KAB_EMBEDDED | 275 | #ifndef KAB_EMBEDDED |
276 | connect(this, SIGNAL(dropped(QDropEvent*)), | 276 | connect(this, SIGNAL(dropped(QDropEvent*)), |
277 | this, SLOT(itemDropped(QDropEvent*))); | 277 | this, SLOT(itemDropped(QDropEvent*))); |
278 | #endif //KAB_EMBEDDED | 278 | #endif //KAB_EMBEDDED |
279 | 279 | ||
280 | 280 | ||
281 | new DynamicTip( this ); | 281 | new DynamicTip( this ); |
282 | } | 282 | } |
283 | void ContactListView::printMe() | 283 | void ContactListView::printMe() |
284 | { | 284 | { |
285 | #ifdef DESKTOP_VERSION | 285 | #ifdef DESKTOP_VERSION |
286 | QPrinter printer; | 286 | QPrinter printer; |
287 | if (!printer.setup() ) | 287 | if (!printer.setup() ) |
288 | return; | 288 | return; |
289 | QPainter p; | 289 | QPainter p; |
290 | p.begin ( &printer ); | 290 | p.begin ( &printer ); |
291 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 291 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
292 | float dx, dy; | 292 | float dx, dy; |
293 | int wid = (m.width() * 9)/10; | 293 | int wid = (m.width() * 9)/10; |
294 | dx = (float) wid/(float)contentsWidth (); | 294 | dx = (float) wid/(float)contentsWidth (); |
295 | dy = (float)(m.height()) / (float)contentsHeight (); | 295 | dy = (float)(m.height()) / (float)contentsHeight (); |
296 | float scale; | 296 | float scale; |
297 | // scale to fit the width or height of the paper | 297 | // scale to fit the width or height of the paper |
298 | if ( dx < dy ) | 298 | if ( dx < dy ) |
299 | scale = dx; | 299 | scale = dx; |
300 | else | 300 | else |
301 | scale = dy; | 301 | scale = dy; |
302 | p.translate( m.width()/10,0 ); | 302 | p.translate( m.width()/10,0 ); |
303 | p.scale( scale, scale ); | 303 | p.scale( scale, scale ); |
304 | qDebug("scale %f ", scale); | 304 | qDebug("scale %f ", scale); |
305 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 305 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
306 | p.end(); | 306 | p.end(); |
307 | qDebug("Why does it not print??? "); | 307 | qDebug("Why does it not print??? "); |
308 | #endif | 308 | #endif |
309 | } | 309 | } |
310 | 310 | ||
311 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 311 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
312 | { | 312 | { |
313 | mAlternateColor = m_AlternateColor; | 313 | mAlternateColor = m_AlternateColor; |
314 | } | 314 | } |
315 | 315 | ||
316 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 316 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
317 | { | 317 | { |
318 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 318 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
319 | 319 | ||
320 | // Get the brush, which will have the background pixmap if there is one. | 320 | // Get the brush, which will have the background pixmap if there is one. |
321 | if (b.pixmap()) | 321 | if (b.pixmap()) |
322 | { | 322 | { |
323 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 323 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
324 | *(b.pixmap()), | 324 | *(b.pixmap()), |
325 | rect.left() + contentsX(), | 325 | rect.left() + contentsX(), |
326 | rect.top() + contentsY() ); | 326 | rect.top() + contentsY() ); |
327 | } | 327 | } |
328 | 328 | ||
329 | else | 329 | else |
330 | { | 330 | { |
331 | // Do a normal paint | 331 | // Do a normal paint |
332 | KListView::paintEmptyArea(p, rect); | 332 | KListView::paintEmptyArea(p, rect); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 336 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) |
337 | { | 337 | { |
338 | presspos = e->pos(); | 338 | presspos = e->pos(); |
339 | KListView::contentsMousePressEvent(e); | 339 | KListView::contentsMousePressEvent(e); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | // To initiate a drag operation | 343 | // To initiate a drag operation |
344 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 344 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) |
345 | { | 345 | { |
346 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { | 346 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { |
347 | emit startAddresseeDrag(); | 347 | emit startAddresseeDrag(); |
348 | } | 348 | } |
349 | else | 349 | else |
350 | KListView::contentsMouseMoveEvent( e ); | 350 | KListView::contentsMouseMoveEvent( e ); |
351 | } | 351 | } |
352 | 352 | ||
353 | bool ContactListView::acceptDrag(QDropEvent *e) const | 353 | bool ContactListView::acceptDrag(QDropEvent *e) const |
354 | { | 354 | { |
355 | #ifndef KAB_EMBEDDED | 355 | #ifndef KAB_EMBEDDED |
356 | return QTextDrag::canDecode(e); | 356 | return QTextDrag::canDecode(e); |
357 | #else //KAB_EMBEDDED | 357 | #else //KAB_EMBEDDED |