Commit 0aac1b42 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove this unused class now

parent aecc5bc7
Pipeline #23699 passed with stage
in 16 minutes and 1 second
......@@ -31,7 +31,6 @@ set(kdepim_widgets_LIB_SRCS
set(kdepim_misc_LIB_SRCS
misc/emailvalidator.cpp
misc/maillistdrag.cpp
misc/uistatesaver.cpp
misc/lineeditcatchreturnkey.cpp
)
......@@ -114,7 +113,6 @@ ecm_generate_headers(libkdepim_Camelcasewidgets_HEADERS
ecm_generate_headers(libkdepim_Camelcasemisc_HEADERS
HEADER_NAMES
EmailValidator
MaillistDrag
UiStateSaver
KCursorSaver
LineEditCatchReturnKey
......
/*
This file is part of libkdepim.
Copyright (c) 2003 Don Sanders <sanders@kde.org>
Copyright (c) 2005 George Staikos <staikos@kde.org>
Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
Copyright (c) 2008 Thomas McGuire <mcguire@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 "maillistdrag.h"
#include <QDateTime>
#include <QBuffer>
#include <QDataStream>
using namespace KPIM;
// Have to define before use
QDataStream &operator<<(QDataStream &s, const MailSummary &d)
{
s << d.serialNumber();
s << d.messageId();
s << d.subject();
s << d.from();
s << d.to();
QDateTime tempTime;
tempTime.setSecsSinceEpoch(d.date());
s << tempTime;
return s;
}
QDataStream &operator>>(QDataStream &s, MailSummary &d)
{
quint32 serialNumber;
QString messageId, subject, from, to;
time_t date;
s >> serialNumber;
s >> messageId;
s >> subject;
s >> from;
s >> to;
QDateTime tempTime;
s >> tempTime;
date = QDateTime(tempTime).toSecsSinceEpoch();
d.set(serialNumber, messageId, subject, from, to, date);
return s;
}
QDataStream &operator<<(QDataStream &s, const MailList &mailList)
{
MailList::const_iterator it;
MailList::const_iterator end(mailList.constEnd());
for (it = mailList.constBegin(); it != end; ++it) {
MailSummary mailDrag = *it;
s << mailDrag;
}
return s;
}
QDataStream &operator>>(QDataStream &s, MailList &mailList)
{
mailList.clear();
MailSummary mailDrag;
while (!s.atEnd()) {
s >> mailDrag;
mailList.append(mailDrag);
}
return s;
}
MailSummary::MailSummary(quint32 serialNumber, const QString &messageId, const QString &subject, const QString &from, const QString &to, time_t date)
: mSerialNumber(serialNumber)
, mMessageId(messageId)
, mSubject(subject)
, mFrom(from)
, mTo(to)
, mDate(date)
{
}
quint32 MailSummary::serialNumber() const
{
return mSerialNumber;
}
QString MailSummary::messageId() const
{
return mMessageId;
}
QString MailSummary::subject() const
{
return mSubject;
}
QString MailSummary::from() const
{
return mFrom;
}
QString MailSummary::to() const
{
return mTo;
}
time_t MailSummary::date() const
{
return mDate;
}
bool MailSummary::operator ==(const MailSummary &other) const
{
return (mSerialNumber == other.mSerialNumber)
&& (mMessageId == other.mMessageId)
&& (mSubject == other.mSubject)
&& (mFrom == other.mFrom)
&& (mTo == other.mTo)
&& (mDate == other.mDate);
}
void MailSummary::set(quint32 serialNumber, const QString &messageId, const QString &subject, const QString &from, const QString &to, time_t date)
{
mSerialNumber = serialNumber;
mMessageId = messageId;
mSubject = subject;
mFrom = from;
mTo = to;
mDate = date;
}
QString MailList::mimeDataType()
{
return QStringLiteral("x-kmail-drag/message-list");
}
bool MailList::canDecode(const QMimeData *md)
{
if (md) {
return md->hasFormat(mimeDataType());
} else {
return false;
}
}
void MailList::populateMimeData(QMimeData *md)
{
/* We have three different possible mime types: x-kmail-drag/message-list, message/rfc822, and URL
Add them in this order */
/* Popuplate the MimeData with the custom streaming x-kmail-drag/message-list mime type */
if (md && !isEmpty()) {
QByteArray array;
QBuffer buffer(&array, nullptr);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
stream << (*this);
buffer.close();
md->setData(MailList::mimeDataType(), array);
}
}
MailList MailList::fromMimeData(const QMimeData *md)
{
if (canDecode(md)) {
return decode(md->data(mimeDataType()));
} else {
return MailList();
}
}
MailList MailList::decode(const QByteArray &payload)
{
MailList mailList;
// A read-only data stream
QDataStream stream(payload);
if (!payload.isEmpty()) {
stream >> mailList;
}
return mailList;
}
QByteArray MailList::serialsFromMimeData(const QMimeData *md)
{
MailList mailList = fromMimeData(md);
if (!mailList.isEmpty()) {
MailList::const_iterator it;
QByteArray a;
QBuffer buffer(&a);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
MailList::const_iterator end(mailList.constEnd());
for (it = mailList.constBegin(); it != end; ++it) {
MailSummary mailDrag = *it;
stream << mailDrag.serialNumber();
}
buffer.close();
return a;
} else {
return QByteArray();
}
}
/*
This file is part of libkdepim.
Copyright (c) 2003 Don Sanders <sanders@kde.org>
Copyright (c) 2005 George Staikos <staikos@kde.org.
Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
Copyright (c) 2008 Thomas McGuire <mcguire@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 KDEPIM_MAILLISTDRAG_H
#define KDEPIM_MAILLISTDRAG_H
#include "kdepim_export.h"
#include <QList>
#include <QMimeData>
#include <QString>
#include <time.h>
namespace KPIM {
/**
* @defgroup maildnd Mail drag and drop
*
* KDEPIM classes for drag and drop of mails
*
* \code
* // Code example for drag and drop enabled widget
*
* void SomeWidget::contentsDropEvent(QDropEvent *e)
* {
* if ( KPIM::MailList::canDecode( e->mimeData() ) ) {
* MailList mailList = KPIM::MailList::fromMimeData( e->mimeData() );
* ...
* \endcode
* @{
**/
/**
Represents a single dragged mail.
*/
class KDEPIM_EXPORT MailSummary
{
public:
MailSummary(quint32 serialNumber, const QString &messageId, const QString &subject, const QString &from, const QString &to, time_t date);
MailSummary()
{
}
~MailSummary()
{
}
/** Set fields for this mail summary */
void set(quint32, const QString &, const QString &, const QString &, const QString &, time_t);
/** KMail unique identification number */
quint32 serialNumber() const;
/** MD5 checksum of message identification string */
QString messageId() const;
/** Subject of the message including prefixes */
QString subject() const;
/** Simplified from address */
QString from() const;
/** Simplified to address */
QString to() const;
/** Date the message was sent */
time_t date() const;
bool operator ==(const MailSummary &other) const;
private:
quint32 mSerialNumber;
QString mMessageId, mSubject, mFrom, mTo;
time_t mDate;
};
/**
List of mail summaries.
*/
class KDEPIM_EXPORT MailList : public QList<MailSummary>
{
public:
static QString mimeDataType();
static bool canDecode(const QMimeData *md);
static MailList fromMimeData(const QMimeData *md);
static QByteArray serialsFromMimeData(const QMimeData *md);
static MailList decode(const QByteArray &payload);
void populateMimeData(QMimeData *md);
};
} // namespace KPIM
#endif /*maillistdrag_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