summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-12 13:32:09 (UTC)
committer zautrix <zautrix>2004-07-12 13:32:09 (UTC)
commit915a3b162dea2755ec1c8267a9c9f65709bce602 (patch) (unidiff)
tree75b3d15a2386a4da7ab790a1f249ff811a7a7ae8
parentcbc789907408fa3359444c464ba5a86be892f301 (diff)
downloadkdepimpi-915a3b162dea2755ec1c8267a9c9f65709bce602.zip
kdepimpi-915a3b162dea2755ec1c8267a9c9f65709bce602.tar.gz
kdepimpi-915a3b162dea2755ec1c8267a9c9f65709bce602.tar.bz2
Another win import fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koimportoldialog.cpp21
-rw-r--r--korganizer/koimportoldialog.h1
2 files changed, 17 insertions, 5 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp
index 36363e5..16f2eca 100644
--- a/korganizer/koimportoldialog.cpp
+++ b/korganizer/koimportoldialog.cpp
@@ -1,96 +1,97 @@
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 <qheader.h> 34#include <qheader.h>
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include <qlistview.h> 36#include <qlistview.h>
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kstandarddirs.h> 40#include <kstandarddirs.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43 43
44#include <libkdepim/categoryselectdialog.h> 44#include <libkdepim/categoryselectdialog.h>
45#include <libkdepim/kinputdialog.h> 45#include <libkdepim/kinputdialog.h>
46 46
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <kabc/stdaddressbook.h>
49 50
50#include "koprefs.h" 51#include "koprefs.h"
51#include "koglobals.h" 52#include "koglobals.h"
52 53
53#include "koimportoldialog.h" 54#include "koimportoldialog.h"
54 55
55#include "../outport/msoutl9.h" 56#include "../outport/msoutl9.h"
56#include <ole2.h> 57#include <ole2.h>
57#include <comutil.h> 58#include <comutil.h>
58_Application gOlApp; 59_Application gOlApp;
59 60
60QDateTime mDdate2Qdtr( DATE dt) 61QDateTime mDdate2Qdtr( DATE dt)
61{ 62{
62 COleDateTime odt; 63 COleDateTime odt;
63 SYSTEMTIME st; 64 SYSTEMTIME st;
64 odt = dt; 65 odt = dt;
65 odt.GetAsSystemTime(st); 66 odt.GetAsSystemTime(st);
66 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); 67 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
67 return qdt; 68 return qdt;
68} 69}
69 70
70class OLEListViewItem : public QCheckListItem 71class OLEListViewItem : public QCheckListItem
71{ 72{
72 public: 73 public:
73 OLEListViewItem( QListView *parent, QString text ) : 74 OLEListViewItem( QListView *parent, QString text ) :
74 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 75 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
75 OLEListViewItem( QListViewItem *after, QString text ) : 76 OLEListViewItem( QListViewItem *after, QString text ) :
76 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 77 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
77 ~OLEListViewItem() {}; 78 ~OLEListViewItem() {};
78 void setData( DWORD data ) {mData= data; }; 79 void setData( DWORD data ) {mData= data; };
79 DWORD data() { return mData ;}; 80 DWORD data() { return mData ;};
80 private: 81 private:
81 DWORD mData; 82 DWORD mData;
82}; 83};
83 84
84KOImportOLdialog::KOImportOLdialog( const QString &caption, 85KOImportOLdialog::KOImportOLdialog( const QString &caption,
85 Calendar *calendar, QWidget *parent ) : 86 Calendar *calendar, QWidget *parent ) :
86 KDialogBase( Plain, caption, User1 | Close, Ok, 87 KDialogBase( Plain, caption, User1 | Close, Ok,
87 parent, caption, true, false, i18n("Import!") ) 88 parent, caption, true, false, i18n("Import!") )
88{ 89{
89 QHBox * mw = new QHBox( this ); 90 QHBox * mw = new QHBox( this );
90 setMainWidget( mw ); 91 setMainWidget( mw );
91 mListView = new QListView( mw ); 92 mListView = new QListView( mw );
92 mListView->addColumn(i18n("Select Folder to import")); 93 mListView->addColumn(i18n("Select Folder to import"));
93 mListView->addColumn(i18n("Content Type")); 94 mListView->addColumn(i18n("Content Type"));
94 mCalendar = calendar; 95 mCalendar = calendar;
95 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); 96 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
96 setupFolderView(); 97 setupFolderView();
@@ -395,72 +396,82 @@ void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRe
395 LPDISPATCH itm; 396 LPDISPATCH itm;
396 int i; 397 int i;
397 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer()); 398 QString optAtt = QString::fromUcs2( aItem->GetOptionalAttendees().GetBuffer());
398 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer()); 399 QString reqAtt = QString::fromUcs2( aItem->GetRequiredAttendees().GetBuffer());
399 //GetRequiredAttendees() 400 //GetRequiredAttendees()
400 for(i=1; i <= mf.GetCount(); ++i) { 401 for(i=1; i <= mf.GetCount(); ++i) {
401 indx = (long)i; 402 indx = (long)i;
402 itm = mf.Item( indx.Detach() ); 403 itm = mf.Item( indx.Detach() );
403 Recipient * pItem = (Recipient *)&itm; 404 Recipient * pItem = (Recipient *)&itm;
404 405
405 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 406 //a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
406 QString name = QString::fromUcs2( pItem->GetName().GetBuffer()); 407 QString name = QString::fromUcs2( pItem->GetName().GetBuffer());
407 KCal::Attendee::PartStat stat; 408 KCal::Attendee::PartStat stat;
408 bool rsvp = false; 409 bool rsvp = false;
409 switch ( pItem->GetMeetingResponseStatus() ) { 410 switch ( pItem->GetMeetingResponseStatus() ) {
410 case 0: //not answered 411 case 0: //not answered
411 rsvp = true; 412 rsvp = true;
412 case 5: //not answered 413 case 5: //not answered
413 stat = Attendee::NeedsAction; 414 stat = Attendee::NeedsAction;
414 break; 415 break;
415 case 1: //organizer 416 case 1: //organizer
416 stat = Attendee::Delegated ; 417 stat = Attendee::Delegated ;
417 break; 418 break;
418 case 2: //tentative 419 case 2: //tentative
419 stat = Attendee::Tentative ; 420 stat = Attendee::Tentative ;
420 break; 421 break;
421 case 3: //accepted 422 case 3: //accepted
422 stat = Attendee::Accepted; 423 stat = Attendee::Accepted;
423 break; 424 break;
424 case 4: //declined 425 case 4: //declined
425 stat =Attendee::Declined ; 426 stat =Attendee::Declined ;
426 break; 427 break;
427 default: 428 default:
428 stat = Attendee::NeedsAction ; 429 stat = Attendee::NeedsAction ;
429 430
430 } 431 }
431 KCal::Attendee::Role role; 432 KCal::Attendee::Role role;
432 if ( event->organizer() == name ) 433 if ( event->organizer() == name )
433 role = KCal::Attendee::Chair; 434 role = KCal::Attendee::Chair;
434 else if ( reqAtt.find( name ) >= 0 ) 435 else if ( reqAtt.find( name ) >= 0 )
435 role = KCal::Attendee::ReqParticipant; 436 role = KCal::Attendee::ReqParticipant;
436 else if ( optAtt.find( name ) >= 0 ) 437 else if ( optAtt.find( name ) >= 0 )
437 role = KCal::Attendee::OptParticipant; 438 role = KCal::Attendee::OptParticipant;
438 else 439 else
439 role = KCal::Attendee::NonParticipant; 440 role = KCal::Attendee::NonParticipant;
440 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer()); 441 QString mail = QString::fromUcs2(pItem->GetAddress().GetBuffer());
441 if( mail.isEmpty() && name.find("@") > 0 ) 442 if( mail.isEmpty() && name.find("@") > 0 )
442 mail = name; 443 mail = name;
443 QString uid;
444 if ( mail.isEmpty() )
445 uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer());
446 else
447 uid = mail;
448 mail = mail.stripWhiteSpace(); 444 mail = mail.stripWhiteSpace();
445
446 QString uid = getUidByEmail( mail );
447 //uid = QString::fromUcs2( pItem->GetEntryID().GetBuffer());
449 KCal::Attendee * a = new KCal::Attendee( name, mail,rsvp,stat,role,uid) ; 448 KCal::Attendee * a = new KCal::Attendee( name, mail,rsvp,stat,role,uid) ;
450 event->addAttendee( a , false ); 449 event->addAttendee( a , false );
451 itm->Release(); 450 itm->Release();
452 } 451 }
453 452
454 453
455 if ( !mCalendar->addEventNoDup( event )) 454 if ( !mCalendar->addEventNoDup( event ))
456 delete event; 455 delete event;
457 else { 456 else {
458 // QString mes = i18n("Importing %1.\n date: %2 date: %3").arg( event->summary()).arg( event->dtStart().toString()).arg( event->dtEnd().toString()); 457 // QString mes = i18n("Importing %1.\n date: %2 date: %3").arg( event->summary()).arg( event->dtStart().toString()).arg( event->dtEnd().toString());
459 //KMessageBox::information(this,mes); 458 //KMessageBox::information(this,mes);
460 ++importedItems; 459 ++importedItems;
461 } 460 }
462} 461}
463void KOImportOLdialog::slotCancel() 462void KOImportOLdialog::slotCancel()
464{ 463{
465 reject(); 464 reject();
466} 465}
466
467QString KOImportOLdialog::getUidByEmail( QString email )
468{
469 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
470 KABC::AddressBook::Iterator it;
471 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
472 QStringList em = (*it).emails();
473 if ( em.contains( email ))
474 return (*it).uid();
475 }
476 return "";
477}
diff --git a/korganizer/koimportoldialog.h b/korganizer/koimportoldialog.h
index f6a753d..c8847c5 100644
--- a/korganizer/koimportoldialog.h
+++ b/korganizer/koimportoldialog.h
@@ -28,56 +28,57 @@
28#include <afxdisp.h> 28#include <afxdisp.h>
29#include <libkcal/calendar.h> 29#include <libkcal/calendar.h>
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32 32
33class QDateTime; 33class QDateTime;
34class QListView; 34class QListView;
35class OLEListViewItem; 35class OLEListViewItem;
36class _AppointmentItem; 36class _AppointmentItem;
37namespace KPIM { class CategorySelectDialog; } 37namespace KPIM { class CategorySelectDialog; }
38 38
39using namespace KCal; 39using namespace KCal;
40 40
41/** 41/**
42 This is the base class for the calendar component editors. 42 This is the base class for the calendar component editors.
43*/ 43*/
44class KOImportOLdialog : public KDialogBase 44class KOImportOLdialog : public KDialogBase
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 /** 48 /**
49 Construct new IncidenceEditor. 49 Construct new IncidenceEditor.
50 */ 50 */
51 KOImportOLdialog( const QString &caption, Calendar *calendar, 51 KOImportOLdialog( const QString &caption, Calendar *calendar,
52 QWidget *parent ); 52 QWidget *parent );
53 virtual ~KOImportOLdialog(); 53 virtual ~KOImportOLdialog();
54 54
55 /** Initialize editor. This function creates the tab widgets. */ 55 /** Initialize editor. This function creates the tab widgets. */
56 void init(); 56 void init();
57 57
58 public slots: 58 public slots:
59 59
60 60
61 signals: 61 signals:
62 62
63 protected slots: 63 protected slots:
64 void slotApply(); 64 void slotApply();
65 void slotOk(); 65 void slotOk();
66 void slotCancel(); 66 void slotCancel();
67 67
68 protected: 68 protected:
69 void setupFolderView(); 69 void setupFolderView();
70 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); 70 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
71 void readCalendarData( DWORD folder ); 71 void readCalendarData( DWORD folder );
72 void ol2kopiCalendar( _AppointmentItem * , bool computeRecurrence = true ); 72 void ol2kopiCalendar( _AppointmentItem * , bool computeRecurrence = true );
73 73
74 Calendar *mCalendar; 74 Calendar *mCalendar;
75 QListView * mListView; 75 QListView * mListView;
76 QString getUidByEmail( QString email );
76 77
77 private: 78 private:
78 int importedItems; 79 int importedItems;
79}; 80};
80 81
81#endif 82#endif
82 83
83 84