Commit 47f21a92 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Save/load address

parent 4c18212b
......@@ -46,14 +46,27 @@ AddressesLocationWidget::~AddressesLocationWidget()
}
KContacts::Address::List AddressesLocationWidget::addresses() const
void AddressesLocationWidget::loadContact(const KContacts::Addressee &contact)
{
return mAddressesLocationViewer->addresses();
mAddressesLocationViewer->setAddresses(contact.addresses());
}
void AddressesLocationWidget::setAddresses(const KContacts::Address::List &addresses)
void AddressesLocationWidget::storeContact(KContacts::Addressee &contact) const
{
mAddressesLocationViewer->setAddresses(addresses);
// delete all previous addresses
const KContacts::Address::List oldAddresses = contact.addresses();
for (int i = 0; i < oldAddresses.count(); ++i) {
contact.removeAddress(oldAddresses.at(i));
}
const KContacts::Address::List addressList = mAddressesLocationViewer->addresses();
// insert the new ones
for (int i = 0; i < addressList.count(); ++i) {
const KContacts::Address address(addressList.at(i));
if (!address.isEmpty()) {
contact.insertAddress(address);
}
}
}
void AddressesLocationWidget::setReadOnly(bool readOnly)
......
......@@ -25,7 +25,7 @@
#define ADDRESSESLOCATIONWIDGET_H
#include <QSplitter>
#include <KContacts/Address>
#include <KContacts/Addressee>
class AddressesLocationViewer;
class AddressLocationWidget;
class AddressesLocationWidget : public QSplitter
......@@ -35,8 +35,8 @@ public:
explicit AddressesLocationWidget(QWidget *parent = Q_NULLPTR);
~AddressesLocationWidget();
KContacts::Address::List addresses() const;
void setAddresses(const KContacts::Address::List &addresses);
void loadContact(const KContacts::Addressee &contact);
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment