summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-20 12:05:18 (UTC)
committer zautrix <zautrix>2004-10-20 12:05:18 (UTC)
commit5cf3c1bce58a6487af166e637e54571e98156fd0 (patch) (unidiff)
tree2e1ba14350aa322bb21729cf462b96e658fa6929 /korganizer
parente2a0df411042d986adb31b28f9e0a2f17395358c (diff)
downloadkdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.zip
kdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.tar.gz
kdepimpi-5cf3c1bce58a6487af166e637e54571e98156fd0.tar.bz2
OL import fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koimportoldialog.cpp3
-rw-r--r--korganizer/mainwindow.cpp8
2 files changed, 9 insertions, 2 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp
index 0a3c2d5..c0bde0d 100644
--- a/korganizer/koimportoldialog.cpp
+++ b/korganizer/koimportoldialog.cpp
@@ -1,445 +1,446 @@
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 <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 <qheader.h> 35#include <qheader.h>
35#include <qdatetime.h> 36#include <qdatetime.h>
36#include <qlistview.h> 37#include <qlistview.h>
37 38
38#include <kdebug.h> 39#include <kdebug.h>
39#include <klocale.h> 40#include <klocale.h>
40#include <kstandarddirs.h> 41#include <kstandarddirs.h>
41#include <kmessagebox.h> 42#include <kmessagebox.h>
42#include <kfiledialog.h> 43#include <kfiledialog.h>
43 44
44#include <libkdepim/categoryselectdialog.h> 45#include <libkdepim/categoryselectdialog.h>
45#include <libkdepim/kinputdialog.h> 46#include <libkdepim/kinputdialog.h>
46 47
47#include <libkcal/calendarlocal.h> 48#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 49#include <libkcal/icalformat.h>
49#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
50 51
51#include "koprefs.h" 52#include "koprefs.h"
52#include "koglobals.h" 53#include "koglobals.h"
53 54
54#include "koimportoldialog.h" 55#include "koimportoldialog.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 gOlApp; 60_Application gOlApp;
60 61
61QDateTime mDdate2Qdtr( DATE dt) 62QDateTime mDdate2Qdtr( DATE dt)
62{ 63{
63 COleDateTime odt; 64 COleDateTime odt;
64 SYSTEMTIME st; 65 SYSTEMTIME st;
65 odt = dt; 66 odt = dt;
66 odt.GetAsSystemTime(st); 67 odt.GetAsSystemTime(st);
67 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 ) );
68 return qdt; 69 return qdt;
69} 70}
70 71
71class OLEListViewItem : public QCheckListItem 72class OLEListViewItem : public QCheckListItem
72{ 73{
73 public: 74 public:
74 OLEListViewItem( QListView *parent, QString text ) : 75 OLEListViewItem( QListView *parent, QString text ) :
75 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 76 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
76 OLEListViewItem( QListViewItem *after, QString text ) : 77 OLEListViewItem( QListViewItem *after, QString text ) :
77 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 78 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
78 ~OLEListViewItem() {}; 79 ~OLEListViewItem() {};
79 void setData( DWORD data ) {mData= data; }; 80 void setData( DWORD data ) {mData= data; };
80 DWORD data() { return mData ;}; 81 DWORD data() { return mData ;};
81 private: 82 private:
82 DWORD mData; 83 DWORD mData;
83}; 84};
84 85
85KOImportOLdialog::KOImportOLdialog( const QString &caption, 86KOImportOLdialog::KOImportOLdialog( const QString &caption,
86 Calendar *calendar, QWidget *parent ) : 87 Calendar *calendar, QWidget *parent ) :
87 KDialogBase( Plain, caption, User1 | Close, Ok, 88 KDialogBase( Plain, caption, User1 | Close, Ok,
88 parent, caption, true, false, i18n("Import!") ) 89 parent, caption, true, false, i18n("Import!") )
89{ 90{
90 QHBox * mw = new QHBox( this ); 91 QHBox * mw = new QHBox( this );
91 setMainWidget( mw ); 92 setMainWidget( mw );
92 mListView = new QListView( mw ); 93 mListView = new QListView( mw );
93 mListView->addColumn(i18n("Select Folder to import")); 94 mListView->addColumn(i18n("Select Folder to import"));
94 mListView->addColumn(i18n("Content Type")); 95 mListView->addColumn(i18n("Content Type"));
95 mCalendar = calendar; 96 mCalendar = calendar;
96 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); 97 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
97 setupFolderView(); 98 setupFolderView();
98 resize( sizeHint().width()+50, sizeHint().height()+50 ); 99 resize( sizeHint().width()+50, sizeHint().height()+50 );
99} 100}
100 101
101KOImportOLdialog::~KOImportOLdialog() 102KOImportOLdialog::~KOImportOLdialog()
102{ 103{
103 104
104} 105}
105 106
106 107
107void KOImportOLdialog::setupFolderView() 108void KOImportOLdialog::setupFolderView()
108{ 109{
109 SCODE sc = ::OleInitialize(NULL); 110 SCODE sc = ::OleInitialize(NULL);
110 if ( FAILED ( sc ) ) { 111 if ( FAILED ( sc ) ) {
111 KMessageBox::information(this,"OLE initialisation failed"); 112 KMessageBox::information(this,"OLE initialisation failed");
112 return; 113 return;
113 } 114 }
114 115
115 if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){ 116 if(!gOlApp.CreateDispatch(_T("Outlook.Application"),NULL)){
116 KMessageBox::information(this,"Sorry, cannot access Outlook"); 117 KMessageBox::information(this,"Sorry, cannot access Outlook");
117 return ; 118 return ;
118 } 119 }
119 MAPIFolder mfInbox; 120 MAPIFolder mfInbox;
120 MAPIFolder mfRoot; 121 MAPIFolder mfRoot;
121 CString szName; 122 CString szName;
122 _NameSpace olNS; 123 _NameSpace olNS;
123 olNS = gOlApp.GetNamespace(_T("MAPI")); 124 olNS = gOlApp.GetNamespace(_T("MAPI"));
124 mfInbox = olNS.GetDefaultFolder(6); 125 mfInbox = olNS.GetDefaultFolder(6);
125 mfRoot = mfInbox.GetParent(); 126 mfRoot = mfInbox.GetParent();
126 szName = mfRoot.GetName(); 127 szName = mfRoot.GetName();
127 long iType = mfRoot.GetDefaultItemType(); 128 long iType = mfRoot.GetDefaultItemType();
128 QString mes; 129 QString mes;
129 mes = QString::fromUcs2( szName.GetBuffer() ); 130 mes = QString::fromUcs2( szName.GetBuffer() );
130 OLEListViewItem * root = new OLEListViewItem( mListView, mes ); 131 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
131 mfRoot.m_lpDispatch->AddRef(); 132 mfRoot.m_lpDispatch->AddRef();
132 addFolder( root, mfRoot.m_lpDispatch ); 133 addFolder( root, mfRoot.m_lpDispatch );
133 root->setOpen( true ); 134 root->setOpen( true );
134 mListView->setSortColumn( 0 ); 135 mListView->setSortColumn( 0 );
135 mListView->sort( ); 136 mListView->sort( );
136} 137}
137 138
138 139
139void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) 140void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
140{ 141{
141 MAPIFolder mfParent(dispParent), mfChild; 142 MAPIFolder mfParent(dispParent), mfChild;
142 _Folders folders; 143 _Folders folders;
143 _variant_t fndx((long)0); 144 _variant_t fndx((long)0);
144 CString szName; 145 CString szName;
145 long iType; 146 long iType;
146 OLEListViewItem* hChild; 147 OLEListViewItem* hChild;
147 148
148 folders = mfParent.GetFolders(); 149 folders = mfParent.GetFolders();
149 for(int i=1; i <= folders.GetCount(); ++i) 150 for(int i=1; i <= folders.GetCount(); ++i)
150 { 151 {
151 fndx = (long)i; 152 fndx = (long)i;
152 mfChild = folders.Item(fndx.Detach()); 153 mfChild = folders.Item(fndx.Detach());
153 mfChild.m_lpDispatch->AddRef(); 154 mfChild.m_lpDispatch->AddRef();
154 szName = mfChild.GetName(); 155 szName = mfChild.GetName();
155 iType = mfChild.GetDefaultItemType(); 156 iType = mfChild.GetDefaultItemType();
156 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); 157 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
157 if ( iType != 1) 158 if ( iType != 1)
158 hChild->setEnabled( false ); 159 hChild->setEnabled( false );
159 QString ts; 160 QString ts;
160 switch( iType ) { 161 switch( iType ) {
161 case 0: 162 case 0:
162 ts = i18n("Mail"); 163 ts = i18n("Mail");
163 break; 164 break;
164 case 1: 165 case 1:
165 ts = i18n("Calendar"); 166 ts = i18n("Calendar");
166 break; 167 break;
167 case 2: 168 case 2:
168 ts = i18n("Contacts"); 169 ts = i18n("Contacts");
169 break; 170 break;
170 case 3: 171 case 3:
171 ts = i18n("Todos"); 172 ts = i18n("Todos");
172 break; 173 break;
173 case 4: 174 case 4:
174 ts = i18n("Journals"); 175 ts = i18n("Journals");
175 break; 176 break;
176 case 5: 177 case 5:
177 ts = i18n("Notes"); 178 ts = i18n("Notes");
178 break; 179 break;
179 default: 180 default:
180 ts = i18n("Unknown"); 181 ts = i18n("Unknown");
181 } 182 }
182 hChild->setText( 1,ts); 183 hChild->setText( 1,ts);
183 hChild->setData( (DWORD) mfChild.m_lpDispatch ); 184 hChild->setData( (DWORD) mfChild.m_lpDispatch );
184 mfChild.m_lpDispatch->AddRef(); 185 mfChild.m_lpDispatch->AddRef();
185 addFolder(hChild, mfChild.m_lpDispatch); 186 addFolder(hChild, mfChild.m_lpDispatch);
186 } 187 }
187} 188}
188 189
189void KOImportOLdialog::slotApply() 190void KOImportOLdialog::slotApply()
190{ 191{
191 importedItems = 0; 192 importedItems = 0;
192 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); 193 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
193 while ( child ) { 194 while ( child ) {
194 if ( child->isOn() ) 195 if ( child->isOn() )
195 readCalendarData( child->data() ); 196 readCalendarData( child->data() );
196 child = (OLEListViewItem*) child->itemBelow(); 197 child = (OLEListViewItem*) child->itemBelow();
197 } 198 }
198 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);
199 KMessageBox::information(this,mes); 200 KMessageBox::information(this,mes);
200} 201}
201void KOImportOLdialog::readCalendarData( DWORD folder ) 202void KOImportOLdialog::readCalendarData( DWORD folder )
202{ 203{
203 204
204 LPDISPATCH dispItem = (LPDISPATCH)folder; 205 LPDISPATCH dispItem = (LPDISPATCH)folder;
205 dispItem->AddRef(); 206 dispItem->AddRef();
206 MAPIFolder mf(dispItem); 207 MAPIFolder mf(dispItem);
207 mf.m_lpDispatch->AddRef(); 208 mf.m_lpDispatch->AddRef();
208 _Items folderItems; 209 _Items folderItems;
209 _variant_t indx((long)0); 210 _variant_t indx((long)0);
210 LPDISPATCH itm; 211 LPDISPATCH itm;
211 int i; 212 int i;
212 folderItems = mf.GetItems(); 213 folderItems = mf.GetItems();
213 QProgressBar bar( folderItems.GetCount(),0 ); 214 QProgressBar bar( folderItems.GetCount(),0 );
214 bar.setCaption (i18n("Importing - close to abort!") ); 215 bar.setCaption (i18n("Importing - close to abort!") );
215 int h = bar.sizeHint().height() ; 216 int h = bar.sizeHint().height() ;
216 int w = 300; 217 int w = 300;
217 int dw = QApplication::desktop()->width(); 218 int dw = QApplication::desktop()->width();
218 int dh = QApplication::desktop()->height(); 219 int dh = QApplication::desktop()->height();
219 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
220 bar.show(); 221 bar.show();
221 for(i=1; i <= folderItems.GetCount(); ++i) 222 for(i=1; i <= folderItems.GetCount(); ++i)
222 { 223 {
223 qApp->processEvents(); 224 qApp->processEvents();
224 if ( ! bar.isVisible() ) 225 if ( ! bar.isVisible() )
225 return ; 226 return ;
226 bar.setProgress( i ); 227 bar.setProgress( i );
227 indx = (long)i; 228 indx = (long)i;
228 itm = folderItems.Item(indx.Detach()); 229 itm = folderItems.Item(indx.Detach());
229 _AppointmentItem * pItem = (_AppointmentItem *)&itm; 230 _AppointmentItem * pItem = (_AppointmentItem *)&itm;
230 ol2kopiCalendar( pItem ); 231 ol2kopiCalendar( pItem );
231 itm->Release(); 232 itm->Release();
232 } 233 }
233} 234}
234void KOImportOLdialog::slotOk() 235void KOImportOLdialog::slotOk()
235{ 236{
236 QDialog::accept(); 237 QDialog::accept();
237} 238}
238 239
239void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) 240void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence )
240{ 241{
241 KCal::Event* event = new KCal::Event(); 242 KCal::Event* event = new KCal::Event();
242 if ( aItem->GetAllDayEvent() ){ 243 if ( aItem->GetAllDayEvent() ){
243 event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); 244 event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) ));
244 event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); 245 event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1));
245 event->setFloats( true ); 246 event->setFloats( true );
246 } else { 247 } else {
247 event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); 248 event->setDtStart( mDdate2Qdtr( aItem->GetStart()) );
248 event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); 249 event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) );
249 event->setFloats( false ); 250 event->setFloats( false );
250 } 251 }
251 event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); 252 event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) );
252 event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); 253 event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) );
253 event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()) ); 254 event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") );
254 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); 255 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer());
255 event->setCategories( QStringList::split( ";", cat )); 256 event->setCategories( QStringList::split( ";", cat ));
256 if ( aItem->GetReminderSet() ) { 257 if ( aItem->GetReminderSet() ) {
257 event->clearAlarms(); 258 event->clearAlarms();
258 Alarm* alarm = event->newAlarm(); 259 Alarm* alarm = event->newAlarm();
259 alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); 260 alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 );
260 alarm->setEnabled( true ); 261 alarm->setEnabled( true );
261 if ( aItem->GetReminderPlaySound() ) { 262 if ( aItem->GetReminderPlaySound() ) {
262 alarm->setType( Alarm::Audio ); 263 alarm->setType( Alarm::Audio );
263 alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); 264 alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer()));
264 } 265 }
265 else 266 else
266 alarm->setType( Alarm::Display ); 267 alarm->setType( Alarm::Display );
267 alarm->setRepeatCount( aItem->GetReplyTime() ); 268 alarm->setRepeatCount( aItem->GetReplyTime() );
268 } 269 }
269 // OL :pub 0 - pers 1 - priv 2 - conf 3 270 // OL :pub 0 - pers 1 - priv 2 - conf 3
270 // KO : pub 0 - priv 1 - conf 2 271 // KO : pub 0 - priv 1 - conf 2
271 int sec = aItem->GetSensitivity() ; 272 int sec = aItem->GetSensitivity() ;
272 if ( sec > 1 )// mapping pers -> private 273 if ( sec > 1 )// mapping pers -> private
273 --sec; 274 --sec;
274 event->setSecrecy( sec ); 275 event->setSecrecy( sec );
275 if ( aItem->GetBusyStatus() == 0 ) 276 if ( aItem->GetBusyStatus() == 0 )
276 event->setTransparency( Event::Transparent);// OL free 277 event->setTransparency( Event::Transparent);// OL free
277 else 278 else
278 event->setTransparency( Event::Opaque);//OL all other 279 event->setTransparency( Event::Opaque);//OL all other
279 280
280 if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur 281 if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur
281 282
282 RecurrencePattern recpat = aItem->GetRecurrencePattern(); 283 RecurrencePattern recpat = aItem->GetRecurrencePattern();
283 284
284 QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); 285 QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date();
285 int freq = recpat.GetInterval(); 286 int freq = recpat.GetInterval();
286 287
287 bool hasEndDate = !recpat.GetNoEndDate(); 288 bool hasEndDate = !recpat.GetNoEndDate();
288 QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); 289 QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date();
289 QBitArray weekDays( 7 ); 290 QBitArray weekDays( 7 );
290 weekDays.fill(false ); 291 weekDays.fill(false );
291 uint weekDaysNum = recpat.GetDayOfWeekMask(); 292 uint weekDaysNum = recpat.GetDayOfWeekMask();
292 int i; 293 int i;
293 int bb = 2; 294 int bb = 2;
294 for( i = 1; i <= 6; ++i ) { 295 for( i = 1; i <= 6; ++i ) {
295 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 296 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
296 bb = 4 << (i-1); 297 bb = 4 << (i-1);
297 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 298 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
298 } 299 }
299 if ( 1 & weekDaysNum) 300 if ( 1 & weekDaysNum)
300 weekDays.setBit( 6 ); 301 weekDays.setBit( 6 );
301 // int pos = 1;// pending 302 // int pos = 1;// pending
302 303
303 Recurrence *r = event->recurrence(); 304 Recurrence *r = event->recurrence();
304 int rtype = recpat.GetRecurrenceType(); 305 int rtype = recpat.GetRecurrenceType();
305 //recurrence types are: 306 //recurrence types are:
306 /* 307 /*
307 olRecursDaily(0) 308 olRecursDaily(0)
308 olRecursWeekly(1) 309 olRecursWeekly(1)
309 olRecursMonthly(2) 310 olRecursMonthly(2)
310 olRecursMonthNth(3) 311 olRecursMonthNth(3)
311 olRecursYearly(5) 312 olRecursYearly(5)
312 olRecursYearNth(6) 313 olRecursYearNth(6)
313 */ 314 */
314 315
315 int duration = recpat.GetOccurrences(); 316 int duration = recpat.GetOccurrences();
316 if ( !hasEndDate ) 317 if ( !hasEndDate )
317 duration = -1; 318 duration = -1;
318 319
319 //LPDISPATCH RecurrencePattern::GetExceptions() 320 //LPDISPATCH RecurrencePattern::GetExceptions()
320 //long RecurrencePattern::GetMonthOfYear() 321 //long RecurrencePattern::GetMonthOfYear()
321 if ( rtype == 0 ) { 322 if ( rtype == 0 ) {
322 if ( hasEndDate ) r->setDaily( freq, endDate ); 323 if ( hasEndDate ) r->setDaily( freq, endDate );
323 else r->setDaily( freq, duration ); 324 else r->setDaily( freq, duration );
324 } else if ( rtype == 1 ) { 325 } else if ( rtype == 1 ) {
325 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 326 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
326 else r->setWeekly( freq, weekDays, duration ); 327 else r->setWeekly( freq, weekDays, duration );
327 } else if ( rtype == 2 ) { 328 } else if ( rtype == 2 ) {
328 if ( hasEndDate ) 329 if ( hasEndDate )
329 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 330 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
330 else 331 else
331 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 332 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
332 //r->addMonthlyDay( startDate.day() ); 333 //r->addMonthlyDay( startDate.day() );
333 r->addMonthlyDay( recpat.GetDayOfMonth() ); 334 r->addMonthlyDay( recpat.GetDayOfMonth() );
334 } else if ( rtype == 3 ) { 335 } else if ( rtype == 3 ) {
335 if ( hasEndDate ) 336 if ( hasEndDate )
336 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 337 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
337 else 338 else
338 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 339 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
339 QBitArray days( 7 ); 340 QBitArray days( 7 );
340 days.fill( false ); 341 days.fill( false );
341 days.setBit( startDate.dayOfWeek() - 1 ); 342 days.setBit( startDate.dayOfWeek() - 1 );
342 int pos = (startDate.day()/7)+1; 343 int pos = (startDate.day()/7)+1;
343 r->addMonthlyPos( pos, days ); 344 r->addMonthlyPos( pos, days );
344 //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); 345 //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1);
345 //KMessageBox::information(this,mes); 346 //KMessageBox::information(this,mes);
346 } else if ( rtype == 5 ) { 347 } else if ( rtype == 5 ) {
347 freq = 1; 348 freq = 1;
348 if ( hasEndDate ) 349 if ( hasEndDate )
349 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 350 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
350 else 351 else
351 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 352 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
352 r->addYearlyNum( startDate.month() ); 353 r->addYearlyNum( startDate.month() );
353 } else if ( true /*rtype == 6*/ ) { 354 } else if ( true /*rtype == 6*/ ) {
354 // KOganizer cannot handle this in the GUI 355 // KOganizer cannot handle this in the GUI
355 // we are mapping this to monthly - every 12. month 356 // we are mapping this to monthly - every 12. month
356 freq = 12; 357 freq = 12;
357 if ( hasEndDate ) 358 if ( hasEndDate )
358 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 359 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
359 else 360 else
360 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 361 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
361 QBitArray days( 7 ); 362 QBitArray days( 7 );
362 days.fill( false ); 363 days.fill( false );
363 days.setBit( startDate.dayOfWeek() - 1 ); 364 days.setBit( startDate.dayOfWeek() - 1 );
364 int pos = (startDate.day()/7)+1; 365 int pos = (startDate.day()/7)+1;
365 r->addMonthlyPos( pos, days ); 366 r->addMonthlyPos( pos, days );
366 } 367 }
367 // recurrence exceptions 368 // recurrence exceptions
368 LPDISPATCH dispItem = recpat.GetExceptions(); 369 LPDISPATCH dispItem = recpat.GetExceptions();
369 dispItem->AddRef(); 370 dispItem->AddRef();
370 Exceptions ex(dispItem); 371 Exceptions ex(dispItem);
371 _variant_t indx((long)0); 372 _variant_t indx((long)0);
372 LPDISPATCH itm; 373 LPDISPATCH itm;
373 for(i=1; i <= ex.GetCount(); ++i) { 374 for(i=1; i <= ex.GetCount(); ++i) {
374 indx = (long)i; 375 indx = (long)i;
375 itm = ex.Item( indx.Detach() ); 376 itm = ex.Item( indx.Detach() );
376 ::Exception * pItem = (::Exception *)&itm; 377 ::Exception * pItem = (::Exception *)&itm;
377 event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() ); 378 event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() );
378 if ( !pItem->GetDeleted() ) { 379 if ( !pItem->GetDeleted() ) {
379 LPDISPATCH appIt = pItem->GetAppointmentItem(); 380 LPDISPATCH appIt = pItem->GetAppointmentItem();
380 _AppointmentItem * paItem = (_AppointmentItem *)&appIt; 381 _AppointmentItem * paItem = (_AppointmentItem *)&appIt;
381 ol2kopiCalendar( paItem, false ); 382 ol2kopiCalendar( paItem, false );
382 } 383 }
383 itm->Release(); 384 itm->Release();
384 } 385 }
385 } 386 }
386 // recurrence ENTE 387 // recurrence ENTE
387 event->setOrganizer( QString::fromUcs2( aItem->GetOrganizer().GetBuffer())); 388 event->setOrganizer( QString::fromUcs2( aItem->GetOrganizer().GetBuffer()));
388 389
389 //GetOptionalAttendees() 390 //GetOptionalAttendees()
390 //GetRequiredAttendees() 391 //GetRequiredAttendees()
391 LPDISPATCH dispItem = aItem->GetRecipients(); 392 LPDISPATCH dispItem = aItem->GetRecipients();
392 dispItem->AddRef(); 393 dispItem->AddRef();
393 _Folders mf(dispItem); 394 _Folders mf(dispItem);
394 mf.m_lpDispatch->AddRef(); 395 mf.m_lpDispatch->AddRef();
395 _variant_t indx((long)0); 396 _variant_t indx((long)0);
396 LPDISPATCH itm; 397 LPDISPATCH itm;
397 int i; 398 int i;
398 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer()); 399 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer());
399 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer()); 400 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer());
400 //GetRequiredAttendees() 401 //GetRequiredAttendees()
401 for(i=1; i <= mf.GetCount(); ++i) { 402 for(i=1; i <= mf.GetCount(); ++i) {
402 indx = (long)i; 403 indx = (long)i;
403 itm = mf.Item( indx.Detach() ); 404 itm = mf.Item( indx.Detach() );
404 Recipient * pItem = (Recipient *)&itm; 405 Recipient * pItem = (Recipient *)&itm;
405 406
406 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 407 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
407 QString name = QString::fromUcs2( pItem->GetName().GetBuffer()); 408 QString name = QString::fromUcs2( pItem->GetName().GetBuffer());
408 KCal::Attendee::PartStat stat; 409 KCal::Attendee::PartStat stat;
409 bool rsvp = false; 410 bool rsvp = false;
410 switch ( pItem->GetMeetingResponseStatus() ) { 411 switch ( pItem->GetMeetingResponseStatus() ) {
411 case 0: //not answered 412 case 0: //not answered
412 rsvp = true; 413 rsvp = true;
413 case 5: //not answered 414 case 5: //not answered
414 stat = Attendee::NeedsAction; 415 stat = Attendee::NeedsAction;
415 break; 416 break;
416 case 1: //organizer 417 case 1: //organizer
417 stat = Attendee::Delegated ; 418 stat = Attendee::Delegated ;
418 break; 419 break;
419 case 2: //tentative 420 case 2: //tentative
420 stat = Attendee::Tentative ; 421 stat = Attendee::Tentative ;
421 break; 422 break;
422 case 3: //accepted 423 case 3: //accepted
423 stat = Attendee::Accepted; 424 stat = Attendee::Accepted;
424 break; 425 break;
425 case 4: //declined 426 case 4: //declined
426 stat =Attendee::Declined ; 427 stat =Attendee::Declined ;
427 break; 428 break;
428 default: 429 default:
429 stat = Attendee::NeedsAction ; 430 stat = Attendee::NeedsAction ;
430 431
431 } 432 }
432 KCal::Attendee::Role role; 433 KCal::Attendee::Role role;
433 if ( event->organizer() == name ) 434 if ( event->organizer() == name )
434 role = KCal::Attendee::Chair; 435 role = KCal::Attendee::Chair;
435 else if ( reqAtt.find( name ) >= 0 ) 436 else if ( reqAtt.find( name ) >= 0 )
436 role = KCal::Attendee::ReqParticipant; 437 role = KCal::Attendee::ReqParticipant;
437 else if ( optAtt.find( name ) >= 0 ) 438 else if ( optAtt.find( name ) >= 0 )
438 role = KCal::Attendee::OptParticipant; 439 role = KCal::Attendee::OptParticipant;
439 else 440 else
440 role = KCal::Attendee::NonParticipant; 441 role = KCal::Attendee::NonParticipant;
441 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer()); 442 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer());
442 if( mail.isEmpty() && name.find("@") > 0 ) { 443 if( mail.isEmpty() && name.find("@") > 0 ) {
443 int kl = name.find("<"); 444 int kl = name.find("<");
444 int gr = name.find(">"); 445 int gr = name.find(">");
445 if ( kl >= 0 && gr >= 0) { 446 if ( kl >= 0 && gr >= 0) {
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9e215b9..63484d6 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -99,403 +99,409 @@ class KOex2phonePrefs : public QDialog
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
232 } 232 }
233 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
238 238
239 239
240 connect( mView, SIGNAL( tempDisableBR(bool) ), 240 connect( mView, SIGNAL( tempDisableBR(bool) ),
241 SLOT( disableBR(bool) ) ); 241 SLOT( disableBR(bool) ) );
242 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 242 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
243 mView->setModified( false ); 243 mView->setModified( false );
244 mBlockAtStartup = false; 244 mBlockAtStartup = false;
245 mView->setModified( false ); 245 mView->setModified( false );
246 setCentralWidget( mView ); 246 setCentralWidget( mView );
247 globalFlagBlockStartup = 0; 247 globalFlagBlockStartup = 0;
248 mView->show(); 248 mView->show();
249 delete splash; 249 delete splash;
250 if ( newFile ) 250 if ( newFile )
251 mView->updateConfig(); 251 mView->updateConfig();
252 // qApp->processEvents(); 252 // qApp->processEvents();
253 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 253 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
254 //fillSyncMenu(); 254 //fillSyncMenu();
255 255
256 256
257 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 257 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
258 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 258 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
259 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 259 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
260 mSyncManager->setDefaultFileName( defaultFileName()); 260 mSyncManager->setDefaultFileName( defaultFileName());
261 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 261 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
262 mSyncManager->fillSyncMenu(); 262 mSyncManager->fillSyncMenu();
263 263
264 264
265 265
266 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 266 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
267 if ( showWarning ) { 267 if ( showWarning ) {
268 KMessageBox::information( this, 268 KMessageBox::information( this,
269 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 269 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
270 qApp->processEvents(); 270 qApp->processEvents();
271 mView->dialogManager()->showSyncOptions(); 271 mView->dialogManager()->showSyncOptions();
272 } 272 }
273 273
274 //US listen for result adressed from Ka/Pi 274 //US listen for result adressed from Ka/Pi
275#ifndef DESKTOP_VERSION 275#ifndef DESKTOP_VERSION
276 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 276 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
277#endif 277#endif
278#ifndef DESKTOP_VERSION 278#ifndef DESKTOP_VERSION
279 infrared = 0; 279 infrared = 0;
280#endif 280#endif
281 281
282 mBRdisabled = false; 282 mBRdisabled = false;
283 toggleBeamReceive(); 283 toggleBeamReceive();
284} 284}
285MainWindow::~MainWindow() 285MainWindow::~MainWindow()
286{ 286{
287 //qDebug("MainWindow::~MainWindow() "); 287 //qDebug("MainWindow::~MainWindow() ");
288 //save toolbar location 288 //save toolbar location
289 delete mCalendar; 289 delete mCalendar;
290 delete mSyncManager; 290 delete mSyncManager;
291#ifndef DESKTOP_VERSION
291 if ( infrared ) 292 if ( infrared )
292 delete infrared; 293 delete infrared;
294#endif
293 295
294 296
295} 297}
296 298
297void MainWindow::disableBR(bool b) 299void MainWindow::disableBR(bool b)
298{ 300{
301#ifndef DESKTOP_VERSION
299 if ( b ) { 302 if ( b ) {
300 if ( infrared ) { 303 if ( infrared ) {
301 toggleBeamReceive(); 304 toggleBeamReceive();
302 mBRdisabled = true; 305 mBRdisabled = true;
303 } 306 }
307 mBRdisabled = true;
304 } else { 308 } else {
305 if ( mBRdisabled ) { 309 if ( mBRdisabled ) {
306 mBRdisabled = false; 310 mBRdisabled = false;
307 toggleBeamReceive(); 311 //makes no sense,because other cal ap is probably running
312 // toggleBeamReceive();
308 } 313 }
309 } 314 }
315#endif
310 316
311} 317}
312bool MainWindow::beamReceiveEnabled() 318bool MainWindow::beamReceiveEnabled()
313{ 319{
314#ifndef DESKTOP_VERSION 320#ifndef DESKTOP_VERSION
315 return ( infrared != 0 ); 321 return ( infrared != 0 );
316#endif 322#endif
317 return false; 323 return false;
318} 324}
319 325
320void MainWindow::toggleBeamReceive() 326void MainWindow::toggleBeamReceive()
321{ 327{
322 if ( mBRdisabled ) 328 if ( mBRdisabled )
323 return; 329 return;
324#ifndef DESKTOP_VERSION 330#ifndef DESKTOP_VERSION
325 if ( infrared ) { 331 if ( infrared ) {
326 qDebug("disable BeamReceive "); 332 qDebug("disable BeamReceive ");
327 delete infrared; 333 delete infrared;
328 infrared = 0; 334 infrared = 0;
329 brAction->setOn(false); 335 brAction->setOn(false);
330 return; 336 return;
331 } 337 }
332 qDebug("enable BeamReceive "); 338 qDebug("enable BeamReceive ");
333 brAction->setOn(true); 339 brAction->setOn(true);
334 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 340 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
335 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 341 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
336#endif 342#endif
337} 343}
338void MainWindow::showMaximized () 344void MainWindow::showMaximized ()
339{ 345{
340#ifndef DESKTOP_VERSION 346#ifndef DESKTOP_VERSION
341 if ( ! globalFlagBlockStartup ) 347 if ( ! globalFlagBlockStartup )
342 if ( mClosed ) 348 if ( mClosed )
343 mView->goToday(); 349 mView->goToday();
344#endif 350#endif
345 QWidget::showMaximized () ; 351 QWidget::showMaximized () ;
346 mClosed = false; 352 mClosed = false;
347} 353}
348void MainWindow::closeEvent( QCloseEvent* ce ) 354void MainWindow::closeEvent( QCloseEvent* ce )
349{ 355{
350 356
351 357
352 358
353 if ( ! KOPrefs::instance()->mAskForQuit ) { 359 if ( ! KOPrefs::instance()->mAskForQuit ) {
354 saveOnClose(); 360 saveOnClose();
355 mClosed = true; 361 mClosed = true;
356 ce->accept(); 362 ce->accept();
357 return; 363 return;
358 364
359 } 365 }
360 366
361 switch( QMessageBox::information( this, "KO/Pi", 367 switch( QMessageBox::information( this, "KO/Pi",
362 i18n("Do you really want\nto close KO/Pi?"), 368 i18n("Do you really want\nto close KO/Pi?"),
363 i18n("Close"), i18n("No"), 369 i18n("Close"), i18n("No"),
364 0, 0 ) ) { 370 0, 0 ) ) {
365 case 0: 371 case 0:
366 saveOnClose(); 372 saveOnClose();
367 mClosed = true; 373 mClosed = true;
368 ce->accept(); 374 ce->accept();
369 break; 375 break;
370 case 1: 376 case 1:
371 ce->ignore(); 377 ce->ignore();
372 break; 378 break;
373 case 2: 379 case 2:
374 380
375 default: 381 default:
376 break; 382 break;
377 } 383 }
378 384
379 385
380} 386}
381 387
382void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 388void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
383{ 389{
384 QDataStream stream( data, IO_ReadOnly ); 390 QDataStream stream( data, IO_ReadOnly );
385 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 391 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
386 //QString datamess; 392 //QString datamess;
387 //qDebug("message "); 393 //qDebug("message ");
388 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 394 qDebug("KO: QCOP message received: %s ", cmsg.data() );
389 395
390 if ( cmsg == "setDocument(QString)" ) { 396 if ( cmsg == "setDocument(QString)" ) {
391 QDataStream stream( data, IO_ReadOnly ); 397 QDataStream stream( data, IO_ReadOnly );
392 QString fileName; 398 QString fileName;
393 stream >> fileName; 399 stream >> fileName;
394 //qDebug("filename %s ", fileName.latin1()); 400 //qDebug("filename %s ", fileName.latin1());
395 showMaximized(); 401 showMaximized();
396 raise(); 402 raise();
397 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 403 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
398 mSyncManager->slotSyncMenu( 1002 ); 404 mSyncManager->slotSyncMenu( 1002 );
399 return; 405 return;
400 } 406 }
401 407
402 if ( cmsg == "-writeFile" ) { 408 if ( cmsg == "-writeFile" ) {
403 // I made from the "-writeFile" an "-writeAlarm" 409 // I made from the "-writeFile" an "-writeAlarm"
404 mView->viewManager()->showWhatsNextView(); 410 mView->viewManager()->showWhatsNextView();
405 mCalendar->checkAlarmForIncidence( 0, true); 411 mCalendar->checkAlarmForIncidence( 0, true);
406 showMaximized(); 412 showMaximized();
407 raise(); 413 raise();
408 return; 414 return;
409 415
410 } 416 }
411 if ( cmsg == "-writeFileSilent" ) { 417 if ( cmsg == "-writeFileSilent" ) {
412 // I made from the "-writeFile" an "-writeAlarm" 418 // I made from the "-writeFile" an "-writeAlarm"
413 // mView->viewManager()->showWhatsNextView(); 419 // mView->viewManager()->showWhatsNextView();
414 mCalendar->checkAlarmForIncidence( 0, true); 420 mCalendar->checkAlarmForIncidence( 0, true);
415 //showMaximized(); 421 //showMaximized();
416 //raise(); 422 //raise();
417 hide(); 423 hide();
418 return; 424 return;
419 } 425 }
420 if ( cmsg == "-newCountdown" ) { 426 if ( cmsg == "-newCountdown" ) {
421 qDebug("newCountdown "); 427 qDebug("newCountdown ");
422 428
423 } 429 }
424 QString msg ; 430 QString msg ;
425 QString allmsg = cmsg; 431 QString allmsg = cmsg;
426 while ( allmsg.length() > 0 ) { 432 while ( allmsg.length() > 0 ) {
427 int nextC = allmsg.find( "-", 1 ); 433 int nextC = allmsg.find( "-", 1 );
428 if ( nextC == -1 ) { 434 if ( nextC == -1 ) {
429 msg = allmsg; 435 msg = allmsg;
430 allmsg = ""; 436 allmsg = "";
431 } else{ 437 } else{
432 msg = allmsg.left( nextC ); 438 msg = allmsg.left( nextC );
433 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 439 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
434 } 440 }
435 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 441 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
436 if ( msg == "-newEvent" ) { 442 if ( msg == "-newEvent" ) {
437 mView->newEvent(); 443 mView->newEvent();
438 } 444 }
439 if ( msg == "-newTodo" ) { 445 if ( msg == "-newTodo" ) {
440 mView->newTodo(); 446 mView->newTodo();
441 447
442 } 448 }
443 if ( msg == "-showWN" ) { 449 if ( msg == "-showWN" ) {
444 mView->viewManager()->showWhatsNextView(); 450 mView->viewManager()->showWhatsNextView();
445 } 451 }
446 if ( msg == "-showTodo" ) { 452 if ( msg == "-showTodo" ) {
447 mView->viewManager()->showTodoView(); 453 mView->viewManager()->showTodoView();
448 } 454 }
449 if ( msg == "-showList" ) { 455 if ( msg == "-showList" ) {
450 mView->viewManager()->showListView(); 456 mView->viewManager()->showListView();
451 } 457 }
452 else if ( msg == "-showDay" ) { 458 else if ( msg == "-showDay" ) {
453 mView->viewManager()->showDayView(); 459 mView->viewManager()->showDayView();
454 } 460 }
455 else if ( msg == "-showWWeek" ) { 461 else if ( msg == "-showWWeek" ) {
456 mView->viewManager()->showWorkWeekView(); 462 mView->viewManager()->showWorkWeekView();
457 } 463 }
458 else if ( msg == "-ringSync" ) { 464 else if ( msg == "-ringSync" ) {
459 mSyncManager->multiSync( false ); 465 mSyncManager->multiSync( false );
460 } 466 }
461 else if ( msg == "-showWeek" ) { 467 else if ( msg == "-showWeek" ) {
462 mView->viewManager()->showWeekView(); 468 mView->viewManager()->showWeekView();
463 } 469 }
464 else if ( msg == "-showTodo" ) { 470 else if ( msg == "-showTodo" ) {
465 mView->viewManager()->showTodoView(); 471 mView->viewManager()->showTodoView();
466 } 472 }
467 else if ( msg == "-showJournal" ) { 473 else if ( msg == "-showJournal" ) {
468 mView->dateNavigator()->selectDates( 1 ); 474 mView->dateNavigator()->selectDates( 1 );
469 mView->dateNavigator()->selectToday(); 475 mView->dateNavigator()->selectToday();
470 mView->viewManager()->showJournalView(); 476 mView->viewManager()->showJournalView();
471 } 477 }
472 else if ( msg == "-showKO" ) { 478 else if ( msg == "-showKO" ) {
473 mView->viewManager()->showNextXView(); 479 mView->viewManager()->showNextXView();
474 } 480 }
475 else if ( msg == "-showWNext" || msg == "nextView()" ) { 481 else if ( msg == "-showWNext" || msg == "nextView()" ) {
476 mView->viewManager()->showWhatsNextView(); 482 mView->viewManager()->showWhatsNextView();
477 } 483 }
478 else if ( msg == "-showNextXView" ) { 484 else if ( msg == "-showNextXView" ) {
479 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
480 } 486 }
481 487
482 488
483 } 489 }
484 490
485 showMaximized(); 491 showMaximized();
486 raise(); 492 raise();
487} 493}
488 494
489QPixmap MainWindow::loadPixmap( QString name ) 495QPixmap MainWindow::loadPixmap( QString name )
490{ 496{
491 return SmallIcon( name ); 497 return SmallIcon( name );
492 498
493} 499}
494void MainWindow::initActions() 500void MainWindow::initActions()
495{ 501{
496 //KOPrefs::instance()->mShowFullMenu 502 //KOPrefs::instance()->mShowFullMenu
497 iconToolBar->clear(); 503 iconToolBar->clear();
498 KOPrefs *p = KOPrefs::instance(); 504 KOPrefs *p = KOPrefs::instance();
499 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 505 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
500 506
501 QPopupMenu *viewMenu = new QPopupMenu( this ); 507 QPopupMenu *viewMenu = new QPopupMenu( this );