-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 @@ | |||
28 | #include <qprogressbar.h> | 28 | #include <qprogressbar.h> |
29 | #include <qwidgetstack.h> | 29 | #include <qwidgetstack.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qhbox.h> | 33 | #include <qhbox.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
37 | #include <qlistview.h> | 37 | #include <qlistview.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kstandarddirs.h> | 41 | #include <kstandarddirs.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 43 | #include <kfiledialog.h> |
44 | 44 | ||
45 | #include <libkdepim/categoryselectdialog.h> | 45 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kinputdialog.h> | 46 | #include <libkdepim/kinputdialog.h> |
47 | 47 | ||
48 | #include <libkcal/calendarlocal.h> | 48 | #include <libkcal/calendarlocal.h> |
49 | #include <libkcal/icalformat.h> | 49 | #include <libkcal/icalformat.h> |
50 | #include <kabc/stdaddressbook.h> | 50 | #include <kabc/stdaddressbook.h> |
51 | 51 | ||
52 | #include "koprefs.h" | 52 | #include "koprefs.h" |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | 54 | ||
55 | #include "koimportoldialog.h" | 55 | #include "koimportoldialog.h" |
56 | 56 | ||
57 | #include "../outport/msoutl9.h" | 57 | #include "../outport/msoutl9.h" |
58 | #include <ole2.h> | 58 | #include <ole2.h> |
59 | #include <comutil.h> | 59 | #include <comutil.h> |
60 | _Application gOlApp; | 60 | _Application gOlApp; |
61 | 61 | ||
62 | QDateTime mDdate2Qdtr( DATE dt) | 62 | QDateTime mDdate2Qdtr( DATE dt) |
63 | { | 63 | { |
64 | COleDateTime odt; | 64 | COleDateTime odt; |
65 | SYSTEMTIME st; | 65 | SYSTEMTIME st; |
66 | odt = dt; | 66 | odt = dt; |
67 | odt.GetAsSystemTime(st); | 67 | odt.GetAsSystemTime(st); |
68 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 68 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
69 | return qdt; | 69 | return qdt; |
70 | } | 70 | } |
71 | 71 | ||
72 | class OLEListViewItem : public QCheckListItem | 72 | class OLEListViewItem : public QCheckListItem |
73 | { | 73 | { |
74 | public: | 74 | public: |
75 | OLEListViewItem( QListView *parent, QString text ) : | 75 | OLEListViewItem( QListView *parent, QString text ) : |
76 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | 76 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { mData = 0; }; |
77 | OLEListViewItem( QListViewItem *after, QString text ) : | 77 | OLEListViewItem( QListViewItem *after, QString text ) : |
78 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | 78 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { mData = 0; }; |
79 | ~OLEListViewItem() {}; | 79 | ~OLEListViewItem() {}; |
80 | void setData( DWORD data ) {mData= data; }; | 80 | void setData( DWORD data ) {mData= data; }; |
81 | DWORD data() { return mData ;}; | 81 | DWORD data() { return mData ;}; |
82 | private: | 82 | private: |
83 | DWORD mData; | 83 | DWORD mData; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | KOImportOLdialog::KOImportOLdialog( const QString &caption, | 86 | KOImportOLdialog::KOImportOLdialog( const QString &caption, |
87 | Calendar *calendar, QWidget *parent ) : | 87 | Calendar *calendar, QWidget *parent ) : |
88 | KDialogBase( Plain, caption, User1 | Close, Ok, | 88 | KDialogBase( Plain, caption, User1 | Close, Ok, |
89 | parent, caption, true, false, i18n("Import!") ) | 89 | parent, caption, true, false, i18n("Import!") ) |
90 | { | 90 | { |
91 | QHBox * mw = new QHBox( this ); | 91 | QHBox * mw = new QHBox( this ); |
92 | setMainWidget( mw ); | 92 | setMainWidget( mw ); |
93 | mListView = new QListView( mw ); | 93 | mListView = new QListView( mw ); |
94 | mListView->addColumn(i18n("Select Folder to import")); | 94 | mListView->addColumn(i18n("Select Folder to import")); |
95 | mListView->addColumn(i18n("Content Type")); | 95 | mListView->addColumn(i18n("Content Type")); |
96 | mCalendar = calendar; | 96 | mCalendar = calendar; |
97 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | 97 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); |
98 | setupFolderView(); | 98 | setupFolderView(); |
99 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | 99 | resize( sizeHint().width()+50, sizeHint().height()+50 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | KOImportOLdialog::~KOImportOLdialog() | 102 | KOImportOLdialog::~KOImportOLdialog() |
103 | { | 103 | { |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void KOImportOLdialog::setupFolderView() | 108 | void KOImportOLdialog::setupFolderView() |
109 | { | 109 | { |
110 | SCODE sc = ::OleInitialize(NULL); | 110 | SCODE sc = ::OleInitialize(NULL); |
111 | if ( FAILED ( sc ) ) { | 111 | if ( FAILED ( sc ) ) { |
112 | KMessageBox::information(this,"OLE initialisation failed"); | 112 | KMessageBox::information(this,"OLE initialisation failed"); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ | 116 | if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ |
117 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | 117 | KMessageBox::information(this,"Sorry, cannot access Outlook"); |
118 | return ; | 118 | return ; |
119 | } | 119 | } |
120 | MAPIFolder mfInbox; | 120 | MAPIFolder mfInbox; |
121 | MAPIFolder mfRoot; | 121 | MAPIFolder mfRoot; |
122 | CString szName; | 122 | CString szName; |
123 | _NameSpace olNS; | 123 | _NameSpace olNS; |
124 | olNS = gOlApp.GetNamespace(_T("MAPI")); | 124 | olNS = gOlApp.GetNamespace(_T("MAPI")); |
125 | mfInbox = olNS.GetDefaultFolder(6); | 125 | mfInbox = olNS.GetDefaultFolder(6); |
126 | mfRoot = mfInbox.GetParent(); | 126 | mfRoot = mfInbox.GetParent(); |
@@ -147,97 +147,97 @@ void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent | |||
147 | OLEListViewItem* hChild; | 147 | OLEListViewItem* hChild; |
148 | 148 | ||
149 | folders = mfParent.GetFolders(); | 149 | folders = mfParent.GetFolders(); |
150 | for(int i=1; i <= folders.GetCount(); ++i) | 150 | for(int i=1; i <= folders.GetCount(); ++i) |
151 | { | 151 | { |
152 | fndx = (long)i; | 152 | fndx = (long)i; |
153 | mfChild = folders.Item(fndx.Detach()); | 153 | mfChild = folders.Item(fndx.Detach()); |
154 | mfChild.m_lpDispatch->AddRef(); | 154 | mfChild.m_lpDispatch->AddRef(); |
155 | szName = mfChild.GetName(); | 155 | szName = mfChild.GetName(); |
156 | iType = mfChild.GetDefaultItemType(); | 156 | iType = mfChild.GetDefaultItemType(); |
157 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | 157 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); |
158 | if ( iType != 1) | 158 | if ( iType != 1) |
159 | hChild->setEnabled( false ); | 159 | hChild->setEnabled( false ); |
160 | QString ts; | 160 | QString ts; |
161 | switch( iType ) { | 161 | switch( iType ) { |
162 | case 0: | 162 | case 0: |
163 | ts = i18n("Mail"); | 163 | ts = i18n("Mail"); |
164 | break; | 164 | break; |
165 | case 1: | 165 | case 1: |
166 | ts = i18n("Calendar"); | 166 | ts = i18n("Calendar"); |
167 | break; | 167 | break; |
168 | case 2: | 168 | case 2: |
169 | ts = i18n("Contacts"); | 169 | ts = i18n("Contacts"); |
170 | break; | 170 | break; |
171 | case 3: | 171 | case 3: |
172 | ts = i18n("Todos"); | 172 | ts = i18n("Todos"); |
173 | break; | 173 | break; |
174 | case 4: | 174 | case 4: |
175 | ts = i18n("Journals"); | 175 | ts = i18n("Journals"); |
176 | break; | 176 | break; |
177 | case 5: | 177 | case 5: |
178 | ts = i18n("Notes"); | 178 | ts = i18n("Notes"); |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | ts = i18n("Unknown"); | 181 | ts = i18n("Unknown"); |
182 | } | 182 | } |
183 | hChild->setText( 1,ts); | 183 | hChild->setText( 1,ts); |
184 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 184 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
185 | mfChild.m_lpDispatch->AddRef(); | 185 | mfChild.m_lpDispatch->AddRef(); |
186 | addFolder(hChild, mfChild.m_lpDispatch); | 186 | addFolder(hChild, mfChild.m_lpDispatch); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOImportOLdialog::slotApply() | 190 | void KOImportOLdialog::slotApply() |
191 | { | 191 | { |
192 | importedItems = 0; | 192 | importedItems = 0; |
193 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 193 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
194 | while ( child ) { | 194 | while ( child ) { |
195 | if ( child->isOn() ) | 195 | if ( child->isOn()&& child->data() ) |
196 | readCalendarData( child->data() ); | 196 | readCalendarData( child->data() ); |
197 | child = (OLEListViewItem*) child->itemBelow(); | 197 | child = (OLEListViewItem*) child->itemBelow(); |
198 | } | 198 | } |
199 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 199 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
200 | KMessageBox::information(this,mes); | 200 | KMessageBox::information(this,mes); |
201 | } | 201 | } |
202 | void KOImportOLdialog::readCalendarData( DWORD folder ) | 202 | void KOImportOLdialog::readCalendarData( DWORD folder ) |
203 | { | 203 | { |
204 | 204 | ||
205 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 205 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
206 | dispItem->AddRef(); | 206 | dispItem->AddRef(); |
207 | MAPIFolder mf(dispItem); | 207 | MAPIFolder mf(dispItem); |
208 | mf.m_lpDispatch->AddRef(); | 208 | mf.m_lpDispatch->AddRef(); |
209 | _Items folderItems; | 209 | _Items folderItems; |
210 | _variant_t indx((long)0); | 210 | _variant_t indx((long)0); |
211 | LPDISPATCH itm; | 211 | LPDISPATCH itm; |
212 | int i; | 212 | int i; |
213 | folderItems = mf.GetItems(); | 213 | folderItems = mf.GetItems(); |
214 | QProgressBar bar( folderItems.GetCount(),0 ); | 214 | QProgressBar bar( folderItems.GetCount(),0 ); |
215 | bar.setCaption (i18n("Importing - close to abort!") ); | 215 | bar.setCaption (i18n("Importing - close to abort!") ); |
216 | int h = bar.sizeHint().height() ; | 216 | int h = bar.sizeHint().height() ; |
217 | int w = 300; | 217 | int w = 300; |
218 | int dw = QApplication::desktop()->width(); | 218 | int dw = QApplication::desktop()->width(); |
219 | int dh = QApplication::desktop()->height(); | 219 | int dh = QApplication::desktop()->height(); |
220 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 220 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
221 | bar.show(); | 221 | bar.show(); |
222 | for(i=1; i <= folderItems.GetCount(); ++i) | 222 | for(i=1; i <= folderItems.GetCount(); ++i) |
223 | { | 223 | { |
224 | qApp->processEvents(); | 224 | qApp->processEvents(); |
225 | if ( ! bar.isVisible() ) | 225 | if ( ! bar.isVisible() ) |
226 | return ; | 226 | return ; |
227 | bar.setProgress( i ); | 227 | bar.setProgress( i ); |
228 | indx = (long)i; | 228 | indx = (long)i; |
229 | itm = folderItems.Item(indx.Detach()); | 229 | itm = folderItems.Item(indx.Detach()); |
230 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; | 230 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; |
231 | ol2kopiCalendar( pItem ); | 231 | ol2kopiCalendar( pItem ); |
232 | itm->Release(); | 232 | itm->Release(); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | void KOImportOLdialog::slotOk() | 235 | void KOImportOLdialog::slotOk() |
236 | { | 236 | { |
237 | QDialog::accept(); | 237 | QDialog::accept(); |
238 | } | 238 | } |
239 | 239 | ||
240 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) | 240 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) |
241 | { | 241 | { |
242 | KCal::Event* event = new KCal::Event(); | 242 | KCal::Event* event = new KCal::Event(); |
243 | if ( aItem->GetAllDayEvent() ){ | 243 | if ( aItem->GetAllDayEvent() ){ |