/****************************************************************************
**
** Copyright (C) 2012 Róbert Márki
**
** This file is part of Web Feeds.
**
** Web Feeds is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Web Feeds 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Web Feeds.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#ifndef STORYITEM_H
#define STORYITEM_H
#include "googlereaderitem.h"
#include <QUrl>

namespace GoogleReader
{
class StoryItem : public GoogleReaderItem
{
    Q_OBJECT
    Q_PROPERTY(bool isRead READ isRead NOTIFY readChanged)
    Q_PROPERTY(bool isReadStateLocked READ isReadStateLocked NOTIFY readStateLockedChanged)
    Q_PROPERTY(bool isKeptUnread READ isKeptUnread NOTIFY keptUnreadChanged)
    Q_PROPERTY(bool starred READ isStarred NOTIFY starredChanged)
    Q_PROPERTY(QString contents READ contents NOTIFY contentsChanged)
    Q_PROPERTY(QString url READ url NOTIFY urlChanged)
    Q_PROPERTY(bool starredBusy READ isStarredBusy WRITE setStarredBusy NOTIFY starredBusyChanged)
    Q_PROPERTY(QDateTime date READ date)
    Q_PROPERTY(QString formattedDate READ formattedDate)
    Q_PROPERTY(QString formattedDateTime READ formattedDateTime)
    Q_PROPERTY(QString feedId READ feedId)
    Q_PROPERTY(QString author READ author)
    Q_PROPERTY(QStringList tags READ tags NOTIFY tagsChanged)
    Q_PROPERTY(bool isInReadingList READ isInReadingList WRITE setInReadingList)
public:
    explicit StoryItem(PageItemPtr parent = PageItemPtr(), AbstractFeedAggreagatorService* service = 0);
    GoogleReaderItem::ItemType itemType() const;
    bool isRead() const;
    void setRead(bool read);
    bool isKeptUnread() const;
    void setKeptUnread(bool keptUnread);
    bool isStarred() const;
    void setStarred(bool starred);
    QString contents() const;
    void setContents(const QString& contents);
    QString url() const;
    void setUrl(const QString& url);
    bool isStarredBusy() const;
    void setStarredBusy(bool busy);
    QDateTime date() const;
    void setDate(const QDateTime& date);
    QString formattedDate() const;
    QString formattedDateTime() const;
    QString feedId() const;
    void setFeedId(const QString& feedId);
    QString author() const;
    void setAuthor(const QString& author);
    bool isReadStateLocked() const;
    void setReadStateLocked(bool locked);
    QStringList tags() const;
    void setTags(const QStringList &tags);
    bool isInReadingList() const;
    void setInReadingList(bool inReadingList);

private:
    bool m_read;
    bool m_readStateLocked;
    bool m_keptUnread;
    bool m_starred;
    bool m_inReadingList;
    QString m_contents;
    QString m_url;
    bool m_starredBusy;
    QDateTime m_date;
    QString m_fromattedDate;
    QString m_formattedDateTime;
    QString m_feedId;
    QString m_author;
    QStringList m_tags;

signals:
    void readChanged();
    void keptUnreadChanged();
    void starredChanged();
    void urlChanged();
    void starredBusyChanged();
    void contentsChanged();
    void readStateLockedChanged();
    void tagsChanged();
};
typedef QSharedPointer<StoryItem> StoryItemPtr;
typedef QWeakPointer<StoryItem> StoryItemWeakRef;
} // namespace GoogleReader
#endif // STORYITEM_H
