Commit 5f42263a authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

KChatBaseMessage: use QSharedDataPointer & QSharedData instead of manual code

NO_CHANGELOG
parent dd5855ba
......@@ -14,8 +14,9 @@
#include <KSharedConfig>
// Qt
#include <QFont>
#include <QSharedData>
class KChatBaseMessagePrivate
class KChatBaseMessagePrivate : public QSharedData
{
public:
KChatBaseMessagePrivate()
......@@ -27,30 +28,26 @@ public:
};
KChatBaseMessage::KChatBaseMessage()
: d(new KChatBaseMessagePrivate())
{
d = new KChatBaseMessagePrivate();
}
KChatBaseMessage::KChatBaseMessage(const QString& sender, const QString& message,
MessageType type) :
QPair<QString,QString>(sender,message)
, d(new KChatBaseMessagePrivate())
{
d = new KChatBaseMessagePrivate();
d->m_type = type;
}
KChatBaseMessage::KChatBaseMessage(const KChatBaseMessage& m) :
QPair< QString, QString >(m)
, d(m.d)
{
d = new KChatBaseMessagePrivate();
d->m_type = m.d->m_type;
}
KChatBaseMessage::~KChatBaseMessage()
{
delete d;
}
KChatBaseMessage::~KChatBaseMessage() = default;
class KChatBaseModelPrivate
{
......
......@@ -14,6 +14,7 @@
// Qt
#include <QAbstractListModel>
#include <QPair>
#include <QSharedDataPointer>
#include <QLoggingCategory>
// Std
#include <memory>
......@@ -57,7 +58,7 @@ class KDEGAMESPRIVATE_EXPORT KChatBaseMessage : public QPair< QString, QString >
virtual ~KChatBaseMessage();
private:
KChatBaseMessagePrivate* d;
QSharedDataPointer<KChatBaseMessagePrivate> d;
};
Q_DECLARE_METATYPE(KChatBaseMessage)
......
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