-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,355 +1,357 @@ | |||
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; |
61 | 62 | ||
62 | QDateTime mDdate2Qdtr( DATE dt) | 63 | QDateTime mDdate2Qdtr( DATE dt) |
63 | { | 64 | { |
64 | COleDateTime odt; | 65 | COleDateTime odt; |
65 | SYSTEMTIME st; | 66 | SYSTEMTIME st; |
66 | odt = dt; | 67 | odt = dt; |
67 | odt.GetAsSystemTime(st); | 68 | odt.GetAsSystemTime(st); |
68 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 69 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
69 | return qdt; | 70 | return qdt; |
70 | } | 71 | } |
71 | 72 | ||
72 | class OLEListViewItem : public QCheckListItem | 73 | class OLEListViewItem : public QCheckListItem |
73 | { | 74 | { |
74 | public: | 75 | public: |
75 | OLEListViewItem( QListView *parent, QString text ) : | 76 | OLEListViewItem( QListView *parent, QString text ) : |
76 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { mData = 0; }; | 77 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { mData = 0; }; |
77 | OLEListViewItem( QListViewItem *after, QString text ) : | 78 | OLEListViewItem( QListViewItem *after, QString text ) : |
78 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { mData = 0; }; | 79 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { mData = 0; }; |
79 | ~OLEListViewItem() {}; | 80 | ~OLEListViewItem() {}; |
80 | void setData( DWORD data ) {mData= data; }; | 81 | void setData( DWORD data ) {mData= data; }; |
81 | DWORD data() { return mData ;}; | 82 | DWORD data() { return mData ;}; |
82 | private: | 83 | private: |
83 | DWORD mData; | 84 | DWORD mData; |
84 | }; | 85 | }; |
85 | 86 | ||
86 | KOImportOLdialog::KOImportOLdialog( const QString &caption, | 87 | KOImportOLdialog::KOImportOLdialog( const QString &caption, |
87 | Calendar *calendar, QWidget *parent ) : | 88 | Calendar *calendar, QWidget *parent ) : |
88 | KDialogBase( Plain, caption, User1 | Close, Ok, | 89 | KDialogBase( Plain, caption, User1 | Close, Ok, |
89 | parent, caption, true, false, i18n("Import!") ) | 90 | parent, caption, true, false, i18n("Import!") ) |
90 | { | 91 | { |
91 | QHBox * mw = new QHBox( this ); | 92 | QHBox * mw = new QHBox( this ); |
92 | setMainWidget( mw ); | 93 | setMainWidget( mw ); |
93 | mListView = new QListView( mw ); | 94 | mListView = new QListView( mw ); |
94 | mListView->addColumn(i18n("Select Folder to import")); | 95 | mListView->addColumn(i18n("Select Folder to import")); |
95 | mListView->addColumn(i18n("Content Type")); | 96 | mListView->addColumn(i18n("Content Type")); |
96 | mCalendar = calendar; | 97 | mCalendar = calendar; |
97 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | 98 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); |
98 | setupFolderView(); | 99 | setupFolderView(); |
99 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | 100 | resize( sizeHint().width()+50, sizeHint().height()+50 ); |
100 | } | 101 | } |
101 | 102 | ||
102 | KOImportOLdialog::~KOImportOLdialog() | 103 | KOImportOLdialog::~KOImportOLdialog() |
103 | { | 104 | { |
104 | 105 | ||
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | void KOImportOLdialog::setupFolderView() | 109 | void KOImportOLdialog::setupFolderView() |
109 | { | 110 | { |
110 | SCODE sc = ::OleInitialize(NULL); | 111 | SCODE sc = ::OleInitialize(NULL); |
111 | if ( FAILED ( sc ) ) { | 112 | if ( FAILED ( sc ) ) { |
112 | KMessageBox::information(this,"OLE initialisation failed"); | 113 | KMessageBox::information(this,"OLE initialisation failed"); |
113 | return; | 114 | return; |
114 | } | 115 | } |
115 | 116 | ||
116 | if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ | 117 | if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ |
117 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | 118 | KMessageBox::information(this,"Sorry, cannot access Outlook"); |
118 | return ; | 119 | return ; |
119 | } | 120 | } |
120 | MAPIFolder mfInbox; | 121 | MAPIFolder mfInbox; |
121 | MAPIFolder mfRoot; | 122 | MAPIFolder mfRoot; |
122 | CString szName; | 123 | CString szName; |
123 | _NameSpace olNS; | 124 | _NameSpace olNS; |
124 | olNS = gOlApp.GetNamespace(_T("MAPI")); | 125 | olNS = gOlApp.GetNamespace(_T("MAPI")); |
125 | mfInbox = olNS.GetDefaultFolder(6); | 126 | mfInbox = olNS.GetDefaultFolder(6); |
126 | mfRoot = mfInbox.GetParent(); | 127 | mfRoot = mfInbox.GetParent(); |
127 | szName = mfRoot.GetName(); | 128 | szName = mfRoot.GetName(); |
128 | long iType = mfRoot.GetDefaultItemType(); | 129 | long iType = mfRoot.GetDefaultItemType(); |
129 | QString mes; | 130 | QString mes; |
130 | mes = QString::fromUcs2( szName.GetBuffer() ); | 131 | mes = QString::fromUcs2( szName.GetBuffer() ); |
131 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | 132 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); |
132 | mfRoot.m_lpDispatch->AddRef(); | 133 | mfRoot.m_lpDispatch->AddRef(); |
133 | addFolder( root, mfRoot.m_lpDispatch ); | 134 | addFolder( root, mfRoot.m_lpDispatch ); |
134 | root->setOpen( true ); | 135 | root->setOpen( true ); |
135 | mListView->setSortColumn( 0 ); | 136 | mListView->setSortColumn( 0 ); |
136 | mListView->sort( ); | 137 | mListView->sort( ); |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | 141 | void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) |
141 | { | 142 | { |
142 | MAPIFolder mfParent(dispParent), mfChild; | 143 | MAPIFolder mfParent(dispParent), mfChild; |
143 | _Folders folders; | 144 | _Folders folders; |
144 | _variant_t fndx((long)0); | 145 | _variant_t fndx((long)0); |
145 | CString szName; | 146 | CString szName; |
146 | long iType; | 147 | long iType; |
147 | OLEListViewItem* hChild; | 148 | OLEListViewItem* hChild; |
148 | 149 | ||
149 | folders = mfParent.GetFolders(); | 150 | folders = mfParent.GetFolders(); |
150 | for(int i=1; i <= folders.GetCount(); ++i) | 151 | for(int i=1; i <= folders.GetCount(); ++i) |
151 | { | 152 | { |
152 | fndx = (long)i; | 153 | fndx = (long)i; |
153 | mfChild = folders.Item(fndx.Detach()); | 154 | mfChild = folders.Item(fndx.Detach()); |
154 | mfChild.m_lpDispatch->AddRef(); | 155 | mfChild.m_lpDispatch->AddRef(); |
155 | szName = mfChild.GetName(); | 156 | szName = mfChild.GetName(); |
156 | iType = mfChild.GetDefaultItemType(); | 157 | iType = mfChild.GetDefaultItemType(); |
157 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | 158 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); |
158 | if ( iType != 1) | 159 | if ( iType != 1) |
159 | hChild->setEnabled( false ); | 160 | hChild->setEnabled( false ); |
160 | QString ts; | 161 | QString ts; |
161 | switch( iType ) { | 162 | switch( iType ) { |
162 | case 0: | 163 | case 0: |
163 | ts = i18n("Mail"); | 164 | ts = i18n("Mail"); |
164 | break; | 165 | break; |
165 | case 1: | 166 | case 1: |
166 | ts = i18n("Calendar"); | 167 | ts = i18n("Calendar"); |
167 | break; | 168 | break; |
168 | case 2: | 169 | case 2: |
169 | ts = i18n("Contacts"); | 170 | ts = i18n("Contacts"); |
170 | break; | 171 | break; |
171 | case 3: | 172 | case 3: |
172 | ts = i18n("Todos"); | 173 | ts = i18n("Todos"); |
173 | break; | 174 | break; |
174 | case 4: | 175 | case 4: |
175 | ts = i18n("Journals"); | 176 | ts = i18n("Journals"); |
176 | break; | 177 | break; |
177 | case 5: | 178 | case 5: |
178 | ts = i18n("Notes"); | 179 | ts = i18n("Notes"); |
179 | break; | 180 | break; |
180 | default: | 181 | default: |
181 | ts = i18n("Unknown"); | 182 | ts = i18n("Unknown"); |
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(); |
260 | alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); | 262 | alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); |
261 | alarm->setEnabled( true ); | 263 | alarm->setEnabled( true ); |
262 | if ( aItem->GetReminderPlaySound() ) { | 264 | if ( aItem->GetReminderPlaySound() ) { |
263 | alarm->setType( Alarm::Audio ); | 265 | alarm->setType( Alarm::Audio ); |
264 | alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); | 266 | alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); |
265 | } | 267 | } |
266 | else | 268 | else |
267 | alarm->setType( Alarm::Display ); | 269 | alarm->setType( Alarm::Display ); |
268 | alarm->setRepeatCount( aItem->GetReplyTime() ); | 270 | alarm->setRepeatCount( aItem->GetReplyTime() ); |
269 | } | 271 | } |
270 | // OL :pub 0 - pers 1 - priv 2 - conf 3 | 272 | // OL :pub 0 - pers 1 - priv 2 - conf 3 |
271 | // KO : pub 0 - priv 1 - conf 2 | 273 | // KO : pub 0 - priv 1 - conf 2 |
272 | int sec = aItem->GetSensitivity() ; | 274 | int sec = aItem->GetSensitivity() ; |
273 | if ( sec > 1 )// mapping pers -> private | 275 | if ( sec > 1 )// mapping pers -> private |
274 | --sec; | 276 | --sec; |
275 | event->setSecrecy( sec ); | 277 | event->setSecrecy( sec ); |
276 | if ( aItem->GetBusyStatus() == 0 ) | 278 | if ( aItem->GetBusyStatus() == 0 ) |
277 | event->setTransparency( Event::Transparent);// OL free | 279 | event->setTransparency( Event::Transparent);// OL free |
278 | else | 280 | else |
279 | event->setTransparency( Event::Opaque);//OL all other | 281 | event->setTransparency( Event::Opaque);//OL all other |
280 | 282 | ||
281 | if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur | 283 | if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur |
282 | 284 | ||
283 | RecurrencePattern recpat = aItem->GetRecurrencePattern(); | 285 | RecurrencePattern recpat = aItem->GetRecurrencePattern(); |
284 | 286 | ||
285 | QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); | 287 | QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); |
286 | int freq = recpat.GetInterval(); | 288 | int freq = recpat.GetInterval(); |
287 | 289 | ||
288 | bool hasEndDate = !recpat.GetNoEndDate(); | 290 | bool hasEndDate = !recpat.GetNoEndDate(); |
289 | QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); | 291 | QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); |
290 | QBitArray weekDays( 7 ); | 292 | QBitArray weekDays( 7 ); |
291 | weekDays.fill(false ); | 293 | weekDays.fill(false ); |
292 | uint weekDaysNum = recpat.GetDayOfWeekMask(); | 294 | uint weekDaysNum = recpat.GetDayOfWeekMask(); |
293 | int i; | 295 | int i; |
294 | int bb = 2; | 296 | int bb = 2; |
295 | for( i = 1; i <= 6; ++i ) { | 297 | for( i = 1; i <= 6; ++i ) { |
296 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 298 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
297 | bb = 4 << (i-1); | 299 | bb = 4 << (i-1); |
298 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 300 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
299 | } | 301 | } |
300 | if ( 1 & weekDaysNum) | 302 | if ( 1 & weekDaysNum) |
301 | weekDays.setBit( 6 ); | 303 | weekDays.setBit( 6 ); |
302 | // int pos = 1;// pending | 304 | // int pos = 1;// pending |
303 | 305 | ||
304 | Recurrence *r = event->recurrence(); | 306 | Recurrence *r = event->recurrence(); |
305 | int rtype = recpat.GetRecurrenceType(); | 307 | int rtype = recpat.GetRecurrenceType(); |
306 | //recurrence types are: | 308 | //recurrence types are: |
307 | /* | 309 | /* |
308 | olRecursDaily(0) | 310 | olRecursDaily(0) |
309 | olRecursWeekly(1) | 311 | olRecursWeekly(1) |
310 | olRecursMonthly(2) | 312 | olRecursMonthly(2) |
311 | olRecursMonthNth(3) | 313 | olRecursMonthNth(3) |
312 | olRecursYearly(5) | 314 | olRecursYearly(5) |
313 | olRecursYearNth(6) | 315 | olRecursYearNth(6) |
314 | */ | 316 | */ |
315 | 317 | ||
316 | int duration = recpat.GetOccurrences(); | 318 | int duration = recpat.GetOccurrences(); |
317 | if ( !hasEndDate ) | 319 | if ( !hasEndDate ) |
318 | duration = -1; | 320 | duration = -1; |
319 | 321 | ||
320 | //LPDISPATCH RecurrencePattern::GetExceptions() | 322 | //LPDISPATCH RecurrencePattern::GetExceptions() |
321 | //long RecurrencePattern::GetMonthOfYear() | 323 | //long RecurrencePattern::GetMonthOfYear() |
322 | if ( rtype == 0 ) { | 324 | if ( rtype == 0 ) { |
323 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 325 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
324 | else r->setDaily( freq, duration ); | 326 | else r->setDaily( freq, duration ); |
325 | } else if ( rtype == 1 ) { | 327 | } else if ( rtype == 1 ) { |
326 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 328 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
327 | else r->setWeekly( freq, weekDays, duration ); | 329 | else r->setWeekly( freq, weekDays, duration ); |
328 | } else if ( rtype == 2 ) { | 330 | } else if ( rtype == 2 ) { |
329 | if ( hasEndDate ) | 331 | if ( hasEndDate ) |
330 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 332 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
331 | else | 333 | else |
332 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 334 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
333 | //r->addMonthlyDay( startDate.day() ); | 335 | //r->addMonthlyDay( startDate.day() ); |
334 | r->addMonthlyDay( recpat.GetDayOfMonth() ); | 336 | r->addMonthlyDay( recpat.GetDayOfMonth() ); |
335 | } else if ( rtype == 3 ) { | 337 | } else if ( rtype == 3 ) { |
336 | if ( hasEndDate ) | 338 | if ( hasEndDate ) |
337 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 339 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
338 | else | 340 | else |
339 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 341 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
340 | QBitArray days( 7 ); | 342 | QBitArray days( 7 ); |
341 | days.fill( false ); | 343 | days.fill( false ); |
342 | days.setBit( startDate.dayOfWeek() - 1 ); | 344 | days.setBit( startDate.dayOfWeek() - 1 ); |
343 | int pos = (startDate.day()/7)+1; | 345 | int pos = (startDate.day()/7)+1; |
344 | r->addMonthlyPos( pos, days ); | 346 | r->addMonthlyPos( pos, days ); |
345 | //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); | 347 | //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); |
346 | //KMessageBox::information(this,mes); | 348 | //KMessageBox::information(this,mes); |
347 | } else if ( rtype == 5 ) { | 349 | } else if ( rtype == 5 ) { |
348 | freq = 1; | 350 | freq = 1; |
349 | if ( hasEndDate ) | 351 | if ( hasEndDate ) |
350 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 352 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
351 | else | 353 | else |
352 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 354 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
353 | r->addYearlyNum( startDate.month() ); | 355 | r->addYearlyNum( startDate.month() ); |
354 | } else if ( true /*rtype == 6*/ ) { | 356 | } else if ( true /*rtype == 6*/ ) { |
355 | // KOganizer cannot handle this in the GUI | 357 | // KOganizer cannot handle this in the GUI |