summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp18
-rw-r--r--core/pim/addressbook/addressbook.h4
2 files changed, 19 insertions, 3 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 86d1760..e11cf4c 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -92,96 +92,110 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
92 WFlags f ) 92 WFlags f )
93 : QMainWindow( parent, name, f ), 93 : QMainWindow( parent, name, f ),
94 abEditor(0), 94 abEditor(0),
95 bAbEditFirstTime(TRUE), 95 bAbEditFirstTime(TRUE),
96 syncing(FALSE) 96 syncing(FALSE)
97{ 97{
98 initFields(); 98 initFields();
99 99
100 setCaption( tr("Contacts") ); 100 setCaption( tr("Contacts") );
101 setIcon( Resource::loadPixmap( "AddressBook" ) ); 101 setIcon( Resource::loadPixmap( "AddressBook" ) );
102 102
103 setToolBarsMovable( FALSE ); 103 setToolBarsMovable( FALSE );
104 104
105 // Create Toolbars 105 // Create Toolbars
106 106
107 QPEToolBar *bar = new QPEToolBar( this ); 107 QPEToolBar *bar = new QPEToolBar( this );
108 bar->setHorizontalStretchable( TRUE ); 108 bar->setHorizontalStretchable( TRUE );
109 109
110 QPEMenuBar *mbList = new QPEMenuBar( bar ); 110 QPEMenuBar *mbList = new QPEMenuBar( bar );
111 mbList->setMargin( 0 ); 111 mbList->setMargin( 0 );
112 112
113 QPopupMenu *edit = new QPopupMenu( this ); 113 QPopupMenu *edit = new QPopupMenu( this );
114 mbList->insertItem( tr( "Contact" ), edit ); 114 mbList->insertItem( tr( "Contact" ), edit );
115 115
116 listTools = new QPEToolBar( this, "list operations" ); 116 listTools = new QPEToolBar( this, "list operations" );
117 117
118 118
119 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 119 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
120 0, this, 0 ); 120 0, this, 0 );
121 actionNew = a; 121 actionNew = a;
122 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
123 a->addTo( edit ); 123 a->addTo( edit );
124 a->addTo( listTools ); 124 a->addTo( listTools );
125 125
126 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 126 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
127 0, this, 0 ); 127 0, this, 0 );
128 actionEdit = a; 128 actionEdit = a;
129 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
130 a->addTo( edit ); 130 a->addTo( edit );
131 a->addTo( listTools ); 131 a->addTo( listTools );
132 132
133 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 133 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
134 0, this, 0 ); 134 0, this, 0 );
135 actionTrash = a; 135 actionTrash = a;
136 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 136 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
137 a->addTo( edit ); 137 a->addTo( edit );
138 a->addTo( listTools ); 138 a->addTo( listTools );
139 139
140
141 // make it possible to go directly to businesscard via qcop call
142#if defined(Q_WS_QWS)
143#if !defined(QT_NO_COP)
144 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
145 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
146 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
147#endif
148#endif
149
150
151
152
153
140#ifndef MAKE_FOR_SHARP_ROM 154#ifndef MAKE_FOR_SHARP_ROM
141 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 155 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
142 QString::null, 0, this, 0 ); 156 QString::null, 0, this, 0 );
143 actionFind = a; 157 actionFind = a;
144 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 158 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
145 a->addTo( edit ); 159 a->addTo( edit );
146 a->addTo( listTools ); 160 a->addTo( listTools );
147#endif 161#endif
148 162
149 163
150 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 164 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
151 QString::null, 0, this, 0 ); 165 QString::null, 0, this, 0 );
152 //a->setEnabled( FALSE ); we got support for it now :) zecke 166 //a->setEnabled( FALSE ); we got support for it now :) zecke
153 actionMail = a; 167 actionMail = a;
154 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 168 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
155 a->addTo( edit ); 169 a->addTo( edit );
156 a->addTo( listTools ); 170 a->addTo( listTools );
157 171
158 172
159 173
160 if ( Ir::supported() ) { 174 if ( Ir::supported() ) {
161 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 175 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
162 0, this, 0 ); 176 0, this, 0 );
163 actionBeam = a; 177 actionBeam = a;
164 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 178 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
165 a->addTo( edit ); 179 a->addTo( edit );
166 a->addTo( listTools ); 180 a->addTo( listTools );
167 } 181 }
168 182
169 edit->insertSeparator(); 183 edit->insertSeparator();
170 184
171 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 185 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
172 actionPersonal = a; 186 actionPersonal = a;
173 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 187 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
174 a->addTo( edit ); 188 a->addTo( edit );
175 189
176 190
177 edit->insertSeparator(); 191 edit->insertSeparator();
178 192
179 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 193 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
180 actionPersonal = a; 194 actionPersonal = a;
181 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 195 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
182 a->addTo( edit ); 196 a->addTo( edit );
183 197
184 198
185 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 199 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
186 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 200 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
187 a->addTo( edit ); 201 a->addTo( edit );
@@ -205,140 +219,142 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
205 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 219 QVBoxLayout *vb = new QVBoxLayout( listContainer );
206 220
207 abList = new AbTable( &orderedFields, listContainer, "table" ); 221 abList = new AbTable( &orderedFields, listContainer, "table" );
208 vb->addWidget(abList); 222 vb->addWidget(abList);
209 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 223 abList->setHScrollBarMode( QScrollView::AlwaysOff );
210 connect( abList, SIGNAL( empty( bool ) ), 224 connect( abList, SIGNAL( empty( bool ) ),
211 this, SLOT( listIsEmpty( bool ) ) ); 225 this, SLOT( listIsEmpty( bool ) ) );
212 connect( abList, SIGNAL( details() ), 226 connect( abList, SIGNAL( details() ),
213 this, SLOT( slotListView() ) ); 227 this, SLOT( slotListView() ) );
214 connect( abList, SIGNAL(currentChanged(int,int)), 228 connect( abList, SIGNAL(currentChanged(int,int)),
215 this, SLOT(slotUpdateToolbar()) ); 229 this, SLOT(slotUpdateToolbar()) );
216 230
217 mView = 0; 231 mView = 0;
218 232
219 abList->load( addressbookXMLFilename() ); 233 abList->load( addressbookXMLFilename() );
220 if ( QFile::exists(addressbookOldXMLFilename()) ) { 234 if ( QFile::exists(addressbookOldXMLFilename()) ) {
221 abList->load( addressbookOldXMLFilename() ); 235 abList->load( addressbookOldXMLFilename() );
222 QFile::remove(addressbookOldXMLFilename()); 236 QFile::remove(addressbookOldXMLFilename());
223 } 237 }
224 238
225 pLabel = new LetterPicker( listContainer ); 239 pLabel = new LetterPicker( listContainer );
226 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 240 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
227 vb->addWidget(pLabel); 241 vb->addWidget(pLabel);
228 catMenu = new QPopupMenu( this ); 242 catMenu = new QPopupMenu( this );
229 catMenu->setCheckable( TRUE ); 243 catMenu->setCheckable( TRUE );
230 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 244 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
231 populateCategories(); 245 populateCategories();
232 246
233 mbList->insertItem( tr("View"), catMenu ); 247 mbList->insertItem( tr("View"), catMenu );
234 setCentralWidget( listContainer ); 248 setCentralWidget( listContainer );
235 249
236 fontMenu = new QPopupMenu(this); 250 fontMenu = new QPopupMenu(this);
237 fontMenu->setCheckable( true ); 251 fontMenu->setCheckable( true );
238 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 252 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
239 253
240 fontMenu->insertItem(tr( "Small" ), 0); 254 fontMenu->insertItem(tr( "Small" ), 0);
241 fontMenu->insertItem(tr( "Normal" ), 1); 255 fontMenu->insertItem(tr( "Normal" ), 1);
242 fontMenu->insertItem(tr( "Large" ), 2); 256 fontMenu->insertItem(tr( "Large" ), 2);
243 257
244 defaultFont = new QFont( abList->font() ); 258 defaultFont = new QFont( abList->font() );
245 259
246 slotSetFont(startFontSize); 260 slotSetFont(startFontSize);
247 261
248 mbList->insertItem( tr("Font"), fontMenu); 262 mbList->insertItem( tr("Font"), fontMenu);
249 setCentralWidget(listContainer); 263 setCentralWidget(listContainer);
250 264
251 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 265 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
252} 266}
267
268
253void AddressbookWindow::slotSetFont( int size ) { 269void AddressbookWindow::slotSetFont( int size ) {
254 270
255 if (size > 2 || size < 0) 271 if (size > 2 || size < 0)
256 size = 1; 272 size = 1;
257 273
258 startFontSize = size; 274 startFontSize = size;
259 275
260 QFont *currentFont; 276 QFont *currentFont;
261 277
262 switch (size) { 278 switch (size) {
263 case 0: 279 case 0:
264 fontMenu->setItemChecked(0, true); 280 fontMenu->setItemChecked(0, true);
265 fontMenu->setItemChecked(1, false); 281 fontMenu->setItemChecked(1, false);
266 fontMenu->setItemChecked(2, false); 282 fontMenu->setItemChecked(2, false);
267 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 283 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
268 currentFont = new QFont (abList->font()); 284 currentFont = new QFont (abList->font());
269 abList->resizeRows(currentFont->pixelSize() + 7); 285 abList->resizeRows(currentFont->pixelSize() + 7);
270 break; 286 break;
271 case 1: 287 case 1:
272 fontMenu->setItemChecked(0, false); 288 fontMenu->setItemChecked(0, false);
273 fontMenu->setItemChecked(1, true); 289 fontMenu->setItemChecked(1, true);
274 fontMenu->setItemChecked(2, false); 290 fontMenu->setItemChecked(2, false);
275 abList->setFont( *defaultFont ); 291 abList->setFont( *defaultFont );
276 currentFont = new QFont (abList->font()); 292 currentFont = new QFont (abList->font());
277 abList->resizeRows(currentFont->pixelSize() + 7); 293 abList->resizeRows(currentFont->pixelSize() + 7);
278 break; 294 break;
279 case 2: 295 case 2:
280 fontMenu->setItemChecked(0, false); 296 fontMenu->setItemChecked(0, false);
281 fontMenu->setItemChecked(1, false); 297 fontMenu->setItemChecked(1, false);
282 fontMenu->setItemChecked(2, true); 298 fontMenu->setItemChecked(2, true);
283 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 299 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
284 currentFont = new QFont (abList->font()); 300 currentFont = new QFont (abList->font());
285 abList->resizeRows(currentFont->pixelSize() + 7); 301 abList->resizeRows(currentFont->pixelSize() + 7);
286 break; 302 break;
287 } 303 }
288} 304}
289 305
290 306
291 307
292void AddressbookWindow::importvCard() { 308void AddressbookWindow::importvCard() {
293 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 309 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
294 if(!str.isEmpty() ) 310 if(!str.isEmpty() )
295 setDocument((const QString&) str ); 311 setDocument((const QString&) str );
296 312
297} 313}
298 314
299void AddressbookWindow::setDocument( const QString &filename ) 315void AddressbookWindow::setDocument( const QString &filename )
300{ 316{
301 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 317 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
302 318
303 QValueList<Contact> cl = Contact::readVCard( filename ); 319 QValueList<Contact> cl = Contact::readVCard( filename );
304 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 320 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
305// QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 321// QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
306// .arg( (*it).fullName() ); 322// .arg( (*it).fullName() );
307// if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 323// if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
308// QMessageBox::Ok ) { 324// QMessageBox::Ok ) {
309 abList->addEntry( *it ); 325 abList->addEntry( *it );
310// } 326// }
311 } 327 }
312 328
313} 329}
314 330
315void AddressbookWindow::resizeEvent( QResizeEvent *e ) 331void AddressbookWindow::resizeEvent( QResizeEvent *e )
316{ 332{
317 QMainWindow::resizeEvent( e ); 333 QMainWindow::resizeEvent( e );
318 334
319 if ( centralWidget() == listContainer ) 335 if ( centralWidget() == listContainer )
320 showList(); 336 showList();
321 else if ( centralWidget() == mView ) 337 else if ( centralWidget() == mView )
322 showView(); 338 showView();
323} 339}
324 340
325AddressbookWindow::~AddressbookWindow() 341AddressbookWindow::~AddressbookWindow()
326{ 342{
327 Config cfg("AddressBook"); 343 Config cfg("AddressBook");
328 cfg.setGroup("Font"); 344 cfg.setGroup("Font");
329 cfg.writeEntry("fontSize", startFontSize); 345 cfg.writeEntry("fontSize", startFontSize);
330} 346}
331 347
332void AddressbookWindow::slotUpdateToolbar() 348void AddressbookWindow::slotUpdateToolbar()
333{ 349{
334 Contact ce = abList->currentEntry(); 350 Contact ce = abList->currentEntry();
335 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 351 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
336} 352}
337 353
338void AddressbookWindow::showList() 354void AddressbookWindow::showList()
339{ 355{
340 if ( mView ) mView->hide(); 356 if ( mView ) mView->hide();
341 setCentralWidget( listContainer ); 357 setCentralWidget( listContainer );
342 listContainer->show(); 358 listContainer->show();
343 // update our focues... (or use a stack widget!); 359 // update our focues... (or use a stack widget!);
344 abList->setFocus(); 360 abList->setFocus();
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index da43731..34ca85d 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -14,95 +14,95 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef Addressbook_H 20#ifndef Addressbook_H
21#define Addressbook_H 21#define Addressbook_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qvaluelist.h> 24#include <qvaluelist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26 26
27class ContactEditor; 27class ContactEditor;
28class AbLabel; 28class AbLabel;
29class AbTable; 29class AbTable;
30class QPEToolBar; 30class QPEToolBar;
31class QPopupMenu; 31class QPopupMenu;
32class QToolButton; 32class QToolButton;
33class QDialog; 33class QDialog;
34class Ir; 34class Ir;
35class QAction; 35class QAction;
36class LetterPicker; 36class LetterPicker;
37 37
38class AddressbookWindow: public QMainWindow 38class AddressbookWindow: public QMainWindow
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 42 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
43 ~AddressbookWindow(); 43 ~AddressbookWindow();
44 44
45protected: 45protected:
46 void resizeEvent( QResizeEvent * e ); 46 void resizeEvent( QResizeEvent * e );
47 void showList(); 47 void showList();
48 void showView(); 48 void showView();
49 enum EntryMode { NewEntry=0, EditEntry }; 49 enum EntryMode { NewEntry=0, EditEntry };
50 void editPersonal(); 50 void editPersonal();
51 void editEntry( EntryMode ); 51 void editEntry( EntryMode );
52 void closeEvent( QCloseEvent *e ); 52 void closeEvent( QCloseEvent *e );
53 bool save(); 53 bool save();
54 54
55public slots: 55public slots:
56 void flush(); 56 void flush();
57 void reload(); 57 void reload();
58 void appMessage(const QCString &, const QByteArray &); 58 void appMessage(const QCString &, const QByteArray &);
59 void setDocument( const QString & ); 59 void setDocument( const QString & );
60 60
61private slots: 61private slots:
62 void importvCard(); 62 void importvCard();
63 void slotListNew(); 63 void slotListNew();
64 void slotListView(); 64 void slotListView();
65 void slotListDelete(); 65 void slotListDelete();
66 void slotViewBack(); 66 void slotViewBack();
67 void slotViewEdit(); 67 void slotViewEdit();
68 void slotPersonalView(); 68 void slotPersonalView();
69 void listIsEmpty( bool ); 69 void listIsEmpty( bool );
70 void slotSettings(); 70 void slotSettings();
71 void writeMail(); 71 void writeMail();
72 void slotBeam(); 72 void slotBeam();
73 void beamDone( Ir * ); 73 void beamDone( Ir * );
74 void slotFind(); 74 void slotFind();
75 void slotSetCategory( int ); 75 void slotSetCategory( int );
76 void slotSetLetter( char ); 76 void slotSetLetter( char );
77 void slotUpdateToolbar(); 77 void slotUpdateToolbar();
78 void slotSetFont(int); 78 void slotSetFont(int);
79private: 79private:
80 void initFields(); // inititialize our fields... 80 void initFields(); // inititialize our fields...
81 AbLabel *abView(); 81 AbLabel *abView();
82 void populateCategories(); 82 void populateCategories();
83 83
84 QPopupMenu *catMenu, *fontMenu; 84 QPopupMenu *catMenu, *fontMenu;
85 QPEToolBar *listTools; 85 QPEToolBar *listTools;
86 QToolButton *deleteButton; 86 QToolButton *deleteButton;
87 QValueList<int> allFields, 87 QValueList<int> allFields,
88 orderedFields; 88 orderedFields;
89 QStringList slOrderedFields; 89 QStringList slOrderedFields;
90 enum Panes { paneList=0, paneView, paneEdit }; 90 enum Panes { paneList=0, paneView, paneEdit };
91 ContactEditor *abEditor; 91 ContactEditor *abEditor;
92 AbLabel *mView; 92 AbLabel *mView;
93 LetterPicker *pLabel; 93 LetterPicker *pLabel;
94 AbTable *abList; 94 AbTable *abList;
95 QWidget *listContainer; 95 QWidget *listContainer;
96 96
97 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, 97 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
98 *actionPersonal, *actionMail; 98 *actionPersonal, *actionMail;
99 99
100 bool bAbEditFirstTime; 100 bool bAbEditFirstTime;
101 int viewMargin; 101 int viewMargin;
102 102
103 bool syncing; 103 bool syncing;
104 QFont *defaultFont; 104 QFont *defaultFont;
105 int startFontSize; 105 int startFontSize;
106}; 106};
107 107
108#endif 108#endif