Plasma

datacontainer.h
1 /*
2  * Copyright 2006-2007 Aaron Seigo <[email protected]>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
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
13  *
14  * You should have received a copy of the GNU Library 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.
18  */
19 
20 #ifndef PLASMA_DATACONTAINER_H
21 #define PLASMA_DATACONTAINER_H
22 
23 #include <QHash>
24 #include <QObject>
25 #include <QTimer>
26 
27 #include <kjob.h>
28 #include <plasma/plasma_export.h>
29 #include <plasma/dataengine.h>
30 
31 class QAbstractItemModel;
32 
33 namespace Plasma
34 {
35 
36 class DataContainerPrivate;
37 
65 class PLASMA_EXPORT DataContainer : public QObject
66 {
67  friend class DataEngine;
68  friend class DataEnginePrivate;
69  Q_OBJECT
70 
71 public:
76  explicit DataContainer(QObject *parent = nullptr);
77  ~DataContainer() override;
78 
82  const DataEngine::Data data() const;
83 
99  void setData(const QString &key, const QVariant &value);
100 
109  void removeAllData();
110 
124  void setModel(QAbstractItemModel *model);
125 
129  QAbstractItemModel *model();
130 
134  bool visualizationIsConnected(QObject *visualization) const;
135 
146  void connectVisualization(QObject *visualization, uint pollingInterval,
148 
154  void setStorageEnabled(bool store);
155 
160  bool isStorageEnabled() const;
161 
165  bool needsToBeStored() const;
166 
171  void setNeedsToBeStored(bool store);
172 
177  DataEngine *getDataEngine();
178 
182  bool isUsed() const;
183 
184 public Q_SLOTS:
191  void disconnectVisualization(QObject *visualization);
192 
197  void forceImmediateUpdate();
198 
199 Q_SIGNALS:
211  void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data);
212 
221  void modelChanged(const QString &source, QAbstractItemModel *model);
222 
232  void becameUnused(const QString &source);
233 
247  void updateRequested(DataContainer *source);
248 
249 protected:
253  void checkForUpdate();
254 
262  uint timeSinceLastUpdate() const;
263 
272  void setNeedsUpdate(bool update = true);
273 
274 protected Q_SLOTS:
278  void timerEvent(QTimerEvent *event) override;
279 
280 private:
281  friend class SignalRelay;
282  friend class DataContainerPrivate;
283  friend class DataEngineManager;
284  DataContainerPrivate *const d;
285 
286  Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job))
287  Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job))
288  Q_PRIVATE_SLOT(d, void retrieve())
289 };
290 
291 } // Plasma namespace
292 
293 #endif // multiple inclusion guard
Namespace for everything in libplasma.
Definition: datamodel.cpp:27
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:60
IntervalAlignment
Possible timing alignments.
Definition: plasma.h:204
A set of data exported via a DataEngine.
Definition: datacontainer.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 7 2020 22:39:38 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.