summaryrefslogtreecommitdiff
authortille <tille>2002-12-08 16:47:12 (UTC)
committer tille <tille>2002-12-08 16:47:12 (UTC)
commitaea4a628b4500f8551255d715c9f8696c6ad3280 (patch) (unidiff)
tree96fbc930732b4574490fe7e59fa19a35fb5b8596
parenta2840f80792c7e40ee3b44be0ec48302d8816cc0 (diff)
downloadopie-aea4a628b4500f8551255d715c9f8696c6ad3280.zip
opie-aea4a628b4500f8551255d715c9f8696c6ad3280.tar.gz
opie-aea4a628b4500f8551255d715c9f8696c6ad3280.tar.bz2
do not close ab while in cardview, rather switch back to listview
as the old version did
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp8
-rw-r--r--core/pim/addressbook/addressbook.h2
2 files changed, 8 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 055124c..60db2b4 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,950 +1,954 @@
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** OContact info@trolltech.com if any conditions of this licensing are 16** OContact 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#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abview.h" 25#include "abview.h"
26#include "abtable.h" 26#include "abtable.h"
27// #include "addresssettings.h" 27// #include "addresssettings.h"
28#include "addressbook.h" 28#include "addressbook.h"
29 29
30 30
31#include <opie/ofileselector.h> 31#include <opie/ofileselector.h>
32#include <opie/ofiledialog.h> 32#include <opie/ofiledialog.h>
33#include <opie/ocontact.h> 33#include <opie/ocontact.h>
34#include <opie/ocontactaccessbackend_vcard.h> 34#include <opie/ocontactaccessbackend_vcard.h>
35 35
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/ir.h> 37#include <qpe/ir.h>
38#include <qpe/qpemessagebox.h> 38#include <qpe/qpemessagebox.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpetoolbar.h> 40#include <qpe/qpetoolbar.h>
41#include <qpe/qpemenubar.h> 41#include <qpe/qpemenubar.h>
42// #include <qtoolbar.h> 42// #include <qtoolbar.h>
43// #include <qmenubar.h> 43// #include <qmenubar.h>
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#include <qpe/config.h> 45#include <qpe/config.h>
46 46
47#include <qaction.h> 47#include <qaction.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdir.h> 49#include <qdir.h>
50#include <qfile.h> 50#include <qfile.h>
51#include <qimage.h> 51#include <qimage.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qpixmap.h> 54#include <qpixmap.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qstringlist.h> 56#include <qstringlist.h>
57#include <qtoolbutton.h> 57#include <qtoolbutton.h>
58#include <qwhatsthis.h> 58#include <qwhatsthis.h>
59#include <qdatetime.h> 59#include <qdatetime.h>
60 60
61#include <stdlib.h> 61#include <stdlib.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <sys/types.h> 63#include <sys/types.h>
64#include <fcntl.h> 64#include <fcntl.h>
65#include <unistd.h> 65#include <unistd.h>
66 66
67 67
68#include "picker.h" 68#include "picker.h"
69#include "configdlg.h" 69#include "configdlg.h"
70 70
71extern QString addressbookPersonalVCardName(); 71extern QString addressbookPersonalVCardName();
72 72
73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
74 WFlags f ) 74 WFlags f )
75 : QMainWindow( parent, name, f ), 75 : QMainWindow( parent, name, f ),
76 catMenu (0l), 76 catMenu (0l),
77 abEditor(0l), 77 abEditor(0l),
78 syncing(FALSE), 78 syncing(FALSE),
79 m_tableViewButton(0l), 79 m_tableViewButton(0l),
80 m_cardViewButton(0l) 80 m_cardViewButton(0l)
81{ 81{
82 isLoading = true; 82 isLoading = true;
83 83
84 m_config.load(); 84 m_config.load();
85 85
86 setCaption( tr("Contacts") ); 86 setCaption( tr("Contacts") );
87 setIcon( Resource::loadPixmap( "AddressBook" ) ); 87 setIcon( Resource::loadPixmap( "AddressBook" ) );
88 88
89 // Settings for Main Menu 89 // Settings for Main Menu
90 setToolBarsMovable( true ); 90 setToolBarsMovable( true );
91 setRightJustification( true ); 91 setRightJustification( true );
92 92
93 // Create Toolbar 93 // Create Toolbar
94 listTools = new QPEToolBar( this, "list operations" ); 94 listTools = new QPEToolBar( this, "list operations" );
95 listTools->setHorizontalStretchable( true ); 95 listTools->setHorizontalStretchable( true );
96 addToolBar( listTools ); 96 addToolBar( listTools );
97 moveToolBar( listTools, m_config.getToolBarPos() ); 97 moveToolBar( listTools, m_config.getToolBarPos() );
98 98
99 QPEMenuBar *mbList = new QPEMenuBar( this ); 99 QPEMenuBar *mbList = new QPEMenuBar( this );
100 mbList->setMargin( 0 ); 100 mbList->setMargin( 0 );
101 101
102 QPopupMenu *edit = new QPopupMenu( mbList ); 102 QPopupMenu *edit = new QPopupMenu( mbList );
103 mbList->insertItem( tr( "Contact" ), edit ); 103 mbList->insertItem( tr( "Contact" ), edit );
104 104
105 105
106 // View Icons 106 // View Icons
107 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ), 107 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ),
108 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
109 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); 109 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
110 m_tableViewButton->setToggleAction( true ); 110 m_tableViewButton->setToggleAction( true );
111 m_tableViewButton->addTo( listTools ); 111 m_tableViewButton->addTo( listTools );
112 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); 112 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 );
113 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); 113 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
114 m_cardViewButton->setToggleAction( true ); 114 m_cardViewButton->setToggleAction( true );
115 m_cardViewButton->addTo( listTools ); 115 m_cardViewButton->addTo( listTools );
116 116
117 listTools->addSeparator(); 117 listTools->addSeparator();
118 118
119 // Other Buttons 119 // Other Buttons
120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
121 0, this, 0 ); 121 0, this, 0 );
122 actionNew = a; 122 actionNew = a;
123 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 123 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
124 a->addTo( edit ); 124 a->addTo( edit );
125 a->addTo( listTools ); 125 a->addTo( listTools );
126 126
127 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 127 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
128 0, this, 0 ); 128 0, this, 0 );
129 actionEdit = a; 129 actionEdit = a;
130 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 130 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
131 a->addTo( edit ); 131 a->addTo( edit );
132 a->addTo( listTools ); 132 a->addTo( listTools );
133 133
134 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 134 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
135 0, this, 0 ); 135 0, this, 0 );
136 actionTrash = a; 136 actionTrash = a;
137 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 137 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
138 a->addTo( edit ); 138 a->addTo( edit );
139 a->addTo( listTools ); 139 a->addTo( listTools );
140 140
141 141
142 // make it possible to go directly to businesscard via qcop call 142 // make it possible to go directly to businesscard via qcop call
143#if defined(Q_WS_QWS) 143#if defined(Q_WS_QWS)
144#if !defined(QT_NO_COP) 144#if !defined(QT_NO_COP)
145 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 145 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
146 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 146 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
147 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 147 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
148#endif 148#endif
149#endif 149#endif
150 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 150 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
151 QString::null, 0, this, 0 ); 151 QString::null, 0, this, 0 );
152 actionFind = a; 152 actionFind = a;
153 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 153 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
154 a->addTo( edit ); 154 a->addTo( edit );
155 a->addTo( listTools ); 155 a->addTo( listTools );
156 156
157 // Much better search widget, taken from QTReader.. (se) 157 // Much better search widget, taken from QTReader.. (se)
158 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 158 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
159 searchBar->setHorizontalStretchable( TRUE ); 159 searchBar->setHorizontalStretchable( TRUE );
160 searchBar->hide(); 160 searchBar->hide();
161 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 161 searchEdit = new QLineEdit( searchBar, "searchEdit" );
162 162
163 // QFont f("unifont", 16 /*, QFont::Bold*/); 163 // QFont f("unifont", 16 /*, QFont::Bold*/);
164 // searchEdit->setFont( f ); 164 // searchEdit->setFont( f );
165 165
166 searchBar->setStretchableWidget( searchEdit ); 166 searchBar->setStretchableWidget( searchEdit );
167 connect( searchEdit, SIGNAL( returnPressed( ) ), 167 connect( searchEdit, SIGNAL( returnPressed( ) ),
168 this, SLOT( slotFind( ) ) ); 168 this, SLOT( slotFind( ) ) );
169 169
170 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 170 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
171 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 171 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
172 a->addTo( searchBar ); 172 a->addTo( searchBar );
173 173
174 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
175 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 175 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
176 a->addTo( searchBar ); 176 a->addTo( searchBar );
177 177
178 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), 178 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ),
179 QString::null, 0, this, 0 ); 179 QString::null, 0, this, 0 );
180 //a->setEnabled( FALSE ); we got support for it now :) zecke 180 //a->setEnabled( FALSE ); we got support for it now :) zecke
181 actionMail = a; 181 actionMail = a;
182 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 182 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
183 a->addTo( edit ); 183 a->addTo( edit );
184 a->addTo( listTools ); 184 a->addTo( listTools );
185 185
186 if ( Ir::supported() ) { 186 if ( Ir::supported() ) {
187 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 187 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
188 0, this, 0 ); 188 0, this, 0 );
189 actionBeam = a; 189 actionBeam = a;
190 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
191 a->addTo( edit ); 191 a->addTo( edit );
192 a->addTo( listTools ); 192 a->addTo( listTools );
193 } 193 }
194 194
195 edit->insertSeparator(); 195 edit->insertSeparator();
196 196
197 a = new QAction( tr("Import vCard"), QString::null, 0, 0); 197 a = new QAction( tr("Import vCard"), QString::null, 0, 0);
198 actionPersonal = a; 198 actionPersonal = a;
199 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
200 a->addTo( edit ); 200 a->addTo( edit );
201 201
202 edit->insertSeparator(); 202 edit->insertSeparator();
203 203
204 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 204 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
205 actionPersonal = a; 205 actionPersonal = a;
206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
207 a->addTo( edit ); 207 a->addTo( edit );
208 208
209 209
210#ifdef __DEBUG_RELEASE 210#ifdef __DEBUG_RELEASE
211 // Remove this function for public Release ! This is only 211 // Remove this function for public Release ! This is only
212 // for debug purposes .. 212 // for debug purposes ..
213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
215 a->addTo( edit ); 215 a->addTo( edit );
216#endif 216#endif
217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null,
218 0, this, 0 ); 218 0, this, 0 );
219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
220 a->addTo( edit ); 220 a->addTo( edit );
221 221
222 // Create Views 222 // Create Views
223 listContainer = new QWidget( this ); 223 listContainer = new QWidget( this );
224 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
225 225
226 m_abView = new AbView( listContainer, m_config.orderList() ); 226 m_abView = new AbView( listContainer, m_config.orderList() );
227 vb->addWidget( m_abView ); 227 vb->addWidget( m_abView );
228 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 228 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
230 this, SLOT( slotViewSwitched( int ) ) ); 230 this, SLOT( slotViewSwitched( int ) ) );
231 231
232 232
233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
234 234
235 m_abView->load(); 235 m_abView->load();
236 236
237 // Letter Picker 237 // Letter Picker
238 pLabel = new LetterPicker( listContainer ); 238 pLabel = new LetterPicker( listContainer );
239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
241 241
242 vb->addWidget( pLabel ); 242 vb->addWidget( pLabel );
243 243
244 // Category Menu 244 // Category Menu
245 catMenu = new QPopupMenu( this ); 245 catMenu = new QPopupMenu( this );
246 catMenu->setCheckable( TRUE ); 246 catMenu->setCheckable( TRUE );
247 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 247 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
248 populateCategories(); 248 populateCategories();
249 mbList->insertItem( tr("View"), catMenu ); 249 mbList->insertItem( tr("View"), catMenu );
250 250
251 defaultFont = new QFont( m_abView->font() ); 251 defaultFont = new QFont( m_abView->font() );
252 slotSetFont(m_config.fontSize()); 252 slotSetFont(m_config.fontSize());
253 m_curFontSize = m_config.fontSize(); 253 m_curFontSize = m_config.fontSize();
254 254
255 setCentralWidget(listContainer); 255 setCentralWidget(listContainer);
256 256
257 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 257 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
258 258
259 259
260 isLoading = false; 260 isLoading = false;
261} 261}
262 262
263 263
264void AddressbookWindow::slotConfig() 264void AddressbookWindow::slotConfig()
265{ 265{
266 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 266 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
267 dlg -> setConfig( m_config ); 267 dlg -> setConfig( m_config );
268 dlg -> showMaximized(); 268 dlg -> showMaximized();
269 if ( dlg -> exec() ) { 269 if ( dlg -> exec() ) {
270 qWarning ("Config Dialog accepted !"); 270 qWarning ("Config Dialog accepted !");
271 m_config = dlg -> getConfig(); 271 m_config = dlg -> getConfig();
272 if ( m_curFontSize != m_config.fontSize() ){ 272 if ( m_curFontSize != m_config.fontSize() ){
273 qWarning("Font was changed!"); 273 qWarning("Font was changed!");
274 m_curFontSize = m_config.fontSize(); 274 m_curFontSize = m_config.fontSize();
275 emit slotSetFont( m_curFontSize ); 275 emit slotSetFont( m_curFontSize );
276 } 276 }
277 m_abView -> setListOrder( m_config.orderList() ); 277 m_abView -> setListOrder( m_config.orderList() );
278 } 278 }
279 279
280 delete dlg; 280 delete dlg;
281} 281}
282 282
283 283
284void AddressbookWindow::slotSetFont( int size ) 284void AddressbookWindow::slotSetFont( int size )
285{ 285{
286 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
287 287
288 if (size > 2 || size < 0) 288 if (size > 2 || size < 0)
289 size = 1; 289 size = 1;
290 290
291 m_config.setFontSize( size ); 291 m_config.setFontSize( size );
292 292
293 QFont *currentFont; 293 QFont *currentFont;
294 294
295 switch (size) { 295 switch (size) {
296 case 0: 296 case 0:
297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
298 currentFont = new QFont (m_abView->font()); 298 currentFont = new QFont (m_abView->font());
299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
300 // abList->resizeRows(); 300 // abList->resizeRows();
301 break; 301 break;
302 case 1: 302 case 1:
303 m_abView->setFont( *defaultFont ); 303 m_abView->setFont( *defaultFont );
304 currentFont = new QFont (m_abView->font()); 304 currentFont = new QFont (m_abView->font());
305 // // abList->resizeRows(currentFont->pixelSize() + 7); 305 // // abList->resizeRows(currentFont->pixelSize() + 7);
306 // abList->resizeRows(); 306 // abList->resizeRows();
307 break; 307 break;
308 case 2: 308 case 2:
309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
310 currentFont = new QFont (m_abView->font()); 310 currentFont = new QFont (m_abView->font());
311 // //abList->resizeRows(currentFont->pixelSize() + 7); 311 // //abList->resizeRows(currentFont->pixelSize() + 7);
312 // abList->resizeRows(); 312 // abList->resizeRows();
313 break; 313 break;
314 } 314 }
315} 315}
316 316
317 317
318 318
319void AddressbookWindow::importvCard() { 319void AddressbookWindow::importvCard() {
320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
321 if(!str.isEmpty() ){ 321 if(!str.isEmpty() ){
322 setDocument((const QString&) str ); 322 setDocument((const QString&) str );
323 } 323 }
324 324
325} 325}
326 326
327void AddressbookWindow::setDocument( const QString &filename ) 327void AddressbookWindow::setDocument( const QString &filename )
328{ 328{
329 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 329 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
330 330
331 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 331 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
332 332
333 333
334 334
335 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 335 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
336 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 336 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
337 tr( "&Yes" ), tr( "&No" ), QString::null, 337 tr( "&Yes" ), tr( "&No" ), QString::null,
338 0, // Enter == button 0 338 0, // Enter == button 0
339 2 ) ) { // Escape == button 2 339 2 ) ) { // Escape == button 2
340 case 0: 340 case 0:
341 qWarning("YES clicked"); 341 qWarning("YES clicked");
342 break; 342 break;
343 case 1: 343 case 1:
344 qWarning("NO clicked"); 344 qWarning("NO clicked");
345 return; 345 return;
346 break; 346 break;
347 } 347 }
348 } 348 }
349 349
350 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 350 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
351 filename ); 351 filename );
352 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 352 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
353 OContactAccess::List allList = access->allRecords(); 353 OContactAccess::List allList = access->allRecords();
354 354
355 OContactAccess::List::Iterator it; 355 OContactAccess::List::Iterator it;
356 for ( it = allList.begin(); it != allList.end(); ++it ){ 356 for ( it = allList.begin(); it != allList.end(); ++it ){
357 m_abView->addEntry( *it ); 357 m_abView->addEntry( *it );
358 } 358 }
359 359
360 delete access; 360 delete access;
361} 361}
362 362
363void AddressbookWindow::resizeEvent( QResizeEvent *e ) 363void AddressbookWindow::resizeEvent( QResizeEvent *e )
364{ 364{
365 QMainWindow::resizeEvent( e ); 365 QMainWindow::resizeEvent( e );
366 366
367 367
368} 368}
369 369
370AddressbookWindow::~AddressbookWindow() 370AddressbookWindow::~AddressbookWindow()
371{ 371{
372 ToolBarDock dock; 372 ToolBarDock dock;
373 int dummy; 373 int dummy;
374 bool bDummy; 374 bool bDummy;
375 getLocation ( listTools, dock, dummy, bDummy, dummy ); 375 getLocation ( listTools, dock, dummy, bDummy, dummy );
376 m_config.setToolBarDock( dock ); 376 m_config.setToolBarDock( dock );
377 m_config.save(); 377 m_config.save();
378} 378}
379 379
380void AddressbookWindow::slotUpdateToolbar() 380void AddressbookWindow::slotUpdateToolbar()
381{ 381{
382 OContact ce = m_abView->currentEntry(); 382 OContact ce = m_abView->currentEntry();
383 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 383 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
384} 384}
385 385
386void AddressbookWindow::slotListNew() 386void AddressbookWindow::slotListNew()
387{ 387{
388 OContact cnt; 388 OContact cnt;
389 if( !syncing ) { 389 if( !syncing ) {
390 editEntry( NewEntry ); 390 editEntry( NewEntry );
391 } else { 391 } else {
392 QMessageBox::warning(this, tr("OContacts"), 392 QMessageBox::warning(this, tr("OContacts"),
393 tr("Can not edit data, currently syncing")); 393 tr("Can not edit data, currently syncing"));
394 } 394 }
395} 395}
396 396
397// void AddressbookWindow::slotListView() 397// void AddressbookWindow::slotListView()
398// { 398// {
399 // m_abView -> init( abList->currentEntry() ); 399 // m_abView -> init( abList->currentEntry() );
400 // // :SX mView->sync(); 400 // // :SX mView->sync();
401 // //:SXshowView(); 401 // //:SXshowView();
402// } 402// }
403 403
404void AddressbookWindow::slotListDelete() 404void AddressbookWindow::slotListDelete()
405{ 405{
406 if(!syncing) { 406 if(!syncing) {
407 OContact tmpEntry = m_abView ->currentEntry(); 407 OContact tmpEntry = m_abView ->currentEntry();
408 408
409 // get a name, do the best we can... 409 // get a name, do the best we can...
410 QString strName = tmpEntry.fullName(); 410 QString strName = tmpEntry.fullName();
411 if ( strName.isEmpty() ) { 411 if ( strName.isEmpty() ) {
412 strName = tmpEntry.company(); 412 strName = tmpEntry.company();
413 if ( strName.isEmpty() ) 413 if ( strName.isEmpty() )
414 strName = "No Name"; 414 strName = "No Name";
415 } 415 }
416 416
417 417
418 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 418 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
419 strName ) ) { 419 strName ) ) {
420 m_abView->removeEntry( tmpEntry.uid() ); 420 m_abView->removeEntry( tmpEntry.uid() );
421 } 421 }
422 } else { 422 } else {
423 QMessageBox::warning( this, tr("Contacts"), 423 QMessageBox::warning( this, tr("Contacts"),
424 tr("Can not edit data, currently syncing") ); 424 tr("Can not edit data, currently syncing") );
425 } 425 }
426} 426}
427 427
428void AddressbookWindow::slotFindOpen() 428void AddressbookWindow::slotFindOpen()
429{ 429{
430 searchBar->show(); 430 searchBar->show();
431 m_abView -> inSearch(); 431 m_abView -> inSearch();
432 searchEdit->setFocus(); 432 searchEdit->setFocus();
433} 433}
434void AddressbookWindow::slotFindClose() 434void AddressbookWindow::slotFindClose()
435{ 435{
436 searchBar->hide(); 436 searchBar->hide();
437 m_abView -> offSearch(); 437 m_abView -> offSearch();
438 // m_abView->setFocus(); 438 // m_abView->setFocus();
439} 439}
440 440
441 441
442void AddressbookWindow::slotFind() 442void AddressbookWindow::slotFind()
443{ 443{
444 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 444 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
445 445
446 searchEdit->clearFocus(); 446 searchEdit->clearFocus();
447 // m_abView->setFocus(); 447 // m_abView->setFocus();
448 448
449} 449}
450 450
451void AddressbookWindow::slotViewBack() 451void AddressbookWindow::slotViewBack()
452{ 452{
453 // :SX showList(); 453 // :SX showList();
454} 454}
455 455
456void AddressbookWindow::slotViewEdit() 456void AddressbookWindow::slotViewEdit()
457{ 457{
458 if(!syncing) { 458 if(!syncing) {
459 if (actionPersonal->isOn()) { 459 if (actionPersonal->isOn()) {
460 editPersonal(); 460 editPersonal();
461 } else { 461 } else {
462 editEntry( EditEntry ); 462 editEntry( EditEntry );
463 } 463 }
464 } else { 464 } else {
465 QMessageBox::warning( this, tr("Contacts"), 465 QMessageBox::warning( this, tr("Contacts"),
466 tr("Can not edit data, currently syncing") ); 466 tr("Can not edit data, currently syncing") );
467 } 467 }
468} 468}
469 469
470 470
471 471
472void AddressbookWindow::writeMail() 472void AddressbookWindow::writeMail()
473{ 473{
474 OContact c = m_abView -> currentEntry(); 474 OContact c = m_abView -> currentEntry();
475 QString name = c.fileAs(); 475 QString name = c.fileAs();
476 QString email = c.defaultEmail(); 476 QString email = c.defaultEmail();
477 477
478 // I prefer the OPIE-Environment variable before the 478 // I prefer the OPIE-Environment variable before the
479 // QPE-one.. 479 // QPE-one..
480 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 480 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
481 if ( basepath.isEmpty() ) 481 if ( basepath.isEmpty() )
482 basepath = QString::fromLatin1( getenv("QPEDIR") ); 482 basepath = QString::fromLatin1( getenv("QPEDIR") );
483 483
484 // Try to access the preferred. If not possible, try to 484 // Try to access the preferred. If not possible, try to
485 // switch to the other one.. 485 // switch to the other one..
486 if ( m_config.useQtMail() ){ 486 if ( m_config.useQtMail() ){
487 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 487 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
488 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 488 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
489 qWarning ("QCop"); 489 qWarning ("QCop");
490 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 490 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
491 e << name << email; 491 e << name << email;
492 return; 492 return;
493 } else 493 } else
494 m_config.setUseOpieMail( true ); 494 m_config.setUseOpieMail( true );
495 } 495 }
496 if ( m_config.useOpieMail() ){ 496 if ( m_config.useOpieMail() ){
497 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 497 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
498 if ( QFile::exists( basepath + "/bin/mail" ) ){ 498 if ( QFile::exists( basepath + "/bin/mail" ) ){
499 qWarning ("QCop"); 499 qWarning ("QCop");
500 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 500 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
501 e << name << email; 501 e << name << email;
502 return; 502 return;
503 } else 503 } else
504 m_config.setUseQtMail( true ); 504 m_config.setUseQtMail( true );
505 } 505 }
506 506
507} 507}
508 508
509static const char * beamfile = "/tmp/obex/contact.vcf"; 509static const char * beamfile = "/tmp/obex/contact.vcf";
510 510
511void AddressbookWindow::slotBeam() 511void AddressbookWindow::slotBeam()
512{ 512{
513 QString filename; 513 QString filename;
514 OContact c; 514 OContact c;
515 if ( actionPersonal->isOn() ) { 515 if ( actionPersonal->isOn() ) {
516 filename = addressbookPersonalVCardName(); 516 filename = addressbookPersonalVCardName();
517 if (!QFile::exists(filename)) 517 if (!QFile::exists(filename))
518 return; // can't beam a non-existent file 518 return; // can't beam a non-existent file
519 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 519 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
520 filename ); 520 filename );
521 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 521 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
522 OContactAccess::List allList = access->allRecords(); 522 OContactAccess::List allList = access->allRecords();
523 OContactAccess::List::Iterator it = allList.begin(); // Just take first 523 OContactAccess::List::Iterator it = allList.begin(); // Just take first
524 c = *it; 524 c = *it;
525 525
526 delete access; 526 delete access;
527 } else { 527 } else {
528 unlink( beamfile ); // delete if exists 528 unlink( beamfile ); // delete if exists
529 mkdir("/tmp/obex/", 0755); 529 mkdir("/tmp/obex/", 0755);
530 c = m_abView -> currentEntry(); 530 c = m_abView -> currentEntry();
531 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 531 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
532 beamfile ); 532 beamfile );
533 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 533 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
534 access->add( c ); 534 access->add( c );
535 access->save(); 535 access->save();
536 delete access; 536 delete access;
537 537
538 filename = beamfile; 538 filename = beamfile;
539 } 539 }
540 540
541 541
542 Ir *ir = new Ir( this ); 542 Ir *ir = new Ir( this );
543 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 543 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
544 QString description = c.fullName(); 544 QString description = c.fullName();
545 ir->send( filename, description, "text/x-vCard" ); 545 ir->send( filename, description, "text/x-vCard" );
546} 546}
547 547
548void AddressbookWindow::beamDone( Ir *ir ) 548void AddressbookWindow::beamDone( Ir *ir )
549{ 549{
550 delete ir; 550 delete ir;
551 unlink( beamfile ); 551 unlink( beamfile );
552} 552}
553 553
554 554
555static void parseName( const QString& name, QString *first, QString *middle, 555static void parseName( const QString& name, QString *first, QString *middle,
556 QString * last ) 556 QString * last )
557{ 557{
558 558
559 int comma = name.find ( "," ); 559 int comma = name.find ( "," );
560 QString rest; 560 QString rest;
561 if ( comma > 0 ) { 561 if ( comma > 0 ) {
562 *last = name.left( comma ); 562 *last = name.left( comma );
563 comma++; 563 comma++;
564 while ( comma < int(name.length()) && name[comma] == ' ' ) 564 while ( comma < int(name.length()) && name[comma] == ' ' )
565 comma++; 565 comma++;
566 rest = name.mid( comma ); 566 rest = name.mid( comma );
567 } else { 567 } else {
568 int space = name.findRev( ' ' ); 568 int space = name.findRev( ' ' );
569 *last = name.mid( space+1 ); 569 *last = name.mid( space+1 );
570 rest = name.left( space ); 570 rest = name.left( space );
571 } 571 }
572 int space = rest.find( ' ' ); 572 int space = rest.find( ' ' );
573 if ( space <= 0 ) { 573 if ( space <= 0 ) {
574 *first = rest; 574 *first = rest;
575 } else { 575 } else {
576 *first = rest.left( space ); 576 *first = rest.left( space );
577 *middle = rest.mid( space+1 ); 577 *middle = rest.mid( space+1 );
578 } 578 }
579 579
580} 580}
581 581
582 582
583void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 583void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
584{ 584{
585 if (msg == "editPersonal()") { 585 if (msg == "editPersonal()") {
586 editPersonal(); 586 editPersonal();
587 } else if (msg == "editPersonalAndClose()") { 587 } else if (msg == "editPersonalAndClose()") {
588 editPersonal(); 588 editPersonal();
589 close(); 589 close();
590 } else if ( msg == "addContact(QString,QString)" ) { 590 } else if ( msg == "addContact(QString,QString)" ) {
591 QDataStream stream(data,IO_ReadOnly); 591 QDataStream stream(data,IO_ReadOnly);
592 QString name, email; 592 QString name, email;
593 stream >> name >> email; 593 stream >> name >> email;
594 594
595 OContact cnt; 595 OContact cnt;
596 QString fn, mn, ln; 596 QString fn, mn, ln;
597 parseName( name, &fn, &mn, &ln ); 597 parseName( name, &fn, &mn, &ln );
598 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 598 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
599 cnt.setFirstName( fn ); 599 cnt.setFirstName( fn );
600 cnt.setMiddleName( mn ); 600 cnt.setMiddleName( mn );
601 cnt.setLastName( ln ); 601 cnt.setLastName( ln );
602 cnt.insertEmails( email ); 602 cnt.insertEmails( email );
603 cnt.setDefaultEmail( email ); 603 cnt.setDefaultEmail( email );
604 cnt.setFileAs(); 604 cnt.setFileAs();
605 605
606 m_abView -> addEntry( cnt ); 606 m_abView -> addEntry( cnt );
607 607
608 // :SXm_abView()->init( cnt ); 608 // :SXm_abView()->init( cnt );
609 editEntry( EditEntry ); 609 editEntry( EditEntry );
610 610
611 611
612 612
613 } 613 }
614#if 0 614#if 0
615 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 615 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
616 QDataStream stream(data,IO_ReadOnly); 616 QDataStream stream(data,IO_ReadOnly);
617 QCString ch,m; 617 QCString ch,m;
618 QStringList types; 618 QStringList types;
619 stream >> ch >> m >> types; 619 stream >> ch >> m >> types;
620 AddressPicker picker(abList,this,0,TRUE); 620 AddressPicker picker(abList,this,0,TRUE);
621 picker.showMaximized(); 621 picker.showMaximized();
622 picker.setChoiceNames(types); 622 picker.setChoiceNames(types);
623 int i=0; 623 int i=0;
624 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 624 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
625 QStringList sel; 625 QStringList sel;
626 stream >> sel; 626 stream >> sel;
627 picker.setSelection(i++,sel); 627 picker.setSelection(i++,sel);
628 } 628 }
629 picker.showMaximized(); 629 picker.showMaximized();
630 picker.exec(); 630 picker.exec();
631 631
632 // ###### note: contacts may have been added - save here! 632 // ###### note: contacts may have been added - save here!
633 633
634 setCentralWidget(abList); 634 setCentralWidget(abList);
635 QCopEnvelope e(ch,m); 635 QCopEnvelope e(ch,m);
636 i=0; 636 i=0;
637 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 637 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
638 QStringList sel = picker.selection(i++); 638 QStringList sel = picker.selection(i++);
639 e << sel; 639 e << sel;
640 } 640 }
641 } 641 }
642#endif 642#endif
643 643
644} 644}
645 645
646void AddressbookWindow::editEntry( EntryMode entryMode ) 646void AddressbookWindow::editEntry( EntryMode entryMode )
647{ 647{
648 OContact entry; 648 OContact entry;
649 if ( !abEditor ) { 649 if ( !abEditor ) {
650 abEditor = new ContactEditor( entry, this, "editor" ); 650 abEditor = new ContactEditor( entry, this, "editor" );
651 } 651 }
652 if ( entryMode == EditEntry ) 652 if ( entryMode == EditEntry )
653 abEditor->setEntry( m_abView -> currentEntry() ); 653 abEditor->setEntry( m_abView -> currentEntry() );
654 else if ( entryMode == NewEntry ) 654 else if ( entryMode == NewEntry )
655 abEditor->setEntry( entry ); 655 abEditor->setEntry( entry );
656 // other things may change the caption. 656 // other things may change the caption.
657 abEditor->setCaption( tr("Edit Address") ); 657 abEditor->setCaption( tr("Edit Address") );
658 658
659#if defined(Q_WS_QWS) || defined(_WS_QWS_) 659#if defined(Q_WS_QWS) || defined(_WS_QWS_)
660 abEditor->showMaximized(); 660 abEditor->showMaximized();
661#endif 661#endif
662 // fix the foxus... 662 // fix the foxus...
663 abEditor->setNameFocus(); 663 abEditor->setNameFocus();
664 if ( abEditor->exec() ) { 664 if ( abEditor->exec() ) {
665 setFocus(); 665 setFocus();
666 if ( entryMode == NewEntry ) { 666 if ( entryMode == NewEntry ) {
667 OContact insertEntry = abEditor->entry(); 667 OContact insertEntry = abEditor->entry();
668 insertEntry.assignUid(); 668 insertEntry.assignUid();
669 m_abView -> addEntry( insertEntry ); 669 m_abView -> addEntry( insertEntry );
670 } else { 670 } else {
671 OContact replEntry = abEditor->entry(); 671 OContact replEntry = abEditor->entry();
672 672
673 if ( !replEntry.isValidUid() ) 673 if ( !replEntry.isValidUid() )
674 replEntry.assignUid(); 674 replEntry.assignUid();
675 675
676 m_abView -> replaceEntry( replEntry ); 676 m_abView -> replaceEntry( replEntry );
677 } 677 }
678 } 678 }
679 // populateCategories(); 679 // populateCategories();
680 680
681} 681}
682 682
683void AddressbookWindow::editPersonal() 683void AddressbookWindow::editPersonal()
684{ 684{
685 OContact entry; 685 OContact entry;
686 if ( !abEditor ) { 686 if ( !abEditor ) {
687 abEditor = new ContactEditor( entry, this, "editor" ); 687 abEditor = new ContactEditor( entry, this, "editor" );
688 } 688 }
689 689
690 abEditor->setCaption(tr("Edit My Personal Details")); 690 abEditor->setCaption(tr("Edit My Personal Details"));
691 abEditor->setPersonalView( true ); 691 abEditor->setPersonalView( true );
692 editEntry( EditEntry ); 692 editEntry( EditEntry );
693 abEditor->setPersonalView( false ); 693 abEditor->setPersonalView( false );
694 694
695} 695}
696 696
697 697
698void AddressbookWindow::slotPersonalView() 698void AddressbookWindow::slotPersonalView()
699{ 699{
700 if (!actionPersonal->isOn()) { 700 if (!actionPersonal->isOn()) {
701 // we just turned it off 701 // we just turned it off
702 setCaption( tr("Contacts") ); 702 setCaption( tr("Contacts") );
703 actionNew->setEnabled(TRUE); 703 actionNew->setEnabled(TRUE);
704 actionTrash->setEnabled(TRUE); 704 actionTrash->setEnabled(TRUE);
705 actionFind->setEnabled(TRUE); 705 actionFind->setEnabled(TRUE);
706 actionMail->setEnabled(TRUE); 706 actionMail->setEnabled(TRUE);
707 // slotUpdateToolbar(); 707 // slotUpdateToolbar();
708 708
709 m_abView->showPersonal( false ); 709 m_abView->showPersonal( false );
710 710
711 return; 711 return;
712 } 712 }
713 713
714 // XXX need to disable some QActions. 714 // XXX need to disable some QActions.
715 actionNew->setEnabled(FALSE); 715 actionNew->setEnabled(FALSE);
716 actionTrash->setEnabled(FALSE); 716 actionTrash->setEnabled(FALSE);
717 actionFind->setEnabled(FALSE); 717 actionFind->setEnabled(FALSE);
718 actionMail->setEnabled(FALSE); 718 actionMail->setEnabled(FALSE);
719 719
720 setCaption( tr("Contacts - My Personal Details") ); 720 setCaption( tr("Contacts - My Personal Details") );
721 721
722 m_abView->showPersonal( true ); 722 m_abView->showPersonal( true );
723 723
724} 724}
725 725
726 726
727void AddressbookWindow::listIsEmpty( bool empty ) 727void AddressbookWindow::listIsEmpty( bool empty )
728{ 728{
729 if ( !empty ) { 729 if ( !empty ) {
730 deleteButton->setEnabled( TRUE ); 730 deleteButton->setEnabled( TRUE );
731 } 731 }
732} 732}
733 733
734void AddressbookWindow::reload() 734void AddressbookWindow::reload()
735{ 735{
736 syncing = FALSE; 736 syncing = FALSE;
737 m_abView->clear(); 737 m_abView->clear();
738 m_abView->reload(); 738 m_abView->reload();
739} 739}
740 740
741void AddressbookWindow::flush() 741void AddressbookWindow::flush()
742{ 742{
743 syncing = TRUE; 743 syncing = TRUE;
744 m_abView->save(); 744 m_abView->save();
745} 745}
746 746
747 747
748void AddressbookWindow::closeEvent( QCloseEvent *e ) 748void AddressbookWindow::closeEvent( QCloseEvent *e )
749{ 749{
750 750 if(active_view == AbView::CardView){
751 slotViewSwitched( AbView::TableView );
752 e->ignore();
753 return;
754 }
751 if(syncing) { 755 if(syncing) {
752 /* shouldn't we save, I hear you say? well its already been set 756 /* shouldn't we save, I hear you say? well its already been set
753 so that an edit can not occur during a sync, and we flushed 757 so that an edit can not occur during a sync, and we flushed
754 at the start of the sync, so there is no need to save 758 at the start of the sync, so there is no need to save
755 Saving however itself would cause problems. */ 759 Saving however itself would cause problems. */
756 e->accept(); 760 e->accept();
757 return; 761 return;
758 } 762 }
759 //################## shouldn't always save 763 //################## shouldn't always save
760 // True, but the database handles this automatically ! (se) 764 // True, but the database handles this automatically ! (se)
761 if ( save() ) 765 if ( save() )
762 e->accept(); 766 e->accept();
763 else 767 else
764 e->ignore(); 768 e->ignore();
765} 769}
766 770
767/* 771/*
768 Returns TRUE if it is OK to exit 772 Returns TRUE if it is OK to exit
769*/ 773*/
770 774
771bool AddressbookWindow::save() 775bool AddressbookWindow::save()
772{ 776{
773 if ( !m_abView->save() ) { 777 if ( !m_abView->save() ) {
774 if ( QMessageBox::critical( 0, tr( "Out of space" ), 778 if ( QMessageBox::critical( 0, tr( "Out of space" ),
775 tr("Unable to save information.\n" 779 tr("Unable to save information.\n"
776 "Free up some space\n" 780 "Free up some space\n"
777 "and try again.\n" 781 "and try again.\n"
778 "\nQuit anyway?"), 782 "\nQuit anyway?"),
779 QMessageBox::Yes|QMessageBox::Escape, 783 QMessageBox::Yes|QMessageBox::Escape,
780 QMessageBox::No|QMessageBox::Default ) 784 QMessageBox::No|QMessageBox::Default )
781 != QMessageBox::No ) 785 != QMessageBox::No )
782 return TRUE; 786 return TRUE;
783 else 787 else
784 return FALSE; 788 return FALSE;
785 } 789 }
786 return TRUE; 790 return TRUE;
787} 791}
788 792
789#ifdef __DEBUG_RELEASE 793#ifdef __DEBUG_RELEASE
790void AddressbookWindow::slotSave() 794void AddressbookWindow::slotSave()
791{ 795{
792 save(); 796 save();
793} 797}
794#endif 798#endif
795 799
796 800
797void AddressbookWindow::slotNotFound() 801void AddressbookWindow::slotNotFound()
798{ 802{
799 qWarning("Got notfound signal !"); 803 qWarning("Got notfound signal !");
800 QMessageBox::information( this, tr( "Not Found" ), 804 QMessageBox::information( this, tr( "Not Found" ),
801 tr( "Unable to find a contact for this \n search pattern!" ) ); 805 tr( "Unable to find a contact for this \n search pattern!" ) );
802 806
803 807
804} 808}
805void AddressbookWindow::slotWrapAround() 809void AddressbookWindow::slotWrapAround()
806{ 810{
807 qWarning("Got wrap signal !"); 811 qWarning("Got wrap signal !");
808 // if ( doNotifyWrapAround ) 812 // if ( doNotifyWrapAround )
809 // QMessageBox::information( this, tr( "End of list" ), 813 // QMessageBox::information( this, tr( "End of list" ),
810 // tr( "End of list. Wrap around now...!" ) + "\n" ); 814 // tr( "End of list. Wrap around now...!" ) + "\n" );
811 815
812} 816}
813 817
814void AddressbookWindow::slotSetCategory( int c ) 818void AddressbookWindow::slotSetCategory( int c )
815{ 819{
816 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); 820 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
817 821
818 QString cat, book; 822 QString cat, book;
819 AbView::Views view = AbView::TableView; 823 AbView::Views view = AbView::TableView;
820 824
821 if ( c <= 0 ) 825 if ( c <= 0 )
822 return; 826 return;
823 827
824 // Switch view 828 // Switch view
825 if ( c < 3 ) 829 if ( c < 3 )
826 for ( unsigned int i = 1; i < 3; i++ ){ 830 for ( unsigned int i = 1; i < 3; i++ ){
827 if ( catMenu ) 831 if ( catMenu )
828 catMenu->setItemChecked( i, c == (int)i ); 832 catMenu->setItemChecked( i, c == (int)i );
829 } 833 }
830 else 834 else
831 // Checkmark Category Menu Item Selected 835 // Checkmark Category Menu Item Selected
832 for ( unsigned int i = 3; i < catMenu->count(); i++ ) 836 for ( unsigned int i = 3; i < catMenu->count(); i++ )
833 catMenu->setItemChecked( i, c == (int)i ); 837 catMenu->setItemChecked( i, c == (int)i );
834 838
835 // Now switch to the selected category 839 // Now switch to the selected category
836 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 840 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
837 if (catMenu->isItemChecked( i )) { 841 if (catMenu->isItemChecked( i )) {
838 if ( i == 1 ){ // default List view 842 if ( i == 1 ){ // default List view
839 book = QString::null; 843 book = QString::null;
840 view = AbView::TableView; 844 view = AbView::TableView;
841 }else if ( i == 2 ){ 845 }else if ( i == 2 ){
842 book = tr( "Cards" ); 846 book = tr( "Cards" );
843 view = AbView::CardView; 847 view = AbView::CardView;
844 // }else if ( i == 3 ){ 848 // }else if ( i == 3 ){
845 // book = tr( "Personal" ); 849 // book = tr( "Personal" );
846 // view = AbView:: PersonalView; 850 // view = AbView:: PersonalView;
847 }else if ( i == 3 ){ // default All Categories 851 }else if ( i == 3 ){ // default All Categories
848 cat = QString::null; 852 cat = QString::null;
849 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled 853 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
850 cat = "Unfiled"; 854 cat = "Unfiled";
851 qWarning ("Unfiled selected!!!"); 855 qWarning ("Unfiled selected!!!");
852 }else{ 856 }else{
853 cat = m_abView->categories()[i - 4]; 857 cat = m_abView->categories()[i - 4];
854 } 858 }
855 } 859 }
856 } 860 }
857 861
858 // Switch to the selected View 862 // Switch to the selected View
859 slotViewSwitched( view ); 863 slotViewSwitched( view );
860 864
861 // Tell the view about the selected category 865 // Tell the view about the selected category
862 m_abView -> setShowByCategory( cat ); 866 m_abView -> setShowByCategory( cat );
863 867
864 if ( book.isEmpty() ) 868 if ( book.isEmpty() )
865 book = "List"; 869 book = "List";
866 if ( cat.isEmpty() ) 870 if ( cat.isEmpty() )
867 cat = "All"; 871 cat = "All";
868 872
869 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); 873 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
870} 874}
871 875
872void AddressbookWindow::slotViewSwitched( int view ) 876void AddressbookWindow::slotViewSwitched( int view )
873{ 877{
874 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); 878 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
875 int menu = 0; 879 int menu = 0;
876 880
877 // Switch to selected view 881 // Switch to selected view
878 switch ( view ){ 882 switch ( view ){
879 case AbView::TableView: 883 case AbView::TableView:
880 menu = 1; 884 menu = 1;
881 m_tableViewButton->setOn(true); 885 m_tableViewButton->setOn(true);
882 m_cardViewButton->setOn(false); 886 m_cardViewButton->setOn(false);
883 break; 887 break;
884 case AbView::CardView: 888 case AbView::CardView:
885 menu = 2; 889 menu = 2;
886 m_tableViewButton->setOn(false); 890 m_tableViewButton->setOn(false);
887 m_cardViewButton->setOn(true); 891 m_cardViewButton->setOn(true);
888 break; 892 break;
889 } 893 }
890 for ( unsigned int i = 1; i < 3; i++ ){ 894 for ( unsigned int i = 1; i < 3; i++ ){
891 if ( catMenu ) 895 if ( catMenu )
892 catMenu->setItemChecked( i, menu == (int)i ); 896 catMenu->setItemChecked( i, menu == (int)i );
893 } 897 }
894 898
895 // Tell the view about the selected view 899 // Tell the view about the selected view
896 m_abView -> setShowToView ( (AbView::Views) view ); 900 m_abView -> setShowToView ( (AbView::Views) view );
897 901 active_view = view;
898} 902}
899 903
900 904
901void AddressbookWindow::slotListView() 905void AddressbookWindow::slotListView()
902{ 906{
903 slotViewSwitched( AbView::TableView ); 907 slotViewSwitched( AbView::TableView );
904} 908}
905 909
906void AddressbookWindow::slotCardView() 910void AddressbookWindow::slotCardView()
907{ 911{
908 slotViewSwitched( AbView::CardView ); 912 slotViewSwitched( AbView::CardView );
909} 913}
910 914
911void AddressbookWindow::slotSetLetter( char c ) { 915void AddressbookWindow::slotSetLetter( char c ) {
912 916
913 m_abView->setShowByLetter( c ); 917 m_abView->setShowByLetter( c );
914 918
915} 919}
916 920
917 921
918void AddressbookWindow::populateCategories() 922void AddressbookWindow::populateCategories()
919{ 923{
920 catMenu->clear(); 924 catMenu->clear();
921 925
922 int id, rememberId; 926 int id, rememberId;
923 id = 1; 927 id = 1;
924 rememberId = 0; 928 rememberId = 0;
925 929
926 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); 930 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
927 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); 931 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
928 // catMenu->insertItem( tr( "Personal" ), id++ ); 932 // catMenu->insertItem( tr( "Personal" ), id++ );
929 catMenu->insertSeparator(); 933 catMenu->insertSeparator();
930 934
931 catMenu->insertItem( tr( "All" ), id++ ); 935 catMenu->insertItem( tr( "All" ), id++ );
932 QStringList categories = m_abView->categories(); 936 QStringList categories = m_abView->categories();
933 categories.append( tr( "Unfiled" ) ); 937 categories.append( tr( "Unfiled" ) );
934 for ( QStringList::Iterator it = categories.begin(); 938 for ( QStringList::Iterator it = categories.begin();
935 it != categories.end(); ++it ) { 939 it != categories.end(); ++it ) {
936 catMenu->insertItem( *it, id ); 940 catMenu->insertItem( *it, id );
937 if ( *it == m_abView -> showCategory() ) 941 if ( *it == m_abView -> showCategory() )
938 rememberId = id; 942 rememberId = id;
939 ++id; 943 ++id;
940 } 944 }
941 945
942 946
943 if ( m_abView -> showCategory().isEmpty() ) { 947 if ( m_abView -> showCategory().isEmpty() ) {
944 slotSetCategory( 3 ); 948 slotSetCategory( 3 );
945 } 949 }
946 else { 950 else {
947 slotSetCategory( rememberId ); 951 slotSetCategory( rememberId );
948 } 952 }
949} 953}
950 954
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 4c1e2f2..2bedc0b 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -1,137 +1,139 @@
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#ifndef Addressbook_H 20#ifndef Addressbook_H
21#define Addressbook_H 21#define Addressbook_H
22 22
23// Remove this for OPIE releae 1.0 ! 23// Remove this for OPIE releae 1.0 !
24#define __DEBUG_RELEASE 24#define __DEBUG_RELEASE
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qvaluelist.h> 27#include <qvaluelist.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include "ofloatbar.h" 30#include "ofloatbar.h"
31#include "abview.h" 31#include "abview.h"
32#include "abconfig.h" 32#include "abconfig.h"
33 33
34class ContactEditor; 34class ContactEditor;
35class AbLabel; 35class AbLabel;
36class AbTable; 36class AbTable;
37class QPEToolBar; 37class QPEToolBar;
38class QPopupMenu; 38class QPopupMenu;
39class QToolButton; 39class QToolButton;
40class QDialog; 40class QDialog;
41class Ir; 41class Ir;
42class QAction; 42class QAction;
43class LetterPicker; 43class LetterPicker;
44 44
45class AddressbookWindow: public QMainWindow 45class AddressbookWindow: public QMainWindow
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48public: 48public:
49 enum EntryMode { NewEntry=0, EditEntry }; 49 enum EntryMode { NewEntry=0, EditEntry };
50 50
51 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 51 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
52 ~AddressbookWindow(); 52 ~AddressbookWindow();
53 53
54protected: 54protected:
55 void resizeEvent( QResizeEvent * e ); 55 void resizeEvent( QResizeEvent * e );
56 56
57 void editPersonal(); 57 void editPersonal();
58 void editEntry( EntryMode ); 58 void editEntry( EntryMode );
59 void closeEvent( QCloseEvent *e ); 59 void closeEvent( QCloseEvent *e );
60 bool save(); 60 bool save();
61 61
62public slots: 62public slots:
63 void flush(); 63 void flush();
64 void reload(); 64 void reload();
65 void appMessage(const QCString &, const QByteArray &); 65 void appMessage(const QCString &, const QByteArray &);
66 void setDocument( const QString & ); 66 void setDocument( const QString & );
67#ifdef __DEBUG_RELEASE 67#ifdef __DEBUG_RELEASE
68 void slotSave(); 68 void slotSave();
69#endif 69#endif
70 70
71private slots: 71private slots:
72 void importvCard(); 72 void importvCard();
73 void slotListNew(); 73 void slotListNew();
74 /* void slotListView(); */ 74 /* void slotListView(); */
75 void slotListDelete(); 75 void slotListDelete();
76 void slotViewBack(); 76 void slotViewBack();
77 void slotViewEdit(); 77 void slotViewEdit();
78 void slotPersonalView(); 78 void slotPersonalView();
79 void listIsEmpty( bool ); 79 void listIsEmpty( bool );
80 /* void slotSettings(); */ 80 /* void slotSettings(); */
81 void writeMail(); 81 void writeMail();
82 void slotBeam(); 82 void slotBeam();
83 void beamDone( Ir * ); 83 void beamDone( Ir * );
84 void slotSetCategory( int ); 84 void slotSetCategory( int );
85 void slotSetLetter( char ); 85 void slotSetLetter( char );
86 void slotUpdateToolbar(); 86 void slotUpdateToolbar();
87 void slotSetFont(int); 87 void slotSetFont(int);
88 88
89 void slotFindOpen(); 89 void slotFindOpen();
90 void slotFindClose(); 90 void slotFindClose();
91 void slotFind(); 91 void slotFind();
92 void slotNotFound(); 92 void slotNotFound();
93 void slotWrapAround(); 93 void slotWrapAround();
94 94
95 void slotViewSwitched( int ); 95 void slotViewSwitched( int );
96 void slotListView(); 96 void slotListView();
97 void slotCardView(); 97 void slotCardView();
98 98
99 void slotConfig(); 99 void slotConfig();
100 100
101private: 101private:
102 //void initFields(); // inititialize our fields... 102 //void initFields(); // inititialize our fields...
103 // AbLabel *abView(); 103 // AbLabel *abView();
104 void populateCategories(); 104 void populateCategories();
105 105
106 QPopupMenu *catMenu; 106 QPopupMenu *catMenu;
107 QPEToolBar *listTools; 107 QPEToolBar *listTools;
108 QToolButton *deleteButton; 108 QToolButton *deleteButton;
109 //QValueList<int> allFields, orderedFields; 109 //QValueList<int> allFields, orderedFields;
110 //QStringList slOrderedFields; 110 //QStringList slOrderedFields;
111 enum Panes { paneList=0, paneView, paneEdit }; 111 enum Panes { paneList=0, paneView, paneEdit };
112 ContactEditor *abEditor; 112 ContactEditor *abEditor;
113 LetterPicker *pLabel; 113 LetterPicker *pLabel;
114 AbView* m_abView; 114 AbView* m_abView;
115 QWidget *listContainer; 115 QWidget *listContainer;
116 116
117 // Searching stuff 117 // Searching stuff
118 OFloatBar* searchBar; 118 OFloatBar* searchBar;
119 QLineEdit* searchEdit; 119 QLineEdit* searchEdit;
120 120
121 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; 121 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail;
122 122
123 int viewMargin; 123 int viewMargin;
124 124
125 bool syncing; 125 bool syncing;
126 QFont *defaultFont; 126 QFont *defaultFont;
127 int m_curFontSize; 127 int m_curFontSize;
128 128
129 bool isLoading; 129 bool isLoading;
130 130
131 AbConfig m_config; 131 AbConfig m_config;
132 132
133 QAction* m_tableViewButton; 133 QAction* m_tableViewButton;
134 QAction* m_cardViewButton; 134 QAction* m_cardViewButton;
135
136 int active_view;
135}; 137};
136 138
137#endif 139#endif