~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to libs/plasma/dataengine.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-11 14:04:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071011140448-v0eb7lxbb24zagca
Tags: 3.94.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <kgenericfactory.h>
28
28
 
29
29
#include <plasma/plasma_export.h>
 
30
#include <plasma/plasma.h>
30
31
 
31
32
namespace Plasma
32
33
{
87
88
         *
88
89
         * @param source the name of the data source
89
90
         * @param visualization the object to connect the data source to
90
 
         **/
91
 
        Q_INVOKABLE void connectSource(const QString& source, QObject* visualization) const;
 
91
         * @param updateInterval the frequency, in milliseconds, with which to signal updates;
 
92
         *                        a value of 0 (the default) means to update only
 
93
         *                        when there is new data spontaneously generated
 
94
         *                        (e.g. by the engine); any other value results in
 
95
         *                        periodic updates from this source. This value is
 
96
         *                        per-visualization and can be handy for items that require
 
97
         *                        constant updates such as scrolling graphs or clocks.
 
98
         * @param intervalAlignedTo the number of ms to aling the interval to
 
99
         **/
 
100
        Q_INVOKABLE void connectSource(const QString& source, QObject* visualization,
 
101
                                       uint updateInterval = 0,
 
102
                                       Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
 
103
 
 
104
        /**
 
105
         * Connects all sources to an object for data updates. The object must
 
106
         * have a slot with the following signature:
 
107
         *
 
108
         * SLOT(updated(QString, Plasma::DataEngine::Data))
 
109
         *
 
110
         * The data is a QHash of QVariants keyed by QString names, allowing
 
111
         * one data source to provide sets of related data.
 
112
         *
 
113
         * This method may be called multiple times for the same visualization
 
114
         * without side-effects. This can be useful to change the updateInterval.
 
115
         *
 
116
         * @param visualization the object to connect the data source to
 
117
         * @param updateInterval the frequency, in milliseconds, with which to signal updates;
 
118
         *                        a value of 0 (the default) means to update only
 
119
         *                        when there is new data spontaneously generated
 
120
         *                        (e.g. by the engine); any other value results in
 
121
         *                        periodic updates from this source. This value is
 
122
         *                        per-visualization and can be handy for items that require
 
123
         *                        constant updates such as scrolling graphs or clocks.
 
124
         **/
 
125
        Q_INVOKABLE void connectAllSources(QObject* viualization, uint updateInterval = 0,
 
126
                                           Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
92
127
 
93
128
        /**
94
129
         * Disconnects a source to an object that was receiving data updates.
99
134
        Q_INVOKABLE void disconnectSource(const QString& source, QObject* visualization) const;
100
135
 
101
136
        /**
102
 
         * Connects all sources to an object for data updates. The object must
103
 
         * have a slot with the following signature:
104
 
         *
105
 
         * SLOT(updated(QString, Plasma::DataEngine::Data))
106
 
         *
107
 
         * The data is a QHash of QVariants keyed by QString names, allowing
108
 
         * one data source to provide sets of related data.
109
 
         *
110
 
         * @param visualization the object to connect the data source to
111
 
         **/
112
 
        Q_INVOKABLE void connectAllSources(QObject* viualization) const;
113
 
 
114
 
        /**
115
137
         * Retrevies a pointer to the DataContainer for a given source. This method
116
138
         * should not be used if possible. An exception is for script engines that 
117
139
         * can not provide a QMetaObject as required by connectSource for the initial
202
224
         * otherwise the requesting visualization may not receive notice of a
203
225
         * data update.
204
226
         *
 
227
         * If the source can not be populated with data immediately (e.g. due to
 
228
         * an asynchronous data acquisition method such as an HTTP request)
 
229
         * the source must still be created, even if it is empty. This can
 
230
         * be accomplished in these cases with the follow line:
 
231
         *
 
232
         *      setData(name, DataEngine::Data());
 
233
         *
205
234
         * @return true if a DataContainer was set up, false otherwise
206
235
         */
207
236
        virtual bool sourceRequested(const QString &name);
208
237
 
209
238
        /**
 
239
         * Called by internal updating mechanisms to trigger the engine
 
240
         * to refresh the data contained in a given source. Reimplement this
 
241
         * method when using facilities such as setUpdateInterval.
 
242
         * @see setUpdateInterval
 
243
         *
 
244
         * @param source the name of the source that should be updated
 
245
         * @return true if the data was changed, or false if there was no
 
246
         *         change or if the change will occur later
 
247
         **/
 
248
        virtual bool updateSource(const QString& source);
 
249
 
 
250
        /**
210
251
         * Sets a value for a data source. If the source
211
252
         * doesn't exist then it is created.
212
253
         *
265
306
         **/
266
307
        void setSourceLimit(uint limit);
267
308
 
268
 
/*        DataContainer* domain(const QString &domain);
269
 
        void createDataContainer(const QString& source,
270
 
                              const QString& domain = QString());*/
 
309
        /**
 
310
         * Sets the minimum amount of time, in milliseconds, that must pass between
 
311
         * successive updates of data. This can help prevent too many updates happening
 
312
         * due to multiple update requests coming in, which can be useful for
 
313
         * expensive (time- or resource-wise) update mechanisms.
 
314
         *
 
315
         * @arg minimumMs the minimum time lapse, in milliseconds, between updates.
 
316
         *                A value less than 0 means to never perform automatic updates,
 
317
         *                a value of 0 means update immediately on every update request,
 
318
         *                a value >0 will result in a minimum time lapse being enforced.
 
319
         **/
 
320
        void setMinimumUpdateInterval(int minimumMs);
 
321
 
 
322
        /**
 
323
         * @return the minimum time between updates. @see setMinimumupdateInterval
 
324
         **/
 
325
        int minimumUpdateInterval() const;
 
326
 
 
327
        /**
 
328
         * Sets up an internal update tick for all data sources. On every update,
 
329
         * updateSource will be called for each applicable source.
 
330
         * @see updateSource
 
331
         *
 
332
         * @param frequency the time, in milliseconds, between updates. A value of 0
 
333
         *                  will stop internally triggered updates.
 
334
         **/
 
335
        void setUpdateInterval(uint frequency);
 
336
 
 
337
        /**
 
338
         * Returns the current update frequency.
 
339
         * @see setUpdateInterval
 
340
         NOTE: This is not implemented to prevent having to store the value internally.
 
341
               When there is a good use case for needing access to this value, we can
 
342
               add another member to the Private class and add this method.
 
343
        uint updateInterval();
 
344
         **/
271
345
 
272
346
        /**
273
347
         * Removes all data sources
288
362
         */
289
363
        SourceDict sourceDict() const;
290
364
 
 
365
        /**
 
366
         * Reimplemented from QObject
 
367
         **/
 
368
        void timerEvent(QTimerEvent *event);
 
369
 
291
370
    protected Q_SLOTS:
292
371
        /**
293
372
         * Call this method when you call setData directly on a DataContainer instead
307
386
         **/
308
387
        void startInit();
309
388
 
 
389
        /**
 
390
         * @internal
 
391
         **/
 
392
        void internalUpdateSource(DataContainer* source);
 
393
 
310
394
    private:
311
395
        class Private;
312
396
        Private* const d;