author | eilers <eilers> | 2002-10-08 12:33:52 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-08 12:33:52 (UTC) |
commit | a194611bf645fe7e2e9e83733ababc587fd42f1d (patch) (unidiff) | |
tree | 2c21a5576bce48dba2fe83f6c849c0d16025a848 | |
parent | 333fec32d47ea32de9fb4c8cd378a519785a1ff8 (diff) | |
download | opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.zip opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.gz opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.bz2 |
Joined development branch: It uses the new PIM API
Some features in "View" added by Darwin Zins, but they are
not finished..
-rw-r--r-- | core/pim/addressbook/abeditor.cpp | 17 | ||||
-rw-r--r-- | core/pim/addressbook/abeditor.h | 8 | ||||
-rw-r--r-- | core/pim/addressbook/ablabel.cpp | 2 | ||||
-rw-r--r-- | core/pim/addressbook/ablabel.h | 6 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 1664 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 36 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 1493 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 109 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 4 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 10 |
10 files changed, 1612 insertions, 1737 deletions
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp index 6354db9..91e8722 100644 --- a/core/pim/addressbook/abeditor.cpp +++ b/core/pim/addressbook/abeditor.cpp | |||
@@ -1,619 +1,620 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "abeditor.h" | 21 | #include "abeditor.h" |
22 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
23 | 23 | ||
24 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qscrollview.h> | 33 | #include <qscrollview.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmainwindow.h> | 36 | #include <qmainwindow.h> |
37 | 37 | ||
38 | 38 | ||
39 | static inline bool containsAlphaNum( const QString &str ); | 39 | static inline bool containsAlphaNum( const QString &str ); |
40 | static inline bool constainsWhiteSpace( const QString &str ); | 40 | static inline bool constainsWhiteSpace( const QString &str ); |
41 | 41 | ||
42 | 42 | ||
43 | // helper functions, convert our comma delimited list to proper | 43 | // helper functions, convert our comma delimited list to proper |
44 | // file format... | 44 | // file format... |
45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
46 | QString &strAll ); | 46 | QString &strAll ); |
47 | 47 | ||
48 | // helper convert from file format to comma delimited... | 48 | // helper convert from file format to comma delimited... |
49 | void parseEmailTo( const QString &strDefaultEmail, | 49 | void parseEmailTo( const QString &strDefaultEmail, |
50 | const QString &strOtherEmail, QString &strBack ); | 50 | const QString &strOtherEmail, QString &strBack ); |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered, | 54 | AbEditor::AbEditor( const OContact &entry, const QValueList<int> *newOrdered, |
55 | QStringList *slNewOrdered, | 55 | QStringList *slNewOrdered, |
56 | QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ) | 56 | QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ) |
57 | : QDialog( parent, name, TRUE, fl ), | 57 | : QDialog( parent, name, TRUE, fl ), |
58 | orderedValues( newOrdered ), | 58 | orderedValues( newOrdered ), |
59 | slOrdered( slNewOrdered ) | 59 | slOrdered( slNewOrdered ) |
60 | { | 60 | { |
61 | init(); | 61 | init(); |
62 | initMap(); | 62 | initMap(); |
63 | setEntry( entry ); | 63 | setEntry( entry ); |
64 | } | 64 | } |
65 | 65 | ||
66 | AbEditor::~AbEditor() | 66 | AbEditor::~AbEditor() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void AbEditor::init() | 70 | void AbEditor::init() |
71 | { | 71 | { |
72 | middleEdit = 0; | 72 | middleEdit = 0; |
73 | QVBoxLayout *vb = new QVBoxLayout( this ); | 73 | QVBoxLayout *vb = new QVBoxLayout( this ); |
74 | svPage = new QScrollView( this ); | 74 | svPage = new QScrollView( this ); |
75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); | 75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); |
76 | vb->addWidget( svPage ); | 76 | vb->addWidget( svPage ); |
77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); | 77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); |
78 | svPage->setFrameStyle( QFrame::NoFrame ); | 78 | svPage->setFrameStyle( QFrame::NoFrame ); |
79 | 79 | ||
80 | QWidget *container = new QWidget( svPage->viewport() ); | 80 | QWidget *container = new QWidget( svPage->viewport() ); |
81 | svPage->addChild( container ); | 81 | svPage->addChild( container ); |
82 | 82 | ||
83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); | 83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); |
84 | 84 | ||
85 | QLabel *l = new QLabel( tr("First Name"), container ); | 85 | QLabel *l = new QLabel( tr("First Name"), container ); |
86 | gl->addWidget( l, 0, 0 ); | 86 | gl->addWidget( l, 0, 0 ); |
87 | firstEdit = new QLineEdit( container ); | 87 | firstEdit = new QLineEdit( container ); |
88 | gl->addWidget( firstEdit, 0, 1 ); | 88 | gl->addWidget( firstEdit, 0, 1 ); |
89 | 89 | ||
90 | l = new QLabel( tr("Last Name"), container ); | 90 | l = new QLabel( tr("Last Name"), container ); |
91 | gl->addWidget( l, 1, 0 ); | 91 | gl->addWidget( l, 1, 0 ); |
92 | lastEdit = new QLineEdit( container ); | 92 | lastEdit = new QLineEdit( container ); |
93 | gl->addWidget( lastEdit, 1, 1 ); | 93 | gl->addWidget( lastEdit, 1, 1 ); |
94 | 94 | ||
95 | l = new QLabel( tr("Categories"), container ); | 95 | l = new QLabel( tr("Categories"), container ); |
96 | gl->addWidget( l, 2, 0 ); | 96 | gl->addWidget( l, 2, 0 ); |
97 | 97 | ||
98 | cmbCat = new CategorySelect( container ); | 98 | cmbCat = new CategorySelect( container ); |
99 | gl->addWidget( cmbCat, 2, 1 ); | 99 | gl->addWidget( cmbCat, 2, 1 ); |
100 | 100 | ||
101 | int i; | 101 | int i; |
102 | bool foundGender, | 102 | bool foundGender, |
103 | foundNotes; | 103 | foundNotes; |
104 | foundGender = foundNotes = false; | 104 | foundGender = foundNotes = false; |
105 | QStringList::ConstIterator it = slOrdered->begin(); | 105 | QStringList::ConstIterator it = slOrdered->begin(); |
106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { | 106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { |
107 | if ( !foundGender && *it == tr("Gender") ) { | 107 | if ( !foundGender && *it == tr("Gender") ) { |
108 | foundGender = true; | 108 | foundGender = true; |
109 | } else if ( !foundNotes && *it == tr("Notes") ) { | 109 | } else if ( !foundNotes && *it == tr("Notes") ) { |
110 | foundNotes = true; | 110 | foundNotes = true; |
111 | } else { | 111 | } else { |
112 | l = new QLabel( *it, container ); | 112 | l = new QLabel( *it, container ); |
113 | listName.append( l ); | 113 | listName.append( l ); |
114 | gl->addWidget( l, i + 3, 0 ); | 114 | gl->addWidget( l, i + 3, 0 ); |
115 | QLineEdit *e = new QLineEdit( container ); | 115 | QLineEdit *e = new QLineEdit( container ); |
116 | listValue.append( e ); | 116 | listValue.append( e ); |
117 | gl->addWidget( e, i + 3, 1 ); | 117 | gl->addWidget( e, i + 3, 1 ); |
118 | if ( *it == tr( "Middle Name" ) ) | 118 | if ( *it == tr( "Middle Name" ) ) |
119 | middleEdit = e; | 119 | middleEdit = e; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | l = new QLabel( tr("Gender"), container ); | 122 | l = new QLabel( tr("Gender"), container ); |
123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); | 123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); |
124 | genderCombo = new QComboBox( container ); | 124 | genderCombo = new QComboBox( container ); |
125 | genderCombo->insertItem( "", 0 ); | 125 | genderCombo->insertItem( "", 0 ); |
126 | genderCombo->insertItem( tr( "Male" ), 1 ); | 126 | genderCombo->insertItem( tr( "Male" ), 1 ); |
127 | genderCombo->insertItem( tr( "Female" ), 2 ); | 127 | genderCombo->insertItem( tr( "Female" ), 2 ); |
128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); | 128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); |
129 | 129 | ||
130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
131 | dlgNote->setCaption( tr("Enter Note") ); | 131 | dlgNote->setCaption( tr("Enter Note") ); |
132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
133 | // lblNote = new QLabel( dlgNote ); | 133 | // lblNote = new QLabel( dlgNote ); |
134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); | 134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); |
135 | // vbNote->addWidget( lblNote ); | 135 | // vbNote->addWidget( lblNote ); |
136 | txtNote = new QMultiLineEdit( dlgNote ); | 136 | txtNote = new QMultiLineEdit( dlgNote ); |
137 | vbNote->addWidget( txtNote ); | 137 | vbNote->addWidget( txtNote ); |
138 | 138 | ||
139 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 139 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
140 | hb->addStretch( 2 ); | 140 | hb->addStretch( 2 ); |
141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); | 141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); |
142 | hb->addWidget( pb ); | 142 | hb->addWidget( pb ); |
143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
144 | 144 | ||
145 | new QPEDialogListener(this); | 145 | new QPEDialogListener(this); |
146 | } | 146 | } |
147 | 147 | ||
148 | void AbEditor::initMap() | 148 | void AbEditor::initMap() |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // since the fields and the XML fields exist, create a map | 151 | // since the fields and the XML fields exist, create a map |
152 | // between them... | 152 | // between them... |
153 | Config cfg1( "AddressBook" ); | 153 | Config cfg1( "AddressBook" ); |
154 | Config cfg2( "AddressBook" ); | 154 | Config cfg2( "AddressBook" ); |
155 | QString strCfg1, | 155 | QString strCfg1, |
156 | strCfg2; | 156 | strCfg2; |
157 | int i; | 157 | int i; |
158 | 158 | ||
159 | // This stuff better exist... | 159 | // This stuff better exist... |
160 | cfg1.setGroup( "AddressFields" ); | 160 | cfg1.setGroup( "AddressFields" ); |
161 | cfg2.setGroup( "XMLFields" ); | 161 | cfg2.setGroup( "XMLFields" ); |
162 | i = 0; | 162 | i = 0; |
163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); | 163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); |
164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
165 | QString::null ); | 165 | QString::null ); |
166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { | 166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { |
167 | mapField.insert( strCfg1, strCfg2 ); | 167 | mapField.insert( strCfg1, strCfg2 ); |
168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), | 168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), |
169 | QString::null ); | 169 | QString::null ); |
170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
171 | QString::null ); | 171 | QString::null ); |
172 | } | 172 | } |
173 | */ | 173 | */ |
174 | } | 174 | } |
175 | 175 | ||
176 | void AbEditor::loadFields() | 176 | void AbEditor::loadFields() |
177 | { | 177 | { |
178 | QStringList::ConstIterator it; | 178 | QStringList::ConstIterator it; |
179 | QListIterator<QLabel> lit( listName ); | 179 | QListIterator<QLabel> lit( listName ); |
180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { | 180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { |
181 | (*lit)->setText( *it ); | 181 | (*lit)->setText( *it ); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void AbEditor::setEntry( const Contact &entry ) | 185 | void AbEditor::setEntry( const OContact &entry ) |
186 | { | 186 | { |
187 | ent = entry; | 187 | ent = entry; |
188 | QListIterator<QLineEdit> it( listValue ); | 188 | QListIterator<QLineEdit> it( listValue ); |
189 | firstEdit->setText( ent.firstName() ); | 189 | firstEdit->setText( ent.firstName() ); |
190 | lastEdit->setText( ent.lastName() ); | 190 | lastEdit->setText( ent.lastName() ); |
191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
192 | 192 | ||
193 | // ### Fix... | 193 | // ### Fix... |
194 | QValueList<int>::ConstIterator itVl; | 194 | QValueList<int>::ConstIterator itVl; |
195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); | 195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); |
196 | ++itVl, ++it ) { | 196 | ++itVl, ++it ) { |
197 | switch( *itVl ) { | 197 | switch( *itVl ) { |
198 | case Qtopia::Title: | 198 | case Qtopia::Title: |
199 | (*it)->setText(ent.title()); | 199 | (*it)->setText(ent.title()); |
200 | break; | 200 | break; |
201 | case Qtopia::MiddleName: | 201 | case Qtopia::MiddleName: |
202 | (*it)->setText( ent.middleName() ); | 202 | (*it)->setText( ent.middleName() ); |
203 | break; | 203 | break; |
204 | case Qtopia::Suffix: | 204 | case Qtopia::Suffix: |
205 | (*it)->setText( ent.suffix() ); | 205 | (*it)->setText( ent.suffix() ); |
206 | break; | 206 | break; |
207 | 207 | ||
208 | 208 | ||
209 | case Qtopia::DefaultEmail: | 209 | case Qtopia::DefaultEmail: |
210 | case Qtopia::Emails: | 210 | case Qtopia::Emails: |
211 | { | 211 | { |
212 | QString strDefEmail = ent.defaultEmail(); | 212 | QString strDefEmail = ent.defaultEmail(); |
213 | QString strAllEmail = ent.emails(); | 213 | QString strAllEmail = ent.emails(); |
214 | QString strFinal; | 214 | QString strFinal; |
215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); | 215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); |
216 | (*it)->setText( strFinal ); | 216 | (*it)->setText( strFinal ); |
217 | // make sure we see the "default" | 217 | // make sure we see the "default" |
218 | (*it)->home( false ); | 218 | (*it)->home( false ); |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | 221 | ||
222 | // home | 222 | // home |
223 | case Qtopia::HomeStreet: | 223 | case Qtopia::HomeStreet: |
224 | (*it)->setText(ent.homeStreet() ); | 224 | (*it)->setText(ent.homeStreet() ); |
225 | break; | 225 | break; |
226 | case Qtopia::HomeCity: | 226 | case Qtopia::HomeCity: |
227 | (*it)->setText( ent.homeCity() ); | 227 | (*it)->setText( ent.homeCity() ); |
228 | break; | 228 | break; |
229 | case Qtopia::HomeState: | 229 | case Qtopia::HomeState: |
230 | (*it)->setText( ent.homeState() ); | 230 | (*it)->setText( ent.homeState() ); |
231 | break; | 231 | break; |
232 | case Qtopia::HomeZip: | 232 | case Qtopia::HomeZip: |
233 | (*it)->setText( ent.homeZip() ); | 233 | (*it)->setText( ent.homeZip() ); |
234 | break; | 234 | break; |
235 | case Qtopia::HomeCountry: | 235 | case Qtopia::HomeCountry: |
236 | (*it)->setText( ent.homeCountry() ); | 236 | (*it)->setText( ent.homeCountry() ); |
237 | break; | 237 | break; |
238 | case Qtopia::HomePhone: | 238 | case Qtopia::HomePhone: |
239 | (*it)->setText( ent.homePhone() ); | 239 | (*it)->setText( ent.homePhone() ); |
240 | break; | 240 | break; |
241 | case Qtopia::HomeFax: | 241 | case Qtopia::HomeFax: |
242 | (*it)->setText( ent.homeFax() ); | 242 | (*it)->setText( ent.homeFax() ); |
243 | break; | 243 | break; |
244 | case Qtopia::HomeMobile: | 244 | case Qtopia::HomeMobile: |
245 | (*it)->setText( ent.homeMobile() ); | 245 | (*it)->setText( ent.homeMobile() ); |
246 | break; | 246 | break; |
247 | case Qtopia::HomeWebPage: | 247 | case Qtopia::HomeWebPage: |
248 | (*it)->setText( ent.homeWebpage() ); | 248 | (*it)->setText( ent.homeWebpage() ); |
249 | break; | 249 | break; |
250 | 250 | ||
251 | // business | 251 | // business |
252 | case Qtopia::Company: | 252 | case Qtopia::Company: |
253 | (*it)->setText( ent.company() ); | 253 | (*it)->setText( ent.company() ); |
254 | break; | 254 | break; |
255 | case Qtopia::BusinessStreet: | 255 | case Qtopia::BusinessStreet: |
256 | (*it)->setText( ent.businessStreet() ); | 256 | (*it)->setText( ent.businessStreet() ); |
257 | break; | 257 | break; |
258 | case Qtopia::BusinessCity: | 258 | case Qtopia::BusinessCity: |
259 | (*it)->setText( ent.businessCity() ); | 259 | (*it)->setText( ent.businessCity() ); |
260 | break; | 260 | break; |
261 | case Qtopia::BusinessState: | 261 | case Qtopia::BusinessState: |
262 | (*it)->setText( ent.businessState() ); | 262 | (*it)->setText( ent.businessState() ); |
263 | break; | 263 | break; |
264 | case Qtopia::BusinessZip: | 264 | case Qtopia::BusinessZip: |
265 | (*it)->setText( ent.businessZip() ); | 265 | (*it)->setText( ent.businessZip() ); |
266 | break; | 266 | break; |
267 | case Qtopia::BusinessCountry: | 267 | case Qtopia::BusinessCountry: |
268 | (*it)->setText( ent.businessCountry() ); | 268 | (*it)->setText( ent.businessCountry() ); |
269 | break; | 269 | break; |
270 | case Qtopia::BusinessWebPage: | 270 | case Qtopia::BusinessWebPage: |
271 | (*it)->setText( ent.businessWebpage() ); | 271 | (*it)->setText( ent.businessWebpage() ); |
272 | break; | 272 | break; |
273 | case Qtopia::JobTitle: | 273 | case Qtopia::JobTitle: |
274 | (*it)->setText( ent.jobTitle() ); | 274 | (*it)->setText( ent.jobTitle() ); |
275 | break; | 275 | break; |
276 | case Qtopia::Department: | 276 | case Qtopia::Department: |
277 | (*it)->setText( ent.department() ); | 277 | (*it)->setText( ent.department() ); |
278 | break; | 278 | break; |
279 | case Qtopia::Office: | 279 | case Qtopia::Office: |
280 | (*it)->setText( ent.office() ); | 280 | (*it)->setText( ent.office() ); |
281 | break; | 281 | break; |
282 | case Qtopia::BusinessPhone: | 282 | case Qtopia::BusinessPhone: |
283 | (*it)->setText( ent.businessPhone() ); | 283 | (*it)->setText( ent.businessPhone() ); |
284 | break; | 284 | break; |
285 | case Qtopia::BusinessFax: | 285 | case Qtopia::BusinessFax: |
286 | (*it)->setText( ent.businessFax() ); | 286 | (*it)->setText( ent.businessFax() ); |
287 | break; | 287 | break; |
288 | case Qtopia::BusinessMobile: | 288 | case Qtopia::BusinessMobile: |
289 | (*it)->setText( ent.businessMobile() ); | 289 | (*it)->setText( ent.businessMobile() ); |
290 | break; | 290 | break; |
291 | case Qtopia::BusinessPager: | 291 | case Qtopia::BusinessPager: |
292 | (*it)->setText( ent.businessPager() ); | 292 | (*it)->setText( ent.businessPager() ); |
293 | break; | 293 | break; |
294 | case Qtopia::Profession: | 294 | case Qtopia::Profession: |
295 | (*it)->setText( ent.profession() ); | 295 | (*it)->setText( ent.profession() ); |
296 | break; | 296 | break; |
297 | case Qtopia::Assistant: | 297 | case Qtopia::Assistant: |
298 | (*it)->setText( ent.assistant() ); | 298 | (*it)->setText( ent.assistant() ); |
299 | break; | 299 | break; |
300 | case Qtopia::Manager: | 300 | case Qtopia::Manager: |
301 | (*it)->setText( ent.manager() ); | 301 | (*it)->setText( ent.manager() ); |
302 | break; | 302 | break; |
303 | 303 | ||
304 | // personal | 304 | // personal |
305 | case Qtopia::Spouse: | 305 | case Qtopia::Spouse: |
306 | (*it)->setText( ent.spouse() ); | 306 | (*it)->setText( ent.spouse() ); |
307 | break; | 307 | break; |
308 | case Qtopia::Children: | 308 | case Qtopia::Children: |
309 | (*it)->setText( ent.children() ); | 309 | (*it)->setText( ent.children() ); |
310 | break; | 310 | break; |
311 | case Qtopia::Birthday: | 311 | case Qtopia::Birthday: |
312 | (*it)->setText( ent.birthday() ); | 312 | (*it)->setText( ent.birthday() ); |
313 | break; | 313 | break; |
314 | case Qtopia::Anniversary: | 314 | case Qtopia::Anniversary: |
315 | (*it)->setText( ent.anniversary() ); | 315 | (*it)->setText( ent.anniversary() ); |
316 | break; | 316 | break; |
317 | case Qtopia::Nickname: | 317 | case Qtopia::Nickname: |
318 | (*it)->setText( ent.nickname() ); | 318 | (*it)->setText( ent.nickname() ); |
319 | break; | 319 | break; |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | QString gender = ent.gender(); | 324 | QString gender = ent.gender(); |
325 | genderCombo->setCurrentItem( gender.toInt() ); | 325 | genderCombo->setCurrentItem( gender.toInt() ); |
326 | 326 | ||
327 | txtNote->setText( ent.notes() ); | 327 | txtNote->setText( ent.notes() ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void AbEditor::accept() | 330 | void AbEditor::accept() |
331 | { | 331 | { |
332 | if ( isEmpty() ) | 332 | if ( isEmpty() ) |
333 | reject(); | 333 | reject(); |
334 | else { | 334 | else { |
335 | saveEntry(); | 335 | saveEntry(); |
336 | QDialog::accept(); | 336 | QDialog::accept(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool AbEditor::isEmpty() | 340 | bool AbEditor::isEmpty() |
341 | { | 341 | { |
342 | // analyze all the fields and make sure there is _something_ there | 342 | // analyze all the fields and make sure there is _something_ there |
343 | // that warrants saving... | 343 | // that warrants saving... |
344 | QString t = firstEdit->text(); | 344 | QString t = firstEdit->text(); |
345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
346 | return false; | 346 | return false; |
347 | 347 | ||
348 | t = lastEdit->text(); | 348 | t = lastEdit->text(); |
349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
350 | return false; | 350 | return false; |
351 | 351 | ||
352 | QListIterator<QLineEdit> it( listValue ); | 352 | QListIterator<QLineEdit> it( listValue ); |
353 | for ( ; it.current(); ++it ) { | 353 | for ( ; it.current(); ++it ) { |
354 | t = it.current()->text(); | 354 | t = it.current()->text(); |
355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
356 | return false; | 356 | return false; |
357 | } | 357 | } |
358 | 358 | ||
359 | t = txtNote->text(); | 359 | t = txtNote->text(); |
360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
361 | return false; | 361 | return false; |
362 | 362 | ||
363 | return true; | 363 | return true; |
364 | } | 364 | } |
365 | 365 | ||
366 | void AbEditor::saveEntry() | 366 | void AbEditor::saveEntry() |
367 | { | 367 | { |
368 | QString strDefaultEmail, strOtherEmail; | 368 | QString strDefaultEmail, strOtherEmail; |
369 | 369 | ||
370 | // determine if there has been a change in names | 370 | // determine if there has been a change in names |
371 | if ( ent.firstName() != firstEdit->text() || | 371 | if ( ent.firstName() != firstEdit->text() || |
372 | ent.lastName() != lastEdit->text() | 372 | ent.lastName() != lastEdit->text() |
373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { | 373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { |
374 | // set the names | 374 | // set the names |
375 | ent.setFirstName( firstEdit->text() ); | 375 | ent.setFirstName( firstEdit->text() ); |
376 | ent.setLastName( lastEdit->text() ); | 376 | ent.setLastName( lastEdit->text() ); |
377 | if ( middleEdit ) | 377 | if ( middleEdit ) |
378 | ent.setMiddleName( middleEdit->text() ); | 378 | ent.setMiddleName( middleEdit->text() ); |
379 | ent.setFileAs(); | 379 | ent.setFileAs(); |
380 | } | 380 | } |
381 | 381 | ||
382 | ent.setCategories( cmbCat->currentCategories() ); | 382 | ent.setCategories( cmbCat->currentCategories() ); |
383 | 383 | ||
384 | QListIterator<QLineEdit> it( listValue ); | 384 | QListIterator<QLineEdit> it( listValue ); |
385 | int i; | 385 | int i; |
386 | QValueList<int>::ConstIterator<int> vlIt; | 386 | QValueList<int>::ConstIterator<int> vlIt; |
387 | for ( i = 0, vlIt = orderedValues->begin(); | 387 | for ( i = 0, vlIt = orderedValues->begin(); |
388 | it.current(); ++it, ++vlIt, i++ ) { | 388 | it.current(); ++it, ++vlIt, i++ ) { |
389 | switch( *vlIt ) { | 389 | switch( *vlIt ) { |
390 | case Qtopia::Title: | 390 | case Qtopia::Title: |
391 | ent.setTitle( it.current()->text() ); | 391 | ent.setTitle( it.current()->text() ); |
392 | break; | 392 | break; |
393 | case Qtopia::MiddleName: | 393 | case Qtopia::MiddleName: |
394 | ent.setMiddleName( it.current()->text() ); | 394 | ent.setMiddleName( it.current()->text() ); |
395 | break; | 395 | break; |
396 | case Qtopia::Suffix: | 396 | case Qtopia::Suffix: |
397 | ent.setSuffix( it.current()->text() ); | 397 | ent.setSuffix( it.current()->text() ); |
398 | break; | 398 | break; |
399 | // case Qtopia::Category: | 399 | // case Qtopia::Category: |
400 | // { | 400 | // { |
401 | // // QStringList slCat = QStringList::split( ";", value ); | 401 | // // QStringList slCat = QStringList::split( ";", value ); |
402 | // // QValueList<int> cat; | 402 | // // QValueList<int> cat; |
403 | // // for ( QStringList::ConstIterator it = slCat.begin(); | 403 | // // for ( QStringList::ConstIterator it = slCat.begin(); |
404 | // // it != slCat.end(); ++it ) | 404 | // // it != slCat.end(); ++it ) |
405 | // // cat.append( (*it).toInt() ); | 405 | // // cat.append( (*it).toInt() ); |
406 | // // ent.setCategories( cat ); | 406 | // // ent.setCategories( cat ); |
407 | // } | 407 | // } |
408 | // break; | 408 | // break; |
409 | 409 | ||
410 | 410 | ||
411 | case Qtopia::DefaultEmail: | 411 | case Qtopia::DefaultEmail: |
412 | case Qtopia::Emails: | 412 | case Qtopia::Emails: |
413 | parseEmailFrom( it.current()->text(), strDefaultEmail, | 413 | parseEmailFrom( it.current()->text(), strDefaultEmail, |
414 | strOtherEmail ); | 414 | strOtherEmail ); |
415 | ent.setDefaultEmail( strDefaultEmail ); | 415 | ent.setDefaultEmail( strDefaultEmail ); |
416 | ent.setEmails( strOtherEmail ); | 416 | ent.setEmails( strOtherEmail ); |
417 | break; | 417 | break; |
418 | 418 | ||
419 | // home | 419 | // home |
420 | case Qtopia::HomeStreet: | 420 | case Qtopia::HomeStreet: |
421 | ent.setHomeStreet( it.current()->text() ); | 421 | ent.setHomeStreet( it.current()->text() ); |
422 | break; | 422 | break; |
423 | case Qtopia::HomeCity: | 423 | case Qtopia::HomeCity: |
424 | ent.setHomeCity( it.current()->text() ); | 424 | ent.setHomeCity( it.current()->text() ); |
425 | break; | 425 | break; |
426 | case Qtopia::HomeState: | 426 | case Qtopia::HomeState: |
427 | ent.setHomeState( it.current()->text() ); | 427 | ent.setHomeState( it.current()->text() ); |
428 | break; | 428 | break; |
429 | case Qtopia::HomeZip: | 429 | case Qtopia::HomeZip: |
430 | ent.setHomeZip( it.current()->text() ); | 430 | ent.setHomeZip( it.current()->text() ); |
431 | break; | 431 | break; |
432 | case Qtopia::HomeCountry: | 432 | case Qtopia::HomeCountry: |
433 | ent.setHomeCountry( it.current()->text() ); | 433 | ent.setHomeCountry( it.current()->text() ); |
434 | break; | 434 | break; |
435 | case Qtopia::HomePhone: | 435 | case Qtopia::HomePhone: |
436 | ent.setHomePhone( it.current()->text() ); | 436 | ent.setHomePhone( it.current()->text() ); |
437 | break; | 437 | break; |
438 | case Qtopia::HomeFax: | 438 | case Qtopia::HomeFax: |
439 | ent.setHomeFax( it.current()->text() ); | 439 | ent.setHomeFax( it.current()->text() ); |
440 | break; | 440 | break; |
441 | case Qtopia::HomeMobile: | 441 | case Qtopia::HomeMobile: |
442 | ent.setHomeMobile( it.current()->text() ); | 442 | ent.setHomeMobile( it.current()->text() ); |
443 | break; | 443 | break; |
444 | case Qtopia::HomeWebPage: | 444 | case Qtopia::HomeWebPage: |
445 | ent.setHomeWebpage( it.current()->text() ); | 445 | ent.setHomeWebpage( it.current()->text() ); |
446 | break; | 446 | break; |
447 | 447 | ||
448 | // business | 448 | // business |
449 | case Qtopia::Company: | 449 | case Qtopia::Company: |
450 | ent.setCompany( it.current()->text() ); | 450 | ent.setCompany( it.current()->text() ); |
451 | break; | 451 | break; |
452 | case Qtopia::BusinessStreet: | 452 | case Qtopia::BusinessStreet: |
453 | ent.setBusinessStreet( it.current()->text() ); | 453 | ent.setBusinessStreet( it.current()->text() ); |
454 | break; | 454 | break; |
455 | case Qtopia::BusinessCity: | 455 | case Qtopia::BusinessCity: |
456 | ent.setBusinessCity( it.current()->text() ); | 456 | ent.setBusinessCity( it.current()->text() ); |
457 | break; | 457 | break; |
458 | case Qtopia::BusinessState: | 458 | case Qtopia::BusinessState: |
459 | ent.setBusinessState( it.current()->text() ); | 459 | ent.setBusinessState( it.current()->text() ); |
460 | break; | 460 | break; |
461 | case Qtopia::BusinessZip: | 461 | case Qtopia::BusinessZip: |
462 | ent.setBusinessZip( it.current()->text() ); | 462 | ent.setBusinessZip( it.current()->text() ); |
463 | break; | 463 | break; |
464 | case Qtopia::BusinessCountry: | 464 | case Qtopia::BusinessCountry: |
465 | ent.setBusinessCountry( it.current()->text() ); | 465 | ent.setBusinessCountry( it.current()->text() ); |
466 | break; | 466 | break; |
467 | case Qtopia::BusinessWebPage: | 467 | case Qtopia::BusinessWebPage: |
468 | ent.setBusinessWebpage( it.current()->text() ); | 468 | ent.setBusinessWebpage( it.current()->text() ); |
469 | break; | 469 | break; |
470 | case Qtopia::JobTitle: | 470 | case Qtopia::JobTitle: |
471 | ent.setJobTitle( it.current()->text() ); | 471 | ent.setJobTitle( it.current()->text() ); |
472 | break; | 472 | break; |
473 | case Qtopia::Department: | 473 | case Qtopia::Department: |
474 | ent.setDepartment( it.current()->text() ); | 474 | ent.setDepartment( it.current()->text() ); |
475 | break; | 475 | break; |
476 | case Qtopia::Office: | 476 | case Qtopia::Office: |
477 | ent.setOffice( it.current()->text() ); | 477 | ent.setOffice( it.current()->text() ); |
478 | break; | 478 | break; |
479 | case Qtopia::BusinessPhone: | 479 | case Qtopia::BusinessPhone: |
480 | ent.setBusinessPhone( it.current()->text() ); | 480 | ent.setBusinessPhone( it.current()->text() ); |
481 | break; | 481 | break; |
482 | case Qtopia::BusinessFax: | 482 | case Qtopia::BusinessFax: |
483 | ent.setBusinessFax( it.current()->text() ); | 483 | ent.setBusinessFax( it.current()->text() ); |
484 | break; | 484 | break; |
485 | case Qtopia::BusinessMobile: | 485 | case Qtopia::BusinessMobile: |
486 | ent.setBusinessMobile( it.current()->text() ); | 486 | ent.setBusinessMobile( it.current()->text() ); |
487 | break; | 487 | break; |
488 | case Qtopia::BusinessPager: | 488 | case Qtopia::BusinessPager: |
489 | ent.setBusinessPager( it.current()->text() ); | 489 | ent.setBusinessPager( it.current()->text() ); |
490 | break; | 490 | break; |
491 | case Qtopia::Profession: | 491 | case Qtopia::Profession: |
492 | ent.setProfession( it.current()->text() ); | 492 | ent.setProfession( it.current()->text() ); |
493 | break; | 493 | break; |
494 | case Qtopia::Assistant: | 494 | case Qtopia::Assistant: |
495 | ent.setAssistant( it.current()->text() ); | 495 | ent.setAssistant( it.current()->text() ); |
496 | break; | 496 | break; |
497 | case Qtopia::Manager: | 497 | case Qtopia::Manager: |
498 | ent.setManager( it.current()->text() ); | 498 | ent.setManager( it.current()->text() ); |
499 | break; | 499 | break; |
500 | 500 | ||
501 | // personal | 501 | // personal |
502 | case Qtopia::Spouse: | 502 | case Qtopia::Spouse: |
503 | ent.setSpouse( it.current()->text() ); | 503 | ent.setSpouse( it.current()->text() ); |
504 | break; | 504 | break; |
505 | case Qtopia::Children: | 505 | case Qtopia::Children: |
506 | ent.setChildren( it.current()->text() ); | 506 | ent.setChildren( it.current()->text() ); |
507 | break; | 507 | break; |
508 | case Qtopia::Birthday: | 508 | case Qtopia::Birthday: |
509 | ent.setBirthday( it.current()->text() ); | 509 | ent.setBirthday( it.current()->text() ); |
510 | break; | 510 | break; |
511 | case Qtopia::Anniversary: | 511 | case Qtopia::Anniversary: |
512 | ent.setAnniversary( it.current()->text() ); | 512 | ent.setAnniversary( it.current()->text() ); |
513 | break; | 513 | break; |
514 | case Qtopia::Nickname: | 514 | case Qtopia::Nickname: |
515 | ent.setNickname( it.current()->text() ); | 515 | ent.setNickname( it.current()->text() ); |
516 | break; | 516 | break; |
517 | default: | 517 | default: |
518 | break; | 518 | break; |
519 | 519 | ||
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | int gender = genderCombo->currentItem(); | 523 | int gender = genderCombo->currentItem(); |
524 | ent.setGender( QString::number( gender ) ); | 524 | ent.setGender( QString::number( gender ) ); |
525 | 525 | ||
526 | QString str = txtNote->text(); | 526 | QString str = txtNote->text(); |
527 | if ( !str.isNull() ) | 527 | if ( !str.isNull() ) |
528 | ent.setNotes( str ); | 528 | ent.setNotes( str ); |
529 | } | 529 | } |
530 | 530 | ||
531 | void AbEditor::slotNote() | 531 | void AbEditor::slotNote() |
532 | { | 532 | { |
533 | dlgNote->showMaximized(); | 533 | dlgNote->showMaximized(); |
534 | if ( !dlgNote->exec() ) { | 534 | if ( !dlgNote->exec() ) { |
535 | // reset the note... | 535 | // reset the note... |
536 | txtNote->setText( ent.notes() ); | 536 | txtNote->setText( ent.notes() ); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | void AbEditor::setNameFocus() | 540 | void AbEditor::setNameFocus() |
541 | { | 541 | { |
542 | firstEdit->setFocus(); | 542 | firstEdit->setFocus(); |
543 | } | 543 | } |
544 | 544 | ||
545 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 545 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
546 | QString &strAll ) | 546 | QString &strAll ) |
547 | { | 547 | { |
548 | int where, | 548 | int where, |
549 | start; | 549 | start; |
550 | if ( txt.isEmpty() ) | 550 | if ( txt.isEmpty() ) |
551 | return; | 551 | return; |
552 | |||
552 | // find the first | 553 | // find the first |
553 | where = txt.find( ',' ); | 554 | where = txt.find( ',' ); |
554 | if ( where < 0 ) { | 555 | if ( where < 0 ) { |
555 | strDefaultEmail = txt; | 556 | strDefaultEmail = txt; |
556 | strAll = txt; | 557 | strAll = txt; |
557 | } else { | 558 | } else { |
558 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 559 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
559 | strAll = strDefaultEmail; | 560 | strAll = strDefaultEmail; |
560 | while ( where > -1 ) { | 561 | while ( where > -1 ) { |
561 | strAll.append(" "); | 562 | strAll.append(" "); |
562 | start = where; | 563 | start = where; |
563 | where = txt.find( ',', where + 1 ); | 564 | where = txt.find( ',', where + 1 ); |
564 | if ( where > - 1 ) | 565 | if ( where > - 1 ) |
565 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 566 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
566 | else // grab until the end... | 567 | else // grab until the end... |
567 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 568 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
568 | } | 569 | } |
569 | } | 570 | } |
570 | } | 571 | } |
571 | 572 | ||
572 | void parseEmailTo( const QString &strDefaultEmail, | 573 | void parseEmailTo( const QString &strDefaultEmail, |
573 | const QString &strOtherEmail, QString &strBack ) | 574 | const QString &strOtherEmail, QString &strBack ) |
574 | { | 575 | { |
575 | // create a comma dilimeted set of emails... | 576 | // create a comma dilimeted set of emails... |
576 | // use the power of short circuiting... | 577 | // use the power of short circuiting... |
577 | bool foundDefault = false; | 578 | bool foundDefault = false; |
578 | QString strTmp; | 579 | QString strTmp; |
579 | int start = 0; | 580 | int start = 0; |
580 | int where; | 581 | int where; |
581 | // start at the beginng. | 582 | // start at the beginng. |
582 | strBack = strDefaultEmail; | 583 | strBack = strDefaultEmail; |
583 | where = 0; | 584 | where = 0; |
584 | while ( where > -1 ) { | 585 | while ( where > -1 ) { |
585 | start = where; | 586 | start = where; |
586 | where = strOtherEmail.find( ' ', where + 1 ); | 587 | where = strOtherEmail.find( ' ', where + 1 ); |
587 | if ( where > 0 ) { | 588 | if ( where > 0 ) { |
588 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 589 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
589 | } else | 590 | } else |
590 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 591 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
591 | if ( foundDefault || strTmp != strDefaultEmail ) { | 592 | if ( foundDefault || strTmp != strDefaultEmail ) { |
592 | strBack.append( ", " ); | 593 | strBack.append( ", " ); |
593 | strBack.append( strTmp ); | 594 | strBack.append( strTmp ); |
594 | } else | 595 | } else |
595 | foundDefault = true; | 596 | foundDefault = true; |
596 | } | 597 | } |
597 | } | 598 | } |
598 | 599 | ||
599 | 600 | ||
600 | static inline bool containsAlphaNum( const QString &str ) | 601 | static inline bool containsAlphaNum( const QString &str ) |
601 | { | 602 | { |
602 | int i, | 603 | int i, |
603 | count = str.length(); | 604 | count = str.length(); |
604 | for ( i = 0; i < count; i++ ) | 605 | for ( i = 0; i < count; i++ ) |
605 | if ( !str[i].isSpace() ) | 606 | if ( !str[i].isSpace() ) |
606 | return TRUE; | 607 | return TRUE; |
607 | return FALSE; | 608 | return FALSE; |
608 | } | 609 | } |
609 | 610 | ||
610 | static inline bool constainsWhiteSpace( const QString &str ) | 611 | static inline bool constainsWhiteSpace( const QString &str ) |
611 | { | 612 | { |
612 | int i, | 613 | int i, |
613 | count = str.length(); | 614 | count = str.length(); |
614 | for (i = 0; i < count; i++ ) | 615 | for (i = 0; i < count; i++ ) |
615 | if ( str[i].isSpace() ) | 616 | if ( str[i].isSpace() ) |
616 | return TRUE; | 617 | return TRUE; |
617 | return FALSE; | 618 | return FALSE; |
618 | } | 619 | } |
619 | 620 | ||
diff --git a/core/pim/addressbook/abeditor.h b/core/pim/addressbook/abeditor.h index 9ce6704..a9c1c5f 100644 --- a/core/pim/addressbook/abeditor.h +++ b/core/pim/addressbook/abeditor.h | |||
@@ -1,79 +1,79 @@ | |||
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 ABEDITOR_H | 20 | #ifndef ABEDITOR_H |
21 | #define ABEDITOR_H | 21 | #define ABEDITOR_H |
22 | 22 | ||
23 | #include <qpe/contact.h> | 23 | #include <qpe/contact.h> |
24 | 24 | ||
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | class QScrollView; | 30 | class QScrollView; |
31 | class QMultiLineEdit; | 31 | class QMultiLineEdit; |
32 | class QLineEdit; | 32 | class QLineEdit; |
33 | class QLabel; | 33 | class QLabel; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class CategorySelect; | 35 | class CategorySelect; |
36 | 36 | ||
37 | class AbEditor : public QDialog | 37 | class AbEditor : public QDialog |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | AbEditor( const Contact &entry, const QValueList<int> *newOrdedValues, | 41 | AbEditor( const OContact &entry, const QValueList<int> *newOrdedValues, |
42 | QStringList *slNewOrdered, | 42 | QStringList *slNewOrdered, |
43 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 43 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
44 | ~AbEditor(); | 44 | ~AbEditor(); |
45 | void loadFields(); | 45 | void loadFields(); |
46 | void setNameFocus(); | 46 | void setNameFocus(); |
47 | Contact entry() const { return ent; } | 47 | OContact entry() const { return ent; } |
48 | 48 | ||
49 | public slots: | 49 | public slots: |
50 | void slotNote(); | 50 | void slotNote(); |
51 | void setEntry( const Contact &entry ); | 51 | void setEntry( const OContact &entry ); |
52 | 52 | ||
53 | protected slots: | 53 | protected slots: |
54 | void accept(); | 54 | void accept(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | void init(); | 57 | void init(); |
58 | void initMap(); | 58 | void initMap(); |
59 | void saveEntry(); | 59 | void saveEntry(); |
60 | bool isEmpty(); | 60 | bool isEmpty(); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | QDialog *dlgNote; | 63 | QDialog *dlgNote; |
64 | QLabel *lblNote; | 64 | QLabel *lblNote; |
65 | QMultiLineEdit *txtNote; | 65 | QMultiLineEdit *txtNote; |
66 | Contact ent; | 66 | OContact ent; |
67 | QScrollView *svPage; | 67 | QScrollView *svPage; |
68 | QLineEdit *firstEdit; | 68 | QLineEdit *firstEdit; |
69 | QLineEdit *lastEdit; | 69 | QLineEdit *lastEdit; |
70 | QLineEdit *middleEdit; | 70 | QLineEdit *middleEdit; |
71 | QComboBox *genderCombo; | 71 | QComboBox *genderCombo; |
72 | QList<QLineEdit> listValue; | 72 | QList<QLineEdit> listValue; |
73 | QList<QLabel> listName; | 73 | QList<QLabel> listName; |
74 | const QValueList<int> *orderedValues; | 74 | const QValueList<int> *orderedValues; |
75 | QStringList *slOrdered; | 75 | QStringList *slOrdered; |
76 | CategorySelect *cmbCat; | 76 | CategorySelect *cmbCat; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #endif | 79 | #endif |
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp index 3bf3e12..cf1e39f 100644 --- a/core/pim/addressbook/ablabel.cpp +++ b/core/pim/addressbook/ablabel.cpp | |||
@@ -1,53 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "ablabel.h" | 21 | #include "ablabel.h" |
22 | 22 | ||
23 | #include <qpe/stringutil.h> | 23 | #include <qpe/stringutil.h> |
24 | 24 | ||
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qstylesheet.h> | 26 | #include <qstylesheet.h> |
27 | 27 | ||
28 | AbLabel::AbLabel( QWidget *parent, const char *name ) | 28 | AbLabel::AbLabel( QWidget *parent, const char *name ) |
29 | : QTextView( parent, name ) | 29 | : QTextView( parent, name ) |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | AbLabel::~AbLabel() | 33 | AbLabel::~AbLabel() |
34 | { | 34 | { |
35 | } | 35 | } |
36 | 36 | ||
37 | void AbLabel::init( const Contact &entry ) | 37 | void AbLabel::init( const OContact &entry ) |
38 | { | 38 | { |
39 | ent = entry; | 39 | ent = entry; |
40 | } | 40 | } |
41 | 41 | ||
42 | void AbLabel::sync() | 42 | void AbLabel::sync() |
43 | { | 43 | { |
44 | QString text = ent.toRichText(); | 44 | QString text = ent.toRichText(); |
45 | setText( text ); | 45 | setText( text ); |
46 | } | 46 | } |
47 | 47 | ||
48 | void AbLabel::keyPressEvent( QKeyEvent *e ) | 48 | void AbLabel::keyPressEvent( QKeyEvent *e ) |
49 | { | 49 | { |
50 | if ( e->key() == Qt::Key_F33 ) { | 50 | if ( e->key() == Qt::Key_F33 ) { |
51 | emit okPressed(); | 51 | emit okPressed(); |
52 | } | 52 | } |
53 | } | 53 | } |
diff --git a/core/pim/addressbook/ablabel.h b/core/pim/addressbook/ablabel.h index cfbd999..9086c4a 100644 --- a/core/pim/addressbook/ablabel.h +++ b/core/pim/addressbook/ablabel.h | |||
@@ -1,50 +1,50 @@ | |||
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 ABLABEL_H | 20 | #ifndef ABLABEL_H |
21 | #define ABLABEL_H | 21 | #define ABLABEL_H |
22 | 22 | ||
23 | #include <qpe/contact.h> | 23 | #include <opie/ocontact.h> |
24 | #include <qtextview.h> | 24 | #include <qtextview.h> |
25 | 25 | ||
26 | class AbLabel : public QTextView | 26 | class AbLabel : public QTextView |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | AbLabel( QWidget *parent, const char *name = 0 ); | 31 | AbLabel( QWidget *parent, const char *name = 0 ); |
32 | ~AbLabel(); | 32 | ~AbLabel(); |
33 | 33 | ||
34 | public slots: | 34 | public slots: |
35 | void init( const Contact &entry ); | 35 | void init( const OContact &entry ); |
36 | void sync(); | 36 | void sync(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void okPressed(); | 39 | void okPressed(); |
40 | 40 | ||
41 | protected: | 41 | protected: |
42 | void keyPressEvent( QKeyEvent * ); | 42 | void keyPressEvent( QKeyEvent * ); |
43 | 43 | ||
44 | private: | 44 | private: |
45 | Contact ent; | 45 | OContact ent; |
46 | 46 | ||
47 | }; | 47 | }; |
48 | 48 | ||
49 | #endif // ABLABEL_H | 49 | #endif // ABLABEL_H |
50 | 50 | ||
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 3fa1a7c..08c6d0a 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,1210 +1,1002 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | 21 | #define QTOPIA_INTERNAL_CONTACT_MRE |
22 | 22 | ||
23 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | 27 | ||
28 | #include <opie/orecordlist.h> | ||
29 | |||
28 | #include <qasciidict.h> | 30 | #include <qasciidict.h> |
29 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
30 | #include <qfile.h> | 32 | #include <qfile.h> |
31 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qmessagebox.h> | ||
32 | 35 | ||
33 | #include "abtable.h" | 36 | #include "abtable.h" |
34 | 37 | ||
35 | #include <errno.h> | 38 | #include <errno.h> |
36 | #include <fcntl.h> | 39 | #include <fcntl.h> |
37 | #include <unistd.h> | 40 | #include <unistd.h> |
38 | #include <stdlib.h> | 41 | #include <stdlib.h> |
39 | 42 | ||
40 | #include <ctype.h> //toupper() for key hack | 43 | #include <ctype.h> //toupper() for key hack |
41 | 44 | ||
42 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ); | 45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); |
43 | |||
44 | //### qtmail/addresslist.cpp hardcodes this filename as well | ||
45 | static QString journalFileName() | ||
46 | { | ||
47 | QString str = getenv("HOME"); | ||
48 | str +="/.abjournal"; | ||
49 | return str; | ||
50 | } | ||
51 | |||
52 | 46 | ||
53 | 47 | ||
54 | /*! | 48 | /*! |
55 | \class AbTableItem abtable.h | 49 | \class AbTableItem abtable.h |
56 | 50 | ||
57 | \brief QTableItem based class for showing a field of an entry | 51 | \brief QTableItem based class for showing a field of an entry |
58 | */ | 52 | */ |
59 | 53 | ||
60 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 54 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
61 | const QString &secondSortKey) | 55 | const QString &secondSortKey) |
62 | : QTableItem( t, et, s ) | 56 | : QTableItem( t, et, s ) |
63 | { | 57 | { |
64 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 58 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
65 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 59 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
66 | } | 60 | } |
67 | 61 | ||
68 | int AbTableItem::alignment() const | 62 | int AbTableItem::alignment() const |
69 | { | 63 | { |
70 | return AlignLeft|AlignVCenter; | 64 | return AlignLeft|AlignVCenter; |
71 | } | 65 | } |
72 | 66 | ||
73 | QString AbTableItem::key() const | 67 | QString AbTableItem::key() const |
74 | { | 68 | { |
75 | return sortKey; | 69 | return sortKey; |
76 | } | 70 | } |
77 | 71 | ||
78 | // A way to reset the item, without out doing a delete or a new... | 72 | // A way to reset the item, without out doing a delete or a new... |
79 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 73 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
80 | { | 74 | { |
81 | setText( txt ); | 75 | setText( txt ); |
82 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 76 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
83 | 77 | ||
84 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 78 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
85 | } | 79 | } |
86 | 80 | ||
87 | /*! | 81 | /*! |
88 | \class AbPickItem abtable.h | 82 | \class AbPickItem abtable.h |
89 | 83 | ||
90 | \brief QTableItem based class for showing slection of an entry | 84 | \brief QTableItem based class for showing slection of an entry |
91 | */ | 85 | */ |
92 | 86 | ||
93 | AbPickItem::AbPickItem( QTable *t ) : | 87 | AbPickItem::AbPickItem( QTable *t ) : |
94 | QTableItem(t, WhenCurrent, "?") | 88 | QTableItem(t, WhenCurrent, "?") |
95 | { | 89 | { |
96 | } | 90 | } |
97 | 91 | ||
98 | QWidget *AbPickItem::createEditor() const | 92 | QWidget *AbPickItem::createEditor() const |
99 | { | 93 | { |
100 | QComboBox* combo = new QComboBox( table()->viewport() ); | 94 | QComboBox* combo = new QComboBox( table()->viewport() ); |
101 | ( (AbPickItem*)this )->cb = combo; | 95 | ( (AbPickItem*)this )->cb = combo; |
102 | AbTable* t = static_cast<AbTable*>(table()); | 96 | AbTable* t = static_cast<AbTable*>(table()); |
103 | QStringList c = t->choiceNames(); | 97 | QStringList c = t->choiceNames(); |
104 | int cur = 0; | 98 | int cur = 0; |
105 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 99 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
106 | if ( *it == text() ) | 100 | if ( *it == text() ) |
107 | cur = combo->count(); | 101 | cur = combo->count(); |
108 | combo->insertItem(*it); | 102 | combo->insertItem(*it); |
109 | } | 103 | } |
110 | combo->setCurrentItem(cur); | 104 | combo->setCurrentItem(cur); |
111 | return combo; | 105 | return combo; |
112 | } | 106 | } |
113 | 107 | ||
114 | void AbPickItem::setContentFromEditor( QWidget *w ) | 108 | void AbPickItem::setContentFromEditor( QWidget *w ) |
115 | { | 109 | { |
116 | if ( w->inherits("QComboBox") ) | 110 | if ( w->inherits("QComboBox") ) |
117 | setText( ( (QComboBox*)w )->currentText() ); | 111 | setText( ( (QComboBox*)w )->currentText() ); |
118 | else | 112 | else |
119 | QTableItem::setContentFromEditor( w ); | 113 | QTableItem::setContentFromEditor( w ); |
120 | } | 114 | } |
121 | 115 | ||
122 | /*! | 116 | /*! |
123 | \class AbTable abtable.h | 117 | \class AbTable abtable.h |
124 | 118 | ||
125 | \brief QTable based class for showing a list of entries | 119 | \brief QTable based class for showing a list of entries |
126 | */ | 120 | */ |
127 | 121 | ||
128 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) | 122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) |
129 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
130 | // : QTable( 0, 0, parent, name, TRUE ), | 124 | // : QTable( 0, 0, parent, name, TRUE ), |
131 | // #else | 125 | // #else |
132 | : QTable( parent, name ), | 126 | : QTable( parent, name ), |
133 | // #endif | 127 | // #endif |
134 | lastSortCol( -1 ), | 128 | lastSortCol( -1 ), |
135 | asc( TRUE ), | 129 | asc( TRUE ), |
136 | intFields( order ), | 130 | intFields( order ), |
137 | currFindRow( -2 ), | 131 | currFindRow( -2 ), |
138 | mCat( 0 ) | 132 | mCat( 0 ), |
139 | { | 133 | m_contactdb ("addressbook") |
140 | mCat.load( categoryFileName() ); | 134 | { |
141 | setSelectionMode( NoSelection ); | 135 | mCat.load( categoryFileName() ); |
142 | init(); | 136 | setSelectionMode( NoSelection ); |
143 | setSorting( TRUE ); | 137 | init(); |
144 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 138 | setSorting( TRUE ); |
145 | this, SLOT(itemClicked(int,int)) ); | 139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
140 | this, SLOT(itemClicked(int,int)) ); | ||
146 | } | 141 | } |
147 | 142 | ||
148 | AbTable::~AbTable() | 143 | AbTable::~AbTable() |
149 | { | 144 | { |
150 | } | 145 | } |
151 | 146 | ||
152 | void AbTable::init() | 147 | void AbTable::init() |
153 | { | 148 | { |
154 | showChar = '\0'; | 149 | showChar = '\0'; |
155 | setNumRows( 0 ); | 150 | setNumRows( 0 ); |
156 | setNumCols( 2 ); | 151 | setNumCols( 2 ); |
157 | 152 | ||
158 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 153 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
159 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 154 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
160 | setLeftMargin( 0 ); | 155 | setLeftMargin( 0 ); |
161 | verticalHeader()->hide(); | 156 | verticalHeader()->hide(); |
157 | columnVisible = true; | ||
162 | } | 158 | } |
163 | 159 | ||
164 | void AbTable::columnClicked( int col ) | 160 | void AbTable::columnClicked( int col ) |
165 | { | 161 | { |
166 | if ( !sorting() ) | 162 | if ( !sorting() ) |
167 | return; | 163 | return; |
168 | 164 | ||
169 | if ( lastSortCol == -1 ) | 165 | if ( lastSortCol == -1 ) |
170 | lastSortCol = col; | 166 | lastSortCol = col; |
171 | 167 | ||
172 | if ( col == lastSortCol ) { | 168 | if ( col == lastSortCol ) { |
173 | asc = !asc; | 169 | asc = !asc; |
174 | } else { | 170 | } else { |
175 | lastSortCol = col; | 171 | lastSortCol = col; |
176 | asc = TRUE; | 172 | asc = TRUE; |
177 | } | 173 | } |
178 | resort(); | 174 | //QMessageBox::information( this, "resort", "columnClicked" ); |
175 | resort(); | ||
179 | } | 176 | } |
180 | 177 | ||
181 | void AbTable::resort() | 178 | void AbTable::resort() |
182 | { | 179 | { |
183 | if ( sorting() ) { | 180 | if ( sorting() ) { |
184 | if ( lastSortCol == -1 ) | 181 | if ( lastSortCol == -1 ) |
185 | lastSortCol = 0; | 182 | lastSortCol = 0; |
186 | sortColumn( lastSortCol, asc, TRUE ); | 183 | sortColumn( lastSortCol, asc, TRUE ); |
187 | updateVisible(); | 184 | //QMessageBox::information( this, "resort", "resort" ); |
188 | } | 185 | updateVisible(); |
186 | } | ||
189 | } | 187 | } |
190 | 188 | ||
191 | Contact AbTable::currentEntry() | 189 | OContact AbTable::currentEntry() |
192 | { | 190 | { |
193 | Contact cnt; | 191 | OContact cnt; |
194 | AbTableItem *abItem; | 192 | AbTableItem *abItem; |
195 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 193 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
196 | if ( abItem ) { | 194 | if ( abItem ) { |
197 | cnt = contactList[abItem]; | 195 | cnt = contactList[abItem]; |
198 | } | 196 | //cnt = contactList[currentRow()]; |
199 | return cnt; | 197 | } |
198 | return cnt; | ||
200 | } | 199 | } |
201 | 200 | ||
202 | void AbTable::replaceCurrentEntry( const Contact &newContact ) | 201 | void AbTable::replaceCurrentEntry( const OContact &newContact ) |
203 | { | 202 | { |
204 | int row = currentRow(); | 203 | int row = currentRow(); |
205 | updateJournal( newContact, Contact::ACTION_REPLACE, row ); | 204 | updateVisible(); |
206 | updateVisible(); | 205 | |
207 | 206 | journalFreeReplace( newContact, row ); | |
208 | journalFreeReplace( newContact, row ); | 207 | |
209 | } | 208 | } |
210 | 209 | ||
211 | void AbTable::deleteCurrentEntry() | 210 | void AbTable::deleteCurrentEntry() |
212 | { | 211 | { |
213 | int row = currentRow(); | 212 | int row = currentRow(); |
214 | AbTableItem *abItem; | 213 | |
215 | abItem = static_cast<AbTableItem*>(item( row, 0 )); | 214 | // a little wasteful, but it ensure's there is only one place |
216 | Contact oldContact; | 215 | // where we delete. |
217 | oldContact = contactList[abItem]; | 216 | journalFreeRemove( row ); |
218 | updateJournal( oldContact, Contact::ACTION_REMOVE, row ); | 217 | updateVisible(); |
219 | 218 | ||
220 | // a little wasteful, but it ensure's there is only one place | 219 | if ( numRows() == 0 ) |
221 | // where we delete. | 220 | emit empty( TRUE ); |
222 | journalFreeRemove( row ); | 221 | |
223 | updateVisible(); | ||
224 | |||
225 | if ( numRows() == 0 ) | ||
226 | emit empty( TRUE ); | ||
227 | } | 222 | } |
228 | 223 | ||
229 | void AbTable::clear() | 224 | void AbTable::clear() |
230 | { | 225 | { |
231 | contactList.clear(); | 226 | contactList.clear(); |
232 | for ( int r = 0; r < numRows(); ++r ) { | 227 | for ( int r = 0; r < numRows(); ++r ) { |
233 | for ( int c = 0; c < numCols(); ++c ) { | 228 | for ( int c = 0; c < numCols(); ++c ) { |
234 | if ( cellWidget( r, c ) ) | 229 | if ( cellWidget( r, c ) ) |
235 | clearCellWidget( r, c ); | 230 | clearCellWidget( r, c ); |
236 | clearCell( r, c ); | 231 | clearCell( r, c ); |
232 | } | ||
237 | } | 233 | } |
238 | } | 234 | setNumRows( 0 ); |
239 | setNumRows( 0 ); | ||
240 | } | 235 | } |
241 | 236 | ||
242 | void AbTable::refresh() | 237 | void AbTable::refresh() |
243 | { | 238 | { |
244 | int rows = numRows(); | 239 | int rows = numRows(); |
245 | QString value; | 240 | QString value; |
246 | AbTableItem *abi; | 241 | AbTableItem *abi; |
247 | for ( int r = 0; r < rows; ++r ) { | 242 | |
248 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 243 | // hide columns so no flashing ? |
249 | value = findContactContact( contactList[abi] ); | 244 | if ( showBk == "Cards" ) { |
250 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 245 | hideColumn(0); |
251 | } | 246 | hideColumn(1); |
252 | resort(); | 247 | } |
248 | for ( int r = 0; r < rows; ++r ) { | ||
249 | abi = static_cast<AbTableItem*>( item(r, 0) ); | ||
250 | value = findContactContact( contactList[abi], r ); | ||
251 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | ||
252 | } | ||
253 | resort(); | ||
253 | } | 254 | } |
254 | 255 | ||
255 | void AbTable::keyPressEvent( QKeyEvent *e ) | 256 | void AbTable::keyPressEvent( QKeyEvent *e ) |
256 | { | 257 | { |
257 | char key = toupper( e->ascii() ); | 258 | char key = toupper( e->ascii() ); |
258 | 259 | ||
259 | if ( key >= 'A' && key <= 'Z' ) | 260 | if ( key >= 'A' && key <= 'Z' ) |
260 | moveTo( key ); | 261 | moveTo( key ); |
261 | 262 | ||
262 | switch( e->key() ) { | 263 | switch( e->key() ) { |
263 | case Qt::Key_Space: | 264 | case Qt::Key_Space: |
264 | case Qt::Key_Return: | 265 | case Qt::Key_Return: |
265 | case Qt::Key_Enter: | 266 | case Qt::Key_Enter: |
266 | emit details(); | 267 | emit details(); |
267 | break; | 268 | break; |
268 | default: | 269 | default: |
269 | QTable::keyPressEvent( e ); | 270 | QTable::keyPressEvent( e ); |
270 | } | 271 | } |
271 | } | 272 | } |
272 | 273 | ||
273 | void AbTable::moveTo( char c ) | 274 | void AbTable::moveTo( char c ) |
274 | { | 275 | { |
275 | 276 | ||
276 | int rows = numRows(); | 277 | int rows = numRows(); |
277 | QString value; | 278 | QString value; |
278 | AbTableItem *abi; | 279 | AbTableItem *abi; |
279 | int r; | 280 | int r; |
280 | if ( asc ) { | 281 | if ( asc ) { |
281 | r = 0; | 282 | r = 0; |
282 | while ( r < rows-1) { | 283 | while ( r < rows-1) { |
283 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 284 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
284 | QChar first = abi->key()[0]; | 285 | QChar first = abi->key()[0]; |
285 | //### is there a bug in QChar to char comparison??? | 286 | //### is there a bug in QChar to char comparison??? |
286 | if ( first.row() || first.cell() >= c ) | 287 | if ( first.row() || first.cell() >= c ) |
287 | break; | 288 | break; |
288 | r++; | 289 | r++; |
289 | } | 290 | } |
290 | } else { | 291 | } else { |
291 | //### should probably disable reverse sorting instead | 292 | //### should probably disable reverse sorting instead |
292 | r = rows - 1; | 293 | r = rows - 1; |
293 | while ( r > 0 ) { | 294 | while ( r > 0 ) { |
294 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 295 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
295 | QChar first = abi->key()[0]; | 296 | QChar first = abi->key()[0]; |
296 | //### is there a bug in QChar to char comparison??? | 297 | //### is there a bug in QChar to char comparison??? |
297 | if ( first.row() || first.cell() >= c ) | 298 | if ( first.row() || first.cell() >= c ) |
298 | break; | 299 | break; |
299 | r--; | 300 | r--; |
301 | } | ||
300 | } | 302 | } |
301 | } | 303 | setCurrentCell( r, currentColumn() ); |
302 | setCurrentCell( r, currentColumn() ); | ||
303 | } | 304 | } |
304 | 305 | ||
305 | 306 | ||
306 | QString AbTable::findContactName( const Contact &entry ) | 307 | QString AbTable::findContactName( const OContact &entry ) |
307 | { | 308 | { |
308 | // We use the fileAs, then company, defaultEmail | 309 | // We use the fileAs, then company, defaultEmail |
309 | QString str; | 310 | QString str; |
310 | str = entry.fileAs(); | 311 | str = entry.fileAs(); |
311 | if ( str.isEmpty() ) { | ||
312 | str = entry.company(); | ||
313 | if ( str.isEmpty() ) { | 312 | if ( str.isEmpty() ) { |
314 | str = entry.defaultEmail(); | 313 | str = entry.company(); |
314 | if ( str.isEmpty() ) { | ||
315 | str = entry.defaultEmail(); | ||
316 | } | ||
315 | } | 317 | } |
316 | } | 318 | return str; |
317 | return str; | 319 | } |
318 | } | 320 | |
319 | 321 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | |
320 | QString AbTable::findContactContact( const Contact &entry ) | 322 | { |
321 | { | 323 | QString value; |
322 | QString value; | 324 | value = ""; |
323 | value = ""; | 325 | for ( QValueList<int>::ConstIterator it = intFields->begin(); |
324 | for ( QValueList<int>::ConstIterator it = intFields->begin(); | 326 | it != intFields->end(); ++it ) { |
325 | it != intFields->end(); ++it ) { | 327 | switch ( *it ) { |
326 | switch ( *it ) { | 328 | default: |
327 | default: | 329 | break; |
328 | break; | 330 | case Qtopia::Title: |
329 | case Qtopia::Title: | 331 | value = entry.title(); |
330 | value = entry.title(); | 332 | break; |
331 | break; | 333 | case Qtopia::Suffix: |
332 | case Qtopia::Suffix: | 334 | value = entry.suffix(); |
333 | value = entry.suffix(); | 335 | break; |
334 | break; | 336 | case Qtopia::FileAs: |
335 | case Qtopia::FileAs: | 337 | value = entry.fileAs(); |
336 | value = entry.fileAs(); | 338 | break; |
337 | break; | 339 | case Qtopia::DefaultEmail: |
338 | case Qtopia::DefaultEmail: | 340 | value = entry.defaultEmail(); |
339 | value = entry.defaultEmail(); | 341 | case Qtopia::Emails: |
340 | case Qtopia::Emails: | 342 | value = entry.emails(); |
341 | value = entry.emails(); | 343 | break; |
342 | break; | 344 | case Qtopia::HomeStreet: |
343 | case Qtopia::HomeStreet: | 345 | value = entry.homeStreet(); |
344 | value = entry.homeStreet(); | 346 | break; |
345 | break; | 347 | case Qtopia::HomeCity: |
346 | case Qtopia::HomeCity: | 348 | value = entry.homeCity(); |
347 | value = entry.homeCity(); | 349 | break; |
348 | break; | 350 | case Qtopia::HomeState: |
349 | case Qtopia::HomeState: | 351 | value = entry.homeState(); |
350 | value = entry.homeState(); | 352 | break; |
351 | break; | 353 | case Qtopia::HomeZip: |
352 | case Qtopia::HomeZip: | 354 | value = entry.homeZip(); |
353 | value = entry.homeZip(); | 355 | break; |
354 | break; | 356 | case Qtopia::HomeCountry: |
355 | case Qtopia::HomeCountry: | 357 | value = entry.homeCountry(); |
356 | value = entry.homeCountry(); | 358 | break; |
357 | break; | 359 | case Qtopia::HomePhone: |
358 | case Qtopia::HomePhone: | 360 | value = entry.homePhone(); |
359 | value = entry.homePhone(); | 361 | break; |
360 | break; | 362 | case Qtopia::HomeFax: |
361 | case Qtopia::HomeFax: | 363 | value = entry.homeFax(); |
362 | value = entry.homeFax(); | 364 | break; |
363 | break; | 365 | case Qtopia::HomeMobile: |
364 | case Qtopia::HomeMobile: | 366 | value = entry.homeMobile(); |
365 | value = entry.homeMobile(); | 367 | break; |
366 | break; | 368 | case Qtopia::HomeWebPage: |
367 | case Qtopia::HomeWebPage: | 369 | value = entry.homeWebpage(); |
368 | value = entry.homeWebpage(); | 370 | break; |
369 | break; | 371 | case Qtopia::Company: |
370 | case Qtopia::Company: | 372 | value = entry.company(); |
371 | value = entry.company(); | 373 | break; |
372 | break; | 374 | case Qtopia::BusinessCity: |
373 | case Qtopia::BusinessCity: | 375 | value = entry.businessCity(); |
374 | value = entry.businessCity(); | 376 | break; |
375 | break; | 377 | case Qtopia::BusinessStreet: |
376 | case Qtopia::BusinessStreet: | 378 | value = entry.businessStreet(); |
377 | value = entry.businessStreet(); | 379 | break; |
378 | break; | 380 | case Qtopia::BusinessZip: |
379 | case Qtopia::BusinessZip: | 381 | value = entry.businessZip(); |
380 | value = entry.businessZip(); | 382 | break; |
381 | break; | 383 | case Qtopia::BusinessCountry: |
382 | case Qtopia::BusinessCountry: | 384 | value = entry.businessCountry(); |
383 | value = entry.businessCountry(); | 385 | break; |
384 | break; | 386 | case Qtopia::BusinessWebPage: |
385 | case Qtopia::BusinessWebPage: | 387 | value = entry.businessWebpage(); |
386 | value = entry.businessWebpage(); | 388 | break; |
387 | break; | 389 | case Qtopia::JobTitle: |
388 | case Qtopia::JobTitle: | 390 | value = entry.jobTitle(); |
389 | value = entry.jobTitle(); | 391 | break; |
390 | break; | 392 | case Qtopia::Department: |
391 | case Qtopia::Department: | 393 | value = entry.department(); |
392 | value = entry.department(); | 394 | break; |
393 | break; | 395 | case Qtopia::Office: |
394 | case Qtopia::Office: | 396 | value = entry.office(); |
395 | value = entry.office(); | 397 | break; |
396 | break; | 398 | case Qtopia::BusinessPhone: |
397 | case Qtopia::BusinessPhone: | 399 | value = entry.businessPhone(); |
398 | value = entry.businessPhone(); | 400 | break; |
399 | break; | 401 | case Qtopia::BusinessFax: |
400 | case Qtopia::BusinessFax: | 402 | value = entry.businessFax(); |
401 | value = entry.businessFax(); | 403 | break; |
402 | break; | 404 | case Qtopia::BusinessMobile: |
403 | case Qtopia::BusinessMobile: | 405 | value = entry.businessMobile(); |
404 | value = entry.businessMobile(); | 406 | break; |
405 | break; | 407 | case Qtopia::BusinessPager: |
406 | case Qtopia::BusinessPager: | 408 | value = entry.businessPager(); |
407 | value = entry.businessPager(); | 409 | break; |
408 | break; | 410 | case Qtopia::Profession: |
409 | case Qtopia::Profession: | 411 | value = entry.profession(); |
410 | value = entry.profession(); | 412 | break; |
411 | break; | 413 | case Qtopia::Assistant: |
412 | case Qtopia::Assistant: | 414 | value = entry.assistant(); |
413 | value = entry.assistant(); | 415 | break; |
414 | break; | 416 | case Qtopia::Manager: |
415 | case Qtopia::Manager: | 417 | value = entry.manager(); |
416 | value = entry.manager(); | 418 | break; |
417 | break; | 419 | case Qtopia::Spouse: |
418 | case Qtopia::Spouse: | 420 | value = entry.spouse(); |
419 | value = entry.spouse(); | 421 | break; |
420 | break; | 422 | case Qtopia::Gender: |
421 | case Qtopia::Gender: | 423 | value = entry.gender(); |
422 | value = entry.gender(); | 424 | break; |
423 | break; | 425 | case Qtopia::Birthday: |
424 | case Qtopia::Birthday: | 426 | value = entry.birthday(); |
425 | value = entry.birthday(); | 427 | break; |
426 | break; | 428 | case Qtopia::Anniversary: |
427 | case Qtopia::Anniversary: | 429 | value = entry.anniversary(); |
428 | value = entry.anniversary(); | 430 | break; |
429 | break; | 431 | case Qtopia::Nickname: |
430 | case Qtopia::Nickname: | 432 | value = entry.nickname(); |
431 | value = entry.nickname(); | 433 | break; |
432 | break; | 434 | case Qtopia::Children: |
433 | case Qtopia::Children: | 435 | value = entry.children(); |
434 | value = entry.children(); | 436 | break; |
435 | break; | 437 | case Qtopia::Notes: |
436 | case Qtopia::Notes: | 438 | value = entry.notes(); |
437 | value = entry.notes(); | 439 | break; |
438 | break; | 440 | } |
441 | if ( !value.isEmpty() ) | ||
442 | break; | ||
439 | } | 443 | } |
440 | if ( !value.isEmpty() ) | 444 | return value; |
441 | break; | ||
442 | } | ||
443 | return value; | ||
444 | } | 445 | } |
445 | 446 | ||
446 | void AbTable::addEntry( const Contact &newCnt ) | 447 | void AbTable::addEntry( const OContact &newCnt ) |
447 | { | 448 | { |
448 | int row = numRows(); | 449 | int row = numRows(); |
449 | setNumRows( row + 1 ); | 450 | |
450 | updateJournal( newCnt, Contact::ACTION_ADD ); | 451 | setNumRows( row + 1 ); |
451 | insertIntoTable( newCnt, row ); | 452 | insertIntoTable( newCnt, row ); |
452 | setCurrentCell( row, 0 ); | 453 | |
453 | updateVisible(); | 454 | qWarning("abtable:AddContact"); |
455 | m_contactdb.add ( newCnt ); | ||
456 | |||
457 | setCurrentCell( row, 0 ); | ||
458 | // updateVisible(); | ||
454 | } | 459 | } |
455 | 460 | ||
456 | void AbTable::resizeRows( int size ) { | 461 | void AbTable::resizeRows() { |
457 | /* | 462 | /* |
458 | if (numRows()) { | 463 | if (numRows()) { |
459 | for (int i = 0; i < numRows(); i++) { | 464 | for (int i = 0; i < numRows(); i++) { |
460 | setRowHeight( i, size ); | 465 | setRowHeight( i, size ); |
461 | } | 466 | } |
462 | }*/ | 467 | } |
463 | updateVisible(); | 468 | updateVisible(); |
469 | */ | ||
464 | } | 470 | } |
465 | 471 | ||
466 | void AbTable::updateJournal( const Contact &cnt, | ||
467 | Contact::journal_action action, int row ) | ||
468 | { | ||
469 | QFile f( journalFileName() ); | ||
470 | if ( !f.open(IO_WriteOnly|IO_Append) ) | ||
471 | return; | ||
472 | QString buf; | ||
473 | QCString str; | ||
474 | buf = "<Contact "; | ||
475 | cnt.save( buf ); | ||
476 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | ||
477 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) | ||
478 | buf += " actionrow=\"" + QString::number(row) + "\" "; | ||
479 | buf += "/>\n"; | ||
480 | QCString cstr = buf.utf8(); | ||
481 | f.writeBlock( cstr.data(), cstr.length() ); | ||
482 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); | ||
483 | } | ||
484 | 472 | ||
485 | bool AbTable::save( const QString &fn ) | 473 | bool AbTable::save( const QString& /* fn */ ) |
486 | { | 474 | { |
487 | // QTime t; | 475 | // QTime t; |
488 | // t.start(); | 476 | // t.start(); |
489 | 477 | qWarning("abtable:Save data"); | |
490 | QString strNewFile = fn + ".new"; | 478 | m_contactdb.save(); |
491 | QFile f( strNewFile ); | 479 | |
492 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) | 480 | return true; |
493 | return false; | ||
494 | |||
495 | int total_written; | ||
496 | QString out; | ||
497 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" | ||
498 | " <Groups>\n" | ||
499 | " </Groups>\n" | ||
500 | " <Contacts>\n"; | ||
501 | QMapIterator<AbTableItem*, Contact> it; | ||
502 | for ( it = contactList.begin(); it != contactList.end(); ++it ) { | ||
503 | out += "<Contact "; | ||
504 | it.data().save( out ); | ||
505 | out += "/>\n"; | ||
506 | QCString cstr = out.utf8(); | ||
507 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
508 | if ( total_written != int(cstr.length()) ) { | ||
509 | f.close(); | ||
510 | QFile::remove( strNewFile ); | ||
511 | return false; | ||
512 | } | ||
513 | out = ""; | ||
514 | } | ||
515 | out += " </Contacts>\n</AddressBook>\n"; | ||
516 | |||
517 | QCString cstr = out.utf8(); | ||
518 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
519 | if ( total_written != int(cstr.length()) ) { | ||
520 | f.close(); | ||
521 | QFile::remove( strNewFile ); | ||
522 | return false; | ||
523 | } | ||
524 | f.close(); | ||
525 | |||
526 | // qDebug("saving: %d", t.elapsed() ); | ||
527 | |||
528 | // move the file over, I'm just going to use the system call | ||
529 | // because, I don't feel like using QDir. | ||
530 | if ( ::rename( strNewFile.latin1(), fn.latin1() ) < 0 ) { | ||
531 | qWarning( "problem renaming file %s to %s, errno: %d", | ||
532 | strNewFile.latin1(), fn.latin1(), errno ); | ||
533 | // remove the tmp file... | ||
534 | QFile::remove( strNewFile ); | ||
535 | } | ||
536 | // remove the journal... | ||
537 | QFile::remove( journalFileName() ); | ||
538 | return true; | ||
539 | } | 481 | } |
540 | 482 | ||
541 | void AbTable::load( const QString &fn ) | 483 | void AbTable::load( const QString& /* fn */ ) |
542 | { | 484 | { |
543 | setSorting( false ); | 485 | setSorting( false ); |
544 | loadFile( fn, false ); | 486 | setUpdatesEnabled( FALSE ); |
545 | // merge in the journal | 487 | |
546 | if ( QFile::exists( journalFileName() ) ) { | 488 | qWarning("abtable:Load data"); |
547 | loadFile( journalFileName(), true ); | 489 | |
548 | save( fn ); | 490 | OContactAccess::List list = m_contactdb.allRecords(); |
549 | } | 491 | OContactAccess::List::Iterator it; |
550 | setSorting( true ); | 492 | setNumRows( list.count() ); |
551 | resort(); | 493 | int row = 0; |
494 | for ( it = list.begin(); it != list.end(); ++it ) | ||
495 | insertIntoTable( *it, row++ ); | ||
496 | |||
497 | resort(); | ||
498 | |||
499 | setUpdatesEnabled( TRUE ); | ||
500 | |||
501 | setSorting( true ); | ||
502 | //resort(); | ||
552 | } | 503 | } |
553 | 504 | ||
554 | void AbTable::loadFile( const QString &strFile, bool journalFile ) | ||
555 | { | ||
556 | // QTime t; | ||
557 | // t.start(); | ||
558 | QFile f( strFile ); | ||
559 | if ( !f.open(IO_ReadOnly) ) | ||
560 | return; | ||
561 | QList<Contact> list; | ||
562 | list.setAutoDelete( TRUE ); | ||
563 | QByteArray ba = f.readAll(); | ||
564 | f.close(); | ||
565 | if (ba.isEmpty() ) | ||
566 | return; | ||
567 | char *uc = ba.data();//(QChar *)data.unicode(); | ||
568 | int len = ba.size();//data.length(); | ||
569 | bool foundAction = false; | ||
570 | Contact::journal_action action; | ||
571 | bool foundKey = false; | ||
572 | int journalKey = 0; | ||
573 | |||
574 | const int JOURNALACTION = Qtopia::Notes + 1; | ||
575 | const int JOURNALROW = JOURNALACTION + 1; | ||
576 | |||
577 | // ********************************** | ||
578 | // CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!! | ||
579 | // ********************************** | ||
580 | QAsciiDict<int> dict( 47 ); | ||
581 | dict.setAutoDelete( TRUE ); | ||
582 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); | ||
583 | dict.insert( "Title", new int(Qtopia::Title) ); | ||
584 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); | ||
585 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); | ||
586 | dict.insert( "LastName", new int(Qtopia::LastName) ); | ||
587 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); | ||
588 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); | ||
589 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); | ||
590 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); | ||
591 | dict.insert( "Emails", new int(Qtopia::Emails) ); | ||
592 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); | ||
593 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); | ||
594 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); | ||
595 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); | ||
596 | dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); | ||
597 | dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); | ||
598 | dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); | ||
599 | dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); | ||
600 | dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); | ||
601 | dict.insert( "Company", new int(Qtopia::Company) ); | ||
602 | dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); | ||
603 | dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); | ||
604 | dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); | ||
605 | dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); | ||
606 | dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); | ||
607 | dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); | ||
608 | dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); | ||
609 | dict.insert( "Department", new int(Qtopia::Department) ); | ||
610 | dict.insert( "Office", new int(Qtopia::Office) ); | ||
611 | dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); | ||
612 | dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); | ||
613 | dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); | ||
614 | dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); | ||
615 | dict.insert( "Profession", new int(Qtopia::Profession) ); | ||
616 | dict.insert( "Assistant", new int(Qtopia::Assistant) ); | ||
617 | dict.insert( "Manager", new int(Qtopia::Manager) ); | ||
618 | dict.insert( "Spouse", new int(Qtopia::Spouse) ); | ||
619 | dict.insert( "Children", new int(Qtopia::Children) ); | ||
620 | dict.insert( "Gender", new int(Qtopia::Gender) ); | ||
621 | dict.insert( "Birthday", new int(Qtopia::Birthday) ); | ||
622 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); | ||
623 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); | ||
624 | dict.insert( "Notes", new int(Qtopia::Notes) ); | ||
625 | dict.insert( "action", new int(JOURNALACTION) ); | ||
626 | dict.insert( "actionrow", new int(JOURNALROW) ); | ||
627 | |||
628 | int i = 0; | ||
629 | int num = 0; | ||
630 | char *point; | ||
631 | while ( (point = strstr( uc+i, "<Contact " ) ) != NULL ) { | ||
632 | i = point - uc; | ||
633 | // if we are reading the standard file, we just need to | ||
634 | // insert info, so just say we'll do an insert... | ||
635 | action = Contact::ACTION_ADD; | ||
636 | // new Contact | ||
637 | Contact *cnt = new Contact; | ||
638 | i += 9; | ||
639 | while ( 1 ) { | ||
640 | while ( i < len && (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) | ||
641 | i++; | ||
642 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) | ||
643 | break; | ||
644 | // we have another attribute read it. | ||
645 | int j = i; | ||
646 | while ( j < len && uc[j] != '=' ) | ||
647 | j++; | ||
648 | char *attr = uc+i; | ||
649 | uc[j] = '\0'; | ||
650 | //qDebug("attr=%s", attr.latin1() ); | ||
651 | i = ++j; // skip = | ||
652 | while ( i < len && uc[i] != '"' ) | ||
653 | i++; | ||
654 | j = ++i; | ||
655 | bool haveEnt = FALSE; | ||
656 | bool haveUtf = FALSE; | ||
657 | while ( j < len && uc[j] != '"' ) { | ||
658 | if ( uc[j] == '&' ) | ||
659 | haveEnt = TRUE; | ||
660 | if ( ((unsigned char)uc[j]) > 0x7f ) | ||
661 | haveUtf = TRUE; | ||
662 | j++; | ||
663 | } | ||
664 | |||
665 | if ( j == i ) { | ||
666 | // empty value | ||
667 | i = j + 1; | ||
668 | continue; | ||
669 | } | ||
670 | |||
671 | QString value = haveUtf ? QString::fromUtf8( uc+i, j-i ) | ||
672 | : QString::fromLatin1( uc+i, j-i ); | ||
673 | if ( haveEnt ) | ||
674 | value = Qtopia::plainString( value ); | ||
675 | i = j + 1; | ||
676 | |||
677 | int *find = dict[ attr ]; | ||
678 | if ( !find ) { | ||
679 | cnt->setCustomField(attr, value); | ||
680 | continue; | ||
681 | } | ||
682 | #if 1 | ||
683 | switch( *find ) { | ||
684 | case Qtopia::AddressUid: | ||
685 | cnt->setUid( value.toInt() ); | ||
686 | break; | ||
687 | case Qtopia::AddressCategory: | ||
688 | cnt->setCategories( Qtopia::Record::idsFromString( value )); | ||
689 | break; | ||
690 | case JOURNALACTION: | ||
691 | action = Contact::journal_action(value.toInt()); | ||
692 | break; | ||
693 | case JOURNALROW: | ||
694 | journalKey = value.toInt(); | ||
695 | break; | ||
696 | 505 | ||
697 | default: | 506 | void AbTable::realignTable( int row ) |
698 | cnt->insert( *find, value ); | 507 | { |
699 | break; | 508 | QTableItem *ti1, |
700 | } | 509 | *ti2; |
701 | #endif | 510 | int totalRows = numRows(); |
511 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | ||
512 | // the same info from the todo list still applies, but I | ||
513 | // don't think it is _too_ bad. | ||
514 | ti1 = item( curr + 1, 0 ); | ||
515 | ti2 = item( curr + 1, 1 ); | ||
516 | takeItem( ti1 ); | ||
517 | takeItem( ti2 ); | ||
518 | setItem( curr, 0, ti1 ); | ||
519 | setItem( curr, 1, ti2 ); | ||
702 | } | 520 | } |
703 | 521 | setNumRows( totalRows - 1 ); | |
704 | // sadly we can't delay adding of items from the journal to get | 522 | resort(); |
705 | // the proper effect, but then, the journal should _never_ be | 523 | } |
706 | // that huge, and recovering from a crash is not necessarily | 524 | |
707 | // a *fast* thing. | 525 | // Add contact into table. |
708 | switch ( action ) { | 526 | void AbTable::insertIntoTable( const OContact &cnt, int row ) |
709 | case Contact::ACTION_ADD: | 527 | { |
710 | if ( journalFile ) { | 528 | QString strName, |
529 | strContact; | ||
530 | |||
531 | strName = findContactName( cnt ); | ||
532 | strContact = findContactContact( cnt, row ); | ||
533 | |||
534 | AbTableItem *ati; | ||
535 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | ||
536 | contactList.insert( ati, cnt ); | ||
537 | setItem( row, 0, ati ); | ||
538 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | ||
539 | setItem( row, 1, ati ); | ||
540 | |||
541 | //### cannot do this; table only has two columns at this point | ||
542 | // setItem( row, 2, new AbPickItem( this ) ); | ||
543 | |||
544 | // resort at some point? | ||
545 | } | ||
546 | |||
547 | |||
548 | // Replace or add an entry | ||
549 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | ||
550 | { | ||
551 | QString strName, | ||
552 | strContact; | ||
553 | AbTableItem *ati = 0l; | ||
554 | |||
555 | strName = findContactName( cnt ); | ||
556 | strContact = findContactContact( cnt, row ); | ||
557 | ati = static_cast<AbTableItem*>(item(row, 0)); | ||
558 | |||
559 | // Replace element if found in row "row" | ||
560 | // or add this element if not. | ||
561 | if ( ati != 0 ) { // replace | ||
562 | // :SX db access -> replace | ||
563 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | ||
564 | m_contactdb.replace ( cnt ); | ||
565 | |||
566 | contactList.remove( ati ); | ||
567 | ati->setItem( strName, strContact ); | ||
568 | contactList.insert( ati, cnt ); | ||
569 | |||
570 | ati = static_cast<AbTableItem*>(item(row, 1)); | ||
571 | ati->setItem( strContact, strName ); | ||
572 | |||
573 | }else{ // add | ||
711 | int myrows = numRows(); | 574 | int myrows = numRows(); |
712 | setNumRows( myrows + 1 ); | 575 | setNumRows( myrows + 1 ); |
713 | insertIntoTable( *cnt, myrows ); | 576 | insertIntoTable( cnt, myrows ); |
714 | delete cnt; | 577 | // gets deleted when returning -- Why ? (se) |
715 | } | 578 | // :SX db access -> add |
716 | else | 579 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); |
717 | list.append( cnt ); | 580 | // m_contactdb.add( cnt ); |
718 | break; | ||
719 | case Contact::ACTION_REMOVE: | ||
720 | // yup, we don't use the entry to remove the object... | ||
721 | journalFreeRemove( journalKey ); | ||
722 | delete cnt; | ||
723 | break; | ||
724 | case Contact::ACTION_REPLACE: | ||
725 | journalFreeReplace( *cnt, journalKey ); | ||
726 | delete cnt; | ||
727 | break; | ||
728 | default: | ||
729 | break; | ||
730 | } | 581 | } |
731 | num++; | ||
732 | foundAction = false; | ||
733 | foundKey = false; | ||
734 | // if ( num % 100 == 0 ) { | ||
735 | // qDebug("loading file, num=%d, t=%d", num, t.elapsed() ); | ||
736 | // } | ||
737 | } | ||
738 | if ( list.count() > 0 ) { | ||
739 | internalAddEntries( list ); | ||
740 | } | ||
741 | // qDebug("done loading %d, t=%d", num, t.elapsed() ); | ||
742 | |||
743 | } | ||
744 | |||
745 | void AbTable::realignTable( int row ) | ||
746 | { | ||
747 | QTableItem *ti1, | ||
748 | *ti2; | ||
749 | int totalRows = numRows(); | ||
750 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | ||
751 | // the same info from the todo list still applies, but I | ||
752 | // don't think it is _too_ bad. | ||
753 | ti1 = item( curr + 1, 0 ); | ||
754 | ti2 = item( curr + 1, 1 ); | ||
755 | takeItem( ti1 ); | ||
756 | takeItem( ti2 ); | ||
757 | setItem( curr, 0, ti1 ); | ||
758 | setItem( curr, 1, ti2 ); | ||
759 | } | ||
760 | setNumRows( totalRows - 1 ); | ||
761 | resort(); | ||
762 | } | ||
763 | |||
764 | void AbTable::insertIntoTable( const Contact &cnt, int row ) | ||
765 | { | ||
766 | QString strName, | ||
767 | strContact; | ||
768 | |||
769 | strName = findContactName( cnt ); | ||
770 | strContact = findContactContact( cnt ); | ||
771 | |||
772 | AbTableItem *ati; | ||
773 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | ||
774 | contactList.insert( ati, cnt ); | ||
775 | setItem( row, 0, ati ); | ||
776 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | ||
777 | setItem( row, 1, ati ); | ||
778 | |||
779 | //### cannot do this; table only has two columns at this point | ||
780 | // setItem( row, 2, new AbPickItem( this ) ); | ||
781 | |||
782 | // resort at some point? | ||
783 | } | ||
784 | |||
785 | void AbTable::internalAddEntries( QList<Contact> &list ) | ||
786 | { | ||
787 | setUpdatesEnabled( FALSE ); | ||
788 | setNumRows( list.count() ); | ||
789 | int row = 0; | ||
790 | Contact *it; | ||
791 | for ( it = list.first(); it; it = list.next() ) | ||
792 | insertIntoTable( *it, row++ ); | ||
793 | resort(); | ||
794 | setUpdatesEnabled( TRUE ); | ||
795 | } | ||
796 | |||
797 | |||
798 | void AbTable::journalFreeReplace( const Contact &cnt, int row ) | ||
799 | { | ||
800 | QString strName, | ||
801 | strContact; | ||
802 | AbTableItem *ati = 0l; | ||
803 | |||
804 | strName = findContactName( cnt ); | ||
805 | strContact = findContactContact( cnt ); | ||
806 | ati = static_cast<AbTableItem*>(item(row, 0)); | ||
807 | if ( ati != 0 ) { | ||
808 | contactList.remove( ati ); | ||
809 | ati->setItem( strName, strContact ); | ||
810 | contactList.insert( ati, cnt ); | ||
811 | |||
812 | ati = static_cast<AbTableItem*>(item(row, 1)); | ||
813 | ati->setItem( strContact, strName ); | ||
814 | }else{ | ||
815 | int myrows = numRows(); | ||
816 | setNumRows( myrows + 1 ); | ||
817 | insertIntoTable( cnt, myrows ); | ||
818 | // gets deleted when returning | ||
819 | } | ||
820 | } | 582 | } |
821 | 583 | ||
584 | // Remove entry | ||
822 | void AbTable::journalFreeRemove( int row ) | 585 | void AbTable::journalFreeRemove( int row ) |
823 | { | 586 | { |
824 | AbTableItem *ati; | 587 | AbTableItem *ati; |
825 | ati = static_cast<AbTableItem*>(item(row, 0)); | 588 | ati = static_cast<AbTableItem*>(item(row, 0)); |
826 | if ( !ati ) | 589 | if ( !ati ) |
827 | return; | 590 | return; |
828 | contactList.remove( ati ); | 591 | |
829 | realignTable( row ); | 592 | // :SX db access -> remove |
593 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | ||
594 | m_contactdb.remove( contactList[ati].uid() ); | ||
595 | |||
596 | contactList.remove( ati ); | ||
597 | |||
598 | realignTable( row ); | ||
599 | |||
830 | } | 600 | } |
831 | 601 | ||
832 | #if QT_VERSION <= 230 | 602 | #if QT_VERSION <= 230 |
833 | #ifndef SINGLE_APP | 603 | #ifndef SINGLE_APP |
834 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 604 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
835 | { | 605 | { |
836 | // Region of the rect we should draw | 606 | // Region of the rect we should draw |
837 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 607 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
838 | // Subtract the table from it | 608 | // Subtract the table from it |
839 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 609 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
840 | // And draw the rectangles (transformed as needed) | 610 | // And draw the rectangles (transformed as needed) |
841 | QArray<QRect> r = reg.rects(); | 611 | QArray<QRect> r = reg.rects(); |
842 | for (unsigned int i=0; i<r.count(); i++) | 612 | for (unsigned int i=0; i<r.count(); i++) |
843 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 613 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
844 | } | 614 | } |
845 | #endif | 615 | #endif |
846 | #endif | 616 | #endif |
847 | 617 | ||
848 | 618 | ||
849 | // int AbTable::rowHeight( int ) const | 619 | // int AbTable::rowHeight( int ) const |
850 | // { | 620 | // { |
851 | // return 18; | 621 | // return 18; |
852 | // } | 622 | // } |
853 | 623 | ||
854 | // int AbTable::rowPos( int row ) const | 624 | // int AbTable::rowPos( int row ) const |
855 | // { | 625 | // { |
856 | // return 18*row; | 626 | // return 18*row; |
857 | // } | 627 | // } |
858 | 628 | ||
859 | // int AbTable::rowAt( int pos ) const | 629 | // int AbTable::rowAt( int pos ) const |
860 | // { | 630 | // { |
861 | // return QMIN( pos/18, numRows()-1 ); | 631 | // return QMIN( pos/18, numRows()-1 ); |
862 | // } | 632 | // } |
863 | 633 | ||
864 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | 634 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, |
865 | bool backwards, int category ) | 635 | bool backwards, int category ) |
866 | { | 636 | { |
867 | if ( currFindRow < -1 ) | 637 | if ( currFindRow < -1 ) |
868 | currFindRow = currentRow() - 1; | 638 | currFindRow = currentRow() - 1; |
869 | clearSelection( TRUE ); | 639 | clearSelection( TRUE ); |
870 | int rows, | 640 | int rows, row; |
871 | row; | 641 | AbTableItem *ati; |
872 | AbTableItem *ati; | 642 | QRegExp r( findString ); |
873 | QRegExp r( findString ); | 643 | r.setCaseSensitive( caseSensitive ); |
874 | r.setCaseSensitive( caseSensitive ); | 644 | rows = numRows(); |
875 | rows = numRows(); | 645 | static bool wrapAround = true; |
876 | static bool wrapAround = true; | 646 | |
877 | 647 | if ( !backwards ) { | |
878 | if ( !backwards ) { | 648 | for ( row = currFindRow + 1; row < rows; row++ ) { |
879 | for ( row = currFindRow + 1; row < rows; row++ ) { | 649 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
880 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 650 | if ( contactCompare( contactList[ati], r, category ) ) |
881 | if ( contactCompare( contactList[ati], r, category ) ) | 651 | //if ( contactCompare( contactList[row], r, category ) ) |
882 | break; | 652 | break; |
883 | 653 | } | |
654 | } else { | ||
655 | for ( row = currFindRow - 1; row > -1; row-- ) { | ||
656 | ati = static_cast<AbTableItem*>( item(row, 0) ); | ||
657 | if ( contactCompare( contactList[ati], r, category ) ) | ||
658 | //if ( contactCompare( contactList[row], r, category ) ) | ||
659 | break; | ||
660 | } | ||
884 | } | 661 | } |
885 | } else { | 662 | if ( row >= rows || row < 0 ) { |
886 | for ( row = currFindRow - 1; row > -1; row-- ) { | 663 | if ( row < 0 ) |
887 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 664 | currFindRow = rows; |
888 | if ( contactCompare( contactList[ati], r, category ) ) | 665 | else |
889 | break; | 666 | currFindRow = -1; |
667 | |||
668 | if ( wrapAround ) | ||
669 | emit signalWrapAround(); | ||
670 | else | ||
671 | emit signalNotFound(); | ||
672 | |||
673 | wrapAround = !wrapAround; | ||
674 | } else { | ||
675 | currFindRow = row; | ||
676 | QTableSelection foundSelection; | ||
677 | foundSelection.init( currFindRow, 0 ); | ||
678 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | ||
679 | addSelection( foundSelection ); | ||
680 | setCurrentCell( currFindRow, numCols() - 1 ); | ||
681 | wrapAround = true; | ||
890 | } | 682 | } |
891 | } | ||
892 | if ( row >= rows || row < 0 ) { | ||
893 | if ( row < 0 ) | ||
894 | currFindRow = rows; | ||
895 | else | ||
896 | currFindRow = -1; | ||
897 | |||
898 | if ( wrapAround ) | ||
899 | emit signalWrapAround(); | ||
900 | else | ||
901 | emit signalNotFound(); | ||
902 | |||
903 | wrapAround = !wrapAround; | ||
904 | } else { | ||
905 | currFindRow = row; | ||
906 | QTableSelection foundSelection; | ||
907 | foundSelection.init( currFindRow, 0 ); | ||
908 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | ||
909 | addSelection( foundSelection ); | ||
910 | setCurrentCell( currFindRow, numCols() - 1 ); | ||
911 | wrapAround = true; | ||
912 | } | ||
913 | } | 683 | } |
914 | 684 | ||
915 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ) | 685 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
916 | { | 686 | { |
917 | bool returnMe; | 687 | bool returnMe; |
918 | QArray<int> cats; | 688 | QArray<int> cats; |
919 | cats = cnt.categories(); | 689 | cats = cnt.categories(); |
920 | 690 | ||
921 | returnMe = false; | 691 | returnMe = false; |
922 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 692 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
923 | returnMe = cnt.match( r ); | ||
924 | else { | ||
925 | int i; | ||
926 | for ( i = 0; i < int(cats.count()); i++ ) { | ||
927 | if ( cats[i] == category ) { | ||
928 | returnMe = cnt.match( r ); | 693 | returnMe = cnt.match( r ); |
929 | break; | 694 | else { |
930 | } | 695 | int i; |
696 | for ( i = 0; i < int(cats.count()); i++ ) { | ||
697 | if ( cats[i] == category ) { | ||
698 | returnMe = cnt.match( r ); | ||
699 | break; | ||
700 | } | ||
701 | } | ||
931 | } | 702 | } |
932 | } | 703 | |
933 | return returnMe; | 704 | return returnMe; |
934 | } | 705 | } |
935 | 706 | ||
936 | void AbTable::fitColumns() | 707 | void AbTable::fitColumns() |
937 | { | 708 | { |
938 | int contentsWidth = visibleWidth(); | 709 | int contentsWidth = visibleWidth() / 2; |
939 | int n = numCols(); | 710 | |
940 | int pw = n == 3 ? columnWidth(2) : 0; | 711 | if ( showBk == "Cards" ) { |
941 | setColumnWidth( 0, contentsWidth - contentsWidth / 2 ); | 712 | showColumn(1); |
942 | setColumnWidth( 1, contentsWidth / 2 - pw ); | 713 | //adjustColumn(1); |
714 | setColumnWidth( 1, visibleWidth() ); | ||
715 | columnVisible = false; | ||
716 | } else { | ||
717 | if ( columnVisible == false ){ | ||
718 | showColumn(0); | ||
719 | columnVisible = true; | ||
720 | } | ||
721 | setColumnWidth( 0, contentsWidth ); | ||
722 | adjustColumn(1); | ||
723 | if ( columnWidth(1) < contentsWidth ) | ||
724 | setColumnWidth( 1, contentsWidth ); | ||
725 | } | ||
943 | } | 726 | } |
944 | 727 | ||
945 | void AbTable::show() | 728 | void AbTable::show() |
946 | { | 729 | { |
947 | fitColumns(); | 730 | fitColumns(); |
948 | QTable::show(); | 731 | QTable::show(); |
949 | } | 732 | } |
950 | 733 | ||
951 | void AbTable::setChoiceNames( const QStringList& list) | 734 | void AbTable::setChoiceNames( const QStringList& list) |
952 | { | 735 | { |
953 | choicenames = list; | 736 | choicenames = list; |
954 | if ( choicenames.isEmpty() ) { | 737 | if ( choicenames.isEmpty() ) { |
955 | // hide pick column | 738 | // hide pick column |
956 | setNumCols( 2 ); | 739 | setNumCols( 2 ); |
957 | } else { | 740 | } else { |
958 | // show pick column | 741 | // show pick column |
959 | setNumCols( 3 ); | 742 | setNumCols( 3 ); |
960 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 743 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
961 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 744 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
962 | } | 745 | } |
963 | fitColumns(); | 746 | fitColumns(); |
964 | } | 747 | } |
965 | 748 | ||
966 | void AbTable::itemClicked(int,int col) | 749 | void AbTable::itemClicked(int,int col) |
967 | { | 750 | { |
968 | if ( col == 2 ) { | 751 | if ( col == 2 ) { |
969 | return; | 752 | return; |
970 | } else { | 753 | } else { |
971 | emit details(); | 754 | emit details(); |
972 | } | 755 | } |
973 | } | 756 | } |
974 | 757 | ||
975 | QStringList AbTable::choiceNames() const | 758 | QStringList AbTable::choiceNames() const |
976 | { | 759 | { |
977 | return choicenames; | 760 | return choicenames; |
978 | } | 761 | } |
979 | 762 | ||
980 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | 763 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) |
981 | { | 764 | { |
982 | /* ###### | 765 | /* ###### |
983 | 766 | ||
984 | QString selname = choicenames.at(index); | 767 | QString selname = choicenames.at(index); |
985 | for (each row) { | 768 | for (each row) { |
986 | Contact *c = contactForRow(row); | 769 | OContact *c = contactForRow(row); |
987 | if ( list.contains(c->email) ) { | 770 | if ( list.contains(c->email) ) { |
988 | list.remove(c->email); | 771 | list.remove(c->email); |
989 | setText(row, 2, selname); | 772 | setText(row, 2, selname); |
990 | } | 773 | } |
991 | } | 774 | } |
992 | for (remaining list items) { | 775 | for (remaining list items) { |
993 | Contact *c = new contact(item); | 776 | OContact *c = new contact(item); |
994 | setText(newrow, 2, selname); | 777 | setText(newrow, 2, selname); |
995 | } | 778 | } |
996 | 779 | ||
997 | */ | 780 | */ |
998 | } | 781 | } |
999 | 782 | ||
1000 | QStringList AbTable::choiceSelection(int /*index*/) const | 783 | QStringList AbTable::choiceSelection(int /*index*/) const |
1001 | { | 784 | { |
1002 | QStringList r; | 785 | QStringList r; |
1003 | /* ###### | 786 | /* ###### |
1004 | 787 | ||
1005 | QString selname = choicenames.at(index); | 788 | QString selname = choicenames.at(index); |
1006 | for (each row) { | 789 | for (each row) { |
1007 | Contact *c = contactForRow(row); | 790 | OContact *c = contactForRow(row); |
1008 | if ( text(row,2) == selname ) { | 791 | if ( text(row,2) == selname ) { |
1009 | r.append(c->email); | 792 | r.append(c->email); |
1010 | } | ||
1011 | } | 793 | } |
1012 | 794 | } | |
1013 | */ | 795 | |
1014 | return r; | 796 | */ |
797 | return r; | ||
1015 | } | 798 | } |
1016 | 799 | ||
1017 | void AbTable::setShowCategory( const QString &c ) | 800 | void AbTable::setShowCategory( const QString &b, const QString &c ) |
1018 | { | 801 | { |
1019 | showCat = c; | 802 | showBk = b; |
1020 | updateVisible(); | 803 | showCat = c; |
804 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); | ||
805 | //updateVisible(); | ||
806 | refresh(); | ||
807 | ensureCellVisible( currentRow(), 0 ); | ||
808 | updateVisible(); // :SX | ||
1021 | } | 809 | } |
1022 | 810 | ||
1023 | void AbTable::setShowByLetter( char c ) | 811 | void AbTable::setShowByLetter( char c ) |
1024 | { | 812 | { |
1025 | showChar = tolower(c); | 813 | showChar = tolower(c); |
1026 | updateVisible(); | 814 | updateVisible(); |
1027 | } | 815 | } |
1028 | 816 | ||
1029 | QString AbTable::showCategory() const | 817 | QString AbTable::showCategory() const |
1030 | { | 818 | { |
1031 | return showCat; | 819 | return showCat; |
1032 | } | 820 | } |
1033 | 821 | ||
822 | QString AbTable::showBook() const | ||
823 | { | ||
824 | return showBk; | ||
825 | } | ||
1034 | 826 | ||
1035 | QStringList AbTable::categories() | 827 | QStringList AbTable::categories() |
1036 | { | 828 | { |
1037 | mCat.load( categoryFileName() ); | 829 | mCat.load( categoryFileName() ); |
1038 | QStringList categoryList = mCat.labels( "Contacts" ); | 830 | QStringList categoryList = mCat.labels( "Contacts" ); |
1039 | return categoryList; | 831 | return categoryList; |
1040 | } | 832 | } |
1041 | 833 | ||
1042 | void AbTable::updateVisible() | 834 | void AbTable::updateVisible() |
1043 | { | 835 | { |
1044 | int visible, | 836 | int visible, |
1045 | totalRows, | 837 | totalRows, |
1046 | id, | 838 | id, |
1047 | totalCats, | 839 | totalCats, |
1048 | it, | 840 | it, |
1049 | row; | 841 | row; |
1050 | bool hide; | 842 | bool hide; |
1051 | AbTableItem *ati; | 843 | AbTableItem *ati; |
1052 | Contact *cnt; | 844 | OContact *cnt; |
1053 | QString fileAsName; | 845 | QString fileAsName; |
1054 | QString tmpStr; | 846 | QString tmpStr; |
1055 | visible = 0; | 847 | visible = 0; |
1056 | 848 | ||
1057 | setPaintingEnabled( FALSE ); | 849 | setPaintingEnabled( FALSE ); |
1058 | 850 | ||
1059 | totalRows = numRows(); | 851 | totalRows = numRows(); |
1060 | id = mCat.id( "Contacts", showCat ); | 852 | id = mCat.id( "Contacts", showCat ); |
1061 | QArray<int> cats; | 853 | QArray<int> cats; |
1062 | for ( row = 0; row < totalRows; row++ ) { | 854 | for ( row = 0; row < totalRows; row++ ) { |
1063 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 855 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
1064 | cnt = &contactList[ati]; | 856 | cnt = &contactList[ati]; |
1065 | cats = cnt->categories(); | 857 | cats = cnt->categories(); |
1066 | fileAsName = cnt->fileAs(); | 858 | fileAsName = cnt->fileAs(); |
1067 | hide = false; | 859 | hide = false; |
1068 | if ( !showCat.isEmpty() ) { | 860 | if ( !showCat.isEmpty() ) { |
1069 | if ( showCat == tr( "Unfiled" ) ) { | 861 | if ( showCat == tr( "Unfiled" ) ) { |
1070 | if ( cats.count() > 0 ) | 862 | if ( cats.count() > 0 ) |
1071 | hide = true; | 863 | hide = true; |
1072 | } else { | 864 | } else { |
1073 | // do some comparing | 865 | // do some comparing |
1074 | if ( !hide ) { | 866 | if ( !hide ) { |
1075 | hide = true; | 867 | hide = true; |
1076 | totalCats = int(cats.count()); | 868 | totalCats = int(cats.count()); |
1077 | for ( it = 0; it < totalCats; it++ ) { | 869 | for ( it = 0; it < totalCats; it++ ) { |
1078 | if ( cats[it] == id ) { | 870 | if ( cats[it] == id ) { |
1079 | hide = false; | 871 | hide = false; |
1080 | break; | 872 | break; |
873 | } | ||
874 | } | ||
875 | } | ||
1081 | } | 876 | } |
1082 | } | ||
1083 | } | 877 | } |
1084 | } | 878 | if ( showChar != '\0' ) { |
1085 | } | 879 | tmpStr = fileAsName.left(1); |
1086 | if ( showChar != '\0' ) { | 880 | tmpStr = tmpStr.lower(); |
1087 | tmpStr = fileAsName.left(1); | 881 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { |
1088 | tmpStr = tmpStr.lower(); | 882 | hide = true; |
1089 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { | 883 | } |
1090 | hide = true; | 884 | if ( showChar == '#' ) { |
1091 | } | 885 | if (tmpStr == "a") |
1092 | if ( showChar == '#' ) { | 886 | hide = true; |
1093 | if (tmpStr == "a") | 887 | |
1094 | hide = true; | 888 | if (tmpStr == "b") |
1095 | 889 | hide = true; | |
1096 | if (tmpStr == "b") | 890 | |
1097 | hide = true; | 891 | if (tmpStr == "c") |
1098 | 892 | hide = true; | |
1099 | if (tmpStr == "c") | 893 | |
1100 | hide = true; | 894 | if (tmpStr == "d") |
1101 | 895 | hide = true; | |
1102 | if (tmpStr == "d") | 896 | |
1103 | hide = true; | 897 | if (tmpStr == "e") |
1104 | 898 | hide = true; | |
1105 | if (tmpStr == "e") | 899 | |
1106 | hide = true; | 900 | if (tmpStr == "f") |
1107 | 901 | hide = true; | |
1108 | if (tmpStr == "f") | 902 | |
1109 | hide = true; | 903 | if (tmpStr == "g") |
1110 | 904 | hide = true; | |
1111 | if (tmpStr == "g") | 905 | |
1112 | hide = true; | 906 | if (tmpStr == "h") |
1113 | 907 | hide = true; | |
1114 | if (tmpStr == "h") | 908 | |
1115 | hide = true; | 909 | if (tmpStr == "i") |
1116 | 910 | hide = true; | |
1117 | if (tmpStr == "i") | 911 | |
1118 | hide = true; | 912 | if (tmpStr == "j") |
1119 | 913 | hide = true; | |
1120 | if (tmpStr == "j") | 914 | |
1121 | hide = true; | 915 | if (tmpStr == "k") |
1122 | 916 | hide = true; | |
1123 | if (tmpStr == "k") | 917 | |
1124 | hide = true; | 918 | if (tmpStr == "l") |
1125 | 919 | hide = true; | |
1126 | if (tmpStr == "l") | 920 | |
1127 | hide = true; | 921 | if (tmpStr == "m") |
1128 | 922 | hide = true; | |
1129 | if (tmpStr == "m") | 923 | |
1130 | hide = true; | 924 | if (tmpStr == "n") |
1131 | 925 | hide = true; | |
1132 | if (tmpStr == "n") | 926 | |
1133 | hide = true; | 927 | if (tmpStr == "o") |
1134 | 928 | hide = true; | |
1135 | if (tmpStr == "o") | 929 | |
1136 | hide = true; | 930 | if (tmpStr == "p") |
1137 | 931 | hide = true; | |
1138 | if (tmpStr == "p") | 932 | |
1139 | hide = true; | 933 | if (tmpStr == "q") |
1140 | 934 | hide = true; | |
1141 | if (tmpStr == "q") | 935 | |
1142 | hide = true; | 936 | if (tmpStr == "r") |
1143 | 937 | hide = true; | |
1144 | if (tmpStr == "r") | 938 | |
1145 | hide = true; | 939 | if (tmpStr == "s") |
1146 | 940 | hide = true; | |
1147 | if (tmpStr == "s") | 941 | |
1148 | hide = true; | 942 | if (tmpStr == "t") |
1149 | 943 | hide = true; | |
1150 | if (tmpStr == "t") | 944 | |
1151 | hide = true; | 945 | if (tmpStr == "u") |
1152 | 946 | hide = true; | |
1153 | if (tmpStr == "u") | 947 | |
1154 | hide = true; | 948 | if (tmpStr == "v") |
1155 | 949 | hide = true; | |
1156 | if (tmpStr == "v") | 950 | |
1157 | hide = true; | 951 | if (tmpStr == "w") |
1158 | 952 | hide = true; | |
1159 | if (tmpStr == "w") | 953 | |
1160 | hide = true; | 954 | if (tmpStr == "x") |
1161 | 955 | hide = true; | |
1162 | if (tmpStr == "x") | 956 | |
1163 | hide = true; | 957 | if (tmpStr == "y") |
1164 | 958 | hide = true; | |
1165 | if (tmpStr == "y") | 959 | |
1166 | hide = true; | 960 | if (tmpStr == "z") |
1167 | 961 | hide = true; | |
1168 | if (tmpStr == "z") | 962 | } |
1169 | hide = true; | 963 | |
1170 | } | 964 | } |
1171 | 965 | if ( hide ) { | |
966 | if ( currentRow() == row ) | ||
967 | setCurrentCell( -1, 0 ); | ||
968 | if ( rowHeight(row) > 0 ) | ||
969 | hideRow( row ); | ||
970 | } else { | ||
971 | if ( rowHeight(row) == 0 ) { | ||
972 | showRow( row ); | ||
973 | adjustRow( row ); | ||
974 | } | ||
975 | visible++; | ||
976 | } | ||
1172 | } | 977 | } |
1173 | if ( hide ) { | 978 | if ( !visible ) |
1174 | if ( currentRow() == row ) | ||
1175 | setCurrentCell( -1, 0 ); | 979 | setCurrentCell( -1, 0 ); |
1176 | if ( rowHeight(row) > 0 ) | 980 | |
1177 | hideRow( row ); | 981 | setPaintingEnabled( TRUE ); |
1178 | } else { | ||
1179 | if ( rowHeight(row) == 0 ) { | ||
1180 | showRow( row ); | ||
1181 | adjustRow( row ); | ||
1182 | } | ||
1183 | visible++; | ||
1184 | } | ||
1185 | } | ||
1186 | if ( !visible ) | ||
1187 | setCurrentCell( -1, 0 ); | ||
1188 | |||
1189 | setPaintingEnabled( TRUE ); | ||
1190 | } | 982 | } |
1191 | 983 | ||
1192 | 984 | ||
1193 | void AbTable::setPaintingEnabled( bool e ) | 985 | void AbTable::setPaintingEnabled( bool e ) |
1194 | { | 986 | { |
1195 | if ( e != enablePainting ) { | 987 | if ( e != enablePainting ) { |
1196 | if ( !enablePainting ) { | 988 | if ( !enablePainting ) { |
1197 | enablePainting = true; | 989 | enablePainting = true; |
1198 | rowHeightChanged( 0 ); | 990 | rowHeightChanged( 0 ); |
1199 | viewport()->update(); | 991 | viewport()->update(); |
1200 | } else { | 992 | } else { |
1201 | enablePainting = false; | 993 | enablePainting = false; |
994 | } | ||
1202 | } | 995 | } |
1203 | } | ||
1204 | } | 996 | } |
1205 | 997 | ||
1206 | void AbTable::rowHeightChanged( int row ) | 998 | void AbTable::rowHeightChanged( int row ) |
1207 | { | 999 | { |
1208 | if ( enablePainting ) | 1000 | if ( enablePainting ) |
1209 | QTable::rowHeightChanged( row ); | 1001 | QTable::rowHeightChanged( row ); |
1210 | } | 1002 | } |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index d5ff279..84aef1e 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -1,143 +1,153 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef ABTABLE_H | 21 | #ifndef ABTABLE_H |
22 | #define ABTABLE_H | 22 | #define ABTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/contact.h> | 25 | #include <opie/ocontact.h> |
26 | 26 | ||
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qtable.h> | 28 | #include <qtable.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | 31 | ||
32 | #include <opie/ocontactaccess.h> | ||
33 | |||
32 | class AbTableItem : public QTableItem | 34 | class AbTableItem : public QTableItem |
33 | { | 35 | { |
34 | public: | 36 | public: |
35 | AbTableItem( QTable *t, EditType et, const QString &s, | 37 | AbTableItem( QTable *t, EditType et, const QString &s, |
36 | const QString &secondSortKey); | 38 | const QString &secondSortKey); |
37 | QString entryKey() const; | 39 | QString entryKey() const; |
38 | void setEntryKey( const QString & k ); | 40 | void setEntryKey( const QString & k ); |
39 | virtual int alignment() const; | 41 | virtual int alignment() const; |
40 | virtual QString key() const; | 42 | virtual QString key() const; |
41 | void setItem( const QString &txt, const QString &secondKey ); | 43 | void setItem( const QString &txt, const QString &secondKey ); |
42 | 44 | ||
43 | private: | 45 | private: |
44 | QString sortKey; | 46 | QString sortKey; |
45 | }; | 47 | }; |
46 | 48 | ||
47 | class AbPickItem : public QTableItem | 49 | class AbPickItem : public QTableItem |
48 | { | 50 | { |
49 | public: | 51 | public: |
50 | AbPickItem( QTable *t ); | 52 | AbPickItem( QTable *t ); |
51 | 53 | ||
52 | QWidget *createEditor() const; | 54 | QWidget *createEditor() const; |
53 | void setContentFromEditor( QWidget *w ); | 55 | void setContentFromEditor( QWidget *w ); |
54 | 56 | ||
55 | private: | 57 | private: |
56 | QGuardedPtr<QComboBox> cb; | 58 | QGuardedPtr<QComboBox> cb; |
57 | }; | 59 | }; |
58 | 60 | ||
59 | class AbTable : public QTable | 61 | class AbTable : public QTable |
60 | { | 62 | { |
61 | Q_OBJECT | 63 | Q_OBJECT |
62 | 64 | ||
63 | public: | 65 | public: |
64 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); | 66 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); |
65 | ~AbTable(); | 67 | ~AbTable(); |
66 | // NEW | 68 | // NEW |
67 | void addEntry( const Contact &newContact ); | 69 | void addEntry( const OContact &newContact ); |
68 | Contact currentEntry(); | 70 | OContact currentEntry(); |
69 | void replaceCurrentEntry( const Contact &newContact ); | 71 | void replaceCurrentEntry( const OContact &newContact ); |
70 | 72 | ||
71 | void init(); | 73 | void init(); |
72 | 74 | ||
73 | void deleteCurrentEntry(); | 75 | void deleteCurrentEntry(); |
74 | void clear(); | 76 | void clear(); |
75 | void clearFindRow() { currFindRow = -2; } | 77 | void clearFindRow() { currFindRow = -2; } |
76 | void loadFields(); | 78 | void loadFields(); |
77 | void refresh(); | 79 | void refresh(); |
78 | bool save( const QString &fn ); | 80 | bool save( const QString &fn ); |
79 | void load( const QString &fn ); | 81 | void load( const QString &fn ); |
80 | 82 | ||
81 | // addresspicker mode | 83 | // addresspicker mode |
82 | void setChoiceNames( const QStringList& list); | 84 | void setChoiceNames( const QStringList& list); |
83 | QStringList choiceNames() const; | 85 | QStringList choiceNames() const; |
84 | void setChoiceSelection(int index, const QStringList& list); | 86 | void setChoiceSelection(int index, const QStringList& list); |
85 | QStringList choiceSelection(int index) const; | 87 | QStringList choiceSelection(int index) const; |
86 | void setShowCategory( const QString &c ); | 88 | void setShowCategory( const QString &b, const QString &c ); |
87 | void setShowByLetter( char c ); | 89 | void setShowByLetter( char c ); |
88 | QString showCategory() const; | 90 | QString showCategory() const; |
89 | QStringList categories(); | 91 | QStringList categories(); |
90 | void resizeRows( int size ); | 92 | |
93 | void resizeRows(); | ||
91 | 94 | ||
92 | void show(); | 95 | void show(); |
93 | void setPaintingEnabled( bool e ); | 96 | void setPaintingEnabled( bool e ); |
94 | 97 | ||
98 | QString showBook() const; | ||
99 | |||
95 | public slots: | 100 | public slots: |
96 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, | 101 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, |
97 | int category ); | 102 | int category ); |
98 | signals: | 103 | signals: |
99 | void empty( bool ); | 104 | void empty( bool ); |
100 | void details(); | 105 | void details(); |
101 | void signalNotFound(); | 106 | void signalNotFound(); |
102 | void signalWrapAround(); | 107 | void signalWrapAround(); |
103 | 108 | ||
104 | protected: | 109 | protected: |
105 | virtual void keyPressEvent( QKeyEvent *e ); | 110 | virtual void keyPressEvent( QKeyEvent *e ); |
106 | 111 | ||
107 | // int rowHeight( int ) const; | 112 | // int rowHeight( int ) const; |
108 | // int rowPos( int row ) const; | 113 | // int rowPos( int row ) const; |
109 | // virtual int rowAt( int pos ) const; | 114 | // virtual int rowAt( int pos ) const; |
110 | 115 | ||
111 | 116 | ||
112 | protected slots: | 117 | protected slots: |
113 | void moveTo( char ); | 118 | void moveTo( char ); |
114 | virtual void columnClicked( int col ); | 119 | virtual void columnClicked( int col ); |
115 | void itemClicked(int,int col); | 120 | void itemClicked(int,int col); |
116 | void rowHeightChanged( int row ); | 121 | void rowHeightChanged( int row ); |
117 | 122 | ||
118 | private: | 123 | private: |
119 | void loadFile( const QString &strFile, bool journalFile ); | 124 | void loadFile( const QString &strFile, bool journalFile ); |
120 | void fitColumns(); | 125 | void fitColumns(); |
121 | void resort(); | 126 | void resort(); |
122 | void updateJournal( const Contact &contact, Contact::journal_action action, | 127 | void updateJournal( const OContact &contact, OContact::journal_action action, |
123 | int row = -1 ); | 128 | int row = -1 ); |
124 | void insertIntoTable( const Contact &contact, int row ); | 129 | void insertIntoTable( const OContact &contact, int row ); |
125 | void internalAddEntries( QList<Contact> &list ); | 130 | QString findContactName( const OContact &entry ); |
126 | QString findContactName( const Contact &entry ); | 131 | QString findContactContact( const OContact &entry, int row ); |
127 | QString findContactContact( const Contact &entry ); | 132 | void journalFreeReplace( const OContact &cnt, int row ); |
128 | void journalFreeReplace( const Contact &cnt, int row ); | ||
129 | void journalFreeRemove( int row ); | 133 | void journalFreeRemove( int row ); |
130 | void realignTable( int ); | 134 | void realignTable( int ); |
131 | void updateVisible(); | 135 | void updateVisible(); |
132 | int lastSortCol; | 136 | int lastSortCol; |
133 | bool asc; | 137 | bool asc; |
134 | char showChar; | 138 | char showChar; |
135 | QMap<AbTableItem*, Contact> contactList; | 139 | QMap<AbTableItem*, OContact> contactList; |
136 | const QValueList<int> *intFields; | 140 | const QValueList<int> *intFields; |
137 | int currFindRow; | 141 | int currFindRow; |
138 | QString showCat; | 142 | QString showCat; |
139 | QStringList choicenames; | 143 | QStringList choicenames; |
140 | bool enablePainting; | 144 | bool enablePainting; |
141 | Categories mCat; | 145 | Categories mCat; |
146 | |||
147 | QString showBk; | ||
148 | bool columnVisible; | ||
149 | |||
150 | OContactAccess m_contactdb; | ||
151 | |||
142 | }; | 152 | }; |
143 | #endif // ABTABLE_H | 153 | #endif // ABTABLE_H |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3255269..cf2eddf 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,959 +1,1030 @@ | |||
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 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_FD | 21 | #define QTOPIA_INTERNAL_FD |
22 | 22 | ||
23 | #include "contacteditor.h" | 23 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 24 | #include "ablabel.h" |
25 | #include "abtable.h" | 25 | #include "abtable.h" |
26 | #include "addresssettings.h" | 26 | #include "addresssettings.h" |
27 | #include "addressbook.h" | 27 | #include "addressbook.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/contact.h> | 34 | #include <qpe/contact.h> |
35 | 35 | ||
36 | #ifndef MAKE_FOR_SHARP_ROM | 36 | #ifndef MAKE_FOR_SHARP_ROM |
37 | #include <qpe/finddialog.h> | 37 | #include <qpe/finddialog.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/ir.h> | 42 | #include <qpe/ir.h> |
43 | #include <qpe/qpemessagebox.h> | 43 | #include <qpe/qpemessagebox.h> |
44 | #include <qpe/qcopenvelope_qws.h> | 44 | #include <qpe/qcopenvelope_qws.h> |
45 | 45 | ||
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qimage.h> | 50 | #include <qimage.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qpe/qpemenubar.h> | 52 | #include <qpe/qpemenubar.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 54 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <qpe/qpetoolbar.h> | 56 | #include <qpe/qpetoolbar.h> |
57 | #include <qstringlist.h> | 57 | #include <qstringlist.h> |
58 | #include <qtoolbutton.h> | 58 | #include <qtoolbutton.h> |
59 | #include <qwhatsthis.h> | 59 | #include <qwhatsthis.h> |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | 66 | ||
67 | #include <qdatetime.h> | 67 | #include <qdatetime.h> |
68 | 68 | ||
69 | #include "picker.h" | 69 | #include "picker.h" |
70 | static QString addressbookOldXMLFilename() | 70 | static QString addressbookOldXMLFilename() |
71 | { | 71 | { |
72 | QString filename = QPEApplication::documentDir() + "addressbook.xml"; | 72 | QString filename = QPEApplication::documentDir() + "addressbook.xml"; |
73 | return filename; | 73 | return filename; |
74 | } | 74 | } |
75 | 75 | ||
76 | static QString addressbookXMLFilename() | 76 | static QString addressbookXMLFilename() |
77 | { | 77 | { |
78 | QString filename = Global::applicationFileName("addressbook", | 78 | QString filename = Global::applicationFileName("addressbook", |
79 | "addressbook.xml"); | 79 | "addressbook.xml"); |
80 | return filename; | 80 | return filename; |
81 | } | 81 | } |
82 | 82 | ||
83 | static QString addressbookPersonalVCardName() | 83 | static QString addressbookPersonalVCardName() |
84 | { | 84 | { |
85 | QString filename = Global::applicationFileName("addressbook", | 85 | QString filename = Global::applicationFileName("addressbook", |
86 | "businesscard.vcf"); | 86 | "businesscard.vcf"); |
87 | return filename; | 87 | return filename; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 91 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
92 | WFlags f ) | 92 | WFlags f ) |
93 | : QMainWindow( parent, name, f ), | 93 | : QMainWindow( parent, name, f ), |
94 | abEditor(0), | 94 | abEditor(0), |
95 | bAbEditFirstTime(TRUE), | 95 | bAbEditFirstTime(TRUE), |
96 | syncing(FALSE) | 96 | syncing(FALSE) |
97 | { | 97 | { |
98 | initFields(); | 98 | isLoading = true; |
99 | 99 | ||
100 | setCaption( tr("Contacts") ); | 100 | initFields(); |
101 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 101 | |
102 | 102 | setCaption( tr("Contacts") ); | |
103 | setToolBarsMovable( FALSE ); | 103 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
104 | 104 | ||
105 | // Create Toolbars | 105 | setToolBarsMovable( FALSE ); |
106 | 106 | ||
107 | QPEToolBar *bar = new QPEToolBar( this ); | 107 | // Create Toolbars |
108 | bar->setHorizontalStretchable( TRUE ); | 108 | |
109 | 109 | QPEToolBar *bar = new QPEToolBar( this ); | |
110 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 110 | bar->setHorizontalStretchable( TRUE ); |
111 | mbList->setMargin( 0 ); | 111 | |
112 | 112 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | |
113 | QPopupMenu *edit = new QPopupMenu( this ); | 113 | mbList->setMargin( 0 ); |
114 | mbList->insertItem( tr( "Contact" ), edit ); | 114 | |
115 | 115 | QPopupMenu *edit = new QPopupMenu( this ); | |
116 | listTools = new QPEToolBar( this, "list operations" ); | 116 | mbList->insertItem( tr( "Contact" ), edit ); |
117 | 117 | ||
118 | 118 | listTools = new QPEToolBar( this, "list operations" ); | |
119 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 119 | |
120 | 0, this, 0 ); | 120 | |
121 | actionNew = a; | 121 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
122 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 122 | 0, this, 0 ); |
123 | a->addTo( edit ); | 123 | actionNew = a; |
124 | a->addTo( listTools ); | 124 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
125 | 125 | a->addTo( edit ); | |
126 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 126 | a->addTo( listTools ); |
127 | 0, this, 0 ); | 127 | |
128 | actionEdit = a; | 128 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
129 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 129 | 0, this, 0 ); |
130 | a->addTo( edit ); | 130 | actionEdit = a; |
131 | a->addTo( listTools ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
132 | 132 | a->addTo( edit ); | |
133 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 133 | a->addTo( listTools ); |
134 | 0, this, 0 ); | 134 | |
135 | actionTrash = a; | 135 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
136 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 136 | 0, this, 0 ); |
137 | a->addTo( edit ); | 137 | actionTrash = a; |
138 | a->addTo( listTools ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
139 | 139 | a->addTo( edit ); | |
140 | 140 | a->addTo( listTools ); | |
141 | // make it possible to go directly to businesscard via qcop call | 141 | |
142 | |||
143 | // make it possible to go directly to businesscard via qcop call | ||
142 | #if defined(Q_WS_QWS) | 144 | #if defined(Q_WS_QWS) |
143 | #if !defined(QT_NO_COP) | 145 | #if !defined(QT_NO_COP) |
144 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 146 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
145 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 147 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
146 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 148 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
147 | #endif | 149 | #endif |
148 | #endif | 150 | #endif |
149 | 151 | ||
150 | 152 | ||
151 | 153 | ||
152 | 154 | ||
153 | 155 | ||
154 | #ifndef MAKE_FOR_SHARP_ROM | 156 | #ifndef MAKE_FOR_SHARP_ROM |
155 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 157 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
156 | QString::null, 0, this, 0 ); | 158 | QString::null, 0, this, 0 ); |
157 | actionFind = a; | 159 | actionFind = a; |
158 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
159 | a->addTo( edit ); | 161 | a->addTo( edit ); |
160 | a->addTo( listTools ); | 162 | a->addTo( listTools ); |
161 | #endif | 163 | #endif |
162 | 164 | ||
163 | 165 | ||
164 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), | 166 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), |
165 | QString::null, 0, this, 0 ); | 167 | QString::null, 0, this, 0 ); |
166 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 168 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
167 | actionMail = a; | 169 | actionMail = a; |
168 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 170 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
169 | a->addTo( edit ); | 171 | a->addTo( edit ); |
170 | a->addTo( listTools ); | 172 | a->addTo( listTools ); |
171 | 173 | ||
172 | 174 | ||
173 | 175 | ||
174 | if ( Ir::supported() ) { | 176 | if ( Ir::supported() ) { |
175 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 177 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
176 | 0, this, 0 ); | 178 | 0, this, 0 ); |
177 | actionBeam = a; | 179 | actionBeam = a; |
178 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 180 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
179 | a->addTo( edit ); | 181 | a->addTo( edit ); |
180 | a->addTo( listTools ); | 182 | a->addTo( listTools ); |
181 | } | 183 | } |
182 | 184 | ||
183 | edit->insertSeparator(); | 185 | edit->insertSeparator(); |
184 | 186 | ||
185 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); | 187 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); |
186 | actionPersonal = a; | 188 | actionPersonal = a; |
187 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 189 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
188 | a->addTo( edit ); | 190 | a->addTo( edit ); |
189 | 191 | ||
190 | 192 | edit->insertSeparator(); | |
191 | edit->insertSeparator(); | 193 | |
192 | 194 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | |
193 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 195 | actionPersonal = a; |
194 | actionPersonal = a; | 196 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
195 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 197 | a->addTo( edit ); |
196 | a->addTo( edit ); | 198 | |
197 | 199 | ||
198 | 200 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | |
199 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 201 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
200 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 202 | a->addTo( edit ); |
201 | a->addTo( edit ); | 203 | |
202 | 204 | // Create Views | |
203 | // Create Views | 205 | |
204 | 206 | // This is safe to call without checking to see if it exists... | |
205 | // This is safe to call without checking to see if it exists... | 207 | // not to mention it also does the necessary stuff for the |
206 | // not to mention it also does the necessary stuff for the | 208 | // journaling... |
207 | // journaling... | 209 | QString str = addressbookXMLFilename(); |
208 | QString str = addressbookXMLFilename(); | 210 | if ( str.isNull() ) { |
209 | if ( str.isNull() ) { | 211 | QMessageBox::warning( |
210 | QMessageBox::warning( this, tr("Out of Space"), | 212 | this, |
211 | tr("There is not enough space to create\n" | 213 | tr("Out of Space"), |
212 | "neccessary startup files.\n" | 214 | tr("There is not enough space to create\n" |
213 | "\nFree up some space before\nentering data!") | 215 | "neccessary startup files.\n" |
214 | ); | 216 | "\nFree up some space before\nentering data!") |
215 | } | 217 | ); |
216 | 218 | } | |
217 | listContainer = new QWidget( this ); | 219 | |
218 | 220 | listContainer = new QWidget( this ); | |
219 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 221 | |
220 | 222 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | |
221 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 223 | |
222 | vb->addWidget(abList); | 224 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
223 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 225 | vb->addWidget(abList); |
224 | connect( abList, SIGNAL( empty( bool ) ), | 226 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
225 | this, SLOT( listIsEmpty( bool ) ) ); | 227 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
226 | connect( abList, SIGNAL( details() ), | 228 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
227 | this, SLOT( slotListView() ) ); | 229 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
228 | connect( abList, SIGNAL(currentChanged(int,int)), | 230 | |
229 | this, SLOT(slotUpdateToolbar()) ); | 231 | mView = 0; |
230 | 232 | ||
231 | mView = 0; | 233 | abList->load( addressbookXMLFilename() ); |
232 | 234 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | |
233 | abList->load( addressbookXMLFilename() ); | 235 | abList->load( addressbookOldXMLFilename() ); |
234 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | 236 | QFile::remove(addressbookOldXMLFilename()); |
235 | abList->load( addressbookOldXMLFilename() ); | 237 | } |
236 | QFile::remove(addressbookOldXMLFilename()); | 238 | |
237 | } | 239 | pLabel = new LetterPicker( listContainer ); |
238 | 240 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | |
239 | pLabel = new LetterPicker( listContainer ); | 241 | vb->addWidget(pLabel); |
240 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 242 | catMenu = new QPopupMenu( this ); |
241 | vb->addWidget(pLabel); | 243 | catMenu->setCheckable( TRUE ); |
242 | catMenu = new QPopupMenu( this ); | 244 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
243 | catMenu->setCheckable( TRUE ); | 245 | populateCategories(); |
244 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 246 | |
245 | populateCategories(); | 247 | mbList->insertItem( tr("View"), catMenu ); |
246 | 248 | // setCentralWidget( listContainer ); | |
247 | mbList->insertItem( tr("View"), catMenu ); | 249 | |
248 | setCentralWidget( listContainer ); | 250 | fontMenu = new QPopupMenu(this); |
249 | 251 | fontMenu->setCheckable( true ); | |
250 | fontMenu = new QPopupMenu(this); | 252 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
251 | fontMenu->setCheckable( true ); | 253 | |
252 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 254 | fontMenu->insertItem(tr( "Small" ), 0); |
253 | 255 | fontMenu->insertItem(tr( "Normal" ), 1); | |
254 | fontMenu->insertItem(tr( "Small" ), 0); | 256 | fontMenu->insertItem(tr( "Large" ), 2); |
255 | fontMenu->insertItem(tr( "Normal" ), 1); | 257 | |
256 | fontMenu->insertItem(tr( "Large" ), 2); | 258 | defaultFont = new QFont( abList->font() ); |
257 | 259 | ||
258 | defaultFont = new QFont( abList->font() ); | 260 | slotSetFont(startFontSize); |
259 | 261 | ||
260 | slotSetFont(startFontSize); | 262 | mbList->insertItem( tr("Font"), fontMenu); |
261 | 263 | setCentralWidget(listContainer); | |
262 | mbList->insertItem( tr("Font"), fontMenu); | 264 | |
263 | setCentralWidget(listContainer); | 265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
264 | 266 | ||
265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 267 | abList->setCurrentCell( 0, 0 ); |
268 | |||
269 | isLoading = false; | ||
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||
269 | void AddressbookWindow::slotSetFont( int size ) { | 273 | void AddressbookWindow::slotSetFont( int size ) { |
270 | 274 | ||
271 | if (size > 2 || size < 0) | 275 | if (size > 2 || size < 0) |
272 | size = 1; | 276 | size = 1; |
273 | 277 | ||
274 | startFontSize = size; | 278 | startFontSize = size; |
275 | 279 | ||
276 | QFont *currentFont; | 280 | QFont *currentFont; |
277 | 281 | ||
278 | switch (size) { | 282 | switch (size) { |
279 | case 0: | 283 | case 0: |
280 | fontMenu->setItemChecked(0, true); | 284 | fontMenu->setItemChecked(0, true); |
281 | fontMenu->setItemChecked(1, false); | 285 | fontMenu->setItemChecked(1, false); |
282 | fontMenu->setItemChecked(2, false); | 286 | fontMenu->setItemChecked(2, false); |
283 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 287 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
284 | currentFont = new QFont (abList->font()); | 288 | currentFont = new QFont (abList->font()); |
285 | abList->resizeRows(currentFont->pixelSize() + 7); | 289 | // abList->resizeRows(currentFont->pixelSize() + 7); |
286 | break; | 290 | abList->resizeRows(); |
287 | case 1: | 291 | break; |
288 | fontMenu->setItemChecked(0, false); | 292 | case 1: |
289 | fontMenu->setItemChecked(1, true); | 293 | fontMenu->setItemChecked(0, false); |
290 | fontMenu->setItemChecked(2, false); | 294 | fontMenu->setItemChecked(1, true); |
291 | abList->setFont( *defaultFont ); | 295 | fontMenu->setItemChecked(2, false); |
292 | currentFont = new QFont (abList->font()); | 296 | abList->setFont( *defaultFont ); |
293 | abList->resizeRows(currentFont->pixelSize() + 7); | 297 | currentFont = new QFont (abList->font()); |
294 | break; | 298 | // abList->resizeRows(currentFont->pixelSize() + 7); |
295 | case 2: | 299 | abList->resizeRows(); |
296 | fontMenu->setItemChecked(0, false); | 300 | break; |
297 | fontMenu->setItemChecked(1, false); | 301 | case 2: |
298 | fontMenu->setItemChecked(2, true); | 302 | fontMenu->setItemChecked(0, false); |
299 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 303 | fontMenu->setItemChecked(1, false); |
300 | currentFont = new QFont (abList->font()); | 304 | fontMenu->setItemChecked(2, true); |
301 | abList->resizeRows(currentFont->pixelSize() + 7); | 305 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
302 | break; | 306 | currentFont = new QFont (abList->font()); |
303 | } | 307 | //abList->resizeRows(currentFont->pixelSize() + 7); |
308 | abList->resizeRows(); | ||
309 | break; | ||
310 | } | ||
304 | } | 311 | } |
305 | 312 | ||
306 | 313 | ||
307 | 314 | ||
308 | void AddressbookWindow::importvCard() { | 315 | void AddressbookWindow::importvCard() { |
309 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 316 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
310 | if(!str.isEmpty() ) | 317 | if(!str.isEmpty() ) |
311 | setDocument((const QString&) str ); | 318 | setDocument((const QString&) str ); |
312 | 319 | ||
313 | } | 320 | } |
314 | 321 | ||
315 | void AddressbookWindow::setDocument( const QString &filename ) | 322 | void AddressbookWindow::setDocument( const QString &filename ) |
316 | { | 323 | { |
317 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; | 324 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
318 | 325 | return; | |
319 | QValueList<Contact> cl = Contact::readVCard( filename ); | 326 | |
320 | for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 327 | QValueList<OContact> cl = OContact::readVCard( filename ); |
321 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 328 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
322 | // .arg( (*it).fullName() ); | 329 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
323 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 330 | // .arg( (*it).fullName() ); |
324 | // QMessageBox::Ok ) { | 331 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
325 | abList->addEntry( *it ); | 332 | // QMessageBox::Ok ) { |
326 | // } | 333 | abList->addEntry( *it ); |
327 | } | 334 | // } |
328 | 335 | } | |
336 | |||
329 | } | 337 | } |
330 | 338 | ||
331 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 339 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
332 | { | 340 | { |
333 | QMainWindow::resizeEvent( e ); | 341 | QMainWindow::resizeEvent( e ); |
334 | 342 | ||
335 | if ( centralWidget() == listContainer ) | 343 | if ( centralWidget() == listContainer ) |
336 | showList(); | 344 | showList(); |
337 | else if ( centralWidget() == mView ) | 345 | else if ( centralWidget() == mView ) |
338 | showView(); | 346 | showView(); |
339 | } | 347 | } |
340 | 348 | ||
341 | AddressbookWindow::~AddressbookWindow() | 349 | AddressbookWindow::~AddressbookWindow() |
342 | { | 350 | { |
343 | Config cfg("AddressBook"); | 351 | Config cfg("AddressBook"); |
344 | cfg.setGroup("Font"); | 352 | cfg.setGroup("Font"); |
345 | cfg.writeEntry("fontSize", startFontSize); | 353 | cfg.writeEntry("fontSize", startFontSize); |
346 | } | 354 | } |
347 | 355 | ||
348 | void AddressbookWindow::slotUpdateToolbar() | 356 | void AddressbookWindow::slotUpdateToolbar() |
349 | { | 357 | { |
350 | Contact ce = abList->currentEntry(); | 358 | OContact ce = abList->currentEntry(); |
351 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 359 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
352 | } | 360 | } |
353 | 361 | ||
354 | void AddressbookWindow::showList() | 362 | void AddressbookWindow::showList() |
355 | { | 363 | { |
356 | if ( mView ) mView->hide(); | 364 | bool visiblemView; |
357 | setCentralWidget( listContainer ); | 365 | |
358 | listContainer->show(); | 366 | visiblemView = false; |
359 | // update our focues... (or use a stack widget!); | 367 | if ( mView ) { |
360 | abList->setFocus(); | 368 | mView->hide(); |
369 | visiblemView = true; | ||
370 | } | ||
371 | setCentralWidget( listContainer ); | ||
372 | listContainer->show(); | ||
373 | // update our focues... (or use a stack widget!); | ||
374 | abList->setFocus(); | ||
375 | |||
376 | // This makes sure we are scrolled all the way to the left | ||
377 | abList->setContentsPos( 0, abList->contentsY() ); | ||
378 | |||
379 | //if ( visiblemView && abList->showBook() == "Cards" ) | ||
380 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | ||
381 | |||
361 | } | 382 | } |
362 | 383 | ||
363 | void AddressbookWindow::showView() | 384 | void AddressbookWindow::showView() |
364 | { | 385 | { |
365 | if ( abList->numRows() > 0 ) { | 386 | if ( abList->numRows() > 0 ) { |
366 | listContainer->hide(); | 387 | listContainer->hide(); |
367 | setCentralWidget( abView() ); | 388 | setCentralWidget( abView() ); |
368 | mView->show(); | 389 | mView->show(); |
369 | mView->setFocus(); | 390 | mView->setFocus(); |
370 | } | 391 | } |
371 | } | 392 | } |
372 | 393 | ||
373 | void AddressbookWindow::slotListNew() | 394 | void AddressbookWindow::slotListNew() |
374 | { | 395 | { |
375 | Contact cnt; | 396 | OContact cnt; |
376 | if( !syncing ) { | 397 | if( !syncing ) { |
377 | if ( abEditor ) | 398 | if ( abEditor ) |
378 | abEditor->setEntry( cnt ); | 399 | abEditor->setEntry( cnt ); |
379 | abView()->init( cnt ); | 400 | abView()->init( cnt ); |
380 | editEntry( NewEntry ); | 401 | editEntry( NewEntry ); |
381 | } else { | 402 | } else { |
382 | QMessageBox::warning(this, tr("Contacts"), | 403 | QMessageBox::warning(this, tr("OContacts"), |
383 | tr("Can not edit data, currently syncing")); | 404 | tr("Can not edit data, currently syncing")); |
384 | } | 405 | } |
385 | } | 406 | } |
386 | 407 | ||
387 | void AddressbookWindow::slotListView() | 408 | void AddressbookWindow::slotListView() |
388 | { | 409 | { |
389 | abView()->init( abList->currentEntry() ); | 410 | abView()->init( abList->currentEntry() ); |
390 | mView->sync(); | 411 | mView->sync(); |
391 | showView(); | 412 | showView(); |
392 | } | 413 | } |
393 | 414 | ||
394 | void AddressbookWindow::slotListDelete() | 415 | void AddressbookWindow::slotListDelete() |
395 | { | 416 | { |
396 | if(!syncing) { | 417 | if(!syncing) { |
397 | Contact tmpEntry = abList->currentEntry(); | 418 | OContact tmpEntry = abList->currentEntry(); |
398 | 419 | ||
399 | // get a name, do the best we can... | 420 | // get a name, do the best we can... |
400 | QString strName = tmpEntry.fullName(); | 421 | QString strName = tmpEntry.fullName(); |
401 | if ( strName.isEmpty() ) { | 422 | if ( strName.isEmpty() ) { |
402 | strName = tmpEntry.company(); | 423 | strName = tmpEntry.company(); |
403 | if ( strName.isEmpty() ) | 424 | if ( strName.isEmpty() ) |
404 | strName = "No Name"; | 425 | strName = "No Name"; |
405 | } | 426 | } |
406 | 427 | ||
407 | 428 | ||
408 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 429 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
409 | strName ) ) { | 430 | strName ) ) { |
410 | abList->deleteCurrentEntry(); | 431 | abList->deleteCurrentEntry(); |
411 | showList(); | 432 | showList(); |
412 | } | 433 | } |
413 | } else { | 434 | } else { |
414 | QMessageBox::warning( this, tr("Contacts"), | 435 | QMessageBox::warning( this, tr("Contacts"), |
415 | tr("Can not edit data, currently syncing") ); | 436 | tr("Can not edit data, currently syncing") ); |
416 | } | 437 | } |
417 | } | 438 | } |
418 | 439 | ||
419 | void AddressbookWindow::slotViewBack() | 440 | void AddressbookWindow::slotViewBack() |
420 | { | 441 | { |
421 | showList(); | 442 | showList(); |
422 | } | 443 | } |
423 | 444 | ||
424 | void AddressbookWindow::slotViewEdit() | 445 | void AddressbookWindow::slotViewEdit() |
425 | { | 446 | { |
426 | if(!syncing) { | 447 | if(!syncing) { |
427 | if (actionPersonal->isOn()) { | 448 | if (actionPersonal->isOn()) { |
428 | editPersonal(); | 449 | editPersonal(); |
429 | } else { | 450 | } else { |
430 | if ( !bAbEditFirstTime ) | 451 | if ( !bAbEditFirstTime ) |
431 | abEditor->setEntry( abList->currentEntry() ); | 452 | abEditor->setEntry( abList->currentEntry() ); |
432 | editEntry( EditEntry ); | 453 | editEntry( EditEntry ); |
433 | } | 454 | } |
434 | } else { | 455 | } else { |
435 | QMessageBox::warning( this, tr("Contacts"), | 456 | QMessageBox::warning( this, tr("Contacts"), |
436 | tr("Can not edit data, currently syncing") ); | 457 | tr("Can not edit data, currently syncing") ); |
437 | } | 458 | } |
438 | } | 459 | } |
439 | 460 | ||
440 | 461 | ||
441 | 462 | ||
442 | void AddressbookWindow::writeMail() | 463 | void AddressbookWindow::writeMail() |
443 | { | 464 | { |
444 | Contact c = abList->currentEntry(); | 465 | OContact c = abList->currentEntry(); |
445 | QString name = c.fileAs(); | 466 | QString name = c.fileAs(); |
446 | QString email = c.defaultEmail(); | 467 | QString email = c.defaultEmail(); |
447 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 468 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
448 | e << name << email; | 469 | e << name << email; |
449 | } | 470 | } |
450 | 471 | ||
451 | |||
452 | |||
453 | |||
454 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 472 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
455 | 473 | ||
456 | void AddressbookWindow::slotBeam() | 474 | void AddressbookWindow::slotBeam() |
457 | { | 475 | { |
458 | QString filename; | 476 | QString filename; |
459 | Contact c; | 477 | OContact c; |
460 | if ( actionPersonal->isOn() ) { | 478 | if ( actionPersonal->isOn() ) { |
461 | filename = addressbookPersonalVCardName(); | 479 | filename = addressbookPersonalVCardName(); |
462 | if (!QFile::exists(filename)) | 480 | if (!QFile::exists(filename)) |
463 | return; // can't beam a non-existent file | 481 | return; // can't beam a non-existent file |
464 | c = Contact::readVCard( filename )[0]; | 482 | c = OContact::readVCard( filename )[0]; |
465 | } else { | 483 | } else { |
466 | unlink( beamfile ); // delete if exists | 484 | unlink( beamfile ); // delete if exists |
467 | c = abList->currentEntry(); | 485 | c = abList->currentEntry(); |
468 | mkdir("/tmp/obex/", 0755); | 486 | mkdir("/tmp/obex/", 0755); |
469 | Contact::writeVCard( beamfile, c ); | 487 | OContact::writeVCard( beamfile, c ); |
470 | filename = beamfile; | 488 | filename = beamfile; |
471 | } | 489 | } |
472 | Ir *ir = new Ir( this ); | 490 | Ir *ir = new Ir( this ); |
473 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 491 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
474 | QString description = c.fullName(); | 492 | QString description = c.fullName(); |
475 | ir->send( filename, description, "text/x-vCard" ); | 493 | ir->send( filename, description, "text/x-vCard" ); |
476 | } | 494 | } |
477 | 495 | ||
478 | void AddressbookWindow::beamDone( Ir *ir ) | 496 | void AddressbookWindow::beamDone( Ir *ir ) |
479 | { | 497 | { |
480 | delete ir; | 498 | delete ir; |
481 | unlink( beamfile ); | 499 | unlink( beamfile ); |
482 | } | 500 | } |
483 | 501 | ||
484 | 502 | ||
485 | static void parseName( const QString& name, QString *first, QString *middle, | 503 | static void parseName( const QString& name, QString *first, QString *middle, |
486 | QString * last ) | 504 | QString * last ) |
487 | { | 505 | { |
488 | 506 | ||
489 | int comma = name.find ( "," ); | 507 | int comma = name.find ( "," ); |
490 | QString rest; | 508 | QString rest; |
491 | if ( comma > 0 ) { | 509 | if ( comma > 0 ) { |
492 | *last = name.left( comma ); | 510 | *last = name.left( comma ); |
493 | comma++; | 511 | comma++; |
494 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 512 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
495 | comma++; | 513 | comma++; |
496 | rest = name.mid( comma ); | 514 | rest = name.mid( comma ); |
497 | } else { | 515 | } else { |
498 | int space = name.findRev( ' ' ); | 516 | int space = name.findRev( ' ' ); |
499 | *last = name.mid( space+1 ); | 517 | *last = name.mid( space+1 ); |
500 | rest = name.left( space ); | 518 | rest = name.left( space ); |
501 | } | 519 | } |
502 | int space = rest.find( ' ' ); | 520 | int space = rest.find( ' ' ); |
503 | if ( space <= 0 ) { | 521 | if ( space <= 0 ) { |
504 | *first = rest; | 522 | *first = rest; |
505 | } else { | 523 | } else { |
506 | *first = rest.left( space ); | 524 | *first = rest.left( space ); |
507 | *middle = rest.mid( space+1 ); | 525 | *middle = rest.mid( space+1 ); |
508 | } | 526 | } |
509 | 527 | ||
510 | } | 528 | } |
511 | 529 | ||
512 | 530 | ||
513 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 531 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
514 | { | 532 | { |
515 | if (msg == "editPersonal()") { | 533 | if (msg == "editPersonal()") { |
516 | editPersonal(); | 534 | editPersonal(); |
517 | } else if (msg == "editPersonalAndClose()") { | 535 | } else if (msg == "editPersonalAndClose()") { |
518 | editPersonal(); | 536 | editPersonal(); |
519 | close(); | 537 | close(); |
520 | } else if ( msg == "addContact(QString,QString)" ) { | 538 | } else if ( msg == "addContact(QString,QString)" ) { |
521 | QDataStream stream(data,IO_ReadOnly); | 539 | QDataStream stream(data,IO_ReadOnly); |
522 | QString name, email; | 540 | QString name, email; |
523 | stream >> name >> email; | 541 | stream >> name >> email; |
524 | 542 | ||
525 | Contact cnt; | 543 | OContact cnt; |
526 | QString fn, mn, ln; | 544 | QString fn, mn, ln; |
527 | parseName( name, &fn, &mn, &ln ); | 545 | parseName( name, &fn, &mn, &ln ); |
528 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 546 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
529 | cnt.setFirstName( fn ); | 547 | cnt.setFirstName( fn ); |
530 | cnt.setMiddleName( mn ); | 548 | cnt.setMiddleName( mn ); |
531 | cnt.setLastName( ln ); | 549 | cnt.setLastName( ln ); |
532 | cnt.insertEmails( email ); | 550 | cnt.insertEmails( email ); |
533 | cnt.setDefaultEmail( email ); | 551 | cnt.setDefaultEmail( email ); |
534 | cnt.setFileAs(); | 552 | cnt.setFileAs(); |
535 | 553 | ||
536 | if ( bAbEditFirstTime ) { | 554 | if ( bAbEditFirstTime ) { |
537 | abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, | 555 | abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, |
538 | this, "editor" ); | 556 | this, "editor" ); |
539 | bAbEditFirstTime = FALSE; | 557 | bAbEditFirstTime = FALSE; |
540 | } else { | 558 | } else { |
541 | abEditor->setEntry( cnt ); | 559 | abEditor->setEntry( cnt ); |
542 | } | 560 | } |
543 | abView()->init( cnt ); | 561 | abView()->init( cnt ); |
544 | editEntry( NewEntry ); | 562 | editEntry( NewEntry ); |
545 | 563 | ||
546 | 564 | ||
547 | 565 | ||
548 | } | 566 | } |
549 | #if 0 | 567 | #if 0 |
550 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 568 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
551 | QDataStream stream(data,IO_ReadOnly); | 569 | QDataStream stream(data,IO_ReadOnly); |
552 | QCString ch,m; | 570 | QCString ch,m; |
553 | QStringList types; | 571 | QStringList types; |
554 | stream >> ch >> m >> types; | 572 | stream >> ch >> m >> types; |
555 | AddressPicker picker(abList,this,0,TRUE); | 573 | AddressPicker picker(abList,this,0,TRUE); |
556 | picker.showMaximized(); | 574 | picker.showMaximized(); |
557 | picker.setChoiceNames(types); | 575 | picker.setChoiceNames(types); |
558 | int i=0; | 576 | int i=0; |
559 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 577 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
560 | QStringList sel; | 578 | QStringList sel; |
561 | stream >> sel; | 579 | stream >> sel; |
562 | picker.setSelection(i++,sel); | 580 | picker.setSelection(i++,sel); |
563 | } | 581 | } |
564 | picker.showMaximized(); | 582 | picker.showMaximized(); |
565 | picker.exec(); | 583 | picker.exec(); |
566 | 584 | ||
567 | // ###### note: contacts may have been added - save here! | 585 | // ###### note: contacts may have been added - save here! |
568 | 586 | ||
569 | setCentralWidget(abList); | 587 | setCentralWidget(abList); |
570 | QCopEnvelope e(ch,m); | 588 | QCopEnvelope e(ch,m); |
571 | i=0; | 589 | i=0; |
572 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 590 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
573 | QStringList sel = picker.selection(i++); | 591 | QStringList sel = picker.selection(i++); |
574 | e << sel; | 592 | e << sel; |
575 | } | 593 | } |
576 | } | 594 | } |
577 | #endif | 595 | #endif |
578 | 596 | ||
579 | } | 597 | } |
580 | 598 | ||
581 | void AddressbookWindow::editPersonal() | 599 | void AddressbookWindow::editPersonal() |
582 | { | 600 | { |
583 | QString filename = addressbookPersonalVCardName(); | 601 | QString filename = addressbookPersonalVCardName(); |
584 | Contact me; | 602 | OContact me; |
585 | if (QFile::exists(filename)) | 603 | if (QFile::exists(filename)) |
586 | me = Contact::readVCard( filename )[0]; | 604 | me = OContact::readVCard( filename )[0]; |
587 | if (bAbEditFirstTime) { | 605 | if (bAbEditFirstTime) { |
588 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, | 606 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, |
589 | this, "editor" ); | 607 | this, "editor" ); |
590 | // don't create a new editor every time | 608 | // don't create a new editor every time |
591 | bAbEditFirstTime = FALSE; | 609 | bAbEditFirstTime = FALSE; |
592 | } else | 610 | } else |
593 | abEditor->setEntry( me ); | 611 | abEditor->setEntry( me ); |
594 | 612 | ||
595 | abEditor->setCaption(tr("Edit My Personal Details")); | 613 | abEditor->setCaption(tr("Edit My Personal Details")); |
596 | abEditor->showMaximized(); | 614 | abEditor->showMaximized(); |
597 | 615 | ||
598 | // fix the foxus... | 616 | // fix the foxus... |
599 | abEditor->setNameFocus(); | 617 | abEditor->setNameFocus(); |
600 | if ( abEditor->exec() ) { | 618 | if ( abEditor->exec() ) { |
601 | setFocus(); | 619 | setFocus(); |
602 | Contact new_personal = abEditor->entry(); | 620 | OContact new_personal = abEditor->entry(); |
603 | QString fname = addressbookPersonalVCardName(); | 621 | QString fname = addressbookPersonalVCardName(); |
604 | Contact::writeVCard( fname, new_personal ); | 622 | OContact::writeVCard( fname, new_personal ); |
605 | abView()->init(new_personal); | 623 | abView()->init(new_personal); |
606 | abView()->sync(); | 624 | abView()->sync(); |
607 | } | 625 | } |
608 | abEditor->setCaption( tr("Edit Address") ); | 626 | abEditor->setCaption( tr("Edit Address") ); |
609 | } | 627 | } |
610 | 628 | ||
611 | void AddressbookWindow::slotPersonalView() | 629 | void AddressbookWindow::slotPersonalView() |
612 | { | 630 | { |
613 | if (!actionPersonal->isOn()) { | 631 | if (!actionPersonal->isOn()) { |
614 | // we just turned it off | 632 | // we just turned it off |
615 | setCaption( tr("Contacts") ); | 633 | setCaption( tr("Contacts") ); |
616 | actionNew->setEnabled(TRUE); | 634 | actionNew->setEnabled(TRUE); |
617 | actionTrash->setEnabled(TRUE); | 635 | actionTrash->setEnabled(TRUE); |
618 | #ifndef MAKE_FOR_SHARP_ROM | 636 | #ifndef MAKE_FOR_SHARP_ROM |
619 | actionFind->setEnabled(TRUE); | 637 | actionFind->setEnabled(TRUE); |
620 | #endif | 638 | #endif |
621 | slotUpdateToolbar(); // maybe some of the above could be moved there | 639 | slotUpdateToolbar(); // maybe some of the above could be moved there |
622 | showList(); | 640 | showList(); |
623 | return; | 641 | return; |
624 | } | 642 | } |
625 | 643 | ||
626 | // XXX need to disable some QActions. | 644 | // XXX need to disable some QActions. |
627 | actionNew->setEnabled(FALSE); | 645 | actionNew->setEnabled(FALSE); |
628 | actionTrash->setEnabled(FALSE); | 646 | actionTrash->setEnabled(FALSE); |
629 | #ifndef MAKE_FOR_SHARP_ROM | 647 | #ifndef MAKE_FOR_SHARP_ROM |
630 | actionFind->setEnabled(FALSE); | 648 | actionFind->setEnabled(FALSE); |
631 | #endif | 649 | #endif |
632 | actionMail->setEnabled(FALSE); | 650 | actionMail->setEnabled(FALSE); |
633 | 651 | ||
634 | setCaption( tr("Contacts - My Personal Details") ); | 652 | setCaption( tr("Contacts - My Personal Details") ); |
635 | QString filename = addressbookPersonalVCardName(); | 653 | QString filename = addressbookPersonalVCardName(); |
636 | Contact me; | 654 | OContact me; |
637 | if (QFile::exists(filename)) | 655 | if (QFile::exists(filename)) |
638 | me = Contact::readVCard( filename )[0]; | 656 | me = OContact::readVCard( filename )[0]; |
639 | 657 | ||
640 | abView()->init( me ); | 658 | abView()->init( me ); |
641 | abView()->sync(); | 659 | abView()->sync(); |
642 | listContainer->hide(); | 660 | listContainer->hide(); |
643 | setCentralWidget( abView() ); | 661 | setCentralWidget( abView() ); |
644 | mView->show(); | 662 | mView->show(); |
645 | mView->setFocus(); | 663 | mView->setFocus(); |
646 | } | 664 | } |
647 | 665 | ||
648 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 666 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
649 | { | 667 | { |
650 | Contact entry; | 668 | OContact entry; |
651 | if ( bAbEditFirstTime ) { | 669 | if ( bAbEditFirstTime ) { |
652 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, | 670 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, |
653 | this, "editor" ); | 671 | this, "editor" ); |
654 | bAbEditFirstTime = FALSE; | 672 | bAbEditFirstTime = FALSE; |
655 | if ( entryMode == EditEntry ) | 673 | if ( entryMode == EditEntry ) |
656 | abEditor->setEntry( abList->currentEntry() ); | 674 | abEditor->setEntry( abList->currentEntry() ); |
657 | } | 675 | } |
658 | // other things may chane the caption. | 676 | // other things may chane the caption. |
659 | abEditor->setCaption( tr("Edit Address") ); | 677 | abEditor->setCaption( tr("Edit Address") ); |
660 | 678 | ||
661 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 679 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
662 | abEditor->showMaximized(); | 680 | abEditor->showMaximized(); |
663 | #endif | 681 | #endif |
664 | // fix the foxus... | 682 | // fix the foxus... |
665 | abEditor->setNameFocus(); | 683 | abEditor->setNameFocus(); |
666 | if ( abEditor->exec() ) { | 684 | if ( abEditor->exec() ) { |
667 | setFocus(); | 685 | setFocus(); |
668 | if ( entryMode == NewEntry ) { | 686 | if ( entryMode == NewEntry ) { |
669 | Contact insertEntry = abEditor->entry(); | 687 | OContact insertEntry = abEditor->entry(); |
670 | insertEntry.assignUid(); | 688 | insertEntry.assignUid(); |
671 | abList->addEntry( insertEntry ); | 689 | abList->addEntry( insertEntry ); |
672 | } else { | 690 | } else { |
673 | Contact replaceEntry = abEditor->entry(); | 691 | OContact replaceEntry = abEditor->entry(); |
674 | if ( !replaceEntry.isValidUid() ) | 692 | if ( !replaceEntry.isValidUid() ) |
675 | replaceEntry.assignUid(); | 693 | replaceEntry.assignUid(); |
676 | abList->replaceCurrentEntry( replaceEntry ); | 694 | abList->replaceCurrentEntry( replaceEntry ); |
677 | } | 695 | } |
678 | } | 696 | } |
679 | populateCategories(); | 697 | populateCategories(); |
680 | showList(); | 698 | showList(); |
681 | } | 699 | } |
682 | 700 | ||
683 | void AddressbookWindow::listIsEmpty( bool empty ) | 701 | void AddressbookWindow::listIsEmpty( bool empty ) |
684 | { | 702 | { |
685 | if ( !empty ) { | 703 | if ( !empty ) { |
686 | deleteButton->setEnabled( TRUE ); | 704 | deleteButton->setEnabled( TRUE ); |
687 | } | 705 | } |
688 | } | 706 | } |
689 | 707 | ||
690 | void AddressbookWindow::reload() | 708 | void AddressbookWindow::reload() |
691 | { | 709 | { |
692 | syncing = FALSE; | 710 | syncing = FALSE; |
693 | abList->clear(); | 711 | abList->clear(); |
694 | abList->load( addressbookXMLFilename() ); | 712 | abList->load( addressbookXMLFilename() ); |
695 | } | 713 | } |
696 | 714 | ||
697 | void AddressbookWindow::flush() | 715 | void AddressbookWindow::flush() |
698 | { | 716 | { |
699 | syncing = TRUE; | 717 | syncing = TRUE; |
700 | abList->save( addressbookXMLFilename() ); | 718 | abList->save( addressbookXMLFilename() ); |
701 | } | 719 | } |
702 | 720 | ||
703 | 721 | ||
704 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 722 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
705 | { | 723 | { |
706 | if ( centralWidget() == mView ) { | 724 | if ( centralWidget() == mView ) { |
707 | if (actionPersonal->isOn()) { | 725 | if (actionPersonal->isOn()) { |
708 | // pretend we clicked it off | 726 | // pretend we clicked it off |
709 | actionPersonal->setOn(FALSE); | 727 | actionPersonal->setOn(FALSE); |
710 | slotPersonalView(); | 728 | slotPersonalView(); |
711 | } else { | 729 | } else { |
712 | showList(); | 730 | showList(); |
713 | } | 731 | } |
714 | e->ignore(); | 732 | e->ignore(); |
715 | return; | 733 | return; |
716 | } | 734 | } |
717 | 735 | ||
718 | if(syncing) { | 736 | if(syncing) { |
719 | /* shouldn't we save, I hear you say? well its already been set | 737 | /* shouldn't we save, I hear you say? well its already been set |
720 | so that an edit can not occur during a sync, and we flushed | 738 | so that an edit can not occur during a sync, and we flushed |
721 | at the start of the sync, so there is no need to save | 739 | at the start of the sync, so there is no need to save |
722 | Saving however itself would cause problems. */ | 740 | Saving however itself would cause problems. */ |
723 | e->accept(); | 741 | e->accept(); |
724 | return; | 742 | return; |
725 | } | 743 | } |
726 | //################## shouldn't always save | 744 | //################## shouldn't always save |
727 | if ( save() ) | 745 | // True, but the database handles this automatically ! (se) |
728 | e->accept(); | 746 | if ( save() ) |
729 | else | 747 | e->accept(); |
730 | e->ignore(); | 748 | else |
749 | e->ignore(); | ||
731 | } | 750 | } |
732 | 751 | ||
733 | /* | 752 | /* |
734 | Returns TRUE if it is OK to exit | 753 | Returns TRUE if it is OK to exit |
735 | */ | 754 | */ |
736 | 755 | ||
737 | bool AddressbookWindow::save() | 756 | bool AddressbookWindow::save() |
738 | { | 757 | { |
739 | QString str = addressbookXMLFilename(); | 758 | QString str = addressbookXMLFilename(); |
740 | if ( str.isNull() ) { | 759 | if ( str.isNull() ) { |
741 | if ( QMessageBox::critical( 0, tr("Out of space"), | 760 | if ( QMessageBox::critical( 0, tr("Out of space"), |
742 | tr("Unable to save information.\n" | 761 | tr("Unable to save information.\n" |
743 | "Free up some space\n" | 762 | "Free up some space\n" |
744 | "and try again.\n" | 763 | "and try again.\n" |
745 | "\nQuit anyway?"), | 764 | "\nQuit anyway?"), |
746 | QMessageBox::Yes|QMessageBox::Escape, | 765 | QMessageBox::Yes|QMessageBox::Escape, |
747 | QMessageBox::No|QMessageBox::Default ) | 766 | QMessageBox::No|QMessageBox::Default ) |
748 | != QMessageBox::No ) | 767 | != QMessageBox::No ) |
749 | return TRUE; | 768 | return TRUE; |
750 | else | 769 | else |
751 | return FALSE; | 770 | return FALSE; |
752 | } else { | 771 | } else { |
753 | if ( !abList->save( str ) ) { | 772 | if ( !abList->save( str ) ) { |
754 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 773 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
755 | tr("Unable to save information.\n" | 774 | tr("Unable to save information.\n" |
756 | "Free up some space\n" | 775 | "Free up some space\n" |
757 | "and try again.\n" | 776 | "and try again.\n" |
758 | "\nQuit anyway?"), | 777 | "\nQuit anyway?"), |
759 | QMessageBox::Yes|QMessageBox::Escape, | 778 | QMessageBox::Yes|QMessageBox::Escape, |
760 | QMessageBox::No|QMessageBox::Default ) | 779 | QMessageBox::No|QMessageBox::Default ) |
761 | != QMessageBox::No ) | 780 | != QMessageBox::No ) |
762 | return TRUE; | 781 | return TRUE; |
763 | else | 782 | else |
764 | return FALSE; | 783 | return FALSE; |
765 | } | 784 | } |
766 | } | 785 | } |
767 | return TRUE; | 786 | return TRUE; |
768 | } | 787 | } |
769 | 788 | ||
770 | void AddressbookWindow::slotSettings() | 789 | void AddressbookWindow::slotSettings() |
771 | { | 790 | { |
772 | AddressSettings frmSettings( this ); | 791 | AddressSettings frmSettings( this ); |
773 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 792 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
774 | frmSettings.showMaximized(); | 793 | frmSettings.showMaximized(); |
775 | #endif | 794 | #endif |
776 | 795 | ||
777 | if ( frmSettings.exec() ) { | 796 | if ( frmSettings.exec() ) { |
778 | allFields.clear(); | 797 | allFields.clear(); |
779 | orderedFields.clear(); | 798 | orderedFields.clear(); |
780 | slOrderedFields.clear(); | 799 | slOrderedFields.clear(); |
781 | initFields(); | 800 | initFields(); |
782 | if ( abEditor ) | 801 | if ( abEditor ) |
783 | abEditor->loadFields(); | 802 | abEditor->loadFields(); |
784 | abList->refresh(); | 803 | abList->refresh(); |
785 | } | 804 | } |
786 | } | 805 | } |
787 | 806 | ||
788 | 807 | ||
789 | void AddressbookWindow::initFields() | 808 | void AddressbookWindow::initFields() |
790 | { | 809 | { |
791 | // we really don't need the things from the configuration, anymore | 810 | // we really don't need the things from the configuration, anymore |
792 | // only thing that is important are the important categories. So, | 811 | // only thing that is important are the important categories. So, |
793 | // Call the contact functions that correspond to these old functions... | 812 | // Call the contact functions that correspond to these old functions... |
794 | 813 | ||
795 | QStringList xmlFields = Contact::fields(); | 814 | QStringList xmlFields = OContact::fields(); |
796 | QStringList visibleFields = Contact::trfields(); | 815 | QStringList visibleFields = OContact::trfields(); |
797 | xmlFields.remove( "Title" ); | 816 | xmlFields.remove( "Title" ); |
798 | visibleFields.remove( tr("Name Title") ); | 817 | visibleFields.remove( tr("Name Title") ); |
799 | visibleFields.remove( tr("Notes") ); | 818 | visibleFields.remove( tr("Notes") ); |
800 | 819 | ||
801 | int i, | 820 | int i, version; |
802 | version; | 821 | Config cfg( "AddressBook" ); |
803 | Config cfg( "AddressBook" ); | 822 | QString zn; |
804 | QString zn; | 823 | |
805 | 824 | // ### Write a function to keep this from happening again... | |
806 | // ### Write a function to keep this from happening again... | 825 | QStringList::ConstIterator it; |
807 | QStringList::ConstIterator it; | 826 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { |
808 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { | 827 | allFields.append( i + 3 ); |
809 | allFields.append( i + 3 ); | 828 | } |
810 | } | 829 | |
811 | 830 | cfg.setGroup( "Version" ); | |
812 | cfg.setGroup( "Version" ); | 831 | version = cfg.readNumEntry( "version" ); |
813 | version = cfg.readNumEntry( "version" ); | 832 | i = 0; |
814 | i = 0; | 833 | startFontSize = 1; |
815 | startFontSize = 1; | 834 | |
816 | 835 | if ( version >= ADDRESSVERSION ) { | |
817 | if ( version >= ADDRESSVERSION ) { | 836 | |
818 | 837 | cfg.setGroup( "ImportantCategory" ); | |
819 | cfg.setGroup( "ImportantCategory" ); | 838 | |
820 | 839 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); | |
821 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); | 840 | while ( !zn.isNull() ) { |
822 | while ( !zn.isNull() ) { | 841 | if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { |
823 | if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { | 842 | slOrderedFields.clear(); |
824 | slOrderedFields.clear(); | 843 | break; |
825 | break; | 844 | } |
826 | } | 845 | slOrderedFields.append( zn ); |
827 | slOrderedFields.append( zn ); | 846 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); |
828 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); | 847 | } |
829 | } | 848 | cfg.setGroup( "Font" ); |
830 | cfg.setGroup( "Font" ); | 849 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); |
831 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); | 850 | |
832 | 851 | ||
833 | 852 | } else { | |
834 | } else { | 853 | QString str; |
835 | QString str; | 854 | str = getenv("HOME"); |
836 | str = getenv("HOME"); | 855 | str += "/Settings/AddressBook.conf"; |
837 | str += "/Settings/AddressBook.conf"; | 856 | QFile::remove( str ); |
838 | QFile::remove( str ); | 857 | } |
839 | } | 858 | if ( slOrderedFields.count() > 0 ) { |
840 | if ( slOrderedFields.count() > 0 ) { | 859 | for( QStringList::ConstIterator it = slOrderedFields.begin(); |
841 | for( QStringList::ConstIterator it = slOrderedFields.begin(); | 860 | it != slOrderedFields.end(); ++it ) { |
842 | it != slOrderedFields.end(); ++it ) { | 861 | QValueList<int>::ConstIterator itVl; |
843 | QValueList<int>::ConstIterator itVl; | 862 | QStringList::ConstIterator itVis; |
844 | QStringList::ConstIterator itVis; | 863 | itVl = allFields.begin(); |
845 | itVl = allFields.begin(); | 864 | for ( itVis = visibleFields.begin(); |
846 | for ( itVis = visibleFields.begin(); | 865 | itVis != visibleFields.end() && itVl != allFields.end(); |
847 | itVis != visibleFields.end() && itVl != allFields.end(); | 866 | ++itVis, ++itVl ) { |
848 | ++itVis, ++itVl ) { | 867 | if ( *it == *itVis && itVl != allFields.end() ) { |
849 | if ( *it == *itVis && itVl != allFields.end() ) { | 868 | orderedFields.append( *itVl ); |
850 | orderedFields.append( *itVl ); | 869 | } |
851 | } | 870 | } |
852 | } | 871 | } |
853 | } | 872 | } else { |
854 | } else { | 873 | QValueList<int>::ConstIterator it; |
855 | QValueList<int>::ConstIterator it; | 874 | for ( it = allFields.begin(); it != allFields.end(); ++it ) |
856 | for ( it = allFields.begin(); it != allFields.end(); ++it ) | 875 | orderedFields.append( *it ); |
857 | orderedFields.append( *it ); | 876 | |
858 | 877 | slOrderedFields = visibleFields; | |
859 | slOrderedFields = visibleFields; | 878 | orderedFields.remove( Qtopia::AddressUid ); |
860 | orderedFields.remove( Qtopia::AddressUid ); | 879 | orderedFields.remove( Qtopia::Title ); |
861 | orderedFields.remove( Qtopia::Title ); | 880 | orderedFields.remove( Qtopia::Groups ); |
862 | orderedFields.remove( Qtopia::Groups ); | 881 | orderedFields.remove( Qtopia::AddressCategory ); |
863 | orderedFields.remove( Qtopia::AddressCategory ); | 882 | orderedFields.remove( Qtopia::FirstName ); |
864 | orderedFields.remove( Qtopia::FirstName ); | 883 | orderedFields.remove( Qtopia::LastName ); |
865 | orderedFields.remove( Qtopia::LastName ); | 884 | orderedFields.remove( Qtopia::DefaultEmail ); |
866 | orderedFields.remove( Qtopia::DefaultEmail ); | 885 | orderedFields.remove( Qtopia::FileAs ); |
867 | orderedFields.remove( Qtopia::FileAs ); | 886 | orderedFields.remove( Qtopia::Notes ); |
868 | orderedFields.remove( Qtopia::Notes ); | 887 | orderedFields.remove( Qtopia::Gender ); |
869 | orderedFields.remove( Qtopia::Gender ); | 888 | slOrderedFields.remove( tr("Name Title") ); |
870 | slOrderedFields.remove( tr("Name Title") ); | 889 | slOrderedFields.remove( tr("First Name") ); |
871 | slOrderedFields.remove( tr("First Name") ); | 890 | slOrderedFields.remove( tr("Last Name") ); |
872 | slOrderedFields.remove( tr("Last Name") ); | 891 | slOrderedFields.remove( tr("File As") ); |
873 | slOrderedFields.remove( tr("File As") ); | 892 | slOrderedFields.remove( tr("Default Email") ); |
874 | slOrderedFields.remove( tr("Default Email") ); | 893 | slOrderedFields.remove( tr("Notes") ); |
875 | slOrderedFields.remove( tr("Notes") ); | 894 | slOrderedFields.remove( tr("Gender") ); |
876 | slOrderedFields.remove( tr("Gender") ); | 895 | |
877 | 896 | } | |
878 | } | ||
879 | } | 897 | } |
880 | 898 | ||
881 | 899 | ||
882 | AbLabel *AddressbookWindow::abView() | 900 | AbLabel *AddressbookWindow::abView() |
883 | { | 901 | { |
884 | if ( !mView ) { | 902 | if ( !mView ) { |
885 | mView = new AbLabel( this, "viewer" ); | 903 | mView = new AbLabel( this, "viewer" ); |
886 | mView->init( Contact() ); | 904 | mView->init( OContact() ); |
887 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 905 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
888 | } | 906 | } |
889 | return mView; | 907 | return mView; |
890 | } | 908 | } |
891 | 909 | ||
892 | void AddressbookWindow::slotFind() | 910 | void AddressbookWindow::slotFind() |
893 | { | 911 | { |
894 | #ifndef MAKE_FOR_SHARP_ROM | 912 | #ifndef MAKE_FOR_SHARP_ROM |
895 | if ( centralWidget() == abView() ) | 913 | if ( centralWidget() == abView() ) |
896 | showList(); | 914 | showList(); |
897 | 915 | ||
898 | FindDialog frmFind( "Contacts", this ); | 916 | FindDialog frmFind( "Contacts", this ); |
899 | QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); | 917 | QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); |
900 | QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); | 918 | QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); |
901 | QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); | 919 | QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); |
902 | 920 | ||
903 | frmFind.exec(); | 921 | frmFind.exec(); |
904 | 922 | ||
905 | if ( abList->numSelections() ) | 923 | if ( abList->numSelections() ) |
906 | abList->clearSelection(); | 924 | abList->clearSelection(); |
907 | 925 | ||
908 | abList->clearFindRow(); | 926 | abList->clearFindRow(); |
909 | #endif | 927 | #endif |
910 | } | 928 | } |
911 | 929 | ||
912 | void AddressbookWindow::slotSetCategory( int c ) | 930 | void AddressbookWindow::slotSetCategory( int c ) |
913 | { | 931 | { |
914 | if ( c <= 0 ) | 932 | |
915 | return; | 933 | QString cat, book; |
916 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 934 | |
917 | catMenu->setItemChecked( i, c == (int)i ); | 935 | if ( c <= 0 ) |
918 | if ( c == 1 ) { | 936 | return; |
919 | abList->setShowCategory( QString::null ); | 937 | |
920 | setCaption( tr("Contacts") + " - " + tr ( "All" ) ); | 938 | // Checkmark Book Menu Item Selected |
921 | } else if ( c == (int)catMenu->count() ) { | 939 | if ( c < 6 ) |
922 | abList->setShowCategory( tr( "Unfiled" ) ); | 940 | for ( unsigned int i = 1; i < 6; i++ ) |
923 | setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); | 941 | catMenu->setItemChecked( i, c == (int)i ); |
924 | } else { | 942 | |
925 | QString cat = abList->categories()[c - 2]; | 943 | // Checkmark Category Menu Item Selected |
926 | abList->setShowCategory( cat ); | 944 | else |
927 | setCaption( tr("Contacts") + " - " + cat ); | 945 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) |
928 | } | 946 | catMenu->setItemChecked( i, c == (int)i ); |
947 | |||
948 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | ||
949 | if (catMenu->isItemChecked( i )) { | ||
950 | if ( i == 1 ) // default List view | ||
951 | book = QString::null; | ||
952 | else if ( i == 2 ) | ||
953 | book = "Phone"; | ||
954 | else if ( i == 3 ) | ||
955 | book = "Company"; | ||
956 | else if ( i == 4 ) | ||
957 | book = "Email"; | ||
958 | else if ( i == 5 ) | ||
959 | book = "Cards"; | ||
960 | else if ( i == 6 ) // default All Categories | ||
961 | cat = QString::null; | ||
962 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | ||
963 | cat = "Unfiled"; | ||
964 | else | ||
965 | cat = abList->categories()[i - 7]; | ||
966 | } | ||
967 | } | ||
968 | |||
969 | abList->setShowCategory( book, cat ); | ||
970 | |||
971 | if ( book.isEmpty() ) | ||
972 | book = "List"; | ||
973 | if ( cat.isEmpty() ) | ||
974 | cat = "All"; | ||
975 | |||
976 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | ||
929 | } | 977 | } |
930 | 978 | ||
931 | void AddressbookWindow::slotSetLetter( char c ) { | 979 | void AddressbookWindow::slotSetLetter( char c ) { |
932 | 980 | ||
933 | abList->setShowByLetter( c ); | 981 | abList->setShowByLetter( c ); |
934 | 982 | ||
935 | } | 983 | } |
936 | 984 | ||
937 | void AddressbookWindow::populateCategories() | 985 | void AddressbookWindow::populateCategories() |
938 | { | 986 | { |
939 | catMenu->clear(); | 987 | catMenu->clear(); |
940 | 988 | ||
941 | int id, | 989 | int id, rememberId; |
942 | rememberId; | 990 | id = 1; |
943 | id = 1; | 991 | rememberId = 0; |
944 | rememberId = 0; | 992 | |
945 | catMenu->insertItem( tr( "All" ), id++ ); | 993 | catMenu->insertItem( tr( "List" ), id++ ); |
946 | QStringList categories = abList->categories(); | 994 | catMenu->insertItem( tr( "Phone Book" ), id++ ); |
947 | categories.append( tr( "Unfiled" ) ); | 995 | catMenu->insertItem( tr( "Company Book" ), id++ ); |
948 | for ( QStringList::Iterator it = categories.begin(); | 996 | catMenu->insertItem( tr( "Email Book" ), id++ ); |
949 | it != categories.end(); ++it ) { | 997 | catMenu->insertItem( tr( "Cards" ), id++ ); |
950 | catMenu->insertItem( *it, id ); | 998 | catMenu->insertSeparator(); |
951 | if ( *it == abList->showCategory() ) | 999 | |
952 | rememberId = id; | 1000 | catMenu->insertItem( tr( "All" ), id++ ); |
953 | ++id; | 1001 | QStringList categories = abList->categories(); |
954 | } | 1002 | categories.append( tr( "Unfiled" ) ); |
955 | if ( abList->showCategory().isEmpty() ) | 1003 | for ( QStringList::Iterator it = categories.begin(); |
956 | slotSetCategory( 1 ); | 1004 | it != categories.end(); ++it ) { |
957 | else | 1005 | catMenu->insertItem( *it, id ); |
958 | slotSetCategory( rememberId ); | 1006 | if ( *it == abList->showCategory() ) |
1007 | rememberId = id; | ||
1008 | ++id; | ||
1009 | } | ||
1010 | |||
1011 | if ( abList->showBook().isEmpty() ) { | ||
1012 | catMenu->setItemChecked( 1, true ); | ||
1013 | } else if ( abList->showBook() == "Phone" ) { | ||
1014 | catMenu->setItemChecked( 2, true ); | ||
1015 | } else if ( abList->showBook() == "Company" ) { | ||
1016 | catMenu->setItemChecked( 3, true ); | ||
1017 | } else if ( abList->showBook() == "Email" ) { | ||
1018 | catMenu->setItemChecked( 4, true ); | ||
1019 | } else if ( abList->showBook() == "Cards" ) { | ||
1020 | catMenu->setItemChecked( 5, true ); | ||
1021 | } | ||
1022 | |||
1023 | if ( abList->showCategory().isEmpty() ) { | ||
1024 | slotSetCategory( 6 ); | ||
1025 | } | ||
1026 | else { | ||
1027 | slotSetCategory( rememberId ); | ||
1028 | } | ||
959 | } | 1029 | } |
1030 | |||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 34ca85d..bf36407 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,108 +1,109 @@ | |||
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 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qvaluelist.h> | 24 | #include <qvaluelist.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | 26 | ||
27 | class ContactEditor; | 27 | class ContactEditor; |
28 | class AbLabel; | 28 | class AbLabel; |
29 | class AbTable; | 29 | class AbTable; |
30 | class QPEToolBar; | 30 | class QPEToolBar; |
31 | class QPopupMenu; | 31 | class QPopupMenu; |
32 | class QToolButton; | 32 | class QToolButton; |
33 | class QDialog; | 33 | class QDialog; |
34 | class Ir; | 34 | class Ir; |
35 | class QAction; | 35 | class QAction; |
36 | class LetterPicker; | 36 | class LetterPicker; |
37 | 37 | ||
38 | class AddressbookWindow: public QMainWindow | 38 | class AddressbookWindow: public QMainWindow |
39 | { | 39 | { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | public: | 41 | public: |
42 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 42 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
43 | ~AddressbookWindow(); | 43 | ~AddressbookWindow(); |
44 | 44 | ||
45 | protected: | 45 | protected: |
46 | void resizeEvent( QResizeEvent * e ); | 46 | void resizeEvent( QResizeEvent * e ); |
47 | void showList(); | 47 | void showList(); |
48 | void showView(); | 48 | void showView(); |
49 | enum EntryMode { NewEntry=0, EditEntry }; | 49 | enum EntryMode { NewEntry=0, EditEntry }; |
50 | void editPersonal(); | 50 | void editPersonal(); |
51 | void editEntry( EntryMode ); | 51 | void editEntry( EntryMode ); |
52 | void closeEvent( QCloseEvent *e ); | 52 | void closeEvent( QCloseEvent *e ); |
53 | bool save(); | 53 | bool save(); |
54 | 54 | ||
55 | public slots: | 55 | public slots: |
56 | void flush(); | 56 | void flush(); |
57 | void reload(); | 57 | void reload(); |
58 | void appMessage(const QCString &, const QByteArray &); | 58 | void appMessage(const QCString &, const QByteArray &); |
59 | void setDocument( const QString & ); | 59 | void setDocument( const QString & ); |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | void importvCard(); | 62 | void importvCard(); |
63 | void slotListNew(); | 63 | void slotListNew(); |
64 | void slotListView(); | 64 | void slotListView(); |
65 | void slotListDelete(); | 65 | void slotListDelete(); |
66 | void slotViewBack(); | 66 | void slotViewBack(); |
67 | void slotViewEdit(); | 67 | void slotViewEdit(); |
68 | void slotPersonalView(); | 68 | void slotPersonalView(); |
69 | void listIsEmpty( bool ); | 69 | void listIsEmpty( bool ); |
70 | void slotSettings(); | 70 | void slotSettings(); |
71 | void writeMail(); | 71 | void writeMail(); |
72 | void slotBeam(); | 72 | void slotBeam(); |
73 | void beamDone( Ir * ); | 73 | void beamDone( Ir * ); |
74 | void slotFind(); | 74 | void slotFind(); |
75 | void slotSetCategory( int ); | 75 | void slotSetCategory( int ); |
76 | void slotSetLetter( char ); | 76 | void slotSetLetter( char ); |
77 | void slotUpdateToolbar(); | 77 | void slotUpdateToolbar(); |
78 | void slotSetFont(int); | 78 | void slotSetFont(int); |
79 | |||
79 | private: | 80 | private: |
80 | void initFields(); // inititialize our fields... | 81 | void initFields(); // inititialize our fields... |
81 | AbLabel *abView(); | 82 | AbLabel *abView(); |
82 | void populateCategories(); | 83 | void populateCategories(); |
84 | |||
85 | QPopupMenu *catMenu, *fontMenu; | ||
86 | QPEToolBar *listTools; | ||
87 | QToolButton *deleteButton; | ||
88 | QValueList<int> allFields, orderedFields; | ||
89 | QStringList slOrderedFields; | ||
90 | enum Panes { paneList=0, paneView, paneEdit }; | ||
91 | ContactEditor *abEditor; | ||
92 | AbLabel *mView; | ||
93 | LetterPicker *pLabel; | ||
94 | AbTable *abList; | ||
95 | QWidget *listContainer; | ||
83 | 96 | ||
84 | QPopupMenu *catMenu, *fontMenu; | 97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
85 | QPEToolBar *listTools; | ||
86 | QToolButton *deleteButton; | ||
87 | QValueList<int> allFields, | ||
88 | orderedFields; | ||
89 | QStringList slOrderedFields; | ||
90 | enum Panes { paneList=0, paneView, paneEdit }; | ||
91 | ContactEditor *abEditor; | ||
92 | AbLabel *mView; | ||
93 | LetterPicker *pLabel; | ||
94 | AbTable *abList; | ||
95 | QWidget *listContainer; | ||
96 | 98 | ||
97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, | 99 | bool bAbEditFirstTime; |
98 | *actionPersonal, *actionMail; | 100 | int viewMargin; |
99 | 101 | ||
100 | bool bAbEditFirstTime; | 102 | bool syncing; |
101 | int viewMargin; | 103 | QFont *defaultFont; |
104 | int startFontSize; | ||
102 | 105 | ||
103 | bool syncing; | 106 | bool isLoading; |
104 | QFont *defaultFont; | ||
105 | int startFontSize; | ||
106 | }; | 107 | }; |
107 | 108 | ||
108 | #endif | 109 | #endif |
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index ae86ed0..fd7f009 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,180 +1,180 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | 2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> |
3 | * | 3 | * |
4 | * This file is an add-on for the OPIE Palmtop Environment | 4 | * This file is an add-on for the OPIE 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 pacakaging | 8 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging |
9 | * of this file. | 9 | * 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 | * This is a rewrite of the abeditor.h file, modified to provide a more | 15 | * This is a rewrite of the abeditor.h file, modified to provide a more |
16 | * intuitive interface to TrollTech's original Address Book editor. This | 16 | * intuitive interface to TrollTech's original Address Book editor. This |
17 | * is made to operate exactly in interface with the exception of name. | 17 | * is made to operate exactly in interface with the exception of name. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "contacteditor.h" | 21 | #include "contacteditor.h" |
22 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
23 | 23 | ||
24 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qscrollview.h> | 34 | #include <qscrollview.h> |
35 | #include <qtoolbutton.h> | 35 | #include <qtoolbutton.h> |
36 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qvaluelist.h> | 38 | #include <qvaluelist.h> |
39 | 39 | ||
40 | static inline bool containsAlphaNum( const QString &str ); | 40 | static inline bool containsAlphaNum( const QString &str ); |
41 | static inline bool constainsWhiteSpace( const QString &str ); | 41 | static inline bool constainsWhiteSpace( const QString &str ); |
42 | 42 | ||
43 | // helper functions, convert our comma delimited list to proper | 43 | // helper functions, convert our comma delimited list to proper |
44 | // file format... | 44 | // file format... |
45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
46 | QString &strAll ); | 46 | QString &strAll ); |
47 | 47 | ||
48 | // helper convert from file format to comma delimited... | 48 | // helper convert from file format to comma delimited... |
49 | void parseEmailTo( const QString &strDefaultEmail, | 49 | void parseEmailTo( const QString &strDefaultEmail, |
50 | const QString &strOtherEmail, QString &strBack ); | 50 | const QString &strOtherEmail, QString &strBack ); |
51 | 51 | ||
52 | ContactEditor::ContactEditor(const Contact &entry, | 52 | ContactEditor::ContactEditor(const OContact &entry, |
53 | const QValueList<int> *newOrderedValues, | 53 | const QValueList<int> *newOrderedValues, |
54 | QStringList *slNewOrdered, | 54 | QStringList *slNewOrdered, |
55 | QWidget *parent, | 55 | QWidget *parent, |
56 | const char *name, | 56 | const char *name, |
57 | WFlags fl ) | 57 | WFlags fl ) |
58 | : QDialog( parent, name, TRUE, fl ), | 58 | : QDialog( parent, name, TRUE, fl ), |
59 | orderedValues( newOrderedValues ), | 59 | orderedValues( newOrderedValues ), |
60 | slOrdered( *slNewOrdered ) | 60 | slOrdered( *slNewOrdered ) |
61 | { | 61 | { |
62 | 62 | ||
63 | init(); | 63 | init(); |
64 | initMap(); | 64 | initMap(); |
65 | setEntry( entry ); | 65 | setEntry( entry ); |
66 | qDebug("finish"); | 66 | qDebug("finish"); |
67 | } | 67 | } |
68 | 68 | ||
69 | ContactEditor::~ContactEditor() { | 69 | ContactEditor::~ContactEditor() { |
70 | } | 70 | } |
71 | 71 | ||
72 | void ContactEditor::init() { | 72 | void ContactEditor::init() { |
73 | 73 | ||
74 | useFullName = TRUE; | 74 | useFullName = TRUE; |
75 | 75 | ||
76 | int i = 0; | 76 | int i = 0; |
77 | /** SHut up and stop leaking | 77 | /** SHut up and stop leaking |
78 | slHomeAddress = new QStringList; | 78 | slHomeAddress = new QStringList; |
79 | slBusinessAddress = new QStringList; | 79 | slBusinessAddress = new QStringList; |
80 | slChooserNames = new QStringList; | 80 | slChooserNames = new QStringList; |
81 | slChooserValues = new QStringList; | 81 | slChooserValues = new QStringList; |
82 | 82 | ||
83 | slDynamicEntries = new QStringList; | 83 | slDynamicEntries = new QStringList; |
84 | */ | 84 | */ |
85 | //*slDynamicEntries = *slOrdered; | 85 | //*slDynamicEntries = *slOrdered; |
86 | 86 | ||
87 | for (i = 0; i <= 6; i++) { | 87 | for (i = 0; i <= 6; i++) { |
88 | slHomeAddress.append( "" ); | 88 | slHomeAddress.append( "" ); |
89 | slBusinessAddress.append( "" ); | 89 | slBusinessAddress.append( "" ); |
90 | } | 90 | } |
91 | 91 | ||
92 | { | 92 | { |
93 | hasGender = FALSE; | 93 | hasGender = FALSE; |
94 | hasTitle = FALSE; | 94 | hasTitle = FALSE; |
95 | hasCompany = FALSE; | 95 | hasCompany = FALSE; |
96 | hasNotes = FALSE; | 96 | hasNotes = FALSE; |
97 | hasStreet = FALSE; | 97 | hasStreet = FALSE; |
98 | hasStreet2 = FALSE; | 98 | hasStreet2 = FALSE; |
99 | hasPOBox = FALSE; | 99 | hasPOBox = FALSE; |
100 | hasCity = FALSE; | 100 | hasCity = FALSE; |
101 | hasState = FALSE; | 101 | hasState = FALSE; |
102 | hasZip = FALSE; | 102 | hasZip = FALSE; |
103 | hasCountry = FALSE; | 103 | hasCountry = FALSE; |
104 | 104 | ||
105 | QStringList::ConstIterator it = slOrdered.begin(); | 105 | QStringList::ConstIterator it = slOrdered.begin(); |
106 | for ( i = 0; it != slOrdered.end(); i++, ++it ) { | 106 | for ( i = 0; it != slOrdered.end(); i++, ++it ) { |
107 | 107 | ||
108 | if ( (*it) == tr( "Business Fax" ) ) { | 108 | if ( (*it) == tr( "Business Fax" ) ) { |
109 | slChooserNames.append( *it ); | 109 | slChooserNames.append( *it ); |
110 | slChooserValues.append("" ); | 110 | slChooserValues.append("" ); |
111 | //slDynamicEntries->remove( it ); | 111 | //slDynamicEntries->remove( it ); |
112 | continue; | 112 | continue; |
113 | } | 113 | } |
114 | 114 | ||
115 | if ( (*it) == tr( "Home Fax" ) ) { | 115 | if ( (*it) == tr( "Home Fax" ) ) { |
116 | slChooserNames.append( *it ); | 116 | slChooserNames.append( *it ); |
117 | slChooserValues.append("" ); | 117 | slChooserValues.append("" ); |
118 | //slDynamicEntries->remove( it ); | 118 | //slDynamicEntries->remove( it ); |
119 | continue; | 119 | continue; |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | if ( (*it) == tr( "Business Phone" ) ) { | 123 | if ( (*it) == tr( "Business Phone" ) ) { |
124 | slChooserNames.append( *it ); | 124 | slChooserNames.append( *it ); |
125 | slChooserValues.append( "" ); | 125 | slChooserValues.append( "" ); |
126 | //slDynamicEntries->remove( it ); | 126 | //slDynamicEntries->remove( it ); |
127 | continue; | 127 | continue; |
128 | } | 128 | } |
129 | 129 | ||
130 | if ( (*it) == tr( "Home Phone" ) ) { | 130 | if ( (*it) == tr( "Home Phone" ) ) { |
131 | slChooserNames.append( *it ); | 131 | slChooserNames.append( *it ); |
132 | slChooserValues.append( "" ); | 132 | slChooserValues.append( "" ); |
133 | //slDynamicEntries->remove( it ); | 133 | //slDynamicEntries->remove( it ); |
134 | continue; | 134 | continue; |
135 | } | 135 | } |
136 | 136 | ||
137 | /* | 137 | /* |
138 | if ( (*it).right( 2 ) == tr( "IM" ) ) { | 138 | if ( (*it).right( 2 ) == tr( "IM" ) ) { |
139 | slChooserNames.append( *it ); | 139 | slChooserNames.append( *it ); |
140 | slChooserValues.append( "" ); | 140 | slChooserValues.append( "" ); |
141 | //slDynamicEntries->remove( it ); | 141 | //slDynamicEntries->remove( it ); |
142 | continue; | 142 | continue; |
143 | } */ | 143 | } */ |
144 | 144 | ||
145 | if ( (*it) == tr( "Business Mobile" ) ) { | 145 | if ( (*it) == tr( "Business Mobile" ) ) { |
146 | slChooserNames.append( *it ); | 146 | slChooserNames.append( *it ); |
147 | slChooserValues.append( "" ); | 147 | slChooserValues.append( "" ); |
148 | //slDynamicEntries->remove( it ); | 148 | //slDynamicEntries->remove( it ); |
149 | continue; | 149 | continue; |
150 | } | 150 | } |
151 | 151 | ||
152 | if ( (*it) == tr( "Home Mobile" ) ) { | 152 | if ( (*it) == tr( "Home Mobile" ) ) { |
153 | slChooserNames.append( *it ); | 153 | slChooserNames.append( *it ); |
154 | slChooserValues.append( "" ); | 154 | slChooserValues.append( "" ); |
155 | //slDynamicEntries->remove( it ); | 155 | //slDynamicEntries->remove( it ); |
156 | continue; | 156 | continue; |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | if ( (*it) == tr( "Business WebPage" ) ) { | 160 | if ( (*it) == tr( "Business WebPage" ) ) { |
161 | slChooserNames.append( *it ); | 161 | slChooserNames.append( *it ); |
162 | slChooserValues.append( "" ); | 162 | slChooserValues.append( "" ); |
163 | //slDynamicEntries->remove( it ); | 163 | //slDynamicEntries->remove( it ); |
164 | continue; | 164 | continue; |
165 | } | 165 | } |
166 | 166 | ||
167 | if ( (*it) == tr( "Home Web Page" ) ) { | 167 | if ( (*it) == tr( "Home Web Page" ) ) { |
168 | slChooserNames.append( *it ); | 168 | slChooserNames.append( *it ); |
169 | slChooserValues.append( "" ); | 169 | slChooserValues.append( "" ); |
170 | //slDynamicEntries->remove( it ); | 170 | //slDynamicEntries->remove( it ); |
171 | continue; | 171 | continue; |
172 | } | 172 | } |
173 | 173 | ||
174 | if ( (*it) == tr( "Business Pager" ) ) { | 174 | if ( (*it) == tr( "Business Pager" ) ) { |
175 | slChooserNames.append( *it ); | 175 | slChooserNames.append( *it ); |
176 | slChooserValues.append( "" ); | 176 | slChooserValues.append( "" ); |
177 | //slDynamicEntries->remove( it ); | 177 | //slDynamicEntries->remove( it ); |
178 | continue; | 178 | continue; |
179 | } | 179 | } |
180 | 180 | ||
@@ -1167,257 +1167,257 @@ QString ContactEditor::parseName( const QString fullName, int type ) { | |||
1167 | } | 1167 | } |
1168 | if (txtSuffix->text() != "") { | 1168 | if (txtSuffix->text() != "") { |
1169 | strSuffix = simplifiedName; | 1169 | strSuffix = simplifiedName; |
1170 | break; | 1170 | break; |
1171 | } | 1171 | } |
1172 | strFirstName = simplifiedName; | 1172 | strFirstName = simplifiedName; |
1173 | break; | 1173 | break; |
1174 | 1174 | ||
1175 | case 1: | 1175 | case 1: |
1176 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1176 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1177 | strLastName = simplifiedName.left( spPos ); | 1177 | strLastName = simplifiedName.left( spPos ); |
1178 | strFirstName = simplifiedName.mid( spPos + 1 ); | 1178 | strFirstName = simplifiedName.mid( spPos + 1 ); |
1179 | break; | 1179 | break; |
1180 | 1180 | ||
1181 | case 2: | 1181 | case 2: |
1182 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1182 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1183 | strLastName = simplifiedName.left( spPos ); | 1183 | strLastName = simplifiedName.left( spPos ); |
1184 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1184 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1185 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1185 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1186 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); | 1186 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); |
1187 | break; | 1187 | break; |
1188 | 1188 | ||
1189 | case 3: | 1189 | case 3: |
1190 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1190 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1191 | strLastName = simplifiedName.left( spPos ); | 1191 | strLastName = simplifiedName.left( spPos ); |
1192 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1192 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1193 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1193 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1194 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1194 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1195 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1195 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1196 | strSuffix = simplifiedName.mid( spPos + 1 ); | 1196 | strSuffix = simplifiedName.mid( spPos + 1 ); |
1197 | break; | 1197 | break; |
1198 | 1198 | ||
1199 | case 4: | 1199 | case 4: |
1200 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1200 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1201 | strLastName = simplifiedName.left( spPos ); | 1201 | strLastName = simplifiedName.left( spPos ); |
1202 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1202 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1203 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1203 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1204 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1204 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1205 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); | 1205 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); |
1206 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1206 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1207 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1207 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1208 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1208 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1209 | break; | 1209 | break; |
1210 | 1210 | ||
1211 | default: | 1211 | default: |
1212 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 1212 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
1213 | strLastName = simplifiedName.left( spPos ); | 1213 | strLastName = simplifiedName.left( spPos ); |
1214 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1214 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1215 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1215 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1216 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 1216 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
1217 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 1217 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
1218 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 1218 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
1219 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 1219 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
1220 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 1220 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
1221 | break; | 1221 | break; |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | switch (type) { | 1224 | switch (type) { |
1225 | case NAME_FL: | 1225 | case NAME_FL: |
1226 | return strFirstName + " " + strLastName; | 1226 | return strFirstName + " " + strLastName; |
1227 | 1227 | ||
1228 | case NAME_LF: | 1228 | case NAME_LF: |
1229 | return strLastName + ", " + strFirstName; | 1229 | return strLastName + ", " + strFirstName; |
1230 | 1230 | ||
1231 | case NAME_LFM: | 1231 | case NAME_LFM: |
1232 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 1232 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
1233 | 1233 | ||
1234 | case NAME_FMLS: | 1234 | case NAME_FMLS: |
1235 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; | 1235 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; |
1236 | 1236 | ||
1237 | case NAME_F: | 1237 | case NAME_F: |
1238 | return strFirstName; | 1238 | return strFirstName; |
1239 | 1239 | ||
1240 | case NAME_M: | 1240 | case NAME_M: |
1241 | return strMiddleName; | 1241 | return strMiddleName; |
1242 | 1242 | ||
1243 | case NAME_L: | 1243 | case NAME_L: |
1244 | return strLastName; | 1244 | return strLastName; |
1245 | 1245 | ||
1246 | case NAME_S: | 1246 | case NAME_S: |
1247 | return strSuffix; | 1247 | return strSuffix; |
1248 | 1248 | ||
1249 | } | 1249 | } |
1250 | return QString::null; | 1250 | return QString::null; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | void ContactEditor::cleanupFields() { | 1253 | void ContactEditor::cleanupFields() { |
1254 | 1254 | ||
1255 | QStringList::Iterator it = slChooserValues.begin(); | 1255 | QStringList::Iterator it = slChooserValues.begin(); |
1256 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { | 1256 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { |
1257 | (*it) = ""; | 1257 | (*it) = ""; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | for ( int i = 0; i < 7; i++ ) { | 1260 | for ( int i = 0; i < 7; i++ ) { |
1261 | slHomeAddress[i] = ""; | 1261 | slHomeAddress[i] = ""; |
1262 | slBusinessAddress[i] = ""; | 1262 | slBusinessAddress[i] = ""; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | QStringList::ConstIterator cit; | 1265 | QStringList::ConstIterator cit; |
1266 | QListIterator<QLineEdit> itLE( listValue ); | 1266 | QListIterator<QLineEdit> itLE( listValue ); |
1267 | for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { | 1267 | for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { |
1268 | (*itLE)->setText( "" ); | 1268 | (*itLE)->setText( "" ); |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | txtFirstName->setText(""); | 1271 | txtFirstName->setText(""); |
1272 | txtMiddleName->setText(""); | 1272 | txtMiddleName->setText(""); |
1273 | txtLastName->setText(""); | 1273 | txtLastName->setText(""); |
1274 | txtSuffix->setText(""); | 1274 | txtSuffix->setText(""); |
1275 | txtNote->setText(""); | 1275 | txtNote->setText(""); |
1276 | txtFullName->setText(""); | 1276 | txtFullName->setText(""); |
1277 | txtJobTitle->setText(""); | 1277 | txtJobTitle->setText(""); |
1278 | txtOrganization->setText(""); | 1278 | txtOrganization->setText(""); |
1279 | txtChooserField1->setText(""); | 1279 | txtChooserField1->setText(""); |
1280 | txtChooserField2->setText(""); | 1280 | txtChooserField2->setText(""); |
1281 | txtChooserField3->setText(""); | 1281 | txtChooserField3->setText(""); |
1282 | txtAddress->setText(""); | 1282 | txtAddress->setText(""); |
1283 | //txtAddress2->setText(""); | 1283 | //txtAddress2->setText(""); |
1284 | txtCity->setText(""); | 1284 | txtCity->setText(""); |
1285 | //txtPOBox->setText(""); | 1285 | //txtPOBox->setText(""); |
1286 | txtState->setText(""); | 1286 | txtState->setText(""); |
1287 | txtZip->setText(""); | 1287 | txtZip->setText(""); |
1288 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1288 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1289 | txtTmp->setText(""); | 1289 | txtTmp->setText(""); |
1290 | txtTmp = cmbFileAs->lineEdit(); | 1290 | txtTmp = cmbFileAs->lineEdit(); |
1291 | txtTmp->setText(""); | 1291 | txtTmp->setText(""); |
1292 | 1292 | ||
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void ContactEditor::setEntry( const Contact &entry ) { | 1295 | void ContactEditor::setEntry( const OContact &entry ) { |
1296 | 1296 | ||
1297 | cleanupFields(); | 1297 | cleanupFields(); |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | ent = entry; | 1300 | ent = entry; |
1301 | 1301 | ||
1302 | useFullName = FALSE; | 1302 | useFullName = FALSE; |
1303 | txtFirstName->setText( ent.firstName() ); | 1303 | txtFirstName->setText( ent.firstName() ); |
1304 | txtMiddleName->setText( ent.middleName() ); | 1304 | txtMiddleName->setText( ent.middleName() ); |
1305 | txtLastName->setText( ent.lastName() ); | 1305 | txtLastName->setText( ent.lastName() ); |
1306 | txtSuffix->setText( ent.suffix() ); | 1306 | txtSuffix->setText( ent.suffix() ); |
1307 | 1307 | ||
1308 | QString *tmpString = new QString; | 1308 | QString *tmpString = new QString; |
1309 | *tmpString = ent.firstName() + " " + ent.middleName() + | 1309 | *tmpString = ent.firstName() + " " + ent.middleName() + |
1310 | + " " + ent.lastName() + " " + ent.suffix(); | 1310 | + " " + ent.lastName() + " " + ent.suffix(); |
1311 | 1311 | ||
1312 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1312 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1313 | 1313 | ||
1314 | cmbFileAs->setEditText( ent.fileAs() ); | 1314 | cmbFileAs->setEditText( ent.fileAs() ); |
1315 | 1315 | ||
1316 | if (hasTitle) | 1316 | if (hasTitle) |
1317 | txtJobTitle->setText( ent.jobTitle() ); | 1317 | txtJobTitle->setText( ent.jobTitle() ); |
1318 | 1318 | ||
1319 | if (hasCompany) | 1319 | if (hasCompany) |
1320 | txtOrganization->setText( ent.company() ); | 1320 | txtOrganization->setText( ent.company() ); |
1321 | 1321 | ||
1322 | if (hasNotes) | 1322 | if (hasNotes) |
1323 | txtNote->setText( ent.notes() ); | 1323 | txtNote->setText( ent.notes() ); |
1324 | 1324 | ||
1325 | if (hasStreet) { | 1325 | if (hasStreet) { |
1326 | slHomeAddress[0] = ent.homeStreet(); | 1326 | slHomeAddress[0] = ent.homeStreet(); |
1327 | slBusinessAddress[0] = ent.businessStreet(); | 1327 | slBusinessAddress[0] = ent.businessStreet(); |
1328 | } | 1328 | } |
1329 | /* | 1329 | /* |
1330 | if (hasStreet2) { | 1330 | if (hasStreet2) { |
1331 | (*slHomeAddress)[1] = ent.homeStreet2(); | 1331 | (*slHomeAddress)[1] = ent.homeStreet2(); |
1332 | (*slBusinessAddress)[1] = ent.businessStreet2(); | 1332 | (*slBusinessAddress)[1] = ent.businessStreet2(); |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | if (hasPOBox) { | 1335 | if (hasPOBox) { |
1336 | (*slHomeAddress)[2] = ent.homePOBox(); | 1336 | (*slHomeAddress)[2] = ent.homePOBox(); |
1337 | (*slBusinessAddress)[2] = ent.businessPOBox(); | 1337 | (*slBusinessAddress)[2] = ent.businessPOBox(); |
1338 | } | 1338 | } |
1339 | */ | 1339 | */ |
1340 | if (hasCity) { | 1340 | if (hasCity) { |
1341 | slHomeAddress[3] = ent.homeCity(); | 1341 | slHomeAddress[3] = ent.homeCity(); |
1342 | slBusinessAddress[3] = ent.businessCity(); | 1342 | slBusinessAddress[3] = ent.businessCity(); |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | if (hasState) { | 1345 | if (hasState) { |
1346 | slHomeAddress[4] = ent.homeState(); | 1346 | slHomeAddress[4] = ent.homeState(); |
1347 | slBusinessAddress[4] = ent.businessState(); | 1347 | slBusinessAddress[4] = ent.businessState(); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | if (hasZip) { | 1350 | if (hasZip) { |
1351 | slHomeAddress[5] = ent.homeZip(); | 1351 | slHomeAddress[5] = ent.homeZip(); |
1352 | slBusinessAddress[5] = ent.businessZip(); | 1352 | slBusinessAddress[5] = ent.businessZip(); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | if (hasCountry) { | 1355 | if (hasCountry) { |
1356 | slHomeAddress[6] = ent.homeCountry(); | 1356 | slHomeAddress[6] = ent.homeCountry(); |
1357 | slBusinessAddress[6] = ent.businessCountry(); | 1357 | slBusinessAddress[6] = ent.businessCountry(); |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | QStringList::ConstIterator it; | 1360 | QStringList::ConstIterator it; |
1361 | QListIterator<QLineEdit> itLE( listValue ); | 1361 | QListIterator<QLineEdit> itLE( listValue ); |
1362 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { | 1362 | for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { |
1363 | if ( *it == tr("Department") ) | 1363 | if ( *it == tr("Department") ) |
1364 | (*itLE)->setText( ent.department() ); | 1364 | (*itLE)->setText( ent.department() ); |
1365 | 1365 | ||
1366 | if ( *it == tr("Company" )) | 1366 | if ( *it == tr("Company" )) |
1367 | (*itLE)->setText( ent.company() ); | 1367 | (*itLE)->setText( ent.company() ); |
1368 | 1368 | ||
1369 | if ( *it == tr("Office" )) | 1369 | if ( *it == tr("Office" )) |
1370 | (*itLE)->setText( ent.office() ); | 1370 | (*itLE)->setText( ent.office() ); |
1371 | 1371 | ||
1372 | if ( *it == tr("Profession" )) | 1372 | if ( *it == tr("Profession" )) |
1373 | (*itLE)->setText( ent.profession() ); | 1373 | (*itLE)->setText( ent.profession() ); |
1374 | 1374 | ||
1375 | if ( *it == tr("Assistant" )) | 1375 | if ( *it == tr("Assistant" )) |
1376 | (*itLE)->setText( ent.assistant() ); | 1376 | (*itLE)->setText( ent.assistant() ); |
1377 | 1377 | ||
1378 | if ( *it == tr("Manager" )) | 1378 | if ( *it == tr("Manager" )) |
1379 | (*itLE)->setText( ent.manager() ); | 1379 | (*itLE)->setText( ent.manager() ); |
1380 | 1380 | ||
1381 | if ( *it == tr("Spouse" )) | 1381 | if ( *it == tr("Spouse" )) |
1382 | (*itLE)->setText( ent.spouse() ); | 1382 | (*itLE)->setText( ent.spouse() ); |
1383 | 1383 | ||
1384 | if ( *it == tr("Birthday" )) | 1384 | if ( *it == tr("Birthday" )) |
1385 | (*itLE)->setText( ent.birthday() ); | 1385 | (*itLE)->setText( ent.birthday() ); |
1386 | 1386 | ||
1387 | if ( *it == tr("Anniversary" )) | 1387 | if ( *it == tr("Anniversary" )) |
1388 | (*itLE)->setText( ent.anniversary() ); | 1388 | (*itLE)->setText( ent.anniversary() ); |
1389 | 1389 | ||
1390 | if ( *it == tr("Nickname" )) | 1390 | if ( *it == tr("Nickname" )) |
1391 | (*itLE)->setText( ent.nickname() ); | 1391 | (*itLE)->setText( ent.nickname() ); |
1392 | 1392 | ||
1393 | if ( *it == tr("Children" )) | 1393 | if ( *it == tr("Children" )) |
1394 | (*itLE)->setText( ent.children() ); | 1394 | (*itLE)->setText( ent.children() ); |
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | QStringList::Iterator itV; | 1398 | QStringList::Iterator itV; |
1399 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { | 1399 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { |
1400 | 1400 | ||
1401 | if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) | 1401 | if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) |
1402 | *itV = ent.businessPhone(); | 1402 | *itV = ent.businessPhone(); |
1403 | /* | 1403 | /* |
1404 | if ( *it == "Business 2 Phone" ) | 1404 | if ( *it == "Business 2 Phone" ) |
1405 | *itV = ent.business2Phone(); | 1405 | *itV = ent.business2Phone(); |
1406 | */ | 1406 | */ |
1407 | if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) | 1407 | if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) |
1408 | *itV = ent.businessFax(); | 1408 | *itV = ent.businessFax(); |
1409 | 1409 | ||
1410 | if ( *it == tr("Business Mobile") || *it == tr("work Mobile" )) | 1410 | if ( *it == tr("Business Mobile") || *it == tr("work Mobile" )) |
1411 | *itV = ent.businessMobile(); | 1411 | *itV = ent.businessMobile(); |
1412 | /* | 1412 | /* |
1413 | if ( *it == "Company Phone" ) | 1413 | if ( *it == "Company Phone" ) |
1414 | *itV = ent.companyPhone(); | 1414 | *itV = ent.companyPhone(); |
1415 | */ | 1415 | */ |
1416 | if ( *it == tr("Default Email" )) | 1416 | if ( *it == tr("Default Email" )) |
1417 | *itV = ent.defaultEmail(); | 1417 | *itV = ent.defaultEmail(); |
1418 | 1418 | ||
1419 | if ( *it == tr("Emails" )) | 1419 | if ( *it == tr("Emails" )) |
1420 | *itV = ent.emailList().join(";"); | 1420 | *itV = ent.emailList().join(";"); |
1421 | 1421 | ||
1422 | if ( *it == tr("Home Phone" )) | 1422 | if ( *it == tr("Home Phone" )) |
1423 | *itV = ent.homePhone(); | 1423 | *itV = ent.homePhone(); |
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 4f3b56e..8ed8553 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h | |||
@@ -1,162 +1,162 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | 2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> |
3 | * | 3 | * |
4 | * This file is an add-on for the OPIE Palmtop Environment | 4 | * This file is an add-on for the OPIE 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 pacakaging | 8 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging |
9 | * of this file. | 9 | * 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 | * This is a rewrite of the abeditor.h file, modified to provide a more | 15 | * This is a rewrite of the abeditor.h file, modified to provide a more |
16 | * intuitive interface to TrollTech's original Address Book editor. This | 16 | * intuitive interface to TrollTech's original Address Book editor. This |
17 | * is made to operate exactly in interface with the exception of name. | 17 | * is made to operate exactly in interface with the exception of name. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef CONTACTEDITOR_H | 21 | #ifndef CONTACTEDITOR_H |
22 | #define CONTACTEDITOR_H | 22 | #define CONTACTEDITOR_H |
23 | 23 | ||
24 | #include <qpe/contact.h> | 24 | #include <opie/ocontact.h> |
25 | 25 | ||
26 | #include <qdialog.h> | 26 | #include <qdialog.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | 30 | ||
31 | const int NAME_LF = 0; | 31 | const int NAME_LF = 0; |
32 | const int NAME_LFM = 1; | 32 | const int NAME_LFM = 1; |
33 | const int NAME_FL = 2; | 33 | const int NAME_FL = 2; |
34 | const int NAME_FMLS = 3; | 34 | const int NAME_FMLS = 3; |
35 | 35 | ||
36 | const int NAME_F = 4; | 36 | const int NAME_F = 4; |
37 | const int NAME_M = 5; | 37 | const int NAME_M = 5; |
38 | const int NAME_L = 6; | 38 | const int NAME_L = 6; |
39 | const int NAME_S = 7; | 39 | const int NAME_S = 7; |
40 | 40 | ||
41 | 41 | ||
42 | class QScrollView; | 42 | class QScrollView; |
43 | class QTabWidget; | 43 | class QTabWidget; |
44 | class QMultiLineEdit; | 44 | class QMultiLineEdit; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QComboBox; | 46 | class QComboBox; |
47 | class QPushButton; | 47 | class QPushButton; |
48 | class CategorySelect; | 48 | class CategorySelect; |
49 | class QLabel; | 49 | class QLabel; |
50 | 50 | ||
51 | class ContactEditor : public QDialog { | 51 | class ContactEditor : public QDialog { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | ContactEditor(const Contact &entry, | 55 | ContactEditor(const OContact &entry, |
56 | const QValueList<int> *newOrderedValues, | 56 | const QValueList<int> *newOrderedValues, |
57 | QStringList *slNewOrdered, | 57 | QStringList *slNewOrdered, |
58 | QWidget *parent = 0, | 58 | QWidget *parent = 0, |
59 | const char *name = 0, | 59 | const char *name = 0, |
60 | WFlags fl = 0 ); | 60 | WFlags fl = 0 ); |
61 | ~ContactEditor(); | 61 | ~ContactEditor(); |
62 | void loadFields(); | 62 | void loadFields(); |
63 | void setNameFocus(); | 63 | void setNameFocus(); |
64 | Contact entry() const { return ent; } | 64 | OContact entry() const { return ent; } |
65 | 65 | ||
66 | public slots: | 66 | public slots: |
67 | void slotNote(); | 67 | void slotNote(); |
68 | void slotName(); | 68 | void slotName(); |
69 | void setEntry(const Contact &entry); | 69 | void setEntry(const OContact &entry); |
70 | 70 | ||
71 | protected slots: | 71 | protected slots: |
72 | void accept(); | 72 | void accept(); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | void init(); | 75 | void init(); |
76 | void initMap(); | 76 | void initMap(); |
77 | void saveEntry(); | 77 | void saveEntry(); |
78 | bool isEmpty(); | 78 | bool isEmpty(); |
79 | void cleanupFields(); | 79 | void cleanupFields(); |
80 | QString parseName( QString fullName, int type ); | 80 | QString parseName( QString fullName, int type ); |
81 | 81 | ||
82 | private slots: | 82 | private slots: |
83 | void slotChooser1Change( const QString &textChanged ); | 83 | void slotChooser1Change( const QString &textChanged ); |
84 | void slotChooser2Change( const QString &textChanged ); | 84 | void slotChooser2Change( const QString &textChanged ); |
85 | void slotChooser3Change( const QString &textChanged ); | 85 | void slotChooser3Change( const QString &textChanged ); |
86 | void slotChooser4Change( const QString &textChanged ); | 86 | void slotChooser4Change( const QString &textChanged ); |
87 | void slotCmbChooser1Change( int index ); | 87 | void slotCmbChooser1Change( int index ); |
88 | void slotCmbChooser2Change( int index ); | 88 | void slotCmbChooser2Change( int index ); |
89 | void slotCmbChooser3Change( int index ); | 89 | void slotCmbChooser3Change( int index ); |
90 | void slotCmbChooser4Change( int index ); | 90 | void slotCmbChooser4Change( int index ); |
91 | void slotAddressTypeChange( int index ); | 91 | void slotAddressTypeChange( int index ); |
92 | void slotAddressChange( const QString &textChanged ); | 92 | void slotAddressChange( const QString &textChanged ); |
93 | void slotAddress2Change( const QString &textChanged ); | 93 | void slotAddress2Change( const QString &textChanged ); |
94 | void slotPOBoxChange( const QString &textChanged ); | 94 | void slotPOBoxChange( const QString &textChanged ); |
95 | void slotCityChange( const QString &textChanged ); | 95 | void slotCityChange( const QString &textChanged ); |
96 | void slotStateChange( const QString &textChanged ); | 96 | void slotStateChange( const QString &textChanged ); |
97 | void slotZipChange( const QString &textChanged ); | 97 | void slotZipChange( const QString &textChanged ); |
98 | void slotCountryChange( const QString &textChanged ); | 98 | void slotCountryChange( const QString &textChanged ); |
99 | void slotFullNameChange( const QString &textChanged ); | 99 | void slotFullNameChange( const QString &textChanged ); |
100 | 100 | ||
101 | private: | 101 | private: |
102 | bool useFullName, hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry; | 102 | bool useFullName, hasGender, hasTitle, hasCompany, hasNotes, hasStreet, hasStreet2, hasPOBox, hasCity, hasState, hasZip, hasCountry; |
103 | 103 | ||
104 | Contact ent; | 104 | OContact ent; |
105 | 105 | ||
106 | QDialog *dlgNote; | 106 | QDialog *dlgNote; |
107 | QDialog *dlgName; | 107 | QDialog *dlgName; |
108 | 108 | ||
109 | QList<QLineEdit> listValue; | 109 | QList<QLineEdit> listValue; |
110 | QList<QLabel> listName; | 110 | QList<QLabel> listName; |
111 | const QValueList<int> *orderedValues; | 111 | const QValueList<int> *orderedValues; |
112 | QStringList slOrdered; | 112 | QStringList slOrdered; |
113 | QStringList slDynamicEntries; | 113 | QStringList slDynamicEntries; |
114 | 114 | ||
115 | QStringList slHomeAddress; | 115 | QStringList slHomeAddress; |
116 | QStringList slBusinessAddress; | 116 | QStringList slBusinessAddress; |
117 | QStringList slChooserNames; | 117 | QStringList slChooserNames; |
118 | QStringList slChooserValues; | 118 | QStringList slChooserValues; |
119 | 119 | ||
120 | QMultiLineEdit *txtNote; | 120 | QMultiLineEdit *txtNote; |
121 | QLabel *lblNote; | 121 | QLabel *lblNote; |
122 | 122 | ||
123 | //QLineEdit *txtTitle; | 123 | //QLineEdit *txtTitle; |
124 | QLineEdit *txtFirstName; | 124 | QLineEdit *txtFirstName; |
125 | QLineEdit *txtMiddleName; | 125 | QLineEdit *txtMiddleName; |
126 | QLineEdit *txtLastName; | 126 | QLineEdit *txtLastName; |
127 | QLineEdit *txtSuffix; | 127 | QLineEdit *txtSuffix; |
128 | 128 | ||
129 | QTabWidget *tabMain; | 129 | QTabWidget *tabMain; |
130 | QScrollView *svGeneral; | 130 | QScrollView *svGeneral; |
131 | QPushButton *btnFullName; | 131 | QPushButton *btnFullName; |
132 | QPushButton *btnNote; | 132 | QPushButton *btnNote; |
133 | QLineEdit *txtFullName; | 133 | QLineEdit *txtFullName; |
134 | QLineEdit *txtJobTitle; | 134 | QLineEdit *txtJobTitle; |
135 | QLineEdit *txtOrganization; | 135 | QLineEdit *txtOrganization; |
136 | QLineEdit *txtChooserField1; | 136 | QLineEdit *txtChooserField1; |
137 | QLineEdit *txtChooserField2; | 137 | QLineEdit *txtChooserField2; |
138 | QLineEdit *txtChooserField3; | 138 | QLineEdit *txtChooserField3; |
139 | QLineEdit *txtChooserField4; | 139 | QLineEdit *txtChooserField4; |
140 | QComboBox *cmbChooserField1; | 140 | QComboBox *cmbChooserField1; |
141 | QComboBox *cmbChooserField2; | 141 | QComboBox *cmbChooserField2; |
142 | QComboBox *cmbChooserField3; | 142 | QComboBox *cmbChooserField3; |
143 | QComboBox *cmbChooserField4; | 143 | QComboBox *cmbChooserField4; |
144 | QComboBox *cmbFileAs; | 144 | QComboBox *cmbFileAs; |
145 | CategorySelect *cmbCat; | 145 | CategorySelect *cmbCat; |
146 | 146 | ||
147 | QScrollView *svAddress; | 147 | QScrollView *svAddress; |
148 | QLineEdit *txtAddress; | 148 | QLineEdit *txtAddress; |
149 | //QLineEdit *txtAddress2; | 149 | //QLineEdit *txtAddress2; |
150 | //QLineEdit *txtPOBox; | 150 | //QLineEdit *txtPOBox; |
151 | QLineEdit *txtCity; | 151 | QLineEdit *txtCity; |
152 | QLineEdit *txtState; | 152 | QLineEdit *txtState; |
153 | QLineEdit *txtZip; | 153 | QLineEdit *txtZip; |
154 | QComboBox *cmbAddress; | 154 | QComboBox *cmbAddress; |
155 | QComboBox *cmbCountry; | 155 | QComboBox *cmbCountry; |
156 | 156 | ||
157 | QScrollView *svDetails; | 157 | QScrollView *svDetails; |
158 | QComboBox *cmbGender; | 158 | QComboBox *cmbGender; |
159 | 159 | ||
160 | }; | 160 | }; |
161 | 161 | ||
162 | #endif | 162 | #endif |