/****************************************************************************
**
** 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 FEEDITEM_H
#define FEEDITEM_H
#include "newsbluritem.h"
#include <QDeclarativePropertyMap>
#include "globals.h"
#include "feedclassifiers.h"

namespace NewsBlur
{
class FeedItem : public NewsBlurItem
{
    Q_OBJECT
    Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadCountChanged)
    Q_PROPERTY(int posUnreadCount READ posUnreadCount NOTIFY posUnreadCountChanged)
    Q_PROPERTY(int negUnreadCount READ negUnreadCount NOTIFY negUnreadCountChanged)
    Q_PROPERTY(QString unreadCountText READ unreadCountText NOTIFY unreadCountTextChanged)

public:
    explicit FeedItem(PageItemPtr parent = PageItemPtr(), AbstractFeedAggreagatorService* service = 0);
    
    NewsBlurItem::ItemType itemType() const;
    int unreadCount() const;
    void setUnreadCount(int unreadCount);
    int posUnreadCount() const;
    void setPosUnreadCount(int unreadCount);
    int negUnreadCount() const;
    void setNegUnreadCount(int unreadCount);
    bool isOutOfDate() const;
    void markAsOutOfDate(bool outOfDate);
    FeedClassifiers classifiers() const;
    void setClassifiers(const FeedClassifiers& classifiers);
    QString unreadCountText() const;
    void setUnreadCountText(const QString& text);
    int filteredChildCount(NewsBlurEnum::ClassificationFilter filter) const;
    QDateTime lastAccessDate() const;
    bool isRead() const;
    void setChildrenRead(bool read);

private:
    int m_unreadCount;
    int m_posUnreadCount;
    int m_negUnreadCount;
    bool m_outOfDate;
    FeedClassifiers m_classifiers;
    QString m_unreadCountText;
    QDateTime m_lastAccessDate;
    void updateUnreadCountText();

private slots:
    void onActivityChanged();

signals:
    void unreadCountChanged();
    void unreadCountTextChanged();
    void negUnreadCountChanged();
    void posUnreadCountChanged();
};
typedef QSharedPointer<FeedItem> FeedItemPtr;
typedef QWeakPointer<FeedItem> FeedItemWeakRef;
} // namespace NewsBlur
#endif // FEEDITEM_H
