summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-16 11:11:30 (UTC)
committer eilers <eilers>2002-10-16 11:11:30 (UTC)
commitfdc4abb0d38e6d5dce98961e47b552ff56c89976 (patch) (unidiff)
tree19201b896894949c3ae62bace1b555dd96874241
parent2bfae6336f88a460311abaf727256c3413b27f67 (diff)
downloadopie-fdc4abb0d38e6d5dce98961e47b552ff56c89976.zip
opie-fdc4abb0d38e6d5dce98961e47b552ff56c89976.tar.gz
opie-fdc4abb0d38e6d5dce98961e47b552ff56c89976.tar.bz2
Temporarely added save function..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 93581e8..82a1b57 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,286 +1,299 @@
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 "abtable.h" 25#include "abtable.h"
26#include "addresssettings.h" 26#include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29 29
30#include <opie/ofileselector.h> 30#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 31#include <opie/ofiledialog.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <opie/ocontact.h> 34#include <opie/ocontact.h>
35 35
36#ifndef MAKE_FOR_SHARP_ROM 36#ifndef MAKE_FOR_SHARP_ROM
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#endif 38#endif
39 39
40#include <qpe/global.h> 40#include <qpe/global.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/ir.h> 42#include <qpe/ir.h>
43#include <qpe/qpemessagebox.h> 43#include <qpe/qpemessagebox.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45 45
46#include <qaction.h> 46#include <qaction.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qfile.h> 49#include <qfile.h>
50#include <qimage.h> 50#include <qimage.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qpe/qpemenubar.h> 52#include <qpe/qpemenubar.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 <qpe/qpetoolbar.h> 56#include <qpe/qpetoolbar.h>
57#include <qstringlist.h> 57#include <qstringlist.h>
58#include <qtoolbutton.h> 58#include <qtoolbutton.h>
59#include <qwhatsthis.h> 59#include <qwhatsthis.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#include <qdatetime.h> 67#include <qdatetime.h>
68 68
69#include "picker.h" 69#include "picker.h"
70 70
71// Remove this for OPIE releae 1.0 !
72#define __DEBUG_RELEASE
73
74
71static QString addressbookPersonalVCardName() 75static QString addressbookPersonalVCardName()
72{ 76{
73 QString filename = Global::applicationFileName("addressbook", 77 QString filename = Global::applicationFileName("addressbook",
74 "businesscard.vcf"); 78 "businesscard.vcf");
75 return filename; 79 return filename;
76} 80}
77 81
78 82
79AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 83AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
80 WFlags f ) 84 WFlags f )
81 : QMainWindow( parent, name, f ), 85 : QMainWindow( parent, name, f ),
82 abEditor(0), 86 abEditor(0),
83 bAbEditFirstTime(TRUE), 87 bAbEditFirstTime(TRUE),
84 syncing(FALSE) 88 syncing(FALSE)
85{ 89{
86 isLoading = true; 90 isLoading = true;
87 91
88 initFields(); 92 initFields();
89 93
90 setCaption( tr("Contacts") ); 94 setCaption( tr("Contacts") );
91 setIcon( Resource::loadPixmap( "AddressBook" ) ); 95 setIcon( Resource::loadPixmap( "AddressBook" ) );
92 96
93 setToolBarsMovable( FALSE ); 97 setToolBarsMovable( FALSE );
94 98
95 // Create Toolbars 99 // Create Toolbars
96 100
97 QPEToolBar *bar = new QPEToolBar( this ); 101 QPEToolBar *bar = new QPEToolBar( this );
98 bar->setHorizontalStretchable( TRUE ); 102 bar->setHorizontalStretchable( TRUE );
99 103
100 QPEMenuBar *mbList = new QPEMenuBar( bar ); 104 QPEMenuBar *mbList = new QPEMenuBar( bar );
101 mbList->setMargin( 0 ); 105 mbList->setMargin( 0 );
102 106
103 QPopupMenu *edit = new QPopupMenu( this ); 107 QPopupMenu *edit = new QPopupMenu( this );
104 mbList->insertItem( tr( "Contact" ), edit ); 108 mbList->insertItem( tr( "Contact" ), edit );
105 109
106 listTools = new QPEToolBar( this, "list operations" ); 110 listTools = new QPEToolBar( this, "list operations" );
107 111
108 112
109 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 113 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
110 0, this, 0 ); 114 0, this, 0 );
111 actionNew = a; 115 actionNew = a;
112 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 116 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
113 a->addTo( edit ); 117 a->addTo( edit );
114 a->addTo( listTools ); 118 a->addTo( listTools );
115 119
116 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 120 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
117 0, this, 0 ); 121 0, this, 0 );
118 actionEdit = a; 122 actionEdit = a;
119 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 123 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
120 a->addTo( edit ); 124 a->addTo( edit );
121 a->addTo( listTools ); 125 a->addTo( listTools );
122 126
123 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 127 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
124 0, this, 0 ); 128 0, this, 0 );
125 actionTrash = a; 129 actionTrash = a;
126 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 130 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
127 a->addTo( edit ); 131 a->addTo( edit );
128 a->addTo( listTools ); 132 a->addTo( listTools );
129 133
130 134
131 // make it possible to go directly to businesscard via qcop call 135 // make it possible to go directly to businesscard via qcop call
132#if defined(Q_WS_QWS) 136#if defined(Q_WS_QWS)
133#if !defined(QT_NO_COP) 137#if !defined(QT_NO_COP)
134 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 138 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
135 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 139 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
136 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 140 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
137#endif 141#endif
138#endif 142#endif
139 143
140 144
141 145
142 146
143 147
144#ifndef MAKE_FOR_SHARP_ROM 148#ifndef MAKE_FOR_SHARP_ROM
145 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
146 QString::null, 0, this, 0 ); 150 QString::null, 0, this, 0 );
147 actionFind = a; 151 actionFind = a;
148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 152 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
149 a->addTo( edit ); 153 a->addTo( edit );
150 a->addTo( listTools ); 154 a->addTo( listTools );
151#endif 155#endif
152 156
153 157
154 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 158 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
155 QString::null, 0, this, 0 ); 159 QString::null, 0, this, 0 );
156 //a->setEnabled( FALSE ); we got support for it now :) zecke 160 //a->setEnabled( FALSE ); we got support for it now :) zecke
157 actionMail = a; 161 actionMail = a;
158 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 162 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
159 a->addTo( edit ); 163 a->addTo( edit );
160 a->addTo( listTools ); 164 a->addTo( listTools );
161 165
162 166
163 167
164 if ( Ir::supported() ) { 168 if ( Ir::supported() ) {
165 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 169 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
166 0, this, 0 ); 170 0, this, 0 );
167 actionBeam = a; 171 actionBeam = a;
168 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 172 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
169 a->addTo( edit ); 173 a->addTo( edit );
170 a->addTo( listTools ); 174 a->addTo( listTools );
171 } 175 }
172 176
173 edit->insertSeparator(); 177 edit->insertSeparator();
174 178
175 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 179 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
176 actionPersonal = a; 180 actionPersonal = a;
177 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 181 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
178 a->addTo( edit ); 182 a->addTo( edit );
179 183
180 edit->insertSeparator(); 184 edit->insertSeparator();
181 185
182 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 186 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
183 actionPersonal = a; 187 actionPersonal = a;
184 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 188 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
185 a->addTo( edit ); 189 a->addTo( edit );
186 190
187 191 // Do we need this function ? (se)
188 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 192 // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
189 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 193 // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
194 // a->addTo( edit );
195
196
197#ifdef __DEBUG_RELEASE
198 // Remove this function for public Release ! This is only
199 // for debug purposes ..
200 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
201 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
190 a->addTo( edit ); 202 a->addTo( edit );
203#endif
191 204
192 // Create Views 205 // Create Views
193 listContainer = new QWidget( this ); 206 listContainer = new QWidget( this );
194 207
195 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 208 QVBoxLayout *vb = new QVBoxLayout( listContainer );
196 209
197 abList = new AbTable( &orderedFields, listContainer, "table" ); 210 abList = new AbTable( &orderedFields, listContainer, "table" );
198 vb->addWidget(abList); 211 vb->addWidget(abList);
199 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 212 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
200 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 213 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) );
201 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 214 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) );
202 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); 215 connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) );
203 216
204 mView = 0; 217 mView = 0;
205 218
206 abList->load(); 219 abList->load();
207 220
208 pLabel = new LetterPicker( listContainer ); 221 pLabel = new LetterPicker( listContainer );
209 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 222 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
210 vb->addWidget(pLabel); 223 vb->addWidget(pLabel);
211 catMenu = new QPopupMenu( this ); 224 catMenu = new QPopupMenu( this );
212 catMenu->setCheckable( TRUE ); 225 catMenu->setCheckable( TRUE );
213 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 226 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
214 populateCategories(); 227 populateCategories();
215 228
216 mbList->insertItem( tr("View"), catMenu ); 229 mbList->insertItem( tr("View"), catMenu );
217 // setCentralWidget( listContainer ); 230 // setCentralWidget( listContainer );
218 231
219 fontMenu = new QPopupMenu(this); 232 fontMenu = new QPopupMenu(this);
220 fontMenu->setCheckable( true ); 233 fontMenu->setCheckable( true );
221 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 234 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
222 235
223 fontMenu->insertItem(tr( "Small" ), 0); 236 fontMenu->insertItem(tr( "Small" ), 0);
224 fontMenu->insertItem(tr( "Normal" ), 1); 237 fontMenu->insertItem(tr( "Normal" ), 1);
225 fontMenu->insertItem(tr( "Large" ), 2); 238 fontMenu->insertItem(tr( "Large" ), 2);
226 239
227 defaultFont = new QFont( abList->font() ); 240 defaultFont = new QFont( abList->font() );
228 241
229 slotSetFont(startFontSize); 242 slotSetFont(startFontSize);
230 243
231 mbList->insertItem( tr("Font"), fontMenu); 244 mbList->insertItem( tr("Font"), fontMenu);
232 setCentralWidget(listContainer); 245 setCentralWidget(listContainer);
233 246
234 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 247 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
235 248
236 abList->setCurrentCell( 0, 0 ); 249 abList->setCurrentCell( 0, 0 );
237 250
238 isLoading = false; 251 isLoading = false;
239} 252}
240 253
241 254
242void AddressbookWindow::slotSetFont( int size ) { 255void AddressbookWindow::slotSetFont( int size ) {
243 256
244 if (size > 2 || size < 0) 257 if (size > 2 || size < 0)
245 size = 1; 258 size = 1;
246 259
247 startFontSize = size; 260 startFontSize = size;
248 261
249 QFont *currentFont; 262 QFont *currentFont;
250 263
251 switch (size) { 264 switch (size) {
252 case 0: 265 case 0:
253 fontMenu->setItemChecked(0, true); 266 fontMenu->setItemChecked(0, true);
254 fontMenu->setItemChecked(1, false); 267 fontMenu->setItemChecked(1, false);
255 fontMenu->setItemChecked(2, false); 268 fontMenu->setItemChecked(2, false);
256 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 269 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
257 currentFont = new QFont (abList->font()); 270 currentFont = new QFont (abList->font());
258 // abList->resizeRows(currentFont->pixelSize() + 7); 271 // abList->resizeRows(currentFont->pixelSize() + 7);
259 abList->resizeRows(); 272 abList->resizeRows();
260 break; 273 break;
261 case 1: 274 case 1:
262 fontMenu->setItemChecked(0, false); 275 fontMenu->setItemChecked(0, false);
263 fontMenu->setItemChecked(1, true); 276 fontMenu->setItemChecked(1, true);
264 fontMenu->setItemChecked(2, false); 277 fontMenu->setItemChecked(2, false);
265 abList->setFont( *defaultFont ); 278 abList->setFont( *defaultFont );
266 currentFont = new QFont (abList->font()); 279 currentFont = new QFont (abList->font());
267 // abList->resizeRows(currentFont->pixelSize() + 7); 280 // abList->resizeRows(currentFont->pixelSize() + 7);
268 abList->resizeRows(); 281 abList->resizeRows();
269 break; 282 break;
270 case 2: 283 case 2:
271 fontMenu->setItemChecked(0, false); 284 fontMenu->setItemChecked(0, false);
272 fontMenu->setItemChecked(1, false); 285 fontMenu->setItemChecked(1, false);
273 fontMenu->setItemChecked(2, true); 286 fontMenu->setItemChecked(2, true);
274 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 287 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
275 currentFont = new QFont (abList->font()); 288 currentFont = new QFont (abList->font());
276 //abList->resizeRows(currentFont->pixelSize() + 7); 289 //abList->resizeRows(currentFont->pixelSize() + 7);
277 abList->resizeRows(); 290 abList->resizeRows();
278 break; 291 break;
279 } 292 }
280} 293}
281 294
282 295
283 296
284void AddressbookWindow::importvCard() { 297void AddressbookWindow::importvCard() {
285 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 298 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
286 if(!str.isEmpty() ) 299 if(!str.isEmpty() )