author | drw <drw> | 2005-02-07 22:08:38 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-07 22:08:38 (UTC) |
commit | 2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07 (patch) (unidiff) | |
tree | dd1c91d19c4e53fea60245e3d4d535ac176ee2c8 | |
parent | 7631c91d6c495a6c60e87a9ab131280f31ee4c87 (diff) | |
download | opie-2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07.zip opie-2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07.tar.gz opie-2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07.tar.bz2 |
Fix contact edit dialog captioning
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 75e539a..6984501 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,883 +1,886 @@ | |||
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 | 30 | ||
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
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 <qtoolbar.h> | 35 | // #include <qtoolbar.h> |
36 | // #include <qmenubar.h> | 36 | // #include <qmenubar.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | 38 | ||
39 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qtoolbutton.h> | 42 | #include <qtoolbutton.h> |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <sys/types.h> | 46 | #include <sys/types.h> |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | #include "picker.h" | 51 | #include "picker.h" |
52 | #include "configdlg.h" | 52 | #include "configdlg.h" |
53 | 53 | ||
54 | extern QString addressbookPersonalVCardName(); | 54 | extern QString addressbookPersonalVCardName(); |
55 | 55 | ||
56 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 56 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
57 | WFlags /*f*/ ) | 57 | WFlags /*f*/ ) |
58 | : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", | 58 | : Opie::OPimMainWindow( "Addressbook", "Contacts", tr( "Contact" ), "AddressBook", |
59 | parent, name, WType_TopLevel | WStyle_ContextHelp ), | 59 | parent, name, WType_TopLevel | WStyle_ContextHelp ), |
60 | abEditor(0l), | 60 | abEditor(0l), |
61 | syncing(false) | 61 | syncing(false) |
62 | { | 62 | { |
63 | setCaption( tr( "Contacts" ) ); | 63 | setCaption( tr( "Contacts" ) ); |
64 | 64 | ||
65 | isLoading = true; | 65 | isLoading = true; |
66 | 66 | ||
67 | m_config.load(); | 67 | m_config.load(); |
68 | 68 | ||
69 | // Create Views | 69 | // Create Views |
70 | m_listContainer = new QWidget( this ); | 70 | m_listContainer = new QWidget( this ); |
71 | QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); | 71 | QVBoxLayout *vb = new QVBoxLayout( m_listContainer ); |
72 | 72 | ||
73 | m_abView = new AbView( m_listContainer, m_config.orderList() ); | 73 | m_abView = new AbView( m_listContainer, m_config.orderList() ); |
74 | vb->addWidget( m_abView ); | 74 | vb->addWidget( m_abView ); |
75 | connect( m_abView, SIGNAL(signalViewSwitched(int)), | 75 | connect( m_abView, SIGNAL(signalViewSwitched(int)), |
76 | this, SLOT(slotViewSwitched(int)) ); | 76 | this, SLOT(slotViewSwitched(int)) ); |
77 | 77 | ||
78 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 78 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
79 | 79 | ||
80 | // Letter Picker | 80 | // Letter Picker |
81 | pLabel = new LetterPicker( m_listContainer ); | 81 | pLabel = new LetterPicker( m_listContainer ); |
82 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 82 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
83 | connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); | 83 | connect(m_abView, SIGNAL(signalClearLetterPicker()), pLabel, SLOT(clear()) ); |
84 | 84 | ||
85 | vb->addWidget( pLabel ); | 85 | vb->addWidget( pLabel ); |
86 | 86 | ||
87 | // Quick search bar | 87 | // Quick search bar |
88 | m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); | 88 | m_searchBar = new OFloatBar( "Search", this, QMainWindow::Top, true ); |
89 | m_searchBar->setHorizontalStretchable( true ); | 89 | m_searchBar->setHorizontalStretchable( true ); |
90 | m_searchBar->hide(); | 90 | m_searchBar->hide(); |
91 | m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); | 91 | m_searchEdit = new QLineEdit( m_searchBar, "m_searchEdit" ); |
92 | 92 | ||
93 | m_searchBar->setStretchableWidget( m_searchEdit ); | 93 | m_searchBar->setStretchableWidget( m_searchEdit ); |
94 | connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); | 94 | connect( m_searchEdit, SIGNAL(returnPressed()), this, SLOT(slotFind()) ); |
95 | 95 | ||
96 | QAction *a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 96 | QAction *a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "find" ), 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" ), Resource::loadPixmap( "addressbook/sendmail" ), | 103 | m_actionMail = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
104 | QString::null, 0, items, 0 ); | 104 | QString::null, 0, items, 0 ); |
105 | connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); | 105 | connect( m_actionMail, SIGNAL(activated()), this, SLOT(writeMail()) ); |
106 | 106 | ||
107 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), | 107 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), |
108 | QString::null, 0, items, 0 ); | 108 | QString::null, 0, items, 0 ); |
109 | connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); | 109 | connect( a, SIGNAL(activated()), this, SLOT(importvCard()) ); |
110 | 110 | ||
111 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), | 111 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), |
112 | QString::null, 0, items, 0 ); | 112 | QString::null, 0, items, 0 ); |
113 | connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); | 113 | connect( a, SIGNAL(activated()), this, SLOT(exportvCard()) ); |
114 | 114 | ||
115 | m_actionPersonal = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 115 | m_actionPersonal = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
116 | QString::null, 0, items, 0 , true ); | 116 | QString::null, 0, items, 0 , true ); |
117 | connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); | 117 | connect( m_actionPersonal, SIGNAL(activated()), this, SLOT(slotPersonalView()) ); |
118 | 118 | ||
119 | insertItemMenuItems( items ); | 119 | insertItemMenuItems( items ); |
120 | 120 | ||
121 | // Insert View menu items | 121 | // Insert View menu items |
122 | items = new QActionGroup( this, QString::null, false ); | 122 | items = new QActionGroup( this, QString::null, false ); |
123 | 123 | ||
124 | a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); | 124 | a = new QAction( tr("Show quick search bar"),QString::null, 0, items, 0, true ); |
125 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); | 125 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowFind(bool)) ); |
126 | 126 | ||
127 | insertViewMenuItems( items ); | 127 | insertViewMenuItems( items ); |
128 | 128 | ||
129 | // Fontsize | 129 | // Fontsize |
130 | defaultFont = new QFont( m_abView->font() ); | 130 | defaultFont = new QFont( m_abView->font() ); |
131 | slotSetFont(m_config.fontSize()); | 131 | slotSetFont(m_config.fontSize()); |
132 | m_curFontSize = m_config.fontSize(); | 132 | m_curFontSize = m_config.fontSize(); |
133 | 133 | ||
134 | setCentralWidget(m_listContainer); | 134 | setCentralWidget(m_listContainer); |
135 | 135 | ||
136 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; | 136 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; |
137 | connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); | 137 | connect( qApp, SIGNAL(flush()), this, SLOT(flush()) ); |
138 | connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); | 138 | connect( qApp, SIGNAL(reload()), this, SLOT(reload()) ); |
139 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 139 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
140 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 140 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
141 | 141 | ||
142 | isLoading = false; | 142 | isLoading = false; |
143 | 143 | ||
144 | // Handle category selection | 144 | // Handle category selection |
145 | setViewCategory( m_config.category() ); | 145 | setViewCategory( m_config.category() ); |
146 | m_abView->setShowByCategory( m_config.category() ); | 146 | m_abView->setShowByCategory( m_config.category() ); |
147 | connect( this, SIGNAL(categorySelected(const QString&)), | 147 | connect( this, SIGNAL(categorySelected(const QString&)), |
148 | this, SLOT(slotSetCategory(const QString&)) ); | 148 | this, SLOT(slotSetCategory(const QString&)) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void AddressbookWindow::slotSetFont( int size ) | 151 | void AddressbookWindow::slotSetFont( int size ) |
152 | { | 152 | { |
153 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; | 153 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; |
154 | 154 | ||
155 | if (size > 2 || size < 0) | 155 | if (size > 2 || size < 0) |
156 | size = 1; | 156 | size = 1; |
157 | 157 | ||
158 | m_config.setFontSize( size ); | 158 | m_config.setFontSize( size ); |
159 | 159 | ||
160 | QFont *currentFont; | 160 | QFont *currentFont; |
161 | 161 | ||
162 | switch (size) { | 162 | switch (size) { |
163 | case 0: | 163 | case 0: |
164 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 164 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
165 | currentFont = new QFont (m_abView->font()); | 165 | currentFont = new QFont (m_abView->font()); |
166 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 166 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
167 | // abList->resizeRows(); | 167 | // abList->resizeRows(); |
168 | break; | 168 | break; |
169 | case 1: | 169 | case 1: |
170 | m_abView->setFont( *defaultFont ); | 170 | m_abView->setFont( *defaultFont ); |
171 | currentFont = new QFont (m_abView->font()); | 171 | currentFont = new QFont (m_abView->font()); |
172 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 172 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
173 | // abList->resizeRows(); | 173 | // abList->resizeRows(); |
174 | break; | 174 | break; |
175 | case 2: | 175 | case 2: |
176 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 176 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
177 | currentFont = new QFont (m_abView->font()); | 177 | currentFont = new QFont (m_abView->font()); |
178 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 178 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
179 | // abList->resizeRows(); | 179 | // abList->resizeRows(); |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | 185 | ||
186 | void AddressbookWindow::importvCard() { | 186 | void AddressbookWindow::importvCard() { |
187 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 187 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
188 | if(!str.isEmpty() ){ | 188 | if(!str.isEmpty() ){ |
189 | setDocument((const QString&) str ); | 189 | setDocument((const QString&) str ); |
190 | } | 190 | } |
191 | 191 | ||
192 | } | 192 | } |
193 | void AddressbookWindow::exportvCard() | 193 | void AddressbookWindow::exportvCard() |
194 | { | 194 | { |
195 | odebug << "void AddressbookWindow::exportvCard()" << oendl; | 195 | odebug << "void AddressbookWindow::exportvCard()" << oendl; |
196 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 196 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
197 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 197 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
198 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; | 198 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; |
199 | Opie::OPimContact curCont = m_abView->currentEntry(); | 199 | Opie::OPimContact curCont = m_abView->currentEntry(); |
200 | if ( !curCont.isEmpty() ){ | 200 | if ( !curCont.isEmpty() ){ |
201 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 201 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
202 | filename ); | 202 | filename ); |
203 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 203 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
204 | if ( access ){ | 204 | if ( access ){ |
205 | access->add( curCont ); | 205 | access->add( curCont ); |
206 | access->save(); | 206 | access->save(); |
207 | } | 207 | } |
208 | delete access; | 208 | delete access; |
209 | }else | 209 | }else |
210 | QMessageBox::critical( 0, "Export VCard", | 210 | QMessageBox::critical( 0, "Export VCard", |
211 | QString( tr( "You have to select a contact !") ) ); | 211 | QString( tr( "You have to select a contact !") ) ); |
212 | 212 | ||
213 | }else | 213 | }else |
214 | QMessageBox::critical( 0, "Export VCard", | 214 | QMessageBox::critical( 0, "Export VCard", |
215 | QString( tr( "You have to set a filename !") ) ); | 215 | QString( tr( "You have to set a filename !") ) ); |
216 | } | 216 | } |
217 | 217 | ||
218 | void AddressbookWindow::setDocument( const QString &filename ) | 218 | void AddressbookWindow::setDocument( const QString &filename ) |
219 | { | 219 | { |
220 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; | 220 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; |
221 | 221 | ||
222 | // Switch to default backend. This should avoid to import into | 222 | // Switch to default backend. This should avoid to import into |
223 | // the personal database accidently. | 223 | // the personal database accidently. |
224 | if ( m_actionPersonal->isOn() ){ | 224 | if ( m_actionPersonal->isOn() ){ |
225 | m_actionPersonal->setOn( false ); | 225 | m_actionPersonal->setOn( false ); |
226 | slotPersonalView(); | 226 | slotPersonalView(); |
227 | } | 227 | } |
228 | 228 | ||
229 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 229 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 233 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
234 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 234 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
235 | tr( "&Yes" ), tr( "&No" ), QString::null, | 235 | tr( "&Yes" ), tr( "&No" ), QString::null, |
236 | 0, // Enter == button 0 | 236 | 0, // Enter == button 0 |
237 | 2 ) ) { // Escape == button 2 | 237 | 2 ) ) { // Escape == button 2 |
238 | case 0: | 238 | case 0: |
239 | odebug << "YES clicked" << oendl; | 239 | odebug << "YES clicked" << oendl; |
240 | break; | 240 | break; |
241 | case 1: | 241 | case 1: |
242 | odebug << "NO clicked" << oendl; | 242 | odebug << "NO clicked" << oendl; |
243 | return; | 243 | return; |
244 | break; | 244 | break; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 248 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
249 | filename ); | 249 | filename ); |
250 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 250 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
251 | Opie::OPimContactAccess::List allList = access->allRecords(); | 251 | Opie::OPimContactAccess::List allList = access->allRecords(); |
252 | odebug << "Found number of contacts in File: " << allList.count() << oendl; | 252 | odebug << "Found number of contacts in File: " << allList.count() << oendl; |
253 | 253 | ||
254 | if ( !allList.count() ) { | 254 | if ( !allList.count() ) { |
255 | QMessageBox::information( this, "Import VCard", | 255 | QMessageBox::information( this, "Import VCard", |
256 | "It was impossible to import\nthe VCard.\n" | 256 | "It was impossible to import\nthe VCard.\n" |
257 | "The VCard may be corrupted!" ); | 257 | "The VCard may be corrupted!" ); |
258 | } | 258 | } |
259 | 259 | ||
260 | bool doAsk = true; | 260 | bool doAsk = true; |
261 | Opie::OPimContactAccess::List::Iterator it; | 261 | Opie::OPimContactAccess::List::Iterator it; |
262 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 262 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
263 | odebug << "Adding Contact from: " << (*it).fullName() << oendl; | 263 | odebug << "Adding Contact from: " << (*it).fullName() << oendl; |
264 | if ( doAsk ){ | 264 | if ( doAsk ){ |
265 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 265 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
266 | tr( "Do you really want add contact for \n%1?" ) | 266 | tr( "Do you really want add contact for \n%1?" ) |
267 | .arg( (*it).fullName().latin1() ), | 267 | .arg( (*it).fullName().latin1() ), |
268 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 268 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
269 | 0, // Enter == button 0 | 269 | 0, // Enter == button 0 |
270 | 2 ) ) { // Escape == button 2 | 270 | 2 ) ) { // Escape == button 2 |
271 | case 0: | 271 | case 0: |
272 | odebug << "YES clicked" << oendl; | 272 | odebug << "YES clicked" << oendl; |
273 | m_abView->addEntry( *it ); | 273 | m_abView->addEntry( *it ); |
274 | break; | 274 | break; |
275 | case 1: | 275 | case 1: |
276 | odebug << "NO clicked" << oendl; | 276 | odebug << "NO clicked" << oendl; |
277 | break; | 277 | break; |
278 | case 2: | 278 | case 2: |
279 | odebug << "YesAll clicked" << oendl; | 279 | odebug << "YesAll clicked" << oendl; |
280 | doAsk = false; | 280 | doAsk = false; |
281 | break; | 281 | break; |
282 | } | 282 | } |
283 | }else | 283 | }else |
284 | m_abView->addEntry( *it ); | 284 | m_abView->addEntry( *it ); |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | delete access; | 288 | delete access; |
289 | } | 289 | } |
290 | 290 | ||
291 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 291 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
292 | { | 292 | { |
293 | QMainWindow::resizeEvent( e ); | 293 | QMainWindow::resizeEvent( e ); |
294 | 294 | ||
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | AddressbookWindow::~AddressbookWindow() | 298 | AddressbookWindow::~AddressbookWindow() |
299 | { | 299 | { |
300 | ToolBarDock dock; | 300 | ToolBarDock dock; |
301 | int dummy; | 301 | int dummy; |
302 | bool bDummy; | 302 | bool bDummy; |
303 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 303 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
304 | m_config.setToolBarDock( dock ); | 304 | m_config.setToolBarDock( dock ); |
305 | m_config.save(); | 305 | m_config.save(); |
306 | } | 306 | } |
307 | 307 | ||
308 | int AddressbookWindow::create() | 308 | int AddressbookWindow::create() |
309 | { | 309 | { |
310 | return 0; | 310 | return 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | bool AddressbookWindow::remove( int /*uid*/ ) | 313 | bool AddressbookWindow::remove( int /*uid*/ ) |
314 | { | 314 | { |
315 | return false; | 315 | return false; |
316 | } | 316 | } |
317 | 317 | ||
318 | void AddressbookWindow::beam( int /*uid*/ ) | 318 | void AddressbookWindow::beam( int /*uid*/ ) |
319 | { | 319 | { |
320 | } | 320 | } |
321 | 321 | ||
322 | void AddressbookWindow::show( int /*uid*/ ) | 322 | void AddressbookWindow::show( int /*uid*/ ) |
323 | { | 323 | { |
324 | } | 324 | } |
325 | 325 | ||
326 | void AddressbookWindow::edit( int /*uid*/ ) | 326 | void AddressbookWindow::edit( int /*uid*/ ) |
327 | { | 327 | { |
328 | } | 328 | } |
329 | 329 | ||
330 | void AddressbookWindow::add( const Opie::OPimRecord& ) | 330 | void AddressbookWindow::add( const Opie::OPimRecord& ) |
331 | { | 331 | { |
332 | } | 332 | } |
333 | 333 | ||
334 | void AddressbookWindow::slotItemNew() | 334 | void AddressbookWindow::slotItemNew() |
335 | { | 335 | { |
336 | Opie::OPimContact cnt; | 336 | Opie::OPimContact cnt; |
337 | if( !syncing ) { | 337 | if( !syncing ) { |
338 | editEntry( NewEntry ); | 338 | editEntry( NewEntry ); |
339 | } else { | 339 | } else { |
340 | QMessageBox::warning(this, tr("Contacts"), | 340 | QMessageBox::warning(this, tr("Contacts"), |
341 | tr("Can not edit data, currently syncing")); | 341 | tr("Can not edit data, currently syncing")); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | void AddressbookWindow::slotItemEdit() | 345 | void AddressbookWindow::slotItemEdit() |
346 | { | 346 | { |
347 | if(!syncing) { | 347 | if(!syncing) { |
348 | if (m_actionPersonal->isOn()) { | 348 | if (m_actionPersonal->isOn()) { |
349 | editPersonal(); | 349 | editPersonal(); |
350 | } else { | 350 | } else { |
351 | editEntry( EditEntry ); | 351 | editEntry( EditEntry ); |
352 | } | 352 | } |
353 | } else { | 353 | } else { |
354 | QMessageBox::warning( this, tr("Contacts"), | 354 | QMessageBox::warning( this, tr("Contacts"), |
355 | tr("Can not edit data, currently syncing") ); | 355 | tr("Can not edit data, currently syncing") ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | void AddressbookWindow::slotItemDuplicate() | 359 | void AddressbookWindow::slotItemDuplicate() |
360 | { | 360 | { |
361 | if(!syncing) | 361 | if(!syncing) |
362 | { | 362 | { |
363 | Opie::OPimContact entry = m_abView->currentEntry(); | 363 | Opie::OPimContact entry = m_abView->currentEntry(); |
364 | entry.assignUid(); | 364 | entry.assignUid(); |
365 | m_abView->addEntry( entry ); | 365 | m_abView->addEntry( entry ); |
366 | m_abView->setCurrentUid( entry.uid() ); | 366 | m_abView->setCurrentUid( entry.uid() ); |
367 | } | 367 | } |
368 | else | 368 | else |
369 | { | 369 | { |
370 | QMessageBox::warning( this, tr("Contacts"), | 370 | QMessageBox::warning( this, tr("Contacts"), |
371 | tr("Can not edit data, currently syncing") ); | 371 | tr("Can not edit data, currently syncing") ); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | void AddressbookWindow::slotItemDelete() | 375 | void AddressbookWindow::slotItemDelete() |
376 | { | 376 | { |
377 | if(!syncing) { | 377 | if(!syncing) { |
378 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); | 378 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); |
379 | 379 | ||
380 | // get a name, do the best we can... | 380 | // get a name, do the best we can... |
381 | QString strName = tmpEntry.fullName(); | 381 | QString strName = tmpEntry.fullName(); |
382 | if ( strName.isEmpty() ) { | 382 | if ( strName.isEmpty() ) { |
383 | strName = tmpEntry.company(); | 383 | strName = tmpEntry.company(); |
384 | if ( strName.isEmpty() ) | 384 | if ( strName.isEmpty() ) |
385 | strName = "No Name"; | 385 | strName = "No Name"; |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 389 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
390 | strName ) ) { | 390 | strName ) ) { |
391 | m_abView->removeEntry( tmpEntry.uid() ); | 391 | m_abView->removeEntry( tmpEntry.uid() ); |
392 | } | 392 | } |
393 | } else { | 393 | } else { |
394 | QMessageBox::warning( this, tr("Contacts"), | 394 | QMessageBox::warning( this, tr("Contacts"), |
395 | tr("Can not edit data, currently syncing") ); | 395 | tr("Can not edit data, currently syncing") ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 399 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
400 | 400 | ||
401 | void AddressbookWindow::slotItemBeam() | 401 | void AddressbookWindow::slotItemBeam() |
402 | { | 402 | { |
403 | QString beamFilename; | 403 | QString beamFilename; |
404 | Opie::OPimContact c; | 404 | Opie::OPimContact c; |
405 | if ( m_actionPersonal->isOn() ) { | 405 | if ( m_actionPersonal->isOn() ) { |
406 | beamFilename = addressbookPersonalVCardName(); | 406 | beamFilename = addressbookPersonalVCardName(); |
407 | if ( !QFile::exists( beamFilename ) ) | 407 | if ( !QFile::exists( beamFilename ) ) |
408 | return; // can't beam a non-existent file | 408 | return; // can't beam a non-existent file |
409 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 409 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
410 | beamFilename ); | 410 | beamFilename ); |
411 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 411 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
412 | Opie::OPimContactAccess::List allList = access->allRecords(); | 412 | Opie::OPimContactAccess::List allList = access->allRecords(); |
413 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 413 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
414 | c = *it; | 414 | c = *it; |
415 | 415 | ||
416 | delete access; | 416 | delete access; |
417 | } else { | 417 | } else { |
418 | unlink( beamfile ); // delete if exists | 418 | unlink( beamfile ); // delete if exists |
419 | mkdir("/tmp/obex/", 0755); | 419 | mkdir("/tmp/obex/", 0755); |
420 | c = m_abView -> currentEntry(); | 420 | c = m_abView -> currentEntry(); |
421 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 421 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
422 | beamfile ); | 422 | beamfile ); |
423 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 423 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
424 | access->add( c ); | 424 | access->add( c ); |
425 | access->save(); | 425 | access->save(); |
426 | delete access; | 426 | delete access; |
427 | 427 | ||
428 | beamFilename = beamfile; | 428 | beamFilename = beamfile; |
429 | } | 429 | } |
430 | 430 | ||
431 | odebug << "Beaming: " << beamFilename << oendl; | 431 | odebug << "Beaming: " << beamFilename << oendl; |
432 | 432 | ||
433 | Ir *ir = new Ir( this ); | 433 | Ir *ir = new Ir( this ); |
434 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 434 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
435 | QString description = c.fullName(); | 435 | QString description = c.fullName(); |
436 | ir->send( beamFilename, description, "text/x-vCard" ); | 436 | ir->send( beamFilename, description, "text/x-vCard" ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void AddressbookWindow::slotItemFind() | 439 | void AddressbookWindow::slotItemFind() |
440 | { | 440 | { |
441 | } | 441 | } |
442 | 442 | ||
443 | void AddressbookWindow::slotConfigure() | 443 | void AddressbookWindow::slotConfigure() |
444 | { | 444 | { |
445 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 445 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
446 | dlg -> setConfig( m_config ); | 446 | dlg -> setConfig( m_config ); |
447 | if ( QPEApplication::execDialog( dlg ) ) { | 447 | if ( QPEApplication::execDialog( dlg ) ) { |
448 | odebug << "Config Dialog accepted!" << oendl; | 448 | odebug << "Config Dialog accepted!" << oendl; |
449 | m_config = dlg -> getConfig(); | 449 | m_config = dlg -> getConfig(); |
450 | if ( m_curFontSize != m_config.fontSize() ){ | 450 | if ( m_curFontSize != m_config.fontSize() ){ |
451 | odebug << "Font was changed!" << oendl; | 451 | odebug << "Font was changed!" << oendl; |
452 | m_curFontSize = m_config.fontSize(); | 452 | m_curFontSize = m_config.fontSize(); |
453 | emit slotSetFont( m_curFontSize ); | 453 | emit slotSetFont( m_curFontSize ); |
454 | } | 454 | } |
455 | m_abView -> setListOrder( m_config.orderList() ); | 455 | m_abView -> setListOrder( m_config.orderList() ); |
456 | } | 456 | } |
457 | 457 | ||
458 | delete dlg; | 458 | delete dlg; |
459 | } | 459 | } |
460 | 460 | ||
461 | void AddressbookWindow::slotShowFind( bool show ) | 461 | void AddressbookWindow::slotShowFind( bool show ) |
462 | { | 462 | { |
463 | if ( show ) | 463 | if ( show ) |
464 | { | 464 | { |
465 | // Display search bar | 465 | // Display search bar |
466 | m_searchBar->show(); | 466 | m_searchBar->show(); |
467 | m_abView -> inSearch(); | 467 | m_abView -> inSearch(); |
468 | m_searchEdit->setFocus(); | 468 | m_searchEdit->setFocus(); |
469 | } | 469 | } |
470 | else | 470 | else |
471 | { | 471 | { |
472 | // Hide search bar | 472 | // Hide search bar |
473 | m_searchBar->hide(); | 473 | m_searchBar->hide(); |
474 | m_abView -> offSearch(); | 474 | m_abView -> offSearch(); |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | void AddressbookWindow::slotFind() | 478 | void AddressbookWindow::slotFind() |
479 | { | 479 | { |
480 | m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 480 | m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
481 | 481 | ||
482 | m_searchEdit->clearFocus(); | 482 | m_searchEdit->clearFocus(); |
483 | // m_abView->setFocus(); | 483 | // m_abView->setFocus(); |
484 | 484 | ||
485 | } | 485 | } |
486 | 486 | ||
487 | void AddressbookWindow::slotViewBack() | 487 | void AddressbookWindow::slotViewBack() |
488 | { | 488 | { |
489 | // :SX showList(); | 489 | // :SX showList(); |
490 | } | 490 | } |
491 | 491 | ||
492 | void AddressbookWindow::writeMail() | 492 | void AddressbookWindow::writeMail() |
493 | { | 493 | { |
494 | Opie::OPimContact c = m_abView -> currentEntry(); | 494 | Opie::OPimContact c = m_abView -> currentEntry(); |
495 | QString name = c.fileAs(); | 495 | QString name = c.fileAs(); |
496 | QString email = c.defaultEmail(); | 496 | QString email = c.defaultEmail(); |
497 | 497 | ||
498 | // I prefer the OPIE-Environment variable before the | 498 | // I prefer the OPIE-Environment variable before the |
499 | // QPE-one.. | 499 | // QPE-one.. |
500 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 500 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
501 | if ( basepath.isEmpty() ) | 501 | if ( basepath.isEmpty() ) |
502 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 502 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
503 | 503 | ||
504 | // Try to access the preferred. If not possible, try to | 504 | // Try to access the preferred. If not possible, try to |
505 | // switch to the other one.. | 505 | // switch to the other one.. |
506 | if ( m_config.useQtMail() ){ | 506 | if ( m_config.useQtMail() ){ |
507 | odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; | 507 | odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; |
508 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 508 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
509 | odebug << "QCop" << oendl; | 509 | odebug << "QCop" << oendl; |
510 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 510 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
511 | e << name << email; | 511 | e << name << email; |
512 | return; | 512 | return; |
513 | } else | 513 | } else |
514 | m_config.setUseOpieMail( true ); | 514 | m_config.setUseOpieMail( true ); |
515 | } | 515 | } |
516 | if ( m_config.useOpieMail() ){ | 516 | if ( m_config.useOpieMail() ){ |
517 | odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; | 517 | odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; |
518 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ | 518 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ |
519 | odebug << "QCop" << oendl; | 519 | odebug << "QCop" << oendl; |
520 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); | 520 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); |
521 | e << name << email; | 521 | e << name << email; |
522 | return; | 522 | return; |
523 | } else | 523 | } else |
524 | m_config.setUseQtMail( true ); | 524 | m_config.setUseQtMail( true ); |
525 | } | 525 | } |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | void AddressbookWindow::beamDone( Ir *ir ) | 529 | void AddressbookWindow::beamDone( Ir *ir ) |
530 | { | 530 | { |
531 | 531 | ||
532 | delete ir; | 532 | delete ir; |
533 | unlink( beamfile ); | 533 | unlink( beamfile ); |
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | static void parseName( const QString& name, QString *first, QString *middle, | 537 | static void parseName( const QString& name, QString *first, QString *middle, |
538 | QString * last ) | 538 | QString * last ) |
539 | { | 539 | { |
540 | 540 | ||
541 | int comma = name.find ( "," ); | 541 | int comma = name.find ( "," ); |
542 | QString rest; | 542 | QString rest; |
543 | if ( comma > 0 ) { | 543 | if ( comma > 0 ) { |
544 | *last = name.left( comma ); | 544 | *last = name.left( comma ); |
545 | comma++; | 545 | comma++; |
546 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 546 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
547 | comma++; | 547 | comma++; |
548 | rest = name.mid( comma ); | 548 | rest = name.mid( comma ); |
549 | } else { | 549 | } else { |
550 | int space = name.findRev( ' ' ); | 550 | int space = name.findRev( ' ' ); |
551 | *last = name.mid( space+1 ); | 551 | *last = name.mid( space+1 ); |
552 | rest = name.left( space ); | 552 | rest = name.left( space ); |
553 | } | 553 | } |
554 | int space = rest.find( ' ' ); | 554 | int space = rest.find( ' ' ); |
555 | if ( space <= 0 ) { | 555 | if ( space <= 0 ) { |
556 | *first = rest; | 556 | *first = rest; |
557 | } else { | 557 | } else { |
558 | *first = rest.left( space ); | 558 | *first = rest.left( space ); |
559 | *middle = rest.mid( space+1 ); | 559 | *middle = rest.mid( space+1 ); |
560 | } | 560 | } |
561 | 561 | ||
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 565 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
566 | { | 566 | { |
567 | bool needShow = false; | 567 | bool needShow = false; |
568 | odebug << "Receiving QCop-Call with message " << msg << oendl; | 568 | odebug << "Receiving QCop-Call with message " << msg << oendl; |
569 | 569 | ||
570 | 570 | ||
571 | if (msg == "editPersonal()") { | 571 | if (msg == "editPersonal()") { |
572 | editPersonal(); | 572 | editPersonal(); |
573 | 573 | ||
574 | // Categories might have changed, so reload | 574 | // Categories might have changed, so reload |
575 | reloadCategories(); | 575 | reloadCategories(); |
576 | } else if (msg == "editPersonalAndClose()") { | 576 | } else if (msg == "editPersonalAndClose()") { |
577 | editPersonal(); | 577 | editPersonal(); |
578 | close(); | 578 | close(); |
579 | } else if ( msg == "addContact(QString,QString)" ) { | 579 | } else if ( msg == "addContact(QString,QString)" ) { |
580 | QDataStream stream(data,IO_ReadOnly); | 580 | QDataStream stream(data,IO_ReadOnly); |
581 | QString name, email; | 581 | QString name, email; |
582 | stream >> name >> email; | 582 | stream >> name >> email; |
583 | 583 | ||
584 | Opie::OPimContact cnt; | 584 | Opie::OPimContact cnt; |
585 | QString fn, mn, ln; | 585 | QString fn, mn, ln; |
586 | parseName( name, &fn, &mn, &ln ); | 586 | parseName( name, &fn, &mn, &ln ); |
587 | //odebug << " " << fn << " - " << mn " - " << ln << oendl; | 587 | //odebug << " " << fn << " - " << mn " - " << ln << oendl; |
588 | cnt.setFirstName( fn ); | 588 | cnt.setFirstName( fn ); |
589 | cnt.setMiddleName( mn ); | 589 | cnt.setMiddleName( mn ); |
590 | cnt.setLastName( ln ); | 590 | cnt.setLastName( ln ); |
591 | cnt.insertEmails( email ); | 591 | cnt.insertEmails( email ); |
592 | cnt.setDefaultEmail( email ); | 592 | cnt.setDefaultEmail( email ); |
593 | cnt.setFileAs(); | 593 | cnt.setFileAs(); |
594 | 594 | ||
595 | m_abView -> addEntry( cnt ); | 595 | m_abView -> addEntry( cnt ); |
596 | 596 | ||
597 | // :SXm_abView()->init( cnt ); | 597 | // :SXm_abView()->init( cnt ); |
598 | editEntry( EditEntry ); | 598 | editEntry( EditEntry ); |
599 | 599 | ||
600 | // Categories might have changed, so reload | 600 | // Categories might have changed, so reload |
601 | reloadCategories(); | 601 | reloadCategories(); |
602 | } else if ( msg == "beamBusinessCard()" ) { | 602 | } else if ( msg == "beamBusinessCard()" ) { |
603 | QString beamFilename = addressbookPersonalVCardName(); | 603 | QString beamFilename = addressbookPersonalVCardName(); |
604 | if ( !QFile::exists( beamFilename ) ) | 604 | if ( !QFile::exists( beamFilename ) ) |
605 | return; // can't beam a non-existent file | 605 | return; // can't beam a non-existent file |
606 | 606 | ||
607 | Ir *ir = new Ir( this ); | 607 | Ir *ir = new Ir( this ); |
608 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 608 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
609 | QString description = "mycard.vcf"; | 609 | QString description = "mycard.vcf"; |
610 | ir->send( beamFilename, description, "text/x-vCard" ); | 610 | ir->send( beamFilename, description, "text/x-vCard" ); |
611 | } else if ( msg == "show(int)" ) { | 611 | } else if ( msg == "show(int)" ) { |
612 | raise(); | 612 | raise(); |
613 | QDataStream stream(data,IO_ReadOnly); | 613 | QDataStream stream(data,IO_ReadOnly); |
614 | int uid; | 614 | int uid; |
615 | stream >> uid; | 615 | stream >> uid; |
616 | 616 | ||
617 | odebug << "Showing uid: " << uid << oendl; | 617 | odebug << "Showing uid: " << uid << oendl; |
618 | 618 | ||
619 | // Deactivate Personal View.. | 619 | // Deactivate Personal View.. |
620 | if ( m_actionPersonal->isOn() ){ | 620 | if ( m_actionPersonal->isOn() ){ |
621 | m_actionPersonal->setOn( false ); | 621 | m_actionPersonal->setOn( false ); |
622 | slotPersonalView(); | 622 | slotPersonalView(); |
623 | } | 623 | } |
624 | 624 | ||
625 | // Reset category and show as card.. | 625 | // Reset category and show as card.. |
626 | m_abView -> setShowByCategory( QString::null ); | 626 | m_abView -> setShowByCategory( QString::null ); |
627 | m_abView -> setCurrentUid( uid ); | 627 | m_abView -> setCurrentUid( uid ); |
628 | slotViewSwitched ( AbView::CardView ); | 628 | slotViewSwitched ( AbView::CardView ); |
629 | 629 | ||
630 | needShow = true; | 630 | needShow = true; |
631 | 631 | ||
632 | 632 | ||
633 | } else if ( msg == "edit(int)" ) { | 633 | } else if ( msg == "edit(int)" ) { |
634 | QDataStream stream(data,IO_ReadOnly); | 634 | QDataStream stream(data,IO_ReadOnly); |
635 | int uid; | 635 | int uid; |
636 | stream >> uid; | 636 | stream >> uid; |
637 | 637 | ||
638 | // Deactivate Personal View.. | 638 | // Deactivate Personal View.. |
639 | if ( m_actionPersonal->isOn() ){ | 639 | if ( m_actionPersonal->isOn() ){ |
640 | m_actionPersonal->setOn( false ); | 640 | m_actionPersonal->setOn( false ); |
641 | slotPersonalView(); | 641 | slotPersonalView(); |
642 | } | 642 | } |
643 | 643 | ||
644 | // Reset category and edit.. | 644 | // Reset category and edit.. |
645 | m_abView -> setShowByCategory( QString::null ); | 645 | m_abView -> setShowByCategory( QString::null ); |
646 | m_abView -> setCurrentUid( uid ); | 646 | m_abView -> setCurrentUid( uid ); |
647 | slotItemEdit(); | 647 | slotItemEdit(); |
648 | 648 | ||
649 | // Categories might have changed, so reload | 649 | // Categories might have changed, so reload |
650 | reloadCategories(); | 650 | reloadCategories(); |
651 | } | 651 | } |
652 | 652 | ||
653 | if (needShow) | 653 | if (needShow) |
654 | QPEApplication::setKeepRunning(); | 654 | QPEApplication::setKeepRunning(); |
655 | } | 655 | } |
656 | 656 | ||
657 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 657 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
658 | { | 658 | { |
659 | Opie::OPimContact entry; | 659 | Opie::OPimContact entry; |
660 | if ( !abEditor ) { | 660 | if ( !abEditor ) { |
661 | abEditor = new ContactEditor( entry, this, "editor" ); | 661 | abEditor = new ContactEditor( entry, this, "editor" ); |
662 | } | 662 | } |
663 | if ( entryMode == EditEntry ) | 663 | if ( entryMode == EditEntry ) |
664 | abEditor->setEntry( m_abView -> currentEntry() ); | 664 | abEditor->setEntry( m_abView -> currentEntry() ); |
665 | else if ( entryMode == NewEntry ) | 665 | else if ( entryMode == NewEntry ) |
666 | abEditor->setEntry( entry ); | 666 | abEditor->setEntry( entry ); |
667 | // other things may change the caption. | 667 | |
668 | abEditor->setCaption( tr("Edit Address") ); | 668 | // Set the dialog caption |
669 | if ( m_actionPersonal->isOn() ) | ||
670 | abEditor->setCaption( tr( "Edit My Personal Details" ) ); | ||
671 | else | ||
672 | abEditor->setCaption( tr( "Edit Contact" ) ); | ||
669 | 673 | ||
670 | // fix the focus... | 674 | // fix the focus... |
671 | abEditor->setNameFocus(); | 675 | abEditor->setNameFocus(); |
672 | if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { | 676 | if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { |
673 | setFocus(); | 677 | setFocus(); |
674 | if ( entryMode == NewEntry ) { | 678 | if ( entryMode == NewEntry ) { |
675 | Opie::OPimContact insertEntry = abEditor->entry(); | 679 | Opie::OPimContact insertEntry = abEditor->entry(); |
676 | insertEntry.assignUid(); | 680 | insertEntry.assignUid(); |
677 | m_abView -> addEntry( insertEntry ); | 681 | m_abView -> addEntry( insertEntry ); |
678 | m_abView -> setCurrentUid( insertEntry.uid() ); | 682 | m_abView -> setCurrentUid( insertEntry.uid() ); |
679 | } else { | 683 | } else { |
680 | Opie::OPimContact replEntry = abEditor->entry(); | 684 | Opie::OPimContact replEntry = abEditor->entry(); |
681 | 685 | ||
682 | if ( !replEntry.isValidUid() ) | 686 | if ( !replEntry.isValidUid() ) |
683 | replEntry.assignUid(); | 687 | replEntry.assignUid(); |
684 | 688 | ||
685 | m_abView -> replaceEntry( replEntry ); | 689 | m_abView -> replaceEntry( replEntry ); |
686 | } | 690 | } |
687 | 691 | ||
688 | // Categories might have changed, so reload | 692 | // Categories might have changed, so reload |
689 | reloadCategories(); | 693 | reloadCategories(); |
690 | } | 694 | } |
691 | } | 695 | } |
692 | 696 | ||
693 | void AddressbookWindow::editPersonal() | 697 | void AddressbookWindow::editPersonal() |
694 | { | 698 | { |
695 | Opie::OPimContact entry; | 699 | Opie::OPimContact entry; |
696 | 700 | ||
697 | // Switch to personal view if not selected | 701 | // Switch to personal view if not selected |
698 | // but take care of the menu, too | 702 | // but take care of the menu, too |
699 | if ( ! m_actionPersonal->isOn() ){ | 703 | if ( ! m_actionPersonal->isOn() ){ |
700 | odebug << "*** ++++" << oendl; | 704 | odebug << "*** ++++" << oendl; |
701 | m_actionPersonal->setOn( true ); | 705 | m_actionPersonal->setOn( true ); |
702 | slotPersonalView(); | 706 | slotPersonalView(); |
703 | } | 707 | } |
704 | 708 | ||
705 | if ( !abEditor ) { | 709 | if ( !abEditor ) { |
706 | abEditor = new ContactEditor( entry, this, "editor" ); | 710 | abEditor = new ContactEditor( entry, this, "editor" ); |
707 | } | 711 | } |
708 | 712 | ||
709 | abEditor->setCaption(tr("Edit My Personal Details")); | 713 | abEditor->setPersonalView( true ); |
710 | abEditor->setPersonalView( true ); | ||
711 | editEntry( EditEntry ); | 714 | editEntry( EditEntry ); |
712 | abEditor->setPersonalView( false ); | 715 | abEditor->setPersonalView( false ); |
713 | 716 | ||
714 | } | 717 | } |
715 | 718 | ||
716 | 719 | ||
717 | void AddressbookWindow::slotPersonalView() | 720 | void AddressbookWindow::slotPersonalView() |
718 | { | 721 | { |
719 | odebug << "slotPersonalView()" << oendl; | 722 | odebug << "slotPersonalView()" << oendl; |
720 | 723 | ||
721 | bool personal = m_actionPersonal->isOn(); | 724 | bool personal = m_actionPersonal->isOn(); |
722 | 725 | ||
723 | // Disable actions when showing personal details | 726 | // Disable actions when showing personal details |
724 | setItemNewEnabled( !personal ); | 727 | setItemNewEnabled( !personal ); |
725 | setItemDuplicateEnabled( !personal ); | 728 | setItemDuplicateEnabled( !personal ); |
726 | setItemDeleteEnabled( !personal ); | 729 | setItemDeleteEnabled( !personal ); |
727 | m_actionMail->setEnabled( !personal ); | 730 | m_actionMail->setEnabled( !personal ); |
728 | setShowCategories( !personal ); | 731 | setShowCategories( !personal ); |
729 | 732 | ||
730 | // Display appropriate view | 733 | // Display appropriate view |
731 | m_abView->showPersonal( personal ); | 734 | m_abView->showPersonal( personal ); |
732 | 735 | ||
733 | if ( personal ) | 736 | if ( personal ) |
734 | { | 737 | { |
735 | setCaption( tr( "Contacts - My Personal Details") ); | 738 | setCaption( tr( "Contacts - My Personal Details") ); |
736 | 739 | ||
737 | // Set category to 'All' to make sure personal details is visible | 740 | // Set category to 'All' to make sure personal details is visible |
738 | setViewCategory( "All" ); | 741 | setViewCategory( "All" ); |
739 | m_abView->setShowByCategory( "All" ); | 742 | m_abView->setShowByCategory( "All" ); |
740 | 743 | ||
741 | // Temporarily disable letter picker | 744 | // Temporarily disable letter picker |
742 | pLabel->hide(); | 745 | pLabel->hide(); |
743 | } | 746 | } |
744 | else | 747 | else |
745 | { | 748 | { |
746 | setCaption( tr( "Contacts") ); | 749 | setCaption( tr( "Contacts") ); |
747 | 750 | ||
748 | // Re-enable letter picker | 751 | // Re-enable letter picker |
749 | pLabel->show(); | 752 | pLabel->show(); |
750 | } | 753 | } |
751 | } | 754 | } |
752 | 755 | ||
753 | void AddressbookWindow::reload() | 756 | void AddressbookWindow::reload() |
754 | { | 757 | { |
755 | syncing = false; | 758 | syncing = false; |
756 | m_abView->clear(); | 759 | m_abView->clear(); |
757 | m_abView->reload(); | 760 | m_abView->reload(); |
758 | } | 761 | } |
759 | 762 | ||
760 | void AddressbookWindow::flush() | 763 | void AddressbookWindow::flush() |
761 | { | 764 | { |
762 | syncing = true; | 765 | syncing = true; |
763 | m_abView->save(); | 766 | m_abView->save(); |
764 | } | 767 | } |
765 | 768 | ||
766 | 769 | ||
767 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 770 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
768 | { | 771 | { |
769 | if ( active_view == AbView::CardView ) | 772 | if ( active_view == AbView::CardView ) |
770 | { | 773 | { |
771 | if ( !m_actionPersonal->isOn() ) | 774 | if ( !m_actionPersonal->isOn() ) |
772 | { | 775 | { |
773 | // Switch to table view only if not editing personal details | 776 | // Switch to table view only if not editing personal details |
774 | slotViewSwitched( AbView::TableView ); | 777 | slotViewSwitched( AbView::TableView ); |
775 | } | 778 | } |
776 | else | 779 | else |
777 | { | 780 | { |
778 | // If currently editing personal details, switch off personal view | 781 | // If currently editing personal details, switch off personal view |
779 | m_actionPersonal->setOn( false ); | 782 | m_actionPersonal->setOn( false ); |
780 | slotPersonalView(); | 783 | slotPersonalView(); |
781 | } | 784 | } |
782 | 785 | ||
783 | e->ignore(); | 786 | e->ignore(); |
784 | return; | 787 | return; |
785 | } | 788 | } |
786 | if(syncing) { | 789 | if(syncing) { |
787 | /* shouldn't we save, I hear you say? well its already been set | 790 | /* shouldn't we save, I hear you say? well its already been set |
788 | so that an edit can not occur during a sync, and we flushed | 791 | so that an edit can not occur during a sync, and we flushed |
789 | at the start of the sync, so there is no need to save | 792 | at the start of the sync, so there is no need to save |
790 | Saving however itself would cause problems. */ | 793 | Saving however itself would cause problems. */ |
791 | e->accept(); | 794 | e->accept(); |
792 | return; | 795 | return; |
793 | } | 796 | } |
794 | //################## shouldn't always save | 797 | //################## shouldn't always save |
795 | // True, but the database handles this automatically ! (se) | 798 | // True, but the database handles this automatically ! (se) |
796 | if ( save() ) | 799 | if ( save() ) |
797 | e->accept(); | 800 | e->accept(); |
798 | else | 801 | else |
799 | e->ignore(); | 802 | e->ignore(); |
800 | } | 803 | } |
801 | 804 | ||
802 | /* | 805 | /* |
803 | Returns true if it is OK to exit | 806 | Returns true if it is OK to exit |
804 | */ | 807 | */ |
805 | 808 | ||
806 | bool AddressbookWindow::save() | 809 | bool AddressbookWindow::save() |
807 | { | 810 | { |
808 | if ( !m_abView->save() ) { | 811 | if ( !m_abView->save() ) { |
809 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 812 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
810 | tr("Unable to save information.\n" | 813 | tr("Unable to save information.\n" |
811 | "Free up some space\n" | 814 | "Free up some space\n" |
812 | "and try again.\n" | 815 | "and try again.\n" |
813 | "\nQuit anyway?"), | 816 | "\nQuit anyway?"), |
814 | QMessageBox::Yes|QMessageBox::Escape, | 817 | QMessageBox::Yes|QMessageBox::Escape, |
815 | QMessageBox::No|QMessageBox::Default ) | 818 | QMessageBox::No|QMessageBox::Default ) |
816 | != QMessageBox::No ) | 819 | != QMessageBox::No ) |
817 | return true; | 820 | return true; |
818 | else | 821 | else |
819 | return false; | 822 | return false; |
820 | } | 823 | } |
821 | return true; | 824 | return true; |
822 | } | 825 | } |
823 | 826 | ||
824 | #ifdef __DEBUG_RELEASE | 827 | #ifdef __DEBUG_RELEASE |
825 | void AddressbookWindow::slotSave() | 828 | void AddressbookWindow::slotSave() |
826 | { | 829 | { |
827 | save(); | 830 | save(); |
828 | } | 831 | } |
829 | #endif | 832 | #endif |
830 | 833 | ||
831 | 834 | ||
832 | void AddressbookWindow::slotNotFound() | 835 | void AddressbookWindow::slotNotFound() |
833 | { | 836 | { |
834 | odebug << "Got not found signal!" << oendl; | 837 | odebug << "Got not found signal!" << oendl; |
835 | QMessageBox::information( this, tr( "Not Found" ), | 838 | QMessageBox::information( this, tr( "Not Found" ), |
836 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); | 839 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
837 | 840 | ||
838 | 841 | ||
839 | } | 842 | } |
840 | void AddressbookWindow::slotWrapAround() | 843 | void AddressbookWindow::slotWrapAround() |
841 | { | 844 | { |
842 | odebug << "Got wrap signal!" << oendl; | 845 | odebug << "Got wrap signal!" << oendl; |
843 | // if ( doNotifyWrapAround ) | 846 | // if ( doNotifyWrapAround ) |
844 | // QMessageBox::information( this, tr( "End of list" ), | 847 | // QMessageBox::information( this, tr( "End of list" ), |
845 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 848 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
846 | 849 | ||
847 | } | 850 | } |
848 | 851 | ||
849 | void AddressbookWindow::slotSetCategory( const QString &category ) | 852 | void AddressbookWindow::slotSetCategory( const QString &category ) |
850 | { | 853 | { |
851 | odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; | 854 | odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; |
852 | 855 | ||
853 | // Tell the view about the selected category | 856 | // Tell the view about the selected category |
854 | m_config.setCategory( category ); | 857 | m_config.setCategory( category ); |
855 | m_abView -> setShowByCategory( category ); | 858 | m_abView -> setShowByCategory( category ); |
856 | } | 859 | } |
857 | 860 | ||
858 | void AddressbookWindow::slotViewSwitched( int view ) | 861 | void AddressbookWindow::slotViewSwitched( int view ) |
859 | { | 862 | { |
860 | odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; | 863 | odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; |
861 | 864 | ||
862 | // Tell the view about the selected view | 865 | // Tell the view about the selected view |
863 | m_abView -> setShowToView ( (AbView::Views) view ); | 866 | m_abView -> setShowToView ( (AbView::Views) view ); |
864 | active_view = view; | 867 | active_view = view; |
865 | } | 868 | } |
866 | 869 | ||
867 | 870 | ||
868 | void AddressbookWindow::slotListView() | 871 | void AddressbookWindow::slotListView() |
869 | { | 872 | { |
870 | slotViewSwitched( AbView::TableView ); | 873 | slotViewSwitched( AbView::TableView ); |
871 | } | 874 | } |
872 | 875 | ||
873 | void AddressbookWindow::slotCardView() | 876 | void AddressbookWindow::slotCardView() |
874 | { | 877 | { |
875 | slotViewSwitched( AbView::CardView ); | 878 | slotViewSwitched( AbView::CardView ); |
876 | } | 879 | } |
877 | 880 | ||
878 | void AddressbookWindow::slotSetLetter( char c ) { | 881 | void AddressbookWindow::slotSetLetter( char c ) { |
879 | 882 | ||
880 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); | 883 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); |
881 | 884 | ||
882 | } | 885 | } |
883 | 886 | ||