/****************************************************************************
**
** 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 CLASSIFICATIONMODEL_H
#define CLASSIFICATIONMODEL_H
#include <QObject>
#include "feedclassifiers.h"

namespace NewsBlur
{
class FeedClassifiersModel : public QObject
{
    Q_OBJECT
    Q_PROPERTY(int feedClassification READ feedClassification WRITE setFeedClassification NOTIFY feedClassificationChanged)
    Q_PROPERTY(int newTitleClassifier READ newTitleClassifier WRITE setNewTitleClassifier NOTIFY newTitleClassifierChanged)
    Q_PROPERTY(QString feedTitle READ feedTitle WRITE setFeedTitle NOTIFY feedTitleChanged)
public:
    FeedClassifiersModel(QObject* parent = 0);
    FeedClassifiers classifiers() const;
    void setClassifiers(const FeedClassifiers& classifierSet);
    QString feedTitle() const;
    void setFeedTitle(const QString& title);

public slots:
    Q_INVOKABLE QStringList titles() const;
    Q_INVOKABLE QStringList tags() const;
    Q_INVOKABLE QStringList authors() const;
    Q_INVOKABLE int titleClassification(const QString& title) const;
    Q_INVOKABLE void setTitleClassification(const QString& title, int classification);
    Q_INVOKABLE int tagClassification(const QString& tag) const;
    Q_INVOKABLE void setTagClassification(const QString& tag, int classification);
    Q_INVOKABLE int authorClassification(const QString& author) const;
    Q_INVOKABLE void setAuthorClassification(const QString& author, int classification);
    Q_INVOKABLE void setFeedClassification(int classification);
    Q_INVOKABLE int feedClassification() const;
    Q_INVOKABLE int newTitleClassifier() const;
    Q_INVOKABLE void setNewTitleClassifier(int classification);
    Q_INVOKABLE void setNewTitleClassifierText(const QString& text);

private:
    mutable ClassifierHash m_titles;
    ClassifierHash m_tags;
    ClassifierHash m_authors;
    NewsBlurEnum::ClassifierValue m_feedClassification;
    NewsBlurEnum::ClassifierValue m_newTitleClassifier;
    QString m_newTitleClassifierText;
    QString m_feedTitle;

signals:
    void feedClassificationChanged();
    void feedTitleChanged();
    void newTitleClassifierChanged();
};
} // namespace NewsBlur
#endif // CLASSIFICATIONMODEL_H
