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