summaryrefslogtreecommitdiff
authoreilers <eilers>2003-08-30 15:32:34 (UTC)
committer eilers <eilers>2003-08-30 15:32:34 (UTC)
commitcfb97af8f45087e58d4b82689df22191bd657c34 (patch) (unidiff)
tree9e01e85787092abb0d8c6733bbe3091eaf6a892a
parent9f07321949f8baf1a64db0e4caec58041d3f775f (diff)
downloadopie-cfb97af8f45087e58d4b82689df22191bd657c34.zip
opie-cfb97af8f45087e58d4b82689df22191bd657c34.tar.gz
opie-cfb97af8f45087e58d4b82689df22191bd657c34.tar.bz2
Speed optimization fix:
Startup and usability improved if a lot of contacts are stored. Left speed bootleneck is the xml file..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/ablabel.cpp7
-rw-r--r--core/pim/addressbook/abtable.cpp113
-rw-r--r--core/pim/addressbook/abtable.h16
-rw-r--r--core/pim/addressbook/abview.cpp31
-rw-r--r--core/pim/addressbook/addressbook.cpp2
-rw-r--r--core/pim/addressbook/version.h2
6 files changed, 105 insertions, 66 deletions
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index 6d8de91..1914f71 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -1,144 +1,147 @@
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 <qpe/stringutil.h> 23#include <qpe/stringutil.h>
24 24
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qstylesheet.h> 26#include <qstylesheet.h>
27 27
28AbLabel::AbLabel( QWidget *parent, const char *name ): 28AbLabel::AbLabel( QWidget *parent, const char *name ):
29 QTextView( parent, name ), 29 QTextView( parent, name ),
30 m_empty( false ) 30 m_empty( false )
31{ 31{
32} 32}
33 33
34AbLabel::~AbLabel() 34AbLabel::~AbLabel()
35{ 35{
36} 36}
37 37
38void AbLabel::setContacts( const OContactAccess::List& viewList ) 38void AbLabel::setContacts( const OContactAccess::List& viewList )
39{ 39{
40 m_viewList = viewList; 40 m_viewList = viewList;
41 if (m_viewList.count() != 0){ 41 if (m_viewList.count() != 0){
42 m_empty = false; 42 m_empty = false;
43 m_itCurContact = m_viewList.begin(); 43 m_itCurContact = m_viewList.begin();
44 sync(); 44 sync();
45 }else{ 45 }else{
46 // m_itCurContact.clear(); 46 // m_itCurContact.clear();
47 m_empty = true; 47 m_empty = true;
48 setText( "" ); 48 setText( "" );
49 } 49 }
50} 50}
51 51
52int AbLabel::currentEntry_UID() 52int AbLabel::currentEntry_UID()
53{ 53{
54 OContact contact = currentEntry(); 54 OContact contact = currentEntry();
55 55
56 if ( contact.isEmpty() ) 56 if ( contact.isEmpty() )
57 return 0; 57 return 0;
58 else 58 else
59 return ( contact.uid() ); 59 return ( contact.uid() );
60} 60}
61 61
62OContact AbLabel::currentEntry() 62OContact AbLabel::currentEntry()
63{ 63{
64 if ( ! m_empty ) 64 if ( ! m_empty )
65 return ( *m_itCurContact ); 65 return ( *m_itCurContact );
66 else 66 else
67 return OContact(); 67 return OContact();
68} 68}
69 69
70 70
71bool AbLabel::selectContact( int UID ) 71bool AbLabel::selectContact( int UID )
72{ 72{
73 73
74 for ( m_itCurContact = m_viewList.begin(); m_itCurContact != m_viewList.end(); ++m_itCurContact){ 74 for ( int r = 0; r < m_viewList.count(); ++r ) {
75 if ( (*m_itCurContact).uid() == UID ) 75 if ( m_viewList.uidAt( r ) == UID ){
76 m_itCurContact.setCurrent( r );
76 break; 77 break;
78 }
77 } 79 }
80
78 sync(); 81 sync();
79 82
80 return true; 83 return true;
81} 84}
82 85
83 86
84 87
85void AbLabel::sync() 88void AbLabel::sync()
86{ 89{
87 QString text = (*m_itCurContact).toRichText(); 90 QString text = (*m_itCurContact).toRichText();
88 setText( text ); 91 setText( text );
89} 92}
90 93
91void AbLabel::keyPressEvent( QKeyEvent *e ) 94void AbLabel::keyPressEvent( QKeyEvent *e )
92{ 95{
93 96
94 // Commonly handled keys 97 // Commonly handled keys
95 if ( !m_empty ){ 98 if ( !m_empty ){
96 switch( e->key() ) { 99 switch( e->key() ) {
97 case Qt::Key_Left: 100 case Qt::Key_Left:
98 qWarning( "Left.."); 101 qWarning( "Left..");
99 case Qt::Key_Right: 102 case Qt::Key_Right:
100 qWarning( "Right.."); 103 qWarning( "Right..");
101 case Qt::Key_F33: 104 case Qt::Key_F33:
102 qWarning( "OK.."); 105 qWarning( "OK..");
103 emit signalOkPressed(); 106 emit signalOkPressed();
104 break; 107 break;
105 case Qt::Key_Up: 108 case Qt::Key_Up:
106 qWarning( "UP.."); 109 qWarning( "UP..");
107 if ( ( visibleHeight() < contentsHeight() ) && 110 if ( ( visibleHeight() < contentsHeight() ) &&
108 ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) ) 111 ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) )
109 scrollBy( 0, -(visibleHeight()-20) ); 112 scrollBy( 0, -(visibleHeight()-20) );
110 else { 113 else {
111 --m_itCurContact; 114 --m_itCurContact;
112 if ( *m_itCurContact != OContact() ) 115 if ( *m_itCurContact != OContact() )
113 sync(); 116 sync();
114 else 117 else
115 m_itCurContact = m_viewList.end(); 118 m_itCurContact = m_viewList.end();
116 } 119 }
117 120
118 break; 121 break;
119 case Qt::Key_Down: 122 case Qt::Key_Down:
120 qWarning( "DOWN.."); 123 qWarning( "DOWN..");
121 // qWarning( "visible: %d, content: %d",visibleHeight(),contentsHeight()); 124 // qWarning( "visible: %d, content: %d",visibleHeight(),contentsHeight());
122 // qWarning( "value: %d; barMaxValue: %d", verticalScrollBar()->value() 125 // qWarning( "value: %d; barMaxValue: %d", verticalScrollBar()->value()
123 // , verticalScrollBar()->maxValue() ); 126 // , verticalScrollBar()->maxValue() );
124 if ( ( visibleHeight() < contentsHeight() ) && 127 if ( ( visibleHeight() < contentsHeight() ) &&
125 ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) ) 128 ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) )
126 scrollBy( 0, visibleHeight()-20 ); 129 scrollBy( 0, visibleHeight()-20 );
127 else { 130 else {
128 ++m_itCurContact; 131 ++m_itCurContact;
129 if ( *m_itCurContact != OContact() ) 132 if ( *m_itCurContact != OContact() )
130 sync(); 133 sync();
131 else 134 else
132 m_itCurContact = m_viewList.begin(); 135 m_itCurContact = m_viewList.begin();
133 } 136 }
134 break; 137 break;
135 case Qt::Key_Return: // fall through 138 case Qt::Key_Return: // fall through
136 case Qt::Key_Space: // fall through 139 case Qt::Key_Space: // fall through
137 case Qt::Key_Enter: // we want to switch back 140 case Qt::Key_Enter: // we want to switch back
138 emit signalOkPressed(); 141 emit signalOkPressed();
139 break; 142 break;
140 default: break; 143 default: break;
141 } 144 }
142 } 145 }
143 146
144} 147}
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index a2617fa..4705c78 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,821 +1,848 @@
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 22
23#include <qpe/categoryselect.h> 23#include <qpe/categoryselect.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/stringutil.h> 25#include <qpe/stringutil.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30#include <opie/orecordlist.h> 30#include <opie/orecordlist.h>
31 31
32#include <qasciidict.h> 32#include <qasciidict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37 37
38#include "abtable.h" 38#include "abtable.h"
39 39
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <stdlib.h> 43#include <stdlib.h>
44 44
45#include <ctype.h> //toupper() for key hack 45#include <ctype.h> //toupper() for key hack
46 46
47#if 0
48
47/*! 49/*!
48 \class AbTableItem abtable.h 50 \class AbTableItem abtable.h
49 51
50 \brief QTableItem based class for showing a field of an entry 52 \brief QTableItem based class for showing a field of an entry
51*/ 53*/
52 54
53AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 55AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
54 const QString &secondSortKey) 56 const QString &secondSortKey)
55 : QTableItem( t, et, s ) 57 : QTableItem( t, et, s )
56{ 58{
57 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 59 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
58 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 60 sortKey = Qtopia::buildSortKey( s, secondSortKey );
59} 61}
60 62
61int AbTableItem::alignment() const 63int AbTableItem::alignment() const
62{ 64{
63 return AlignLeft|AlignVCenter; 65 return AlignLeft|AlignVCenter;
64} 66}
65 67
66QString AbTableItem::key() const 68QString AbTableItem::key() const
67{ 69{
68 return sortKey; 70 return sortKey;
69} 71}
70 72
71// A way to reset the item, without out doing a delete or a new... 73// A way to reset the item, without out doing a delete or a new...
72void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 74void AbTableItem::setItem( const QString &txt, const QString &secondKey )
73{ 75{
74 setText( txt ); 76 setText( txt );
75 sortKey = Qtopia::buildSortKey( txt, secondKey ); 77 sortKey = Qtopia::buildSortKey( txt, secondKey );
76 78
77 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 79 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
78} 80}
79 81
80/*! 82/*!
81 \class AbPickItem abtable.h 83 \class AbPickItem abtable.h
82 84
83 \brief QTableItem based class for showing slection of an entry 85 \brief QTableItem based class for showing slection of an entry
84*/ 86*/
85 87
86AbPickItem::AbPickItem( QTable *t ) : 88AbPickItem::AbPickItem( QTable *t ) :
87 QTableItem(t, WhenCurrent, "?") 89 QTableItem(t, WhenCurrent, "?")
88{ 90{
89} 91}
90 92
91QWidget *AbPickItem::createEditor() const 93QWidget *AbPickItem::createEditor() const
92{ 94{
93 QComboBox* combo = new QComboBox( table()->viewport() ); 95 QComboBox* combo = new QComboBox( table()->viewport() );
94 ( (AbPickItem*)this )->cb = combo; 96 ( (AbPickItem*)this )->cb = combo;
95 AbTable* t = static_cast<AbTable*>(table()); 97 AbTable* t = static_cast<AbTable*>(table());
96 QStringList c = t->choiceNames(); 98 QStringList c = t->choiceNames();
97 int cur = 0; 99 int cur = 0;
98 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 100 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
99 if ( *it == text() ) 101 if ( *it == text() )
100 cur = combo->count(); 102 cur = combo->count();
101 combo->insertItem(*it); 103 combo->insertItem(*it);
102 } 104 }
103 combo->setCurrentItem(cur); 105 combo->setCurrentItem(cur);
104 return combo; 106 return combo;
105} 107}
106 108
107void AbPickItem::setContentFromEditor( QWidget *w ) 109void AbPickItem::setContentFromEditor( QWidget *w )
108{ 110{
109 if ( w->inherits("QComboBox") ) 111 if ( w->inherits("QComboBox") )
110 setText( ( (QComboBox*)w )->currentText() ); 112 setText( ( (QComboBox*)w )->currentText() );
111 else 113 else
112 QTableItem::setContentFromEditor( w ); 114 QTableItem::setContentFromEditor( w );
113} 115}
114 116
117#endif
118
115/*! 119/*!
116 \class AbTable abtable.h 120 \class AbTable abtable.h
117 121
118 \brief QTable based class for showing a list of entries 122 \brief QTable based class for showing a list of entries
119*/ 123*/
120 124
121AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 125AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
122 : QTable( parent, name ), 126 : QTable( parent, name ),
123 lastSortCol( -1 ), 127 lastSortCol( -1 ),
124 asc( TRUE ), 128 asc( TRUE ),
125 intFields( order ), 129 intFields( order ),
126 enablePainting( true ), 130 enablePainting( true ),
127 columnVisible( true ), 131 columnVisible( true ),
128 countNested( 0 ) 132 countNested( 0 )
129{ 133{
130 //qWarning("C'tor start"); 134 //qWarning("C'tor start");
131 135
132 setSelectionMode( NoSelection ); 136 setSelectionMode( NoSelection );
133 init(); 137 init();
134 setSorting( TRUE ); 138 setSorting( TRUE );
135 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 139 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
136 this, SLOT(itemClicked(int,int)) ); 140 this, SLOT(itemClicked(int,int)) );
137 141
138 contactList.clear(); 142 // contactList.clear();
139 //qWarning("C'tor end"); 143 //qWarning("C'tor end");
140} 144}
141 145
142AbTable::~AbTable() 146AbTable::~AbTable()
143{ 147{
144} 148}
145 149
146void AbTable::init() 150void AbTable::init()
147{ 151{
148 // :SX showChar = '\0'; 152 // :SX showChar = '\0';
149 setNumRows( 0 ); 153 setNumRows( 0 );
150 setNumCols( 2 ); 154 setNumCols( 2 );
151 155
152 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 156 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
153 horizontalHeader()->setLabel( 1, tr( "Contact" )); 157 horizontalHeader()->setLabel( 1, tr( "Contact" ));
154 setLeftMargin( 0 ); 158 setLeftMargin( 0 );
155 verticalHeader()->hide(); 159 verticalHeader()->hide();
156 columnVisible = true; 160 columnVisible = true;
157} 161}
158 162
159void AbTable::setContacts( const OContactAccess::List& viewList ) 163void AbTable::setContacts( const OContactAccess::List& viewList )
160{ 164{
161 //qWarning("AbTable::setContacts()"); 165 qWarning("AbTable::setContacts()");
162 166
163 clear(); 167 clear();
164 m_viewList = viewList; 168 m_viewList = viewList;
165 169
166 setSorting( false ); 170 setSorting( false );
167 setPaintingEnabled( FALSE ); 171 setPaintingEnabled( FALSE );
168 172
169 OContactAccess::List::Iterator it; 173 OContactAccess::List::Iterator it;
170 setNumRows( m_viewList.count() ); 174 setNumRows( m_viewList.count() );
171 int row = 0; 175 //int row = 0;
172 for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 176 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
173 insertIntoTable( *it, row++ ); 177 // insertIntoTable( *it, row++ );
174 178
175 setSorting( true ); 179 // setSorting( true );
176 180
177 resort(); 181 // resort();
178 182
179 updateVisible(); 183 updateVisible();
180 184
181 setPaintingEnabled( TRUE ); 185 setPaintingEnabled( TRUE );
182 186
183} 187}
184 188
185void AbTable::setOrderedList( const QValueList<int> ordered ) 189void AbTable::setOrderedList( const QValueList<int> ordered )
186{ 190{
187 intFields = ordered; 191 intFields = ordered;
188} 192}
189 193
190 194
191bool AbTable::selectContact( int UID ) 195bool AbTable::selectContact( int UID )
192{ 196{
193 //qWarning( "AbTable::selectContact( %d )", UID ); 197 qWarning( "AbTable::selectContact( %d )", UID );
194 int rows = numRows(); 198 int rows = numRows();
195 AbTableItem *abi;
196 OContact* foundContact = 0l; 199 OContact* foundContact = 0l;
197 bool found = false; 200 bool found = false;
198 201
199 setPaintingEnabled( FALSE ); 202 setPaintingEnabled( FALSE );
203 qWarning( "search start" );
200 for ( int r = 0; r < rows; ++r ) { 204 for ( int r = 0; r < rows; ++r ) {
201 abi = static_cast<AbTableItem*>( item(r, 0) ); 205 if ( m_viewList.uidAt( r ) == UID ){
202 foundContact = &contactList[abi];
203 if ( foundContact -> uid() == UID ){
204 ensureCellVisible( r, 0 ); 206 ensureCellVisible( r, 0 );
205 setCurrentCell( r, 0 ); 207 setCurrentCell( r, 0 );
206 found = true; 208 found = true;
207 break; 209 break;
208 } 210 }
209 } 211 }
212 qWarning( "search end" );
210 213
211 if ( !found ){ 214 if ( !found ){
212 ensureCellVisible( 0,0 ); 215 ensureCellVisible( 0,0 );
213 setCurrentCell( 0, 0 ); 216 setCurrentCell( 0, 0 );
214 } 217 }
215 218
216 setPaintingEnabled( TRUE ); 219 setPaintingEnabled( TRUE );
217 220
218 return true; 221 return true;
219} 222}
220 223
224#if 0
221void AbTable::insertIntoTable( const OContact& cnt, int row ) 225void AbTable::insertIntoTable( const OContact& cnt, int row )
222{ 226{
223 //qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 227 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
224 QString strName; 228 QString strName;
225 ContactItem contactItem; 229 ContactItem contactItem;
226 230
227 strName = findContactName( cnt ); 231 strName = findContactName( cnt );
228 contactItem = findContactContact( cnt, row ); 232 contactItem = findContactContact( cnt, row );
229 233
230 AbTableItem *ati; 234 AbTableItem *ati;
231 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); 235 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
232 contactList.insert( ati, cnt ); 236 contactList.insert( ati, cnt );
233 setItem( row, 0, ati ); 237 setItem( row, 0, ati );
234 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); 238 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName);
235 if ( !contactItem.icon.isNull() ) 239 if ( !contactItem.icon.isNull() )
236 ati->setPixmap( contactItem.icon ); 240 ati->setPixmap( contactItem.icon );
237 setItem( row, 1, ati ); 241 setItem( row, 1, ati );
238 242
239 //### cannot do this; table only has two columns at this point 243 //### cannot do this; table only has two columns at this point
240 // setItem( row, 2, new AbPickItem( this ) ); 244 // setItem( row, 2, new AbPickItem( this ) );
241 245
242} 246}
243 247#endif
244 248
245 249
246void AbTable::columnClicked( int col ) 250void AbTable::columnClicked( int col )
247{ 251{
248 if ( !sorting() ) 252 if ( !sorting() )
249 return; 253 return;
250 254
251 if ( lastSortCol == -1 ) 255 if ( lastSortCol == -1 )
252 lastSortCol = col; 256 lastSortCol = col;
253 257
254 if ( col == lastSortCol ) { 258 if ( col == lastSortCol ) {
255 asc = !asc; 259 asc = !asc;
256 } else { 260 } else {
257 lastSortCol = col; 261 lastSortCol = col;
258 asc = TRUE; 262 asc = TRUE;
259 } 263 }
260 //QMessageBox::information( this, "resort", "columnClicked" ); 264 //QMessageBox::information( this, "resort", "columnClicked" );
261 resort(); 265 resort();
262} 266}
263 267
264void AbTable::resort() 268void AbTable::resort()
265{ 269{
266 //qWarning( "void AbTable::resort()" ); 270 qWarning( "void AbTable::resort() NOT POSSIBLE !!" );
271#if 0
267 setPaintingEnabled( FALSE ); 272 setPaintingEnabled( FALSE );
268 if ( sorting() ) { 273 if ( sorting() ) {
269 if ( lastSortCol == -1 ) 274 if ( lastSortCol == -1 )
270 lastSortCol = 0; 275 lastSortCol = 0;
271 sortColumn( lastSortCol, asc, TRUE ); 276 sortColumn( lastSortCol, asc, TRUE );
272 //QMessageBox::information( this, "resort", "resort" ); 277 //QMessageBox::information( this, "resort", "resort" );
273 updateVisible(); 278 updateVisible();
274 } 279 }
275 setPaintingEnabled( TRUE ); 280 setPaintingEnabled( TRUE );
281#endif
276} 282}
277 283
278OContact AbTable::currentEntry() 284OContact AbTable::currentEntry()
279{ 285 {
280 //qWarning( "OContact AbTable::currentEntry()" ); 286 return m_viewList[currentRow()];
281 OContact cnt;
282 AbTableItem *abItem;
283 abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
284 if ( abItem ) {
285 cnt = contactList[abItem];
286 //cnt = contactList[currentRow()];
287 }
288 return cnt;
289} 287}
290 288
291int AbTable::currentEntry_UID() 289int AbTable::currentEntry_UID()
292{ 290{
293 return ( currentEntry().uid() ); 291 return ( currentEntry().uid() );
294} 292}
295 293
296void AbTable::clear() 294void AbTable::clear()
297{ 295{
298 //qWarning( "void AbTable::clear()" ); 296 qWarning( "void AbTable::clear()" );
299 contactList.clear(); 297 // contactList.clear();
300 298
301 setPaintingEnabled( FALSE ); 299 setPaintingEnabled( FALSE );
302 for ( int r = 0; r < numRows(); ++r ) { 300 for ( int r = 0; r < numRows(); ++r ) {
303 for ( int c = 0; c < numCols(); ++c ) { 301 for ( int c = 0; c < numCols(); ++c ) {
304 if ( cellWidget( r, c ) ) 302 if ( cellWidget( r, c ) )
305 clearCellWidget( r, c ); 303 clearCellWidget( r, c );
306 clearCell( r, c ); 304 clearCell( r, c );
307 } 305 }
308 } 306 }
309 setNumRows( 0 ); 307 setNumRows( 0 );
310 setPaintingEnabled( TRUE ); 308 setPaintingEnabled( TRUE );
311} 309}
312 310
313// Refresh updates column 2 if the contactsettings changed 311// Refresh updates column 2 if the contactsettings changed
314void AbTable::refresh() 312void AbTable::refresh()
315{ 313{
316 //qWarning( "void AbTable::refresh()" ); 314 qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" );
315
316#if 0
317 int rows = numRows(); 317 int rows = numRows();
318 AbTableItem *abi; 318 AbTableItem *abi;
319 ContactItem contactItem; 319 ContactItem contactItem;
320 320
321 setPaintingEnabled( FALSE ); 321 setPaintingEnabled( FALSE );
322 for ( int r = 0; r < rows; ++r ) { 322 for ( int r = 0; r < rows; ++r ) {
323 abi = static_cast<AbTableItem*>( item(r, 0) ); 323 abi = static_cast<AbTableItem*>( item(r, 0) );
324 contactItem = findContactContact( contactList[abi], r ); 324 contactItem = findContactContact( contactList[abi], r );
325 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); 325 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() );
326 if ( !contactItem.icon.isNull() ){ 326 if ( !contactItem.icon.isNull() ){
327 static_cast<AbTableItem*>( item(r, 1) )-> 327 static_cast<AbTableItem*>( item(r, 1) )->
328 setPixmap( contactItem.icon ); 328 setPixmap( contactItem.icon );
329 }else{ 329 }else{
330 static_cast<AbTableItem*>( item(r, 1) )-> 330 static_cast<AbTableItem*>( item(r, 1) )->
331 setPixmap( QPixmap() ); 331 setPixmap( QPixmap() );
332 } 332 }
333 } 333 }
334 resort(); 334 resort();
335 setPaintingEnabled( TRUE ); 335 setPaintingEnabled( TRUE );
336
337#endif
336} 338}
337 339
338void AbTable::keyPressEvent( QKeyEvent *e ) 340void AbTable::keyPressEvent( QKeyEvent *e )
339{ 341{
340 char key = toupper( e->ascii() ); 342 char key = toupper( e->ascii() );
341 343
342 if ( key >= 'A' && key <= 'Z' ) 344 if ( key >= 'A' && key <= 'Z' )
343 moveTo( key ); 345 moveTo( key );
344 346
345 //qWarning("Received key .."); 347 //qWarning("Received key ..");
346 switch( e->key() ) { 348 switch( e->key() ) {
347 case Qt::Key_Space: 349 case Qt::Key_Space:
348 case Qt::Key_Return: 350 case Qt::Key_Return:
349 case Qt::Key_Enter: 351 case Qt::Key_Enter:
350 emit signalSwitch(); 352 emit signalSwitch();
351 break; 353 break;
352 // case Qt::Key_Up: 354 // case Qt::Key_Up:
353 // qWarning("a"); 355 // qWarning("a");
354 // emit signalKeyUp(); 356 // emit signalKeyUp();
355 // break; 357 // break;
356 // case Qt::Key_Down: 358 // case Qt::Key_Down:
357 // qWarning("b"); 359 // qWarning("b");
358 // emit signalKeyDown(); 360 // emit signalKeyDown();
359 // break; 361 // break;
360 default: 362 default:
361 QTable::keyPressEvent( e ); 363 QTable::keyPressEvent( e );
362 } 364 }
363 365
364} 366}
365 367
366void AbTable::moveTo( char c ) 368void AbTable::moveTo( char c )
367{ 369{
368 qWarning( "void AbTable::moveTo( char c )" ); 370 qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" );
369 371
372#if 0
370 int rows = numRows(); 373 int rows = numRows();
371 QString value; 374 QString value;
372 AbTableItem *abi; 375 AbTableItem *abi;
373 int r; 376 int r;
374 if ( asc ) { 377 if ( asc ) {
375 r = 0; 378 r = 0;
376 while ( r < rows-1) { 379 while ( r < rows-1) {
377 abi = static_cast<AbTableItem*>( item(r, 0) ); 380 abi = static_cast<AbTableItem*>( item(r, 0) );
378 QChar first = abi->key()[0]; 381 QChar first = abi->key()[0];
379 //### is there a bug in QChar to char comparison??? 382 //### is there a bug in QChar to char comparison???
380 if ( first.row() || first.cell() >= c ) 383 if ( first.row() || first.cell() >= c )
381 break; 384 break;
382 r++; 385 r++;
383 } 386 }
384 } else { 387 } else {
385 //### should probably disable reverse sorting instead 388 //### should probably disable reverse sorting instead
386 r = rows - 1; 389 r = rows - 1;
387 while ( r > 0 ) { 390 while ( r > 0 ) {
388 abi = static_cast<AbTableItem*>( item(r, 0) ); 391 abi = static_cast<AbTableItem*>( item(r, 0) );
389 QChar first = abi->key()[0]; 392 QChar first = abi->key()[0];
390 //### is there a bug in QChar to char comparison??? 393 //### is there a bug in QChar to char comparison???
391 if ( first.row() || first.cell() >= c ) 394 if ( first.row() || first.cell() >= c )
392 break; 395 break;
393 r--; 396 r--;
394 } 397 }
395 } 398 }
396 setCurrentCell( r, currentColumn() ); 399 setCurrentCell( r, currentColumn() );
397}
398 400
401#endif
402}
399 403
404#if 0
405// Useless.. Nobody uses it .. (se)
400QString AbTable::findContactName( const OContact &entry ) 406QString AbTable::findContactName( const OContact &entry )
401{ 407{
402 // We use the fileAs, then company, defaultEmail 408 // We use the fileAs, then company, defaultEmail
403 QString str; 409 QString str;
404 str = entry.fileAs(); 410 str = entry.fileAs();
405 if ( str.isEmpty() ) { 411 if ( str.isEmpty() ) {
406 str = entry.company(); 412 str = entry.company();
407 if ( str.isEmpty() ) { 413 if ( str.isEmpty() ) {
408 str = entry.defaultEmail(); 414 str = entry.defaultEmail();
409 } 415 }
410 } 416 }
411 return str; 417 return str;
412} 418}
413 419#endif
414 420
415 421
416void AbTable::resizeRows() { 422void AbTable::resizeRows() {
417 /* 423 /*
418 if (numRows()) { 424 if (numRows()) {
419 for (int i = 0; i < numRows(); i++) { 425 for (int i = 0; i < numRows(); i++) {
420 setRowHeight( i, size ); 426 setRowHeight( i, size );
421 } 427 }
422 } 428 }
423 updateVisible(); 429 updateVisible();
424 */ 430 */
425} 431}
426 432
427 433
428void AbTable::realignTable() 434void AbTable::realignTable()
429{ 435{
430 //qWarning( "void AbTable::realignTable()" ); 436 //qWarning( "void AbTable::realignTable()" );
431 437
432 setPaintingEnabled( FALSE ); 438 setPaintingEnabled( FALSE );
433 439
434 resizeRows(); 440 resizeRows();
435 fitColumns(); 441 fitColumns();
436 442
437 setPaintingEnabled( TRUE ); 443 setPaintingEnabled( TRUE );
438 444
439} 445}
440 446
441 447
442 448
443 449
444#if QT_VERSION <= 230 450#if QT_VERSION <= 230
445#ifndef SINGLE_APP 451#ifndef SINGLE_APP
446void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 452void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
447{ 453{
448 // Region of the rect we should draw 454 // Region of the rect we should draw
449 QRegion reg( QRect( cx, cy, cw, ch ) ); 455 QRegion reg( QRect( cx, cy, cw, ch ) );
450 // Subtract the table from it 456 // Subtract the table from it
451 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 457 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
452 // And draw the rectangles (transformed as needed) 458 // And draw the rectangles (transformed as needed)
453 QArray<QRect> r = reg.rects(); 459 QArray<QRect> r = reg.rects();
454 for (unsigned int i=0; i<r.count(); i++) 460 for (unsigned int i=0; i<r.count(); i++)
455 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 461 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
456} 462}
457#endif 463#endif
458#endif 464#endif
459 465
460 466
461// int AbTable::rowHeight( int ) const 467// int AbTable::rowHeight( int ) const
462// { 468// {
463// return 18; 469// return 18;
464// } 470// }
465 471
466// int AbTable::rowPos( int row ) const 472// int AbTable::rowPos( int row ) const
467// { 473// {
468// return 18*row; 474// return 18*row;
469// } 475// }
470 476
471// int AbTable::rowAt( int pos ) const 477// int AbTable::rowAt( int pos ) const
472// { 478// {
473// return QMIN( pos/18, numRows()-1 ); 479// return QMIN( pos/18, numRows()-1 );
474// } 480// }
475 481
476 482
477 483
478void AbTable::fitColumns() 484void AbTable::fitColumns()
479{ 485{
480 //qWarning( "void AbTable::fitColumns()" ); 486 //qWarning( "void AbTable::fitColumns()" );
481 int contentsWidth = visibleWidth() / 2; // :SX Why too low 487 int contentsWidth = visibleWidth() / 2; // :SX Why too low
482 // Fix to better value 488 // Fix to better value
483 // contentsWidth = 130; 489 // contentsWidth = 130;
484 490
485 setPaintingEnabled( FALSE ); 491 setPaintingEnabled( FALSE );
486 492
487 if ( columnVisible == false ){ 493 if ( columnVisible == false ){
488 showColumn(0); 494 showColumn(0);
489 columnVisible = true; 495 columnVisible = true;
490 } 496 }
491 497
492 //qWarning("Width: %d", contentsWidth); 498 //qWarning("Width: %d", contentsWidth);
493 499
494 setColumnWidth( 0, contentsWidth ); 500 setColumnWidth( 0, contentsWidth );
495 adjustColumn(1); 501 adjustColumn(1);
496 if ( columnWidth(1) < contentsWidth ) 502 if ( columnWidth(1) < contentsWidth )
497 setColumnWidth( 1, contentsWidth ); 503 setColumnWidth( 1, contentsWidth );
498 504
499 setPaintingEnabled( TRUE ); 505 setPaintingEnabled( TRUE );
500} 506}
501 507
502void AbTable::show() 508void AbTable::show()
503{ 509{
504 //qWarning( "void AbTable::show()" ); 510 //qWarning( "void AbTable::show()" );
505 realignTable(); 511 realignTable();
506 QTable::show(); 512 QTable::show();
507} 513}
508 514
515#if 0
509void AbTable::setChoiceNames( const QStringList& list) 516void AbTable::setChoiceNames( const QStringList& list)
510{ 517{
511 choicenames = list; 518 choicenames = list;
512 if ( choicenames.isEmpty() ) { 519 if ( choicenames.isEmpty() ) {
513 // hide pick column 520 // hide pick column
514 setNumCols( 2 ); 521 setNumCols( 2 );
515 } else { 522 } else {
516 // show pick column 523 // show pick column
517 setNumCols( 3 ); 524 setNumCols( 3 );
518 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 525 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
519 horizontalHeader()->setLabel( 2, tr( "Pick" )); 526 horizontalHeader()->setLabel( 2, tr( "Pick" ));
520 } 527 }
521 fitColumns(); 528 fitColumns();
522} 529}
530#endif
523 531
524void AbTable::itemClicked(int,int col) 532void AbTable::itemClicked(int,int col)
525{ 533{
526 //qWarning( "AbTable::itemClicked(int, col:%d)", col); 534 //qWarning( "AbTable::itemClicked(int, col:%d)", col);
527 if ( col == 2 ) { 535 if ( col == 2 ) {
528 return; 536 return;
529 } else { 537 } else {
530 // qWarning ("Emitting signalSwitch()"); 538 // qWarning ("Emitting signalSwitch()");
531 emit signalSwitch(); 539 emit signalSwitch();
532 } 540 }
533} 541}
534 542
543#if 0
535QStringList AbTable::choiceNames() const 544QStringList AbTable::choiceNames() const
536{ 545{
537 return choicenames; 546 return choicenames;
538} 547}
539 548
549#endif
540void AbTable::setChoiceSelection( const QValueList<int>& list ) 550void AbTable::setChoiceSelection( const QValueList<int>& list )
541{ 551{
542 intFields = list; 552 intFields = list;
543} 553}
544 554
545QStringList AbTable::choiceSelection(int /*index*/) const 555QStringList AbTable::choiceSelection(int /*index*/) const
546{ 556{
547 QStringList r; 557 QStringList r;
548 /* ###### 558 /* ######
549 559
550 QString selname = choicenames.at(index); 560 QString selname = choicenames.at(index);
551 for (each row) { 561 for (each row) {
552 OContact *c = contactForRow(row); 562 OContact *c = contactForRow(row);
553 if ( text(row,2) == selname ) { 563 if ( text(row,2) == selname ) {
554 r.append(c->email); 564 r.append(c->email);
555 } 565 }
556 } 566 }
557 567
558 */ 568 */
559 return r; 569 return r;
560} 570}
561 571
562 572
563
564
565void AbTable::updateVisible() 573void AbTable::updateVisible()
566{ 574{
567 //qWarning("void AbTable::updateVisible()"); 575 //qWarning("void AbTable::updateVisible()");
568 576
569 int visible, 577 int visible,
570 totalRows, 578 totalRows,
571 row, 579 row,
572 selectedRow = 0; 580 selectedRow = 0;
573 581
574 visible = 0; 582 visible = 0;
575 583
576 setPaintingEnabled( FALSE ); 584 setPaintingEnabled( FALSE );
577 585
578 realignTable(); 586 realignTable();
579 587
580 totalRows = numRows(); 588 totalRows = numRows();
581 for ( row = 0; row < totalRows; row++ ) { 589 for ( row = 0; row < totalRows; row++ ) {
582 if ( rowHeight(row) == 0 ) { 590 if ( rowHeight(row) == 0 ) {
583 showRow( row ); 591 showRow( row );
584 adjustRow( row ); 592 adjustRow( row );
585 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 593 if ( isSelected( row,0 ) || isSelected( row,1 ) )
586 selectedRow = row; 594 selectedRow = row;
587 } 595 }
588 visible++; 596 visible++;
589 } 597 }
590 598
591 if ( selectedRow ) 599 if ( selectedRow )
592 setCurrentCell( selectedRow, 0 ); 600 setCurrentCell( selectedRow, 0 );
593 601
594 if ( !visible ) 602 if ( !visible )
595 setCurrentCell( -1, 0 ); 603 setCurrentCell( -1, 0 );
596 604
597 setPaintingEnabled( TRUE ); 605 setPaintingEnabled( TRUE );
598} 606}
599 607
600 608
601void AbTable::setPaintingEnabled( bool e ) 609void AbTable::setPaintingEnabled( bool e )
602{ 610{
603 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 611 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
604 612
605 if ( e ) { 613 if ( e ) {
606 if ( countNested > 0 ) 614 if ( countNested > 0 )
607 --countNested; 615 --countNested;
608 if ( ! countNested ){ 616 if ( ! countNested ){
609 setUpdatesEnabled( true ); 617 setUpdatesEnabled( true );
610 enablePainting = true; 618 enablePainting = true;
611 rowHeightChanged( 0 ); 619 rowHeightChanged( 0 );
612 viewport()->update(); 620 viewport()->update();
613 } 621 }
614 } else { 622 } else {
615 ++countNested; 623 ++countNested;
616 enablePainting = false; 624 enablePainting = false;
617 setUpdatesEnabled( false ); 625 setUpdatesEnabled( false );
618 } 626 }
619 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 627 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
620} 628}
621 629
622void AbTable::viewportPaintEvent( QPaintEvent* e ) { 630void AbTable::viewportPaintEvent( QPaintEvent* e ) {
623 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); 631 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
624 if ( enablePainting ) 632 if ( enablePainting )
625 QTable::viewportPaintEvent( e ); 633 QTable::viewportPaintEvent( e );
626} 634}
627 635
628void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 636void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
629 const QColorGroup &cg = colorGroup(); 637 const QColorGroup &cg = colorGroup();
630 638
631 p->save(); 639 p->save();
632 640
641 //qWarning( "Paint row: %d", row );
642
643 OContact act_contact = m_viewList[row];
644
633 // Paint alternating background bars 645 // Paint alternating background bars
634 if ( (row % 2 ) == 0 ) { 646 if ( (row % 2 ) == 0 ) {
635 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 647 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
636 p->setPen( QPen( cg.text() ) ); 648 p->setPen( QPen( cg.text() ) );
637 } 649 }
638 else { 650 else {
639 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 651 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
640 p->setPen( QPen( cg.buttonText() ) ); 652 p->setPen( QPen( cg.buttonText() ) );
641 } 653 }
642 654
643 QFont f = p->font(); 655 QFont f = p->font();
644 QFontMetrics fm(f); 656 QFontMetrics fm(f);
645 657
646 int marg = 2; 658 int marg = 2;
647 int x = 0; 659 int x = 0;
648 int y = ( cr.height() - 14 ) / 2; 660 int y = ( cr.height() - 14 ) / 2;
649 661
650 QPixmap pic = pixmap( row, col ); 662 QString nameText = act_contact.fileAs();
651 if ( !pic.isNull() ) 663
652 { 664 switch( col ){
653 p->drawPixmap( x + marg, y, pixmap( row, col ) ); 665 case 0:
654 p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) ); 666 p->drawText( x + marg,2 + fm.ascent(), nameText );
655 } 667 break;
656 else 668 case 1:{
657 { 669
658 p->drawText( x + marg,2 + fm.ascent(), text( row, col ) ); 670 ContactItem contactItem = findContactContact( act_contact, 0 );
659 } 671 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
672 QString contactText = contactItem.value;
673
674 if ( !contactPic.isNull() )
675 {
676 p->drawPixmap( x + marg, y, contactPic );
677 p->drawText( x + marg + contactPic.width()
678 + 4,2 + fm.ascent(), contactText );
679 }
680 else
681 {
682 p->drawText( x + marg,2 + fm.ascent(), contactText );
683 }
684 }
685 break;
660 686
687 }
661 p->restore(); 688 p->restore();
662} 689}
663 690
664void AbTable::rowHeightChanged( int row ) 691void AbTable::rowHeightChanged( int row )
665{ 692{
666 if ( enablePainting ) 693 if ( enablePainting )
667 QTable::rowHeightChanged( row ); 694 QTable::rowHeightChanged( row );
668} 695}
669ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) 696ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ )
670{ 697{
671 698
672 ContactItem item; 699 ContactItem item;
673 700
674 item.value = ""; 701 item.value = "";
675 702
676 for ( QValueList<int>::ConstIterator it = intFields.begin(); 703 for ( QValueList<int>::ConstIterator it = intFields.begin();
677 it != intFields.end(); ++it ) { 704 it != intFields.end(); ++it ) {
678 switch ( *it ) { 705 switch ( *it ) {
679 default: 706 default:
680 break; 707 break;
681 case Qtopia::Title: 708 case Qtopia::Title:
682 item.value = entry.title(); 709 item.value = entry.title();
683 break; 710 break;
684 case Qtopia::Suffix: 711 case Qtopia::Suffix:
685 item.value = entry.suffix(); 712 item.value = entry.suffix();
686 break; 713 break;
687 case Qtopia::FileAs: 714 case Qtopia::FileAs:
688 item.value = entry.fileAs(); 715 item.value = entry.fileAs();
689 break; 716 break;
690 case Qtopia::DefaultEmail: 717 case Qtopia::DefaultEmail:
691 item.value = entry.defaultEmail(); 718 item.value = entry.defaultEmail();
692 if ( !item.value.isEmpty() ) 719 if ( !item.value.isEmpty() )
693 item.icon = Resource::loadPixmap( "addressbook/email" ); 720 item.icon = Resource::loadPixmap( "addressbook/email" );
694 break; 721 break;
695 case Qtopia::Emails: 722 case Qtopia::Emails:
696 item.value = entry.emails(); 723 item.value = entry.emails();
697 if ( !item.value.isEmpty() ) 724 if ( !item.value.isEmpty() )
698 item.icon = Resource::loadPixmap( "addressbook/email" ); 725 item.icon = Resource::loadPixmap( "addressbook/email" );
699 break; 726 break;
700 case Qtopia::HomeStreet: 727 case Qtopia::HomeStreet:
701 item.value = entry.homeStreet(); 728 item.value = entry.homeStreet();
702 break; 729 break;
703 case Qtopia::HomeCity: 730 case Qtopia::HomeCity:
704 item.value = entry.homeCity(); 731 item.value = entry.homeCity();
705 break; 732 break;
706 case Qtopia::HomeState: 733 case Qtopia::HomeState:
707 item.value = entry.homeState(); 734 item.value = entry.homeState();
708 break; 735 break;
709 case Qtopia::HomeZip: 736 case Qtopia::HomeZip:
710 item.value = entry.homeZip(); 737 item.value = entry.homeZip();
711 break; 738 break;
712 case Qtopia::HomeCountry: 739 case Qtopia::HomeCountry:
713 item.value = entry.homeCountry(); 740 item.value = entry.homeCountry();
714 break; 741 break;
715 case Qtopia::HomePhone: 742 case Qtopia::HomePhone:
716 item.value = entry.homePhone(); 743 item.value = entry.homePhone();
717 if ( !item.value.isEmpty() ) 744 if ( !item.value.isEmpty() )
718 item.icon = Resource::loadPixmap( "addressbook/phonehome" ); 745 item.icon = Resource::loadPixmap( "addressbook/phonehome" );
719 break; 746 break;
720 case Qtopia::HomeFax: 747 case Qtopia::HomeFax:
721 item.value = entry.homeFax(); 748 item.value = entry.homeFax();
722 if ( !item.value.isEmpty() ) 749 if ( !item.value.isEmpty() )
723 item.icon = Resource::loadPixmap( "addressbook/faxhome" ); 750 item.icon = Resource::loadPixmap( "addressbook/faxhome" );
724 break; 751 break;
725 case Qtopia::HomeMobile: 752 case Qtopia::HomeMobile:
726 item.value = entry.homeMobile(); 753 item.value = entry.homeMobile();
727 if ( !item.value.isEmpty() ) 754 if ( !item.value.isEmpty() )
728 item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); 755 item.icon = Resource::loadPixmap( "addressbook/mobilehome" );
729 break; 756 break;
730 case Qtopia::HomeWebPage: 757 case Qtopia::HomeWebPage:
731 item.value = entry.homeWebpage(); 758 item.value = entry.homeWebpage();
732 if ( !item.value.isEmpty() ) 759 if ( !item.value.isEmpty() )
733 item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); 760 item.icon = Resource::loadPixmap( "addressbook/webpagehome" );
734 break; 761 break;
735 case Qtopia::Company: 762 case Qtopia::Company:
736 item.value = entry.company(); 763 item.value = entry.company();
737 break; 764 break;
738 case Qtopia::BusinessCity: 765 case Qtopia::BusinessCity:
739 item.value = entry.businessCity(); 766 item.value = entry.businessCity();
740 break; 767 break;
741 case Qtopia::BusinessStreet: 768 case Qtopia::BusinessStreet:
742 item.value = entry.businessStreet(); 769 item.value = entry.businessStreet();
743 break; 770 break;
744 case Qtopia::BusinessZip: 771 case Qtopia::BusinessZip:
745 item.value = entry.businessZip(); 772 item.value = entry.businessZip();
746 break; 773 break;
747 case Qtopia::BusinessCountry: 774 case Qtopia::BusinessCountry:
748 item.value = entry.businessCountry(); 775 item.value = entry.businessCountry();
749 break; 776 break;
750 case Qtopia::BusinessWebPage: 777 case Qtopia::BusinessWebPage:
751 item.value = entry.businessWebpage(); 778 item.value = entry.businessWebpage();
752 if ( !item.value.isEmpty() ) 779 if ( !item.value.isEmpty() )
753 item.icon = Resource::loadPixmap( "addressbook/webpagework" ); 780 item.icon = Resource::loadPixmap( "addressbook/webpagework" );
754 break; 781 break;
755 case Qtopia::JobTitle: 782 case Qtopia::JobTitle:
756 item.value = entry.jobTitle(); 783 item.value = entry.jobTitle();
757 break; 784 break;
758 case Qtopia::Department: 785 case Qtopia::Department:
759 item.value = entry.department(); 786 item.value = entry.department();
760 break; 787 break;
761 case Qtopia::Office: 788 case Qtopia::Office:
762 item.value = entry.office(); 789 item.value = entry.office();
763 break; 790 break;
764 case Qtopia::BusinessPhone: 791 case Qtopia::BusinessPhone:
765 item.value = entry.businessPhone(); 792 item.value = entry.businessPhone();
766 if ( !item.value.isEmpty() ) 793 if ( !item.value.isEmpty() )
767 item.icon = Resource::loadPixmap( "addressbook/phonework" ); 794 item.icon = Resource::loadPixmap( "addressbook/phonework" );
768 break; 795 break;
769 case Qtopia::BusinessFax: 796 case Qtopia::BusinessFax:
770 item.value = entry.businessFax(); 797 item.value = entry.businessFax();
771 if ( !item.value.isEmpty() ) 798 if ( !item.value.isEmpty() )
772 item.icon = Resource::loadPixmap( "addressbook/faxwork" ); 799 item.icon = Resource::loadPixmap( "addressbook/faxwork" );
773 break; 800 break;
774 case Qtopia::BusinessMobile: 801 case Qtopia::BusinessMobile:
775 item.value = entry.businessMobile(); 802 item.value = entry.businessMobile();
776 if ( !item.value.isEmpty() ) 803 if ( !item.value.isEmpty() )
777 item.icon = Resource::loadPixmap( "addressbook/mobilework" ); 804 item.icon = Resource::loadPixmap( "addressbook/mobilework" );
778 break; 805 break;
779 case Qtopia::BusinessPager: 806 case Qtopia::BusinessPager:
780 item.value = entry.businessPager(); 807 item.value = entry.businessPager();
781 break; 808 break;
782 case Qtopia::Profession: 809 case Qtopia::Profession:
783 item.value = entry.profession(); 810 item.value = entry.profession();
784 break; 811 break;
785 case Qtopia::Assistant: 812 case Qtopia::Assistant:
786 item.value = entry.assistant(); 813 item.value = entry.assistant();
787 break; 814 break;
788 case Qtopia::Manager: 815 case Qtopia::Manager:
789 item.value = entry.manager(); 816 item.value = entry.manager();
790 break; 817 break;
791 case Qtopia::Spouse: 818 case Qtopia::Spouse:
792 item.value = entry.spouse(); 819 item.value = entry.spouse();
793 break; 820 break;
794 case Qtopia::Gender: 821 case Qtopia::Gender:
795 item.value = entry.gender(); 822 item.value = entry.gender();
796 break; 823 break;
797 case Qtopia::Birthday: 824 case Qtopia::Birthday:
798 if ( ! entry.birthday().isNull() ){ 825 if ( ! entry.birthday().isNull() ){
799 item.value = TimeString::numberDateString( entry.birthday() ); 826 item.value = TimeString::numberDateString( entry.birthday() );
800 } 827 }
801 break; 828 break;
802 case Qtopia::Anniversary: 829 case Qtopia::Anniversary:
803 if ( ! entry.anniversary().isNull() ){ 830 if ( ! entry.anniversary().isNull() ){
804 item.value = TimeString::numberDateString( entry.anniversary() ); 831 item.value = TimeString::numberDateString( entry.anniversary() );
805 } 832 }
806 break; 833 break;
807 case Qtopia::Nickname: 834 case Qtopia::Nickname:
808 item.value = entry.nickname(); 835 item.value = entry.nickname();
809 break; 836 break;
810 case Qtopia::Children: 837 case Qtopia::Children:
811 item.value = entry.children(); 838 item.value = entry.children();
812 break; 839 break;
813 case Qtopia::Notes: 840 case Qtopia::Notes:
814 item.value = entry.notes(); 841 item.value = entry.notes();
815 break; 842 break;
816 } 843 }
817 if ( !item.value.isEmpty() ) 844 if ( !item.value.isEmpty() )
818 break; 845 break;
819 } 846 }
820 return item; 847 return item;
821} 848}
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 0f7bc29..b9ebe27 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -1,152 +1,158 @@
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#ifndef ABTABLE_H 22#ifndef ABTABLE_H
23#define ABTABLE_H 23#define ABTABLE_H
24 24
25#include <qpe/categories.h> 25#include <qpe/categories.h>
26#include <opie/ocontact.h> 26#include <opie/ocontact.h>
27#include <opie/ocontactaccess.h> 27#include <opie/ocontactaccess.h>
28 28
29#include <qmap.h> 29#include <qmap.h>
30#include <qtable.h> 30#include <qtable.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qpixmap.h> 33#include <qpixmap.h>
34 34
35#if 0
35class AbTableItem : public QTableItem 36class AbTableItem : public QTableItem
36{ 37{
37public: 38public:
38 AbTableItem( QTable *t, EditType et, const QString &s, 39 AbTableItem( QTable *t, EditType et, const QString &s,
39 const QString &secondSortKey); 40 const QString &secondSortKey);
40 QString entryKey() const; 41 QString entryKey() const;
41 void setEntryKey( const QString & k ); 42 void setEntryKey( const QString & k );
42 virtual int alignment() const; 43 virtual int alignment() const;
43 virtual QString key() const; 44 virtual QString key() const;
44 void setItem( const QString &txt, const QString &secondKey ); 45 void setItem( const QString &txt, const QString &secondKey );
45 46
46private: 47private:
47 QString sortKey; 48 QString sortKey;
48}; 49};
49 50
51#endif
52
50// This is a simple container, storing all contact 53// This is a simple container, storing all contact
51// information 54// information
52class ContactItem 55class ContactItem
53{ 56{
54 public: 57 public:
55 QPixmap icon; 58 QPixmap icon;
56 QString value; 59 QString value;
57}; 60};
58 61
62#if 0
59class AbPickItem : public QTableItem 63class AbPickItem : public QTableItem
60{ 64{
61public: 65public:
62 AbPickItem( QTable *t ); 66 AbPickItem( QTable *t );
63 67
64 QWidget *createEditor() const; 68 QWidget *createEditor() const;
65 void setContentFromEditor( QWidget *w ); 69 void setContentFromEditor( QWidget *w );
66 70
67private: 71private:
68 QGuardedPtr<QComboBox> cb; 72 QGuardedPtr<QComboBox> cb;
69}; 73};
70 74
75#endif
76
71class AbTable : public QTable 77class AbTable : public QTable
72{ 78{
73 Q_OBJECT 79 Q_OBJECT
74 80
75public: 81public:
76 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); 82 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
77 ~AbTable(); 83 ~AbTable();
78 84
79 // Set the contacts shown in the table 85 // Set the contacts shown in the table
80 void setContacts( const OContactAccess::List& viewList ); 86 void setContacts( const OContactAccess::List& viewList );
81 87
82 // Set the list for primary contacts 88 // Set the list for primary contacts
83 void setOrderedList( const QValueList<int> ordered ); 89 void setOrderedList( const QValueList<int> ordered );
84 90
85 // Selects a contact of a specific UID 91 // Selects a contact of a specific UID
86 bool selectContact( int UID ); 92 bool selectContact( int UID );
87 93
88 // Get the current selected entry 94 // Get the current selected entry
89 OContact currentEntry(); 95 OContact currentEntry();
90 96
91 // Get the UID of the current selected Entry 97 // Get the UID of the current selected Entry
92 int currentEntry_UID(); 98 int currentEntry_UID();
93 99
94 QString findContactName( const OContact &entry ); 100 // QString findContactName( const OContact &entry );
95 101
96 void init(); 102 void init();
97 void clear(); 103 void clear();
98 void refresh(); 104 void refresh();
99 105
100 void show(); 106 void show();
101 void setPaintingEnabled( bool e ); 107 void setPaintingEnabled( bool e );
102 void viewportPaintEvent( QPaintEvent* e); 108 void viewportPaintEvent( QPaintEvent* e);
103 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 109 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
104 110
105 // addresspicker mode (What's that ? se) 111 // addresspicker mode (What's that ? se)
106 void setChoiceNames( const QStringList& list); 112 // void setChoiceNames( const QStringList& list);
107 QStringList choiceNames() const; 113 // QStringList choiceNames() const;
108 void setChoiceSelection( const QValueList<int>& list ); 114 void setChoiceSelection( const QValueList<int>& list );
109 QStringList choiceSelection(int index) const; 115 QStringList choiceSelection(int index) const;
110 116
111signals: 117signals:
112 void signalSwitch(); 118 void signalSwitch();
113 void signalEditor(); 119 void signalEditor();
114 void signalKeyDown(); 120 void signalKeyDown();
115 void signalKeyUp(); 121 void signalKeyUp();
116 122
117protected: 123protected:
118 virtual void keyPressEvent( QKeyEvent *e ); 124 virtual void keyPressEvent( QKeyEvent *e );
119 125
120// int rowHeight( int ) const; 126// int rowHeight( int ) const;
121// int rowPos( int row ) const; 127// int rowPos( int row ) const;
122// virtual int rowAt( int pos ) const; 128// virtual int rowAt( int pos ) const;
123 129
124 130
125protected slots: 131protected slots:
126 void moveTo( char ); 132 void moveTo( char );
127 virtual void columnClicked( int col ); 133 virtual void columnClicked( int col );
128 void itemClicked(int,int col); 134 void itemClicked(int,int col);
129 void rowHeightChanged( int row ); 135 void rowHeightChanged( int row );
130 136
131private: 137private:
132 void insertIntoTable( const OContact &cnt, int row ); 138 // void insertIntoTable( const OContact &cnt, int row );
133 ContactItem findContactContact( const OContact &entry, int row ); 139 ContactItem findContactContact( const OContact &entry, int row );
134 void fitColumns(); 140 void fitColumns();
135 void resizeRows(); 141 void resizeRows();
136 void realignTable(); 142 void realignTable();
137 void resort(); 143 void resort();
138 void updateVisible(); 144 void updateVisible();
139 145
140 int lastSortCol; 146 int lastSortCol;
141 bool asc; 147 bool asc;
142 QMap<AbTableItem*, OContact> contactList; 148 // QMap<AbTableItem*, OContact> contactList;
143 QValueList<int> intFields; 149 QValueList<int> intFields;
144 QStringList choicenames; 150 QStringList choicenames;
145 bool enablePainting; 151 bool enablePainting;
146 bool columnVisible; 152 bool columnVisible;
147 int countNested; 153 int countNested;
148 154
149 OContactAccess::List m_viewList; 155 OContactAccess::List m_viewList;
150 156
151}; 157};
152#endif // ABTABLE_H 158#endif // ABTABLE_H
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 477f85b..6cbd556 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,502 +1,505 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
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** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "abview.h" 17#include "abview.h"
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20 20
21#include <qpe/global.h> 21#include <qpe/global.h>
22 22
23#include <opie/ocontactaccessbackend_vcard.h> 23#include <opie/ocontactaccessbackend_vcard.h>
24 24
25#include <assert.h> 25#include <assert.h>
26 26
27 27
28// Is defined in LibQPE 28// Is defined in LibQPE
29extern QString categoryFileName(); 29extern QString categoryFileName();
30 30
31QString addressbookPersonalVCardName() 31QString addressbookPersonalVCardName()
32{ 32{
33 QString filename = Global::applicationFileName("addressbook", 33 QString filename = Global::applicationFileName("addressbook",
34 "businesscard.vcf"); 34 "businesscard.vcf");
35 return filename; 35 return filename;
36} 36}
37 37
38 38
39AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): 39AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
40 QWidget(parent), 40 QWidget(parent),
41 mCat(0), 41 mCat(0),
42 m_inSearch( false ), 42 m_inSearch( false ),
43 m_inPersonal( false ), 43 m_inPersonal( false ),
44 m_curr_category( -1 ), 44 m_curr_category( -1 ),
45 m_curr_View( TableView ), 45 m_curr_View( TableView ),
46 m_prev_View( TableView ), 46 m_prev_View( TableView ),
47 m_curr_Contact ( 0 ), 47 m_curr_Contact ( 0 ),
48 m_contactdb ( 0l ), 48 m_contactdb ( 0l ),
49 m_storedDB ( 0l ), 49 m_storedDB ( 0l ),
50 m_viewStack( 0l ), 50 m_viewStack( 0l ),
51 m_abTable( 0l ), 51 m_abTable( 0l ),
52 m_orderedFields( ordered ) 52 m_orderedFields( ordered )
53{ 53{
54 qWarning("AbView::c'tor");
54 // Load default database and handle syncing myself.. ! 55 // Load default database and handle syncing myself.. !
55 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), 56 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ),
56 mCat.load( categoryFileName() ); 57 mCat.load( categoryFileName() );
57 58
58 // Create Layout and put WidgetStack into it. 59 // Create Layout and put WidgetStack into it.
59 QVBoxLayout *vb = new QVBoxLayout( this ); 60 QVBoxLayout *vb = new QVBoxLayout( this );
60 m_viewStack = new QWidgetStack( this ); 61 m_viewStack = new QWidgetStack( this );
61 vb->addWidget( m_viewStack ); 62 vb->addWidget( m_viewStack );
62 63
63 // Creat TableView 64 // Creat TableView
64 QVBox* tableBox = new QVBox( m_viewStack ); 65 QVBox* tableBox = new QVBox( m_viewStack );
65 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 66 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
66 m_abTable->setCurrentCell( 0, 0 ); 67 m_abTable->setCurrentCell( 0, 0 );
67 m_abTable->setFocus(); 68 m_abTable->setFocus();
68 69
69 // Add TableView to WidgetStack and raise it 70 // Add TableView to WidgetStack and raise it
70 m_viewStack -> addWidget( tableBox , TableView ); 71 m_viewStack -> addWidget( tableBox , TableView );
71 72
72 // Create CardView and add it to WidgetStack 73 // Create CardView and add it to WidgetStack
73 QVBox* cardBox = new QVBox( m_viewStack ); 74 QVBox* cardBox = new QVBox( m_viewStack );
74 m_ablabel = new AbLabel( cardBox, "CardView"); 75 m_ablabel = new AbLabel( cardBox, "CardView");
75 m_viewStack -> addWidget( cardBox , CardView ); 76 m_viewStack -> addWidget( cardBox , CardView );
76 77
77 // Connect views to me 78 // Connect views to me
78 connect ( m_abTable, SIGNAL( signalSwitch( void ) ), 79 connect ( m_abTable, SIGNAL( signalSwitch( void ) ),
79 this, SLOT( slotSwitch( void ) ) ); 80 this, SLOT( slotSwitch( void ) ) );
80 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), 81 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ),
81 this, SLOT( slotSwitch( void ) ) ); 82 this, SLOT( slotSwitch( void ) ) );
82 83
83 load(); 84 load();
84} 85}
85 86
86AbView::~AbView() 87AbView::~AbView()
87{ 88{
88 m_contactdb -> save(); 89 m_contactdb -> save();
89 delete m_contactdb; 90 delete m_contactdb;
90 91
91 if ( m_storedDB ){ 92 if ( m_storedDB ){
92 m_storedDB -> save(); 93 m_storedDB -> save();
93 delete m_storedDB; 94 delete m_storedDB;
94 } 95 }
95} 96}
96 97
97 98
98void AbView::setView( Views view ) 99void AbView::setView( Views view )
99{ 100{
100 //qWarning("AbView::setView( Views view )"); 101 qWarning("AbView::setView( Views view )");
101 m_curr_View = view; 102 m_curr_View = view;
102 load(); 103 load();
103} 104}
104 105
105void AbView::addEntry( const OContact &newContact ) 106void AbView::addEntry( const OContact &newContact )
106{ 107{
107 //qWarning("abview:AddContact"); 108 qWarning("abview:AddContact");
108 m_contactdb->add ( newContact ); 109 m_contactdb->add ( newContact );
109 load(); 110 load();
110 111
111} 112}
112void AbView::removeEntry( const int UID ) 113void AbView::removeEntry( const int UID )
113{ 114{
114 //qWarning("abview:RemoveContact"); 115 qWarning("abview:RemoveContact");
115 m_contactdb->remove( UID ); 116 m_contactdb->remove( UID );
116 load(); 117 load();
117} 118}
118 119
119void AbView::replaceEntry( const OContact &contact ) 120void AbView::replaceEntry( const OContact &contact )
120{ 121{
121 //qWarning("abview:ReplaceContact"); 122 qWarning("abview:ReplaceContact");
122 m_contactdb->replace( contact ); 123 m_contactdb->replace( contact );
123 load(); 124 load();
124 125
125} 126}
126 127
127OContact AbView::currentEntry() 128OContact AbView::currentEntry()
128{ 129{
129 OContact currentContact; 130 OContact currentContact;
130 131
131 switch ( (int) m_curr_View ) { 132 switch ( (int) m_curr_View ) {
132 case TableView: 133 case TableView:
133 currentContact = m_abTable -> currentEntry(); 134 currentContact = m_abTable -> currentEntry();
134 break; 135 break;
135 case CardView: 136 case CardView:
136 currentContact = m_ablabel -> currentEntry(); 137 currentContact = m_ablabel -> currentEntry();
137 break; 138 break;
138 } 139 }
139 m_curr_Contact = currentContact.uid(); 140 m_curr_Contact = currentContact.uid();
140 return currentContact; 141 return currentContact;
141} 142}
142 143
143bool AbView::save() 144bool AbView::save()
144{ 145{
145 //qWarning("abView:Save data"); 146 //qWarning("abView:Save data");
146 147
147 return m_contactdb->save(); 148 return m_contactdb->save();
148} 149}
149 150
150void AbView::load() 151void AbView::load()
151{ 152{
152 //qWarning("abView:Load data"); 153 qWarning("abView:Load data");
153 154
154 // Letter Search is stopped at this place 155 // Letter Search is stopped at this place
155 emit signalClearLetterPicker(); 156 emit signalClearLetterPicker();
156 157
157 if ( m_inPersonal ) 158 if ( m_inPersonal )
158 // VCard Backend does not sort.. 159 // VCard Backend does not sort..
159 m_list = m_contactdb->allRecords(); 160 m_list = m_contactdb->allRecords();
160 else{ 161 else{
161 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 162 m_list = m_contactdb->sorted( true, 0, 0, 0 );
162 clearForCategory(); 163 if ( m_curr_category != -1 )
164 clearForCategory();
163 } 165 }
164 166
165 qWarning ("Number of contacts: %d", m_list.count()); 167 qWarning ("Number of contacts: %d", m_list.count());
166 168
167 updateView( true ); 169 updateView( true );
168 170
169} 171}
170 172
171void AbView::reload() 173void AbView::reload()
172{ 174{
173 //qWarning( "void AbView::reload()" ); 175 qWarning( "void AbView::reload()" );
174 176
175 m_contactdb->reload(); 177 m_contactdb->reload();
176 load(); 178 load();
177} 179}
178 180
179void AbView::clear() 181void AbView::clear()
180{ 182{
181 // :SX 183 // :SX
182} 184}
183 185
184void AbView::setShowByCategory( const QString& cat ) 186void AbView::setShowByCategory( const QString& cat )
185{ 187{
186 //qWarning("AbView::setShowCategory( const QString& cat )"); 188 qWarning("AbView::setShowCategory( const QString& cat )");
187 189
188 int intCat = 0; 190 int intCat = 0;
189 191
190 // All (cat == NULL) will be stored as -1 192 // All (cat == NULL) will be stored as -1
191 if ( cat.isNull() ) 193 if ( cat.isNull() )
192 intCat = -1; 194 intCat = -1;
193 else 195 else
194 intCat = mCat.id("Contacts", cat ); 196 intCat = mCat.id("Contacts", cat );
195 197
196 // Just do anything if we really change the category 198 // Just do anything if we really change the category
197 if ( intCat != m_curr_category ){ 199 if ( intCat != m_curr_category ){
198 // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); 200 // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
199 201
200 m_curr_category = intCat; 202 m_curr_category = intCat;
201 emit signalClearLetterPicker(); 203 emit signalClearLetterPicker();
202 204
203 load(); 205 load();
204 } 206 }
205 207
206} 208}
207 209
208void AbView::setShowToView( Views view ) 210void AbView::setShowToView( Views view )
209{ 211{
210 //qWarning("void AbView::setShowToView( View %d )", view); 212 qWarning("void AbView::setShowToView( View %d )", view);
211
212 //qWarning ("Change the View (Category is: %d)", m_curr_category);
213 213
214 if ( m_curr_View != view ){ 214 if ( m_curr_View != view ){
215 qWarning ("Change the View (Category is: %d)", m_curr_category);
215 m_prev_View = m_curr_View; 216 m_prev_View = m_curr_View;
216 m_curr_View = view; 217 m_curr_View = view;
217 218
218 updateView(); 219 updateView();
219 } 220 }
220 221
221} 222}
222 223
223void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) 224void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode )
224{ 225{
225 qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); 226 qWarning("void AbView::setShowByLetter( %c, %d )", c, mode );
226 227
227 assert( mode < AbConfig::LASTELEMENT ); 228 assert( mode < AbConfig::LASTELEMENT );
228 229
229 OContact query; 230 OContact query;
230 if ( c == 0 ){ 231 if ( c == 0 ){
231 load(); 232 load();
232 return; 233 return;
233 }else{ 234 }else{
234 // If the current Backend is unable to solve the query, we will 235 // If the current Backend is unable to solve the query, we will
235 // ignore the request .. 236 // ignore the request ..
236 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ 237 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){
237 return; 238 return;
238 } 239 }
239 240
240 switch( mode ){ 241 switch( mode ){
241 case AbConfig::LastName: 242 case AbConfig::LastName:
242 query.setLastName( QString("%1*").arg(c) ); 243 query.setLastName( QString("%1*").arg(c) );
243 break; 244 break;
244 case AbConfig::FileAs: 245 case AbConfig::FileAs:
245 query.setFileAs( QString("%1*").arg(c) ); 246 query.setFileAs( QString("%1*").arg(c) );
246 break; 247 break;
247 default: 248 default:
248 qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); 249 qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode );
249 qWarning( "I will ignore it.." ); 250 qWarning( "I will ignore it.." );
250 return; 251 return;
251 } 252 }
252 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); 253 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase );
253 clearForCategory(); 254 if ( m_curr_category != -1 )
255 clearForCategory();
254 m_curr_Contact = 0; 256 m_curr_Contact = 0;
255 } 257 }
256 updateView( true ); 258 updateView( true );
257} 259}
258 260
259void AbView::setListOrder( const QValueList<int>& ordered ) 261void AbView::setListOrder( const QValueList<int>& ordered )
260{ 262{
261 m_orderedFields = ordered; 263 m_orderedFields = ordered;
262 if ( m_abTable ){ 264 if ( m_abTable ){
263 m_abTable->setOrderedList( ordered ); 265 m_abTable->setOrderedList( ordered );
264 m_abTable->refresh(); 266 m_abTable->refresh();
265 } 267 }
266 updateView(); 268 updateView();
267} 269}
268 270
269 271
270QString AbView::showCategory() const 272QString AbView::showCategory() const
271{ 273{
272 return mCat.label( "Contacts", m_curr_category ); 274 return mCat.label( "Contacts", m_curr_category );
273} 275}
274 276
275void AbView::showPersonal( bool personal ) 277void AbView::showPersonal( bool personal )
276{ 278{
277 //qWarning ("void AbView::showPersonal( %d )", personal); 279 qWarning ("void AbView::showPersonal( %d )", personal);
278 280
279 if ( personal ){ 281 if ( personal ){
280 282
281 if ( m_inPersonal ) 283 if ( m_inPersonal )
282 return; 284 return;
283 285
284 // Now switch to vCard Backend and load data. 286 // Now switch to vCard Backend and load data.
285 // The current default backend will be stored 287 // The current default backend will be stored
286 // to avoid unneeded load/stores. 288 // to avoid unneeded load/stores.
287 m_storedDB = m_contactdb; 289 m_storedDB = m_contactdb;
288 290
289 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 291 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
290 addressbookPersonalVCardName() ); 292 addressbookPersonalVCardName() );
291 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 293 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
292 294
293 m_inPersonal = true; 295 m_inPersonal = true;
294 m_curr_View = CardView; 296 m_curr_View = CardView;
295 297
296 }else{ 298 }else{
297 299
298 if ( !m_inPersonal ) 300 if ( !m_inPersonal )
299 return; 301 return;
300 302
301 // Remove vCard Backend and restore default 303 // Remove vCard Backend and restore default
302 m_contactdb->save(); 304 m_contactdb->save();
303 delete m_contactdb; 305 delete m_contactdb;
304 306
305 m_contactdb = m_storedDB; 307 m_contactdb = m_storedDB;
306 m_storedDB = 0l; 308 m_storedDB = 0l;
307 309
308 m_curr_View = TableView; 310 m_curr_View = TableView;
309 m_inPersonal = false; 311 m_inPersonal = false;
310 312
311 } 313 }
312 load(); 314 load();
313} 315}
314 316
315void AbView::setCurrentUid( int uid ){ 317void AbView::setCurrentUid( int uid ){
316 318
317 m_curr_Contact = uid; 319 m_curr_Contact = uid;
318 updateView( true ); //true: Don't modificate the UID ! 320 updateView( true ); //true: Don't modificate the UID !
319} 321}
320 322
321 323
322QStringList AbView::categories() 324QStringList AbView::categories()
323{ 325{
324 mCat.load( categoryFileName() ); 326 mCat.load( categoryFileName() );
325 QStringList categoryList = mCat.labels( "Contacts" ); 327 QStringList categoryList = mCat.labels( "Contacts" );
326 return categoryList; 328 return categoryList;
327} 329}
328 330
329// BEGIN: Slots 331// BEGIN: Slots
330void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 332void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
331 bool , QString cat ) 333 bool , QString cat )
332{ 334{
333 //qWarning( "void AbView::slotDoFind" ); 335 //qWarning( "void AbView::slotDoFind" );
334 336
335 // We reloading the data: Deselect Letterpicker 337 // We reloading the data: Deselect Letterpicker
336 emit signalClearLetterPicker(); 338 emit signalClearLetterPicker();
337 339
338 // Use the current Category if nothing else selected 340 // Use the current Category if nothing else selected
339 int category = 0; 341 int category = 0;
340 342
341 if ( cat.isEmpty() ) 343 if ( cat.isEmpty() )
342 category = m_curr_category; 344 category = m_curr_category;
343 else{ 345 else{
344 category = mCat.id("Contacts", cat ); 346 category = mCat.id("Contacts", cat );
345 } 347 }
346 348
347 //qWarning ("Find in Category %d", category); 349 //qWarning ("Find in Category %d", category);
348 350
349 QRegExp r( str ); 351 QRegExp r( str );
350 r.setCaseSensitive( caseSensitive ); 352 r.setCaseSensitive( caseSensitive );
351 r.setWildcard( !useRegExp ); 353 r.setWildcard( !useRegExp );
352 354
353 // Get all matching entries out of the database 355 // Get all matching entries out of the database
354 m_list = m_contactdb->matchRegexp( r ); 356 m_list = m_contactdb->matchRegexp( r );
355 357
356 //qWarning( "found: %d", m_list.count() ); 358 //qWarning( "found: %d", m_list.count() );
357 if ( m_list.count() == 0 ){ 359 if ( m_list.count() == 0 ){
358 emit signalNotFound(); 360 emit signalNotFound();
359 return; 361 return;
360 } 362 }
361 363
362 // Now remove all contacts with wrong category (if any selected) 364 // Now remove all contacts with wrong category (if any selected)
363 // This algorithm is a litte bit ineffective, but 365 // This algorithm is a litte bit ineffective, but
364 // we will not have a lot of matching entries.. 366 // we will not have a lot of matching entries..
365 clearForCategory(); 367 if ( m_curr_category != -1 )
368 clearForCategory();
366 369
367 // Now show all found entries 370 // Now show all found entries
368 updateView( true ); 371 updateView( true );
369} 372}
370 373
371void AbView::offSearch() 374void AbView::offSearch()
372{ 375{
373 m_inSearch = false; 376 m_inSearch = false;
374 377
375 load(); 378 load();
376} 379}
377 380
378void AbView::slotSwitch(){ 381void AbView::slotSwitch(){
379 //qWarning("AbView::slotSwitch()"); 382 //qWarning("AbView::slotSwitch()");
380 383
381 m_prev_View = m_curr_View; 384 m_prev_View = m_curr_View;
382 switch ( (int) m_curr_View ){ 385 switch ( (int) m_curr_View ){
383 case TableView: 386 case TableView:
384 qWarning("Switching to CardView"); 387 qWarning("Switching to CardView");
385 m_curr_View = CardView; 388 m_curr_View = CardView;
386 break; 389 break;
387 case CardView: 390 case CardView:
388 qWarning("Switching to TableView"); 391 qWarning("Switching to TableView");
389 m_curr_View = TableView; 392 m_curr_View = TableView;
390 break; 393 break;
391 } 394 }
392 updateView(); 395 updateView();
393 396
394} 397}
395 398
396// END: Slots 399// END: Slots
397 400
398void AbView::clearForCategory() 401void AbView::clearForCategory()
399{ 402{
400 OContactAccess::List::Iterator it; 403 OContactAccess::List::Iterator it;
401 // Now remove all contacts with wrong category if any category selected 404 // Now remove all contacts with wrong category if any category selected
402 405
403 OContactAccess::List allList = m_list; 406 OContactAccess::List allList = m_list;
404 if ( m_curr_category != -1 ){ 407 if ( m_curr_category != -1 ){
405 for ( it = allList.begin(); it != allList.end(); ++it ){ 408 for ( it = allList.begin(); it != allList.end(); ++it ){
406 if ( !contactCompare( *it, m_curr_category ) ){ 409 if ( !contactCompare( *it, m_curr_category ) ){
407 // qWarning("Removing %d", (*it).uid()); 410 // qWarning("Removing %d", (*it).uid());
408 m_list.remove( (*it).uid() ); 411 m_list.remove( (*it).uid() );
409 } 412 }
410 } 413 }
411 } 414 }
412 415
413} 416}
414 417
415bool AbView::contactCompare( const OContact &cnt, int category ) 418bool AbView::contactCompare( const OContact &cnt, int category )
416{ 419{
417 //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); 420 //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
418 421
419 bool returnMe; 422 bool returnMe;
420 QArray<int> cats; 423 QArray<int> cats;
421 cats = cnt.categories(); 424 cats = cnt.categories();
422 425
423 //qWarning ("Number of categories: %d", cats.count() ); 426 //qWarning ("Number of categories: %d", cats.count() );
424 427
425 returnMe = false; 428 returnMe = false;
426 if ( cats.count() == 0 && category == 0 ) 429 if ( cats.count() == 0 && category == 0 )
427 // Contacts with no category will just shown on "All" and "Unfiled" 430 // Contacts with no category will just shown on "All" and "Unfiled"
428 returnMe = true; 431 returnMe = true;
429 else { 432 else {
430 int i; 433 int i;
431 for ( i = 0; i < int(cats.count()); i++ ) { 434 for ( i = 0; i < int(cats.count()); i++ ) {
432 // qWarning("Comparing %d with %d",cats[i],category ); 435 // qWarning("Comparing %d with %d",cats[i],category );
433 if ( cats[i] == category ) { 436 if ( cats[i] == category ) {
434 returnMe = true; 437 returnMe = true;
435 break; 438 break;
436 } 439 }
437 } 440 }
438 } 441 }
439 //qWarning ("Return: %d", returnMe); 442 //qWarning ("Return: %d", returnMe);
440 return returnMe; 443 return returnMe;
441} 444}
442 445
443// In Some rare cases we have to update all lists.. 446// In Some rare cases we have to update all lists..
444void AbView::updateListinViews() 447void AbView::updateListinViews()
445{ 448{
446 m_abTable -> setContacts( m_list ); 449 m_abTable -> setContacts( m_list );
447 m_ablabel -> setContacts( m_list ); 450 m_ablabel -> setContacts( m_list );
448} 451}
449 452
450void AbView::updateView( bool newdata ) 453void AbView::updateView( bool newdata )
451{ 454{
452 //qWarning("AbView::updateView()"); 455 //qWarning("AbView::updateView()");
453 456
454 if ( m_viewStack -> visibleWidget() ){ 457 if ( m_viewStack -> visibleWidget() ){
455 m_viewStack -> visibleWidget() -> clearFocus(); 458 m_viewStack -> visibleWidget() -> clearFocus();
456 } 459 }
457 460
458 // If we switching the view, we have to store some information 461 // If we switching the view, we have to store some information
459 if ( !newdata ){ 462 if ( !newdata ){
460 if ( m_list.count() ){ 463 if ( m_list.count() ){
461 switch ( (int) m_prev_View ) { 464 switch ( (int) m_prev_View ) {
462 case TableView: 465 case TableView:
463 m_curr_Contact = m_abTable -> currentEntry_UID(); 466 m_curr_Contact = m_abTable -> currentEntry_UID();
464 break; 467 break;
465 case CardView: 468 case CardView:
466 m_curr_Contact = m_ablabel -> currentEntry_UID(); 469 m_curr_Contact = m_ablabel -> currentEntry_UID();
467 break; 470 break;
468 } 471 }
469 }else 472 }else
470 m_curr_Contact = 0; 473 m_curr_Contact = 0;
471 } 474 }
472 475
473 // Feed all views with new lists 476 // Feed all views with new lists
474 if ( newdata ) 477 if ( newdata )
475 updateListinViews(); 478 updateListinViews();
476 479
477 // Tell the world that the view is changed 480 // Tell the world that the view is changed
478 if ( m_curr_View != m_prev_View ) 481 if ( m_curr_View != m_prev_View )
479 emit signalViewSwitched ( (int) m_curr_View ); 482 emit signalViewSwitched ( (int) m_curr_View );
480 483
481 m_prev_View = m_curr_View; 484 m_prev_View = m_curr_View;
482 485
483 // Switch to new View 486 // Switch to new View
484 switch ( (int) m_curr_View ) { 487 switch ( (int) m_curr_View ) {
485 case TableView: 488 case TableView:
486 m_abTable -> setChoiceSelection( m_orderedFields ); 489 m_abTable -> setChoiceSelection( m_orderedFields );
487 if ( m_curr_Contact != 0 ) 490 if ( m_curr_Contact != 0 )
488 m_abTable -> selectContact ( m_curr_Contact ); 491 m_abTable -> selectContact ( m_curr_Contact );
489 m_abTable -> setFocus(); 492 m_abTable -> setFocus();
490 break; 493 break;
491 case CardView: 494 case CardView:
492 if ( m_curr_Contact != 0 ) 495 if ( m_curr_Contact != 0 )
493 m_ablabel -> selectContact( m_curr_Contact ); 496 m_ablabel -> selectContact( m_curr_Contact );
494 m_ablabel -> setFocus(); 497 m_ablabel -> setFocus();
495 break; 498 break;
496 } 499 }
497 500
498 // Raise the current View 501 // Raise the current View
499 m_viewStack -> raiseWidget( m_curr_View ); 502 m_viewStack -> raiseWidget( m_curr_View );
500} 503}
501 504
502 505
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 03c96c8..0ba024e 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,1057 +1,1057 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of the Open Palmtop Environment (see www.opie.info). 5** This file is part of the Open Palmtop Environment (see www.opie.info).
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** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#define QTOPIA_INTERNAL_FD 20#define QTOPIA_INTERNAL_FD
21 21
22#include "contacteditor.h" 22#include "contacteditor.h"
23#include "ablabel.h" 23#include "ablabel.h"
24#include "abview.h" 24#include "abview.h"
25#include "abtable.h" 25#include "abtable.h"
26// #include "addresssettings.h" 26// #include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29 29
30#include <opie/ofileselector.h> 30#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 31#include <opie/ofiledialog.h>
32#include <opie/ocontact.h> 32#include <opie/ocontact.h>
33#include <opie/ocontactaccessbackend_vcard.h> 33#include <opie/ocontactaccessbackend_vcard.h>
34 34
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/ir.h> 36#include <qpe/ir.h>
37#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/qpetoolbar.h> 39#include <qpe/qpetoolbar.h>
40#include <qpe/qpemenubar.h> 40#include <qpe/qpemenubar.h>
41// #include <qtoolbar.h> 41// #include <qtoolbar.h>
42// #include <qmenubar.h> 42// #include <qmenubar.h>
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44#include <qpe/config.h> 44#include <qpe/config.h>
45 45
46#include <qaction.h> 46#include <qaction.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qfile.h> 49#include <qfile.h>
50#include <qimage.h> 50#include <qimage.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpixmap.h> 53#include <qpixmap.h>
54#include <qpopupmenu.h> 54#include <qpopupmenu.h>
55#include <qstringlist.h> 55#include <qstringlist.h>
56#include <qtoolbutton.h> 56#include <qtoolbutton.h>
57#include <qwhatsthis.h> 57#include <qwhatsthis.h>
58#include <qdatetime.h> 58#include <qdatetime.h>
59 59
60#include <stdlib.h> 60#include <stdlib.h>
61#include <sys/stat.h> 61#include <sys/stat.h>
62#include <sys/types.h> 62#include <sys/types.h>
63#include <fcntl.h> 63#include <fcntl.h>
64#include <unistd.h> 64#include <unistd.h>
65 65
66 66
67#include "picker.h" 67#include "picker.h"
68#include "configdlg.h" 68#include "configdlg.h"
69 69
70extern QString addressbookPersonalVCardName(); 70extern QString addressbookPersonalVCardName();
71 71
72AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 72AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
73 WFlags f ) 73 WFlags f )
74 : QMainWindow( parent, name, f ), 74 : QMainWindow( parent, name, f ),
75 catMenu (0l), 75 catMenu (0l),
76 abEditor(0l), 76 abEditor(0l),
77 syncing(FALSE), 77 syncing(FALSE),
78 m_tableViewButton(0l), 78 m_tableViewButton(0l),
79 m_cardViewButton(0l) 79 m_cardViewButton(0l)
80{ 80{
81 isLoading = true; 81 isLoading = true;
82 82
83 m_config.load(); 83 m_config.load();
84 84
85 setCaption( tr("Contacts") ); 85 setCaption( tr("Contacts") );
86 setIcon( Resource::loadPixmap( "AddressBook" ) ); 86 setIcon( Resource::loadPixmap( "AddressBook" ) );
87 87
88 // Settings for Main Menu 88 // Settings for Main Menu
89 // setToolBarsMovable( false ); 89 // setToolBarsMovable( false );
90 setToolBarsMovable( !m_config.fixedBars() ); 90 setToolBarsMovable( !m_config.fixedBars() );
91 setRightJustification( true ); 91 setRightJustification( true );
92 92
93 QPEToolBar *bar = new QPEToolBar( this ); 93 QPEToolBar *bar = new QPEToolBar( this );
94 bar->setHorizontalStretchable( TRUE ); 94 bar->setHorizontalStretchable( TRUE );
95 95
96 QPEMenuBar *mbList = new QPEMenuBar( bar ); 96 QPEMenuBar *mbList = new QPEMenuBar( bar );
97 mbList->setMargin( 0 ); 97 mbList->setMargin( 0 );
98 98
99 QPopupMenu *edit = new QPopupMenu( mbList ); 99 QPopupMenu *edit = new QPopupMenu( mbList );
100 mbList->insertItem( tr( "Contact" ), edit ); 100 mbList->insertItem( tr( "Contact" ), edit );
101 101
102 // Category Menu 102 // Category Menu
103 catMenu = new QPopupMenu( this ); 103 catMenu = new QPopupMenu( this );
104 catMenu->setCheckable( TRUE ); 104 catMenu->setCheckable( TRUE );
105 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 105 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
106 mbList->insertItem( tr("View"), catMenu ); 106 mbList->insertItem( tr("View"), catMenu );
107 107
108 // Create Toolbar 108 // Create Toolbar
109 listTools = new QPEToolBar( this, "list operations" ); 109 listTools = new QPEToolBar( this, "list operations" );
110 listTools->setHorizontalStretchable( true ); 110 listTools->setHorizontalStretchable( true );
111 addToolBar( listTools ); 111 addToolBar( listTools );
112 moveToolBar( listTools, m_config.getToolBarPos() ); 112 moveToolBar( listTools, m_config.getToolBarPos() );
113 113
114 // View Icons 114 // View Icons
115 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), 115 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ),
116 QString::null, 0, this, 0 ); 116 QString::null, 0, this, 0 );
117 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); 117 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
118 m_tableViewButton->setToggleAction( true ); 118 m_tableViewButton->setToggleAction( true );
119 m_tableViewButton->addTo( listTools ); 119 m_tableViewButton->addTo( listTools );
120 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); 120 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 );
121 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); 121 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
122 m_cardViewButton->setToggleAction( true ); 122 m_cardViewButton->setToggleAction( true );
123 m_cardViewButton->addTo( listTools ); 123 m_cardViewButton->addTo( listTools );
124 124
125 listTools->addSeparator(); 125 listTools->addSeparator();
126 126
127 // Other Buttons 127 // Other Buttons
128 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 128 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
129 0, this, 0 ); 129 0, this, 0 );
130 actionNew = a; 130 actionNew = a;
131 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 131 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
132 a->addTo( edit ); 132 a->addTo( edit );
133 a->addTo( listTools ); 133 a->addTo( listTools );
134 134
135 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 135 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
136 0, this, 0 ); 136 0, this, 0 );
137 actionEdit = a; 137 actionEdit = a;
138 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 138 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
139 a->addTo( edit ); 139 a->addTo( edit );
140 a->addTo( listTools ); 140 a->addTo( listTools );
141 141
142 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 142 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
143 0, this, 0 ); 143 0, this, 0 );
144 actionTrash = a; 144 actionTrash = a;
145 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 145 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
146 a->addTo( edit ); 146 a->addTo( edit );
147 a->addTo( listTools ); 147 a->addTo( listTools );
148 148
149 149
150 // make it possible to go directly to businesscard via qcop call 150 // make it possible to go directly to businesscard via qcop call
151 //#if defined(Q_WS_QWS) // Why this ? (se) 151 //#if defined(Q_WS_QWS) // Why this ? (se)
152#if !defined(QT_NO_COP) 152#if !defined(QT_NO_COP)
153 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 153 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
154 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 154 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
155 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 155 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
156#endif 156#endif
157 // #endif 157 // #endif
158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
159 QString::null, 0, this, 0 ); 159 QString::null, 0, this, 0 );
160 actionFind = a; 160 actionFind = a;
161 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 161 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
162 a->addTo( edit ); 162 a->addTo( edit );
163 a->addTo( listTools ); 163 a->addTo( listTools );
164 164
165 // Much better search widget, taken from QTReader.. (se) 165 // Much better search widget, taken from QTReader.. (se)
166 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 166 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
167 searchBar->setHorizontalStretchable( TRUE ); 167 searchBar->setHorizontalStretchable( TRUE );
168 searchBar->hide(); 168 searchBar->hide();
169 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 169 searchEdit = new QLineEdit( searchBar, "searchEdit" );
170 170
171 // QFont f("unifont", 16 /*, QFont::Bold*/); 171 // QFont f("unifont", 16 /*, QFont::Bold*/);
172 // searchEdit->setFont( f ); 172 // searchEdit->setFont( f );
173 173
174 searchBar->setStretchableWidget( searchEdit ); 174 searchBar->setStretchableWidget( searchEdit );
175 connect( searchEdit, SIGNAL( returnPressed( ) ), 175 connect( searchEdit, SIGNAL( returnPressed( ) ),
176 this, SLOT( slotFind( ) ) ); 176 this, SLOT( slotFind( ) ) );
177 177
178 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 178 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
179 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 179 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
180 a->addTo( searchBar ); 180 a->addTo( searchBar );
181 181
182 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 182 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
183 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 183 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
184 a->addTo( searchBar ); 184 a->addTo( searchBar );
185 185
186 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), 186 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
187 QString::null, 0, this, 0 ); 187 QString::null, 0, this, 0 );
188 //a->setEnabled( FALSE ); we got support for it now :) zecke 188 //a->setEnabled( FALSE ); we got support for it now :) zecke
189 actionMail = a; 189 actionMail = a;
190 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
191 a->addTo( edit ); 191 a->addTo( edit );
192 a->addTo( listTools ); 192 a->addTo( listTools );
193 193
194 if ( Ir::supported() ) { 194 if ( Ir::supported() ) {
195 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 195 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
196 0, this, 0 ); 196 0, this, 0 );
197 actionBeam = a; 197 actionBeam = a;
198 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
199 a->addTo( edit ); 199 a->addTo( edit );
200 a->addTo( listTools ); 200 a->addTo( listTools );
201 } 201 }
202 202
203 edit->insertSeparator(); 203 edit->insertSeparator();
204 204
205 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 205 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null,
206 0, this, 0); 206 0, this, 0);
207 actionPersonal = a; 207 actionPersonal = a;
208 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 208 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
209 a->addTo( edit ); 209 a->addTo( edit );
210 210
211 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, 211 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null,
212 0, this, 0); 212 0, this, 0);
213 actionPersonal = a; 213 actionPersonal = a;
214 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 214 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) );
215 a->addTo( edit ); 215 a->addTo( edit );
216 216
217 edit->insertSeparator(); 217 edit->insertSeparator();
218 218
219 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 219 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
220 QString::null, 0, this, 0 , TRUE ); 220 QString::null, 0, this, 0 , TRUE );
221 actionPersonal = a; 221 actionPersonal = a;
222 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 222 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
223 a->addTo( edit ); 223 a->addTo( edit );
224 224
225 225
226#ifdef __DEBUG_RELEASE 226#ifdef __DEBUG_RELEASE
227 // Remove this function for public Release ! This is only 227 // Remove this function for public Release ! This is only
228 // for debug purposes .. 228 // for debug purposes ..
229 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 229 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
230 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 230 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
231 a->addTo( edit ); 231 a->addTo( edit );
232#endif 232#endif
233 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 233 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
234 0, this, 0 ); 234 0, this, 0 );
235 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 235 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
236 a->addTo( edit ); 236 a->addTo( edit );
237 237
238 // Create Views 238 // Create Views
239 listContainer = new QWidget( this ); 239 listContainer = new QWidget( this );
240 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 240 QVBoxLayout *vb = new QVBoxLayout( listContainer );
241 241
242 m_abView = new AbView( listContainer, m_config.orderList() ); 242 m_abView = new AbView( listContainer, m_config.orderList() );
243 vb->addWidget( m_abView ); 243 vb->addWidget( m_abView );
244 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 244 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
245 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 245 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
246 this, SLOT( slotViewSwitched( int ) ) ); 246 this, SLOT( slotViewSwitched( int ) ) );
247 247
248 248
249 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 249 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
250 250
251 m_abView->load(); 251 // m_abView->load(); // Already done by c'tor .
252 252
253 // Letter Picker 253 // Letter Picker
254 pLabel = new LetterPicker( listContainer ); 254 pLabel = new LetterPicker( listContainer );
255 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 255 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
256 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 256 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
257 257
258 vb->addWidget( pLabel ); 258 vb->addWidget( pLabel );
259 259
260 // All Categories into view-menu.. 260 // All Categories into view-menu..
261 populateCategories(); 261 populateCategories();
262 262
263 // Fontsize 263 // Fontsize
264 defaultFont = new QFont( m_abView->font() ); 264 defaultFont = new QFont( m_abView->font() );
265 slotSetFont(m_config.fontSize()); 265 slotSetFont(m_config.fontSize());
266 m_curFontSize = m_config.fontSize(); 266 m_curFontSize = m_config.fontSize();
267 267
268 setCentralWidget(listContainer); 268 setCentralWidget(listContainer);
269 269
270 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 270 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
271 271
272 272
273 isLoading = false; 273 isLoading = false;
274} 274}
275 275
276 276
277void AddressbookWindow::slotConfig() 277void AddressbookWindow::slotConfig()
278{ 278{
279 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 279 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
280 dlg -> setConfig( m_config ); 280 dlg -> setConfig( m_config );
281 dlg -> showMaximized(); 281 dlg -> showMaximized();
282 if ( dlg -> exec() ) { 282 if ( dlg -> exec() ) {
283 qWarning ("Config Dialog accepted!"); 283 qWarning ("Config Dialog accepted!");
284 m_config = dlg -> getConfig(); 284 m_config = dlg -> getConfig();
285 if ( m_curFontSize != m_config.fontSize() ){ 285 if ( m_curFontSize != m_config.fontSize() ){
286 qWarning("Font was changed!"); 286 qWarning("Font was changed!");
287 m_curFontSize = m_config.fontSize(); 287 m_curFontSize = m_config.fontSize();
288 emit slotSetFont( m_curFontSize ); 288 emit slotSetFont( m_curFontSize );
289 } 289 }
290 m_abView -> setListOrder( m_config.orderList() ); 290 m_abView -> setListOrder( m_config.orderList() );
291 } 291 }
292 292
293 delete dlg; 293 delete dlg;
294} 294}
295 295
296 296
297void AddressbookWindow::slotSetFont( int size ) 297void AddressbookWindow::slotSetFont( int size )
298{ 298{
299 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 299 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
300 300
301 if (size > 2 || size < 0) 301 if (size > 2 || size < 0)
302 size = 1; 302 size = 1;
303 303
304 m_config.setFontSize( size ); 304 m_config.setFontSize( size );
305 305
306 QFont *currentFont; 306 QFont *currentFont;
307 307
308 switch (size) { 308 switch (size) {
309 case 0: 309 case 0:
310 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 310 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
311 currentFont = new QFont (m_abView->font()); 311 currentFont = new QFont (m_abView->font());
312 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 312 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
313 // abList->resizeRows(); 313 // abList->resizeRows();
314 break; 314 break;
315 case 1: 315 case 1:
316 m_abView->setFont( *defaultFont ); 316 m_abView->setFont( *defaultFont );
317 currentFont = new QFont (m_abView->font()); 317 currentFont = new QFont (m_abView->font());
318 // // abList->resizeRows(currentFont->pixelSize() + 7); 318 // // abList->resizeRows(currentFont->pixelSize() + 7);
319 // abList->resizeRows(); 319 // abList->resizeRows();
320 break; 320 break;
321 case 2: 321 case 2:
322 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 322 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
323 currentFont = new QFont (m_abView->font()); 323 currentFont = new QFont (m_abView->font());
324 // //abList->resizeRows(currentFont->pixelSize() + 7); 324 // //abList->resizeRows(currentFont->pixelSize() + 7);
325 // abList->resizeRows(); 325 // abList->resizeRows();
326 break; 326 break;
327 } 327 }
328} 328}
329 329
330 330
331 331
332void AddressbookWindow::importvCard() { 332void AddressbookWindow::importvCard() {
333 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 333 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
334 if(!str.isEmpty() ){ 334 if(!str.isEmpty() ){
335 setDocument((const QString&) str ); 335 setDocument((const QString&) str );
336 } 336 }
337 337
338} 338}
339void AddressbookWindow::exportvCard() 339void AddressbookWindow::exportvCard()
340{ 340{
341 qWarning(" void AddressbookWindow::exportvCard()"); 341 qWarning(" void AddressbookWindow::exportvCard()");
342 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 342 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
343 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 343 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
344 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); 344 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
345 OContact curCont = m_abView->currentEntry(); 345 OContact curCont = m_abView->currentEntry();
346 if ( !curCont.isEmpty() ){ 346 if ( !curCont.isEmpty() ){
347 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 347 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
348 filename ); 348 filename );
349 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 349 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
350 if ( access ){ 350 if ( access ){
351 access->add( curCont ); 351 access->add( curCont );
352 access->save(); 352 access->save();
353 } 353 }
354 delete access; 354 delete access;
355 }else 355 }else
356 QMessageBox::critical( 0, "Export VCard", 356 QMessageBox::critical( 0, "Export VCard",
357 QString( tr( "You have to select a contact !") ) ); 357 QString( tr( "You have to select a contact !") ) );
358 358
359 }else 359 }else
360 QMessageBox::critical( 0, "Export VCard", 360 QMessageBox::critical( 0, "Export VCard",
361 QString( tr( "You have to set a filename !") ) ); 361 QString( tr( "You have to set a filename !") ) );
362} 362}
363 363
364void AddressbookWindow::setDocument( const QString &filename ) 364void AddressbookWindow::setDocument( const QString &filename )
365{ 365{
366 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 366 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
367 367
368 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 368 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
369 369
370 370
371 371
372 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 372 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
373 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 373 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
374 tr( "&Yes" ), tr( "&No" ), QString::null, 374 tr( "&Yes" ), tr( "&No" ), QString::null,
375 0, // Enter == button 0 375 0, // Enter == button 0
376 2 ) ) { // Escape == button 2 376 2 ) ) { // Escape == button 2
377 case 0: 377 case 0:
378 qWarning("YES clicked"); 378 qWarning("YES clicked");
379 break; 379 break;
380 case 1: 380 case 1:
381 qWarning("NO clicked"); 381 qWarning("NO clicked");
382 return; 382 return;
383 break; 383 break;
384 } 384 }
385 } 385 }
386 386
387 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 387 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
388 filename ); 388 filename );
389 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 389 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
390 OContactAccess::List allList = access->allRecords(); 390 OContactAccess::List allList = access->allRecords();
391 qWarning( "Found number of contacts in File: %d", allList.count() ); 391 qWarning( "Found number of contacts in File: %d", allList.count() );
392 392
393 if ( !allList.count() ) { 393 if ( !allList.count() ) {
394 QMessageBox::information( this, "Import VCard", 394 QMessageBox::information( this, "Import VCard",
395 "It was impossible to import\nthe VCard.\n" 395 "It was impossible to import\nthe VCard.\n"
396 "The VCard may be corrupted!" ); 396 "The VCard may be corrupted!" );
397 } 397 }
398 398
399 bool doAsk = true; 399 bool doAsk = true;
400 OContactAccess::List::Iterator it; 400 OContactAccess::List::Iterator it;
401 for ( it = allList.begin(); it != allList.end(); ++it ){ 401 for ( it = allList.begin(); it != allList.end(); ++it ){
402 qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); 402 qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
403 if ( doAsk ){ 403 if ( doAsk ){
404 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 404 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
405 tr( "Do you really want add contact for \n%1?" ) 405 tr( "Do you really want add contact for \n%1?" )
406 .arg( (*it).fullName().latin1() ), 406 .arg( (*it).fullName().latin1() ),
407 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 407 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
408 0, // Enter == button 0 408 0, // Enter == button 0
409 2 ) ) { // Escape == button 2 409 2 ) ) { // Escape == button 2
410 case 0: 410 case 0:
411 qWarning("YES clicked"); 411 qWarning("YES clicked");
412 m_abView->addEntry( *it ); 412 m_abView->addEntry( *it );
413 break; 413 break;
414 case 1: 414 case 1:
415 qWarning("NO clicked"); 415 qWarning("NO clicked");
416 break; 416 break;
417 case 2: 417 case 2:
418 qWarning("YesAll clicked"); 418 qWarning("YesAll clicked");
419 doAsk = false; 419 doAsk = false;
420 break; 420 break;
421 } 421 }
422 }else 422 }else
423 m_abView->addEntry( *it ); 423 m_abView->addEntry( *it );
424 424
425 } 425 }
426 426
427 delete access; 427 delete access;
428} 428}
429 429
430void AddressbookWindow::resizeEvent( QResizeEvent *e ) 430void AddressbookWindow::resizeEvent( QResizeEvent *e )
431{ 431{
432 QMainWindow::resizeEvent( e ); 432 QMainWindow::resizeEvent( e );
433 433
434 434
435} 435}
436 436
437AddressbookWindow::~AddressbookWindow() 437AddressbookWindow::~AddressbookWindow()
438{ 438{
439 ToolBarDock dock; 439 ToolBarDock dock;
440 int dummy; 440 int dummy;
441 bool bDummy; 441 bool bDummy;
442 getLocation ( listTools, dock, dummy, bDummy, dummy ); 442 getLocation ( listTools, dock, dummy, bDummy, dummy );
443 m_config.setToolBarDock( dock ); 443 m_config.setToolBarDock( dock );
444 m_config.save(); 444 m_config.save();
445} 445}
446 446
447void AddressbookWindow::slotUpdateToolbar() 447void AddressbookWindow::slotUpdateToolbar()
448{ 448{
449 OContact ce = m_abView->currentEntry(); 449 OContact ce = m_abView->currentEntry();
450 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 450 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
451} 451}
452 452
453void AddressbookWindow::slotListNew() 453void AddressbookWindow::slotListNew()
454{ 454{
455 OContact cnt; 455 OContact cnt;
456 if( !syncing ) { 456 if( !syncing ) {
457 editEntry( NewEntry ); 457 editEntry( NewEntry );
458 } else { 458 } else {
459 QMessageBox::warning(this, tr("Contacts"), 459 QMessageBox::warning(this, tr("Contacts"),
460 tr("Can not edit data, currently syncing")); 460 tr("Can not edit data, currently syncing"));
461 } 461 }
462} 462}
463 463
464// void AddressbookWindow::slotListView() 464// void AddressbookWindow::slotListView()
465// { 465// {
466 // m_abView -> init( abList->currentEntry() ); 466 // m_abView -> init( abList->currentEntry() );
467 // // :SX mView->sync(); 467 // // :SX mView->sync();
468 // //:SXshowView(); 468 // //:SXshowView();
469// } 469// }
470 470
471void AddressbookWindow::slotListDelete() 471void AddressbookWindow::slotListDelete()
472{ 472{
473 if(!syncing) { 473 if(!syncing) {
474 OContact tmpEntry = m_abView ->currentEntry(); 474 OContact tmpEntry = m_abView ->currentEntry();
475 475
476 // get a name, do the best we can... 476 // get a name, do the best we can...
477 QString strName = tmpEntry.fullName(); 477 QString strName = tmpEntry.fullName();
478 if ( strName.isEmpty() ) { 478 if ( strName.isEmpty() ) {
479 strName = tmpEntry.company(); 479 strName = tmpEntry.company();
480 if ( strName.isEmpty() ) 480 if ( strName.isEmpty() )
481 strName = "No Name"; 481 strName = "No Name";
482 } 482 }
483 483
484 484
485 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 485 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
486 strName ) ) { 486 strName ) ) {
487 m_abView->removeEntry( tmpEntry.uid() ); 487 m_abView->removeEntry( tmpEntry.uid() );
488 } 488 }
489 } else { 489 } else {
490 QMessageBox::warning( this, tr("Contacts"), 490 QMessageBox::warning( this, tr("Contacts"),
491 tr("Can not edit data, currently syncing") ); 491 tr("Can not edit data, currently syncing") );
492 } 492 }
493} 493}
494 494
495void AddressbookWindow::slotFindOpen() 495void AddressbookWindow::slotFindOpen()
496{ 496{
497 searchBar->show(); 497 searchBar->show();
498 m_abView -> inSearch(); 498 m_abView -> inSearch();
499 searchEdit->setFocus(); 499 searchEdit->setFocus();
500} 500}
501void AddressbookWindow::slotFindClose() 501void AddressbookWindow::slotFindClose()
502{ 502{
503 searchBar->hide(); 503 searchBar->hide();
504 m_abView -> offSearch(); 504 m_abView -> offSearch();
505 // m_abView->setFocus(); 505 // m_abView->setFocus();
506} 506}
507 507
508 508
509void AddressbookWindow::slotFind() 509void AddressbookWindow::slotFind()
510{ 510{
511 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 511 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
512 512
513 searchEdit->clearFocus(); 513 searchEdit->clearFocus();
514 // m_abView->setFocus(); 514 // m_abView->setFocus();
515 515
516} 516}
517 517
518void AddressbookWindow::slotViewBack() 518void AddressbookWindow::slotViewBack()
519{ 519{
520 // :SX showList(); 520 // :SX showList();
521} 521}
522 522
523void AddressbookWindow::slotViewEdit() 523void AddressbookWindow::slotViewEdit()
524{ 524{
525 if(!syncing) { 525 if(!syncing) {
526 if (actionPersonal->isOn()) { 526 if (actionPersonal->isOn()) {
527 editPersonal(); 527 editPersonal();
528 } else { 528 } else {
529 editEntry( EditEntry ); 529 editEntry( EditEntry );
530 } 530 }
531 } else { 531 } else {
532 QMessageBox::warning( this, tr("Contacts"), 532 QMessageBox::warning( this, tr("Contacts"),
533 tr("Can not edit data, currently syncing") ); 533 tr("Can not edit data, currently syncing") );
534 } 534 }
535} 535}
536 536
537 537
538 538
539void AddressbookWindow::writeMail() 539void AddressbookWindow::writeMail()
540{ 540{
541 OContact c = m_abView -> currentEntry(); 541 OContact c = m_abView -> currentEntry();
542 QString name = c.fileAs(); 542 QString name = c.fileAs();
543 QString email = c.defaultEmail(); 543 QString email = c.defaultEmail();
544 544
545 // I prefer the OPIE-Environment variable before the 545 // I prefer the OPIE-Environment variable before the
546 // QPE-one.. 546 // QPE-one..
547 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 547 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
548 if ( basepath.isEmpty() ) 548 if ( basepath.isEmpty() )
549 basepath = QString::fromLatin1( getenv("QPEDIR") ); 549 basepath = QString::fromLatin1( getenv("QPEDIR") );
550 550
551 // Try to access the preferred. If not possible, try to 551 // Try to access the preferred. If not possible, try to
552 // switch to the other one.. 552 // switch to the other one..
553 if ( m_config.useQtMail() ){ 553 if ( m_config.useQtMail() ){
554 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 554 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
555 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 555 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
556 qWarning ("QCop"); 556 qWarning ("QCop");
557 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 557 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
558 e << name << email; 558 e << name << email;
559 return; 559 return;
560 } else 560 } else
561 m_config.setUseOpieMail( true ); 561 m_config.setUseOpieMail( true );
562 } 562 }
563 if ( m_config.useOpieMail() ){ 563 if ( m_config.useOpieMail() ){
564 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 564 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
565 if ( QFile::exists( basepath + "/bin/mail" ) ){ 565 if ( QFile::exists( basepath + "/bin/mail" ) ){
566 qWarning ("QCop"); 566 qWarning ("QCop");
567 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 567 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
568 e << name << email; 568 e << name << email;
569 return; 569 return;
570 } else 570 } else
571 m_config.setUseQtMail( true ); 571 m_config.setUseQtMail( true );
572 } 572 }
573 573
574} 574}
575 575
576static const char * beamfile = "/tmp/obex/contact.vcf"; 576static const char * beamfile = "/tmp/obex/contact.vcf";
577 577
578void AddressbookWindow::slotBeam() 578void AddressbookWindow::slotBeam()
579{ 579{
580 QString beamFilename; 580 QString beamFilename;
581 OContact c; 581 OContact c;
582 if ( actionPersonal->isOn() ) { 582 if ( actionPersonal->isOn() ) {
583 beamFilename = addressbookPersonalVCardName(); 583 beamFilename = addressbookPersonalVCardName();
584 if ( !QFile::exists( beamFilename ) ) 584 if ( !QFile::exists( beamFilename ) )
585 return; // can't beam a non-existent file 585 return; // can't beam a non-existent file
586 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 586 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
587 beamFilename ); 587 beamFilename );
588 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 588 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
589 OContactAccess::List allList = access->allRecords(); 589 OContactAccess::List allList = access->allRecords();
590 OContactAccess::List::Iterator it = allList.begin(); // Just take first 590 OContactAccess::List::Iterator it = allList.begin(); // Just take first
591 c = *it; 591 c = *it;
592 592
593 delete access; 593 delete access;
594 } else { 594 } else {
595 unlink( beamfile ); // delete if exists 595 unlink( beamfile ); // delete if exists
596 mkdir("/tmp/obex/", 0755); 596 mkdir("/tmp/obex/", 0755);
597 c = m_abView -> currentEntry(); 597 c = m_abView -> currentEntry();
598 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 598 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
599 beamfile ); 599 beamfile );
600 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 600 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
601 access->add( c ); 601 access->add( c );
602 access->save(); 602 access->save();
603 delete access; 603 delete access;
604 604
605 beamFilename = beamfile; 605 beamFilename = beamfile;
606 } 606 }
607 607
608 qWarning("Beaming: %s", beamFilename.latin1() ); 608 qWarning("Beaming: %s", beamFilename.latin1() );
609 609
610 Ir *ir = new Ir( this ); 610 Ir *ir = new Ir( this );
611 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 611 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
612 QString description = c.fullName(); 612 QString description = c.fullName();
613 ir->send( beamFilename, description, "text/x-vCard" ); 613 ir->send( beamFilename, description, "text/x-vCard" );
614} 614}
615 615
616void AddressbookWindow::beamDone( Ir *ir ) 616void AddressbookWindow::beamDone( Ir *ir )
617{ 617{
618 618
619 delete ir; 619 delete ir;
620 unlink( beamfile ); 620 unlink( beamfile );
621} 621}
622 622
623 623
624static void parseName( const QString& name, QString *first, QString *middle, 624static void parseName( const QString& name, QString *first, QString *middle,
625 QString * last ) 625 QString * last )
626{ 626{
627 627
628 int comma = name.find ( "," ); 628 int comma = name.find ( "," );
629 QString rest; 629 QString rest;
630 if ( comma > 0 ) { 630 if ( comma > 0 ) {
631 *last = name.left( comma ); 631 *last = name.left( comma );
632 comma++; 632 comma++;
633 while ( comma < int(name.length()) && name[comma] == ' ' ) 633 while ( comma < int(name.length()) && name[comma] == ' ' )
634 comma++; 634 comma++;
635 rest = name.mid( comma ); 635 rest = name.mid( comma );
636 } else { 636 } else {
637 int space = name.findRev( ' ' ); 637 int space = name.findRev( ' ' );
638 *last = name.mid( space+1 ); 638 *last = name.mid( space+1 );
639 rest = name.left( space ); 639 rest = name.left( space );
640 } 640 }
641 int space = rest.find( ' ' ); 641 int space = rest.find( ' ' );
642 if ( space <= 0 ) { 642 if ( space <= 0 ) {
643 *first = rest; 643 *first = rest;
644 } else { 644 } else {
645 *first = rest.left( space ); 645 *first = rest.left( space );
646 *middle = rest.mid( space+1 ); 646 *middle = rest.mid( space+1 );
647 } 647 }
648 648
649} 649}
650 650
651 651
652void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 652void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
653{ 653{
654 bool needShow = FALSE; 654 bool needShow = FALSE;
655 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); 655 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() );
656 656
657 657
658 if (msg == "editPersonal()") { 658 if (msg == "editPersonal()") {
659 editPersonal(); 659 editPersonal();
660 } else if (msg == "editPersonalAndClose()") { 660 } else if (msg == "editPersonalAndClose()") {
661 editPersonal(); 661 editPersonal();
662 close(); 662 close();
663 } else if ( msg == "addContact(QString,QString)" ) { 663 } else if ( msg == "addContact(QString,QString)" ) {
664 QDataStream stream(data,IO_ReadOnly); 664 QDataStream stream(data,IO_ReadOnly);
665 QString name, email; 665 QString name, email;
666 stream >> name >> email; 666 stream >> name >> email;
667 667
668 OContact cnt; 668 OContact cnt;
669 QString fn, mn, ln; 669 QString fn, mn, ln;
670 parseName( name, &fn, &mn, &ln ); 670 parseName( name, &fn, &mn, &ln );
671 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 671 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
672 cnt.setFirstName( fn ); 672 cnt.setFirstName( fn );
673 cnt.setMiddleName( mn ); 673 cnt.setMiddleName( mn );
674 cnt.setLastName( ln ); 674 cnt.setLastName( ln );
675 cnt.insertEmails( email ); 675 cnt.insertEmails( email );
676 cnt.setDefaultEmail( email ); 676 cnt.setDefaultEmail( email );
677 cnt.setFileAs(); 677 cnt.setFileAs();
678 678
679 m_abView -> addEntry( cnt ); 679 m_abView -> addEntry( cnt );
680 680
681 // :SXm_abView()->init( cnt ); 681 // :SXm_abView()->init( cnt );
682 editEntry( EditEntry ); 682 editEntry( EditEntry );
683 } else if ( msg == "beamBusinessCard()" ) { 683 } else if ( msg == "beamBusinessCard()" ) {
684 QString beamFilename = addressbookPersonalVCardName(); 684 QString beamFilename = addressbookPersonalVCardName();
685 if ( !QFile::exists( beamFilename ) ) 685 if ( !QFile::exists( beamFilename ) )
686 return; // can't beam a non-existent file 686 return; // can't beam a non-existent file
687 687
688 Ir *ir = new Ir( this ); 688 Ir *ir = new Ir( this );
689 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 689 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
690 QString description = "mycard.vcf"; 690 QString description = "mycard.vcf";
691 ir->send( beamFilename, description, "text/x-vCard" ); 691 ir->send( beamFilename, description, "text/x-vCard" );
692 } else if ( msg == "show(int)" ) { 692 } else if ( msg == "show(int)" ) {
693 raise(); 693 raise();
694 QDataStream stream(data,IO_ReadOnly); 694 QDataStream stream(data,IO_ReadOnly);
695 int uid; 695 int uid;
696 stream >> uid; 696 stream >> uid;
697 697
698 qWarning( "Showing uid: %d" , uid ); 698 qWarning( "Showing uid: %d" , uid );
699 699
700 // Deactivate Personal View.. 700 // Deactivate Personal View..
701 if ( actionPersonal->isOn() ){ 701 if ( actionPersonal->isOn() ){
702 actionPersonal->setOn( false ); 702 actionPersonal->setOn( false );
703 slotPersonalView(); 703 slotPersonalView();
704 } 704 }
705 705
706 // Reset category and show as card.. 706 // Reset category and show as card..
707 m_abView -> setShowByCategory( QString::null ); 707 m_abView -> setShowByCategory( QString::null );
708 m_abView -> setCurrentUid( uid ); 708 m_abView -> setCurrentUid( uid );
709 slotViewSwitched ( AbView::CardView ); 709 slotViewSwitched ( AbView::CardView );
710 710
711 needShow = true; 711 needShow = true;
712 712
713 713
714 } else if ( msg == "edit(int)" ) { 714 } else if ( msg == "edit(int)" ) {
715 QDataStream stream(data,IO_ReadOnly); 715 QDataStream stream(data,IO_ReadOnly);
716 int uid; 716 int uid;
717 stream >> uid; 717 stream >> uid;
718 718
719 // Deactivate Personal View.. 719 // Deactivate Personal View..
720 if ( actionPersonal->isOn() ){ 720 if ( actionPersonal->isOn() ){
721 actionPersonal->setOn( false ); 721 actionPersonal->setOn( false );
722 slotPersonalView(); 722 slotPersonalView();
723 } 723 }
724 724
725 // Reset category and edit.. 725 // Reset category and edit..
726 m_abView -> setShowByCategory( QString::null ); 726 m_abView -> setShowByCategory( QString::null );
727 m_abView -> setCurrentUid( uid ); 727 m_abView -> setCurrentUid( uid );
728 slotViewEdit(); 728 slotViewEdit();
729 } 729 }
730 730
731 if (needShow) 731 if (needShow)
732 QPEApplication::setKeepRunning(); 732 QPEApplication::setKeepRunning();
733 733
734} 734}
735 735
736void AddressbookWindow::editEntry( EntryMode entryMode ) 736void AddressbookWindow::editEntry( EntryMode entryMode )
737{ 737{
738 OContact entry; 738 OContact entry;
739 if ( !abEditor ) { 739 if ( !abEditor ) {
740 abEditor = new ContactEditor( entry, this, "editor" ); 740 abEditor = new ContactEditor( entry, this, "editor" );
741 } 741 }
742 if ( entryMode == EditEntry ) 742 if ( entryMode == EditEntry )
743 abEditor->setEntry( m_abView -> currentEntry() ); 743 abEditor->setEntry( m_abView -> currentEntry() );
744 else if ( entryMode == NewEntry ) 744 else if ( entryMode == NewEntry )
745 abEditor->setEntry( entry ); 745 abEditor->setEntry( entry );
746 // other things may change the caption. 746 // other things may change the caption.
747 abEditor->setCaption( tr("Edit Address") ); 747 abEditor->setCaption( tr("Edit Address") );
748 748
749#if defined(Q_WS_QWS) || defined(_WS_QWS_) 749#if defined(Q_WS_QWS) || defined(_WS_QWS_)
750 abEditor->showMaximized(); 750 abEditor->showMaximized();
751#endif 751#endif
752 // fix the foxus... 752 // fix the foxus...
753 abEditor->setNameFocus(); 753 abEditor->setNameFocus();
754 if ( abEditor->exec() ) { 754 if ( abEditor->exec() ) {
755 setFocus(); 755 setFocus();
756 if ( entryMode == NewEntry ) { 756 if ( entryMode == NewEntry ) {
757 OContact insertEntry = abEditor->entry(); 757 OContact insertEntry = abEditor->entry();
758 insertEntry.assignUid(); 758 insertEntry.assignUid();
759 m_abView -> addEntry( insertEntry ); 759 m_abView -> addEntry( insertEntry );
760 m_abView -> setCurrentUid( insertEntry.uid() ); 760 m_abView -> setCurrentUid( insertEntry.uid() );
761 } else { 761 } else {
762 OContact replEntry = abEditor->entry(); 762 OContact replEntry = abEditor->entry();
763 763
764 if ( !replEntry.isValidUid() ) 764 if ( !replEntry.isValidUid() )
765 replEntry.assignUid(); 765 replEntry.assignUid();
766 766
767 m_abView -> replaceEntry( replEntry ); 767 m_abView -> replaceEntry( replEntry );
768 } 768 }
769 } 769 }
770 // populateCategories(); 770 // populateCategories();
771 771
772} 772}
773 773
774void AddressbookWindow::editPersonal() 774void AddressbookWindow::editPersonal()
775{ 775{
776 OContact entry; 776 OContact entry;
777 777
778 // Switch to personal view if not selected 778 // Switch to personal view if not selected
779 // but take care of the menu, too 779 // but take care of the menu, too
780 if ( ! actionPersonal->isOn() ){ 780 if ( ! actionPersonal->isOn() ){
781 qWarning("*** ++++"); 781 qWarning("*** ++++");
782 actionPersonal->setOn( true ); 782 actionPersonal->setOn( true );
783 slotPersonalView(); 783 slotPersonalView();
784 } 784 }
785 785
786 if ( !abEditor ) { 786 if ( !abEditor ) {
787 abEditor = new ContactEditor( entry, this, "editor" ); 787 abEditor = new ContactEditor( entry, this, "editor" );
788 } 788 }
789 789
790 abEditor->setCaption(tr("Edit My Personal Details")); 790 abEditor->setCaption(tr("Edit My Personal Details"));
791 abEditor->setPersonalView( true ); 791 abEditor->setPersonalView( true );
792 editEntry( EditEntry ); 792 editEntry( EditEntry );
793 abEditor->setPersonalView( false ); 793 abEditor->setPersonalView( false );
794 794
795} 795}
796 796
797 797
798void AddressbookWindow::slotPersonalView() 798void AddressbookWindow::slotPersonalView()
799{ 799{
800 qWarning("slotPersonalView()"); 800 qWarning("slotPersonalView()");
801 if (!actionPersonal->isOn()) { 801 if (!actionPersonal->isOn()) {
802 // we just turned it off 802 // we just turned it off
803 qWarning("slotPersonalView()-> OFF"); 803 qWarning("slotPersonalView()-> OFF");
804 setCaption( tr("Contacts") ); 804 setCaption( tr("Contacts") );
805 actionNew->setEnabled(TRUE); 805 actionNew->setEnabled(TRUE);
806 actionTrash->setEnabled(TRUE); 806 actionTrash->setEnabled(TRUE);
807 actionFind->setEnabled(TRUE); 807 actionFind->setEnabled(TRUE);
808 actionMail->setEnabled(TRUE); 808 actionMail->setEnabled(TRUE);
809 // slotUpdateToolbar(); 809 // slotUpdateToolbar();
810 810
811 m_abView->showPersonal( false ); 811 m_abView->showPersonal( false );
812 812
813 return; 813 return;
814 } 814 }
815 815
816 qWarning("slotPersonalView()-> ON"); 816 qWarning("slotPersonalView()-> ON");
817 // XXX need to disable some QActions. 817 // XXX need to disable some QActions.
818 actionNew->setEnabled(FALSE); 818 actionNew->setEnabled(FALSE);
819 actionTrash->setEnabled(FALSE); 819 actionTrash->setEnabled(FALSE);
820 actionFind->setEnabled(FALSE); 820 actionFind->setEnabled(FALSE);
821 actionMail->setEnabled(FALSE); 821 actionMail->setEnabled(FALSE);
822 822
823 setCaption( tr("Contacts - My Personal Details") ); 823 setCaption( tr("Contacts - My Personal Details") );
824 824
825 m_abView->showPersonal( true ); 825 m_abView->showPersonal( true );
826 826
827} 827}
828 828
829 829
830void AddressbookWindow::listIsEmpty( bool empty ) 830void AddressbookWindow::listIsEmpty( bool empty )
831{ 831{
832 if ( !empty ) { 832 if ( !empty ) {
833 deleteButton->setEnabled( TRUE ); 833 deleteButton->setEnabled( TRUE );
834 } 834 }
835} 835}
836 836
837void AddressbookWindow::reload() 837void AddressbookWindow::reload()
838{ 838{
839 syncing = FALSE; 839 syncing = FALSE;
840 m_abView->clear(); 840 m_abView->clear();
841 m_abView->reload(); 841 m_abView->reload();
842} 842}
843 843
844void AddressbookWindow::flush() 844void AddressbookWindow::flush()
845{ 845{
846 syncing = TRUE; 846 syncing = TRUE;
847 m_abView->save(); 847 m_abView->save();
848} 848}
849 849
850 850
851void AddressbookWindow::closeEvent( QCloseEvent *e ) 851void AddressbookWindow::closeEvent( QCloseEvent *e )
852{ 852{
853 if(active_view == AbView::CardView){ 853 if(active_view == AbView::CardView){
854 slotViewSwitched( AbView::TableView ); 854 slotViewSwitched( AbView::TableView );
855 e->ignore(); 855 e->ignore();
856 return; 856 return;
857 } 857 }
858 if(syncing) { 858 if(syncing) {
859 /* shouldn't we save, I hear you say? well its already been set 859 /* shouldn't we save, I hear you say? well its already been set
860 so that an edit can not occur during a sync, and we flushed 860 so that an edit can not occur during a sync, and we flushed
861 at the start of the sync, so there is no need to save 861 at the start of the sync, so there is no need to save
862 Saving however itself would cause problems. */ 862 Saving however itself would cause problems. */
863 e->accept(); 863 e->accept();
864 return; 864 return;
865 } 865 }
866 //################## shouldn't always save 866 //################## shouldn't always save
867 // True, but the database handles this automatically ! (se) 867 // True, but the database handles this automatically ! (se)
868 if ( save() ) 868 if ( save() )
869 e->accept(); 869 e->accept();
870 else 870 else
871 e->ignore(); 871 e->ignore();
872} 872}
873 873
874/* 874/*
875 Returns TRUE if it is OK to exit 875 Returns TRUE if it is OK to exit
876*/ 876*/
877 877
878bool AddressbookWindow::save() 878bool AddressbookWindow::save()
879{ 879{
880 if ( !m_abView->save() ) { 880 if ( !m_abView->save() ) {
881 if ( QMessageBox::critical( 0, tr( "Out of space" ), 881 if ( QMessageBox::critical( 0, tr( "Out of space" ),
882 tr("Unable to save information.\n" 882 tr("Unable to save information.\n"
883 "Free up some space\n" 883 "Free up some space\n"
884 "and try again.\n" 884 "and try again.\n"
885 "\nQuit anyway?"), 885 "\nQuit anyway?"),
886 QMessageBox::Yes|QMessageBox::Escape, 886 QMessageBox::Yes|QMessageBox::Escape,
887 QMessageBox::No|QMessageBox::Default ) 887 QMessageBox::No|QMessageBox::Default )
888 != QMessageBox::No ) 888 != QMessageBox::No )
889 return TRUE; 889 return TRUE;
890 else 890 else
891 return FALSE; 891 return FALSE;
892 } 892 }
893 return TRUE; 893 return TRUE;
894} 894}
895 895
896#ifdef __DEBUG_RELEASE 896#ifdef __DEBUG_RELEASE
897void AddressbookWindow::slotSave() 897void AddressbookWindow::slotSave()
898{ 898{
899 save(); 899 save();
900} 900}
901#endif 901#endif
902 902
903 903
904void AddressbookWindow::slotNotFound() 904void AddressbookWindow::slotNotFound()
905{ 905{
906 qWarning("Got notfound signal!"); 906 qWarning("Got notfound signal!");
907 QMessageBox::information( this, tr( "Not Found" ), 907 QMessageBox::information( this, tr( "Not Found" ),
908 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); 908 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" );
909 909
910 910
911} 911}
912void AddressbookWindow::slotWrapAround() 912void AddressbookWindow::slotWrapAround()
913{ 913{
914 qWarning("Got wrap signal!"); 914 qWarning("Got wrap signal!");
915 // if ( doNotifyWrapAround ) 915 // if ( doNotifyWrapAround )
916 // QMessageBox::information( this, tr( "End of list" ), 916 // QMessageBox::information( this, tr( "End of list" ),
917 // tr( "End of list. Wrap around now...!" ) + "\n" ); 917 // tr( "End of list. Wrap around now...!" ) + "\n" );
918 918
919} 919}
920 920
921void AddressbookWindow::slotSetCategory( int c ) 921void AddressbookWindow::slotSetCategory( int c )
922{ 922{
923 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); 923 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
924 924
925 QString cat, book; 925 QString cat, book;
926 AbView::Views view = AbView::TableView; 926 AbView::Views view = AbView::TableView;
927 927
928 if ( c <= 0 ) 928 if ( c <= 0 )
929 return; 929 return;
930 930
931 // Switch view 931 // Switch view
932 if ( c < 3 ) 932 if ( c < 3 )
933 for ( unsigned int i = 1; i < 3; i++ ){ 933 for ( unsigned int i = 1; i < 3; i++ ){
934 if ( catMenu ) 934 if ( catMenu )
935 catMenu->setItemChecked( i, c == (int)i ); 935 catMenu->setItemChecked( i, c == (int)i );
936 } 936 }
937 else 937 else
938 // Checkmark Category Menu Item Selected 938 // Checkmark Category Menu Item Selected
939 for ( unsigned int i = 3; i < catMenu->count(); i++ ) 939 for ( unsigned int i = 3; i < catMenu->count(); i++ )
940 catMenu->setItemChecked( i, c == (int)i ); 940 catMenu->setItemChecked( i, c == (int)i );
941 941
942 // Now switch to the selected category 942 // Now switch to the selected category
943 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 943 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
944 if (catMenu->isItemChecked( i )) { 944 if (catMenu->isItemChecked( i )) {
945 if ( i == 1 ){ // default List view 945 if ( i == 1 ){ // default List view
946 book = QString::null; 946 book = QString::null;
947 view = AbView::TableView; 947 view = AbView::TableView;
948 }else if ( i == 2 ){ 948 }else if ( i == 2 ){
949 book = tr( "Cards" ); 949 book = tr( "Cards" );
950 view = AbView::CardView; 950 view = AbView::CardView;
951 // }else if ( i == 3 ){ 951 // }else if ( i == 3 ){
952 // book = tr( "Personal" ); 952 // book = tr( "Personal" );
953 // view = AbView:: PersonalView; 953 // view = AbView:: PersonalView;
954 }else if ( i == 3 ){ // default All Categories 954 }else if ( i == 3 ){ // default All Categories
955 cat = QString::null; 955 cat = QString::null;
956 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled 956 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
957 cat = "Unfiled"; 957 cat = "Unfiled";
958 qWarning ("Unfiled selected!"); 958 qWarning ("Unfiled selected!");
959 }else{ 959 }else{
960 cat = m_abView->categories()[i - 4]; 960 cat = m_abView->categories()[i - 4];
961 } 961 }
962 } 962 }
963 } 963 }
964 964
965 // Switch to the selected View 965 // Switch to the selected View
966 slotViewSwitched( view ); 966 slotViewSwitched( view );
967 967
968 // Tell the view about the selected category 968 // Tell the view about the selected category
969 m_abView -> setShowByCategory( cat ); 969 m_abView -> setShowByCategory( cat );
970 970
971 if ( book.isEmpty() ) 971 if ( book.isEmpty() )
972 book = "List"; 972 book = "List";
973 if ( cat.isEmpty() ) 973 if ( cat.isEmpty() )
974 cat = "All"; 974 cat = "All";
975 975
976 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); 976 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
977} 977}
978 978
979void AddressbookWindow::slotViewSwitched( int view ) 979void AddressbookWindow::slotViewSwitched( int view )
980{ 980{
981 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); 981 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
982 int menu = 0; 982 int menu = 0;
983 983
984 // Switch to selected view 984 // Switch to selected view
985 switch ( view ){ 985 switch ( view ){
986 case AbView::TableView: 986 case AbView::TableView:
987 menu = 1; 987 menu = 1;
988 m_tableViewButton->setOn(true); 988 m_tableViewButton->setOn(true);
989 m_cardViewButton->setOn(false); 989 m_cardViewButton->setOn(false);
990 break; 990 break;
991 case AbView::CardView: 991 case AbView::CardView:
992 menu = 2; 992 menu = 2;
993 m_tableViewButton->setOn(false); 993 m_tableViewButton->setOn(false);
994 m_cardViewButton->setOn(true); 994 m_cardViewButton->setOn(true);
995 break; 995 break;
996 } 996 }
997 for ( unsigned int i = 1; i < 3; i++ ){ 997 for ( unsigned int i = 1; i < 3; i++ ){
998 if ( catMenu ) 998 if ( catMenu )
999 catMenu->setItemChecked( i, menu == (int)i ); 999 catMenu->setItemChecked( i, menu == (int)i );
1000 } 1000 }
1001 1001
1002 // Tell the view about the selected view 1002 // Tell the view about the selected view
1003 m_abView -> setShowToView ( (AbView::Views) view ); 1003 m_abView -> setShowToView ( (AbView::Views) view );
1004 active_view = view; 1004 active_view = view;
1005} 1005}
1006 1006
1007 1007
1008void AddressbookWindow::slotListView() 1008void AddressbookWindow::slotListView()
1009{ 1009{
1010 slotViewSwitched( AbView::TableView ); 1010 slotViewSwitched( AbView::TableView );
1011} 1011}
1012 1012
1013void AddressbookWindow::slotCardView() 1013void AddressbookWindow::slotCardView()
1014{ 1014{
1015 slotViewSwitched( AbView::CardView ); 1015 slotViewSwitched( AbView::CardView );
1016} 1016}
1017 1017
1018void AddressbookWindow::slotSetLetter( char c ) { 1018void AddressbookWindow::slotSetLetter( char c ) {
1019 1019
1020 m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); 1020 m_abView->setShowByLetter( c, m_config.letterPickerSearch() );
1021 1021
1022} 1022}
1023 1023
1024 1024
1025void AddressbookWindow::populateCategories() 1025void AddressbookWindow::populateCategories()
1026{ 1026{
1027 catMenu->clear(); 1027 catMenu->clear();
1028 1028
1029 int id, rememberId; 1029 int id, rememberId;
1030 id = 1; 1030 id = 1;
1031 rememberId = 0; 1031 rememberId = 0;
1032 1032
1033 catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); 1033 catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ );
1034 catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); 1034 catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ );
1035 // catMenu->insertItem( tr( "Personal" ), id++ ); 1035 // catMenu->insertItem( tr( "Personal" ), id++ );
1036 catMenu->insertSeparator(); 1036 catMenu->insertSeparator();
1037 1037
1038 catMenu->insertItem( tr( "All" ), id++ ); 1038 catMenu->insertItem( tr( "All" ), id++ );
1039 QStringList categories = m_abView->categories(); 1039 QStringList categories = m_abView->categories();
1040 categories.append( tr( "Unfiled" ) ); 1040 categories.append( tr( "Unfiled" ) );
1041 for ( QStringList::Iterator it = categories.begin(); 1041 for ( QStringList::Iterator it = categories.begin();
1042 it != categories.end(); ++it ) { 1042 it != categories.end(); ++it ) {
1043 catMenu->insertItem( *it, id ); 1043 catMenu->insertItem( *it, id );
1044 if ( *it == m_abView -> showCategory() ) 1044 if ( *it == m_abView -> showCategory() )
1045 rememberId = id; 1045 rememberId = id;
1046 ++id; 1046 ++id;
1047 } 1047 }
1048 1048
1049 1049
1050 if ( m_abView -> showCategory().isEmpty() ) { 1050 if ( m_abView -> showCategory().isEmpty() ) {
1051 slotSetCategory( 3 ); 1051 slotSetCategory( 3 );
1052 } 1052 }
1053 else { 1053 else {
1054 slotSetCategory( rememberId ); 1054 slotSetCategory( rememberId );
1055 } 1055 }
1056} 1056}
1057 1057
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index 9621826..790aa95 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -1,10 +1,10 @@
1#ifndef _VERSION_H_ 1#ifndef _VERSION_H_
2#define _VERSION_H_ 2#define _VERSION_H_
3 3
4#define MAINVERSION "1" 4#define MAINVERSION "1"
5#define SUBVERSION "0" 5#define SUBVERSION "1"
6#define PATCHVERSION "0" 6#define PATCHVERSION "0"
7 7
8#define APPNAME "OPIE_ADDRESSBOOK" 8#define APPNAME "OPIE_ADDRESSBOOK"
9 9
10#endif 10#endif