From 8401def65aa4f19d91873bc57a3dcf25c358c490 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 18 Nov 2002 09:38:28 +0000 Subject: Back to main tree. Back to main tree. Back to main tree. Waiting for moving to feature freeze .. --- (limited to 'core/pim/addressbook/ablabel.cpp') diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp index ea80700..5b40dc1 100644 --- a/core/pim/addressbook/ablabel.cpp +++ b/core/pim/addressbook/ablabel.cpp @@ -25,8 +25,9 @@ #include #include -AbLabel::AbLabel( QWidget *parent, const char *name ) - : QTextView( parent, name ) +AbLabel::AbLabel( QWidget *parent, const char *name ): + QTextView( parent, name ), + m_empty( false ) { } @@ -34,57 +35,82 @@ AbLabel::~AbLabel() { } -void AbLabel::init( const OContact &entry ) +void AbLabel::setContacts( const OContactAccess::List& viewList ) { - ent = entry; + m_viewList = viewList; + if (m_viewList.count() != 0){ + m_empty = false; + m_itCurContact = m_viewList.begin(); + sync(); + }else{ + // m_itCurContact.clear(); + m_empty = true; + setText( "" ); + } +} + +int AbLabel::currentEntry_UID() +{ + return ( (*m_itCurContact).uid() ); +} + +OContact AbLabel::currentEntry() +{ + return ( *m_itCurContact ); } + +bool AbLabel::selectContact( int UID ) +{ + + for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){ + if ( (*m_itCurContact).uid() == UID ) + break; + } + sync(); + + return true; +} + + + void AbLabel::sync() { - QString text = ent.toRichText(); + QString text = (*m_itCurContact).toRichText(); setText( text ); } void AbLabel::keyPressEvent( QKeyEvent *e ) { // Commonly handled keys - switch( e->key() ) { - case Qt::Key_Left: - qWarning( "Left.."); - case Qt::Key_F33: - qWarning( "OK.."); - emit okPressed(); - break; - } - - - if ( /* m_inSearch */ false ) { - // Running in seach-mode, therefore we will interprete - // some key differently - qWarning("Received key in search mode"); + if ( !m_empty ){ switch( e->key() ) { - case Qt::Key_Up: - qWarning("a"); - // emit signalSearchBackward(); - break; - case Qt::Key_Down: - qWarning("b"); - // emit signalSearchNext(); + case Qt::Key_Left: + qWarning( "Left.."); + case Qt::Key_Right: + qWarning( "Right.."); + case Qt::Key_F33: + qWarning( "OK.."); + emit signalOkPressed(); break; - } - - } else { - qWarning("Received key in NON search mode"); - - switch( e->key() ) { case Qt::Key_Up: - qWarning("a"); - // emit signalSearchBackward(); + qWarning( "UP.."); + --m_itCurContact; + if ( *m_itCurContact != OContact() ) + sync(); + else + m_itCurContact = m_viewList.end(); + break; case Qt::Key_Down: - qWarning("b"); - // emit signalSearchNext(); + qWarning( "DOWN.."); + ++m_itCurContact; + if ( *m_itCurContact != OContact() ) + sync(); + else + m_itCurContact = m_viewList.begin(); break; } } + } -- cgit v0.9.0.2