Diffstat (limited to 'core/pim/addressbook/ablabel.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/ablabel.cpp | 98 |
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 | |||
@@ -25,8 +25,9 @@ | |||
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qstylesheet.h> | 26 | #include <qstylesheet.h> |
27 | 27 | ||
28 | AbLabel::AbLabel( QWidget *parent, const char *name ) | 28 | AbLabel::AbLabel( QWidget *parent, const char *name ): |
29 | : QTextView( parent, name ) | 29 | QTextView( parent, name ), |
30 | m_empty( false ) | ||
30 | { | 31 | { |
31 | } | 32 | } |
32 | 33 | ||
@@ -34,57 +35,82 @@ AbLabel::~AbLabel() | |||
34 | { | 35 | { |
35 | } | 36 | } |
36 | 37 | ||
37 | void AbLabel::init( const OContact &entry ) | 38 | void AbLabel::setContacts( const OContactAccess::List& viewList ) |
38 | { | 39 | { |
39 | ent = entry; | 40 | m_viewList = viewList; |
41 | if (m_viewList.count() != 0){ | ||
42 | m_empty = false; | ||
43 | m_itCurContact = m_viewList.begin(); | ||
44 | sync(); | ||
45 | }else{ | ||
46 | // m_itCurContact.clear(); | ||
47 | m_empty = true; | ||
48 | setText( "" ); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | int AbLabel::currentEntry_UID() | ||
53 | { | ||
54 | return ( (*m_itCurContact).uid() ); | ||
55 | } | ||
56 | |||
57 | OContact AbLabel::currentEntry() | ||
58 | { | ||
59 | return ( *m_itCurContact ); | ||
40 | } | 60 | } |
41 | 61 | ||
62 | |||
63 | bool AbLabel::selectContact( int UID ) | ||
64 | { | ||
65 | |||
66 | for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){ | ||
67 | if ( (*m_itCurContact).uid() == UID ) | ||
68 | break; | ||
69 | } | ||
70 | sync(); | ||
71 | |||
72 | return true; | ||
73 | } | ||
74 | |||
75 | |||
76 | |||
42 | void AbLabel::sync() | 77 | void AbLabel::sync() |
43 | { | 78 | { |
44 | QString text = ent.toRichText(); | 79 | QString text = (*m_itCurContact).toRichText(); |
45 | setText( text ); | 80 | setText( text ); |
46 | } | 81 | } |
47 | 82 | ||
48 | void AbLabel::keyPressEvent( QKeyEvent *e ) | 83 | void AbLabel::keyPressEvent( QKeyEvent *e ) |
49 | { | 84 | { |
50 | // Commonly handled keys | 85 | // Commonly handled keys |
51 | switch( e->key() ) { | 86 | if ( !m_empty ){ |
52 | case Qt::Key_Left: | ||
53 | qWarning( "Left.."); | ||
54 | case Qt::Key_F33: | ||
55 | qWarning( "OK.."); | ||
56 | emit okPressed(); | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | |||
61 | if ( /* m_inSearch */ false ) { | ||
62 | // Running in seach-mode, therefore we will interprete | ||
63 | // some key differently | ||
64 | qWarning("Received key in search mode"); | ||
65 | switch( e->key() ) { | 87 | switch( e->key() ) { |
66 | case Qt::Key_Up: | 88 | case Qt::Key_Left: |
67 | qWarning("a"); | 89 | qWarning( "Left.."); |
68 | // emit signalSearchBackward(); | 90 | case Qt::Key_Right: |
69 | break; | 91 | qWarning( "Right.."); |
70 | case Qt::Key_Down: | 92 | case Qt::Key_F33: |
71 | qWarning("b"); | 93 | qWarning( "OK.."); |
72 | // emit signalSearchNext(); | 94 | emit signalOkPressed(); |
73 | break; | 95 | break; |
74 | } | ||
75 | |||
76 | } else { | ||
77 | qWarning("Received key in NON search mode"); | ||
78 | |||
79 | switch( e->key() ) { | ||
80 | case Qt::Key_Up: | 96 | case Qt::Key_Up: |
81 | qWarning("a"); | 97 | qWarning( "UP.."); |
82 | // emit signalSearchBackward(); | 98 | --m_itCurContact; |
99 | if ( *m_itCurContact != OContact() ) | ||
100 | sync(); | ||
101 | else | ||
102 | m_itCurContact = m_viewList.end(); | ||
103 | |||
83 | break; | 104 | break; |
84 | case Qt::Key_Down: | 105 | case Qt::Key_Down: |
85 | qWarning("b"); | 106 | qWarning( "DOWN.."); |
86 | // emit signalSearchNext(); | 107 | ++m_itCurContact; |
108 | if ( *m_itCurContact != OContact() ) | ||
109 | sync(); | ||
110 | else | ||
111 | m_itCurContact = m_viewList.begin(); | ||
87 | break; | 112 | break; |
88 | } | 113 | } |
89 | } | 114 | } |
115 | |||
90 | } | 116 | } |