author | zautrix <zautrix> | 2005-01-11 18:17:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-11 18:17:09 (UTC) |
commit | b7753438e51d9b87da7d802ef1f5ac092e3266dd (patch) (side-by-side diff) | |
tree | 493030cc2217def407de4a1b8254a9e288b33585 | |
parent | 1ce6538c94c7eea930b439eb9c7a7dea020aaace (diff) | |
download | kdepimpi-b7753438e51d9b87da7d802ef1f5ac092e3266dd.zip kdepimpi-b7753438e51d9b87da7d802ef1f5ac092e3266dd.tar.gz kdepimpi-b7753438e51d9b87da7d802ef1f5ac092e3266dd.tar.bz2 |
ole fix
-rw-r--r-- | korganizer/koimportoldialog.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp index c0bde0d..cc13395 100644 --- a/korganizer/koimportoldialog.cpp +++ b/korganizer/koimportoldialog.cpp @@ -28,99 +28,99 @@ #include <qprogressbar.h> #include <qwidgetstack.h> #include <qdatetime.h> #include <qdir.h> #include <qapplication.h> #include <qhbox.h> #include <qregexp.h> #include <qheader.h> #include <qdatetime.h> #include <qlistview.h> #include <kdebug.h> #include <klocale.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kinputdialog.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include <kabc/stdaddressbook.h> #include "koprefs.h" #include "koglobals.h" #include "koimportoldialog.h" #include "../outport/msoutl9.h" #include <ole2.h> #include <comutil.h> _Application gOlApp; QDateTime mDdate2Qdtr( DATE dt) { COleDateTime odt; SYSTEMTIME st; odt = dt; odt.GetAsSystemTime(st); QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); return qdt; } class OLEListViewItem : public QCheckListItem { public: OLEListViewItem( QListView *parent, QString text ) : - QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; + QCheckListItem( parent, text, QCheckListItem::CheckBox ) { mData = 0; }; OLEListViewItem( QListViewItem *after, QString text ) : - QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; + QCheckListItem( after, text, QCheckListItem::CheckBox ) { mData = 0; }; ~OLEListViewItem() {}; void setData( DWORD data ) {mData= data; }; DWORD data() { return mData ;}; private: DWORD mData; }; KOImportOLdialog::KOImportOLdialog( const QString &caption, Calendar *calendar, QWidget *parent ) : KDialogBase( Plain, caption, User1 | Close, Ok, parent, caption, true, false, i18n("Import!") ) { QHBox * mw = new QHBox( this ); setMainWidget( mw ); mListView = new QListView( mw ); mListView->addColumn(i18n("Select Folder to import")); mListView->addColumn(i18n("Content Type")); mCalendar = calendar; connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); setupFolderView(); resize( sizeHint().width()+50, sizeHint().height()+50 ); } KOImportOLdialog::~KOImportOLdialog() { } void KOImportOLdialog::setupFolderView() { SCODE sc = ::OleInitialize(NULL); if ( FAILED ( sc ) ) { KMessageBox::information(this,"OLE initialisation failed"); return; } if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ KMessageBox::information(this,"Sorry, cannot access Outlook"); return ; } MAPIFolder mfInbox; MAPIFolder mfRoot; CString szName; _NameSpace olNS; olNS = gOlApp.GetNamespace(_T("MAPI")); mfInbox = olNS.GetDefaultFolder(6); mfRoot = mfInbox.GetParent(); @@ -147,97 +147,97 @@ void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent OLEListViewItem* hChild; folders = mfParent.GetFolders(); for(int i=1; i <= folders.GetCount(); ++i) { fndx = (long)i; mfChild = folders.Item(fndx.Detach()); mfChild.m_lpDispatch->AddRef(); szName = mfChild.GetName(); iType = mfChild.GetDefaultItemType(); hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); if ( iType != 1) hChild->setEnabled( false ); QString ts; switch( iType ) { case 0: ts = i18n("Mail"); break; case 1: ts = i18n("Calendar"); break; case 2: ts = i18n("Contacts"); break; case 3: ts = i18n("Todos"); break; case 4: ts = i18n("Journals"); break; case 5: ts = i18n("Notes"); break; default: ts = i18n("Unknown"); } hChild->setText( 1,ts); hChild->setData( (DWORD) mfChild.m_lpDispatch ); mfChild.m_lpDispatch->AddRef(); addFolder(hChild, mfChild.m_lpDispatch); } } void KOImportOLdialog::slotApply() { importedItems = 0; OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); while ( child ) { - if ( child->isOn() ) + if ( child->isOn()&& child->data() ) readCalendarData( child->data() ); child = (OLEListViewItem*) child->itemBelow(); } QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); KMessageBox::information(this,mes); } void KOImportOLdialog::readCalendarData( DWORD folder ) { LPDISPATCH dispItem = (LPDISPATCH)folder; dispItem->AddRef(); MAPIFolder mf(dispItem); mf.m_lpDispatch->AddRef(); _Items folderItems; _variant_t indx((long)0); LPDISPATCH itm; int i; folderItems = mf.GetItems(); QProgressBar bar( folderItems.GetCount(),0 ); bar.setCaption (i18n("Importing - close to abort!") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _AppointmentItem * pItem = (_AppointmentItem *)&itm; ol2kopiCalendar( pItem ); itm->Release(); } } void KOImportOLdialog::slotOk() { QDialog::accept(); } void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) { KCal::Event* event = new KCal::Event(); if ( aItem->GetAllDayEvent() ){ |