/* * Copyright (C) 2013 Canonical, Ltd. * * Authors: * MichaƂ Sawicz * Michal Hruby * * This program 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; version 3. * * This program 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 this program. If not, see . */ #ifndef CATEGORIES_H #define CATEGORIES_H // unity-core #include // dee-qt #include "deelistmodel.h" #include #include #include class Categories : public DeeListModel { Q_OBJECT Q_ENUMS(Roles) public: explicit Categories(QObject* parent = 0); enum Roles { RoleCategoryId, RoleName, RoleIcon, RoleRenderer, RoleContentType, RoleProgressSource, RoleHints, RoleResults, RoleCount }; Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model); QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; QHash roleNames() const; /* setters */ void setUnityScope(const unity::dash::Scope::Ptr& scope); private Q_SLOTS: void onCountChanged(); void onRowCountChanged(); void onEmitCountChanged(); void onOverrideModelDestroyed(); private: void onCategoriesModelChanged(unity::glib::Object model); DeeListModel* getResults(int index) const; unity::dash::Scope::Ptr m_unityScope; QTimer m_timer; QSet m_updatedCategories; QHash m_roles; QMap m_overriddenCategories; mutable QMap m_results; sigc::connection m_categoriesChangedConnection; }; #endif // CATEGORIES_H