You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
552 lines
18 KiB
552 lines
18 KiB
15 years ago
|
/*
|
||
|
This file is part of the KDE project
|
||
|
Copyright (C) 2003 Tobias Koenig <tokoe@kde.org>
|
||
|
Joseph Wenninger <jowenn@kde.org>
|
||
|
Ingo Kloecker <kloecker@kde.org>
|
||
|
Copyright (C) 2004 Tobias Koenig <tokoe@kde.org>
|
||
|
Joseph Wenninger <jowenn@kde.org>
|
||
|
Ingo Kloecker <kloecker@kde.org>
|
||
|
Dirk Schmidt <fs@dirk-schmidt.net>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
|
#include <tdelocale.h>
|
||
|
#include <tdeabc/distributionlist.h>
|
||
|
#include <tdeabc/stdaddressbook.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include "KWMailMergeTDEABC.h"
|
||
|
#include "KWMailMergeTDEABCConfig.h"
|
||
15 years ago
|
|
||
12 years ago
|
KWMailMergeTDEABC::KWMailMergeTDEABC( TDEInstance *inst, TQObject *parent )
|
||
14 years ago
|
: KWMailMergeDataSource( inst, parent )
|
||
15 years ago
|
{
|
||
12 years ago
|
_addressBook = TDEABC::StdAddressBook::self();
|
||
15 years ago
|
_iterator = _addressBook->begin();
|
||
|
|
||
|
|
||
|
// init record list
|
||
|
// Using names from kaddressbook.
|
||
12 years ago
|
sampleRecord[ ("KAddressbook identifier") ] = TDEABC::Addressee::uidLabel();
|
||
|
sampleRecord[ ("Name" ) ] = TDEABC::Addressee::nameLabel();
|
||
|
sampleRecord[ ("Formatted name" ) ] = TDEABC::Addressee::formattedNameLabel();
|
||
|
sampleRecord[ ("Family names" ) ] = TDEABC::Addressee::familyNameLabel();
|
||
|
sampleRecord[ ("Given name" ) ] = TDEABC::Addressee::givenNameLabel();
|
||
|
sampleRecord[ ("Additional names" ) ] = TDEABC::Addressee::additionalNameLabel();
|
||
|
sampleRecord[ ("Honorific prefixes" ) ] = TDEABC::Addressee::prefixLabel();
|
||
|
sampleRecord[ ("Honorific suffixes" ) ] = TDEABC::Addressee::suffixLabel();
|
||
|
sampleRecord[ ("Nick name" ) ] = TDEABC::Addressee::nickNameLabel();
|
||
|
sampleRecord[ ("Birthday" ) ] = TDEABC::Addressee::birthdayLabel();
|
||
|
sampleRecord[ ("Home address: Street" ) ] = TDEABC::Addressee::homeAddressStreetLabel();
|
||
|
sampleRecord[ ("Home address: Locality" ) ] = TDEABC::Addressee::homeAddressLocalityLabel();
|
||
|
sampleRecord[ ("Home address: Region" ) ] = TDEABC::Addressee::homeAddressRegionLabel();
|
||
|
sampleRecord[ ("Home address: Postal code" ) ] = TDEABC::Addressee::homeAddressPostalCodeLabel();
|
||
|
sampleRecord[ ("Home address: Country" ) ] = TDEABC::Addressee::homeAddressCountryLabel();
|
||
|
sampleRecord[ ("Home address: Label" ) ] = TDEABC::Addressee::homeAddressLabelLabel();
|
||
|
sampleRecord[ ("Business address: Street" ) ] = TDEABC::Addressee::businessAddressStreetLabel();
|
||
|
sampleRecord[ ("Business address: Locality" ) ] = TDEABC::Addressee::businessAddressLocalityLabel();
|
||
|
sampleRecord[ ("Business address: Region" ) ] = TDEABC::Addressee::businessAddressRegionLabel();
|
||
|
sampleRecord[ ("Business address: Postal code" ) ] = TDEABC::Addressee::businessAddressPostalCodeLabel();
|
||
|
sampleRecord[ ("Business address: Country" ) ] = TDEABC::Addressee::businessAddressCountryLabel();
|
||
|
sampleRecord[ ("Business address: Label" ) ] = TDEABC::Addressee::businessAddressLabelLabel();
|
||
|
sampleRecord[ ("Home phone" ) ] = TDEABC::Addressee::homePhoneLabel();
|
||
|
sampleRecord[ ("Business phone" ) ] = TDEABC::Addressee::businessPhoneLabel();
|
||
|
sampleRecord[ ("Mobile phone" ) ] = TDEABC::Addressee::mobilePhoneLabel();
|
||
|
sampleRecord[ ("Home fax" ) ] = TDEABC::Addressee::homeFaxLabel();
|
||
|
sampleRecord[ ("Business fax" ) ] = TDEABC::Addressee::businessFaxLabel();
|
||
|
sampleRecord[ ("Car phone" ) ] = TDEABC::Addressee::carPhoneLabel();
|
||
|
sampleRecord[ ("ISDN" ) ] = TDEABC::Addressee::isdnLabel();
|
||
|
sampleRecord[ ("Pager" ) ] = TDEABC::Addressee::pagerLabel();
|
||
|
sampleRecord[ ("Email" ) ] = TDEABC::Addressee::emailLabel();
|
||
|
sampleRecord[ ("Mailer" ) ] = TDEABC::Addressee::mailerLabel();
|
||
|
sampleRecord[ ("Time zone" ) ] = TDEABC::Addressee::timeZoneLabel();
|
||
|
sampleRecord[ ("Geographic position" ) ] = TDEABC::Addressee::geoLabel();
|
||
|
sampleRecord[ ("Title" ) ] = TDEABC::Addressee::titleLabel();
|
||
|
sampleRecord[ ("Role" ) ] = TDEABC::Addressee::roleLabel();
|
||
|
sampleRecord[ ("Organization" ) ] = TDEABC::Addressee::organizationLabel();
|
||
|
sampleRecord[ ("Note" ) ] = TDEABC::Addressee::noteLabel();
|
||
|
sampleRecord[ ("productId" ) ] = TDEABC::Addressee::productIdLabel();
|
||
|
sampleRecord[ ("Revision" ) ] = TDEABC::Addressee::revisionLabel();
|
||
|
sampleRecord[ ("sortString" ) ] = TDEABC::Addressee::sortStringLabel();
|
||
|
sampleRecord[ ("URL" ) ] = TDEABC::Addressee::urlLabel();
|
||
|
sampleRecord[ ("Secrecy" ) ] = TDEABC::Addressee::secrecyLabel();
|
||
14 years ago
|
sampleRecord[ ("Preferred address: Street" ) ] = TQString( "preferedAddressStreet" );
|
||
|
sampleRecord[ ("Preferred address: Locality" ) ] = TQString( "preferedAddressLocality" );
|
||
|
sampleRecord[ ("Preferred address: Region" ) ] = TQString( "preferedAddressRegion" );
|
||
|
sampleRecord[ ("Preferred address: Postal code" ) ] = TQString( "preferedAddressPostalCode" );
|
||
|
sampleRecord[ ("Preferred address: Country" ) ] = TQString( "preferedAddressCountry" );
|
||
|
sampleRecord[ ("Preferred address: Label" ) ] = TQString( "preferedAddressLabel" );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
12 years ago
|
KWMailMergeTDEABC::~KWMailMergeTDEABC()
|
||
15 years ago
|
{
|
||
|
;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::addEntry( const TQString &uid )
|
||
15 years ago
|
{
|
||
|
_individualUIDs.append( uid );
|
||
|
makeUIDsExclusive();
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::addList( const TQString &id )
|
||
15 years ago
|
{
|
||
|
_lists.append( id );
|
||
|
parseList( id );
|
||
|
makeUIDsExclusive();
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::clear()
|
||
15 years ago
|
{
|
||
|
_exclusiveUIDs.clear();
|
||
|
_individualUIDs.clear();
|
||
|
_listUIDs.clear();
|
||
|
_lists.clear();
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
int KWMailMergeTDEABC::getNumRecords() const
|
||
15 years ago
|
{
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::getNumRecords(): " << _exclusiveUIDs.count() << endl;
|
||
15 years ago
|
return _exclusiveUIDs.count();
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TQString KWMailMergeTDEABC::getValue( const TQString &name, int record ) const
|
||
15 years ago
|
{
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::getValue(" << name << ", " << record << ")" << endl;
|
||
15 years ago
|
if ( record < 0 )
|
||
|
return name;
|
||
|
|
||
|
// This doesn't ever happen, right? So why is it there? Dirk Schmidt
|
||
|
if ( record == -1 && _iterator == _addressBook->end() )
|
||
|
return "";
|
||
|
|
||
|
//
|
||
|
// Set the iterator to the asked Addressee.
|
||
|
//
|
||
|
bool uidAvailable = false;
|
||
|
if ( record != -1 )
|
||
|
{
|
||
|
int counter = 0;
|
||
|
|
||
|
for ( _UIDIterator = _exclusiveUIDs.begin(); _UIDIterator != _exclusiveUIDs.end()
|
||
|
&& counter < record; _UIDIterator++ )
|
||
|
{
|
||
|
counter++;
|
||
|
}
|
||
|
|
||
|
for ( _iterator = _addressBook->begin(); _iterator != _addressBook->end(); ++_iterator )
|
||
|
{
|
||
|
|
||
|
if( _iterator->uid() == *_UIDIterator )
|
||
|
{
|
||
|
uidAvailable = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if( !uidAvailable )
|
||
|
{
|
||
13 years ago
|
return ( i18n ( "KAddressbook entry '%1' not available." ).arg( *_UIDIterator ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TDEABC::Addressee addr = *_iterator;
|
||
15 years ago
|
_iterator++; // Don't know why. Could be removed? Dirk Schmidt
|
||
|
|
||
|
|
||
|
//
|
||
|
// Return the asked variable.
|
||
|
//
|
||
|
if ( name == "KAddressbook identifier" )
|
||
|
return addr.uid();
|
||
|
if ( name == "Name" )
|
||
|
return addr.name();
|
||
|
if ( name == "Formatted name" )
|
||
|
return addr.formattedName();
|
||
|
if ( name == "Family names" )
|
||
|
return addr.familyName();
|
||
|
if ( name == "Given name" )
|
||
|
return addr.givenName();
|
||
|
if ( name == "Additional names" )
|
||
|
return addr.additionalName();
|
||
|
if ( name == "Honorific prefixes" )
|
||
|
return addr.prefix();
|
||
|
if ( name == "Honorific suffixes" )
|
||
|
return addr.suffix();
|
||
|
if ( name == "Nick name" )
|
||
|
return addr.nickName();
|
||
|
if ( name == "Birthday" )
|
||
12 years ago
|
return TDEGlobal::locale()->formatDate( addr.birthday().date() );
|
||
15 years ago
|
|
||
|
if ( name == "Home address: Street" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.street();
|
||
|
}
|
||
|
if ( name == "Home address: Locality" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.locality();
|
||
|
}
|
||
|
if ( name == "Home address: Region" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.region();
|
||
|
}
|
||
|
if ( name == "Home address: Postal code" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.postalCode();
|
||
|
}
|
||
|
if ( name == "Home address: Country" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.country();
|
||
|
}
|
||
|
if ( name == "Home address: Label" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Home );
|
||
15 years ago
|
return a.label();
|
||
|
}
|
||
|
|
||
|
if ( name == "Business address: Street" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.street();
|
||
|
}
|
||
|
if ( name == "Business address: Locality" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.locality();
|
||
|
}
|
||
|
if ( name == "Business address: Region" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.region();
|
||
|
}
|
||
|
if ( name == "Business address: Postal code" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.postalCode();
|
||
|
}
|
||
|
if ( name == "Business address: Country" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.country();
|
||
|
}
|
||
|
if ( name == "Business address: Label" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Work );
|
||
15 years ago
|
return a.label();
|
||
|
}
|
||
|
|
||
|
if ( name == "Prefered address: Street" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.street();
|
||
|
}
|
||
|
|
||
|
if ( name == "Prefered address: Locality" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.locality();
|
||
|
}
|
||
|
if ( name == "Prefered address: Region" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.region();
|
||
|
}
|
||
|
if ( name == "Prefered address: Postal code" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.postalCode();
|
||
|
}
|
||
|
if ( name == "Prefered address: Country" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.country();
|
||
|
}
|
||
|
if ( name == "Prefered address: Label" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Address a = addr.address( TDEABC::Address::Pref );
|
||
15 years ago
|
return a.label();
|
||
|
}
|
||
|
|
||
|
if ( name == "Home phone" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Home );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Business phone" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Work );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Mobile phone" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Cell );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Home fax" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Home | TDEABC::PhoneNumber::Fax );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Business fax" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Work | TDEABC::PhoneNumber::Fax );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Car phone" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Car );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "ISDN" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Isdn );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
if ( name == "Pager" )
|
||
|
{
|
||
12 years ago
|
TDEABC::PhoneNumber phone = addr.phoneNumber( TDEABC::PhoneNumber::Pager );
|
||
15 years ago
|
return phone.number();
|
||
|
}
|
||
|
|
||
|
if ( name == "Email" )
|
||
|
return addr.preferredEmail();
|
||
|
if ( name == "Mailer" )
|
||
|
return addr.mailer();
|
||
|
if ( name == "Time zone" )
|
||
|
{
|
||
12 years ago
|
TDEABC::TimeZone zone = addr.timeZone();
|
||
14 years ago
|
return TQString::number( zone.offset() );
|
||
15 years ago
|
}
|
||
|
if ( name == "Geographic position" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Geo geo = addr.geo();
|
||
14 years ago
|
TQString lat;
|
||
|
TQString longi;
|
||
15 years ago
|
if( geo.latitude()<0 )
|
||
13 years ago
|
lat = TQString( i18n("%1 South") ).arg( -geo.latitude() );
|
||
15 years ago
|
else
|
||
13 years ago
|
lat = TQString( i18n("%1 North") ).arg( geo.latitude() );
|
||
15 years ago
|
|
||
|
if( geo.longitude()<0 )
|
||
|
// There is something going wrong, because "W" is replaced by "q ".
|
||
|
// Needs fix.
|
||
13 years ago
|
longi = TQString( i18n("%1 West") ).arg( -geo.longitude() );
|
||
15 years ago
|
else
|
||
13 years ago
|
longi = TQString( i18n("%1 East") ).arg( geo.longitude() );
|
||
15 years ago
|
|
||
|
return i18n( "Geographic coordinates", "%1, %2" ).arg ( lat, longi );
|
||
|
}
|
||
|
|
||
|
if ( name == "Title" )
|
||
|
return addr.title();
|
||
|
if ( name == "Role" )
|
||
|
return addr.role();
|
||
|
if ( name == "Organization" )
|
||
|
return addr.organization();
|
||
|
if ( name == "Note" )
|
||
|
return addr.note();
|
||
|
if ( name == "productId" )
|
||
|
return addr.productId();
|
||
|
if ( name == "Revision" )
|
||
12 years ago
|
return TDEGlobal::locale()->formatDate( addr.revision().date() );
|
||
15 years ago
|
if ( name == "sortString" )
|
||
|
return addr.sortString();
|
||
|
if ( name == "URL" )
|
||
|
return addr.url().url();
|
||
|
if ( name == "Secrecy" )
|
||
|
{
|
||
12 years ago
|
TDEABC::Secrecy secrecy = addr.secrecy();
|
||
|
return TDEABC::Secrecy::typeLabel( secrecy.type() );
|
||
15 years ago
|
}
|
||
|
|
||
|
return ( i18n("Unkown mail merge variable: %1").arg ( name ) ) ;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TQStringList KWMailMergeTDEABC::lists() const
|
||
15 years ago
|
{
|
||
|
return _lists;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::load( TQDomElement& parentElem )
|
||
15 years ago
|
{
|
||
|
clear();
|
||
14 years ago
|
TQDomNode contentNode=parentElem.namedItem("CONTENT");
|
||
15 years ago
|
if( contentNode.isNull() )
|
||
|
return;
|
||
14 years ago
|
for( TQDomNode rec=contentNode.firstChild(); !rec.isNull(); rec=rec.nextSibling() )
|
||
15 years ago
|
{
|
||
|
if( rec.nodeName()== "RECORD" )
|
||
|
{
|
||
14 years ago
|
for( TQDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
|
||
15 years ago
|
recEnt=recEnt.nextSibling().toElement() )
|
||
|
{
|
||
13 years ago
|
addEntry( recEnt.attribute( TQString::fromLatin1("uid") ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
else if( rec.nodeName() == "LIST" )
|
||
|
{
|
||
14 years ago
|
for( TQDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
|
||
15 years ago
|
recEnt=recEnt.nextSibling().toElement() )
|
||
|
{
|
||
13 years ago
|
addList( recEnt.attribute( TQString::fromLatin1("listid") ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
else
|
||
|
kdDebug() << "rec.nodeName(): " << rec.nodeName() << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::makeUIDsExclusive()
|
||
15 years ago
|
{
|
||
|
_exclusiveUIDs = _individualUIDs + _listUIDs;
|
||
|
_exclusiveUIDs.sort();
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::makeUIDsExclusive(): before: " << _exclusiveUIDs.join(",")
|
||
15 years ago
|
<< endl;
|
||
14 years ago
|
TQString uid;
|
||
|
for( TQStringList::Iterator it=_exclusiveUIDs.begin();
|
||
15 years ago
|
it!=_exclusiveUIDs.end(); ++it )
|
||
|
{
|
||
|
if( *it == uid )
|
||
|
{
|
||
|
it = _exclusiveUIDs.remove( it );
|
||
|
}
|
||
|
uid = *it;
|
||
|
}
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::makeUIDsExclusive(): after: " << _exclusiveUIDs.join(",")
|
||
15 years ago
|
<< endl;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::parseList( const TQString& listName )
|
||
15 years ago
|
{
|
||
|
if( listName.isEmpty() )
|
||
|
return;
|
||
|
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::parseList: " << listName << endl;
|
||
|
TDEABC::DistributionListManager dlm ( _addressBook );
|
||
15 years ago
|
dlm.load();
|
||
|
|
||
14 years ago
|
TQStringList::Iterator listIt;
|
||
15 years ago
|
|
||
12 years ago
|
TDEABC::DistributionList* list = dlm.list( listName );
|
||
|
TDEABC::DistributionList::Entry::List entries = list->entries();
|
||
15 years ago
|
|
||
12 years ago
|
TDEABC::DistributionList::Entry::List::Iterator itemIt;
|
||
15 years ago
|
for ( itemIt = entries.begin(); itemIt != entries.end(); ++itemIt )
|
||
|
{
|
||
12 years ago
|
kdDebug() << "WMailMergeTDEABC::parseList: Listentry UID: " <<
|
||
15 years ago
|
(*itemIt).addressee.uid() << endl;
|
||
|
_listUIDs.append( (*itemIt).addressee.uid() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::refresh( bool )
|
||
15 years ago
|
{
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABC::refresh()" << endl;
|
||
15 years ago
|
_iterator = _addressBook->begin();
|
||
|
_UIDIterator = _individualUIDs.begin();
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void KWMailMergeTDEABC::save( TQDomDocument& doc, TQDomElement& parent)
|
||
15 years ago
|
{
|
||
13 years ago
|
TQDomElement cont=doc.createElement(TQString::fromLatin1("CONTENT"));
|
||
14 years ago
|
parent.appendChild(cont);
|
||
15 years ago
|
|
||
14 years ago
|
TQValueList<TQString>::ConstIterator it = _individualUIDs.begin();
|
||
15 years ago
|
for( ; it != _individualUIDs.end(); ++it )
|
||
|
{
|
||
13 years ago
|
TQDomElement rec=doc.createElement(TQString::fromLatin1("RECORD"));
|
||
15 years ago
|
cont.appendChild(rec);
|
||
13 years ago
|
TQDomElement recEnt=doc.createElement(TQString::fromLatin1("ITEM"));
|
||
|
recEnt.setAttribute(TQString::fromLatin1("uid"),*it);
|
||
15 years ago
|
rec.appendChild(recEnt);
|
||
|
}
|
||
|
|
||
|
it = _lists.begin();
|
||
|
for( ; !(it == _lists.end()); ++it )
|
||
|
{
|
||
13 years ago
|
TQDomElement rec=doc.createElement(TQString::fromLatin1("LIST"));
|
||
15 years ago
|
cont.appendChild(rec);
|
||
13 years ago
|
TQDomElement recEnt=doc.createElement(TQString::fromLatin1("ITEM"));
|
||
|
recEnt.setAttribute(TQString::fromLatin1("listid"),*it);
|
||
15 years ago
|
rec.appendChild(recEnt);
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
bool KWMailMergeTDEABC::showConfigDialog( TQWidget* par, int action )
|
||
15 years ago
|
{
|
||
|
bool ret=false;
|
||
|
if (action == KWSLCreate )
|
||
|
{
|
||
|
clear();
|
||
|
}
|
||
|
|
||
|
//if (action==KWSLOpen)
|
||
|
{
|
||
12 years ago
|
KWMailMergeTDEABCConfig *dia=new KWMailMergeTDEABCConfig( par, this );
|
||
15 years ago
|
|
||
14 years ago
|
ret=( dia->exec() == TQDialog::Accepted );
|
||
12 years ago
|
kdDebug() << "KWMailMergeTDEABCConfig::Accepted " << ret << endl;
|
||
15 years ago
|
delete dia;
|
||
|
}
|
||
|
refresh(false);
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TQStringList KWMailMergeTDEABC::singleRecords() const
|
||
15 years ago
|
{
|
||
|
return _individualUIDs;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
11 years ago
|
KWORD_MAILMERGE_EXPORT KWMailMergeDataSource *create_kwmailmerge_tdeabc( TDEInstance *inst, TQObject *parent )
|
||
15 years ago
|
{
|
||
12 years ago
|
return new KWMailMergeTDEABC( inst, parent );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
12 years ago
|
#include "KWMailMergeTDEABC.moc"
|
||
15 years ago
|
|
||
|
|