summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaimportoldialog.cpp
authorzautrix <zautrix>2005-06-29 21:43:21 (UTC)
committer zautrix <zautrix>2005-06-29 21:43:21 (UTC)
commit54dd512d3980381c2b02263462db03ae7c5a0264 (patch) (side-by-side diff)
tree82a31315a85ad5e0a95ef37274fa96f7c4a88dfa /kaddressbook/kaimportoldialog.cpp
parent7ccfe9b674bd5cc52eab708c2e7dfb02c3328deb (diff)
downloadkdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.zip
kdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.tar.gz
kdepimpi-54dd512d3980381c2b02263462db03ae7c5a0264.tar.bz2
fixxx
Diffstat (limited to 'kaddressbook/kaimportoldialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaimportoldialog.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 7bb8bd8..2f794d6 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -1,92 +1,93 @@
/*
This file is part of KAddressbook/Pi.
Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qprogressbar.h>
+#include <qprogressdialog.h>
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qdir.h>
#include <qregexp.h>
#include <qapplication.h>
#include <qhbox.h>
#include <qheader.h>
#include <qdatetime.h>
#include <qlistview.h>
#include <kdebug.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkdepim/kinputdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
#include <kabc/addresseelist.h>
#include <kabc/phonenumber.h>
#include "kaimportoldialog.h"
#include "../outport/msoutl9.h"
#include <ole2.h>
#include <comutil.h>
_Application gOlAppAB;
QDateTime mDdate2Qdtr( DATE dt)
{
COleDateTime odt;
SYSTEMTIME st;
odt = dt;
if ( odt.GetStatus() != 0 )
return QDateTime();
odt.GetAsSystemTime(st);
if ( st.wYear > 4000 ) // this program as a year 4000 bug!
return QDateTime();
// it seems so, that 1.1.4501 indicates: DATE invalid
QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
return qdt;
}
class OLEListViewItem : public QCheckListItem
{
public:
OLEListViewItem( QListView *parent, QString text ) :
QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
OLEListViewItem( QListViewItem *after, QString text ) :
QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
~OLEListViewItem() {};
void setData( DWORD data ) {mData= data; };
DWORD data() { return mData ;};
private:
DWORD mData;
};
KAImportOLdialog::KAImportOLdialog( const QString &caption,
KABC::AddressBook * aBook, QWidget *parent ) :
KDialogBase( Plain, caption, User1 | Close, Ok,
@@ -157,135 +158,135 @@ void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent
for(int i=1; i <= folders.GetCount(); ++i)
{
fndx = (long)i;
mfChild = folders.Item(fndx.Detach());
mfChild.m_lpDispatch->AddRef();
szName = mfChild.GetName();
iType = mfChild.GetDefaultItemType();
hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
if ( iType != 2)
hChild->setEnabled( false );
QString ts;
switch( iType ) {
case 0:
ts = i18n("Mail");
break;
case 1:
ts = i18n("Calendar");
break;
case 2:
ts = i18n("Contacts");
break;
case 3:
ts = i18n("Todos");
break;
case 4:
ts = i18n("Journals");
break;
case 5:
ts = i18n("Notes");
break;
default:
ts = i18n("Unknown");
}
hChild->setText( 1,ts);
hChild->setData( (DWORD) mfChild.m_lpDispatch );
mfChild.m_lpDispatch->AddRef();
addFolder(hChild, mfChild.m_lpDispatch);
}
}
void KAImportOLdialog::slotApply()
{
importedItems = 0;
OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
while ( child ) {
if ( child->isOn() )
readContactData( child->data() );
child = (OLEListViewItem*) child->itemBelow();
}
QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
KMessageBox::information(this,mes);
}
void KAImportOLdialog::readContactData( DWORD folder )
{
LPDISPATCH dispItem = (LPDISPATCH)folder;
dispItem->AddRef();
MAPIFolder mf(dispItem);
mf.m_lpDispatch->AddRef();
_Items folderItems;
_variant_t indx((long)0);
LPDISPATCH itm;
int i;
folderItems = mf.GetItems();
- QProgressBar bar( folderItems.GetCount(),0 );
- bar.setCaption (i18n("Importing - close to abort!") );
+ QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this);
+ bar.setCaption (i18n("Importing!") );
int h = bar.sizeHint().height() ;
int w = 300;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
- bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
for(i=1; i <= folderItems.GetCount(); ++i)
{
qApp->processEvents();
if ( ! bar.isVisible() )
return ;
bar.setProgress( i );
indx = (long)i;
itm = folderItems.Item(indx.Detach());
_ContactItem * pItem = (_ContactItem *)&itm;
ol2kapiContact( pItem );
itm->Release();
}
}
void KAImportOLdialog::slotOk()
{
QDialog::accept();
}
void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
{
KABC::Addressee addressee;
addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
//GetLastModificationTime()
//addressee.setName( const QString &name );
//addressee.setFormattedName( const QString &formattedName );
addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
if ( dtb.isValid() )
addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
//QString::fromUcs2(aItem->.GetBuffer())
//addressee.setMailer( const QString &mailer );
//addressee.setTimeZone( const TimeZone &timeZone );
//addressee.setGeo( const Geo &geo );
//addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
notesStr.replace( QRegExp("\\r"), "");
addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
//addressee.setRevision( const QDateTime &revision );
// addressee.setSortString( const QString &sortString );
addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
QString tempS;
tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
if ( tempS.length() > 12 )
addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
if ( !tempS.isEmpty() )
addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
if ( !tempS.isEmpty() )