summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/ablabel.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/ablabel.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/ablabel.cpp98
1 files changed, 62 insertions, 36 deletions
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
@@ -22,69 +22,95 @@
#include <qpe/stringutil.h>
#include <qregexp.h>
#include <qstylesheet.h>
-AbLabel::AbLabel( QWidget *parent, const char *name )
- : QTextView( parent, name )
+AbLabel::AbLabel( QWidget *parent, const char *name ):
+ QTextView( parent, name ),
+ m_empty( false )
{
}
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;
}
}
+
}