author | eilers <eilers> | 2004-12-20 14:19:24 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-12-20 14:19:24 (UTC) |
commit | 29f05e7138a05c2c32cad8b40fd432cd383964a9 (patch) (unidiff) | |
tree | 2f80ace57f99ce24ac8c1e8a556c08e07ca18019 | |
parent | 18e47153532d016d878f47e0ce11cb1a9716218e (diff) | |
download | opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.zip opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.tar.gz opie-29f05e7138a05c2c32cad8b40fd432cd383964a9.tar.bz2 |
Fix for Bug #1269 and use of new sorted of the pim libary
-rw-r--r-- | core/pim/addressbook/abview.cpp | 27 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 7 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/version.h | 2 |
4 files changed, 28 insertions, 10 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 7abb45c..6be19f8 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -1,496 +1,507 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
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 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "abview.h" | 17 | #include "abview.h" |
18 | 18 | ||
19 | #include <opie2/ocontactaccessbackend_vcard.h> | 19 | #include <opie2/ocontactaccessbackend_vcard.h> |
20 | #include <opie2/odebug.h> | 20 | #include <opie2/odebug.h> |
21 | 21 | ||
22 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | #include <assert.h> | 26 | #include <assert.h> |
27 | 27 | ||
28 | 28 | ||
29 | // Is defined in LibQPE | 29 | // Is defined in LibQPE |
30 | extern QString categoryFileName(); | 30 | extern QString categoryFileName(); |
31 | 31 | ||
32 | QString addressbookPersonalVCardName() | 32 | QString addressbookPersonalVCardName() |
33 | { | 33 | { |
34 | QString filename = Global::applicationFileName("addressbook", | 34 | QString filename = Global::applicationFileName("addressbook", |
35 | "businesscard.vcf"); | 35 | "businesscard.vcf"); |
36 | return filename; | 36 | return filename; |
37 | } | 37 | } |
38 | 38 | ||
39 | 39 | ||
40 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | 40 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): |
41 | QWidget(parent), | 41 | QWidget(parent), |
42 | mCat(0), | 42 | mCat(0), |
43 | m_inSearch( false ), | 43 | m_inSearch( false ), |
44 | m_inPersonal( false ), | 44 | m_inPersonal( false ), |
45 | m_curr_category( -1 ), | 45 | m_curr_category( -1 ), |
46 | m_curr_View( TableView ), | 46 | m_curr_View( TableView ), |
47 | m_prev_View( TableView ), | 47 | m_prev_View( TableView ), |
48 | m_curr_Contact ( 0 ), | 48 | m_curr_Contact ( 0 ), |
49 | m_contactdb ( 0l ), | 49 | m_contactdb ( 0l ), |
50 | m_storedDB ( 0l ), | 50 | m_storedDB ( 0l ), |
51 | m_viewStack( 0l ), | 51 | m_viewStack( 0l ), |
52 | m_abTable( 0l ), | 52 | m_abTable( 0l ), |
53 | m_orderedFields( ordered ) | 53 | m_orderedFields( ordered ) |
54 | { | 54 | { |
55 | odebug << "AbView::c'tor" << oendl; | 55 | odebug << "AbView::c'tor" << oendl; |
56 | // Load default database and handle syncing myself.. ! | 56 | // Load default database and handle syncing myself.. ! |
57 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); | 57 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); |
58 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available | 58 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available |
59 | mCat.load( categoryFileName() ); | 59 | mCat.load( categoryFileName() ); |
60 | 60 | ||
61 | // Create Layout and put WidgetStack into it. | 61 | // Create Layout and put WidgetStack into it. |
62 | QVBoxLayout *vb = new QVBoxLayout( this ); | 62 | QVBoxLayout *vb = new QVBoxLayout( this ); |
63 | m_viewStack = new QWidgetStack( this ); | 63 | m_viewStack = new QWidgetStack( this ); |
64 | vb->addWidget( m_viewStack ); | 64 | vb->addWidget( m_viewStack ); |
65 | 65 | ||
66 | // Creat TableView | 66 | // Creat TableView |
67 | QVBox* tableBox = new QVBox( m_viewStack ); | 67 | QVBox* tableBox = new QVBox( m_viewStack ); |
68 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); | 68 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); |
69 | m_abTable->setCurrentCell( 0, 0 ); | 69 | m_abTable->setCurrentCell( 0, 0 ); |
70 | m_abTable->setFocus(); | 70 | m_abTable->setFocus(); |
71 | 71 | ||
72 | // Add TableView to WidgetStack and raise it | 72 | // Add TableView to WidgetStack and raise it |
73 | m_viewStack -> addWidget( tableBox , TableView ); | 73 | m_viewStack -> addWidget( tableBox , TableView ); |
74 | 74 | ||
75 | // Create CardView and add it to WidgetStack | 75 | // Create CardView and add it to WidgetStack |
76 | QVBox* cardBox = new QVBox( m_viewStack ); | 76 | QVBox* cardBox = new QVBox( m_viewStack ); |
77 | m_ablabel = new AbLabel( cardBox, "CardView"); | 77 | m_ablabel = new AbLabel( cardBox, "CardView"); |
78 | m_viewStack -> addWidget( cardBox , CardView ); | 78 | m_viewStack -> addWidget( cardBox , CardView ); |
79 | 79 | ||
80 | // Connect views to me | 80 | // Connect views to me |
81 | connect ( m_abTable, SIGNAL( signalSwitch(void) ), | 81 | connect ( m_abTable, SIGNAL( signalSwitch(void) ), |
82 | this, SLOT( slotSwitch(void) ) ); | 82 | this, SLOT( slotSwitch(void) ) ); |
83 | connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), | 83 | connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), |
84 | this, SLOT( slotSwitch(void) ) ); | 84 | this, SLOT( slotSwitch(void) ) ); |
85 | 85 | ||
86 | load(); | 86 | load(); |
87 | } | 87 | } |
88 | 88 | ||
89 | AbView::~AbView() | 89 | AbView::~AbView() |
90 | { | 90 | { |
91 | m_contactdb -> save(); | 91 | m_contactdb -> save(); |
92 | delete m_contactdb; | 92 | delete m_contactdb; |
93 | 93 | ||
94 | if ( m_storedDB ){ | 94 | if ( m_storedDB ){ |
95 | m_storedDB -> save(); | 95 | m_storedDB -> save(); |
96 | delete m_storedDB; | 96 | delete m_storedDB; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void AbView::setView( Views view ) | 101 | void AbView::setView( Views view ) |
102 | { | 102 | { |
103 | odebug << "AbView::setView( Views view )" << oendl; | 103 | odebug << "AbView::setView( Views view )" << oendl; |
104 | m_curr_View = view; | 104 | m_curr_View = view; |
105 | load(); | 105 | load(); |
106 | } | 106 | } |
107 | 107 | ||
108 | void AbView::addEntry( const Opie::OPimContact &newContact ) | 108 | void AbView::addEntry( const Opie::OPimContact &newContact ) |
109 | { | 109 | { |
110 | odebug << "AbView::AddContact" << oendl; | 110 | odebug << "AbView::AddContact" << oendl; |
111 | m_contactdb->add ( newContact ); | 111 | m_contactdb->add ( newContact ); |
112 | load(); | 112 | load(); |
113 | 113 | ||
114 | } | 114 | } |
115 | void AbView::removeEntry( const int UID ) | 115 | void AbView::removeEntry( const int UID ) |
116 | { | 116 | { |
117 | odebug << "AbView;:RemoveContact" << oendl; | 117 | odebug << "AbView;:RemoveContact" << oendl; |
118 | m_contactdb->remove( UID ); | 118 | m_contactdb->remove( UID ); |
119 | load(); | 119 | load(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) | 122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) |
123 | { | 123 | { |
124 | odebug << "AbView::ReplaceContact" << oendl; | 124 | odebug << "AbView::ReplaceContact" << oendl; |
125 | m_contactdb->replace( contact ); | 125 | m_contactdb->replace( contact ); |
126 | load(); | 126 | load(); |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | Opie::OPimContact AbView::currentEntry() | 130 | Opie::OPimContact AbView::currentEntry() |
131 | { | 131 | { |
132 | Opie::OPimContact currentContact; | 132 | Opie::OPimContact currentContact; |
133 | 133 | ||
134 | switch ( (int) m_curr_View ) { | 134 | switch ( (int) m_curr_View ) { |
135 | case TableView: | 135 | case TableView: |
136 | currentContact = m_abTable -> currentEntry(); | 136 | currentContact = m_abTable -> currentEntry(); |
137 | break; | 137 | break; |
138 | case CardView: | 138 | case CardView: |
139 | currentContact = m_ablabel -> currentEntry(); | 139 | currentContact = m_ablabel -> currentEntry(); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | m_curr_Contact = currentContact.uid(); | 142 | m_curr_Contact = currentContact.uid(); |
143 | return currentContact; | 143 | return currentContact; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool AbView::save() | 146 | bool AbView::save() |
147 | { | 147 | { |
148 | //odebug << "AbView::Save data" << oendl; | 148 | //odebug << "AbView::Save data" << oendl; |
149 | 149 | ||
150 | return m_contactdb->save(); | 150 | return m_contactdb->save(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void AbView::load() | 153 | void AbView::load() |
154 | { | 154 | { |
155 | odebug << "AbView::Load data" << oendl; | 155 | odebug << "AbView::Load data" << oendl; |
156 | 156 | ||
157 | // Letter Search is stopped at this place | 157 | // Letter Search is stopped at this place |
158 | emit signalClearLetterPicker(); | 158 | emit signalClearLetterPicker(); |
159 | 159 | ||
160 | if ( m_inPersonal ) | 160 | if ( m_curr_category == 0 ) { |
161 | // VCard Backend does not sort.. | 161 | // Show unfiled |
162 | m_list = m_contactdb->allRecords(); | 162 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
163 | else{ | 163 | Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); |
164 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 164 | } elseif ( m_curr_category != -1 ){ |
165 | if ( m_curr_category != -1 ) | 165 | // Just show selected category |
166 | clearForCategory(); | 166 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
167 | Opie::OPimBase::FilterCategory, m_curr_category ); | ||
168 | } else { | ||
169 | // Show all categories | ||
170 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
171 | Opie::OPimBase::FilterOff, 0 ); | ||
167 | } | 172 | } |
173 | |||
174 | // if ( m_curr_category != -1 ) | ||
175 | // clearForCategory(); | ||
168 | 176 | ||
169 | odebug << "Number of contacts: " << m_list.count() << oendl; | 177 | odebug << "Number of contacts: " << m_list.count() << oendl; |
170 | 178 | ||
171 | updateView( true ); | 179 | updateView( true ); |
172 | 180 | ||
173 | } | 181 | } |
174 | 182 | ||
175 | void AbView::reload() | 183 | void AbView::reload() |
176 | { | 184 | { |
177 | odebug << "AbView::::reload()" << oendl; | 185 | odebug << "AbView::::reload()" << oendl; |
178 | 186 | ||
179 | m_contactdb->reload(); | 187 | m_contactdb->reload(); |
180 | load(); | 188 | load(); |
181 | } | 189 | } |
182 | 190 | ||
183 | void AbView::clear() | 191 | void AbView::clear() |
184 | { | 192 | { |
185 | // :SX | 193 | // :SX |
186 | } | 194 | } |
187 | 195 | ||
188 | void AbView::setShowByCategory( const QString& cat ) | 196 | void AbView::setShowByCategory( const QString& cat ) |
189 | { | 197 | { |
190 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; | 198 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; |
191 | 199 | ||
192 | int intCat = 0; | 200 | int intCat = 0; |
193 | 201 | ||
194 | // All (cat == NULL) will be stored as -1 | 202 | // All (cat == NULL) will be stored as -1 |
195 | if ( cat.isNull() ) | 203 | if ( cat.isNull() ) |
196 | intCat = -1; | 204 | intCat = -1; |
197 | else | 205 | else |
198 | intCat = mCat.id("Contacts", cat ); | 206 | intCat = mCat.id("Contacts", cat ); |
199 | 207 | ||
200 | // Just do anything if we really change the category | 208 | // Just do anything if we really change the category |
201 | if ( intCat != m_curr_category ){ | 209 | if ( intCat != m_curr_category ){ |
202 | // odebug << "Categories: Selected " << cat << ".. Number: " | 210 | // odebug << "Categories: Selected " << cat << ".. Number: " |
203 | // << m_curr_category << oendl; | 211 | // << m_curr_category << oendl; |
204 | 212 | ||
205 | m_curr_category = intCat; | 213 | m_curr_category = intCat; |
206 | emit signalClearLetterPicker(); | 214 | emit signalClearLetterPicker(); |
207 | 215 | ||
208 | load(); | 216 | load(); |
209 | } | 217 | } |
210 | 218 | ||
211 | } | 219 | } |
212 | 220 | ||
213 | void AbView::setShowToView( Views view ) | 221 | void AbView::setShowToView( Views view ) |
214 | { | 222 | { |
215 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; | 223 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; |
216 | 224 | ||
217 | if ( m_curr_View != view ){ | 225 | if ( m_curr_View != view ){ |
218 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; | 226 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; |
219 | m_prev_View = m_curr_View; | 227 | m_prev_View = m_curr_View; |
220 | m_curr_View = view; | 228 | m_curr_View = view; |
221 | 229 | ||
222 | updateView(); | 230 | updateView(); |
223 | } | 231 | } |
224 | 232 | ||
225 | } | 233 | } |
226 | 234 | ||
227 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 235 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
228 | { | 236 | { |
229 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; | 237 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; |
230 | 238 | ||
231 | assert( mode < AbConfig::LASTELEMENT ); | 239 | assert( mode < AbConfig::LASTELEMENT ); |
232 | 240 | ||
233 | Opie::OPimContact query; | 241 | Opie::OPimContact query; |
234 | if ( c == 0 ){ | 242 | if ( c == 0 ){ |
235 | load(); | 243 | load(); |
236 | return; | 244 | return; |
237 | }else{ | 245 | }else{ |
238 | // If the current Backend is unable to solve the query, we will | 246 | // If the current Backend is unable to solve the query, we will |
239 | // ignore the request .. | 247 | // ignore the request .. |
240 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ) ){ | 248 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | |
249 | Opie::OPimContactAccess::IgnoreCase ) ){ | ||
250 | owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; | ||
251 | owarn << "I have to ignore this access!" << oendl; | ||
241 | return; | 252 | return; |
242 | } | 253 | } |
243 | 254 | ||
244 | switch( mode ){ | 255 | switch( mode ){ |
245 | case AbConfig::LastName: | 256 | case AbConfig::LastName: |
246 | query.setLastName( QString("%1*").arg(c) ); | 257 | query.setLastName( QString("%1*").arg(c) ); |
247 | break; | 258 | break; |
248 | case AbConfig::FileAs: | 259 | case AbConfig::FileAs: |
249 | query.setFileAs( QString("%1*").arg(c) ); | 260 | query.setFileAs( QString("%1*").arg(c) ); |
250 | break; | 261 | break; |
251 | default: | 262 | default: |
252 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl | 263 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl |
253 | << "I will ignore it.." << oendl; | 264 | << "I will ignore it.." << oendl; |
254 | return; | 265 | return; |
255 | } | 266 | } |
256 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); | 267 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); |
257 | if ( m_curr_category != -1 ) | 268 | if ( m_curr_category != -1 ) |
258 | clearForCategory(); | 269 | clearForCategory(); |
259 | m_curr_Contact = 0; | 270 | m_curr_Contact = 0; |
260 | } | 271 | } |
261 | updateView( true ); | 272 | updateView( true ); |
262 | } | 273 | } |
263 | 274 | ||
264 | void AbView::setListOrder( const QValueList<int>& ordered ) | 275 | void AbView::setListOrder( const QValueList<int>& ordered ) |
265 | { | 276 | { |
266 | m_orderedFields = ordered; | 277 | m_orderedFields = ordered; |
267 | if ( m_abTable ){ | 278 | if ( m_abTable ){ |
268 | m_abTable->setOrderedList( ordered ); | 279 | m_abTable->setOrderedList( ordered ); |
269 | m_abTable->refresh(); | 280 | m_abTable->refresh(); |
270 | } | 281 | } |
271 | updateView(); | 282 | updateView(); |
272 | } | 283 | } |
273 | 284 | ||
274 | 285 | ||
275 | QString AbView::showCategory() const | 286 | QString AbView::showCategory() const |
276 | { | 287 | { |
277 | return mCat.label( "Contacts", m_curr_category ); | 288 | return mCat.label( "Contacts", m_curr_category ); |
278 | } | 289 | } |
279 | 290 | ||
280 | void AbView::showPersonal( bool personal ) | 291 | void AbView::showPersonal( bool personal ) |
281 | { | 292 | { |
282 | odebug << "void AbView::showPersonal( " << personal << " )" << oendl; | 293 | odebug << "void AbView::showPersonal( " << personal << " )" << oendl; |
283 | 294 | ||
284 | if ( personal ){ | 295 | if ( personal ){ |
285 | 296 | ||
286 | if ( m_inPersonal ) | 297 | if ( m_inPersonal ) |
287 | return; | 298 | return; |
288 | 299 | ||
289 | // Now switch to vCard Backend and load data. | 300 | // Now switch to vCard Backend and load data. |
290 | // The current default backend will be stored | 301 | // The current default backend will be stored |
291 | // to avoid unneeded load/stores. | 302 | // to avoid unneeded load/stores. |
292 | m_storedDB = m_contactdb; | 303 | m_storedDB = m_contactdb; |
293 | 304 | ||
294 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 305 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
295 | addressbookPersonalVCardName() ); | 306 | addressbookPersonalVCardName() ); |
296 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 307 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
297 | 308 | ||
298 | m_inPersonal = true; | 309 | m_inPersonal = true; |
299 | m_curr_View = CardView; | 310 | m_curr_View = CardView; |
300 | 311 | ||
301 | }else{ | 312 | }else{ |
302 | 313 | ||
303 | if ( !m_inPersonal ) | 314 | if ( !m_inPersonal ) |
304 | return; | 315 | return; |
305 | 316 | ||
306 | // Remove vCard Backend and restore default | 317 | // Remove vCard Backend and restore default |
307 | m_contactdb->save(); | 318 | m_contactdb->save(); |
308 | delete m_contactdb; | 319 | delete m_contactdb; |
309 | 320 | ||
310 | m_contactdb = m_storedDB; | 321 | m_contactdb = m_storedDB; |
311 | m_storedDB = 0l; | 322 | m_storedDB = 0l; |
312 | 323 | ||
313 | m_curr_View = TableView; | 324 | m_curr_View = TableView; |
314 | m_inPersonal = false; | 325 | m_inPersonal = false; |
315 | 326 | ||
316 | } | 327 | } |
317 | load(); | 328 | load(); |
318 | } | 329 | } |
319 | 330 | ||
320 | void AbView::setCurrentUid( int uid ){ | 331 | void AbView::setCurrentUid( int uid ){ |
321 | 332 | ||
322 | m_curr_Contact = uid; | 333 | m_curr_Contact = uid; |
323 | updateView( true ); //true: Don't modificate the UID ! | 334 | updateView( true ); //true: Don't modificate the UID ! |
324 | } | 335 | } |
325 | 336 | ||
326 | 337 | ||
327 | QStringList AbView::categories() | 338 | QStringList AbView::categories() |
328 | { | 339 | { |
329 | mCat.load( categoryFileName() ); | 340 | mCat.load( categoryFileName() ); |
330 | QStringList categoryList = mCat.labels( "Contacts" ); | 341 | QStringList categoryList = mCat.labels( "Contacts" ); |
331 | return categoryList; | 342 | return categoryList; |
332 | } | 343 | } |
333 | 344 | ||
334 | // BEGIN: Slots | 345 | // BEGIN: Slots |
335 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 346 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
336 | bool , QString cat ) | 347 | bool , QString cat ) |
337 | { | 348 | { |
338 | //owarn << "void AbView::slotDoFind" << oendl; | 349 | //owarn << "void AbView::slotDoFind" << oendl; |
339 | 350 | ||
340 | // We reloading the data: Deselect Letterpicker | 351 | // We reloading the data: Deselect Letterpicker |
341 | emit signalClearLetterPicker(); | 352 | emit signalClearLetterPicker(); |
342 | 353 | ||
343 | // Use the current Category if nothing else selected | 354 | // Use the current Category if nothing else selected |
344 | int category = 0; | 355 | int category = 0; |
345 | 356 | ||
346 | if ( cat.isEmpty() ) | 357 | if ( cat.isEmpty() ) |
347 | category = m_curr_category; | 358 | category = m_curr_category; |
348 | else{ | 359 | else{ |
349 | category = mCat.id("Contacts", cat ); | 360 | category = mCat.id("Contacts", cat ); |
350 | } | 361 | } |
351 | 362 | ||
352 | //odebug << "Find in Category " << category << oendl; | 363 | //odebug << "Find in Category " << category << oendl; |
353 | 364 | ||
354 | QRegExp r( str ); | 365 | QRegExp r( str ); |
355 | r.setCaseSensitive( caseSensitive ); | 366 | r.setCaseSensitive( caseSensitive ); |
356 | r.setWildcard( !useRegExp ); | 367 | r.setWildcard( !useRegExp ); |
357 | 368 | ||
358 | // Get all matching entries out of the database | 369 | // Get all matching entries out of the database |
359 | m_list = m_contactdb->matchRegexp( r ); | 370 | m_list = m_contactdb->matchRegexp( r ); |
360 | 371 | ||
361 | //odebug << "Found: " << m_list.count() << oendl; | 372 | //odebug << "Found: " << m_list.count() << oendl; |
362 | if ( m_list.count() == 0 ){ | 373 | if ( m_list.count() == 0 ){ |
363 | emit signalNotFound(); | 374 | emit signalNotFound(); |
364 | return; | 375 | return; |
365 | } | 376 | } |
366 | 377 | ||
367 | // Now remove all contacts with wrong category (if any selected) | 378 | // Now remove all contacts with wrong category (if any selected) |
368 | // This algorithm is a litte bit ineffective, but | 379 | // This algorithm is a litte bit ineffective, but |
369 | // we will not have a lot of matching entries.. | 380 | // we will not have a lot of matching entries.. |
370 | if ( m_curr_category != -1 ) | 381 | if ( m_curr_category != -1 ) |
371 | clearForCategory(); | 382 | clearForCategory(); |
372 | 383 | ||
373 | // Now show all found entries | 384 | // Now show all found entries |
374 | updateView( true ); | 385 | updateView( true ); |
375 | } | 386 | } |
376 | 387 | ||
377 | void AbView::offSearch() | 388 | void AbView::offSearch() |
378 | { | 389 | { |
379 | m_inSearch = false; | 390 | m_inSearch = false; |
380 | 391 | ||
381 | load(); | 392 | load(); |
382 | } | 393 | } |
383 | 394 | ||
384 | void AbView::slotSwitch(){ | 395 | void AbView::slotSwitch(){ |
385 | //odebug << "AbView::slotSwitch()" << oendl; | 396 | //odebug << "AbView::slotSwitch()" << oendl; |
386 | 397 | ||
387 | m_prev_View = m_curr_View; | 398 | m_prev_View = m_curr_View; |
388 | switch ( (int) m_curr_View ){ | 399 | switch ( (int) m_curr_View ){ |
389 | case TableView: | 400 | case TableView: |
390 | odebug << "Switching to CardView" << oendl; | 401 | odebug << "Switching to CardView" << oendl; |
391 | m_curr_View = CardView; | 402 | m_curr_View = CardView; |
392 | break; | 403 | break; |
393 | case CardView: | 404 | case CardView: |
394 | odebug << "Switching to TableView" << oendl; | 405 | odebug << "Switching to TableView" << oendl; |
395 | m_curr_View = TableView; | 406 | m_curr_View = TableView; |
396 | break; | 407 | break; |
397 | } | 408 | } |
398 | updateView(); | 409 | updateView(); |
399 | 410 | ||
400 | } | 411 | } |
401 | 412 | ||
402 | // END: Slots | 413 | // END: Slots |
403 | 414 | ||
404 | void AbView::clearForCategory() | 415 | void AbView::clearForCategory() |
405 | { | 416 | { |
406 | Opie::OPimContactAccess::List::Iterator it; | 417 | Opie::OPimContactAccess::List::Iterator it; |
407 | // Now remove all contacts with wrong category if any category selected | 418 | // Now remove all contacts with wrong category if any category selected |
408 | 419 | ||
409 | Opie::OPimContactAccess::List allList = m_list; | 420 | Opie::OPimContactAccess::List allList = m_list; |
410 | if ( m_curr_category != -1 ){ | 421 | if ( m_curr_category != -1 ){ |
411 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 422 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
412 | if ( !contactCompare( *it, m_curr_category ) ){ | 423 | if ( !contactCompare( *it, m_curr_category ) ){ |
413 | //odebug << "Removing " << (*it).uid() << oendl; | 424 | //odebug << "Removing " << (*it).uid() << oendl; |
414 | m_list.remove( (*it).uid() ); | 425 | m_list.remove( (*it).uid() ); |
415 | } | 426 | } |
416 | } | 427 | } |
417 | } | 428 | } |
418 | 429 | ||
419 | } | 430 | } |
420 | 431 | ||
421 | bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) | 432 | bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) |
422 | { | 433 | { |
423 | //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " | 434 | //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " |
424 | // << category << " )" << oendl; | 435 | // << category << " )" << oendl; |
425 | 436 | ||
426 | bool returnMe; | 437 | bool returnMe; |
427 | QArray<int> cats; | 438 | QArray<int> cats; |
428 | cats = cnt.categories(); | 439 | cats = cnt.categories(); |
429 | 440 | ||
430 | //odebug << "Number of categories: " << cats.count() << oendl; | 441 | //odebug << "Number of categories: " << cats.count() << oendl; |
431 | 442 | ||
432 | returnMe = false; | 443 | returnMe = false; |
433 | if ( cats.count() == 0 && category == 0 ) | 444 | if ( cats.count() == 0 && category == 0 ) |
434 | // Contacts with no category will just shown on "All" and "Unfiled" | 445 | // Contacts with no category will just shown on "All" and "Unfiled" |
435 | returnMe = true; | 446 | returnMe = true; |
436 | else { | 447 | else { |
437 | int i; | 448 | int i; |
438 | for ( i = 0; i < int(cats.count()); i++ ) { | 449 | for ( i = 0; i < int(cats.count()); i++ ) { |
439 | //odebug << "Comparing " << cats[i] << " with " << category << oendl; | 450 | //odebug << "Comparing " << cats[i] << " with " << category << oendl; |
440 | if ( cats[i] == category ) { | 451 | if ( cats[i] == category ) { |
441 | returnMe = true; | 452 | returnMe = true; |
442 | break; | 453 | break; |
443 | } | 454 | } |
444 | } | 455 | } |
445 | } | 456 | } |
446 | //odebug << "Return: " << returnMe << oendl; | 457 | //odebug << "Return: " << returnMe << oendl; |
447 | return returnMe; | 458 | return returnMe; |
448 | } | 459 | } |
449 | 460 | ||
450 | // In Some rare cases we have to update all lists.. | 461 | // In Some rare cases we have to update all lists.. |
451 | void AbView::updateListinViews() | 462 | void AbView::updateListinViews() |
452 | { | 463 | { |
453 | m_abTable -> setContacts( m_list ); | 464 | m_abTable -> setContacts( m_list ); |
454 | m_ablabel -> setContacts( m_list ); | 465 | m_ablabel -> setContacts( m_list ); |
455 | } | 466 | } |
456 | 467 | ||
457 | void AbView::updateView( bool newdata ) | 468 | void AbView::updateView( bool newdata ) |
458 | { | 469 | { |
459 | //odebug << "AbView::updateView()" << oendl; | 470 | //odebug << "AbView::updateView()" << oendl; |
460 | 471 | ||
461 | if ( m_viewStack -> visibleWidget() ){ | 472 | if ( m_viewStack -> visibleWidget() ){ |
462 | m_viewStack -> visibleWidget() -> clearFocus(); | 473 | m_viewStack -> visibleWidget() -> clearFocus(); |
463 | } | 474 | } |
464 | 475 | ||
465 | // If we switching the view, we have to store some information | 476 | // If we switching the view, we have to store some information |
466 | if ( !newdata ){ | 477 | if ( !newdata ){ |
467 | if ( m_list.count() ){ | 478 | if ( m_list.count() ){ |
468 | switch ( (int) m_prev_View ) { | 479 | switch ( (int) m_prev_View ) { |
469 | case TableView: | 480 | case TableView: |
470 | m_curr_Contact = m_abTable -> currentEntry_UID(); | 481 | m_curr_Contact = m_abTable -> currentEntry_UID(); |
471 | break; | 482 | break; |
472 | case CardView: | 483 | case CardView: |
473 | m_curr_Contact = m_ablabel -> currentEntry_UID(); | 484 | m_curr_Contact = m_ablabel -> currentEntry_UID(); |
474 | break; | 485 | break; |
475 | } | 486 | } |
476 | }else | 487 | }else |
477 | m_curr_Contact = 0; | 488 | m_curr_Contact = 0; |
478 | } | 489 | } |
479 | 490 | ||
480 | // Feed all views with new lists | 491 | // Feed all views with new lists |
481 | if ( newdata ) | 492 | if ( newdata ) |
482 | updateListinViews(); | 493 | updateListinViews(); |
483 | 494 | ||
484 | // Tell the world that the view is changed | 495 | // Tell the world that the view is changed |
485 | if ( m_curr_View != m_prev_View ) | 496 | if ( m_curr_View != m_prev_View ) |
486 | emit signalViewSwitched ( (int) m_curr_View ); | 497 | emit signalViewSwitched ( (int) m_curr_View ); |
487 | 498 | ||
488 | m_prev_View = m_curr_View; | 499 | m_prev_View = m_curr_View; |
489 | 500 | ||
490 | // Switch to new View | 501 | // Switch to new View |
491 | switch ( (int) m_curr_View ) { | 502 | switch ( (int) m_curr_View ) { |
492 | case TableView: | 503 | case TableView: |
493 | m_abTable -> setChoiceSelection( m_orderedFields ); | 504 | m_abTable -> setChoiceSelection( m_orderedFields ); |
494 | if ( m_curr_Contact != 0 ) | 505 | if ( m_curr_Contact != 0 ) |
495 | m_abTable -> selectContact ( m_curr_Contact ); | 506 | m_abTable -> selectContact ( m_curr_Contact ); |
496 | m_abTable -> setFocus(); | 507 | m_abTable -> setFocus(); |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 835038a..0654e1a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -99,512 +99,519 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
99 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), | 99 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
100 | QString::null, 0, this, 0 ); | 100 | QString::null, 0, this, 0 ); |
101 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 101 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
102 | m_tableViewButton->setToggleAction( true ); | 102 | m_tableViewButton->setToggleAction( true ); |
103 | m_tableViewButton->addTo( listTools ); | 103 | m_tableViewButton->addTo( listTools ); |
104 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); | 104 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
105 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 105 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
106 | m_cardViewButton->setToggleAction( true ); | 106 | m_cardViewButton->setToggleAction( true ); |
107 | m_cardViewButton->addTo( listTools ); | 107 | m_cardViewButton->addTo( listTools ); |
108 | 108 | ||
109 | listTools->addSeparator(); | 109 | listTools->addSeparator(); |
110 | 110 | ||
111 | // Other Buttons | 111 | // Other Buttons |
112 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 112 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
113 | 0, this, 0 ); | 113 | 0, this, 0 ); |
114 | actionNew = a; | 114 | actionNew = a; |
115 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 115 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
116 | a->addTo( edit ); | 116 | a->addTo( edit ); |
117 | a->addTo( listTools ); | 117 | a->addTo( listTools ); |
118 | 118 | ||
119 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 119 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
120 | 0, this, 0 ); | 120 | 0, this, 0 ); |
121 | actionEdit = a; | 121 | actionEdit = a; |
122 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 122 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
123 | a->addTo( edit ); | 123 | a->addTo( edit ); |
124 | a->addTo( listTools ); | 124 | a->addTo( listTools ); |
125 | 125 | ||
126 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 126 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
127 | 0, this, 0 ); | 127 | 0, this, 0 ); |
128 | actionTrash = a; | 128 | actionTrash = a; |
129 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 129 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
130 | a->addTo( edit ); | 130 | a->addTo( edit ); |
131 | a->addTo( listTools ); | 131 | a->addTo( listTools ); |
132 | 132 | ||
133 | 133 | ||
134 | // make it possible to go directly to businesscard via qcop call | 134 | // make it possible to go directly to businesscard via qcop call |
135 | //#if defined(Q_WS_QWS) // Why this ? (se) | 135 | //#if defined(Q_WS_QWS) // Why this ? (se) |
136 | #if !defined(QT_NO_COP) | 136 | #if !defined(QT_NO_COP) |
137 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 137 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
138 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), | 138 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), |
139 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); | 139 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); |
140 | #endif | 140 | #endif |
141 | // #endif | 141 | // #endif |
142 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 142 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
143 | QString::null, 0, this, 0 ); | 143 | QString::null, 0, this, 0 ); |
144 | actionFind = a; | 144 | actionFind = a; |
145 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 145 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
146 | a->addTo( edit ); | 146 | a->addTo( edit ); |
147 | a->addTo( listTools ); | 147 | a->addTo( listTools ); |
148 | 148 | ||
149 | // Much better search widget, taken from QTReader.. (se) | 149 | // Much better search widget, taken from QTReader.. (se) |
150 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 150 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
151 | searchBar->setHorizontalStretchable( TRUE ); | 151 | searchBar->setHorizontalStretchable( TRUE ); |
152 | searchBar->hide(); | 152 | searchBar->hide(); |
153 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 153 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
154 | 154 | ||
155 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 155 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
156 | // searchEdit->setFont( f ); | 156 | // searchEdit->setFont( f ); |
157 | 157 | ||
158 | searchBar->setStretchableWidget( searchEdit ); | 158 | searchBar->setStretchableWidget( searchEdit ); |
159 | connect( searchEdit, SIGNAL( returnPressed() ), | 159 | connect( searchEdit, SIGNAL( returnPressed() ), |
160 | this, SLOT( slotFind() ) ); | 160 | this, SLOT( slotFind() ) ); |
161 | 161 | ||
162 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 162 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
163 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 163 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
164 | a->addTo( searchBar ); | 164 | a->addTo( searchBar ); |
165 | 165 | ||
166 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 166 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 167 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
168 | a->addTo( searchBar ); | 168 | a->addTo( searchBar ); |
169 | 169 | ||
170 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 170 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
171 | QString::null, 0, this, 0 ); | 171 | QString::null, 0, this, 0 ); |
172 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 172 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
173 | actionMail = a; | 173 | actionMail = a; |
174 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 174 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
175 | a->addTo( edit ); | 175 | a->addTo( edit ); |
176 | a->addTo( listTools ); | 176 | a->addTo( listTools ); |
177 | 177 | ||
178 | if ( Ir::supported() ) { | 178 | if ( Ir::supported() ) { |
179 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 179 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
180 | 0, this, 0 ); | 180 | 0, this, 0 ); |
181 | actionBeam = a; | 181 | actionBeam = a; |
182 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 182 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
183 | a->addTo( edit ); | 183 | a->addTo( edit ); |
184 | a->addTo( listTools ); | 184 | a->addTo( listTools ); |
185 | } | 185 | } |
186 | 186 | ||
187 | edit->insertSeparator(); | 187 | edit->insertSeparator(); |
188 | 188 | ||
189 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 189 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
190 | 0, this, 0); | 190 | 0, this, 0); |
191 | actionPersonal = a; | 191 | actionPersonal = a; |
192 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
193 | a->addTo( edit ); | 193 | a->addTo( edit ); |
194 | 194 | ||
195 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 195 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
196 | 0, this, 0); | 196 | 0, this, 0); |
197 | actionPersonal = a; | 197 | actionPersonal = a; |
198 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
199 | a->addTo( edit ); | 199 | a->addTo( edit ); |
200 | 200 | ||
201 | edit->insertSeparator(); | 201 | edit->insertSeparator(); |
202 | 202 | ||
203 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 203 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
204 | QString::null, 0, this, 0 , TRUE ); | 204 | QString::null, 0, this, 0 , TRUE ); |
205 | actionPersonal = a; | 205 | actionPersonal = a; |
206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
207 | a->addTo( edit ); | 207 | a->addTo( edit ); |
208 | 208 | ||
209 | 209 | ||
210 | #ifdef __DEBUG_RELEASE | 210 | #ifdef __DEBUG_RELEASE |
211 | // Remove this function for public Release ! This is only | 211 | // Remove this function for public Release ! This is only |
212 | // for debug purposes .. | 212 | // for debug purposes .. |
213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
215 | a->addTo( edit ); | 215 | a->addTo( edit ); |
216 | #endif | 216 | #endif |
217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
218 | 0, this, 0 ); | 218 | 0, this, 0 ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
220 | a->addTo( edit ); | 220 | a->addTo( edit ); |
221 | 221 | ||
222 | // Create Views | 222 | // Create Views |
223 | listContainer = new QWidget( this ); | 223 | listContainer = new QWidget( this ); |
224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
225 | 225 | ||
226 | m_abView = new AbView( listContainer, m_config.orderList() ); | 226 | m_abView = new AbView( listContainer, m_config.orderList() ); |
227 | vb->addWidget( m_abView ); | 227 | vb->addWidget( m_abView ); |
228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
229 | connect( m_abView, SIGNAL( signalViewSwitched(int) ), | 229 | connect( m_abView, SIGNAL( signalViewSwitched(int) ), |
230 | this, SLOT( slotViewSwitched(int) ) ); | 230 | this, SLOT( slotViewSwitched(int) ) ); |
231 | 231 | ||
232 | 232 | ||
233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
234 | 234 | ||
235 | // m_abView->load(); // Already done by c'tor . | 235 | // m_abView->load(); // Already done by c'tor . |
236 | 236 | ||
237 | // Letter Picker | 237 | // Letter Picker |
238 | pLabel = new LetterPicker( listContainer ); | 238 | pLabel = new LetterPicker( listContainer ); |
239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
241 | 241 | ||
242 | vb->addWidget( pLabel ); | 242 | vb->addWidget( pLabel ); |
243 | 243 | ||
244 | // All Categories into view-menu.. | 244 | // All Categories into view-menu.. |
245 | populateCategories(); | 245 | populateCategories(); |
246 | 246 | ||
247 | // Fontsize | 247 | // Fontsize |
248 | defaultFont = new QFont( m_abView->font() ); | 248 | defaultFont = new QFont( m_abView->font() ); |
249 | slotSetFont(m_config.fontSize()); | 249 | slotSetFont(m_config.fontSize()); |
250 | m_curFontSize = m_config.fontSize(); | 250 | m_curFontSize = m_config.fontSize(); |
251 | 251 | ||
252 | setCentralWidget(listContainer); | 252 | setCentralWidget(listContainer); |
253 | 253 | ||
254 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; | 254 | //odebug << "adressbook contrsuction: t=" << t.elapsed() << oendl; |
255 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 255 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
256 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); | 256 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); |
257 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 257 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
258 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 258 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
259 | 259 | ||
260 | 260 | ||
261 | isLoading = false; | 261 | isLoading = false; |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | void AddressbookWindow::slotConfig() | 265 | void AddressbookWindow::slotConfig() |
266 | { | 266 | { |
267 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 267 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
268 | dlg -> setConfig( m_config ); | 268 | dlg -> setConfig( m_config ); |
269 | if ( QPEApplication::execDialog( dlg ) ) { | 269 | if ( QPEApplication::execDialog( dlg ) ) { |
270 | odebug << "Config Dialog accepted!" << oendl; | 270 | odebug << "Config Dialog accepted!" << oendl; |
271 | m_config = dlg -> getConfig(); | 271 | m_config = dlg -> getConfig(); |
272 | if ( m_curFontSize != m_config.fontSize() ){ | 272 | if ( m_curFontSize != m_config.fontSize() ){ |
273 | odebug << "Font was changed!" << oendl; | 273 | odebug << "Font was changed!" << oendl; |
274 | m_curFontSize = m_config.fontSize(); | 274 | m_curFontSize = m_config.fontSize(); |
275 | emit slotSetFont( m_curFontSize ); | 275 | emit slotSetFont( m_curFontSize ); |
276 | } | 276 | } |
277 | m_abView -> setListOrder( m_config.orderList() ); | 277 | m_abView -> setListOrder( m_config.orderList() ); |
278 | } | 278 | } |
279 | 279 | ||
280 | delete dlg; | 280 | delete dlg; |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AddressbookWindow::slotSetFont( int size ) | 284 | void AddressbookWindow::slotSetFont( int size ) |
285 | { | 285 | { |
286 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; | 286 | odebug << "void AddressbookWindow::slotSetFont( " << size << " )" << oendl; |
287 | 287 | ||
288 | if (size > 2 || size < 0) | 288 | if (size > 2 || size < 0) |
289 | size = 1; | 289 | size = 1; |
290 | 290 | ||
291 | m_config.setFontSize( size ); | 291 | m_config.setFontSize( size ); |
292 | 292 | ||
293 | QFont *currentFont; | 293 | QFont *currentFont; |
294 | 294 | ||
295 | switch (size) { | 295 | switch (size) { |
296 | case 0: | 296 | case 0: |
297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
298 | currentFont = new QFont (m_abView->font()); | 298 | currentFont = new QFont (m_abView->font()); |
299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
300 | // abList->resizeRows(); | 300 | // abList->resizeRows(); |
301 | break; | 301 | break; |
302 | case 1: | 302 | case 1: |
303 | m_abView->setFont( *defaultFont ); | 303 | m_abView->setFont( *defaultFont ); |
304 | currentFont = new QFont (m_abView->font()); | 304 | currentFont = new QFont (m_abView->font()); |
305 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 305 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
306 | // abList->resizeRows(); | 306 | // abList->resizeRows(); |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
310 | currentFont = new QFont (m_abView->font()); | 310 | currentFont = new QFont (m_abView->font()); |
311 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 311 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
312 | // abList->resizeRows(); | 312 | // abList->resizeRows(); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | 318 | ||
319 | void AddressbookWindow::importvCard() { | 319 | void AddressbookWindow::importvCard() { |
320 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 320 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
321 | if(!str.isEmpty() ){ | 321 | if(!str.isEmpty() ){ |
322 | setDocument((const QString&) str ); | 322 | setDocument((const QString&) str ); |
323 | } | 323 | } |
324 | 324 | ||
325 | } | 325 | } |
326 | void AddressbookWindow::exportvCard() | 326 | void AddressbookWindow::exportvCard() |
327 | { | 327 | { |
328 | odebug << "void AddressbookWindow::exportvCard()" << oendl; | 328 | odebug << "void AddressbookWindow::exportvCard()" << oendl; |
329 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 329 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
330 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 330 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
331 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; | 331 | odebug << " Save to file " << filename << ", (" << filename.length()-1 << ")" << oendl; |
332 | Opie::OPimContact curCont = m_abView->currentEntry(); | 332 | Opie::OPimContact curCont = m_abView->currentEntry(); |
333 | if ( !curCont.isEmpty() ){ | 333 | if ( !curCont.isEmpty() ){ |
334 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 334 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
335 | filename ); | 335 | filename ); |
336 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 336 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
337 | if ( access ){ | 337 | if ( access ){ |
338 | access->add( curCont ); | 338 | access->add( curCont ); |
339 | access->save(); | 339 | access->save(); |
340 | } | 340 | } |
341 | delete access; | 341 | delete access; |
342 | }else | 342 | }else |
343 | QMessageBox::critical( 0, "Export VCard", | 343 | QMessageBox::critical( 0, "Export VCard", |
344 | QString( tr( "You have to select a contact !") ) ); | 344 | QString( tr( "You have to select a contact !") ) ); |
345 | 345 | ||
346 | }else | 346 | }else |
347 | QMessageBox::critical( 0, "Export VCard", | 347 | QMessageBox::critical( 0, "Export VCard", |
348 | QString( tr( "You have to set a filename !") ) ); | 348 | QString( tr( "You have to set a filename !") ) ); |
349 | } | 349 | } |
350 | 350 | ||
351 | void AddressbookWindow::setDocument( const QString &filename ) | 351 | void AddressbookWindow::setDocument( const QString &filename ) |
352 | { | 352 | { |
353 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; | 353 | odebug << "void AddressbookWindow::setDocument( " << filename << " )" << oendl; |
354 | 354 | ||
355 | // Switch to default backend. This should avoid to import into | ||
356 | // the personal database accidently. | ||
357 | if ( actionPersonal->isOn() ){ | ||
358 | actionPersonal->setOn( false ); | ||
359 | slotPersonalView(); | ||
360 | } | ||
361 | |||
355 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 362 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
356 | 363 | ||
357 | 364 | ||
358 | 365 | ||
359 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 366 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
360 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 367 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
361 | tr( "&Yes" ), tr( "&No" ), QString::null, | 368 | tr( "&Yes" ), tr( "&No" ), QString::null, |
362 | 0, // Enter == button 0 | 369 | 0, // Enter == button 0 |
363 | 2 ) ) { // Escape == button 2 | 370 | 2 ) ) { // Escape == button 2 |
364 | case 0: | 371 | case 0: |
365 | odebug << "YES clicked" << oendl; | 372 | odebug << "YES clicked" << oendl; |
366 | break; | 373 | break; |
367 | case 1: | 374 | case 1: |
368 | odebug << "NO clicked" << oendl; | 375 | odebug << "NO clicked" << oendl; |
369 | return; | 376 | return; |
370 | break; | 377 | break; |
371 | } | 378 | } |
372 | } | 379 | } |
373 | 380 | ||
374 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 381 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
375 | filename ); | 382 | filename ); |
376 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 383 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
377 | Opie::OPimContactAccess::List allList = access->allRecords(); | 384 | Opie::OPimContactAccess::List allList = access->allRecords(); |
378 | odebug << "Found number of contacts in File: " << allList.count() << oendl; | 385 | odebug << "Found number of contacts in File: " << allList.count() << oendl; |
379 | 386 | ||
380 | if ( !allList.count() ) { | 387 | if ( !allList.count() ) { |
381 | QMessageBox::information( this, "Import VCard", | 388 | QMessageBox::information( this, "Import VCard", |
382 | "It was impossible to import\nthe VCard.\n" | 389 | "It was impossible to import\nthe VCard.\n" |
383 | "The VCard may be corrupted!" ); | 390 | "The VCard may be corrupted!" ); |
384 | } | 391 | } |
385 | 392 | ||
386 | bool doAsk = true; | 393 | bool doAsk = true; |
387 | Opie::OPimContactAccess::List::Iterator it; | 394 | Opie::OPimContactAccess::List::Iterator it; |
388 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 395 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
389 | odebug << "Adding Contact from: " << (*it).fullName() << oendl; | 396 | odebug << "Adding Contact from: " << (*it).fullName() << oendl; |
390 | if ( doAsk ){ | 397 | if ( doAsk ){ |
391 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 398 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
392 | tr( "Do you really want add contact for \n%1?" ) | 399 | tr( "Do you really want add contact for \n%1?" ) |
393 | .arg( (*it).fullName().latin1() ), | 400 | .arg( (*it).fullName().latin1() ), |
394 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 401 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
395 | 0, // Enter == button 0 | 402 | 0, // Enter == button 0 |
396 | 2 ) ) { // Escape == button 2 | 403 | 2 ) ) { // Escape == button 2 |
397 | case 0: | 404 | case 0: |
398 | odebug << "YES clicked" << oendl; | 405 | odebug << "YES clicked" << oendl; |
399 | m_abView->addEntry( *it ); | 406 | m_abView->addEntry( *it ); |
400 | break; | 407 | break; |
401 | case 1: | 408 | case 1: |
402 | odebug << "NO clicked" << oendl; | 409 | odebug << "NO clicked" << oendl; |
403 | break; | 410 | break; |
404 | case 2: | 411 | case 2: |
405 | odebug << "YesAll clicked" << oendl; | 412 | odebug << "YesAll clicked" << oendl; |
406 | doAsk = false; | 413 | doAsk = false; |
407 | break; | 414 | break; |
408 | } | 415 | } |
409 | }else | 416 | }else |
410 | m_abView->addEntry( *it ); | 417 | m_abView->addEntry( *it ); |
411 | 418 | ||
412 | } | 419 | } |
413 | 420 | ||
414 | delete access; | 421 | delete access; |
415 | } | 422 | } |
416 | 423 | ||
417 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 424 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
418 | { | 425 | { |
419 | QMainWindow::resizeEvent( e ); | 426 | QMainWindow::resizeEvent( e ); |
420 | 427 | ||
421 | 428 | ||
422 | } | 429 | } |
423 | 430 | ||
424 | AddressbookWindow::~AddressbookWindow() | 431 | AddressbookWindow::~AddressbookWindow() |
425 | { | 432 | { |
426 | ToolBarDock dock; | 433 | ToolBarDock dock; |
427 | int dummy; | 434 | int dummy; |
428 | bool bDummy; | 435 | bool bDummy; |
429 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 436 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
430 | m_config.setToolBarDock( dock ); | 437 | m_config.setToolBarDock( dock ); |
431 | m_config.save(); | 438 | m_config.save(); |
432 | } | 439 | } |
433 | 440 | ||
434 | void AddressbookWindow::slotUpdateToolbar() | 441 | void AddressbookWindow::slotUpdateToolbar() |
435 | { | 442 | { |
436 | Opie::OPimContact ce = m_abView->currentEntry(); | 443 | Opie::OPimContact ce = m_abView->currentEntry(); |
437 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 444 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
438 | } | 445 | } |
439 | 446 | ||
440 | void AddressbookWindow::slotListNew() | 447 | void AddressbookWindow::slotListNew() |
441 | { | 448 | { |
442 | Opie::OPimContact cnt; | 449 | Opie::OPimContact cnt; |
443 | if( !syncing ) { | 450 | if( !syncing ) { |
444 | editEntry( NewEntry ); | 451 | editEntry( NewEntry ); |
445 | } else { | 452 | } else { |
446 | QMessageBox::warning(this, tr("Contacts"), | 453 | QMessageBox::warning(this, tr("Contacts"), |
447 | tr("Can not edit data, currently syncing")); | 454 | tr("Can not edit data, currently syncing")); |
448 | } | 455 | } |
449 | } | 456 | } |
450 | 457 | ||
451 | // void AddressbookWindow::slotListView() | 458 | // void AddressbookWindow::slotListView() |
452 | // { | 459 | // { |
453 | // m_abView -> init( abList->currentEntry() ); | 460 | // m_abView -> init( abList->currentEntry() ); |
454 | // // :SX mView->sync(); | 461 | // // :SX mView->sync(); |
455 | // //:SXshowView(); | 462 | // //:SXshowView(); |
456 | // } | 463 | // } |
457 | 464 | ||
458 | void AddressbookWindow::slotListDelete() | 465 | void AddressbookWindow::slotListDelete() |
459 | { | 466 | { |
460 | if(!syncing) { | 467 | if(!syncing) { |
461 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); | 468 | Opie::OPimContact tmpEntry = m_abView ->currentEntry(); |
462 | 469 | ||
463 | // get a name, do the best we can... | 470 | // get a name, do the best we can... |
464 | QString strName = tmpEntry.fullName(); | 471 | QString strName = tmpEntry.fullName(); |
465 | if ( strName.isEmpty() ) { | 472 | if ( strName.isEmpty() ) { |
466 | strName = tmpEntry.company(); | 473 | strName = tmpEntry.company(); |
467 | if ( strName.isEmpty() ) | 474 | if ( strName.isEmpty() ) |
468 | strName = "No Name"; | 475 | strName = "No Name"; |
469 | } | 476 | } |
470 | 477 | ||
471 | 478 | ||
472 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 479 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
473 | strName ) ) { | 480 | strName ) ) { |
474 | m_abView->removeEntry( tmpEntry.uid() ); | 481 | m_abView->removeEntry( tmpEntry.uid() ); |
475 | } | 482 | } |
476 | } else { | 483 | } else { |
477 | QMessageBox::warning( this, tr("Contacts"), | 484 | QMessageBox::warning( this, tr("Contacts"), |
478 | tr("Can not edit data, currently syncing") ); | 485 | tr("Can not edit data, currently syncing") ); |
479 | } | 486 | } |
480 | } | 487 | } |
481 | 488 | ||
482 | void AddressbookWindow::slotFindOpen() | 489 | void AddressbookWindow::slotFindOpen() |
483 | { | 490 | { |
484 | searchBar->show(); | 491 | searchBar->show(); |
485 | m_abView -> inSearch(); | 492 | m_abView -> inSearch(); |
486 | searchEdit->setFocus(); | 493 | searchEdit->setFocus(); |
487 | } | 494 | } |
488 | void AddressbookWindow::slotFindClose() | 495 | void AddressbookWindow::slotFindClose() |
489 | { | 496 | { |
490 | searchBar->hide(); | 497 | searchBar->hide(); |
491 | m_abView -> offSearch(); | 498 | m_abView -> offSearch(); |
492 | // m_abView->setFocus(); | 499 | // m_abView->setFocus(); |
493 | } | 500 | } |
494 | 501 | ||
495 | 502 | ||
496 | void AddressbookWindow::slotFind() | 503 | void AddressbookWindow::slotFind() |
497 | { | 504 | { |
498 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 505 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
499 | 506 | ||
500 | searchEdit->clearFocus(); | 507 | searchEdit->clearFocus(); |
501 | // m_abView->setFocus(); | 508 | // m_abView->setFocus(); |
502 | 509 | ||
503 | } | 510 | } |
504 | 511 | ||
505 | void AddressbookWindow::slotViewBack() | 512 | void AddressbookWindow::slotViewBack() |
506 | { | 513 | { |
507 | // :SX showList(); | 514 | // :SX showList(); |
508 | } | 515 | } |
509 | 516 | ||
510 | void AddressbookWindow::slotViewEdit() | 517 | void AddressbookWindow::slotViewEdit() |
511 | { | 518 | { |
512 | if(!syncing) { | 519 | if(!syncing) { |
513 | if (actionPersonal->isOn()) { | 520 | if (actionPersonal->isOn()) { |
514 | editPersonal(); | 521 | editPersonal(); |
515 | } else { | 522 | } else { |
516 | editEntry( EditEntry ); | 523 | editEntry( EditEntry ); |
517 | } | 524 | } |
518 | } else { | 525 | } else { |
519 | QMessageBox::warning( this, tr("Contacts"), | 526 | QMessageBox::warning( this, tr("Contacts"), |
520 | tr("Can not edit data, currently syncing") ); | 527 | tr("Can not edit data, currently syncing") ); |
521 | } | 528 | } |
522 | } | 529 | } |
523 | 530 | ||
524 | 531 | ||
525 | 532 | ||
526 | void AddressbookWindow::writeMail() | 533 | void AddressbookWindow::writeMail() |
527 | { | 534 | { |
528 | Opie::OPimContact c = m_abView -> currentEntry(); | 535 | Opie::OPimContact c = m_abView -> currentEntry(); |
529 | QString name = c.fileAs(); | 536 | QString name = c.fileAs(); |
530 | QString email = c.defaultEmail(); | 537 | QString email = c.defaultEmail(); |
531 | 538 | ||
532 | // I prefer the OPIE-Environment variable before the | 539 | // I prefer the OPIE-Environment variable before the |
533 | // QPE-one.. | 540 | // QPE-one.. |
534 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 541 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
535 | if ( basepath.isEmpty() ) | 542 | if ( basepath.isEmpty() ) |
536 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 543 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
537 | 544 | ||
538 | // Try to access the preferred. If not possible, try to | 545 | // Try to access the preferred. If not possible, try to |
539 | // switch to the other one.. | 546 | // switch to the other one.. |
540 | if ( m_config.useQtMail() ){ | 547 | if ( m_config.useQtMail() ){ |
541 | odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; | 548 | odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; |
542 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 549 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
543 | odebug << "QCop" << oendl; | 550 | odebug << "QCop" << oendl; |
544 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 551 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
545 | e << name << email; | 552 | e << name << email; |
546 | return; | 553 | return; |
547 | } else | 554 | } else |
548 | m_config.setUseOpieMail( true ); | 555 | m_config.setUseOpieMail( true ); |
549 | } | 556 | } |
550 | if ( m_config.useOpieMail() ){ | 557 | if ( m_config.useOpieMail() ){ |
551 | odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; | 558 | odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; |
552 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ | 559 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ |
553 | odebug << "QCop" << oendl; | 560 | odebug << "QCop" << oendl; |
554 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); | 561 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); |
555 | e << name << email; | 562 | e << name << email; |
556 | return; | 563 | return; |
557 | } else | 564 | } else |
558 | m_config.setUseQtMail( true ); | 565 | m_config.setUseQtMail( true ); |
559 | } | 566 | } |
560 | 567 | ||
561 | } | 568 | } |
562 | 569 | ||
563 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 570 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
564 | 571 | ||
565 | void AddressbookWindow::slotBeam() | 572 | void AddressbookWindow::slotBeam() |
566 | { | 573 | { |
567 | QString beamFilename; | 574 | QString beamFilename; |
568 | Opie::OPimContact c; | 575 | Opie::OPimContact c; |
569 | if ( actionPersonal->isOn() ) { | 576 | if ( actionPersonal->isOn() ) { |
570 | beamFilename = addressbookPersonalVCardName(); | 577 | beamFilename = addressbookPersonalVCardName(); |
571 | if ( !QFile::exists( beamFilename ) ) | 578 | if ( !QFile::exists( beamFilename ) ) |
572 | return; // can't beam a non-existent file | 579 | return; // can't beam a non-existent file |
573 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 580 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
574 | beamFilename ); | 581 | beamFilename ); |
575 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 582 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
576 | Opie::OPimContactAccess::List allList = access->allRecords(); | 583 | Opie::OPimContactAccess::List allList = access->allRecords(); |
577 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 584 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
578 | c = *it; | 585 | c = *it; |
579 | 586 | ||
580 | delete access; | 587 | delete access; |
581 | } else { | 588 | } else { |
582 | unlink( beamfile ); // delete if exists | 589 | unlink( beamfile ); // delete if exists |
583 | mkdir("/tmp/obex/", 0755); | 590 | mkdir("/tmp/obex/", 0755); |
584 | c = m_abView -> currentEntry(); | 591 | c = m_abView -> currentEntry(); |
585 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 592 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
586 | beamfile ); | 593 | beamfile ); |
587 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 594 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
588 | access->add( c ); | 595 | access->add( c ); |
589 | access->save(); | 596 | access->save(); |
590 | delete access; | 597 | delete access; |
591 | 598 | ||
592 | beamFilename = beamfile; | 599 | beamFilename = beamfile; |
593 | } | 600 | } |
594 | 601 | ||
595 | odebug << "Beaming: " << beamFilename << oendl; | 602 | odebug << "Beaming: " << beamFilename << oendl; |
596 | 603 | ||
597 | Ir *ir = new Ir( this ); | 604 | Ir *ir = new Ir( this ); |
598 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 605 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
599 | QString description = c.fullName(); | 606 | QString description = c.fullName(); |
600 | ir->send( beamFilename, description, "text/x-vCard" ); | 607 | ir->send( beamFilename, description, "text/x-vCard" ); |
601 | } | 608 | } |
602 | 609 | ||
603 | void AddressbookWindow::beamDone( Ir *ir ) | 610 | void AddressbookWindow::beamDone( Ir *ir ) |
604 | { | 611 | { |
605 | 612 | ||
606 | delete ir; | 613 | delete ir; |
607 | unlink( beamfile ); | 614 | unlink( beamfile ); |
608 | } | 615 | } |
609 | 616 | ||
610 | 617 | ||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 9217e95..7cc61bf 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,137 +1,137 @@ | |||
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 | #ifndef Addressbook_H | 20 | #ifndef Addressbook_H |
21 | #define Addressbook_H | 21 | #define Addressbook_H |
22 | 22 | ||
23 | // Remove this for OPIE releae 1.0 ! | 23 | // Remove this for OPIE releae 1.0 ! |
24 | // #define __DEBUG_RELEASE | 24 | // #define __DEBUG_RELEASE |
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qvaluelist.h> | 27 | #include <qvaluelist.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include "ofloatbar.h" | 30 | #include "ofloatbar.h" |
31 | #include "abview.h" | 31 | #include "abview.h" |
32 | #include "abconfig.h" | 32 | #include "abconfig.h" |
33 | 33 | ||
34 | class ContactEditor; | 34 | class ContactEditor; |
35 | class AbLabel; | 35 | class AbLabel; |
36 | class AbTable; | 36 | class AbTable; |
37 | class QToolBar; | 37 | class QToolBar; |
38 | class QPopupMenu; | 38 | class QPopupMenu; |
39 | class QToolButton; | 39 | class QToolButton; |
40 | class QDialog; | 40 | class QDialog; |
41 | class Ir; | 41 | class Ir; |
42 | class QAction; | 42 | class QAction; |
43 | class LetterPicker; | 43 | class LetterPicker; |
44 | 44 | ||
45 | class AddressbookWindow: public QMainWindow | 45 | class AddressbookWindow: public QMainWindow |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | enum EntryMode { NewEntry=0, EditEntry }; | 49 | enum EntryMode { NewEntry=0, EditEntry }; |
50 | 50 | ||
51 | static QString appName() { return QString::fromLatin1("addressbook"); } | 51 | static QString appName() { return QString::fromLatin1("addressbook"); } |
52 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 52 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
53 | ~AddressbookWindow(); | 53 | ~AddressbookWindow(); |
54 | 54 | ||
55 | protected: | 55 | protected: |
56 | void resizeEvent( QResizeEvent * e ); | 56 | void resizeEvent( QResizeEvent * e ); |
57 | 57 | ||
58 | void editPersonal(); | 58 | void editPersonal(); |
59 | void editEntry( EntryMode ); | 59 | void editEntry( EntryMode ); |
60 | void closeEvent( QCloseEvent *e ); | 60 | void closeEvent( QCloseEvent *e ); |
61 | bool save(); | 61 | bool save(); |
62 | 62 | ||
63 | public slots: | 63 | public slots: |
64 | void flush(); | 64 | void flush(); |
65 | void reload(); | 65 | void reload(); |
66 | void appMessage(const QCString &, const QByteArray &); | 66 | void appMessage(const QCString &, const QByteArray &); |
67 | void setDocument( const QString & ); | 67 | void setDocument( const QString & ); // Called by obex receiver and internally! |
68 | #ifdef __DEBUG_RELEASE | 68 | #ifdef __DEBUG_RELEASE |
69 | // void slotSave(); | 69 | // void slotSave(); |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | private slots: | 72 | private slots: |
73 | void importvCard(); | 73 | void importvCard(); |
74 | void exportvCard(); | 74 | void exportvCard(); |
75 | void slotListNew(); | 75 | void slotListNew(); |
76 | /* void slotListView(); */ | 76 | /* void slotListView(); */ |
77 | void slotListDelete(); | 77 | void slotListDelete(); |
78 | void slotViewBack(); | 78 | void slotViewBack(); |
79 | void slotViewEdit(); | 79 | void slotViewEdit(); |
80 | void slotPersonalView(); | 80 | void slotPersonalView(); |
81 | void listIsEmpty( bool ); | 81 | void listIsEmpty( bool ); |
82 | /* void slotSettings(); */ | 82 | /* void slotSettings(); */ |
83 | void writeMail(); | 83 | void writeMail(); |
84 | void slotBeam(); | 84 | void slotBeam(); |
85 | void beamDone( Ir * ); | 85 | void beamDone( Ir * ); |
86 | void slotSetCategory( int ); | 86 | void slotSetCategory( int ); |
87 | void slotSetLetter( char ); | 87 | void slotSetLetter( char ); |
88 | void slotUpdateToolbar(); | 88 | void slotUpdateToolbar(); |
89 | void slotSetFont(int); | 89 | void slotSetFont(int); |
90 | 90 | ||
91 | void slotFindOpen(); | 91 | void slotFindOpen(); |
92 | void slotFindClose(); | 92 | void slotFindClose(); |
93 | void slotFind(); | 93 | void slotFind(); |
94 | void slotNotFound(); | 94 | void slotNotFound(); |
95 | void slotWrapAround(); | 95 | void slotWrapAround(); |
96 | 96 | ||
97 | void slotViewSwitched( int ); | 97 | void slotViewSwitched( int ); |
98 | void slotListView(); | 98 | void slotListView(); |
99 | void slotCardView(); | 99 | void slotCardView(); |
100 | 100 | ||
101 | void slotConfig(); | 101 | void slotConfig(); |
102 | 102 | ||
103 | private: | 103 | private: |
104 | void populateCategories(); | 104 | void populateCategories(); |
105 | 105 | ||
106 | QPopupMenu *catMenu; | 106 | QPopupMenu *catMenu; |
107 | QToolBar *listTools; | 107 | QToolBar *listTools; |
108 | QToolButton *deleteButton; | 108 | QToolButton *deleteButton; |
109 | enum Panes { paneList=0, paneView, paneEdit }; | 109 | enum Panes { paneList=0, paneView, paneEdit }; |
110 | ContactEditor *abEditor; | 110 | ContactEditor *abEditor; |
111 | LetterPicker *pLabel; | 111 | LetterPicker *pLabel; |
112 | AbView* m_abView; | 112 | AbView* m_abView; |
113 | QWidget *listContainer; | 113 | QWidget *listContainer; |
114 | 114 | ||
115 | // Searching stuff | 115 | // Searching stuff |
116 | OFloatBar* searchBar; | 116 | OFloatBar* searchBar; |
117 | QLineEdit* searchEdit; | 117 | QLineEdit* searchEdit; |
118 | 118 | ||
119 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; | 119 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
120 | 120 | ||
121 | int viewMargin; | 121 | int viewMargin; |
122 | 122 | ||
123 | bool syncing; | 123 | bool syncing; |
124 | QFont *defaultFont; | 124 | QFont *defaultFont; |
125 | int m_curFontSize; | 125 | int m_curFontSize; |
126 | 126 | ||
127 | bool isLoading; | 127 | bool isLoading; |
128 | 128 | ||
129 | AbConfig m_config; | 129 | AbConfig m_config; |
130 | 130 | ||
131 | QAction* m_tableViewButton; | 131 | QAction* m_tableViewButton; |
132 | QAction* m_cardViewButton; | 132 | QAction* m_cardViewButton; |
133 | 133 | ||
134 | int active_view; | 134 | int active_view; |
135 | }; | 135 | }; |
136 | 136 | ||
137 | #endif | 137 | #endif |
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h index 790aa95..7ce9752 100644 --- a/core/pim/addressbook/version.h +++ b/core/pim/addressbook/version.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef _VERSION_H_ | 1 | #ifndef _VERSION_H_ |
2 | #define _VERSION_H_ | 2 | #define _VERSION_H_ |
3 | 3 | ||
4 | #define MAINVERSION "1" | 4 | #define MAINVERSION "1" |
5 | #define SUBVERSION "1" | 5 | #define SUBVERSION "1" |
6 | #define PATCHVERSION "0" | 6 | #define PATCHVERSION "1" |
7 | 7 | ||
8 | #define APPNAME "OPIE_ADDRESSBOOK" | 8 | #define APPNAME "OPIE_ADDRESSBOOK" |
9 | 9 | ||
10 | #endif | 10 | #endif |