Plasma
datacontainer.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_DATACONTAINER_H 00021 #define PLASMA_DATACONTAINER_H 00022 00023 #include <QtCore/QHash> 00024 #include <QtCore/QObject> 00025 #include <QtCore/QTimer> 00026 00027 #include <kjob.h> 00028 #include <plasma/plasma_export.h> 00029 #include <plasma/dataengine.h> 00030 00031 namespace Plasma 00032 { 00033 00034 class DataContainerPrivate; 00035 00063 class PLASMA_EXPORT DataContainer : public QObject 00064 { 00065 friend class DataEngine; 00066 friend class DataEnginePrivate; 00067 Q_OBJECT 00068 00069 public: 00074 explicit DataContainer(QObject *parent = 0); 00075 virtual ~DataContainer(); 00076 00080 const DataEngine::Data data() const; 00081 00097 void setData(const QString &key, const QVariant &value); 00098 00107 void removeAllData(); 00108 00112 bool visualizationIsConnected(QObject *visualization) const; 00113 00124 void connectVisualization(QObject *visualization, uint pollingInterval, 00125 Plasma::IntervalAlignment alignment); 00126 00132 void setStorageEnabled(bool store); 00133 00138 bool isStorageEnabled() const; 00139 00143 bool needsToBeStored() const; 00144 00149 void setNeedsToBeStored(bool store); 00150 00155 DataEngine* getDataEngine(); 00156 00157 public Q_SLOTS: 00164 void disconnectVisualization(QObject *visualization); 00165 00170 void forceImmediateUpdate(); 00171 00172 Q_SIGNALS: 00184 void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data); 00185 00195 void becameUnused(const QString &source); 00196 00210 void updateRequested(DataContainer *source); 00211 00212 protected: 00216 void checkForUpdate(); 00217 00225 uint timeSinceLastUpdate() const; 00226 00235 void setNeedsUpdate(bool update = true); 00236 00237 protected Q_SLOTS: 00246 void checkUsage(); 00247 00248 private: 00249 friend class SignalRelay; 00250 friend class DataContainerPrivate; 00251 friend class DataEngineManager; 00252 DataContainerPrivate *const d; 00253 00254 Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job)) 00255 Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job)) 00256 Q_PRIVATE_SLOT(d, void store()) 00257 Q_PRIVATE_SLOT(d, void retrieve()) 00258 }; 00259 00260 } // Plasma namespace 00261 00262 #endif // multiple inclusion guard
KDE 4.6 API Reference