author | zautrix <zautrix> | 2005-06-29 21:43:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 21:43:21 (UTC) |
commit | 54dd512d3980381c2b02263462db03ae7c5a0264 (patch) (unidiff) | |
tree | 82a31315a85ad5e0a95ef37274fa96f7c4a88dfa /kaddressbook | |
parent | 7ccfe9b674bd5cc52eab708c2e7dfb02c3328deb (diff) | |
download | kdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.zip kdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.tar.gz kdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.tar.bz2 |
fixxx
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 7bb8bd8..2f794d6 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -1,76 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook/Pi. | 2 | This file is part of KAddressbook/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qprogressbar.h> | 28 | #include <qprogressbar.h> |
29 | #include <qprogressdialog.h> | ||
29 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
30 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <qregexp.h> | 33 | #include <qregexp.h> |
33 | #include <qapplication.h> | 34 | #include <qapplication.h> |
34 | #include <qhbox.h> | 35 | #include <qhbox.h> |
35 | #include <qheader.h> | 36 | #include <qheader.h> |
36 | #include <qdatetime.h> | 37 | #include <qdatetime.h> |
37 | #include <qlistview.h> | 38 | #include <qlistview.h> |
38 | 39 | ||
39 | #include <kdebug.h> | 40 | #include <kdebug.h> |
40 | #include <klocale.h> | 41 | #include <klocale.h> |
41 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
42 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 44 | #include <kfiledialog.h> |
44 | 45 | ||
45 | #include <libkdepim/categoryselectdialog.h> | 46 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kinputdialog.h> | 47 | #include <libkdepim/kinputdialog.h> |
47 | 48 | ||
48 | #include <libkcal/calendarlocal.h> | 49 | #include <libkcal/calendarlocal.h> |
49 | #include <libkcal/icalformat.h> | 50 | #include <libkcal/icalformat.h> |
50 | 51 | ||
51 | #include <kabc/addresseelist.h> | 52 | #include <kabc/addresseelist.h> |
52 | #include <kabc/phonenumber.h> | 53 | #include <kabc/phonenumber.h> |
53 | 54 | ||
54 | #include "kaimportoldialog.h" | 55 | #include "kaimportoldialog.h" |
55 | 56 | ||
56 | #include "../outport/msoutl9.h" | 57 | #include "../outport/msoutl9.h" |
57 | #include <ole2.h> | 58 | #include <ole2.h> |
58 | #include <comutil.h> | 59 | #include <comutil.h> |
59 | _Application gOlAppAB; | 60 | _Application gOlAppAB; |
60 | 61 | ||
61 | QDateTime mDdate2Qdtr( DATE dt) | 62 | QDateTime mDdate2Qdtr( DATE dt) |
62 | { | 63 | { |
63 | COleDateTime odt; | 64 | COleDateTime odt; |
64 | SYSTEMTIME st; | 65 | SYSTEMTIME st; |
65 | odt = dt; | 66 | odt = dt; |
66 | if ( odt.GetStatus() != 0 ) | 67 | if ( odt.GetStatus() != 0 ) |
67 | return QDateTime(); | 68 | return QDateTime(); |
68 | odt.GetAsSystemTime(st); | 69 | odt.GetAsSystemTime(st); |
69 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | 70 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! |
70 | return QDateTime(); | 71 | return QDateTime(); |
71 | // it seems so, that 1.1.4501 indicates: DATE invalid | 72 | // it seems so, that 1.1.4501 indicates: DATE invalid |
72 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 73 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
73 | return qdt; | 74 | return qdt; |
74 | } | 75 | } |
75 | 76 | ||
76 | class OLEListViewItem : public QCheckListItem | 77 | class OLEListViewItem : public QCheckListItem |
@@ -173,103 +174,103 @@ void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent | |||
173 | ts = i18n("Calendar"); | 174 | ts = i18n("Calendar"); |
174 | break; | 175 | break; |
175 | case 2: | 176 | case 2: |
176 | ts = i18n("Contacts"); | 177 | ts = i18n("Contacts"); |
177 | break; | 178 | break; |
178 | case 3: | 179 | case 3: |
179 | ts = i18n("Todos"); | 180 | ts = i18n("Todos"); |
180 | break; | 181 | break; |
181 | case 4: | 182 | case 4: |
182 | ts = i18n("Journals"); | 183 | ts = i18n("Journals"); |
183 | break; | 184 | break; |
184 | case 5: | 185 | case 5: |
185 | ts = i18n("Notes"); | 186 | ts = i18n("Notes"); |
186 | break; | 187 | break; |
187 | default: | 188 | default: |
188 | ts = i18n("Unknown"); | 189 | ts = i18n("Unknown"); |
189 | } | 190 | } |
190 | hChild->setText( 1,ts); | 191 | hChild->setText( 1,ts); |
191 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 192 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
192 | mfChild.m_lpDispatch->AddRef(); | 193 | mfChild.m_lpDispatch->AddRef(); |
193 | addFolder(hChild, mfChild.m_lpDispatch); | 194 | addFolder(hChild, mfChild.m_lpDispatch); |
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
197 | void KAImportOLdialog::slotApply() | 198 | void KAImportOLdialog::slotApply() |
198 | { | 199 | { |
199 | importedItems = 0; | 200 | importedItems = 0; |
200 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 201 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
201 | while ( child ) { | 202 | while ( child ) { |
202 | if ( child->isOn() ) | 203 | if ( child->isOn() ) |
203 | readContactData( child->data() ); | 204 | readContactData( child->data() ); |
204 | child = (OLEListViewItem*) child->itemBelow(); | 205 | child = (OLEListViewItem*) child->itemBelow(); |
205 | } | 206 | } |
206 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 207 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
207 | KMessageBox::information(this,mes); | 208 | KMessageBox::information(this,mes); |
208 | } | 209 | } |
209 | void KAImportOLdialog::readContactData( DWORD folder ) | 210 | void KAImportOLdialog::readContactData( DWORD folder ) |
210 | { | 211 | { |
211 | 212 | ||
212 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 213 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
213 | dispItem->AddRef(); | 214 | dispItem->AddRef(); |
214 | MAPIFolder mf(dispItem); | 215 | MAPIFolder mf(dispItem); |
215 | mf.m_lpDispatch->AddRef(); | 216 | mf.m_lpDispatch->AddRef(); |
216 | _Items folderItems; | 217 | _Items folderItems; |
217 | _variant_t indx((long)0); | 218 | _variant_t indx((long)0); |
218 | LPDISPATCH itm; | 219 | LPDISPATCH itm; |
219 | int i; | 220 | int i; |
220 | folderItems = mf.GetItems(); | 221 | folderItems = mf.GetItems(); |
221 | QProgressBar bar( folderItems.GetCount(),0 ); | 222 | QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this); |
222 | bar.setCaption (i18n("Importing - close to abort!") ); | 223 | bar.setCaption (i18n("Importing!") ); |
223 | int h = bar.sizeHint().height() ; | 224 | int h = bar.sizeHint().height() ; |
224 | int w = 300; | 225 | int w = 300; |
225 | int dw = QApplication::desktop()->width(); | 226 | int dw = QApplication::desktop()->width(); |
226 | int dh = QApplication::desktop()->height(); | 227 | int dh = QApplication::desktop()->height(); |
227 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 228 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
228 | bar.show(); | 229 | bar.show(); |
229 | for(i=1; i <= folderItems.GetCount(); ++i) | 230 | for(i=1; i <= folderItems.GetCount(); ++i) |
230 | { | 231 | { |
231 | qApp->processEvents(); | 232 | qApp->processEvents(); |
232 | if ( ! bar.isVisible() ) | 233 | if ( ! bar.isVisible() ) |
233 | return ; | 234 | return ; |
234 | bar.setProgress( i ); | 235 | bar.setProgress( i ); |
235 | indx = (long)i; | 236 | indx = (long)i; |
236 | itm = folderItems.Item(indx.Detach()); | 237 | itm = folderItems.Item(indx.Detach()); |
237 | _ContactItem * pItem = (_ContactItem *)&itm; | 238 | _ContactItem * pItem = (_ContactItem *)&itm; |
238 | ol2kapiContact( pItem ); | 239 | ol2kapiContact( pItem ); |
239 | itm->Release(); | 240 | itm->Release(); |
240 | } | 241 | } |
241 | } | 242 | } |
242 | void KAImportOLdialog::slotOk() | 243 | void KAImportOLdialog::slotOk() |
243 | { | 244 | { |
244 | QDialog::accept(); | 245 | QDialog::accept(); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | 248 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) |
248 | { | 249 | { |
249 | KABC::Addressee addressee; | 250 | KABC::Addressee addressee; |
250 | 251 | ||
251 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | 252 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); |
252 | //GetLastModificationTime() | 253 | //GetLastModificationTime() |
253 | //addressee.setName( const QString &name ); | 254 | //addressee.setName( const QString &name ); |
254 | //addressee.setFormattedName( const QString &formattedName ); | 255 | //addressee.setFormattedName( const QString &formattedName ); |
255 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | 256 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); |
256 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | 257 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); |
257 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | 258 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); |
258 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | 259 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); |
259 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | 260 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); |
260 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | 261 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); |
261 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | 262 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); |
262 | if ( dtb.isValid() ) | 263 | if ( dtb.isValid() ) |
263 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | 264 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); |
264 | 265 | ||
265 | //QString::fromUcs2(aItem->.GetBuffer()) | 266 | //QString::fromUcs2(aItem->.GetBuffer()) |
266 | //addressee.setMailer( const QString &mailer ); | 267 | //addressee.setMailer( const QString &mailer ); |
267 | //addressee.setTimeZone( const TimeZone &timeZone ); | 268 | //addressee.setTimeZone( const TimeZone &timeZone ); |
268 | //addressee.setGeo( const Geo &geo ); | 269 | //addressee.setGeo( const Geo &geo ); |
269 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | 270 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix |
270 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | 271 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); |
271 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); | 272 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); |
272 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); | 273 | QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); |
273 | notesStr.replace( QRegExp("\\r"), ""); | 274 | notesStr.replace( QRegExp("\\r"), ""); |
274 | 275 | ||
275 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | 276 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); |