Diffstat (limited to 'kaddressbook/views/contactlistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index e75810e..09d9c03 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -8,48 +8,49 @@ | |||
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 <qheader.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <qdragobject.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 | 33 | ||
33 | #include <klocale.h> | 34 | #include <klocale.h> |
34 | #include <kglobalsettings.h> | 35 | #include <kglobalsettings.h> |
35 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
36 | #include <kdebug.h> | 37 | #include <kdebug.h> |
37 | #include <kconfig.h> | 38 | #include <kconfig.h> |
38 | #include <kapplication.h> | 39 | #include <kapplication.h> |
39 | #include <kurl.h> | 40 | #include <kurl.h> |
40 | 41 | ||
41 | #include "kaddressbooktableview.h" | 42 | #include "kaddressbooktableview.h" |
42 | 43 | ||
43 | #include "contactlistview.h" | 44 | #include "contactlistview.h" |
44 | 45 | ||
45 | ///////////////////////////////// | 46 | ///////////////////////////////// |
46 | // DynamicTip Methods | 47 | // DynamicTip Methods |
47 | 48 | ||
48 | DynamicTip::DynamicTip( ContactListView *parent) | 49 | DynamicTip::DynamicTip( ContactListView *parent) |
49 | : QToolTip( parent ) | 50 | : QToolTip( parent ) |
50 | { | 51 | { |
51 | } | 52 | } |
52 | 53 | ||
53 | void DynamicTip::maybeTip( const QPoint &pos ) | 54 | void DynamicTip::maybeTip( const QPoint &pos ) |
54 | { | 55 | { |
55 | static bool ishidden = true; | 56 | static bool ishidden = true; |
@@ -227,48 +228,50 @@ void ContactListViewItem::refresh() | |||
227 | { | 228 | { |
228 | // Update our addressee, since it may have changed else were | 229 | // Update our addressee, since it may have changed else were |
229 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 230 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
230 | if (mAddressee.isEmpty()) | 231 | if (mAddressee.isEmpty()) |
231 | return; | 232 | return; |
232 | 233 | ||
233 | int i = 0; | 234 | int i = 0; |
234 | KABC::Field::List::ConstIterator it; | 235 | KABC::Field::List::ConstIterator it; |
235 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 236 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
236 | setText( i++, (*it)->value( mAddressee ) ); | 237 | setText( i++, (*it)->value( mAddressee ) ); |
237 | } | 238 | } |
238 | } | 239 | } |
239 | 240 | ||
240 | /////////////////////////////// | 241 | /////////////////////////////// |
241 | // ContactListView | 242 | // ContactListView |
242 | 243 | ||
243 | ContactListView::ContactListView(KAddressBookTableView *view, | 244 | ContactListView::ContactListView(KAddressBookTableView *view, |
244 | KABC::AddressBook* /* doc */, | 245 | KABC::AddressBook* /* doc */, |
245 | QWidget *parent, | 246 | QWidget *parent, |
246 | const char *name ) | 247 | const char *name ) |
247 | : KListView( parent, name ), | 248 | : KListView( parent, name ), |
248 | pabWidget( view ), | 249 | pabWidget( view ), |
249 | oldColumn( 0 ) | 250 | oldColumn( 0 ) |
250 | { | 251 | { |
252 | mFlagBlockKeyPressed = false; | ||
253 | mFlagKeyPressed = false; | ||
251 | mABackground = true; | 254 | mABackground = true; |
252 | mSingleLine = false; | 255 | mSingleLine = false; |
253 | mToolTips = true; | 256 | mToolTips = true; |
254 | #ifndef KAB_EMBEDDED | 257 | #ifndef KAB_EMBEDDED |
255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 258 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
256 | #else //KAB_EMBEDDED | 259 | #else //KAB_EMBEDDED |
257 | mAlternateColor = QColor(240, 240, 240); | 260 | mAlternateColor = QColor(240, 240, 240); |
258 | #endif //KAB_EMBEDDED | 261 | #endif //KAB_EMBEDDED |
259 | 262 | ||
260 | setAlternateBackgroundEnabled(mABackground); | 263 | setAlternateBackgroundEnabled(mABackground); |
261 | setAcceptDrops( true ); | 264 | setAcceptDrops( true ); |
262 | viewport()->setAcceptDrops( true ); | 265 | viewport()->setAcceptDrops( true ); |
263 | setAllColumnsShowFocus( true ); | 266 | setAllColumnsShowFocus( true ); |
264 | setShowSortIndicator(true); | 267 | setShowSortIndicator(true); |
265 | 268 | ||
266 | setSelectionModeExt( KListView::Extended ); | 269 | setSelectionModeExt( KListView::Extended ); |
267 | setDropVisualizer(false); | 270 | setDropVisualizer(false); |
268 | // setFrameStyle(QFrame::NoFrame); | 271 | // setFrameStyle(QFrame::NoFrame); |
269 | //setLineWidth ( 0 ); | 272 | //setLineWidth ( 0 ); |
270 | //setMidLineWidth ( 0 ); | 273 | //setMidLineWidth ( 0 ); |
271 | //setMargin ( 0 ); | 274 | //setMargin ( 0 ); |
272 | #ifndef KAB_EMBEDDED | 275 | #ifndef KAB_EMBEDDED |
273 | connect(this, SIGNAL(dropped(QDropEvent*)), | 276 | connect(this, SIGNAL(dropped(QDropEvent*)), |
274 | this, SLOT(itemDropped(QDropEvent*))); | 277 | this, SLOT(itemDropped(QDropEvent*))); |
@@ -374,27 +377,53 @@ void ContactListView::setAlternateBackgroundEnabled(bool enabled) | |||
374 | if (mABackground) | 377 | if (mABackground) |
375 | { | 378 | { |
376 | setAlternateBackground(mAlternateColor); | 379 | setAlternateBackground(mAlternateColor); |
377 | } | 380 | } |
378 | else | 381 | else |
379 | { | 382 | { |
380 | setAlternateBackground(QColor()); | 383 | setAlternateBackground(QColor()); |
381 | } | 384 | } |
382 | } | 385 | } |
383 | 386 | ||
384 | void ContactListView::setBackgroundPixmap(const QString &filename) | 387 | void ContactListView::setBackgroundPixmap(const QString &filename) |
385 | { | 388 | { |
386 | if (filename.isEmpty()) | 389 | if (filename.isEmpty()) |
387 | { | 390 | { |
388 | unsetPalette(); | 391 | unsetPalette(); |
389 | } | 392 | } |
390 | else | 393 | else |
391 | { | 394 | { |
392 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 395 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
393 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 396 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
394 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 397 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
395 | } | 398 | } |
396 | 399 | ||
397 | } | 400 | } |
401 | |||
402 | void ContactListView::keyPressEvent ( QKeyEvent * e ) | ||
403 | { | ||
404 | if ( mFlagBlockKeyPressed ) | ||
405 | return; | ||
406 | qApp->processEvents(); | ||
407 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
408 | e->accept(); | ||
409 | return; | ||
410 | } | ||
411 | if (! e->isAutoRepeat() ) | ||
412 | mFlagKeyPressed = true; | ||
413 | KListView::keyPressEvent ( e ); | ||
414 | } | ||
415 | void ContactListView::keyReleaseEvent ( QKeyEvent * e ) | ||
416 | { | ||
417 | if ( mFlagBlockKeyPressed ) | ||
418 | return; | ||
419 | if ( !e->isAutoRepeat() ) { | ||
420 | mFlagBlockKeyPressed = true; | ||
421 | qApp->processEvents(); | ||
422 | mFlagBlockKeyPressed = false; | ||
423 | mFlagKeyPressed = false; | ||
424 | } | ||
425 | KListView::keyReleaseEvent ( e ); | ||
426 | } | ||
398 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
399 | #include "contactlistview.moc" | 428 | #include "contactlistview.moc" |
400 | #endif //KAB_EMBEDDED | 429 | #endif //KAB_EMBEDDED |