summaryrefslogtreecommitdiffstats
path: root/kword/mailmerge/kabc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kword/mailmerge/kabc
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kword/mailmerge/kabc')
-rw-r--r--kword/mailmerge/kabc/KWMailMergeKABC.cpp551
-rw-r--r--kword/mailmerge/kabc/KWMailMergeKABC.h185
-rw-r--r--kword/mailmerge/kabc/KWMailMergeKABCConfig.cpp546
-rw-r--r--kword/mailmerge/kabc/KWMailMergeKABCConfig.h149
-rw-r--r--kword/mailmerge/kabc/Makefile.am17
-rw-r--r--kword/mailmerge/kabc/addresspicker.ui297
-rw-r--r--kword/mailmerge/kabc/kwmailmerge_kabc.desktop105
7 files changed, 1850 insertions, 0 deletions
diff --git a/kword/mailmerge/kabc/KWMailMergeKABC.cpp b/kword/mailmerge/kabc/KWMailMergeKABC.cpp
new file mode 100644
index 00000000..a5df7e73
--- /dev/null
+++ b/kword/mailmerge/kabc/KWMailMergeKABC.cpp
@@ -0,0 +1,551 @@
+/*
+ This file is part of the KDE project
+ Copyright (C) 2003 Tobias Koenig <[email protected]>
+ Joseph Wenninger <[email protected]>
+ Ingo Kloecker <[email protected]>
+ Copyright (C) 2004 Tobias Koenig <[email protected]>
+ Joseph Wenninger <[email protected]>
+ Ingo Kloecker <[email protected]>
+ Dirk Schmidt <[email protected]>
+
+ 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>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kabc/distributionlist.h>
+#include <kabc/stdaddressbook.h>
+
+#include "KWMailMergeKABC.h"
+#include "KWMailMergeKABCConfig.h"
+
+KWMailMergeKABC::KWMailMergeKABC( KInstance *inst, QObject *parent )
+ : KWMailMergeDataSource( inst, parent )
+{
+ _addressBook = KABC::StdAddressBook::self();
+ _iterator = _addressBook->begin();
+
+
+ // init record list
+ // Using names from kaddressbook.
+ sampleRecord[ ("KAddressbook identifier") ] = KABC::Addressee::uidLabel();
+ sampleRecord[ ("Name" ) ] = KABC::Addressee::nameLabel();
+ sampleRecord[ ("Formatted name" ) ] = KABC::Addressee::formattedNameLabel();
+ sampleRecord[ ("Family names" ) ] = KABC::Addressee::familyNameLabel();
+ sampleRecord[ ("Given name" ) ] = KABC::Addressee::givenNameLabel();
+ sampleRecord[ ("Additional names" ) ] = KABC::Addressee::additionalNameLabel();
+ sampleRecord[ ("Honorific prefixes" ) ] = KABC::Addressee::prefixLabel();
+ sampleRecord[ ("Honorific suffixes" ) ] = KABC::Addressee::suffixLabel();
+ sampleRecord[ ("Nick name" ) ] = KABC::Addressee::nickNameLabel();
+ sampleRecord[ ("Birthday" ) ] = KABC::Addressee::birthdayLabel();
+ sampleRecord[ ("Home address: Street" ) ] = KABC::Addressee::homeAddressStreetLabel();
+ sampleRecord[ ("Home address: Locality" ) ] = KABC::Addressee::homeAddressLocalityLabel();
+ sampleRecord[ ("Home address: Region" ) ] = KABC::Addressee::homeAddressRegionLabel();
+ sampleRecord[ ("Home address: Postal code" ) ] = KABC::Addressee::homeAddressPostalCodeLabel();
+ sampleRecord[ ("Home address: Country" ) ] = KABC::Addressee::homeAddressCountryLabel();
+ sampleRecord[ ("Home address: Label" ) ] = KABC::Addressee::homeAddressLabelLabel();
+ sampleRecord[ ("Business address: Street" ) ] = KABC::Addressee::businessAddressStreetLabel();
+ sampleRecord[ ("Business address: Locality" ) ] = KABC::Addressee::businessAddressLocalityLabel();
+ sampleRecord[ ("Business address: Region" ) ] = KABC::Addressee::businessAddressRegionLabel();
+ sampleRecord[ ("Business address: Postal code" ) ] = KABC::Addressee::businessAddressPostalCodeLabel();
+ sampleRecord[ ("Business address: Country" ) ] = KABC::Addressee::businessAddressCountryLabel();
+ sampleRecord[ ("Business address: Label" ) ] = KABC::Addressee::businessAddressLabelLabel();
+ sampleRecord[ ("Home phone" ) ] = KABC::Addressee::homePhoneLabel();
+ sampleRecord[ ("Business phone" ) ] = KABC::Addressee::businessPhoneLabel();
+ sampleRecord[ ("Mobile phone" ) ] = KABC::Addressee::mobilePhoneLabel();
+ sampleRecord[ ("Home fax" ) ] = KABC::Addressee::homeFaxLabel();
+ sampleRecord[ ("Business fax" ) ] = KABC::Addressee::businessFaxLabel();
+ sampleRecord[ ("Car phone" ) ] = KABC::Addressee::carPhoneLabel();
+ sampleRecord[ ("ISDN" ) ] = KABC::Addressee::isdnLabel();
+ sampleRecord[ ("Pager" ) ] = KABC::Addressee::pagerLabel();
+ sampleRecord[ ("Email" ) ] = KABC::Addressee::emailLabel();
+ sampleRecord[ ("Mailer" ) ] = KABC::Addressee::mailerLabel();
+ sampleRecord[ ("Time zone" ) ] = KABC::Addressee::timeZoneLabel();
+ sampleRecord[ ("Geographic position" ) ] = KABC::Addressee::geoLabel();
+ sampleRecord[ ("Title" ) ] = KABC::Addressee::titleLabel();
+ sampleRecord[ ("Role" ) ] = KABC::Addressee::roleLabel();
+ sampleRecord[ ("Organization" ) ] = KABC::Addressee::organizationLabel();
+ sampleRecord[ ("Note" ) ] = KABC::Addressee::noteLabel();
+ sampleRecord[ ("productId" ) ] = KABC::Addressee::productIdLabel();
+ sampleRecord[ ("Revision" ) ] = KABC::Addressee::revisionLabel();
+ sampleRecord[ ("sortString" ) ] = KABC::Addressee::sortStringLabel();
+ sampleRecord[ ("URL" ) ] = KABC::Addressee::urlLabel();
+ sampleRecord[ ("Secrecy" ) ] = KABC::Addressee::secrecyLabel();
+ sampleRecord[ ("Preferred address: Street" ) ] = QString( "preferedAddressStreet" );
+ sampleRecord[ ("Preferred address: Locality" ) ] = QString( "preferedAddressLocality" );
+ sampleRecord[ ("Preferred address: Region" ) ] = QString( "preferedAddressRegion" );
+ sampleRecord[ ("Preferred address: Postal code" ) ] = QString( "preferedAddressPostalCode" );
+ sampleRecord[ ("Preferred address: Country" ) ] = QString( "preferedAddressCountry" );
+ sampleRecord[ ("Preferred address: Label" ) ] = QString( "preferedAddressLabel" );
+}
+
+
+KWMailMergeKABC::~KWMailMergeKABC()
+{
+ ;
+}
+
+
+void KWMailMergeKABC::addEntry( const QString &uid )
+{
+ _individualUIDs.append( uid );
+ makeUIDsExclusive();
+}
+
+
+void KWMailMergeKABC::addList( const QString &id )
+{
+ _lists.append( id );
+ parseList( id );
+ makeUIDsExclusive();
+}
+
+
+void KWMailMergeKABC::clear()
+{
+ _exclusiveUIDs.clear();
+ _individualUIDs.clear();
+ _listUIDs.clear();
+ _lists.clear();
+}
+
+
+int KWMailMergeKABC::getNumRecords() const
+{
+ kdDebug() << "KWMailMergeKABC::getNumRecords(): " << _exclusiveUIDs.count() << endl;
+ return _exclusiveUIDs.count();
+}
+
+
+QString KWMailMergeKABC::getValue( const QString &name, int record ) const
+{
+ kdDebug() << "KWMailMergeKABC::getValue(" << name << ", " << record << ")" << endl;
+ 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 )
+ {
+ return ( i18n ( "KAddressbook entry '%1' not available." ).arg( *_UIDIterator ) );
+ }
+
+
+ KABC::Addressee addr = *_iterator;
+ _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" )
+ return KGlobal::locale()->formatDate( addr.birthday().date() );
+
+ if ( name == "Home address: Street" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.street();
+ }
+ if ( name == "Home address: Locality" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.locality();
+ }
+ if ( name == "Home address: Region" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.region();
+ }
+ if ( name == "Home address: Postal code" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.postalCode();
+ }
+ if ( name == "Home address: Country" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.country();
+ }
+ if ( name == "Home address: Label" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Home );
+ return a.label();
+ }
+
+ if ( name == "Business address: Street" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.street();
+ }
+ if ( name == "Business address: Locality" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.locality();
+ }
+ if ( name == "Business address: Region" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.region();
+ }
+ if ( name == "Business address: Postal code" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.postalCode();
+ }
+ if ( name == "Business address: Country" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.country();
+ }
+ if ( name == "Business address: Label" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Work );
+ return a.label();
+ }
+
+ if ( name == "Prefered address: Street" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.street();
+ }
+
+ if ( name == "Prefered address: Locality" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.locality();
+ }
+ if ( name == "Prefered address: Region" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.region();
+ }
+ if ( name == "Prefered address: Postal code" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.postalCode();
+ }
+ if ( name == "Prefered address: Country" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.country();
+ }
+ if ( name == "Prefered address: Label" )
+ {
+ KABC::Address a = addr.address( KABC::Address::Pref );
+ return a.label();
+ }
+
+ if ( name == "Home phone" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Home );
+ return phone.number();
+ }
+ if ( name == "Business phone" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Work );
+ return phone.number();
+ }
+ if ( name == "Mobile phone" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Cell );
+ return phone.number();
+ }
+ if ( name == "Home fax" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
+ return phone.number();
+ }
+ if ( name == "Business fax" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
+ return phone.number();
+ }
+ if ( name == "Car phone" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Car );
+ return phone.number();
+ }
+ if ( name == "ISDN" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Isdn );
+ return phone.number();
+ }
+ if ( name == "Pager" )
+ {
+ KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Pager );
+ return phone.number();
+ }
+
+ if ( name == "Email" )
+ return addr.preferredEmail();
+ if ( name == "Mailer" )
+ return addr.mailer();
+ if ( name == "Time zone" )
+ {
+ KABC::TimeZone zone = addr.timeZone();
+ return QString::number( zone.offset() );
+ }
+ if ( name == "Geographic position" )
+ {
+ KABC::Geo geo = addr.geo();
+ QString lat;
+ QString longi;
+ if( geo.latitude()<0 )
+ lat = QString( i18n("%1 South") ).arg( -geo.latitude() );
+ else
+ lat = QString( i18n("%1 North") ).arg( geo.latitude() );
+
+ if( geo.longitude()<0 )
+ // There is something going wrong, because "W" is replaced by "q ".
+ // Needs fix.
+ longi = QString( i18n("%1 West") ).arg( -geo.longitude() );
+ else
+ longi = QString( i18n("%1 East") ).arg( geo.longitude() );
+
+ 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" )
+ return KGlobal::locale()->formatDate( addr.revision().date() );
+ if ( name == "sortString" )
+ return addr.sortString();
+ if ( name == "URL" )
+ return addr.url().url();
+ if ( name == "Secrecy" )
+ {
+ KABC::Secrecy secrecy = addr.secrecy();
+ return KABC::Secrecy::typeLabel( secrecy.type() );
+ }
+
+ return ( i18n("Unkown mail merge variable: %1").arg ( name ) ) ;
+}
+
+
+QStringList KWMailMergeKABC::lists() const
+{
+ return _lists;
+}
+
+
+void KWMailMergeKABC::load( QDomElement& parentElem )
+{
+ clear();
+ QDomNode contentNode=parentElem.namedItem("CONTENT");
+ if( contentNode.isNull() )
+ return;
+ for( QDomNode rec=contentNode.firstChild(); !rec.isNull(); rec=rec.nextSibling() )
+ {
+ if( rec.nodeName()== "RECORD" )
+ {
+ for( QDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
+ recEnt=recEnt.nextSibling().toElement() )
+ {
+ addEntry( recEnt.attribute( QString::fromLatin1("uid") ) );
+ }
+ }
+ else if( rec.nodeName() == "LIST" )
+ {
+ for( QDomElement recEnt=rec.firstChild().toElement(); !recEnt.isNull();
+ recEnt=recEnt.nextSibling().toElement() )
+ {
+ addList( recEnt.attribute( QString::fromLatin1("listid") ) );
+ }
+ }
+ else
+ kdDebug() << "rec.nodeName(): " << rec.nodeName() << endl;
+ }
+}
+
+
+void KWMailMergeKABC::makeUIDsExclusive()
+{
+ _exclusiveUIDs = _individualUIDs + _listUIDs;
+ _exclusiveUIDs.sort();
+ kdDebug() << "KWMailMergeKABC::makeUIDsExclusive(): before: " << _exclusiveUIDs.join(",")
+ << endl;
+ QString uid;
+ for( QStringList::Iterator it=_exclusiveUIDs.begin();
+ it!=_exclusiveUIDs.end(); ++it )
+ {
+ if( *it == uid )
+ {
+ it = _exclusiveUIDs.remove( it );
+ }
+ uid = *it;
+ }
+ kdDebug() << "KWMailMergeKABC::makeUIDsExclusive(): after: " << _exclusiveUIDs.join(",")
+ << endl;
+}
+
+
+void KWMailMergeKABC::parseList( const QString& listName )
+{
+ if( listName.isEmpty() )
+ return;
+
+ kdDebug() << "KWMailMergeKABC::parseList: " << listName << endl;
+ KABC::DistributionListManager dlm ( _addressBook );
+ dlm.load();
+
+ QStringList::Iterator listIt;
+
+ KABC::DistributionList* list = dlm.list( listName );
+ KABC::DistributionList::Entry::List entries = list->entries();
+
+ KABC::DistributionList::Entry::List::Iterator itemIt;
+ for ( itemIt = entries.begin(); itemIt != entries.end(); ++itemIt )
+ {
+ kdDebug() << "WMailMergeKABC::parseList: Listentry UID: " <<
+ (*itemIt).addressee.uid() << endl;
+ _listUIDs.append( (*itemIt).addressee.uid() );
+ }
+}
+
+
+void KWMailMergeKABC::refresh( bool )
+{
+ kdDebug() << "KWMailMergeKABC::refresh()" << endl;
+ _iterator = _addressBook->begin();
+ _UIDIterator = _individualUIDs.begin();
+
+}
+
+
+void KWMailMergeKABC::save( QDomDocument& doc, QDomElement& parent)
+{
+ QDomElement cont=doc.createElement(QString::fromLatin1("CONTENT"));
+ parent.appendChild(cont);
+
+ QValueList<QString>::ConstIterator it = _individualUIDs.begin();
+ for( ; it != _individualUIDs.end(); ++it )
+ {
+ QDomElement rec=doc.createElement(QString::fromLatin1("RECORD"));
+ cont.appendChild(rec);
+ QDomElement recEnt=doc.createElement(QString::fromLatin1("ITEM"));
+ recEnt.setAttribute(QString::fromLatin1("uid"),*it);
+ rec.appendChild(recEnt);
+ }
+
+ it = _lists.begin();
+ for( ; !(it == _lists.end()); ++it )
+ {
+ QDomElement rec=doc.createElement(QString::fromLatin1("LIST"));
+ cont.appendChild(rec);
+ QDomElement recEnt=doc.createElement(QString::fromLatin1("ITEM"));
+ recEnt.setAttribute(QString::fromLatin1("listid"),*it);
+ rec.appendChild(recEnt);
+ }
+}
+
+bool KWMailMergeKABC::showConfigDialog( QWidget* par, int action )
+{
+ bool ret=false;
+ if (action == KWSLCreate )
+ {
+ clear();
+ }
+
+ //if (action==KWSLOpen)
+ {
+ KWMailMergeKABCConfig *dia=new KWMailMergeKABCConfig( par, this );
+
+ ret=( dia->exec() == QDialog::Accepted );
+ kdDebug() << "KWMailMergeKABCConfig::Accepted " << ret << endl;
+ delete dia;
+ }
+ refresh(false);
+
+ return ret;
+}
+
+
+QStringList KWMailMergeKABC::singleRecords() const
+{
+ return _individualUIDs;
+}
+
+
+
+extern "C"
+{
+ KWORD_MAILMERGE_EXPORT KWMailMergeDataSource *create_kwmailmerge_kabc( KInstance *inst, QObject *parent )
+ {
+ return new KWMailMergeKABC( inst, parent );
+ }
+}
+
+
+
+
+#include "KWMailMergeKABC.moc"
+
+
diff --git a/kword/mailmerge/kabc/KWMailMergeKABC.h b/kword/mailmerge/kabc/KWMailMergeKABC.h
new file mode 100644
index 00000000..2787ac6f
--- /dev/null
+++ b/kword/mailmerge/kabc/KWMailMergeKABC.h
@@ -0,0 +1,185 @@
+/*
+ This file is part of the KDE project
+ Copyright (C) 2003 Tobias Koenig <[email protected]>
+ Copyright (C) 2004 Tobias Koenig <[email protected]>
+ Dirk Schmidt <[email protected]>
+
+ 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.
+*/
+
+#ifndef _KWMAILMERGE_KABC_H_
+#define _KWMAILMERGE_KABC_H_
+
+#include <qdom.h>
+#include <qguardedptr.h>
+
+#include <kabc/addressbook.h>
+
+#include "KWMailMergeDataSource.h"
+
+class KWMailMergeKABC: public KWMailMergeDataSource
+{
+ Q_OBJECT
+
+public:
+ KWMailMergeKABC( KInstance *inst, QObject *parent );
+ ~KWMailMergeKABC();
+
+ /**
+ Saves the mail merge list to the kword document.
+ */
+ virtual void save( QDomDocument&, QDomElement& );
+
+ /**
+ Loads the mail merge list stored in the kword document.
+ */
+ virtual void load( QDomElement& );
+
+ /**
+ @param name The name of the value e.g. "Family name".
+ @param record The position of the the entry in mail merge list.
+ @return The value of the mail merge variable.
+
+ If @p record equals -1, @p name is returned.
+ */
+ virtual class QString getValue( const class QString &name, int record = -1 ) const;
+
+ /**
+ @return The number of available contacts in mail merge list.
+ */
+ virtual int getNumRecords() const;
+
+ /**
+ Only for compatability reasons.
+
+ @param force Hasn't any effect.
+ */
+ virtual void refresh( bool force );
+
+ /**
+ Shows a KWMailMergeKABCConfig dialog for selecting entries from KAddressbook.
+ */
+ virtual bool showConfigDialog( QWidget*, int action);
+
+protected:
+ friend class KWMailMergeKABCConfig;
+
+ /**
+ Adds an entry from KABC::StdAddressBook::self()
+ to the mail merge list.
+
+ To be called by KWMailMergeKABC::load() and
+ KWMailMergeKABCConfig::acceptSelection() only.
+
+ @param uid The entry's KABC::Addressee::uid().
+ */
+ void addEntry( const QString &uid );
+
+ /**
+ Adds a distribution list to the mail merge list.
+
+ To be called by KWMailMergeKABC::load() and
+ KWMailMergeKABCConfig::acceptSelection() only.
+
+ @param id The DistributionList::name().
+ */
+ void addList( const QString &id );
+
+ /**
+ Removes all entries and distribution lists from the mail merge list.
+ */
+ void clear();
+
+ /**
+ @return All selected DistributionList::name().
+
+ To be called by KWMailMergeKABCConfig::initSelectedLists()
+ */
+ virtual QStringList lists() const;
+
+ /**
+ @return The KABC::Addressee::uid() of all individually selected
+ entries in mail merge list.
+
+ To be called by KWMailMergeKABCConfig::initSelectedAddressees()
+ */
+ virtual QStringList singleRecords() const;
+
+private:
+ /**
+ The KABC::StdAddressBook::self().
+ */
+ KABC::AddressBook* _addressBook;
+
+ /**
+ Just an Iterator.
+ */
+ mutable KABC::AddressBook::ConstIterator _iterator;
+
+ /**
+ Just an Iterator.
+ */
+ mutable QStringList::ConstIterator _UIDIterator;
+
+ /**
+ The "real" mail merge list. A list of QStrings. Each represents
+ the KABC::Addressee::uid() of a KAdressbook entry.
+ There is no UID twice in this list.
+
+ Needed because selected contacts may appear in a selected
+ distribution list, too. And we don't want to print it multiple.
+ */
+ QStringList _exclusiveUIDs;
+
+ /**
+ This list contains all the KABC::Addressee::uid() selected
+ individually with the KWMailMergeKABCConfig dialog.
+ */
+ QStringList _individualUIDs;
+
+ /**
+ This list contains all the KABC::Addressee::uid() from the distribution
+ lists selected with the KWMailMergeKABCConfig dialog.
+ */
+ QStringList _listUIDs;
+
+ /**
+ This list contains all the DistributionList::name() selected with the
+ KWMailMergeKABCConfig dialog.
+ */
+ QStringList _lists;
+
+
+ /**
+ Appends all KABC::Addressee::uid() of a distribution list to _listUIDs
+ and updates the mail merge list.
+
+ To be used by KWMailMergeKABCConfig::addList( const QString &id )
+ only.
+
+ @param listName The DistributionList::name() of the distribution list.
+ */
+ void parseList( const QString& listName );
+
+ /**
+ Removes duplicate entries in the mail merge list.
+ */
+ void makeUIDsExclusive();
+
+};
+
+#endif
+
diff --git a/kword/mailmerge/kabc/KWMailMergeKABCConfig.cpp b/kword/mailmerge/kabc/KWMailMergeKABCConfig.cpp
new file mode 100644
index 00000000..dee519c3
--- /dev/null
+++ b/kword/mailmerge/kabc/KWMailMergeKABCConfig.cpp
@@ -0,0 +1,546 @@
+/*
+ This file is part of the KDE project
+ Copyright (C) 2004 Dirk Schmidt <[email protected]>
+
+ 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 <qvbox.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kpushbutton.h>
+#include <krun.h>
+#include <kabc/stdaddressbook.h>
+#include <kabc/distributionlist.h>
+
+#include "addresspicker.h"
+#include "KWMailMergeKABC.h"
+#include "KWMailMergeKABCConfig.h"
+
+
+KWMailMergeKABCConfig::KWMailMergeKABCConfig( QWidget *parent, KWMailMergeKABC *db_)
+ :KDialogBase( Plain, i18n( "Mail Merge - Editor" ),
+ Ok | Cancel, Ok, parent, "", true)
+{
+ _db = db_;
+
+ (new QVBoxLayout(plainPage()))->setAutoAdd(true);
+ setMainWidget( _ui=new AddressPickerUI( plainPage() ) );
+
+ updateAvailable();
+ initSelectedAddressees();
+ initSelectedLists();
+ initSlotSignalConnections();
+}
+
+
+KWMailMergeKABCConfig::~KWMailMergeKABCConfig()
+{
+ ;
+}
+
+
+void KWMailMergeKABCConfig::acceptSelection()
+{
+ _db->clear();
+
+ QListViewItem* top = _ui->mSelectedView->firstChild();
+ while(top)
+ {
+ kdDebug() << "acceptSelection(): " << top->text(0) << endl;
+ if( top->text(0) == i18n("Distribution Lists") )
+ {
+ QListViewItem* item = top->firstChild();
+ while(item)
+ {
+ kdDebug() << "acceptSelection(): " << item->text(0) << endl;
+ _db->addList( item->text(0) );
+ item = item->nextSibling();
+ }
+ }
+ else if( top->text(0) == i18n("Single Entries") )
+ {
+ QListViewItem* item = top->firstChild();
+ while(item)
+ {
+ kdDebug() << "acceptSelection(): " << item->text(0) << endl;
+ _db->addEntry( item->text(-1) );
+ item = item->nextSibling();
+ }
+ }
+ top = top->nextSibling();
+ }
+
+}
+
+
+void KWMailMergeKABCConfig::addSelectedContacts()
+{
+ QListViewItemIterator it( _ui->mAvailableView, QListViewItemIterator::Selected );
+ QListViewItem* selected = _ui->mSelectedView->findItem(
+ i18n("Single Entries"), 0, Qt::ExactMatch );
+ QListViewItem* selectedLists = _ui->mSelectedView->findItem(
+ i18n("Distribution Lists"), 0, Qt::ExactMatch );
+ while ( it.current() )
+ {
+ if( it.current()->depth() > 0 )
+ {
+ QString uid = it.current()->text( -1 );
+ kdDebug() << "addSelectedContacts(): uid :" << uid << endl;
+ if( !uid.isEmpty() )
+ {
+ KWMailMergeKABCConfigListItem *item =
+ static_cast<KWMailMergeKABCConfigListItem*> ( it.current() );
+ if( selected )
+ {
+ selected->insertItem( item );
+ selected->setOpen( true );
+ destroyAvailableClones( uid );
+ }
+ }
+ else if( it.current()->parent()->text(0) == i18n("Distribution Lists") )
+ {
+ if( selectedLists )
+ {
+ selectedLists->insertItem( it.current() );
+ selectedLists->setOpen( true );
+ }
+ }
+ }
+ ++it;
+ }
+ _ui->mSelectedView->selectAll( false );
+}
+
+
+void KWMailMergeKABCConfig::destroyAvailableClones( const QString& uid )
+{
+ if( uid.isEmpty() )
+ return;
+
+ QListViewItemIterator it( _ui->mAvailableView );
+
+ while ( it.current() )
+ {
+ if( it.current()->depth() > 0)
+ {
+ if( it.current()->text(-1)== uid )
+ {
+ delete it.current();
+ }
+ }
+ ++it;
+ }
+}
+
+
+void KWMailMergeKABCConfig::filterChanged( const QString& txt )
+{
+ kdDebug() << "KWMailMergeKABCConfig::filterChanged( " << txt << " )" << endl;
+
+ bool showAll = txt.isEmpty();
+
+ QListViewItem* category = _ui->mAvailableView->firstChild();
+ while(category)
+ {
+ if( category->text(0)!=i18n("Distribution Lists") )
+ {
+ QListViewItem* item = category->firstChild();
+ while(item)
+ {
+ if(showAll)
+ {
+ item->setVisible( true );
+ }
+ else
+ {
+ item->setVisible( item->text(0).contains( txt, false ) );
+ }
+ item = item->nextSibling();
+ }
+ category->setOpen( !showAll );
+ }
+ else
+ {
+ category->setVisible( showAll );
+ }
+ category = category->nextSibling();
+ }
+}
+
+
+void KWMailMergeKABCConfig::initSelectedAddressees()
+{
+ QStringList records = _db->singleRecords();
+
+ QListViewItem* category = _ui->mAvailableView->firstChild();
+ QListViewItem* selected = _ui->mSelectedView->findItem(
+ i18n("Single Entries"), 0, Qt::ExactMatch );
+ while ( category && (records.count()>0) )
+ {
+ if( category->text(0) != i18n("Distribution Lists") )
+ {
+ KWMailMergeKABCConfigListItem* item =
+ static_cast<KWMailMergeKABCConfigListItem*> ( category->firstChild() );
+ while( item && (records.count()>0) )
+ {
+ // Need some temporary item, because after selected->insertItem( item )
+ // the item->nextSibling() is not the one we want.
+ KWMailMergeKABCConfigListItem* nextItem =
+ static_cast<KWMailMergeKABCConfigListItem*> ( item->nextSibling() );
+
+ for( QStringList::Iterator itRecords = records.begin();
+ itRecords != records.end(); ++itRecords )
+ {
+ QString uid = *itRecords;
+ if( item->text(-1) == uid )
+ {
+ selected->insertItem( item );
+
+ // downsize records to speed up iterations
+ itRecords = records.remove( itRecords );
+ --itRecords;
+
+ destroyAvailableClones( uid );
+ }
+ }
+ item = nextItem;
+ }
+ }
+ category = category->nextSibling();
+ }
+}
+
+
+void KWMailMergeKABCConfig::initSelectedLists()
+{
+ QStringList lists = _db->lists();
+
+ kdDebug() << "::initSelectedLists()" << lists.join(",") << endl;
+
+ QListViewItem* l = _ui->mAvailableView->findItem(
+ i18n("Distribution Lists"), 0, Qt::ExactMatch );
+ QListViewItem* selected = _ui->mSelectedView->findItem(
+ i18n("Distribution Lists"), 0, Qt::ExactMatch );
+
+ QListViewItem* item = ( l->firstChild() );
+ while( item && (lists.count()>0) )
+ {
+ QListViewItem* nextItem = item->nextSibling();
+
+ for( QStringList::Iterator itLists = lists.begin();
+ itLists != lists.end(); ++itLists )
+ {
+ QString id = *itLists;
+ if( item->text(0) == id )
+ {
+ selected->insertItem( item );
+ itLists = lists.remove( itLists );
+ --itLists;
+ }
+ }
+ item = nextItem;
+ }
+}
+
+
+void KWMailMergeKABCConfig::initSlotSignalConnections()
+{
+ connect( this, SIGNAL( okClicked() ), SLOT( acceptSelection() ) );
+ connect( _ui->mAddButton, SIGNAL( clicked() ), SLOT( addSelectedContacts() ) );
+ connect( _ui->mAddressBook, SIGNAL( clicked() ), SLOT( launchAddressbook() ) );
+
+ connect( _ui->mAvailableView, SIGNAL( doubleClicked( QListViewItem *, const QPoint &, int ) ),
+ SLOT( addSelectedContacts() ) );
+
+ connect( _ui->mFilterEdit, SIGNAL( textChanged(const QString &) ),
+ SLOT( filterChanged(const QString &) ) );
+ connect( _ui->mRemoveButton, SIGNAL( clicked() ), SLOT( removeSelectedContacts() ) );
+ connect( _ui->mSaveList, SIGNAL( clicked() ), SLOT( saveDistributionList() ) );
+ connect( _ui->mSelectedView, SIGNAL( doubleClicked( QListViewItem *, const QPoint &, int ) ),
+ SLOT( removeSelectedContacts() ) );
+}
+
+
+void KWMailMergeKABCConfig::launchAddressbook() const
+{
+ kapp->startServiceByDesktopName( "kaddressbook", QString() );
+}
+
+
+
+void KWMailMergeKABCConfig::removeContact( QListViewItem* item )
+{
+ QStringList& categories = _usedCategories;
+ QListViewItem* availableLists = _ui->mAvailableView->findItem(
+ i18n("Distribution Lists"), 0, Qt::ExactMatch );
+ if( item->depth() > 0 )
+ {
+ if( !item->text( -1 ).isEmpty() ) // remove selected single entry here
+ {
+ KWMailMergeKABCConfigListItem* rightItem =
+ static_cast<KWMailMergeKABCConfigListItem*> ( item );
+
+ QStringList entryCategories = rightItem->addressee().categories();
+ for ( QStringList::Iterator itEntryCat = entryCategories.begin();
+ itEntryCat != entryCategories.end(); ++itEntryCat )
+ {
+ int i = categories.findIndex(*itEntryCat);
+ if( i == -1 )
+ {
+ QListViewItem* category = new QListViewItem( _ui->mAvailableView,
+ *itEntryCat );
+ categories.append( *itEntryCat );
+
+ KWMailMergeKABCConfigListItem* leftItem = new KWMailMergeKABCConfigListItem(
+ category, rightItem->addressee() );
+ }
+ else
+ {
+ KWMailMergeKABCConfigListItem* leftItem = new
+ KWMailMergeKABCConfigListItem(
+ _ui->mAvailableView->findItem(
+ *itEntryCat, 0,
+ Qt::ExactMatch),
+ rightItem->addressee() );
+ }
+ }
+ if( entryCategories.isEmpty() )
+ {
+ QString noCat = i18n("no category");
+ KWMailMergeKABCConfigListItem* leftItem = new KWMailMergeKABCConfigListItem(
+ _ui->mAvailableView->findItem(
+ noCat, 0, Qt::ExactMatch),
+ rightItem->addressee() );
+ }
+ delete item;
+ }
+ else if( item->parent()->text(0) == i18n("Distribution Lists") ) // remove a list
+ {
+ if( availableLists )
+ availableLists->insertItem( item );
+ }
+ }
+}
+
+void KWMailMergeKABCConfig::removeSelectedContacts()
+{
+ QListViewItemIterator it( _ui->mSelectedView, QListViewItemIterator::Selected );
+
+ while( it.current() )
+ {
+ kdDebug() << "removeSelectedContacts(): text: " << it.current()->text(-1) << endl;
+ removeContact( it.current() );
+ ++it;
+ }
+ _ui->mAvailableView->selectAll( false );
+}
+
+
+void KWMailMergeKABCConfig::saveDistributionList()
+{
+ KABC::DistributionListManager dlm( KABC::StdAddressBook::self() );
+ dlm.load();
+
+ bool ok = false;
+ QString listName = KInputDialog::getText( i18n("New Distribution List"),
+ i18n("Please enter name:"),
+ QString::null, &ok,
+ this );
+ if ( !ok || listName.isEmpty() )
+ return;
+
+ if ( dlm.list( listName ) )
+ {
+ KMessageBox::information( 0,
+ i18n( "<qt>Distribution list with the given name <b>%1</b> "
+ "already exists. Please select a different name.</qt>" )
+ .arg( listName ) );
+ return;
+ }
+ KABC::DistributionList *distList = new KABC::DistributionList( &dlm, listName );
+
+ QListViewItem* newListItem = new QListViewItem( _ui->mSelectedView->findItem(
+ i18n("Distribution Lists"),0 , Qt::ExactMatch), listName );
+
+ QListViewItem* category = _ui->mSelectedView->firstChild();
+ while(category)
+ {
+ if( category->text(0)==i18n("Single Entries") )
+ {
+ KWMailMergeKABCConfigListItem* item =
+ static_cast<KWMailMergeKABCConfigListItem*> ( category->firstChild() );
+
+ while(item)
+ {
+ distList->insertEntry( item->addressee() );
+
+ KABC::Addressee addr = item->addressee();
+ QString formattedName = addr.formattedName();
+ QListViewItem* newItem = new QListViewItem(
+ newListItem, item->addressee().formattedName() );
+ newItem->setEnabled( false );
+
+ item = static_cast<KWMailMergeKABCConfigListItem*>( item->nextSibling() );
+ }
+
+ QListViewItemIterator it ( category->firstChild() );
+ while( it.current() )
+ {
+ removeContact( it.current() );
+ ++it;
+ }
+ }
+ category = category->nextSibling();
+ }
+
+ dlm.save();
+ newListItem->setOpen( true );
+}
+
+
+void KWMailMergeKABCConfig::updateAvailable()
+{
+ _ui->mAvailableView->clear();
+ _ui->mAvailableView->setRootIsDecorated( true );
+
+ //
+ // First append the addressees.
+ //
+ QListViewItem* noCategory = new QListViewItem( _ui->mAvailableView,
+ i18n("no category") );
+
+ QStringList& categories = _usedCategories ;
+ categories.clear();
+
+ KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
+ for( KABC::AddressBook::Iterator itAddr = addressBook->begin();
+ itAddr != addressBook->end(); ++itAddr )
+ {
+
+ QStringList entryCategories = itAddr->categories();
+ for ( QStringList::Iterator itCat = entryCategories.begin();
+ itCat != entryCategories.end(); ++itCat )
+ {
+ int i = categories.findIndex(*itCat);
+
+ // Create category, if not yet in listview and append item to it.
+ if( i == -1 )
+ {
+ QListViewItem* category = new QListViewItem( _ui->mAvailableView, *itCat );
+ categories.append( *itCat );
+
+ KWMailMergeKABCConfigListItem* item = new KWMailMergeKABCConfigListItem(
+ category, *itAddr );
+ }
+ // Append item to existing category in listview.
+ else
+ {
+ KWMailMergeKABCConfigListItem* item = new KWMailMergeKABCConfigListItem(
+ _ui->mAvailableView->findItem(
+ *itCat, 0, Qt::ExactMatch),
+ *itAddr );
+ }
+
+ }
+ // If Addressee does not belong to any category, append it to "no category".
+ if( entryCategories.isEmpty() )
+ {
+ KWMailMergeKABCConfigListItem* item = new KWMailMergeKABCConfigListItem(
+ noCategory, *itAddr );
+ }
+ }
+
+ //
+ // Now append the distribution lists
+ //
+ KABC::DistributionListManager dlm ( addressBook );
+ dlm.load();
+
+ QStringList distributionLists = dlm.listNames();
+ QListViewItem* distributionListsItem = new QListViewItem( _ui->mAvailableView,
+ i18n("Distribution Lists") );
+
+ QStringList::Iterator itDistributionLists;
+
+ for( itDistributionLists = distributionLists.begin();
+ itDistributionLists != distributionLists.end(); ++itDistributionLists )
+ {
+ KABC::DistributionList* list = dlm.list( *itDistributionLists );
+
+ KABC::DistributionList::Entry::List entries = list->entries();
+
+ QListViewItem* listItem = new QListViewItem( distributionListsItem,
+ *itDistributionLists );
+
+ KABC::DistributionList::Entry::List::Iterator itList;
+ for ( itList = entries.begin(); itList != entries.end(); ++itList )
+ {
+ // Create a normal QListViewItem and disable it, because this is not a
+ // distribution-list-editor. KAddressbook should be used instead.
+ QListViewItem* item = new QListViewItem(
+ listItem, (*itList).addressee.formattedName() );
+ item->setEnabled( false );
+ }
+
+ }
+}
+
+
+
+KWMailMergeKABCConfigListItem::KWMailMergeKABCConfigListItem( QListView *parent,
+ const KABC::Addressee& addressEntry ) : QListViewItem( parent )
+{
+ setText( 0, addressEntry.formattedName() );
+ _addressEntry = addressEntry;
+}
+
+KWMailMergeKABCConfigListItem::KWMailMergeKABCConfigListItem( QListViewItem *parent,
+ const KABC::Addressee& addressEntry ) : QListViewItem( parent )
+{
+ setText( 0, addressEntry.formattedName() );
+ _addressEntry = addressEntry;
+}
+
+KWMailMergeKABCConfigListItem::~KWMailMergeKABCConfigListItem()
+{}
+
+KABC::Addressee KWMailMergeKABCConfigListItem::addressee() const
+{
+ return _addressEntry;
+}
+
+QString KWMailMergeKABCConfigListItem::text( int column ) const
+{
+ if( column == -1 )
+ {
+ return _addressEntry.uid();
+ }
+ else
+ {
+ return QListViewItem::text( column );
+ }
+}
+
+#include "KWMailMergeKABCConfig.moc"
diff --git a/kword/mailmerge/kabc/KWMailMergeKABCConfig.h b/kword/mailmerge/kabc/KWMailMergeKABCConfig.h
new file mode 100644
index 00000000..335574b8
--- /dev/null
+++ b/kword/mailmerge/kabc/KWMailMergeKABCConfig.h
@@ -0,0 +1,149 @@
+/*
+ This file is part of the KDE project
+ Copyright (C) 2004 Dirk Schmidt <[email protected]>
+
+ 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.
+*/
+
+#ifndef _KWMAILMERGE_KABC_CONFIG_H_
+#define _KWMAILMERGE_KABC_CONFIG_H_
+
+#include <kdialogbase.h>
+#include <klistview.h>
+#include <kabc/stdaddressbook.h>
+
+#include "KWMailMergeKABC.h"
+
+
+class AddressPickerUI;
+class KWMailMergeKABC;
+
+class KWMailMergeKABCConfig: public KDialogBase
+{
+ Q_OBJECT
+public:
+ KWMailMergeKABCConfig( QWidget *parent, KWMailMergeKABC *db_ );
+ virtual ~KWMailMergeKABCConfig();
+
+
+private slots:
+
+ /**
+ Moves selected items from the left Listview to the right one.
+ */
+ void addSelectedContacts();
+
+ /**
+ Moves selected items from the right Listview to the left one.
+ */
+ void removeSelectedContacts();
+
+ /**
+ Executes KAddressbook as external application.
+ */
+ void launchAddressbook() const;
+
+ /**
+ Updates the parent's mail merge list from items in the right Listview.
+ */
+ void acceptSelection();
+
+ /**
+ Hides items in the left listview, which are not matching @p txt.
+ */
+ void filterChanged( const QString& txt );
+
+ /**
+ Saves the selected single entries to a new KABC::DistributionList in KAddressbook.
+ */
+ void saveDistributionList();
+private:
+ /**
+ The addresspicker widget.
+ */
+ AddressPickerUI *_ui;
+
+ /**
+ Store all categories used in the addressbook, to avoid some iterator cycles.
+ */
+ QStringList _usedCategories;
+
+ /**
+ The mail merge list.
+ */
+ KWMailMergeKABC *_db;
+
+ /**
+ Removes duplicates in the left QListView, when moving an item to the right.
+ */
+ void destroyAvailableClones( const QString& uid );
+
+ /**
+ Appends the previously selected entries to the right QListView.
+ */
+ void initSelectedAddressees();
+
+ /**
+ Appends the previously selected distribution lists to the right QListView.
+ */
+ void initSelectedLists();
+
+ /**
+ Just connects signals and slots.
+ */
+ void initSlotSignalConnections();
+
+ /**
+ Moves @p item from the right Listview to the left one.
+
+ Called by KWMailMergeKABCConfig::removeSelectedContacts().
+ */
+ void removeContact( QListViewItem* item );
+
+ /**
+ Appends all KAddressbook entries in KABC::StdAddressBook::self() and all
+ KABC::DistributionLists to the left QListView.
+ */
+ void updateAvailable();
+};
+
+
+class KWMailMergeKABCConfigListItem : public QListViewItem
+{
+
+public:
+ KWMailMergeKABCConfigListItem( QListView *parent, const KABC::Addressee& addressEntry );
+ KWMailMergeKABCConfigListItem( QListViewItem *parent, const KABC::Addressee& addressEntry );
+ virtual ~KWMailMergeKABCConfigListItem();
+
+ /**
+ Returns the KABC::Addressee of a KWMailMergeKABCConfigListItem.
+ */
+ KABC::Addressee addressee() const;
+
+ /**
+ This is an overloaded member function of QListViewItem::text( int column ).
+ It Returns the KABC::Addressee::uid(), if column is set to -1.
+ Otherwise QListViewItem::text( int column ) is returned.
+ */
+ QString text( int column ) const;
+
+
+private:
+ KABC::Addressee _addressEntry;
+
+};
+#endif
diff --git a/kword/mailmerge/kabc/Makefile.am b/kword/mailmerge/kabc/Makefile.am
new file mode 100644
index 00000000..9231a371
--- /dev/null
+++ b/kword/mailmerge/kabc/Makefile.am
@@ -0,0 +1,17 @@
+
+KDE_CXXFLAGS = $(USE_RTTI)
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/lib/kformula \
+ $(KOTEXT_INCLUDES) -I$(top_srcdir)/kword $(all_includes)
+
+kde_module_LTLIBRARIES = kwmailmerge_kabc.la
+
+## Plugin encapsulating the QT SQL database interface
+kwmailmerge_kabc_la_SOURCES = KWMailMergeKABC.cpp KWMailMergeKABCConfig.cpp addresspicker.ui
+kwmailmerge_kabc_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kwmailmerge_kabc_la_LIBADD = ../../libkwmailmerge_interface.la $(LIB_KDEUI) $(LIB_KABC)
+
+METASOURCES = AUTO
+
+services_DATA=kwmailmerge_kabc.desktop
+servicesdir=$(kde_servicesdir)
+
diff --git a/kword/mailmerge/kabc/addresspicker.ui b/kword/mailmerge/kabc/addresspicker.ui
new file mode 100644
index 00000000..ec179c3b
--- /dev/null
+++ b/kword/mailmerge/kabc/addresspicker.ui
@@ -0,0 +1,297 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>AddressPickerUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>AddressPickerUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>617</width>
+ <height>434</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Address Selection</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>mAddButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Add &gt;&gt;</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>mRemoveButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&lt;&lt; &amp;Remove</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QPushButton" row="2" column="2">
+ <property name="name">
+ <cstring>mSaveList</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Save as &amp;Distribution List...</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Save selected single entries to a new distribution list.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Filter on:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>mFilterEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>mFilterEdit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="KListView" row="1" column="2">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>Distribution Lists</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Single Entries</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>mSelectedView</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="2" column="1">
+ <property name="name">
+ <cstring>mAddressBook</cstring>
+ </property>
+ <property name="text">
+ <string>Address B&amp;ook</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Launch KAddressbook</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>&amp;Address Book</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>mAvailableView</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>&amp;Selected Addresses</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>mSelectedView</cstring>
+ </property>
+ </widget>
+ <widget class="KListView" row="1" column="0">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>mAvailableView</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode" stdset="0">
+ <enum>Extended</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/kword/mailmerge/kabc/kwmailmerge_kabc.desktop b/kword/mailmerge/kabc/kwmailmerge_kabc.desktop
new file mode 100644
index 00000000..77dd7d4a
--- /dev/null
+++ b/kword/mailmerge/kabc/kwmailmerge_kabc.desktop
@@ -0,0 +1,105 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=KWord/MailMergePlugin
+
+Name=KDE Addressbook Plugin
+Name[bg]=Приставка за адресника на KDE
+Name[br]=Lugent Karned chomlec'hioù KDE
+Name[ca]=Connector de llibreta d'adreces KDE
+Name[cs]=Modul Knihy adres KDE
+Name[cy]=Ategyn Llyfr Cyfeiriadau KDE
+Name[da]=KDE's adressebog Plugin
+Name[de]=KDE Adressbuch-Modul
+Name[el]=Πρόσθετο βιβλίου διευθύνσεων του KDE
+Name[eo]=KDE Adresaro-kromprogramo
+Name[es]=Accesorio de la libreta de direcciones de KDE
+Name[et]=KDE aadressiraamatu plugin
+Name[eu]=KDE-ren helbide-liburuaren plugina
+Name[fa]=وصلۀ کتاب نشانی KDE
+Name[fi]=KDE:n osoitekirjan liitännäinen
+Name[fr]=Module externe de carnet d'adresses de KDE
+Name[fy]=Adresboekplugin foar KDE
+Name[gl]=Plugin do Libro de Enderezos de KDE
+Name[he]=תוסף של פנקס הכתובות של KDE
+Name[hi]=केडीई पतापुस्तिका प्लगिन
+Name[hr]=KDE dodatak adresara
+Name[hu]=Illesztőmodul a KDE címjegyzékhez
+Name[is]=KDE vistfanga íforrit
+Name[it]=Plugin per la rubrica degli indirizzi KDE
+Name[ja]=KDE アドレス帳プラグイン
+Name[km]=កម្មវិធី​ជំនួយ​សៀវភៅ​អាសយដ្ឋាន KDE
+Name[lv]=KDE adrešu grāmatiņas spraudnis
+Name[ms]=Plugin Buku Alamat KDE
+Name[nb]=Programtillegg for KDE-adresseboka
+Name[nds]=Adressbook-Moduul för KDE
+Name[ne]=KDE ठेगानापुस्तक प्लगइन
+Name[nl]=Adresboekplugin voor KDE
+Name[nn]=Programtillegg for KDE-adresseboka
+Name[pl]=Wtyczka Książki adresowej KDE
+Name[pt]='Plugin' do Livro de Endereços do KDE
+Name[pt_BR]=Livro de Endereços do KDE
+Name[ru]=Модуль адресной книги KDE
+Name[se]=KDE:a čujuhusgirjemoduvla
+Name[sk]=Modul pre KDE adresár
+Name[sl]=Vstavek Adresar KDE
+Name[sr]=Прикључак за KDE-ов адресар
+Name[sr@Latn]=Priključak za KDE-ov adresar
+Name[sv]=Insticksprogram för KDE:s adressbok
+Name[ta]= KDE முகவரிப்புத்தகம் சொருகு
+Name[tg]=Дарҷ кардани KDE Китоби Адресҳо
+Name[tr]=KDE Adres Defteri Eklentisi
+Name[uk]=Втулок адресної книги KDE
+Name[uz]=KDE manzillar daftari plagini
+Name[uz@cyrillic]=KDE манзиллар дафтари плагини
+Name[wa]=Tchôke-divins calpin d' adresses KDE
+Name[zh_CN]=KDE 地址簿插件
+Name[zh_TW]=KDE 通訊錄外掛程式
+Comment=This datasource type lets you use your KDE Address Book entries.
+Comment[bg]=Този източник на данни се свързва директно с адресника на KDE и чете данните от там.
+Comment[ca]=Aquest tipus de font de dades permet usar les entrades de la llibreta d'adreces del KDE.
+Comment[cs]=Tento zdroj dat umožňuje využít položky z Knihy adres.
+Comment[cy]=Mae'r math yma o ffynhonell ddata yn eich galluogi i ddefnyddio eich cofnodion Llyfr Cyfeiriadau KDE.
+Comment[da]=Denne datakildetype lader dig bruge dine KDE adressebogsindgange.
+Comment[de]=Dieser Quellentyp ermöglicht die Verwendung von KDE-Adressbucheinträgen.
+Comment[el]=Αυτή η πηγή δεδομένων σας επιτρέπει να χρησιμοποιήσετε τις καταχωρήσεις σας από το βιβλίο διευθύνσεων του KDE.
+Comment[es]=Este tipo de fuente de datos le permite usar las entradas de su libreta de direcciones de KDE.
+Comment[et]=See andmeallika tüüp võimaldab kasutada KDE aadressiraamatu kirjeid.
+Comment[eu]=Datu-iturburu honek zure KDE-ko helbide-liburuko sarrerak erabiltzeko aukera ematen dizu.
+Comment[fa]=این نوع متن داده‌ به شما اجازۀ استفاده از مدخلهای کتاب نشانی KDE را می‌دهد.
+Comment[fi]=Tämän tietolähteen avulla voit käyttää KDE:n osoitekirjan tietoja.
+Comment[fr]=Ce type de source de données vous permet d'utiliser votre carnet d'adresses KDE.
+Comment[fy]=Mei dizze plugin ha jo taging ta jo KDE adresboek.
+Comment[gl]=Este tipo de fonte de datos armacena os datos directamente no Libro de Enderezos de KDE.
+Comment[he]=טיפוס מקור נתונים זה מאפשר לך להשתמש ברשומות שלך מתוך פנקס הכתובות של KDE.
+Comment[hi]=यह डाटा स्रोत क़िस्म आपको केडीई पता पुस्तिका प्रविष्टियों को इस्तेमाल करने देती है.
+Comment[hu]=Ez az adatforrástípus a KDE címjegyzék adatait teszi hozzáférhetővé.
+Comment[is]=Þessi auðlindategund gerir þér kleyft að nota færslur frá KDE vistfangaskránni þinni.
+Comment[it]=Questo tipo di fonte di dati permette di usare le voci della rubrica degli indirizzi di KDE.
+Comment[ja]=KDE アドレス帳のデータを使用できるようにします。
+Comment[km]=ប្រភេទ​ប្រភព​ទិន្នន័យ​នេះ​អនុញ្ញាត​ឲ្យ​អ្នក​ប្រើ​ធាតុ​សៀវភៅ​អាសយដ្ឋាន KDE របស់​អ្នក ។
+Comment[ms]=Jenis sumber data ini membenarkan anda menggunakan entri Buku Alamat KDE anda.
+Comment[nb]=Med denne datakildetypen kan du få tilgang til oppføringene i KDE-adresseboka.
+Comment[nds]=Mit dissen Datenborntyp laat sik KDE-Adressbookindrääg bruken.
+Comment[ne]=यो डेटासंसाधनले तपाईंलाई तपाईंको KDE ठेगाना पुस्तक प्रविष्टिहरू प्रयोग गर्न दिन्छ ।
+Comment[nl]=Via deze plugin hebt u toegang tot uw KDE-adresboek.
+Comment[nn]=Med denne datakjeldetypen kan du få tilgang til oppføringane i KDE-adresseboka.
+Comment[pl]=To źródło danych pozwala Ci używać Twoich wpisów z Książki adresowej KDE.
+Comment[pt]=Este tipo de fonte de dados armazena os dados directamente no Livro de Endereços do KDE.
+Comment[pt_BR]=Este tipo de fonte de dados permite-lhe usar suas entradas do Livro de Endereços do KDE.
+Comment[ru]=Источник данных, работающий с записями адресной книги KDE
+Comment[se]=Dát dáhtagáldu diktá du geavahit KDE-čujuhusgirjemerkošiid.
+Comment[sk]=Tento typ zdroja dát umožňuje používať záznamy z KDE adresára.
+Comment[sl]=Ta tip vira podatkov vam omogoča uporabljati vnose vašega Adresarja KDE.
+Comment[sr]=Овај тип извора података омогућава вам да користите ставке из KDE-овог адресара.
+Comment[sr@Latn]=Ovaj tip izvora podataka omogućava vam da koristite stavke iz KDE-ovog adresara.
+Comment[sv]=Den här typen av datakälla låter dig använda information från KDE:s adressbok
+Comment[ta]=பலகத்தின் தோற்றத்தை நீங்கள் இங்கே வடிவமைக்கலாம்.
+Comment[tg]=Ин намуди манбаъи маълумот гузоштани шумо истифода кардан шуморо воридҳои Китоби Адресҳои KDE.
+Comment[tr]=Bu veri kaynağı biçimi KDE Adres Defteri girdilerini kullanmanızı sağlar.
+Comment[uk]=Цей тип джерела даних дає доступ до записів адресної книги KDE.
+Comment[zh_CN]=该数据源类型允许您使用您的 KDE 地址簿条目。
+Comment[zh_TW]=這個資料來源類別讓您使用您的 KDE 通訊錄項目。
+
+X-KDE-Library=kwmailmerge_kabc
+X-KDE-Capabilities=open
+X-KDE-InternalName=KABC