2007-09-26 09:44:06 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-10-12 10:44:02 +02:00
|
|
|
* it under the terms of the GNU Library/Lesser General Public License
|
|
|
|
* version 2, or (at your option) any later version, as published by the
|
|
|
|
* Free Software Foundation
|
2007-09-26 09:44:06 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2007-10-12 10:44:02 +02:00
|
|
|
* You should have received a copy of the GNU Library/Lesser General Public
|
2007-09-26 09:44:06 +02:00
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-19 10:12:34 +01:00
|
|
|
#ifndef PLASMAAPPLETITEMMODEL_P_H
|
|
|
|
#define PLASMAAPPLETITEMMODEL_P_H
|
2007-09-26 09:44:06 +02:00
|
|
|
|
|
|
|
#include <KPluginInfo>
|
2007-09-27 20:51:31 +02:00
|
|
|
|
|
|
|
#include <plasma/applet.h>
|
|
|
|
|
|
|
|
#include "kcategorizeditemsview_p.h"
|
2007-09-26 09:44:06 +02:00
|
|
|
|
2007-10-09 11:51:55 +02:00
|
|
|
class PlasmaAppletItemModel;
|
|
|
|
|
2007-09-26 09:44:06 +02:00
|
|
|
/**
|
|
|
|
* Implementation of the KCategorizedItemsViewModels::AbstractItem
|
|
|
|
*/
|
|
|
|
class PlasmaAppletItem : public KCategorizedItemsViewModels::AbstractItem,
|
|
|
|
QObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum FilterFlag {NoFilter = 0,
|
|
|
|
Favorite = 1,
|
2007-10-08 23:50:38 +02:00
|
|
|
Used = 2};
|
2007-09-26 09:44:06 +02:00
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(FilterFlags, FilterFlag)
|
|
|
|
|
2007-10-12 19:30:30 +02:00
|
|
|
PlasmaAppletItem(PlasmaAppletItemModel * model, const QMap<QString, QVariant>& info,
|
2007-10-08 23:50:38 +02:00
|
|
|
FilterFlags flags = NoFilter, QMap<QString, QVariant> * extraAttrs = NULL);
|
2007-09-26 09:44:06 +02:00
|
|
|
|
|
|
|
virtual QString name() const;
|
|
|
|
QString pluginName() const;
|
|
|
|
virtual QString description() const;
|
2007-12-10 02:18:57 +01:00
|
|
|
virtual int running() const;
|
2007-09-26 09:44:06 +02:00
|
|
|
virtual void setFavorite(bool favorite);
|
2007-12-10 02:18:57 +01:00
|
|
|
//set how many instances of this applet are running
|
|
|
|
virtual void setRunning(int count);
|
2007-09-26 09:44:06 +02:00
|
|
|
virtual bool passesFiltering(
|
|
|
|
const KCategorizedItemsViewModels::Filter & filter) const;
|
2007-10-12 19:30:30 +02:00
|
|
|
virtual QVariantList arguments() const;
|
|
|
|
|
2007-10-09 11:51:55 +02:00
|
|
|
private:
|
|
|
|
PlasmaAppletItemModel * m_model;
|
2007-09-26 09:44:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class PlasmaAppletItemModel :
|
|
|
|
public KCategorizedItemsViewModels::DefaultItemModel
|
|
|
|
{
|
|
|
|
public:
|
2008-02-19 09:32:32 +01:00
|
|
|
explicit PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent = 0);
|
2007-09-26 09:44:06 +02:00
|
|
|
|
|
|
|
QStringList mimeTypes() const;
|
|
|
|
|
|
|
|
QMimeData* mimeData(const QModelIndexList & indexes) const;
|
2007-10-09 11:51:55 +02:00
|
|
|
|
2008-02-19 10:19:02 +01:00
|
|
|
void setFavorite(const QString &plugin, bool favorite);
|
2007-11-06 03:45:24 +01:00
|
|
|
void setApplication(const QString& app);
|
2008-02-19 10:19:02 +01:00
|
|
|
void setRunningApplets(const QHash<QString, int> &apps);
|
|
|
|
void setRunningApplets(const QString &name, int count);
|
2007-11-06 03:45:24 +01:00
|
|
|
|
|
|
|
QString& Application();
|
2007-10-09 11:51:55 +02:00
|
|
|
private:
|
2007-11-06 03:45:24 +01:00
|
|
|
QString m_application;
|
2007-10-09 11:51:55 +02:00
|
|
|
QStringList m_favorites;
|
2007-10-12 19:30:30 +02:00
|
|
|
QStringList m_used;
|
2007-10-09 11:51:55 +02:00
|
|
|
KConfigGroup m_configGroup;
|
2007-10-12 19:30:30 +02:00
|
|
|
|
|
|
|
void loadSuperKarambaThemes(const KPluginInfo &info);
|
2007-11-06 22:10:11 +01:00
|
|
|
void populateModel();
|
2007-09-26 09:44:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(PlasmaAppletItem::FilterFlags)
|
|
|
|
|
|
|
|
#endif /*PLASMAAPPLETSMODEL_H_*/
|