author | drw <drw> | 2005-02-07 20:38:20 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-07 20:38:20 (UTC) |
commit | 9f7017a1a571991763ed53066b64988cefdff07b (patch) (unidiff) | |
tree | 54028bb0ab76c4dfd7cec67474d98cb1a08912ce | |
parent | e56c7dfec502972fc7efcd9e0357c371d0e9cd15 (diff) | |
download | opie-9f7017a1a571991763ed53066b64988cefdff07b.zip opie-9f7017a1a571991763ed53066b64988cefdff07b.tar.gz opie-9f7017a1a571991763ed53066b64988cefdff07b.tar.bz2 |
Eliminate compiler warnings
-rw-r--r-- | core/pim/addressbook/ablabel.cpp | 2 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp index 6b8e4dd..139030d 100644 --- a/core/pim/addressbook/ablabel.cpp +++ b/core/pim/addressbook/ablabel.cpp | |||
@@ -1,144 +1,144 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "ablabel.h" | 21 | #include "ablabel.h" |
22 | 22 | ||
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | AbLabel::AbLabel( QWidget *parent, const char *name ): | 25 | AbLabel::AbLabel( QWidget *parent, const char *name ): |
26 | QTextView( parent, name ), | 26 | QTextView( parent, name ), |
27 | m_empty( false ) | 27 | m_empty( false ) |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | AbLabel::~AbLabel() | 31 | AbLabel::~AbLabel() |
32 | { | 32 | { |
33 | } | 33 | } |
34 | 34 | ||
35 | void AbLabel::setContacts( const Opie::OPimContactAccess::List& viewList ) | 35 | void AbLabel::setContacts( const Opie::OPimContactAccess::List& viewList ) |
36 | { | 36 | { |
37 | m_viewList = viewList; | 37 | m_viewList = viewList; |
38 | if (m_viewList.count() != 0){ | 38 | if (m_viewList.count() != 0){ |
39 | m_empty = false; | 39 | m_empty = false; |
40 | m_itCurContact = m_viewList.begin(); | 40 | m_itCurContact = m_viewList.begin(); |
41 | sync(); | 41 | sync(); |
42 | }else{ | 42 | }else{ |
43 | // m_itCurContact.clear(); | 43 | // m_itCurContact.clear(); |
44 | m_empty = true; | 44 | m_empty = true; |
45 | setText( "" ); | 45 | setText( "" ); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | int AbLabel::currentEntry_UID() | 49 | int AbLabel::currentEntry_UID() |
50 | { | 50 | { |
51 | Opie::OPimContact contact = currentEntry(); | 51 | Opie::OPimContact contact = currentEntry(); |
52 | 52 | ||
53 | if ( contact.isEmpty() ) | 53 | if ( contact.isEmpty() ) |
54 | return 0; | 54 | return 0; |
55 | else | 55 | else |
56 | return ( contact.uid() ); | 56 | return ( contact.uid() ); |
57 | } | 57 | } |
58 | 58 | ||
59 | Opie::OPimContact AbLabel::currentEntry() | 59 | Opie::OPimContact AbLabel::currentEntry() |
60 | { | 60 | { |
61 | if ( ! m_empty ) | 61 | if ( ! m_empty ) |
62 | return ( *m_itCurContact ); | 62 | return ( *m_itCurContact ); |
63 | else | 63 | else |
64 | return Opie::OPimContact(); | 64 | return Opie::OPimContact(); |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | bool AbLabel::selectContact( int UID ) | 68 | bool AbLabel::selectContact( int UID ) |
69 | { | 69 | { |
70 | 70 | ||
71 | for ( int r = 0; r < m_viewList.count(); ++r ) { | 71 | for ( uint r = 0; r < m_viewList.count(); ++r ) { |
72 | if ( m_viewList.uidAt( r ) == UID ){ | 72 | if ( m_viewList.uidAt( r ) == UID ){ |
73 | m_itCurContact.setCurrent( r ); | 73 | m_itCurContact.setCurrent( r ); |
74 | break; | 74 | break; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | sync(); | 78 | sync(); |
79 | 79 | ||
80 | return true; | 80 | return true; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | void AbLabel::sync() | 85 | void AbLabel::sync() |
86 | { | 86 | { |
87 | QString text = (*m_itCurContact).toRichText(); | 87 | QString text = (*m_itCurContact).toRichText(); |
88 | setText( text ); | 88 | setText( text ); |
89 | } | 89 | } |
90 | 90 | ||
91 | void AbLabel::keyPressEvent( QKeyEvent *e ) | 91 | void AbLabel::keyPressEvent( QKeyEvent *e ) |
92 | { | 92 | { |
93 | 93 | ||
94 | // Commonly handled keys | 94 | // Commonly handled keys |
95 | if ( !m_empty ){ | 95 | if ( !m_empty ){ |
96 | switch( e->key() ) { | 96 | switch( e->key() ) { |
97 | case Qt::Key_Left: | 97 | case Qt::Key_Left: |
98 | odebug << "Left.." << oendl; | 98 | odebug << "Left.." << oendl; |
99 | case Qt::Key_Right: | 99 | case Qt::Key_Right: |
100 | odebug << "Right.." << oendl; | 100 | odebug << "Right.." << oendl; |
101 | case Qt::Key_F33: | 101 | case Qt::Key_F33: |
102 | odebug << "OK.." << oendl; | 102 | odebug << "OK.." << oendl; |
103 | emit signalOkPressed(); | 103 | emit signalOkPressed(); |
104 | break; | 104 | break; |
105 | case Qt::Key_Up: | 105 | case Qt::Key_Up: |
106 | odebug << "Up.." << oendl; | 106 | odebug << "Up.." << oendl; |
107 | if ( ( visibleHeight() < contentsHeight() ) && | 107 | if ( ( visibleHeight() < contentsHeight() ) && |
108 | ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) ) | 108 | ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) ) |
109 | scrollBy( 0, -(visibleHeight()-20) ); | 109 | scrollBy( 0, -(visibleHeight()-20) ); |
110 | else { | 110 | else { |
111 | --m_itCurContact; | 111 | --m_itCurContact; |
112 | if ( *m_itCurContact != Opie::OPimContact() ) | 112 | if ( *m_itCurContact != Opie::OPimContact() ) |
113 | sync(); | 113 | sync(); |
114 | else | 114 | else |
115 | m_itCurContact = m_viewList.end(); | 115 | m_itCurContact = m_viewList.end(); |
116 | } | 116 | } |
117 | 117 | ||
118 | break; | 118 | break; |
119 | case Qt::Key_Down: | 119 | case Qt::Key_Down: |
120 | odebug << "Down.." << oendl; | 120 | odebug << "Down.." << oendl; |
121 | // odebug << "Visible: " << visibleHeight() << ", content: " << contentHeight() << oendl; | 121 | // odebug << "Visible: " << visibleHeight() << ", content: " << contentHeight() << oendl; |
122 | // odebug << "Value: " << verticalScrollBar()->value() | 122 | // odebug << "Value: " << verticalScrollBar()->value() |
123 | // << ", barMaxValue: " << verticalScrollBar()->maxValue() << oendl; | 123 | // << ", barMaxValue: " << verticalScrollBar()->maxValue() << oendl; |
124 | if ( ( visibleHeight() < contentsHeight() ) && | 124 | if ( ( visibleHeight() < contentsHeight() ) && |
125 | ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) ) | 125 | ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) ) |
126 | scrollBy( 0, visibleHeight()-20 ); | 126 | scrollBy( 0, visibleHeight()-20 ); |
127 | else { | 127 | else { |
128 | ++m_itCurContact; | 128 | ++m_itCurContact; |
129 | if ( *m_itCurContact != Opie::OPimContact() ) | 129 | if ( *m_itCurContact != Opie::OPimContact() ) |
130 | sync(); | 130 | sync(); |
131 | else | 131 | else |
132 | m_itCurContact = m_viewList.begin(); | 132 | m_itCurContact = m_viewList.begin(); |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | case Qt::Key_Return: // fall through | 135 | case Qt::Key_Return: // fall through |
136 | case Qt::Key_Space: // fall through | 136 | case Qt::Key_Space: // fall through |
137 | case Qt::Key_Enter: // we want to switch back | 137 | case Qt::Key_Enter: // we want to switch back |
138 | emit signalOkPressed(); | 138 | emit signalOkPressed(); |
139 | break; | 139 | break; |
140 | default: break; | 140 | default: break; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | } | 144 | } |
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 30d749c..0be7d1a 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,841 +1,840 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of Qt Palmtop Environment. | 5 | ** This file is part of Qt Palmtop Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <opie2/opimrecordlist.h> | 23 | #include <opie2/opimrecordlist.h> |
24 | 24 | ||
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include "abtable.h" | 28 | #include "abtable.h" |
29 | 29 | ||
30 | #include <errno.h> | 30 | #include <errno.h> |
31 | #include <fcntl.h> | 31 | #include <fcntl.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | #include <ctype.h> //toupper() for key hack | 35 | #include <ctype.h> //toupper() for key hack |
36 | 36 | ||
37 | #if 0 | 37 | #if 0 |
38 | 38 | ||
39 | /*! | 39 | /*! |
40 | \class AbTableItem abtable.h | 40 | \class AbTableItem abtable.h |
41 | 41 | ||
42 | \brief QTableItem based class for showing a field of an entry | 42 | \brief QTableItem based class for showing a field of an entry |
43 | */ | 43 | */ |
44 | 44 | ||
45 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 45 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
46 | const QString &secondSortKey) | 46 | const QString &secondSortKey) |
47 | : QTableItem( t, et, s ) | 47 | : QTableItem( t, et, s ) |
48 | { | 48 | { |
49 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 49 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
50 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 50 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
51 | } | 51 | } |
52 | 52 | ||
53 | int AbTableItem::alignment() const | 53 | int AbTableItem::alignment() const |
54 | { | 54 | { |
55 | return AlignLeft|AlignVCenter; | 55 | return AlignLeft|AlignVCenter; |
56 | } | 56 | } |
57 | 57 | ||
58 | QString AbTableItem::key() const | 58 | QString AbTableItem::key() const |
59 | { | 59 | { |
60 | return sortKey; | 60 | return sortKey; |
61 | } | 61 | } |
62 | 62 | ||
63 | // A way to reset the item, without out doing a delete or a new... | 63 | // A way to reset the item, without out doing a delete or a new... |
64 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 64 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
65 | { | 65 | { |
66 | setText( txt ); | 66 | setText( txt ); |
67 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 67 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
68 | 68 | ||
69 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 69 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
70 | } | 70 | } |
71 | 71 | ||
72 | /*! | 72 | /*! |
73 | \class AbPickItem abtable.h | 73 | \class AbPickItem abtable.h |
74 | 74 | ||
75 | \brief QTableItem based class for showing slection of an entry | 75 | \brief QTableItem based class for showing slection of an entry |
76 | */ | 76 | */ |
77 | 77 | ||
78 | AbPickItem::AbPickItem( QTable *t ) : | 78 | AbPickItem::AbPickItem( QTable *t ) : |
79 | QTableItem(t, WhenCurrent, "?") | 79 | QTableItem(t, WhenCurrent, "?") |
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | QWidget *AbPickItem::createEditor() const | 83 | QWidget *AbPickItem::createEditor() const |
84 | { | 84 | { |
85 | QComboBox* combo = new QComboBox( table()->viewport() ); | 85 | QComboBox* combo = new QComboBox( table()->viewport() ); |
86 | ( (AbPickItem*)this )->cb = combo; | 86 | ( (AbPickItem*)this )->cb = combo; |
87 | AbTable* t = static_cast<AbTable*>(table()); | 87 | AbTable* t = static_cast<AbTable*>(table()); |
88 | QStringList c = t->choiceNames(); | 88 | QStringList c = t->choiceNames(); |
89 | int cur = 0; | 89 | int cur = 0; |
90 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 90 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
91 | if ( *it == text() ) | 91 | if ( *it == text() ) |
92 | cur = combo->count(); | 92 | cur = combo->count(); |
93 | combo->insertItem(*it); | 93 | combo->insertItem(*it); |
94 | } | 94 | } |
95 | combo->setCurrentItem(cur); | 95 | combo->setCurrentItem(cur); |
96 | return combo; | 96 | return combo; |
97 | } | 97 | } |
98 | 98 | ||
99 | void AbPickItem::setContentFromEditor( QWidget *w ) | 99 | void AbPickItem::setContentFromEditor( QWidget *w ) |
100 | { | 100 | { |
101 | if ( w->inherits("QComboBox") ) | 101 | if ( w->inherits("QComboBox") ) |
102 | setText( ( (QComboBox*)w )->currentText() ); | 102 | setText( ( (QComboBox*)w )->currentText() ); |
103 | else | 103 | else |
104 | QTableItem::setContentFromEditor( w ); | 104 | QTableItem::setContentFromEditor( w ); |
105 | } | 105 | } |
106 | 106 | ||
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | /*! | 109 | /*! |
110 | \class AbTable abtable.h | 110 | \class AbTable abtable.h |
111 | 111 | ||
112 | \brief QTable based class for showing a list of entries | 112 | \brief QTable based class for showing a list of entries |
113 | */ | 113 | */ |
114 | 114 | ||
115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 115 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
116 | : QTable( parent, name ), | 116 | : QTable( parent, name ), |
117 | lastSortCol( -1 ), | 117 | lastSortCol( -1 ), |
118 | asc( TRUE ), | 118 | asc( TRUE ), |
119 | intFields( order ), | 119 | intFields( order ), |
120 | enablePainting( true ), | 120 | enablePainting( true ), |
121 | columnVisible( true ), | 121 | columnVisible( true ), |
122 | countNested( 0 ) | 122 | countNested( 0 ) |
123 | { | 123 | { |
124 | //odebug << "C'tor start" << oendl; | 124 | //odebug << "C'tor start" << oendl; |
125 | setSelectionMode( NoSelection ); | 125 | setSelectionMode( NoSelection ); |
126 | init(); | 126 | init(); |
127 | setSorting( TRUE ); | 127 | setSorting( TRUE ); |
128 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), | 128 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), |
129 | this, SLOT(itemClicked(int,int)) ); | 129 | this, SLOT(itemClicked(int,int)) ); |
130 | 130 | ||
131 | // contactList.clear(); | 131 | // contactList.clear(); |
132 | //odebug << "C'tor end" << oendl; | 132 | //odebug << "C'tor end" << oendl; |
133 | } | 133 | } |
134 | 134 | ||
135 | AbTable::~AbTable() | 135 | AbTable::~AbTable() |
136 | { | 136 | { |
137 | } | 137 | } |
138 | 138 | ||
139 | void AbTable::init() | 139 | void AbTable::init() |
140 | { | 140 | { |
141 | // :SX showChar = '\0'; | 141 | // :SX showChar = '\0'; |
142 | setNumRows( 0 ); | 142 | setNumRows( 0 ); |
143 | setNumCols( 2 ); | 143 | setNumCols( 2 ); |
144 | 144 | ||
145 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 145 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
146 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 146 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
147 | setLeftMargin( 0 ); | 147 | setLeftMargin( 0 ); |
148 | verticalHeader()->hide(); | 148 | verticalHeader()->hide(); |
149 | columnVisible = true; | 149 | columnVisible = true; |
150 | } | 150 | } |
151 | 151 | ||
152 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) | 152 | void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) |
153 | { | 153 | { |
154 | odebug << "AbTable::setContacts()" << oendl; | 154 | odebug << "AbTable::setContacts()" << oendl; |
155 | 155 | ||
156 | clear(); | 156 | clear(); |
157 | m_viewList = viewList; | 157 | m_viewList = viewList; |
158 | 158 | ||
159 | setSorting( false ); | 159 | setSorting( false ); |
160 | setPaintingEnabled( FALSE ); | 160 | setPaintingEnabled( FALSE ); |
161 | 161 | ||
162 | Opie::OPimContactAccess::List::Iterator it; | 162 | Opie::OPimContactAccess::List::Iterator it; |
163 | setNumRows( m_viewList.count() ); | 163 | setNumRows( m_viewList.count() ); |
164 | //int row = 0; | 164 | //int row = 0; |
165 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 165 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
166 | // insertIntoTable( *it, row++ ); | 166 | // insertIntoTable( *it, row++ ); |
167 | 167 | ||
168 | // setSorting( true ); | 168 | // setSorting( true ); |
169 | 169 | ||
170 | // resort(); | 170 | // resort(); |
171 | 171 | ||
172 | updateVisible(); | 172 | updateVisible(); |
173 | 173 | ||
174 | setPaintingEnabled( TRUE ); | 174 | setPaintingEnabled( TRUE ); |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 178 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
179 | { | 179 | { |
180 | intFields = ordered; | 180 | intFields = ordered; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool AbTable::selectContact( int UID ) | 184 | bool AbTable::selectContact( int UID ) |
185 | { | 185 | { |
186 | odebug << "AbTable::selectContact( " << UID << " )" << oendl; | 186 | odebug << "AbTable::selectContact( " << UID << " )" << oendl; |
187 | int rows = numRows(); | 187 | int rows = numRows(); |
188 | Opie::OPimContact* foundContact = 0l; | ||
189 | bool found = false; | 188 | bool found = false; |
190 | 189 | ||
191 | setPaintingEnabled( FALSE ); | 190 | setPaintingEnabled( FALSE ); |
192 | odebug << "Search start" << oendl; | 191 | odebug << "Search start" << oendl; |
193 | for ( int r = 0; r < rows; ++r ) { | 192 | for ( int r = 0; r < rows; ++r ) { |
194 | if ( m_viewList.uidAt( r ) == UID ){ | 193 | if ( m_viewList.uidAt( r ) == UID ){ |
195 | ensureCellVisible( r, 0 ); | 194 | ensureCellVisible( r, 0 ); |
196 | setCurrentCell( r, 0 ); | 195 | setCurrentCell( r, 0 ); |
197 | found = true; | 196 | found = true; |
198 | break; | 197 | break; |
199 | } | 198 | } |
200 | } | 199 | } |
201 | odebug << "Search end" << oendl; | 200 | odebug << "Search end" << oendl; |
202 | 201 | ||
203 | if ( !found ){ | 202 | if ( !found ){ |
204 | ensureCellVisible( 0,0 ); | 203 | ensureCellVisible( 0,0 ); |
205 | setCurrentCell( 0, 0 ); | 204 | setCurrentCell( 0, 0 ); |
206 | } | 205 | } |
207 | 206 | ||
208 | setPaintingEnabled( TRUE ); | 207 | setPaintingEnabled( TRUE ); |
209 | 208 | ||
210 | return true; | 209 | return true; |
211 | } | 210 | } |
212 | 211 | ||
213 | #if 0 | 212 | #if 0 |
214 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) | 213 | void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) |
215 | { | 214 | { |
216 | odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " | 215 | odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " |
217 | << row << " )" << oendl; | 216 | << row << " )" << oendl; |
218 | QString strName; | 217 | QString strName; |
219 | ContactItem contactItem; | 218 | ContactItem contactItem; |
220 | 219 | ||
221 | strName = findContactName( cnt ); | 220 | strName = findContactName( cnt ); |
222 | contactItem = findContactContact( cnt, row ); | 221 | contactItem = findContactContact( cnt, row ); |
223 | 222 | ||
224 | AbTableItem *ati; | 223 | AbTableItem *ati; |
225 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 224 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
226 | contactList.insert( ati, cnt ); | 225 | contactList.insert( ati, cnt ); |
227 | setItem( row, 0, ati ); | 226 | setItem( row, 0, ati ); |
228 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 227 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
229 | if ( !contactItem.icon.isNull() ) | 228 | if ( !contactItem.icon.isNull() ) |
230 | ati->setPixmap( contactItem.icon ); | 229 | ati->setPixmap( contactItem.icon ); |
231 | setItem( row, 1, ati ); | 230 | setItem( row, 1, ati ); |
232 | 231 | ||
233 | //### cannot do this; table only has two columns at this point | 232 | //### cannot do this; table only has two columns at this point |
234 | // setItem( row, 2, new AbPickItem( this ) ); | 233 | // setItem( row, 2, new AbPickItem( this ) ); |
235 | 234 | ||
236 | } | 235 | } |
237 | #endif | 236 | #endif |
238 | 237 | ||
239 | 238 | ||
240 | void AbTable::columnClicked( int col ) | 239 | void AbTable::columnClicked( int col ) |
241 | { | 240 | { |
242 | if ( !sorting() ) | 241 | if ( !sorting() ) |
243 | return; | 242 | return; |
244 | 243 | ||
245 | if ( lastSortCol == -1 ) | 244 | if ( lastSortCol == -1 ) |
246 | lastSortCol = col; | 245 | lastSortCol = col; |
247 | 246 | ||
248 | if ( col == lastSortCol ) { | 247 | if ( col == lastSortCol ) { |
249 | asc = !asc; | 248 | asc = !asc; |
250 | } else { | 249 | } else { |
251 | lastSortCol = col; | 250 | lastSortCol = col; |
252 | asc = TRUE; | 251 | asc = TRUE; |
253 | } | 252 | } |
254 | //QMessageBox::information( this, "resort", "columnClicked" ); | 253 | //QMessageBox::information( this, "resort", "columnClicked" ); |
255 | resort(); | 254 | resort(); |
256 | } | 255 | } |
257 | 256 | ||
258 | void AbTable::resort() | 257 | void AbTable::resort() |
259 | { | 258 | { |
260 | owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; | 259 | owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; |
261 | #if 0 | 260 | #if 0 |
262 | setPaintingEnabled( FALSE ); | 261 | setPaintingEnabled( FALSE ); |
263 | if ( sorting() ) { | 262 | if ( sorting() ) { |
264 | if ( lastSortCol == -1 ) | 263 | if ( lastSortCol == -1 ) |
265 | lastSortCol = 0; | 264 | lastSortCol = 0; |
266 | sortColumn( lastSortCol, asc, TRUE ); | 265 | sortColumn( lastSortCol, asc, TRUE ); |
267 | //QMessageBox::information( this, "resort", "resort" ); | 266 | //QMessageBox::information( this, "resort", "resort" ); |
268 | updateVisible(); | 267 | updateVisible(); |
269 | } | 268 | } |
270 | setPaintingEnabled( TRUE ); | 269 | setPaintingEnabled( TRUE ); |
271 | #endif | 270 | #endif |
272 | } | 271 | } |
273 | 272 | ||
274 | Opie::OPimContact AbTable::currentEntry() | 273 | Opie::OPimContact AbTable::currentEntry() |
275 | { | 274 | { |
276 | return m_viewList[currentRow()]; | 275 | return m_viewList[currentRow()]; |
277 | } | 276 | } |
278 | 277 | ||
279 | int AbTable::currentEntry_UID() | 278 | int AbTable::currentEntry_UID() |
280 | { | 279 | { |
281 | return ( currentEntry().uid() ); | 280 | return ( currentEntry().uid() ); |
282 | } | 281 | } |
283 | 282 | ||
284 | void AbTable::clear() | 283 | void AbTable::clear() |
285 | { | 284 | { |
286 | odebug << "void AbTable::clear()" << oendl; | 285 | odebug << "void AbTable::clear()" << oendl; |
287 | // contactList.clear(); | 286 | // contactList.clear(); |
288 | 287 | ||
289 | setPaintingEnabled( FALSE ); | 288 | setPaintingEnabled( FALSE ); |
290 | for ( int r = 0; r < numRows(); ++r ) { | 289 | for ( int r = 0; r < numRows(); ++r ) { |
291 | for ( int c = 0; c < numCols(); ++c ) { | 290 | for ( int c = 0; c < numCols(); ++c ) { |
292 | if ( cellWidget( r, c ) ) | 291 | if ( cellWidget( r, c ) ) |
293 | clearCellWidget( r, c ); | 292 | clearCellWidget( r, c ); |
294 | clearCell( r, c ); | 293 | clearCell( r, c ); |
295 | } | 294 | } |
296 | } | 295 | } |
297 | setNumRows( 0 ); | 296 | setNumRows( 0 ); |
298 | setPaintingEnabled( TRUE ); | 297 | setPaintingEnabled( TRUE ); |
299 | } | 298 | } |
300 | 299 | ||
301 | // Refresh updates column 2 if the contactsettings changed | 300 | // Refresh updates column 2 if the contactsettings changed |
302 | void AbTable::refresh() | 301 | void AbTable::refresh() |
303 | { | 302 | { |
304 | owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; | 303 | owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; |
305 | 304 | ||
306 | #if 0 | 305 | #if 0 |
307 | int rows = numRows(); | 306 | int rows = numRows(); |
308 | AbTableItem *abi; | 307 | AbTableItem *abi; |
309 | ContactItem contactItem; | 308 | ContactItem contactItem; |
310 | 309 | ||
311 | setPaintingEnabled( FALSE ); | 310 | setPaintingEnabled( FALSE ); |
312 | for ( int r = 0; r < rows; ++r ) { | 311 | for ( int r = 0; r < rows; ++r ) { |
313 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 312 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
314 | contactItem = findContactContact( contactList[abi], r ); | 313 | contactItem = findContactContact( contactList[abi], r ); |
315 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); | 314 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); |
316 | if ( !contactItem.icon.isNull() ){ | 315 | if ( !contactItem.icon.isNull() ){ |
317 | static_cast<AbTableItem*>( item(r, 1) )-> | 316 | static_cast<AbTableItem*>( item(r, 1) )-> |
318 | setPixmap( contactItem.icon ); | 317 | setPixmap( contactItem.icon ); |
319 | }else{ | 318 | }else{ |
320 | static_cast<AbTableItem*>( item(r, 1) )-> | 319 | static_cast<AbTableItem*>( item(r, 1) )-> |
321 | setPixmap( QPixmap() ); | 320 | setPixmap( QPixmap() ); |
322 | } | 321 | } |
323 | } | 322 | } |
324 | resort(); | 323 | resort(); |
325 | setPaintingEnabled( TRUE ); | 324 | setPaintingEnabled( TRUE ); |
326 | 325 | ||
327 | #endif | 326 | #endif |
328 | } | 327 | } |
329 | 328 | ||
330 | void AbTable::keyPressEvent( QKeyEvent *e ) | 329 | void AbTable::keyPressEvent( QKeyEvent *e ) |
331 | { | 330 | { |
332 | char key = toupper( e->ascii() ); | 331 | char key = toupper( e->ascii() ); |
333 | 332 | ||
334 | if ( key >= 'A' && key <= 'Z' ) | 333 | if ( key >= 'A' && key <= 'Z' ) |
335 | moveTo( key ); | 334 | moveTo( key ); |
336 | 335 | ||
337 | // odebug << "Received key .." << oendl; | 336 | // odebug << "Received key .." << oendl; |
338 | switch( e->key() ) { | 337 | switch( e->key() ) { |
339 | case Qt::Key_Space: | 338 | case Qt::Key_Space: |
340 | case Qt::Key_Return: | 339 | case Qt::Key_Return: |
341 | case Qt::Key_Enter: | 340 | case Qt::Key_Enter: |
342 | emit signalSwitch(); | 341 | emit signalSwitch(); |
343 | break; | 342 | break; |
344 | // case Qt::Key_Up: | 343 | // case Qt::Key_Up: |
345 | // odebug << "a" << oendl; | 344 | // odebug << "a" << oendl; |
346 | // emit signalKeyUp(); | 345 | // emit signalKeyUp(); |
347 | // break; | 346 | // break; |
348 | // case Qt::Key_Down: | 347 | // case Qt::Key_Down: |
349 | // odebug << "b" << oendl; | 348 | // odebug << "b" << oendl; |
350 | // emit signalKeyDown(); | 349 | // emit signalKeyDown(); |
351 | // break; | 350 | // break; |
352 | default: | 351 | default: |
353 | QTable::keyPressEvent( e ); | 352 | QTable::keyPressEvent( e ); |
354 | } | 353 | } |
355 | 354 | ||
356 | } | 355 | } |
357 | 356 | ||
358 | void AbTable::moveTo( char c ) | 357 | void AbTable::moveTo( char /*c*/ ) |
359 | { | 358 | { |
360 | odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; | 359 | odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; |
361 | 360 | ||
362 | #if 0 | 361 | #if 0 |
363 | int rows = numRows(); | 362 | int rows = numRows(); |
364 | QString value; | 363 | QString value; |
365 | AbTableItem *abi; | 364 | AbTableItem *abi; |
366 | int r; | 365 | int r; |
367 | if ( asc ) { | 366 | if ( asc ) { |
368 | r = 0; | 367 | r = 0; |
369 | while ( r < rows-1) { | 368 | while ( r < rows-1) { |
370 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 369 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
371 | QChar first = abi->key()[0]; | 370 | QChar first = abi->key()[0]; |
372 | //### is there a bug in QChar to char comparison??? | 371 | //### is there a bug in QChar to char comparison??? |
373 | if ( first.row() || first.cell() >= c ) | 372 | if ( first.row() || first.cell() >= c ) |
374 | break; | 373 | break; |
375 | r++; | 374 | r++; |
376 | } | 375 | } |
377 | } else { | 376 | } else { |
378 | //### should probably disable reverse sorting instead | 377 | //### should probably disable reverse sorting instead |
379 | r = rows - 1; | 378 | r = rows - 1; |
380 | while ( r > 0 ) { | 379 | while ( r > 0 ) { |
381 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 380 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
382 | QChar first = abi->key()[0]; | 381 | QChar first = abi->key()[0]; |
383 | //### is there a bug in QChar to char comparison??? | 382 | //### is there a bug in QChar to char comparison??? |
384 | if ( first.row() || first.cell() >= c ) | 383 | if ( first.row() || first.cell() >= c ) |
385 | break; | 384 | break; |
386 | r--; | 385 | r--; |
387 | } | 386 | } |
388 | } | 387 | } |
389 | setCurrentCell( r, currentColumn() ); | 388 | setCurrentCell( r, currentColumn() ); |
390 | 389 | ||
391 | #endif | 390 | #endif |
392 | } | 391 | } |
393 | 392 | ||
394 | #if 0 | 393 | #if 0 |
395 | // Useless.. Nobody uses it .. (se) | 394 | // Useless.. Nobody uses it .. (se) |
396 | QString AbTable::findContactName( const Opie::OPimContact &entry ) | 395 | QString AbTable::findContactName( const Opie::OPimContact &entry ) |
397 | { | 396 | { |
398 | // We use the fileAs, then company, defaultEmail | 397 | // We use the fileAs, then company, defaultEmail |
399 | QString str; | 398 | QString str; |
400 | str = entry.fileAs(); | 399 | str = entry.fileAs(); |
401 | if ( str.isEmpty() ) { | 400 | if ( str.isEmpty() ) { |
402 | str = entry.company(); | 401 | str = entry.company(); |
403 | if ( str.isEmpty() ) { | 402 | if ( str.isEmpty() ) { |
404 | str = entry.defaultEmail(); | 403 | str = entry.defaultEmail(); |
405 | } | 404 | } |
406 | } | 405 | } |
407 | return str; | 406 | return str; |
408 | } | 407 | } |
409 | #endif | 408 | #endif |
410 | 409 | ||
411 | 410 | ||
412 | void AbTable::resizeRows() { | 411 | void AbTable::resizeRows() { |
413 | /* | 412 | /* |
414 | if (numRows()) { | 413 | if (numRows()) { |
415 | for (int i = 0; i < numRows(); i++) { | 414 | for (int i = 0; i < numRows(); i++) { |
416 | setRowHeight( i, size ); | 415 | setRowHeight( i, size ); |
417 | } | 416 | } |
418 | } | 417 | } |
419 | updateVisible(); | 418 | updateVisible(); |
420 | */ | 419 | */ |
421 | } | 420 | } |
422 | 421 | ||
423 | 422 | ||
424 | void AbTable::realignTable() | 423 | void AbTable::realignTable() |
425 | { | 424 | { |
426 | //odebug << "void AbTable::realignTable()" << oendl; | 425 | //odebug << "void AbTable::realignTable()" << oendl; |
427 | 426 | ||
428 | setPaintingEnabled( FALSE ); | 427 | setPaintingEnabled( FALSE ); |
429 | 428 | ||
430 | resizeRows(); | 429 | resizeRows(); |
431 | fitColumns(); | 430 | fitColumns(); |
432 | 431 | ||
433 | setPaintingEnabled( TRUE ); | 432 | setPaintingEnabled( TRUE ); |
434 | 433 | ||
435 | } | 434 | } |
436 | 435 | ||
437 | 436 | ||
438 | 437 | ||
439 | 438 | ||
440 | #if QT_VERSION <= 230 | 439 | #if QT_VERSION <= 230 |
441 | #ifndef SINGLE_APP | 440 | #ifndef SINGLE_APP |
442 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 441 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
443 | { | 442 | { |
444 | // Region of the rect we should draw | 443 | // Region of the rect we should draw |
445 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 444 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
446 | // Subtract the table from it | 445 | // Subtract the table from it |
447 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 446 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
448 | // And draw the rectangles (transformed as needed) | 447 | // And draw the rectangles (transformed as needed) |
449 | QArray<QRect> r = reg.rects(); | 448 | QArray<QRect> r = reg.rects(); |
450 | for (unsigned int i=0; i<r.count(); i++) | 449 | for (unsigned int i=0; i<r.count(); i++) |
451 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 450 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
452 | } | 451 | } |
453 | #endif | 452 | #endif |
454 | #endif | 453 | #endif |
455 | 454 | ||
456 | 455 | ||
457 | // int AbTable::rowHeight( int ) const | 456 | // int AbTable::rowHeight( int ) const |
458 | // { | 457 | // { |
459 | // return 18; | 458 | // return 18; |
460 | // } | 459 | // } |
461 | 460 | ||
462 | // int AbTable::rowPos( int row ) const | 461 | // int AbTable::rowPos( int row ) const |
463 | // { | 462 | // { |
464 | // return 18*row; | 463 | // return 18*row; |
465 | // } | 464 | // } |
466 | 465 | ||
467 | // int AbTable::rowAt( int pos ) const | 466 | // int AbTable::rowAt( int pos ) const |
468 | // { | 467 | // { |
469 | // return QMIN( pos/18, numRows()-1 ); | 468 | // return QMIN( pos/18, numRows()-1 ); |
470 | // } | 469 | // } |
471 | 470 | ||
472 | 471 | ||
473 | 472 | ||
474 | void AbTable::fitColumns() | 473 | void AbTable::fitColumns() |
475 | { | 474 | { |
476 | odebug << "void AbTable::fitColumns()" << oendl; | 475 | odebug << "void AbTable::fitColumns()" << oendl; |
477 | int contentsWidth = visibleWidth() / 2; | 476 | int contentsWidth = visibleWidth() / 2; |
478 | // Fix to better value | 477 | // Fix to better value |
479 | // contentsWidth = 130; | 478 | // contentsWidth = 130; |
480 | 479 | ||
481 | setPaintingEnabled( FALSE ); | 480 | setPaintingEnabled( FALSE ); |
482 | 481 | ||
483 | if ( columnVisible == false ){ | 482 | if ( columnVisible == false ){ |
484 | showColumn(0); | 483 | showColumn(0); |
485 | columnVisible = true; | 484 | columnVisible = true; |
486 | } | 485 | } |
487 | 486 | ||
488 | //odebug << "Width: " << contentsWidth << oendl; | 487 | //odebug << "Width: " << contentsWidth << oendl; |
489 | 488 | ||
490 | setColumnWidth( 0, contentsWidth ); | 489 | setColumnWidth( 0, contentsWidth ); |
491 | adjustColumn(1); | 490 | adjustColumn(1); |
492 | if ( columnWidth(1) < contentsWidth ) | 491 | if ( columnWidth(1) < contentsWidth ) |
493 | setColumnWidth( 1, contentsWidth ); | 492 | setColumnWidth( 1, contentsWidth ); |
494 | 493 | ||
495 | setPaintingEnabled( TRUE ); | 494 | setPaintingEnabled( TRUE ); |
496 | } | 495 | } |
497 | 496 | ||
498 | void AbTable::show() | 497 | void AbTable::show() |
499 | { | 498 | { |
500 | //odebug << "void AbTable::show()" << oendl; | 499 | //odebug << "void AbTable::show()" << oendl; |
501 | realignTable(); | 500 | realignTable(); |
502 | QTable::show(); | 501 | QTable::show(); |
503 | } | 502 | } |
504 | 503 | ||
505 | #if 0 | 504 | #if 0 |
506 | void AbTable::setChoiceNames( const QStringList& list) | 505 | void AbTable::setChoiceNames( const QStringList& list) |
507 | { | 506 | { |
508 | choicenames = list; | 507 | choicenames = list; |
509 | if ( choicenames.isEmpty() ) { | 508 | if ( choicenames.isEmpty() ) { |
510 | // hide pick column | 509 | // hide pick column |
511 | setNumCols( 2 ); | 510 | setNumCols( 2 ); |
512 | } else { | 511 | } else { |
513 | // show pick column | 512 | // show pick column |
514 | setNumCols( 3 ); | 513 | setNumCols( 3 ); |
515 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 514 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
516 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 515 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
517 | } | 516 | } |
518 | fitColumns(); | 517 | fitColumns(); |
519 | } | 518 | } |
520 | #endif | 519 | #endif |
521 | 520 | ||
522 | void AbTable::itemClicked(int,int col) | 521 | void AbTable::itemClicked(int,int col) |
523 | { | 522 | { |
524 | //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl; | 523 | //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl; |
525 | if ( col == 2 ) { | 524 | if ( col == 2 ) { |
526 | return; | 525 | return; |
527 | } else { | 526 | } else { |
528 | //odebug << "Emitting signalSwitch()" << oendl; | 527 | //odebug << "Emitting signalSwitch()" << oendl; |
529 | emit signalSwitch(); | 528 | emit signalSwitch(); |
530 | } | 529 | } |
531 | } | 530 | } |
532 | 531 | ||
533 | #if 0 | 532 | #if 0 |
534 | QStringList AbTable::choiceNames() const | 533 | QStringList AbTable::choiceNames() const |
535 | { | 534 | { |
536 | return choicenames; | 535 | return choicenames; |
537 | } | 536 | } |
538 | 537 | ||
539 | #endif | 538 | #endif |
540 | void AbTable::setChoiceSelection( const QValueList<int>& list ) | 539 | void AbTable::setChoiceSelection( const QValueList<int>& list ) |
541 | { | 540 | { |
542 | intFields = list; | 541 | intFields = list; |
543 | } | 542 | } |
544 | 543 | ||
545 | QStringList AbTable::choiceSelection(int /*index*/) const | 544 | QStringList AbTable::choiceSelection(int /*index*/) const |
546 | { | 545 | { |
547 | QStringList r; | 546 | QStringList r; |
548 | /* ###### | 547 | /* ###### |
549 | 548 | ||
550 | QString selname = choicenames.at(index); | 549 | QString selname = choicenames.at(index); |
551 | for (each row) { | 550 | for (each row) { |
552 | Opie::OPimContact *c = contactForRow(row); | 551 | Opie::OPimContact *c = contactForRow(row); |
553 | if ( text(row,2) == selname ) { | 552 | if ( text(row,2) == selname ) { |
554 | r.append(c->email); | 553 | r.append(c->email); |
555 | } | 554 | } |
556 | } | 555 | } |
557 | 556 | ||
558 | */ | 557 | */ |
559 | return r; | 558 | return r; |
560 | } | 559 | } |
561 | 560 | ||
562 | 561 | ||
563 | void AbTable::updateVisible() | 562 | void AbTable::updateVisible() |
564 | { | 563 | { |
565 | //odebug << "void AbTable::updateVisible()" << oendl; | 564 | //odebug << "void AbTable::updateVisible()" << oendl; |
566 | 565 | ||
567 | int visible, | 566 | int visible, |
568 | totalRows, | 567 | totalRows, |
569 | row, | 568 | row, |
570 | selectedRow = 0; | 569 | selectedRow = 0; |
571 | 570 | ||
572 | visible = 0; | 571 | visible = 0; |
573 | 572 | ||
574 | setPaintingEnabled( FALSE ); | 573 | setPaintingEnabled( FALSE ); |
575 | 574 | ||
576 | realignTable(); | 575 | realignTable(); |
577 | 576 | ||
578 | totalRows = numRows(); | 577 | totalRows = numRows(); |
579 | for ( row = 0; row < totalRows; row++ ) { | 578 | for ( row = 0; row < totalRows; row++ ) { |
580 | if ( rowHeight(row) == 0 ) { | 579 | if ( rowHeight(row) == 0 ) { |
581 | showRow( row ); | 580 | showRow( row ); |
582 | adjustRow( row ); | 581 | adjustRow( row ); |
583 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 582 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
584 | selectedRow = row; | 583 | selectedRow = row; |
585 | } | 584 | } |
586 | visible++; | 585 | visible++; |
587 | } | 586 | } |
588 | 587 | ||
589 | if ( selectedRow ) | 588 | if ( selectedRow ) |
590 | setCurrentCell( selectedRow, 0 ); | 589 | setCurrentCell( selectedRow, 0 ); |
591 | 590 | ||
592 | if ( !visible ) | 591 | if ( !visible ) |
593 | setCurrentCell( -1, 0 ); | 592 | setCurrentCell( -1, 0 ); |
594 | 593 | ||
595 | setPaintingEnabled( TRUE ); | 594 | setPaintingEnabled( TRUE ); |
596 | } | 595 | } |
597 | 596 | ||
598 | 597 | ||
599 | void AbTable::setPaintingEnabled( bool e ) | 598 | void AbTable::setPaintingEnabled( bool e ) |
600 | { | 599 | { |
601 | //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " | 600 | //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " |
602 | // << countNested << oendl; | 601 | // << countNested << oendl; |
603 | 602 | ||
604 | if ( e ) { | 603 | if ( e ) { |
605 | if ( countNested > 0 ) | 604 | if ( countNested > 0 ) |
606 | --countNested; | 605 | --countNested; |
607 | if ( ! countNested ){ | 606 | if ( ! countNested ){ |
608 | setUpdatesEnabled( true ); | 607 | setUpdatesEnabled( true ); |
609 | enablePainting = true; | 608 | enablePainting = true; |
610 | rowHeightChanged( 0 ); | 609 | rowHeightChanged( 0 ); |
611 | viewport()->update(); | 610 | viewport()->update(); |
612 | } | 611 | } |
613 | } else { | 612 | } else { |
614 | ++countNested; | 613 | ++countNested; |
615 | enablePainting = false; | 614 | enablePainting = false; |
616 | setUpdatesEnabled( false ); | 615 | setUpdatesEnabled( false ); |
617 | } | 616 | } |
618 | //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " | 617 | //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " |
619 | // << countNested << oendl; | 618 | // << countNested << oendl; |
620 | } | 619 | } |
621 | 620 | ||
622 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | 621 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { |
623 | //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " | 622 | //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " |
624 | // << enablePainting << oendl; | 623 | // << enablePainting << oendl; |
625 | if ( enablePainting ) | 624 | if ( enablePainting ) |
626 | QTable::viewportPaintEvent( e ); | 625 | QTable::viewportPaintEvent( e ); |
627 | } | 626 | } |
628 | 627 | ||
629 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 628 | void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
630 | const QColorGroup &cg = colorGroup(); | 629 | const QColorGroup &cg = colorGroup(); |
631 | 630 | ||
632 | p->save(); | 631 | p->save(); |
633 | 632 | ||
634 | //odebug << "Paint row: " << row << oendl; | 633 | //odebug << "Paint row: " << row << oendl; |
635 | 634 | ||
636 | Opie::OPimContact act_contact = m_viewList[row]; | 635 | Opie::OPimContact act_contact = m_viewList[row]; |
637 | 636 | ||
638 | // Paint alternating background bars | 637 | // Paint alternating background bars |
639 | if ( (row % 2 ) == 0 ) { | 638 | if ( (row % 2 ) == 0 ) { |
640 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 639 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
641 | p->setPen( QPen( cg.text() ) ); | 640 | p->setPen( QPen( cg.text() ) ); |
642 | } | 641 | } |
643 | else { | 642 | else { |
644 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 643 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
645 | p->setPen( QPen( cg.buttonText() ) ); | 644 | p->setPen( QPen( cg.buttonText() ) ); |
646 | } | 645 | } |
647 | 646 | ||
648 | QFont f = p->font(); | 647 | QFont f = p->font(); |
649 | QFontMetrics fm(f); | 648 | QFontMetrics fm(f); |
650 | 649 | ||
651 | int marg = 2; | 650 | int marg = 2; |
652 | int x = 0; | 651 | int x = 0; |
653 | int y = ( cr.height() - 14 ) / 2; | 652 | int y = ( cr.height() - 14 ) / 2; |
654 | 653 | ||
655 | QString nameText = act_contact.fileAs(); | 654 | QString nameText = act_contact.fileAs(); |
656 | 655 | ||
657 | switch( col ){ | 656 | switch( col ){ |
658 | case 0: | 657 | case 0: |
659 | p->drawText( x + marg,2 + fm.ascent(), nameText ); | 658 | p->drawText( x + marg,2 + fm.ascent(), nameText ); |
660 | break; | 659 | break; |
661 | case 1:{ | 660 | case 1:{ |
662 | 661 | ||
663 | ContactItem contactItem = findContactContact( act_contact, 0 ); | 662 | ContactItem contactItem = findContactContact( act_contact, 0 ); |
664 | QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ | 663 | QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ |
665 | QString contactText = contactItem.value; | 664 | QString contactText = contactItem.value; |
666 | 665 | ||
667 | if ( !contactPic.isNull() ) | 666 | if ( !contactPic.isNull() ) |
668 | { | 667 | { |
669 | p->drawPixmap( x + marg, y, contactPic ); | 668 | p->drawPixmap( x + marg, y, contactPic ); |
670 | p->drawText( x + marg + contactPic.width() | 669 | p->drawText( x + marg + contactPic.width() |
671 | + 4,2 + fm.ascent(), contactText ); | 670 | + 4,2 + fm.ascent(), contactText ); |
672 | } | 671 | } |
673 | else | 672 | else |
674 | { | 673 | { |
675 | p->drawText( x + marg,2 + fm.ascent(), contactText ); | 674 | p->drawText( x + marg,2 + fm.ascent(), contactText ); |
676 | } | 675 | } |
677 | } | 676 | } |
678 | break; | 677 | break; |
679 | 678 | ||
680 | } | 679 | } |
681 | p->restore(); | 680 | p->restore(); |
682 | } | 681 | } |
683 | 682 | ||
684 | void AbTable::rowHeightChanged( int row ) | 683 | void AbTable::rowHeightChanged( int row ) |
685 | { | 684 | { |
686 | if ( enablePainting ) | 685 | if ( enablePainting ) |
687 | QTable::rowHeightChanged( row ); | 686 | QTable::rowHeightChanged( row ); |
688 | } | 687 | } |
689 | ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ ) | 688 | ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ ) |
690 | { | 689 | { |
691 | 690 | ||
692 | ContactItem item; | 691 | ContactItem item; |
693 | 692 | ||
694 | item.value = ""; | 693 | item.value = ""; |
695 | 694 | ||
696 | for ( QValueList<int>::ConstIterator it = intFields.begin(); | 695 | for ( QValueList<int>::ConstIterator it = intFields.begin(); |
697 | it != intFields.end(); ++it ) { | 696 | it != intFields.end(); ++it ) { |
698 | switch ( *it ) { | 697 | switch ( *it ) { |
699 | default: | 698 | default: |
700 | break; | 699 | break; |
701 | case Qtopia::Title: | 700 | case Qtopia::Title: |
702 | item.value = entry.title(); | 701 | item.value = entry.title(); |
703 | break; | 702 | break; |
704 | case Qtopia::Suffix: | 703 | case Qtopia::Suffix: |
705 | item.value = entry.suffix(); | 704 | item.value = entry.suffix(); |
706 | break; | 705 | break; |
707 | case Qtopia::FileAs: | 706 | case Qtopia::FileAs: |
708 | item.value = entry.fileAs(); | 707 | item.value = entry.fileAs(); |
709 | break; | 708 | break; |
710 | case Qtopia::DefaultEmail: | 709 | case Qtopia::DefaultEmail: |
711 | item.value = entry.defaultEmail(); | 710 | item.value = entry.defaultEmail(); |
712 | if ( !item.value.isEmpty() ) | 711 | if ( !item.value.isEmpty() ) |
713 | item.icon = Resource::loadPixmap( "addressbook/email" ); | 712 | item.icon = Resource::loadPixmap( "addressbook/email" ); |
714 | break; | 713 | break; |
715 | case Qtopia::Emails: | 714 | case Qtopia::Emails: |
716 | item.value = entry.emails(); | 715 | item.value = entry.emails(); |
717 | if ( !item.value.isEmpty() ) | 716 | if ( !item.value.isEmpty() ) |
718 | item.icon = Resource::loadPixmap( "addressbook/email" ); | 717 | item.icon = Resource::loadPixmap( "addressbook/email" ); |
719 | break; | 718 | break; |
720 | case Qtopia::HomeStreet: | 719 | case Qtopia::HomeStreet: |
721 | item.value = entry.homeStreet(); | 720 | item.value = entry.homeStreet(); |
722 | break; | 721 | break; |
723 | case Qtopia::HomeCity: | 722 | case Qtopia::HomeCity: |
724 | item.value = entry.homeCity(); | 723 | item.value = entry.homeCity(); |
725 | break; | 724 | break; |
726 | case Qtopia::HomeState: | 725 | case Qtopia::HomeState: |
727 | item.value = entry.homeState(); | 726 | item.value = entry.homeState(); |
728 | break; | 727 | break; |
729 | case Qtopia::HomeZip: | 728 | case Qtopia::HomeZip: |
730 | item.value = entry.homeZip(); | 729 | item.value = entry.homeZip(); |
731 | break; | 730 | break; |
732 | case Qtopia::HomeCountry: | 731 | case Qtopia::HomeCountry: |
733 | item.value = entry.homeCountry(); | 732 | item.value = entry.homeCountry(); |
734 | break; | 733 | break; |
735 | case Qtopia::HomePhone: | 734 | case Qtopia::HomePhone: |
736 | item.value = entry.homePhone(); | 735 | item.value = entry.homePhone(); |
737 | if ( !item.value.isEmpty() ) | 736 | if ( !item.value.isEmpty() ) |
738 | item.icon = Resource::loadPixmap( "addressbook/phonehome" ); | 737 | item.icon = Resource::loadPixmap( "addressbook/phonehome" ); |
739 | break; | 738 | break; |
740 | case Qtopia::HomeFax: | 739 | case Qtopia::HomeFax: |
741 | item.value = entry.homeFax(); | 740 | item.value = entry.homeFax(); |
742 | if ( !item.value.isEmpty() ) | 741 | if ( !item.value.isEmpty() ) |
743 | item.icon = Resource::loadPixmap( "addressbook/faxhome" ); | 742 | item.icon = Resource::loadPixmap( "addressbook/faxhome" ); |
744 | break; | 743 | break; |
745 | case Qtopia::HomeMobile: | 744 | case Qtopia::HomeMobile: |
746 | item.value = entry.homeMobile(); | 745 | item.value = entry.homeMobile(); |
747 | if ( !item.value.isEmpty() ) | 746 | if ( !item.value.isEmpty() ) |
748 | item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); | 747 | item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); |
749 | break; | 748 | break; |
750 | case Qtopia::HomeWebPage: | 749 | case Qtopia::HomeWebPage: |
751 | item.value = entry.homeWebpage(); | 750 | item.value = entry.homeWebpage(); |
752 | if ( !item.value.isEmpty() ) | 751 | if ( !item.value.isEmpty() ) |
753 | item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); | 752 | item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); |
754 | break; | 753 | break; |
755 | case Qtopia::Company: | 754 | case Qtopia::Company: |
756 | item.value = entry.company(); | 755 | item.value = entry.company(); |
757 | break; | 756 | break; |
758 | case Qtopia::BusinessCity: | 757 | case Qtopia::BusinessCity: |
759 | item.value = entry.businessCity(); | 758 | item.value = entry.businessCity(); |
760 | break; | 759 | break; |
761 | case Qtopia::BusinessStreet: | 760 | case Qtopia::BusinessStreet: |
762 | item.value = entry.businessStreet(); | 761 | item.value = entry.businessStreet(); |
763 | break; | 762 | break; |
764 | case Qtopia::BusinessZip: | 763 | case Qtopia::BusinessZip: |
765 | item.value = entry.businessZip(); | 764 | item.value = entry.businessZip(); |
766 | break; | 765 | break; |
767 | case Qtopia::BusinessCountry: | 766 | case Qtopia::BusinessCountry: |
768 | item.value = entry.businessCountry(); | 767 | item.value = entry.businessCountry(); |
769 | break; | 768 | break; |
770 | case Qtopia::BusinessWebPage: | 769 | case Qtopia::BusinessWebPage: |
771 | item.value = entry.businessWebpage(); | 770 | item.value = entry.businessWebpage(); |
772 | if ( !item.value.isEmpty() ) | 771 | if ( !item.value.isEmpty() ) |
773 | item.icon = Resource::loadPixmap( "addressbook/webpagework" ); | 772 | item.icon = Resource::loadPixmap( "addressbook/webpagework" ); |
774 | break; | 773 | break; |
775 | case Qtopia::JobTitle: | 774 | case Qtopia::JobTitle: |
776 | item.value = entry.jobTitle(); | 775 | item.value = entry.jobTitle(); |
777 | break; | 776 | break; |
778 | case Qtopia::Department: | 777 | case Qtopia::Department: |
779 | item.value = entry.department(); | 778 | item.value = entry.department(); |
780 | break; | 779 | break; |
781 | case Qtopia::Office: | 780 | case Qtopia::Office: |
782 | item.value = entry.office(); | 781 | item.value = entry.office(); |
783 | break; | 782 | break; |
784 | case Qtopia::BusinessPhone: | 783 | case Qtopia::BusinessPhone: |
785 | item.value = entry.businessPhone(); | 784 | item.value = entry.businessPhone(); |
786 | if ( !item.value.isEmpty() ) | 785 | if ( !item.value.isEmpty() ) |
787 | item.icon = Resource::loadPixmap( "addressbook/phonework" ); | 786 | item.icon = Resource::loadPixmap( "addressbook/phonework" ); |
788 | break; | 787 | break; |
789 | case Qtopia::BusinessFax: | 788 | case Qtopia::BusinessFax: |
790 | item.value = entry.businessFax(); | 789 | item.value = entry.businessFax(); |
791 | if ( !item.value.isEmpty() ) | 790 | if ( !item.value.isEmpty() ) |
792 | item.icon = Resource::loadPixmap( "addressbook/faxwork" ); | 791 | item.icon = Resource::loadPixmap( "addressbook/faxwork" ); |
793 | break; | 792 | break; |
794 | case Qtopia::BusinessMobile: | 793 | case Qtopia::BusinessMobile: |
795 | item.value = entry.businessMobile(); | 794 | item.value = entry.businessMobile(); |
796 | if ( !item.value.isEmpty() ) | 795 | if ( !item.value.isEmpty() ) |
797 | item.icon = Resource::loadPixmap( "addressbook/mobilework" ); | 796 | item.icon = Resource::loadPixmap( "addressbook/mobilework" ); |
798 | break; | 797 | break; |
799 | case Qtopia::BusinessPager: | 798 | case Qtopia::BusinessPager: |
800 | item.value = entry.businessPager(); | 799 | item.value = entry.businessPager(); |
801 | break; | 800 | break; |
802 | case Qtopia::Profession: | 801 | case Qtopia::Profession: |
803 | item.value = entry.profession(); | 802 | item.value = entry.profession(); |
804 | break; | 803 | break; |
805 | case Qtopia::Assistant: | 804 | case Qtopia::Assistant: |
806 | item.value = entry.assistant(); | 805 | item.value = entry.assistant(); |
807 | break; | 806 | break; |
808 | case Qtopia::Manager: | 807 | case Qtopia::Manager: |
809 | item.value = entry.manager(); | 808 | item.value = entry.manager(); |
810 | break; | 809 | break; |
811 | case Qtopia::Spouse: | 810 | case Qtopia::Spouse: |
812 | item.value = entry.spouse(); | 811 | item.value = entry.spouse(); |
813 | break; | 812 | break; |
814 | case Qtopia::Gender: | 813 | case Qtopia::Gender: |
815 | item.value = entry.gender(); | 814 | item.value = entry.gender(); |
816 | break; | 815 | break; |
817 | case Qtopia::Birthday: | 816 | case Qtopia::Birthday: |
818 | if ( ! entry.birthday().isNull() ){ | 817 | if ( ! entry.birthday().isNull() ){ |
819 | item.value = TimeString::numberDateString( entry.birthday() ); | 818 | item.value = TimeString::numberDateString( entry.birthday() ); |
820 | } | 819 | } |
821 | break; | 820 | break; |
822 | case Qtopia::Anniversary: | 821 | case Qtopia::Anniversary: |
823 | if ( ! entry.anniversary().isNull() ){ | 822 | if ( ! entry.anniversary().isNull() ){ |
824 | item.value = TimeString::numberDateString( entry.anniversary() ); | 823 | item.value = TimeString::numberDateString( entry.anniversary() ); |
825 | } | 824 | } |
826 | break; | 825 | break; |
827 | case Qtopia::Nickname: | 826 | case Qtopia::Nickname: |
828 | item.value = entry.nickname(); | 827 | item.value = entry.nickname(); |
829 | break; | 828 | break; |
830 | case Qtopia::Children: | 829 | case Qtopia::Children: |
831 | item.value = entry.children(); | 830 | item.value = entry.children(); |
832 | break; | 831 | break; |
833 | case Qtopia::Notes: | 832 | case Qtopia::Notes: |
834 | item.value = entry.notes(); | 833 | item.value = entry.notes(); |
835 | break; | 834 | break; |
836 | } | 835 | } |
837 | if ( !item.value.isEmpty() ) | 836 | if ( !item.value.isEmpty() ) |
838 | break; | 837 | break; |
839 | } | 838 | } |
840 | return item; | 839 | return item; |
841 | } | 840 | } |