-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 4fa9253..b4734a4 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,247 +1,247 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
21 | 21 | ||
22 | // #include "addresssettings.h" | 22 | // #include "addresssettings.h" |
23 | #include "addressbook.h" | 23 | #include "addressbook.h" |
24 | 24 | ||
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/ofileselector.h> | 26 | #include <opie2/ofileselector.h> |
27 | #include <opie2/ofiledialog.h> | 27 | #include <opie2/ofiledialog.h> |
28 | #include <opie2/opimcontact.h> | 28 | #include <opie2/opimcontact.h> |
29 | #include <opie2/ocontactaccessbackend_vcard.h> | 29 | #include <opie2/ocontactaccessbackend_vcard.h> |
30 | #include <opie2/oresource.h> | 30 | #include <opie2/oresource.h> |
31 | 31 | ||
32 | #include <qpe/ir.h> | 32 | #include <qpe/ir.h> |
33 | #include <qpe/qpemessagebox.h> | 33 | #include <qpe/qpemessagebox.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <unistd.h> | 46 | #include <unistd.h> |
47 | 47 | ||
48 | 48 | ||
49 | #include "picker.h" | 49 | #include "picker.h" |
50 | #include "configdlg.h" | 50 | #include "configdlg.h" |
51 | 51 | ||
52 | extern QString addressbookPersonalVCardName(); | 52 | extern QString addressbookPersonalVCardName(); |
53 | 53 | ||
54 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 54 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
55 | WFlags /*f*/ ) | 55 | WFlags /*f*/ ) |
56 | : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", | 56 | : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", |
57 | parent, name, WType_TopLevel | WStyle_ContextHelp ), | 57 | parent, name, WType_TopLevel | WStyle_ContextHelp ), |
58 | abEditor(0l), | 58 | abEditor(0l), |
59 | syncing(false) | 59 | syncing(false) |
60 | { | 60 | { |
61 | setCaption( tr( "Contacts" ) ); | 61 | setCaption( tr( "Contacts" ) ); |
62 | 62 | ||
63 | isLoading = true; | 63 | isLoading = true; |
64 | 64 | ||
65 | m_config.load(); | 65 | m_config.load(); |
66 | 66 | ||
67 | // Create Views | 67 | // Create Views |
68 | m_listContainer = new QWidget( this ); | 68 | m_listContainer = new QWidget( this ); |
69 | QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); | 69 | QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); |
70 | 70 | ||
71 | m_abView = new AbView( m_listContainer, m_config.orderList() ); | 71 | m_abView = new AbView( m_listContainer, m_config.orderList() ); |
72 | vb->addWidget( m_abView ); | 72 | vb->addWidget( m_abView ); |
73 | connect( m_abView, SIGNAL(signalViewSwitched(int)), | 73 | connect( m_abView, SIGNAL(signalViewSwitched(int)), |
74 | this, SLOT(slotViewSwitched(int)) ); | 74 | this, SLOT(slotViewSwitched(int)) ); |
75 | 75 | ||
76 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 76 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
77 | 77 | ||
78 | // Letter Picker | 78 | // Letter Picker |
79 | pLabel = new LetterPicker( m_listContainer ); | 79 | pLabel = new LetterPicker( m_listContainer ); |
80 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 80 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
81 | connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); | 81 | connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); |
82 | 82 | ||
83 | vb->addWidget( pLabel ); | 83 | vb->addWidget( pLabel ); |
84 | 84 | ||
85 | // Quick search bar | 85 | // Quick search bar |
86 | m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); | 86 | m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); |
87 | m_searchBar->setHorizontalStretchable( true ); | 87 | m_searchBar->setHorizontalStretchable( true ); |
88 | m_searchBar->hide(); | 88 | m_searchBar->hide(); |
89 | m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); | 89 | m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); |
90 | 90 | ||
91 | m_searchBar->setStretchableWidget( m_searchEdit ); | 91 | m_searchBar->setStretchableWidget( m_searchEdit ); |
92 | connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); | 92 | connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); |
93 | 93 | ||
94 | QAction *a = new QAction( tr( "Start Search" ), | 94 | QAction *a = new QAction( tr( "Start Search" ), |
95 | Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), | 95 | Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), |
96 | QString::null, 0, this, 0 ); | 96 | QString::null, 0, this, 0 ); |
97 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 97 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
98 | a->addTo( m_searchBar ); | 98 | a->addTo( m_searchBar ); |
99 | 99 | ||
100 | // Insert Contact menu items | 100 | // Insert Contact menu items |
101 | QActionGroup *items = new QActionGroup( this, QString::null, false ); | 101 | QActionGroup *items = new QActionGroup( this, QString::null, false ); |
102 | 102 | ||
103 | m_actionMail = new QAction( tr( "Write Mail To" ), | 103 | m_actionMail = new QAction( tr( "Write Mail To" ), |
104 | Opie::Core::OResource::loadPixmap( "addressbook/sendmail" ), | 104 | Opie::Core::OResource::loadPixmap( "addressbook/sendmail", Opie::Core::OResource::SmallIcon ), |
105 | QString::null, 0, items, 0 ); | 105 | QString::null, 0, items, 0 ); |
106 | connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); | 106 | connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); |
107 | 107 | ||
108 | a = new QAction( tr("Import vCard"), | 108 | a = new QAction( tr("Import vCard"), |
109 | Opie::Core::OResource::loadPixmap( "addressbook/fileimport" ), | 109 | Opie::Core::OResource::loadPixmap( "addressbook/fileimport", Opie::Core::OResource::SmallIcon ), |
110 | QString::null, 0, items, 0 ); | 110 | QString::null, 0, items, 0 ); |
111 | connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); | 111 | connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); |
112 | 112 | ||
113 | a = new QAction( tr("Export vCard"), | 113 | a = new QAction( tr("Export vCard"), |
114 | Opie::Core::OResource::loadPixmap( "addressbook/fileexport" ), | 114 | Opie::Core::OResource::loadPixmap( "addressbook/fileexport", Opie::Core::OResource::SmallIcon ), |
115 | QString::null, 0, items, 0 ); | 115 | QString::null, 0, items, 0 ); |
116 | connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); | 116 | connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); |
117 | 117 | ||
118 | m_actionPersonal = new QAction( tr("My Personal Details"), | 118 | m_actionPersonal = new QAction( tr("My Personal Details"), |
119 | Opie::Core::OResource::loadPixmap( "addressbook/identity" ), | 119 | Opie::Core::OResource::loadPixmap( "addressbook/identity", Opie::Core::OResource::SmallIcon ), |
120 | QString::null, 0, items, 0 , true ); | 120 | QString::null, 0, items, 0 , true ); |
121 | connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); | 121 | connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); |
122 | 122 | ||
123 | insertItemMenuItems( items ); | 123 | insertItemMenuItems( items ); |
124 | 124 | ||
125 | // Insert View menu items | 125 | // Insert View menu items |
126 | items = new QActionGroup( this, QString::null, false ); | 126 | items = new QActionGroup( this, QString::null, false ); |
127 | 127 | ||
128 | a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); | 128 | a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); |
129 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); | 129 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); |
130 | 130 | ||
131 | insertViewMenuItems( items ); | 131 | insertViewMenuItems( items ); |
132 | 132 | ||
133 | // Fontsize | 133 | // Fontsize |
134 | defaultFont = new QFont( m_abView->font() ); | 134 | defaultFont = new QFont( m_abView->font() ); |
135 | slotSetFont(m_config.fontSize()); | 135 | slotSetFont(m_config.fontSize()); |
136 | m_curFontSize = m_config.fontSize(); | 136 | m_curFontSize = m_config.fontSize(); |
137 | 137 | ||
138 | setCentralWidget(m_listContainer); | 138 | setCentralWidget(m_listContainer); |
139 | 139 | ||
140 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; | 140 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; |
141 | connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); | 141 | connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); |
142 | connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); | 142 | connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); |
143 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 143 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
144 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 144 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
145 | 145 | ||
146 | isLoading = false; | 146 | isLoading = false; |
147 | 147 | ||
148 | // Handle category selection | 148 | // Handle category selection |
149 | setViewCategory( m_config.category() ); | 149 | setViewCategory( m_config.category() ); |
150 | m_abView->setShowByCategory( m_config.category() ); | 150 | m_abView->setShowByCategory( m_config.category() ); |
151 | connect( this, SIGNAL(categorySelected(const QString&)), | 151 | connect( this, SIGNAL(categorySelected(const QString&)), |
152 | this, SLOT(slotSetCategory(const QString&)) ); | 152 | this, SLOT(slotSetCategory(const QString&)) ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void AddressbookWindow::slotSetFont( int size ) | 155 | void AddressbookWindow::slotSetFont( int size ) |
156 | { | 156 | { |
157 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; | 157 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; |
158 | 158 | ||
159 | if (size > 2 || size < 0) | 159 | if (size > 2 || size < 0) |
160 | size = 1; | 160 | size = 1; |
161 | 161 | ||
162 | m_config.setFontSize( size ); | 162 | m_config.setFontSize( size ); |
163 | 163 | ||
164 | QFont *currentFont; | 164 | QFont *currentFont; |
165 | 165 | ||
166 | switch (size) { | 166 | switch (size) { |
167 | case 0: | 167 | case 0: |
168 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 168 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
169 | currentFont = new QFont (m_abView->font()); | 169 | currentFont = new QFont (m_abView->font()); |
170 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 170 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
171 | // abList->resizeRows(); | 171 | // abList->resizeRows(); |
172 | break; | 172 | break; |
173 | case 1: | 173 | case 1: |
174 | m_abView->setFont( *defaultFont ); | 174 | m_abView->setFont( *defaultFont ); |
175 | currentFont = new QFont (m_abView->font()); | 175 | currentFont = new QFont (m_abView->font()); |
176 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 176 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
177 | // abList->resizeRows(); | 177 | // abList->resizeRows(); |
178 | break; | 178 | break; |
179 | case 2: | 179 | case 2: |
180 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 180 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
181 | currentFont = new QFont (m_abView->font()); | 181 | currentFont = new QFont (m_abView->font()); |
182 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 182 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
183 | // abList->resizeRows(); | 183 | // abList->resizeRows(); |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | 189 | ||
190 | void AddressbookWindow::importvCard() { | 190 | void AddressbookWindow::importvCard() { |
191 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 191 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
192 | if(!str.isEmpty() ){ | 192 | if(!str.isEmpty() ){ |
193 | setDocument((const QString&) str ); | 193 | setDocument((const QString&) str ); |
194 | } | 194 | } |
195 | 195 | ||
196 | } | 196 | } |
197 | void AddressbookWindow::exportvCard() | 197 | void AddressbookWindow::exportvCard() |
198 | { | 198 | { |
199 | odebug << "void AddressbookWindow::exportvCard()" << oendl; | 199 | odebug << "void AddressbookWindow::exportvCard()" << oendl; |
200 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 200 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
201 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 201 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
202 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; | 202 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; |
203 | Opie::OPimContact curCont = m_abView->currentEntry(); | 203 | Opie::OPimContact curCont = m_abView->currentEntry(); |
204 | if ( !curCont.isEmpty() ){ | 204 | if ( !curCont.isEmpty() ){ |
205 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 205 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
206 | filename ); | 206 | filename ); |
207 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 207 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
208 | if ( access ){ | 208 | if ( access ){ |
209 | access->add( curCont ); | 209 | access->add( curCont ); |
210 | access->save(); | 210 | access->save(); |
211 | } | 211 | } |
212 | delete access; | 212 | delete access; |
213 | }else | 213 | }else |
214 | QMessageBox::critical( 0, "Export VCard", | 214 | QMessageBox::critical( 0, "Export VCard", |
215 | QString( tr( "You have to select a contact !") ) ); | 215 | QString( tr( "You have to select a contact !") ) ); |
216 | 216 | ||
217 | }else | 217 | }else |
218 | QMessageBox::critical( 0, "Export VCard", | 218 | QMessageBox::critical( 0, "Export VCard", |
219 | QString( tr( "You have to set a filename !") ) ); | 219 | QString( tr( "You have to set a filename !") ) ); |
220 | } | 220 | } |
221 | 221 | ||
222 | void AddressbookWindow::setDocument( const QString &filename ) | 222 | void AddressbookWindow::setDocument( const QString &filename ) |
223 | { | 223 | { |
224 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; | 224 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; |
225 | 225 | ||
226 | // Switch to default backend. This should avoid to import into | 226 | // Switch to default backend. This should avoid to import into |
227 | // the personal database accidently. | 227 | // the personal database accidently. |
228 | if ( m_actionPersonal->isOn() ){ | 228 | if ( m_actionPersonal->isOn() ){ |
229 | m_actionPersonal->setOn( false ); | 229 | m_actionPersonal->setOn( false ); |
230 | slotPersonalView(); | 230 | slotPersonalView(); |
231 | } | 231 | } |
232 | 232 | ||
233 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 233 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
234 | 234 | ||
235 | 235 | ||
236 | 236 | ||
237 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 237 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
238 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 238 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
239 | tr( "&Yes" ), tr( "&No" ), QString::null, | 239 | tr( "&Yes" ), tr( "&No" ), QString::null, |
240 | 0, // Enter == button 0 | 240 | 0, // Enter == button 0 |
241 | 2 ) ) { // Escape == button 2 | 241 | 2 ) ) { // Escape == button 2 |
242 | case 0: | 242 | case 0: |
243 | odebug << "YES clicked" << oendl; | 243 | odebug << "YES clicked" << oendl; |
244 | break; | 244 | break; |
245 | case 1: | 245 | case 1: |
246 | odebug << "NO clicked" << oendl; | 246 | odebug << "NO clicked" << oendl; |
247 | return; | 247 | return; |