not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / shells / common / plasmaappletitemmodel_p.h
blob13b23c2b6e4bbd042429a8758fb83c190b552d56
1 /*
2 * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library/Lesser General Public License
6 * version 2, or (at your option) any later version, as published by the
7 * Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library/Lesser General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_PLASMAAPPLETITEMMODEL_P_H
21 #define PLASMA_PLASMAAPPLETITEMMODEL_P_H
23 #include <KPluginInfo>
25 #include <Plasma/Applet>
27 #include "kcategorizeditemsview_p.h"
29 class PlasmaAppletItemModel;
31 /**
32 * Implementation of the KCategorizedItemsViewModels::AbstractItem
34 class PlasmaAppletItem : public QObject, public KCategorizedItemsViewModels::AbstractItem
36 Q_OBJECT
38 public:
39 enum FilterFlag {
40 NoFilter = 0,
41 Favorite = 1,
42 Used = 2
45 Q_DECLARE_FLAGS(FilterFlags, FilterFlag)
47 PlasmaAppletItem(PlasmaAppletItemModel *model, const QMap<QString, QVariant>& info, FilterFlags flags = NoFilter, QMap<QString, QVariant> *extraAttrs = NULL);
49 virtual QString name() const;
50 QString pluginName() const;
51 virtual QString description() const;
52 virtual int running() const;
53 virtual bool used() const;
54 virtual void setUsed(bool used);
55 virtual void setFavorite(bool favorite);
56 //set how many instances of this applet are running
57 virtual void setRunning(int count);
58 virtual bool passesFiltering(const KCategorizedItemsViewModels::Filter & filter) const;
59 virtual QVariantList arguments() const;
61 private:
62 PlasmaAppletItemModel * m_model;
65 class PlasmaAppletItemModel :
66 public KCategorizedItemsViewModels::DefaultItemModel
68 Q_OBJECT
70 public:
71 explicit PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent = 0);
73 QStringList mimeTypes() const;
75 QMimeData *mimeData(const QModelIndexList &indexes) const;
77 void setFavorite(const QString &plugin, bool favorite);
78 void setApplication(const QString &app);
79 void setRunningApplets(const QHash<QString, int> &apps);
80 void setRunningApplets(const QString &name, int count);
82 QString &Application();
84 private:
85 QString m_application;
86 QStringList m_favorites;
87 QStringList m_used;
88 KConfigGroup m_configGroup;
90 private slots:
91 void populateModel();
94 Q_DECLARE_OPERATORS_FOR_FLAGS(PlasmaAppletItem::FilterFlags)
96 #endif /*PLASMAAPPLETSMODEL_H_*/