Implement ratings, blacklists, add some const correctness

This commit is contained in:
Luca Beltrame 2013-03-17 11:59:15 +01:00
parent f442c2f605
commit 816b370302
2 changed files with 60 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/*
* <one line to give the library's name and an idea of what it does.>
* This file is part of libdanbooru.
* Copyright 2013 Luca Beltrame <lbeltrame@kde.org>
*
* This program is free software; you can redistribute it and/or
@ -33,14 +33,18 @@
#include <QtCore/QObject>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <QtCore/QSet>
#include <QtXml/QXmlStreamAttributes>
// KDE
#include <KUrl>
class QPixmap;
// Own
#include "danbooru.h"
class QPixmap;
namespace Danbooru {
@ -66,15 +70,15 @@ namespace Danbooru {
Q_OBJECT
Q_PROPERTY(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(QStringList tags READ tags)
Q_PROPERTY(QSet<QString> tags READ tags)
Q_PROPERTY(KUrl thumbnailUrl READ thumbnailUrl)
private:
QPixmap* m_pixmap;
const QPixmap* m_pixmap;
// basic features of a post
@ -85,7 +89,14 @@ namespace Danbooru {
KUrl m_url;
KUrl m_thumbnailUrl;
QStringList m_tags;
QSet<QString> m_tags;
Ratings m_rating;
static const QMap<QString, Rating> RATING_MAP;
// Private functions
static const QMap< QString, Rating > initRatingMap();
public:
@ -156,7 +167,7 @@ namespace Danbooru {
/**
* @return The tags associated to the post.
**/
QStringList tags() const;
const QSet< QString > tags() const;
/**
* @return The URL to the post's thumbnail.
@ -166,13 +177,18 @@ namespace Danbooru {
/**
* @return A pointer to the thumbnail's pixmap.
**/
QPixmap* pixmap() const;
const QPixmap* pixmap() const;
/**
* @return The current post's rating.
**/
const Ratings rating() const;
/**
* Set the post's pixmap to a specific QPixmap instance's pointer.
*
**/
void setPixmap(QPixmap* pixmap);
void setPixmap(const QPixmap* pixmap);
/**
* @return A string representation of the post.