summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-08 21:10:34 (UTC)
committer harlekin <harlekin>2003-03-08 21:10:34 (UTC)
commitd44025daf7b191e1f79fe181b9ad1fcad20f3bdb (patch) (unidiff)
treedfeca99f66ac32be7d7485aaf36b353a8d775dd3
parent9e482f354732a04aebfe8ab9a9eb5cfaad5b3cdb (diff)
downloadopie-d44025daf7b191e1f79fe181b9ad1fcad20f3bdb.zip
opie-d44025daf7b191e1f79fe181b9ad1fcad20f3bdb.tar.gz
opie-d44025daf7b191e1f79fe181b9ad1fcad20f3bdb.tar.bz2
use the opie wide config icon
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp166
-rw-r--r--pics/addressbook/configure.pngbin485 -> 0 bytes
2 files changed, 83 insertions, 83 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 8937227..14e5b3f 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,1006 +1,1006 @@
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( "addressbook/weeklst" ), 107 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/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) // Why this ? (se) 143 //#if defined(Q_WS_QWS) // Why this ? (se)
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( "addressbook/sendmail" ), 178 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/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"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 197 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null,
198 0, this, 0); 198 0, this, 0);
199 actionPersonal = a; 199 actionPersonal = a;
200 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 200 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
201 a->addTo( edit ); 201 a->addTo( edit );
202 202
203 edit->insertSeparator(); 203 edit->insertSeparator();
204 204
205 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 205 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
206 QString::null, 0, this, 0 , TRUE ); 206 QString::null, 0, this, 0 , TRUE );
207 actionPersonal = a; 207 actionPersonal = a;
208 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 208 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
209 a->addTo( edit ); 209 a->addTo( edit );
210 210
211 211
212#ifdef __DEBUG_RELEASE 212#ifdef __DEBUG_RELEASE
213 // Remove this function for public Release ! This is only 213 // Remove this function for public Release ! This is only
214 // for debug purposes .. 214 // for debug purposes ..
215 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 215 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
216 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 216 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
217 a->addTo( edit ); 217 a->addTo( edit );
218#endif 218#endif
219 a = new QAction( tr( "Config" ), Resource::loadPixmap( "addressbook/configure" ), QString::null, 219 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
220 0, this, 0 ); 220 0, this, 0 );
221 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 221 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
222 a->addTo( edit ); 222 a->addTo( edit );
223 223
224 // Create Views 224 // Create Views
225 listContainer = new QWidget( this ); 225 listContainer = new QWidget( this );
226 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 226 QVBoxLayout *vb = new QVBoxLayout( listContainer );
227 227
228 m_abView = new AbView( listContainer, m_config.orderList() ); 228 m_abView = new AbView( listContainer, m_config.orderList() );
229 vb->addWidget( m_abView ); 229 vb->addWidget( m_abView );
230 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 230 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
231 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 231 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
232 this, SLOT( slotViewSwitched( int ) ) ); 232 this, SLOT( slotViewSwitched( int ) ) );
233 233
234 234
235 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 235 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
236 236
237 m_abView->load(); 237 m_abView->load();
238 238
239 // Letter Picker 239 // Letter Picker
240 pLabel = new LetterPicker( listContainer ); 240 pLabel = new LetterPicker( listContainer );
241 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 241 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
242 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 242 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
243 243
244 vb->addWidget( pLabel ); 244 vb->addWidget( pLabel );
245 245
246 // Category Menu 246 // Category Menu
247 catMenu = new QPopupMenu( this ); 247 catMenu = new QPopupMenu( this );
248 catMenu->setCheckable( TRUE ); 248 catMenu->setCheckable( TRUE );
249 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 249 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
250 populateCategories(); 250 populateCategories();
251 mbList->insertItem( tr("View"), catMenu ); 251 mbList->insertItem( tr("View"), catMenu );
252 252
253 defaultFont = new QFont( m_abView->font() ); 253 defaultFont = new QFont( m_abView->font() );
254 slotSetFont(m_config.fontSize()); 254 slotSetFont(m_config.fontSize());
255 m_curFontSize = m_config.fontSize(); 255 m_curFontSize = m_config.fontSize();
256 256
257 setCentralWidget(listContainer); 257 setCentralWidget(listContainer);
258 258
259 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 259 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
260 260
261 261
262 isLoading = false; 262 isLoading = false;
263} 263}
264 264
265 265
266void AddressbookWindow::slotConfig() 266void AddressbookWindow::slotConfig()
267{ 267{
268 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 268 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
269 dlg -> setConfig( m_config ); 269 dlg -> setConfig( m_config );
270 dlg -> showMaximized(); 270 dlg -> showMaximized();
271 if ( dlg -> exec() ) { 271 if ( dlg -> exec() ) {
272 qWarning ("Config Dialog accepted!"); 272 qWarning ("Config Dialog accepted!");
273 m_config = dlg -> getConfig(); 273 m_config = dlg -> getConfig();
274 if ( m_curFontSize != m_config.fontSize() ){ 274 if ( m_curFontSize != m_config.fontSize() ){
275 qWarning("Font was changed!"); 275 qWarning("Font was changed!");
276 m_curFontSize = m_config.fontSize(); 276 m_curFontSize = m_config.fontSize();
277 emit slotSetFont( m_curFontSize ); 277 emit slotSetFont( m_curFontSize );
278 } 278 }
279 m_abView -> setListOrder( m_config.orderList() ); 279 m_abView -> setListOrder( m_config.orderList() );
280 } 280 }
281 281
282 delete dlg; 282 delete dlg;
283} 283}
284 284
285 285
286void AddressbookWindow::slotSetFont( int size ) 286void AddressbookWindow::slotSetFont( int size )
287{ 287{
288 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 288 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
289 289
290 if (size > 2 || size < 0) 290 if (size > 2 || size < 0)
291 size = 1; 291 size = 1;
292 292
293 m_config.setFontSize( size ); 293 m_config.setFontSize( size );
294 294
295 QFont *currentFont; 295 QFont *currentFont;
296 296
297 switch (size) { 297 switch (size) {
298 case 0: 298 case 0:
299 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 299 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
300 currentFont = new QFont (m_abView->font()); 300 currentFont = new QFont (m_abView->font());
301 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 301 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
302 // abList->resizeRows(); 302 // abList->resizeRows();
303 break; 303 break;
304 case 1: 304 case 1:
305 m_abView->setFont( *defaultFont ); 305 m_abView->setFont( *defaultFont );
306 currentFont = new QFont (m_abView->font()); 306 currentFont = new QFont (m_abView->font());
307 // // abList->resizeRows(currentFont->pixelSize() + 7); 307 // // abList->resizeRows(currentFont->pixelSize() + 7);
308 // abList->resizeRows(); 308 // abList->resizeRows();
309 break; 309 break;
310 case 2: 310 case 2:
311 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 311 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
312 currentFont = new QFont (m_abView->font()); 312 currentFont = new QFont (m_abView->font());
313 // //abList->resizeRows(currentFont->pixelSize() + 7); 313 // //abList->resizeRows(currentFont->pixelSize() + 7);
314 // abList->resizeRows(); 314 // abList->resizeRows();
315 break; 315 break;
316 } 316 }
317} 317}
318 318
319 319
320 320
321void AddressbookWindow::importvCard() { 321void AddressbookWindow::importvCard() {
322 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 322 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
323 if(!str.isEmpty() ){ 323 if(!str.isEmpty() ){
324 setDocument((const QString&) str ); 324 setDocument((const QString&) str );
325 } 325 }
326 326
327} 327}
328 328
329void AddressbookWindow::setDocument( const QString &filename ) 329void AddressbookWindow::setDocument( const QString &filename )
330{ 330{
331 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 331 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
332 332
333 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 333 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
334 334
335 335
336 336
337 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 337 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
338 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 338 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
339 tr( "&Yes" ), tr( "&No" ), QString::null, 339 tr( "&Yes" ), tr( "&No" ), QString::null,
340 0, // Enter == button 0 340 0, // Enter == button 0
341 2 ) ) { // Escape == button 2 341 2 ) ) { // Escape == button 2
342 case 0: 342 case 0:
343 qWarning("YES clicked"); 343 qWarning("YES clicked");
344 break; 344 break;
345 case 1: 345 case 1:
346 qWarning("NO clicked"); 346 qWarning("NO clicked");
347 return; 347 return;
348 break; 348 break;
349 } 349 }
350 } 350 }
351 351
352 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 352 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
353 filename ); 353 filename );
354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
355 OContactAccess::List allList = access->allRecords(); 355 OContactAccess::List allList = access->allRecords();
356 qWarning( "Found number of contacts in File: %d", allList.count() ); 356 qWarning( "Found number of contacts in File: %d", allList.count() );
357 357
358 if ( !allList.count() ) { 358 if ( !allList.count() ) {
359 QMessageBox::information( this, "Import VCard", 359 QMessageBox::information( this, "Import VCard",
360 "It was impossible to import\nthe VCard.\n" 360 "It was impossible to import\nthe VCard.\n"
361 "The VCard may be corrupted!" ); 361 "The VCard may be corrupted!" );
362 } 362 }
363 363
364 bool doAsk = true; 364 bool doAsk = true;
365 OContactAccess::List::Iterator it; 365 OContactAccess::List::Iterator it;
366 for ( it = allList.begin(); it != allList.end(); ++it ){ 366 for ( it = allList.begin(); it != allList.end(); ++it ){
367 qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); 367 qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
368 if ( doAsk ){ 368 if ( doAsk ){
369 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 369 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
370 tr( "Do you really want add contact for \n%1?" ) 370 tr( "Do you really want add contact for \n%1?" )
371 .arg( (*it).fullName().latin1() ), 371 .arg( (*it).fullName().latin1() ),
372 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 372 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
373 0, // Enter == button 0 373 0, // Enter == button 0
374 2 ) ) { // Escape == button 2 374 2 ) ) { // Escape == button 2
375 case 0: 375 case 0:
376 qWarning("YES clicked"); 376 qWarning("YES clicked");
377 m_abView->addEntry( *it ); 377 m_abView->addEntry( *it );
378 break; 378 break;
379 case 1: 379 case 1:
380 qWarning("NO clicked"); 380 qWarning("NO clicked");
381 break; 381 break;
382 case 2: 382 case 2:
383 qWarning("YesAll clicked"); 383 qWarning("YesAll clicked");
384 doAsk = false; 384 doAsk = false;
385 break; 385 break;
386 } 386 }
387 }else 387 }else
388 m_abView->addEntry( *it ); 388 m_abView->addEntry( *it );
389 389
390 } 390 }
391 391
392 delete access; 392 delete access;
393} 393}
394 394
395void AddressbookWindow::resizeEvent( QResizeEvent *e ) 395void AddressbookWindow::resizeEvent( QResizeEvent *e )
396{ 396{
397 QMainWindow::resizeEvent( e ); 397 QMainWindow::resizeEvent( e );
398 398
399 399
400} 400}
401 401
402AddressbookWindow::~AddressbookWindow() 402AddressbookWindow::~AddressbookWindow()
403{ 403{
404 ToolBarDock dock; 404 ToolBarDock dock;
405 int dummy; 405 int dummy;
406 bool bDummy; 406 bool bDummy;
407 getLocation ( listTools, dock, dummy, bDummy, dummy ); 407 getLocation ( listTools, dock, dummy, bDummy, dummy );
408 m_config.setToolBarDock( dock ); 408 m_config.setToolBarDock( dock );
409 m_config.save(); 409 m_config.save();
410} 410}
411 411
412void AddressbookWindow::slotUpdateToolbar() 412void AddressbookWindow::slotUpdateToolbar()
413{ 413{
414 OContact ce = m_abView->currentEntry(); 414 OContact ce = m_abView->currentEntry();
415 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 415 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
416} 416}
417 417
418void AddressbookWindow::slotListNew() 418void AddressbookWindow::slotListNew()
419{ 419{
420 OContact cnt; 420 OContact cnt;
421 if( !syncing ) { 421 if( !syncing ) {
422 editEntry( NewEntry ); 422 editEntry( NewEntry );
423 } else { 423 } else {
424 QMessageBox::warning(this, tr("Contacts"), 424 QMessageBox::warning(this, tr("Contacts"),
425 tr("Can not edit data, currently syncing")); 425 tr("Can not edit data, currently syncing"));
426 } 426 }
427} 427}
428 428
429// void AddressbookWindow::slotListView() 429// void AddressbookWindow::slotListView()
430// { 430// {
431 // m_abView -> init( abList->currentEntry() ); 431 // m_abView -> init( abList->currentEntry() );
432 // // :SX mView->sync(); 432 // // :SX mView->sync();
433 // //:SXshowView(); 433 // //:SXshowView();
434// } 434// }
435 435
436void AddressbookWindow::slotListDelete() 436void AddressbookWindow::slotListDelete()
437{ 437{
438 if(!syncing) { 438 if(!syncing) {
439 OContact tmpEntry = m_abView ->currentEntry(); 439 OContact tmpEntry = m_abView ->currentEntry();
440 440
441 // get a name, do the best we can... 441 // get a name, do the best we can...
442 QString strName = tmpEntry.fullName(); 442 QString strName = tmpEntry.fullName();
443 if ( strName.isEmpty() ) { 443 if ( strName.isEmpty() ) {
444 strName = tmpEntry.company(); 444 strName = tmpEntry.company();
445 if ( strName.isEmpty() ) 445 if ( strName.isEmpty() )
446 strName = "No Name"; 446 strName = "No Name";
447 } 447 }
448 448
449 449
450 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 450 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
451 strName ) ) { 451 strName ) ) {
452 m_abView->removeEntry( tmpEntry.uid() ); 452 m_abView->removeEntry( tmpEntry.uid() );
453 } 453 }
454 } else { 454 } else {
455 QMessageBox::warning( this, tr("Contacts"), 455 QMessageBox::warning( this, tr("Contacts"),
456 tr("Can not edit data, currently syncing") ); 456 tr("Can not edit data, currently syncing") );
457 } 457 }
458} 458}
459 459
460void AddressbookWindow::slotFindOpen() 460void AddressbookWindow::slotFindOpen()
461{ 461{
462 searchBar->show(); 462 searchBar->show();
463 m_abView -> inSearch(); 463 m_abView -> inSearch();
464 searchEdit->setFocus(); 464 searchEdit->setFocus();
465} 465}
466void AddressbookWindow::slotFindClose() 466void AddressbookWindow::slotFindClose()
467{ 467{
468 searchBar->hide(); 468 searchBar->hide();
469 m_abView -> offSearch(); 469 m_abView -> offSearch();
470 // m_abView->setFocus(); 470 // m_abView->setFocus();
471} 471}
472 472
473 473
474void AddressbookWindow::slotFind() 474void AddressbookWindow::slotFind()
475{ 475{
476 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 476 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
477 477
478 searchEdit->clearFocus(); 478 searchEdit->clearFocus();
479 // m_abView->setFocus(); 479 // m_abView->setFocus();
480 480
481} 481}
482 482
483void AddressbookWindow::slotViewBack() 483void AddressbookWindow::slotViewBack()
484{ 484{
485 // :SX showList(); 485 // :SX showList();
486} 486}
487 487
488void AddressbookWindow::slotViewEdit() 488void AddressbookWindow::slotViewEdit()
489{ 489{
490 if(!syncing) { 490 if(!syncing) {
491 if (actionPersonal->isOn()) { 491 if (actionPersonal->isOn()) {
492 editPersonal(); 492 editPersonal();
493 } else { 493 } else {
494 editEntry( EditEntry ); 494 editEntry( EditEntry );
495 } 495 }
496 } else { 496 } else {
497 QMessageBox::warning( this, tr("Contacts"), 497 QMessageBox::warning( this, tr("Contacts"),
498 tr("Can not edit data, currently syncing") ); 498 tr("Can not edit data, currently syncing") );
499 } 499 }
500} 500}
501 501
502 502
503 503
504void AddressbookWindow::writeMail() 504void AddressbookWindow::writeMail()
505{ 505{
506 OContact c = m_abView -> currentEntry(); 506 OContact c = m_abView -> currentEntry();
507 QString name = c.fileAs(); 507 QString name = c.fileAs();
508 QString email = c.defaultEmail(); 508 QString email = c.defaultEmail();
509 509
510 // I prefer the OPIE-Environment variable before the 510 // I prefer the OPIE-Environment variable before the
511 // QPE-one.. 511 // QPE-one..
512 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 512 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
513 if ( basepath.isEmpty() ) 513 if ( basepath.isEmpty() )
514 basepath = QString::fromLatin1( getenv("QPEDIR") ); 514 basepath = QString::fromLatin1( getenv("QPEDIR") );
515 515
516 // Try to access the preferred. If not possible, try to 516 // Try to access the preferred. If not possible, try to
517 // switch to the other one.. 517 // switch to the other one..
518 if ( m_config.useQtMail() ){ 518 if ( m_config.useQtMail() ){
519 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 519 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
520 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 520 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
521 qWarning ("QCop"); 521 qWarning ("QCop");
522 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 522 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
523 e << name << email; 523 e << name << email;
524 return; 524 return;
525 } else 525 } else
526 m_config.setUseOpieMail( true ); 526 m_config.setUseOpieMail( true );
527 } 527 }
528 if ( m_config.useOpieMail() ){ 528 if ( m_config.useOpieMail() ){
529 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 529 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
530 if ( QFile::exists( basepath + "/bin/mail" ) ){ 530 if ( QFile::exists( basepath + "/bin/mail" ) ){
531 qWarning ("QCop"); 531 qWarning ("QCop");
532 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 532 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
533 e << name << email; 533 e << name << email;
534 return; 534 return;
535 } else 535 } else
536 m_config.setUseQtMail( true ); 536 m_config.setUseQtMail( true );
537 } 537 }
538 538
539} 539}
540 540
541static const char * beamfile = "/tmp/obex/contact.vcf"; 541static const char * beamfile = "/tmp/obex/contact.vcf";
542 542
543void AddressbookWindow::slotBeam() 543void AddressbookWindow::slotBeam()
544{ 544{
545 QString beamFilename; 545 QString beamFilename;
546 OContact c; 546 OContact c;
547 if ( actionPersonal->isOn() ) { 547 if ( actionPersonal->isOn() ) {
548 beamFilename = addressbookPersonalVCardName(); 548 beamFilename = addressbookPersonalVCardName();
549 if ( !QFile::exists( beamFilename ) ) 549 if ( !QFile::exists( beamFilename ) )
550 return; // can't beam a non-existent file 550 return; // can't beam a non-existent file
551 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 551 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
552 beamFilename ); 552 beamFilename );
553 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 553 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
554 OContactAccess::List allList = access->allRecords(); 554 OContactAccess::List allList = access->allRecords();
555 OContactAccess::List::Iterator it = allList.begin(); // Just take first 555 OContactAccess::List::Iterator it = allList.begin(); // Just take first
556 c = *it; 556 c = *it;
557 557
558 delete access; 558 delete access;
559 } else { 559 } else {
560 unlink( beamfile ); // delete if exists 560 unlink( beamfile ); // delete if exists
561 mkdir("/tmp/obex/", 0755); 561 mkdir("/tmp/obex/", 0755);
562 c = m_abView -> currentEntry(); 562 c = m_abView -> currentEntry();
563 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 563 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
564 beamfile ); 564 beamfile );
565 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 565 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
566 access->add( c ); 566 access->add( c );
567 access->save(); 567 access->save();
568 delete access; 568 delete access;
569 569
570 beamFilename = beamfile; 570 beamFilename = beamfile;
571 } 571 }
572 572
573 qWarning("Beaming: %s", beamFilename.latin1() ); 573 qWarning("Beaming: %s", beamFilename.latin1() );
574 574
575 Ir *ir = new Ir( this ); 575 Ir *ir = new Ir( this );
576 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 576 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
577 QString description = c.fullName(); 577 QString description = c.fullName();
578 ir->send( beamFilename, description, "text/x-vCard" ); 578 ir->send( beamFilename, description, "text/x-vCard" );
579} 579}
580 580
581void AddressbookWindow::beamDone( Ir *ir ) 581void AddressbookWindow::beamDone( Ir *ir )
582{ 582{
583 583
584 delete ir; 584 delete ir;
585 unlink( beamfile ); 585 unlink( beamfile );
586} 586}
587 587
588 588
589static void parseName( const QString& name, QString *first, QString *middle, 589static void parseName( const QString& name, QString *first, QString *middle,
590 QString * last ) 590 QString * last )
591{ 591{
592 592
593 int comma = name.find ( "," ); 593 int comma = name.find ( "," );
594 QString rest; 594 QString rest;
595 if ( comma > 0 ) { 595 if ( comma > 0 ) {
596 *last = name.left( comma ); 596 *last = name.left( comma );
597 comma++; 597 comma++;
598 while ( comma < int(name.length()) && name[comma] == ' ' ) 598 while ( comma < int(name.length()) && name[comma] == ' ' )
599 comma++; 599 comma++;
600 rest = name.mid( comma ); 600 rest = name.mid( comma );
601 } else { 601 } else {
602 int space = name.findRev( ' ' ); 602 int space = name.findRev( ' ' );
603 *last = name.mid( space+1 ); 603 *last = name.mid( space+1 );
604 rest = name.left( space ); 604 rest = name.left( space );
605 } 605 }
606 int space = rest.find( ' ' ); 606 int space = rest.find( ' ' );
607 if ( space <= 0 ) { 607 if ( space <= 0 ) {
608 *first = rest; 608 *first = rest;
609 } else { 609 } else {
610 *first = rest.left( space ); 610 *first = rest.left( space );
611 *middle = rest.mid( space+1 ); 611 *middle = rest.mid( space+1 );
612 } 612 }
613 613
614} 614}
615 615
616 616
617void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 617void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
618{ 618{
619 if (msg == "editPersonal()") { 619 if (msg == "editPersonal()") {
620 editPersonal(); 620 editPersonal();
621 } else if (msg == "editPersonalAndClose()") { 621 } else if (msg == "editPersonalAndClose()") {
622 editPersonal(); 622 editPersonal();
623 close(); 623 close();
624 } else if ( msg == "addContact(QString,QString)" ) { 624 } else if ( msg == "addContact(QString,QString)" ) {
625 QDataStream stream(data,IO_ReadOnly); 625 QDataStream stream(data,IO_ReadOnly);
626 QString name, email; 626 QString name, email;
627 stream >> name >> email; 627 stream >> name >> email;
628 628
629 OContact cnt; 629 OContact cnt;
630 QString fn, mn, ln; 630 QString fn, mn, ln;
631 parseName( name, &fn, &mn, &ln ); 631 parseName( name, &fn, &mn, &ln );
632 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 632 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
633 cnt.setFirstName( fn ); 633 cnt.setFirstName( fn );
634 cnt.setMiddleName( mn ); 634 cnt.setMiddleName( mn );
635 cnt.setLastName( ln ); 635 cnt.setLastName( ln );
636 cnt.insertEmails( email ); 636 cnt.insertEmails( email );
637 cnt.setDefaultEmail( email ); 637 cnt.setDefaultEmail( email );
638 cnt.setFileAs(); 638 cnt.setFileAs();
639 639
640 m_abView -> addEntry( cnt ); 640 m_abView -> addEntry( cnt );
641 641
642 // :SXm_abView()->init( cnt ); 642 // :SXm_abView()->init( cnt );
643 editEntry( EditEntry ); 643 editEntry( EditEntry );
644 } else if ( msg == "beamBusinessCard()" ) { 644 } else if ( msg == "beamBusinessCard()" ) {
645 QString beamFilename = addressbookPersonalVCardName(); 645 QString beamFilename = addressbookPersonalVCardName();
646 if ( !QFile::exists( beamFilename ) ) 646 if ( !QFile::exists( beamFilename ) )
647 return; // can't beam a non-existent file 647 return; // can't beam a non-existent file
648 648
649 Ir *ir = new Ir( this ); 649 Ir *ir = new Ir( this );
650 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 650 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
651 QString description = "mycard.vcf"; 651 QString description = "mycard.vcf";
652 ir->send( beamFilename, description, "text/x-vCard" ); 652 ir->send( beamFilename, description, "text/x-vCard" );
653 } 653 }
654#if 0 654#if 0
655 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 655 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
656 QDataStream stream(data,IO_ReadOnly); 656 QDataStream stream(data,IO_ReadOnly);
657 QCString ch,m; 657 QCString ch,m;
658 QStringList types; 658 QStringList types;
659 stream >> ch >> m >> types; 659 stream >> ch >> m >> types;
660 AddressPicker picker(abList,this,0,TRUE); 660 AddressPicker picker(abList,this,0,TRUE);
661 picker.showMaximized(); 661 picker.showMaximized();
662 picker.setChoiceNames(types); 662 picker.setChoiceNames(types);
663 int i=0; 663 int i=0;
664 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 664 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
665 QStringList sel; 665 QStringList sel;
666 stream >> sel; 666 stream >> sel;
667 picker.setSelection(i++,sel); 667 picker.setSelection(i++,sel);
668 } 668 }
669 picker.showMaximized(); 669 picker.showMaximized();
670 picker.exec(); 670 picker.exec();
671 671
672 // ###### note: contacts may have been added - save here! 672 // ###### note: contacts may have been added - save here!
673 673
674 setCentralWidget(abList); 674 setCentralWidget(abList);
675 QCopEnvelope e(ch,m); 675 QCopEnvelope e(ch,m);
676 i=0; 676 i=0;
677 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 677 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
678 QStringList sel = picker.selection(i++); 678 QStringList sel = picker.selection(i++);
679 e << sel; 679 e << sel;
680 } 680 }
681 } 681 }
682#endif 682#endif
683 683
684} 684}
685 685
686void AddressbookWindow::editEntry( EntryMode entryMode ) 686void AddressbookWindow::editEntry( EntryMode entryMode )
687{ 687{
688 OContact entry; 688 OContact entry;
689 if ( !abEditor ) { 689 if ( !abEditor ) {
690 abEditor = new ContactEditor( entry, this, "editor" ); 690 abEditor = new ContactEditor( entry, this, "editor" );
691 } 691 }
692 if ( entryMode == EditEntry ) 692 if ( entryMode == EditEntry )
693 abEditor->setEntry( m_abView -> currentEntry() ); 693 abEditor->setEntry( m_abView -> currentEntry() );
694 else if ( entryMode == NewEntry ) 694 else if ( entryMode == NewEntry )
695 abEditor->setEntry( entry ); 695 abEditor->setEntry( entry );
696 // other things may change the caption. 696 // other things may change the caption.
697 abEditor->setCaption( tr("Edit Address") ); 697 abEditor->setCaption( tr("Edit Address") );
698 698
699#if defined(Q_WS_QWS) || defined(_WS_QWS_) 699#if defined(Q_WS_QWS) || defined(_WS_QWS_)
700 abEditor->showMaximized(); 700 abEditor->showMaximized();
701#endif 701#endif
702 // fix the foxus... 702 // fix the foxus...
703 abEditor->setNameFocus(); 703 abEditor->setNameFocus();
704 if ( abEditor->exec() ) { 704 if ( abEditor->exec() ) {
705 setFocus(); 705 setFocus();
706 if ( entryMode == NewEntry ) { 706 if ( entryMode == NewEntry ) {
707 OContact insertEntry = abEditor->entry(); 707 OContact insertEntry = abEditor->entry();
708 insertEntry.assignUid(); 708 insertEntry.assignUid();
709 m_abView -> addEntry( insertEntry ); 709 m_abView -> addEntry( insertEntry );
710 } else { 710 } else {
711 OContact replEntry = abEditor->entry(); 711 OContact replEntry = abEditor->entry();
712 712
713 if ( !replEntry.isValidUid() ) 713 if ( !replEntry.isValidUid() )
714 replEntry.assignUid(); 714 replEntry.assignUid();
715 715
716 m_abView -> replaceEntry( replEntry ); 716 m_abView -> replaceEntry( replEntry );
717 } 717 }
718 } 718 }
719 // populateCategories(); 719 // populateCategories();
720 720
721} 721}
722 722
723void AddressbookWindow::editPersonal() 723void AddressbookWindow::editPersonal()
724{ 724{
725 OContact entry; 725 OContact entry;
726 726
727 // Switch to personal view if not selected 727 // Switch to personal view if not selected
728 // but take care of the menu, too 728 // but take care of the menu, too
729 if ( ! actionPersonal->isOn() ){ 729 if ( ! actionPersonal->isOn() ){
730 qWarning("*** ++++"); 730 qWarning("*** ++++");
731 actionPersonal->setOn( true ); 731 actionPersonal->setOn( true );
732 slotPersonalView(); 732 slotPersonalView();
733 } 733 }
734 734
735 if ( !abEditor ) { 735 if ( !abEditor ) {
736 abEditor = new ContactEditor( entry, this, "editor" ); 736 abEditor = new ContactEditor( entry, this, "editor" );
737 } 737 }
738 738
739 abEditor->setCaption(tr("Edit My Personal Details")); 739 abEditor->setCaption(tr("Edit My Personal Details"));
740 abEditor->setPersonalView( true ); 740 abEditor->setPersonalView( true );
741 editEntry( EditEntry ); 741 editEntry( EditEntry );
742 abEditor->setPersonalView( false ); 742 abEditor->setPersonalView( false );
743 743
744} 744}
745 745
746 746
747void AddressbookWindow::slotPersonalView() 747void AddressbookWindow::slotPersonalView()
748{ 748{
749 qWarning("slotPersonalView()"); 749 qWarning("slotPersonalView()");
750 if (!actionPersonal->isOn()) { 750 if (!actionPersonal->isOn()) {
751 // we just turned it off 751 // we just turned it off
752 qWarning("slotPersonalView()-> OFF"); 752 qWarning("slotPersonalView()-> OFF");
753 setCaption( tr("Contacts") ); 753 setCaption( tr("Contacts") );
754 actionNew->setEnabled(TRUE); 754 actionNew->setEnabled(TRUE);
755 actionTrash->setEnabled(TRUE); 755 actionTrash->setEnabled(TRUE);
756 actionFind->setEnabled(TRUE); 756 actionFind->setEnabled(TRUE);
757 actionMail->setEnabled(TRUE); 757 actionMail->setEnabled(TRUE);
758 // slotUpdateToolbar(); 758 // slotUpdateToolbar();
759 759
760 m_abView->showPersonal( false ); 760 m_abView->showPersonal( false );
761 761
762 return; 762 return;
763 } 763 }
764 764
765 qWarning("slotPersonalView()-> ON"); 765 qWarning("slotPersonalView()-> ON");
766 // XXX need to disable some QActions. 766 // XXX need to disable some QActions.
767 actionNew->setEnabled(FALSE); 767 actionNew->setEnabled(FALSE);
768 actionTrash->setEnabled(FALSE); 768 actionTrash->setEnabled(FALSE);
769 actionFind->setEnabled(FALSE); 769 actionFind->setEnabled(FALSE);
770 actionMail->setEnabled(FALSE); 770 actionMail->setEnabled(FALSE);
771 771
772 setCaption( tr("Contacts - My Personal Details") ); 772 setCaption( tr("Contacts - My Personal Details") );
773 773
774 m_abView->showPersonal( true ); 774 m_abView->showPersonal( true );
775 775
776} 776}
777 777
778 778
779void AddressbookWindow::listIsEmpty( bool empty ) 779void AddressbookWindow::listIsEmpty( bool empty )
780{ 780{
781 if ( !empty ) { 781 if ( !empty ) {
782 deleteButton->setEnabled( TRUE ); 782 deleteButton->setEnabled( TRUE );
783 } 783 }
784} 784}
785 785
786void AddressbookWindow::reload() 786void AddressbookWindow::reload()
787{ 787{
788 syncing = FALSE; 788 syncing = FALSE;
789 m_abView->clear(); 789 m_abView->clear();
790 m_abView->reload(); 790 m_abView->reload();
791} 791}
792 792
793void AddressbookWindow::flush() 793void AddressbookWindow::flush()
794{ 794{
795 syncing = TRUE; 795 syncing = TRUE;
796 m_abView->save(); 796 m_abView->save();
797} 797}
798 798
799 799
800void AddressbookWindow::closeEvent( QCloseEvent *e ) 800void AddressbookWindow::closeEvent( QCloseEvent *e )
801{ 801{
802 if(active_view == AbView::CardView){ 802 if(active_view == AbView::CardView){
803 slotViewSwitched( AbView::TableView ); 803 slotViewSwitched( AbView::TableView );
804 e->ignore(); 804 e->ignore();
805 return; 805 return;
806 } 806 }
807 if(syncing) { 807 if(syncing) {
808 /* shouldn't we save, I hear you say? well its already been set 808 /* shouldn't we save, I hear you say? well its already been set
809 so that an edit can not occur during a sync, and we flushed 809 so that an edit can not occur during a sync, and we flushed
810 at the start of the sync, so there is no need to save 810 at the start of the sync, so there is no need to save
811 Saving however itself would cause problems. */ 811 Saving however itself would cause problems. */
812 e->accept(); 812 e->accept();
813 return; 813 return;
814 } 814 }
815 //################## shouldn't always save 815 //################## shouldn't always save
816 // True, but the database handles this automatically ! (se) 816 // True, but the database handles this automatically ! (se)
817 if ( save() ) 817 if ( save() )
818 e->accept(); 818 e->accept();
819 else 819 else
820 e->ignore(); 820 e->ignore();
821} 821}
822 822
823/* 823/*
824 Returns TRUE if it is OK to exit 824 Returns TRUE if it is OK to exit
825*/ 825*/
826 826
827bool AddressbookWindow::save() 827bool AddressbookWindow::save()
828{ 828{
829 if ( !m_abView->save() ) { 829 if ( !m_abView->save() ) {
830 if ( QMessageBox::critical( 0, tr( "Out of space" ), 830 if ( QMessageBox::critical( 0, tr( "Out of space" ),
831 tr("Unable to save information.\n" 831 tr("Unable to save information.\n"
832 "Free up some space\n" 832 "Free up some space\n"
833 "and try again.\n" 833 "and try again.\n"
834 "\nQuit anyway?"), 834 "\nQuit anyway?"),
835 QMessageBox::Yes|QMessageBox::Escape, 835 QMessageBox::Yes|QMessageBox::Escape,
836 QMessageBox::No|QMessageBox::Default ) 836 QMessageBox::No|QMessageBox::Default )
837 != QMessageBox::No ) 837 != QMessageBox::No )
838 return TRUE; 838 return TRUE;
839 else 839 else
840 return FALSE; 840 return FALSE;
841 } 841 }
842 return TRUE; 842 return TRUE;
843} 843}
844 844
845#ifdef __DEBUG_RELEASE 845#ifdef __DEBUG_RELEASE
846void AddressbookWindow::slotSave() 846void AddressbookWindow::slotSave()
847{ 847{
848 save(); 848 save();
849} 849}
850#endif 850#endif
851 851
852 852
853void AddressbookWindow::slotNotFound() 853void AddressbookWindow::slotNotFound()
854{ 854{
855 qWarning("Got notfound signal!"); 855 qWarning("Got notfound signal!");
856 QMessageBox::information( this, tr( "Not Found" ), 856 QMessageBox::information( this, tr( "Not Found" ),
857 tr( "Unable to find a contact for this \n search pattern!" ) ); 857 tr( "Unable to find a contact for this \n search pattern!" ) );
858 858
859 859
860} 860}
861void AddressbookWindow::slotWrapAround() 861void AddressbookWindow::slotWrapAround()
862{ 862{
863 qWarning("Got wrap signal!"); 863 qWarning("Got wrap signal!");
864 // if ( doNotifyWrapAround ) 864 // if ( doNotifyWrapAround )
865 // QMessageBox::information( this, tr( "End of list" ), 865 // QMessageBox::information( this, tr( "End of list" ),
866 // tr( "End of list. Wrap around now...!" ) + "\n" ); 866 // tr( "End of list. Wrap around now...!" ) + "\n" );
867 867
868} 868}
869 869
870void AddressbookWindow::slotSetCategory( int c ) 870void AddressbookWindow::slotSetCategory( int c )
871{ 871{
872 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); 872 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
873 873
874 QString cat, book; 874 QString cat, book;
875 AbView::Views view = AbView::TableView; 875 AbView::Views view = AbView::TableView;
876 876
877 if ( c <= 0 ) 877 if ( c <= 0 )
878 return; 878 return;
879 879
880 // Switch view 880 // Switch view
881 if ( c < 3 ) 881 if ( c < 3 )
882 for ( unsigned int i = 1; i < 3; i++ ){ 882 for ( unsigned int i = 1; i < 3; i++ ){
883 if ( catMenu ) 883 if ( catMenu )
884 catMenu->setItemChecked( i, c == (int)i ); 884 catMenu->setItemChecked( i, c == (int)i );
885 } 885 }
886 else 886 else
887 // Checkmark Category Menu Item Selected 887 // Checkmark Category Menu Item Selected
888 for ( unsigned int i = 3; i < catMenu->count(); i++ ) 888 for ( unsigned int i = 3; i < catMenu->count(); i++ )
889 catMenu->setItemChecked( i, c == (int)i ); 889 catMenu->setItemChecked( i, c == (int)i );
890 890
891 // Now switch to the selected category 891 // Now switch to the selected category
892 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 892 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
893 if (catMenu->isItemChecked( i )) { 893 if (catMenu->isItemChecked( i )) {
894 if ( i == 1 ){ // default List view 894 if ( i == 1 ){ // default List view
895 book = QString::null; 895 book = QString::null;
896 view = AbView::TableView; 896 view = AbView::TableView;
897 }else if ( i == 2 ){ 897 }else if ( i == 2 ){
898 book = tr( "Cards" ); 898 book = tr( "Cards" );
899 view = AbView::CardView; 899 view = AbView::CardView;
900 // }else if ( i == 3 ){ 900 // }else if ( i == 3 ){
901 // book = tr( "Personal" ); 901 // book = tr( "Personal" );
902 // view = AbView:: PersonalView; 902 // view = AbView:: PersonalView;
903 }else if ( i == 3 ){ // default All Categories 903 }else if ( i == 3 ){ // default All Categories
904 cat = QString::null; 904 cat = QString::null;
905 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled 905 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
906 cat = "Unfiled"; 906 cat = "Unfiled";
907 qWarning ("Unfiled selected!!!"); 907 qWarning ("Unfiled selected!!!");
908 }else{ 908 }else{
909 cat = m_abView->categories()[i - 4]; 909 cat = m_abView->categories()[i - 4];
910 } 910 }
911 } 911 }
912 } 912 }
913 913
914 // Switch to the selected View 914 // Switch to the selected View
915 slotViewSwitched( view ); 915 slotViewSwitched( view );
916 916
917 // Tell the view about the selected category 917 // Tell the view about the selected category
918 m_abView -> setShowByCategory( cat ); 918 m_abView -> setShowByCategory( cat );
919 919
920 if ( book.isEmpty() ) 920 if ( book.isEmpty() )
921 book = "List"; 921 book = "List";
922 if ( cat.isEmpty() ) 922 if ( cat.isEmpty() )
923 cat = "All"; 923 cat = "All";
924 924
925 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); 925 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
926} 926}
927 927
928void AddressbookWindow::slotViewSwitched( int view ) 928void AddressbookWindow::slotViewSwitched( int view )
929{ 929{
930 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); 930 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
931 int menu = 0; 931 int menu = 0;
932 932
933 // Switch to selected view 933 // Switch to selected view
934 switch ( view ){ 934 switch ( view ){
935 case AbView::TableView: 935 case AbView::TableView:
936 menu = 1; 936 menu = 1;
937 m_tableViewButton->setOn(true); 937 m_tableViewButton->setOn(true);
938 m_cardViewButton->setOn(false); 938 m_cardViewButton->setOn(false);
939 break; 939 break;
940 case AbView::CardView: 940 case AbView::CardView:
941 menu = 2; 941 menu = 2;
942 m_tableViewButton->setOn(false); 942 m_tableViewButton->setOn(false);
943 m_cardViewButton->setOn(true); 943 m_cardViewButton->setOn(true);
944 break; 944 break;
945 } 945 }
946 for ( unsigned int i = 1; i < 3; i++ ){ 946 for ( unsigned int i = 1; i < 3; i++ ){
947 if ( catMenu ) 947 if ( catMenu )
948 catMenu->setItemChecked( i, menu == (int)i ); 948 catMenu->setItemChecked( i, menu == (int)i );
949 } 949 }
950 950
951 // Tell the view about the selected view 951 // Tell the view about the selected view
952 m_abView -> setShowToView ( (AbView::Views) view ); 952 m_abView -> setShowToView ( (AbView::Views) view );
953 active_view = view; 953 active_view = view;
954} 954}
955 955
956 956
957void AddressbookWindow::slotListView() 957void AddressbookWindow::slotListView()
958{ 958{
959 slotViewSwitched( AbView::TableView ); 959 slotViewSwitched( AbView::TableView );
960} 960}
961 961
962void AddressbookWindow::slotCardView() 962void AddressbookWindow::slotCardView()
963{ 963{
964 slotViewSwitched( AbView::CardView ); 964 slotViewSwitched( AbView::CardView );
965} 965}
966 966
967void AddressbookWindow::slotSetLetter( char c ) { 967void AddressbookWindow::slotSetLetter( char c ) {
968 968
969 m_abView->setShowByLetter( c ); 969 m_abView->setShowByLetter( c );
970 970
971} 971}
972 972
973 973
974void AddressbookWindow::populateCategories() 974void AddressbookWindow::populateCategories()
975{ 975{
976 catMenu->clear(); 976 catMenu->clear();
977 977
978 int id, rememberId; 978 int id, rememberId;
979 id = 1; 979 id = 1;
980 rememberId = 0; 980 rememberId = 0;
981 981
982 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); 982 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
983 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); 983 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
984 // catMenu->insertItem( tr( "Personal" ), id++ ); 984 // catMenu->insertItem( tr( "Personal" ), id++ );
985 catMenu->insertSeparator(); 985 catMenu->insertSeparator();
986 986
987 catMenu->insertItem( tr( "All" ), id++ ); 987 catMenu->insertItem( tr( "All" ), id++ );
988 QStringList categories = m_abView->categories(); 988 QStringList categories = m_abView->categories();
989 categories.append( tr( "Unfiled" ) ); 989 categories.append( tr( "Unfiled" ) );
990 for ( QStringList::Iterator it = categories.begin(); 990 for ( QStringList::Iterator it = categories.begin();
991 it != categories.end(); ++it ) { 991 it != categories.end(); ++it ) {
992 catMenu->insertItem( *it, id ); 992 catMenu->insertItem( *it, id );
993 if ( *it == m_abView -> showCategory() ) 993 if ( *it == m_abView -> showCategory() )
994 rememberId = id; 994 rememberId = id;
995 ++id; 995 ++id;
996 } 996 }
997 997
998 998
999 if ( m_abView -> showCategory().isEmpty() ) { 999 if ( m_abView -> showCategory().isEmpty() ) {
1000 slotSetCategory( 3 ); 1000 slotSetCategory( 3 );
1001 } 1001 }
1002 else { 1002 else {
1003 slotSetCategory( rememberId ); 1003 slotSetCategory( rememberId );
1004 } 1004 }
1005} 1005}
1006 1006
diff --git a/pics/addressbook/configure.png b/pics/addressbook/configure.png
deleted file mode 100644
index dd68320..0000000
--- a/pics/addressbook/configure.png
+++ b/dev/null
Binary files differ