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