-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index db30d34..c9b0163 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp | |||
@@ -88,19 +88,19 @@ OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name | |||
88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
89 | { | 89 | { |
90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
91 | 91 | ||
92 | #ifndef KAB_EMBEDDED | 92 | #ifndef KAB_EMBEDDED |
93 | QString fileName = KFileDialog::getSaveFileName( name ); | 93 | QString fileName = KFileDialog::getSaveFileName( name ); |
94 | #else //KAB_EMBEDDED | 94 | #else //KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
96 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
97 | 97 | ||
98 | if ( fileName.isEmpty() ) | 98 | if ( fileName.isEmpty() ) |
99 | return true; | 99 | return false; |
100 | 100 | ||
101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
103 | 103 | ||
104 | if ( !access ) { | 104 | if ( !access ) { |
105 | qDebug("Unable to access file() %s", fileName.latin1()); | 105 | qDebug("Unable to access file() %s", fileName.latin1()); |
106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
@@ -108,7 +108,7 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
108 | } | 108 | } |
109 | 109 | ||
110 | KABC::OpieConverter mConverter; | 110 | KABC::OpieConverter mConverter; |
111 | 111 | ||
112 | bool res = mConverter.init(); | 112 | bool res = mConverter.init(); |
113 | if (!res) | 113 | if (!res) |
114 | { | 114 | { |
@@ -116,9 +116,9 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
116 | qDebug(text); | 116 | qDebug(text); |
117 | KMessageBox::error( parentWidget(), text ); | 117 | KMessageBox::error( parentWidget(), text ); |
118 | delete access; | 118 | delete access; |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | 121 | ||
122 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 122 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
123 | OContactAccess::List contactList = access->allRecords(); | 123 | OContactAccess::List contactList = access->allRecords(); |
124 | if (contactList.count() > 0) | 124 | if (contactList.count() > 0) |
@@ -129,13 +129,13 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
129 | access->clear(); | 129 | access->clear(); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | KABC::Addressee::List::ConstIterator it; | 134 | KABC::Addressee::List::ConstIterator it; |
135 | for ( it = list.begin(); it != list.end(); ++it ) { | 135 | for ( it = list.begin(); it != list.end(); ++it ) { |
136 | OContact c; | 136 | OContact c; |
137 | KABC::Addressee addressee = (*it); | 137 | KABC::Addressee addressee = (*it); |
138 | 138 | ||
139 | res = mConverter.addresseeToOpie( *it, c ); | 139 | res = mConverter.addresseeToOpie( *it, c ); |
140 | if (res == true) | 140 | if (res == true) |
141 | { | 141 | { |
@@ -148,33 +148,33 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
148 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | 148 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | access->save(); | 152 | access->save(); |
153 | 153 | ||
154 | delete access; | 154 | delete access; |
155 | //US the deletion of the access object deletes the backend object as well. | 155 | //US the deletion of the access object deletes the backend object as well. |
156 | 156 | ||
157 | return true; | 157 | return true; |
158 | } | 158 | } |
159 | 159 | ||
160 | KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | 160 | KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const |
161 | { | 161 | { |
162 | KABC::AddresseeList adrlst; | 162 | KABC::AddresseeList adrlst; |
163 | 163 | ||
164 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 164 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
165 | 165 | ||
166 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
167 | QString fileName = KFileDialog::getOpenFileName( name ); | 167 | QString fileName = KFileDialog::getOpenFileName( name ); |
168 | #else //KAB_EMBEDDED | 168 | #else //KAB_EMBEDDED |
169 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); | 169 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); |
170 | #endif //KAB_EMBEDDED | 170 | #endif //KAB_EMBEDDED |
171 | 171 | ||
172 | if ( fileName.isEmpty() ) | 172 | if ( fileName.isEmpty() ) |
173 | return KABC::AddresseeList(); | 173 | return KABC::AddresseeList(); |
174 | 174 | ||
175 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 175 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
176 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 176 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
177 | 177 | ||
178 | if ( !access ) { | 178 | if ( !access ) { |
179 | qDebug("Unable to access file() %s", fileName.latin1()); | 179 | qDebug("Unable to access file() %s", fileName.latin1()); |
180 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 180 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
@@ -182,7 +182,7 @@ KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | |||
182 | } | 182 | } |
183 | 183 | ||
184 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available | 184 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available |
185 | 185 | ||
186 | KABC::OpieConverter mConverter; | 186 | KABC::OpieConverter mConverter; |
187 | 187 | ||
188 | bool res = mConverter.init(); | 188 | bool res = mConverter.init(); |
@@ -194,28 +194,28 @@ KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | |||
194 | delete access; | 194 | delete access; |
195 | return KABC::AddresseeList(); | 195 | return KABC::AddresseeList(); |
196 | } | 196 | } |
197 | 197 | ||
198 | 198 | ||
199 | OContactAccess::List::Iterator it; | 199 | OContactAccess::List::Iterator it; |
200 | OContactAccess::List allList = access->allRecords(); | 200 | OContactAccess::List allList = access->allRecords(); |
201 | for ( it = allList.begin(); it != allList.end(); ++it ) | 201 | for ( it = allList.begin(); it != allList.end(); ++it ) |
202 | { | 202 | { |
203 | OContact c = (*it); | 203 | OContact c = (*it); |
204 | 204 | ||
205 | KABC::Addressee addressee; | 205 | KABC::Addressee addressee; |
206 | 206 | ||
207 | res = mConverter.opieToAddressee( c, addressee ); | 207 | res = mConverter.opieToAddressee( c, addressee ); |
208 | 208 | ||
209 | if ( !addressee.isEmpty() && res ) { | 209 | if ( !addressee.isEmpty() && res ) { |
210 | adrlst.append( addressee ); | 210 | adrlst.append( addressee ); |
211 | } | 211 | } |
212 | 212 | ||
213 | // qDebug("found %s", c.fullName().latin1()); | 213 | // qDebug("found %s", c.fullName().latin1()); |
214 | } | 214 | } |
215 | 215 | ||
216 | delete access; | 216 | delete access; |
217 | //US the deletion of the access object deletes the backend object as well. | 217 | //US the deletion of the access object deletes the backend object as well. |
218 | 218 | ||
219 | return adrlst; | 219 | return adrlst; |
220 | 220 | ||
221 | } | 221 | } |