Get rid of QPixmap pointers

According to my understanding of Qt documentation, there should be no need to
manually create QPixmap with new and delete. This also makes things simpler for the model.
This commit is contained in:
Luca Beltrame 2014-08-28 09:19:20 +02:00
parent dafe9d2c3e
commit 061251bc26
2 changed files with 17 additions and 17 deletions

View file

@ -38,7 +38,7 @@ namespace Danbooru {
const QMap<QString, Rating> DanbooruPost::RATING_MAP = initRatingMap();
DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap* pixmap,
DanbooruPost::DanbooruPost(QVariantMap postData, QPixmap pixmap,
QObject* parent):
QObject(parent),
m_pixmap(pixmap)
@ -56,9 +56,7 @@ namespace Danbooru {
}
DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData,
QPixmap* pixmap,
QObject* parent):
DanbooruPost::DanbooruPost(QXmlStreamAttributes& postData, QPixmap pixmap, QObject* parent):
QObject(parent),
m_pixmap(pixmap)
{
@ -101,7 +99,7 @@ namespace Danbooru {
}
void DanbooruPost::setPixmap(const QPixmap* pixmap)
void DanbooruPost::setPixmap(const QPixmap pixmap)
{
m_pixmap = pixmap;
}
@ -138,7 +136,7 @@ namespace Danbooru {
return m_thumbnailUrl;
}
const QPixmap* DanbooruPost::pixmap() const
const QPixmap DanbooruPost::pixmap() const
{
return m_pixmap;
}

View file

@ -30,11 +30,12 @@
// Qt
#include <QtCore/QObject>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <QtCore/QSet>
#include <QtXml/QXmlStreamAttributes>
#include <QObject>
#include <QVariant>
#include <QStringList>
#include <QSet>
#include <QXmlStreamAttributes>
#include <QPixmap>
// KDE
@ -70,7 +71,7 @@ namespace Danbooru {
Q_OBJECT
Q_PROPERTY(const QPixmap* pixmap READ pixmap WRITE setPixmap)
Q_PROPERTY(const QPixmap pixmap READ pixmap WRITE setPixmap)
Q_PROPERTY(int id READ id)
Q_PROPERTY(KUrl fileUrl READ fileUrl)
Q_PROPERTY(QSet<QString> tags READ tags)
@ -78,7 +79,7 @@ namespace Danbooru {
private:
const QPixmap* m_pixmap;
const QPixmap m_pixmap;
// basic features of a post
@ -113,7 +114,7 @@ namespace Danbooru {
* @param parent A pointer to the parent QObject.
*
**/
explicit DanbooruPost(QVariantMap postData, QPixmap* pixmap = 0,
explicit DanbooruPost(QVariantMap postData, QPixmap pixmap = QPixmap(),
QObject* parent = 0);
/**
@ -131,7 +132,7 @@ namespace Danbooru {
*
**/
explicit DanbooruPost(QXmlStreamAttributes& postData,
QPixmap* pixmap = 0, QObject* parent=0);
QPixmap pixmap = QPixmap(), QObject* parent =0);
bool operator==(const DanbooruPost&);
@ -177,7 +178,7 @@ namespace Danbooru {
/**
* @return A pointer to the thumbnail's pixmap.
**/
const QPixmap* pixmap() const;
const QPixmap pixmap() const;
/**
* @return The current post's rating.
@ -188,7 +189,7 @@ namespace Danbooru {
* Set the post's pixmap to a specific QPixmap instance's pointer.
*
**/
void setPixmap(const QPixmap* pixmap);
void setPixmap(const QPixmap pixmap);
/**
* @return A string representation of the post.
@ -203,3 +204,4 @@ namespace Danbooru {
Q_DECLARE_METATYPE(Danbooru::DanbooruPost*)
#endif // DANBOORUPOST_H