/****************************************************************************
**
** 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 NEWSBLURITEM_H
#define NEWSBLURITEM_H
#include "pageitem.h"
#include <QPointer>
#include "globals.h"

namespace NewsBlur
{
class NewsBlurItem : public PageItem
{
    Q_OBJECT
    Q_PROPERTY(ItemType itemType READ itemType NOTIFY itemTypeChanged)
    Q_PROPERTY(bool feedReadBusy READ feedReadBusy WRITE setFeedReadBusy NOTIFY feedReadBusyChanged)
    Q_PROPERTY(bool movingBusy READ movingBusy WRITE setMovingBusy NOTIFY movingBusyChanged)
    Q_PROPERTY(bool deletingBusy READ deletingBusy WRITE setDeletingBusy NOTIFY deletingBusyChanged)    
    Q_ENUMS(ItemType)
public:
    enum ItemType
    {
        UndefinedType,
        RootItem,
        FeedItem,
        FolderItem,
        StoryItem,
        StarredGroup,
        EverythingGroup
    };
    explicit NewsBlurItem(PageItemPtr parent = PageItemPtr(), AbstractFeedAggreagatorService* service = 0);
    virtual NewsBlurItem::ItemType itemType() const;
    bool feedReadBusy() const;
    void setFeedReadBusy(bool busy);
    bool movingBusy() const;
    void setMovingBusy(bool busy);
    bool deletingBusy() const;
    void setDeletingBusy(bool busy);

private:
    ItemType m_itemType;
    bool m_feedReadBusy;
    bool m_movingBusy;
    bool m_deletingBusy;

signals:
    void feedReadBusyChanged();
    void movingBusyChanged();
    void deletingBusyChanged();
    void itemTypeChanged();
};
typedef QSharedPointer<NewsBlurItem> NewsBlurItemPtr;
typedef QWeakPointer<NewsBlurItem> NewsBlurItemWeakRef;
inline uint qHash(const NewsBlurItemWeakRef& item)
{
    return qHash(item.data());
}
} // namespace NewsBlur
Q_DECLARE_METATYPE(NewsBlur::NewsBlurItem::ItemType)
Q_DECLARE_METATYPE(QPointer<NewsBlur::NewsBlurItem>)
Q_DECLARE_METATYPE(NewsBlur::NewsBlurItemWeakRef)
#endif // NEWSBLURITEM_H
