Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 0ad2fe52 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement email support

parent 7b7dd09d
......@@ -51,11 +51,43 @@ Email::Email()
}
Email::Email(const QString &mail, bool preferred)
: d( new Private )
{
d->mail = mail;
d->preferred = preferred;
}
Email::~Email()
{
}
QMap<QString, QStringList> Email::parameters() const
{
return d->parameters;
}
bool Email::operator==(const Email &other) const
{
return (d->parameters == other.parameters()) && (d->mail == other.mail()) && (d->preferred == other.preferred());
}
void Email::setPreferred(bool pref)
{
d->preferred = pref;
}
bool Email::preferred() const
{
return d->preferred;
}
void Email::setParameters(const QMap<QString, QStringList> &params)
{
d->parameters = params;
}
void Email::setEmail(const QString &mail)
{
d->mail = mail;
......
......@@ -25,6 +25,11 @@
#include "kabc_export.h"
#include <QtCore/QSharedDataPointer>
#include <QtCore/QString>
#include <qmap.h>
/** @short Class that holds a Email for a contact.
* @since 4.14.5
*/
namespace KABC {
......@@ -33,13 +38,27 @@ class KABC_EXPORT Email
friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Email & );
friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Email & );
public:
/**
* Creates an empty email object.
*/
Email();
Email(const QString &mail, bool preferred);
~Email();
void setEmail(const QString &mail);
QString mail() const;
bool isValid() const;
void setParameters(const QMap<QString, QStringList> &params);
QMap<QString, QStringList> parameters() const;
void setPreferred(bool pref);
bool preferred() const;
bool operator==( const Email &other ) const;
private:
class Private;
QSharedDataPointer<Private> d;
......
......@@ -185,3 +185,14 @@ set(vcarddragtest_SRCS vcarddragtest.cpp)
kde4_add_unit_test(vcarddragtest TESTNAME kabc-vcarddragtest ${vcarddragtest_SRCS})
target_link_libraries(vcarddragtest ${KDE4_KDECORE_LIBS} kabc ${QT_QTTEST_LIBRARY})
########### next target ###############
set(emailtest_SRCS emailtest.cpp)
kde4_add_unit_test(emailtest TESTNAME kabc-emailtest ${emailtest_SRCS})
target_link_libraries(emailtest ${KDE4_KDECORE_LIBS} kabc ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY})
/*
This file is part of libkabc.
Copyright (c) 2015 Laurent Montel <montel@kde.org>
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 "emailtest.h"
#include "kabc/email.h"
#include <qtest_kde.h>
EmailTest::EmailTest(QObject *parent)
: QObject(parent)
{
}
EmailTest::~EmailTest()
{
}
void EmailTest::shouldHaveDefaultValue()
{
KABC::Email email;
QVERIFY(!email.isValid());
QVERIFY(email.mail().isEmpty());
QVERIFY(email.parameters().isEmpty());
QVERIFY(!email.preferred());
}
QTEST_KDEMAIN(EmailTest, NoGUI)
/*
This file is part of libkabc.
Copyright (c) 2015 Laurent Montel <montel@kde.org>
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 EMAILTEST_H
#define EMAILTEST_H
#include <QObject>
class EmailTest : public QObject
{
Q_OBJECT
public:
explicit EmailTest(QObject *parent = 0);
~EmailTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // EMAILTEST_H
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