summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp33
-rw-r--r--kabc/converter/opie/opieconverter.h2
2 files changed, 4 insertions, 31 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index b4e9f1c..0b6a55e 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -41,65 +41,65 @@ OpieConverter::OpieConverter() : catDB(0)
{
}
OpieConverter::~OpieConverter()
{
deinit();
}
bool OpieConverter::init()
{
catDB = new Categories();
if (catDB)
{
catDB->load( categoryFileName() );
return true;
}
else
{
return false;
}
}
void OpieConverter::deinit()
{
if (catDB)
{
delete catDB;
catDB = 0;
}
}
-bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
+bool OpieConverter::opieToAddressee( const OContact &contact, Addressee &addr )
{
// name
addr.setFormattedName(contact.fileAs());
addr.setFamilyName( contact.lastName() );
addr.setGivenName( contact.firstName() );
addr.setAdditionalName( contact.middleName() );
addr.setPrefix( contact.title() );
addr.setSuffix( contact.suffix() );
// email
QStringList emails = contact.emailList();
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
}
if (!contact.defaultEmail().isEmpty())
addr.insertEmail(contact.defaultEmail(), true);
// home
if ((!contact.homeStreet().isEmpty()) ||
(!contact.homeCity().isEmpty()) ||
(!contact.homeState().isEmpty()) ||
(!contact.homeZip().isEmpty()) ||
(!contact.homeCountry().isEmpty()))
{
Address homeaddress;
homeaddress.setType(Address::Home);
//US homeaddress.setPostOfficeBox( "" );
//US homeaddress.setExtended( "" );
homeaddress.setStreet( contact.homeStreet() );
homeaddress.setLocality( contact.homeCity() );
@@ -200,73 +200,69 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
//personal
addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
if (contact.anniversary().isValid()) {
QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
//US
qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
if (contact.birthday().isValid())
addr.setBirthday( contact.birthday() );
addr.setNickName( contact.nickname() );
// others
//US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
QString notes = contact.notes();
notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
addr.setNote( contact.notes() );
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
QStringList cats = contact.categoryNames("Contacts");
+ addr.setCategories( cats );
// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
// qDebug("Cat: %s", (*it).latin1());
// }
-
- addr.setCategories( contact.categoryNames("Contacts") );
-// qDebug("Groups: %s", contact.groups().latin1());
-// addr.setCategories( contact.groupList() );
-
return true;
}
bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
{
// name
contact.setLastName(addr.familyName());
contact.setFirstName(addr.givenName());
contact.setMiddleName(addr.additionalName());
contact.setTitle(addr.prefix());
contact.setSuffix(addr.suffix());
contact.setFileAs();
// email
QStringList emails = addr.emails();
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
contact.insertEmail(*it);
}
contact.setDefaultEmail( addr.preferredEmail() );
// home
const Address homeaddress = addr.address(Address::Home);
if (!homeaddress.isEmpty()) {
contact.setHomeStreet(homeaddress.street());
contact.setHomeCity(homeaddress.locality());
contact.setHomeState(homeaddress.region());
contact.setHomeZip(homeaddress.postalCode());
contact.setHomeCountry(homeaddress.country());
}
@@ -311,65 +307,42 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
if (!businesspager.number().isEmpty())
contact.setBusinessPager(businesspager.number());
contact.setJobTitle(addr.role());
contact.setCompany(addr.organization());
contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
//personal
contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" ));
QDate dt = KGlobal::locale()->readDate(
addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
contact.setAnniversary( dt );
contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
contact.setBirthday(addr.birthday().date());
contact.setNickname(addr.nickName());
// other
contact.setNotes(addr.note());
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
-/*US
- QStringList cats = contact.categoryNames("Contacts");
- for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
- qDebug("Cat: %s", (*it).latin1());
- }
-*/
-
-// addr.setCategories( contact.categoryNames("Contacts") );
-// contact.categoryNames("Contacts");
-// contact.setCategoryNames(addr.categories());
-
-/*US
- QStringList cats = addr.categories();
- QArray<int> cat(cats.count());
- int counter = 0;
- for ( QStringList::ConstIterator it = cats.begin(); it != cats.end(); ++it )
- cat[counter] = (*it).toInt();
-
- contact.setCategories( cat );
-*/
-
- Categories catDB;
- catDB.load( categoryFileName() );
QStringList cats = addr.categories();
QArray<int> iar;
if ( !cats.isEmpty() ) {
- QArray<int> iar = catDB.ids("contact", cats);
+ QArray<int> iar = catDB->ids("contact", cats);
contact.setCategories(iar);
}
return true;
}
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
index 7d2ad85..c7e691f 100644
--- a/kabc/converter/opie/opieconverter.h
+++ b/kabc/converter/opie/opieconverter.h
@@ -31,50 +31,50 @@ $Id$
#include <qstring.h>
#include "addressee.h"
#include <opie/ocontact.h>
class Categories;
namespace KABC {
class OpieConverter
{
public:
/**
* Constructor.
*/
OpieConverter();
/**
* Destructor.
*/
virtual ~OpieConverter();
virtual bool init();
virtual void deinit();
/**
* Converts a vcard string to an addressee.
*
* @param contact The opie contact.
* @param addr The addressee.
*/
- bool opieToAddressee( OContact &contact, Addressee &addr );
+ bool opieToAddressee( const OContact &contact, Addressee &addr );
/**
* Converts an addressee to a vcard string.
*
* @param addr The addressee.
* @param contact The opie contact.
*/
bool addresseeToOpie( const Addressee &addr, OContact &contact );
private:
Categories* catDB;
};
}
#endif