summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-03 01:12:20 (UTC)
committer zecke <zecke>2002-03-03 01:12:20 (UTC)
commit0e245156b28b70be5cd98a58a9256fe5e2739562 (patch) (unidiff)
treef24fb55bca70820d6d30444ec128d1afd8e32cd3
parent1b89006f83e7516e13f808742d118e209377abcc (diff)
downloadopie-0e245156b28b70be5cd98a58a9256fe5e2739562.zip
opie-0e245156b28b70be5cd98a58a9256fe5e2739562.tar.gz
opie-0e245156b28b70be5cd98a58a9256fe5e2739562.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index b694e4f..a2b8276 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,236 +1,238 @@
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** 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 20
21#define QTOPIA_INTERNAL_FD
22
21#include "abeditor.h" 23#include "abeditor.h"
22#include "ablabel.h" 24#include "ablabel.h"
23#include "abtable.h" 25#include "abtable.h"
24#include "addresssettings.h" 26#include "addresssettings.h"
25#include "addressbook.h" 27#include "addressbook.h"
26 28
27#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
28#include <qpe/config.h> 30#include <qpe/config.h>
29#include <qpe/contact.h> 31#include <qpe/contact.h>
30#include <qpe/finddialog.h> 32#include <qpe/finddialog.h>
31#include <qpe/global.h> 33#include <qpe/global.h>
32#include <qpe/resource.h> 34#include <qpe/resource.h>
33#include <qpe/ir.h> 35#include <qpe/ir.h>
34#include <qpe/qpemessagebox.h> 36#include <qpe/qpemessagebox.h>
35#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
36 38
37#include <qaction.h> 39#include <qaction.h>
38#include <qdialog.h> 40#include <qdialog.h>
39#include <qdir.h> 41#include <qdir.h>
40#include <qfile.h> 42#include <qfile.h>
41#include <qimage.h> 43#include <qimage.h>
42#include <qlayout.h> 44#include <qlayout.h>
43#include <qpe/qpemenubar.h> 45#include <qpe/qpemenubar.h>
44#include <qmessagebox.h> 46#include <qmessagebox.h>
45#include <qpixmap.h> 47#include <qpixmap.h>
46#include <qpopupmenu.h> 48#include <qpopupmenu.h>
47#include <qpe/qpetoolbar.h> 49#include <qpe/qpetoolbar.h>
48#include <qstringlist.h> 50#include <qstringlist.h>
49#include <qtoolbutton.h> 51#include <qtoolbutton.h>
50#include <qwhatsthis.h> 52#include <qwhatsthis.h>
51 53
52#include <stdlib.h> 54#include <stdlib.h>
53#include <sys/stat.h> 55#include <sys/stat.h>
54#include <sys/types.h> 56#include <sys/types.h>
55#include <fcntl.h> 57#include <fcntl.h>
56#include <unistd.h> 58#include <unistd.h>
57 59
58#include <qdatetime.h> 60#include <qdatetime.h>
59 61
60static QString addressbookOldXMLFilename() 62static QString addressbookOldXMLFilename()
61{ 63{
62 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 64 QString filename = QPEApplication::documentDir() + "addressbook.xml";
63 return filename; 65 return filename;
64} 66}
65 67
66static QString addressbookXMLFilename() 68static QString addressbookXMLFilename()
67{ 69{
68 QString filename = Global::applicationFileName("addressbook", 70 QString filename = Global::applicationFileName("addressbook",
69 "addressbook.xml"); 71 "addressbook.xml");
70 return filename; 72 return filename;
71} 73}
72 74
73static QString addressbookPersonalVCardName() 75static QString addressbookPersonalVCardName()
74{ 76{
75 QString filename = Global::applicationFileName("addressbook", 77 QString filename = Global::applicationFileName("addressbook",
76 "businesscard.vcf"); 78 "businesscard.vcf");
77 return filename; 79 return filename;
78} 80}
79 81
80 82
81AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 83AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
82 WFlags f ) 84 WFlags f )
83 : QMainWindow( parent, name, f ), 85 : QMainWindow( parent, name, f ),
84 abEditor(0), 86 abEditor(0),
85 bAbEditFirstTime(TRUE), 87 bAbEditFirstTime(TRUE),
86 syncing(FALSE) 88 syncing(FALSE)
87{ 89{
88 initFields(); 90 initFields();
89 91
90 setCaption( tr("Contacts") ); 92 setCaption( tr("Contacts") );
91 setIcon( Resource::loadPixmap( "AddressBook" ) ); 93 setIcon( Resource::loadPixmap( "AddressBook" ) );
92 94
93 setToolBarsMovable( FALSE ); 95 setToolBarsMovable( FALSE );
94 96
95 // Create Toolbars 97 // Create Toolbars
96 98
97 QPEToolBar *bar = new QPEToolBar( this ); 99 QPEToolBar *bar = new QPEToolBar( this );
98 bar->setHorizontalStretchable( TRUE ); 100 bar->setHorizontalStretchable( TRUE );
99 101
100 QPEMenuBar *mbList = new QPEMenuBar( bar ); 102 QPEMenuBar *mbList = new QPEMenuBar( bar );
101 mbList->setMargin( 0 ); 103 mbList->setMargin( 0 );
102 104
103 QPopupMenu *edit = new QPopupMenu( this ); 105 QPopupMenu *edit = new QPopupMenu( this );
104 mbList->insertItem( tr( "Contact" ), edit ); 106 mbList->insertItem( tr( "Contact" ), edit );
105 107
106 listTools = new QPEToolBar( this, "list operations" ); 108 listTools = new QPEToolBar( this, "list operations" );
107 109
108 110
109 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 111 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
110 0, this, 0 ); 112 0, this, 0 );
111 actionNew = a; 113 actionNew = a;
112 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 114 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
113 a->addTo( edit ); 115 a->addTo( edit );
114 a->addTo( listTools ); 116 a->addTo( listTools );
115 117
116 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 118 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
117 0, this, 0 ); 119 0, this, 0 );
118 actionEdit = a; 120 actionEdit = a;
119 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 121 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
120 a->addTo( edit ); 122 a->addTo( edit );
121 a->addTo( listTools ); 123 a->addTo( listTools );
122 124
123 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 125 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
124 0, this, 0 ); 126 0, this, 0 );
125 actionTrash = a; 127 actionTrash = a;
126 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 128 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
127 a->addTo( edit ); 129 a->addTo( edit );
128 a->addTo( listTools ); 130 a->addTo( listTools );
129 131
130 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 132 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
131 QString::null, 0, this, 0 ); 133 QString::null, 0, this, 0 );
132 actionFind = a; 134 actionFind = a;
133 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 135 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
134 a->addTo( edit ); 136 a->addTo( edit );
135 a->addTo( listTools ); 137 a->addTo( listTools );
136 138
137 139
138 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 140 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
139 QString::null, 0, this, 0 ); 141 QString::null, 0, this, 0 );
140 a->setEnabled( FALSE ); 142 //a->setEnabled( FALSE ); we got support for it now :) zecke
141 actionMail = a; 143 actionMail = a;
142 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 144 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
143 a->addTo( edit ); 145 a->addTo( edit );
144 a->addTo( listTools ); 146 a->addTo( listTools );
145 147
146 148
147 149
148 if ( Ir::supported() ) { 150 if ( Ir::supported() ) {
149 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 151 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
150 0, this, 0 ); 152 0, this, 0 );
151 actionBeam = a; 153 actionBeam = a;
152 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
153 a->addTo( edit ); 155 a->addTo( edit );
154 a->addTo( listTools ); 156 a->addTo( listTools );
155 } 157 }
156 158
157 edit->insertSeparator(); 159 edit->insertSeparator();
158 160
159 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 161 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
160 actionPersonal = a; 162 actionPersonal = a;
161 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 163 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
162 a->addTo( edit ); 164 a->addTo( edit );
163 165
164 166
165 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 167 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
166 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 168 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
167 a->addTo( edit ); 169 a->addTo( edit );
168 170
169 // Create Views 171 // Create Views
170 172
171 // This is safe to call without checking to see if it exists... 173 // This is safe to call without checking to see if it exists...
172 // not to mention it also does the necessary stuff for the 174 // not to mention it also does the necessary stuff for the
173 // journaling... 175 // journaling...
174 QString str = addressbookXMLFilename(); 176 QString str = addressbookXMLFilename();
175 if ( str.isNull() ) { 177 if ( str.isNull() ) {
176 QMessageBox::warning( this, tr("Out of Space"), 178 QMessageBox::warning( this, tr("Out of Space"),
177 tr("There is not enough space to create\n" 179 tr("There is not enough space to create\n"
178 "neccessary startup files.\n" 180 "neccessary startup files.\n"
179 "\nFree up some space before\nentering data!") 181 "\nFree up some space before\nentering data!")
180 ); 182 );
181 } 183 }
182 184
183 abList = new AbTable( &orderedFields, this, "table" ); 185 abList = new AbTable( &orderedFields, this, "table" );
184 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 186 abList->setHScrollBarMode( QScrollView::AlwaysOff );
185 connect( abList, SIGNAL( empty( bool ) ), 187 connect( abList, SIGNAL( empty( bool ) ),
186 this, SLOT( listIsEmpty( bool ) ) ); 188 this, SLOT( listIsEmpty( bool ) ) );
187 connect( abList, SIGNAL( details() ), 189 connect( abList, SIGNAL( details() ),
188 this, SLOT( slotListView() ) ); 190 this, SLOT( slotListView() ) );
189 connect( abList, SIGNAL(currentChanged(int,int)), 191 connect( abList, SIGNAL(currentChanged(int,int)),
190 this, SLOT(slotUpdateToolbar()) ); 192 this, SLOT(slotUpdateToolbar()) );
191 193
192 mView = 0; 194 mView = 0;
193 195
194 abList->load( addressbookXMLFilename() ); 196 abList->load( addressbookXMLFilename() );
195 if ( QFile::exists(addressbookOldXMLFilename()) ) { 197 if ( QFile::exists(addressbookOldXMLFilename()) ) {
196 abList->load( addressbookOldXMLFilename() ); 198 abList->load( addressbookOldXMLFilename() );
197 QFile::remove(addressbookOldXMLFilename()); 199 QFile::remove(addressbookOldXMLFilename());
198 } 200 }
199 201
200 catMenu = new QPopupMenu( this ); 202 catMenu = new QPopupMenu( this );
201 catMenu->setCheckable( TRUE ); 203 catMenu->setCheckable( TRUE );
202 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 204 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
203 populateCategories(); 205 populateCategories();
204 206
205 mbList->insertItem( tr("View"), catMenu ); 207 mbList->insertItem( tr("View"), catMenu );
206 setCentralWidget( abList ); 208 setCentralWidget( abList );
207 209
208 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 210 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
209} 211}
210 212
211void AddressbookWindow::setDocument( const QString &filename ) 213void AddressbookWindow::setDocument( const QString &filename )
212{ 214{
213 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 215 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
214 216
215 QValueList<Contact> cl = Contact::readVCard( filename ); 217 QValueList<Contact> cl = Contact::readVCard( filename );
216 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 218 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
217 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 219 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
218 // .arg( (*it).fullName() ); 220 // .arg( (*it).fullName() );
219 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 221 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
220 // QMessageBox::Ok ) { 222 // QMessageBox::Ok ) {
221 abList->addEntry( *it ); 223 abList->addEntry( *it );
222 // } 224 // }
223 } 225 }
224 226
225} 227}
226 228
227void AddressbookWindow::resizeEvent( QResizeEvent *e ) 229void AddressbookWindow::resizeEvent( QResizeEvent *e )
228{ 230{
229 QMainWindow::resizeEvent( e ); 231 QMainWindow::resizeEvent( e );
230 232
231 if ( centralWidget() == abList ) 233 if ( centralWidget() == abList )
232 showList(); 234 showList();
233 else if ( centralWidget() == mView ) 235 else if ( centralWidget() == mView )
234 showView(); 236 showView();
235} 237}
236 238