-rw-r--r-- | korganizer/koimportoldialog.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp index 7aa6076..2af436c 100644 --- a/korganizer/koimportoldialog.cpp +++ b/korganizer/koimportoldialog.cpp | |||
@@ -1,60 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@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 <qapplication.h> | 33 | #include <qapplication.h> |
33 | #include <qhbox.h> | 34 | #include <qhbox.h> |
34 | #include <qregexp.h> | 35 | #include <qregexp.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 | #include <kabc/stdaddressbook.h> | 51 | #include <kabc/stdaddressbook.h> |
51 | 52 | ||
52 | #include "koprefs.h" | 53 | #include "koprefs.h" |
53 | #include "koglobals.h" | 54 | #include "koglobals.h" |
54 | 55 | ||
55 | #include "koimportoldialog.h" | 56 | #include "koimportoldialog.h" |
56 | 57 | ||
57 | #include "../outport/msoutl9.h" | 58 | #include "../outport/msoutl9.h" |
58 | #include <ole2.h> | 59 | #include <ole2.h> |
59 | #include <comutil.h> | 60 | #include <comutil.h> |
60 | _Application gOlApp; | 61 | _Application gOlApp; |
@@ -182,78 +183,79 @@ void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent | |||
182 | } | 183 | } |
183 | hChild->setText( 1,ts); | 184 | hChild->setText( 1,ts); |
184 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 185 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
185 | mfChild.m_lpDispatch->AddRef(); | 186 | mfChild.m_lpDispatch->AddRef(); |
186 | addFolder(hChild, mfChild.m_lpDispatch); | 187 | addFolder(hChild, mfChild.m_lpDispatch); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | void KOImportOLdialog::slotApply() | 191 | void KOImportOLdialog::slotApply() |
191 | { | 192 | { |
192 | importedItems = 0; | 193 | importedItems = 0; |
193 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 194 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
194 | while ( child ) { | 195 | while ( child ) { |
195 | if ( child->isOn()&& child->data() ) | 196 | if ( child->isOn()&& child->data() ) |
196 | readCalendarData( child->data() ); | 197 | readCalendarData( child->data() ); |
197 | child = (OLEListViewItem*) child->itemBelow(); | 198 | child = (OLEListViewItem*) child->itemBelow(); |
198 | } | 199 | } |
199 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 200 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
200 | KMessageBox::information(this,mes); | 201 | KMessageBox::information(this,mes); |
201 | } | 202 | } |
202 | void KOImportOLdialog::readCalendarData( DWORD folder ) | 203 | void KOImportOLdialog::readCalendarData( DWORD folder ) |
203 | { | 204 | { |
204 | 205 | ||
205 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 206 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
206 | dispItem->AddRef(); | 207 | dispItem->AddRef(); |
207 | MAPIFolder mf(dispItem); | 208 | MAPIFolder mf(dispItem); |
208 | mf.m_lpDispatch->AddRef(); | 209 | mf.m_lpDispatch->AddRef(); |
209 | _Items folderItems; | 210 | _Items folderItems; |
210 | _variant_t indx((long)0); | 211 | _variant_t indx((long)0); |
211 | LPDISPATCH itm; | 212 | LPDISPATCH itm; |
212 | int i; | 213 | int i; |
213 | folderItems = mf.GetItems(); | 214 | folderItems = mf.GetItems(); |
214 | QProgressBar bar( folderItems.GetCount(),0 ); | 215 | QProgressDialog bar( i18n("Importing calendar data"),i18n("Abort"), folderItems.GetCount(),this ); |
215 | bar.setCaption (i18n("Importing - close to abort!") ); | 216 | bar.setCaption (i18n("Importing!") ); |
216 | int h = bar.sizeHint().height() ; | 217 | int h = bar.sizeHint().height() ; |
217 | int w = 300; | 218 | int w = 300; |
218 | int dw = QApplication::desktop()->width(); | 219 | int dw = QApplication::desktop()->width(); |
219 | int dh = QApplication::desktop()->height(); | 220 | int dh = QApplication::desktop()->height(); |
220 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 221 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
221 | bar.show(); | 222 | bar.show(); |
222 | for(i=1; i <= folderItems.GetCount(); ++i) | 223 | for(i=1; i <= folderItems.GetCount(); ++i) |
223 | { | 224 | { |
224 | qApp->processEvents(); | 225 | qApp->processEvents(); |
225 | if ( ! bar.isVisible() ) | 226 | if ( ! bar.isVisible() ) |
226 | return ; | 227 | return ; |
227 | bar.setProgress( i ); | 228 | bar.setProgress( i ); |
229 | bar.raise(); | ||
228 | indx = (long)i; | 230 | indx = (long)i; |
229 | itm = folderItems.Item(indx.Detach()); | 231 | itm = folderItems.Item(indx.Detach()); |
230 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; | 232 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; |
231 | ol2kopiCalendar( pItem ); | 233 | ol2kopiCalendar( pItem ); |
232 | itm->Release(); | 234 | itm->Release(); |
233 | } | 235 | } |
234 | } | 236 | } |
235 | void KOImportOLdialog::slotOk() | 237 | void KOImportOLdialog::slotOk() |
236 | { | 238 | { |
237 | QDialog::accept(); | 239 | QDialog::accept(); |
238 | } | 240 | } |
239 | 241 | ||
240 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) | 242 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) |
241 | { | 243 | { |
242 | KCal::Event* event = new KCal::Event(); | 244 | KCal::Event* event = new KCal::Event(); |
243 | if ( aItem->GetAllDayEvent() ){ | 245 | if ( aItem->GetAllDayEvent() ){ |
244 | event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); | 246 | event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); |
245 | event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); | 247 | event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); |
246 | event->setFloats( true ); | 248 | event->setFloats( true ); |
247 | } else { | 249 | } else { |
248 | event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); | 250 | event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); |
249 | event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); | 251 | event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); |
250 | event->setFloats( false ); | 252 | event->setFloats( false ); |
251 | } | 253 | } |
252 | event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); | 254 | event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); |
253 | event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); | 255 | event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); |
254 | event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") ); | 256 | event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") ); |
255 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("; "), ";"); | 257 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("; "), ";"); |
256 | event->setCategories( QStringList::split( ";", cat ) ); | 258 | event->setCategories( QStringList::split( ";", cat ) ); |
257 | if ( aItem->GetReminderSet() ) { | 259 | if ( aItem->GetReminderSet() ) { |
258 | event->clearAlarms(); | 260 | event->clearAlarms(); |
259 | Alarm* alarm = event->newAlarm(); | 261 | Alarm* alarm = event->newAlarm(); |