put sourceLimit back in, add an accessor as well. used by akonadi

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800769
This commit is contained in:
Aaron J. Seigo 2008-04-24 20:16:21 +00:00
parent 4bb368919d
commit 9250bd82b4
4 changed files with 45 additions and 0 deletions

View File

@ -418,6 +418,26 @@ void DataEngine::addSource(DataContainer* source)
emit sourceAdded(source->objectName());
}
void DataEngine::setSourceLimit(uint limit)
{
if (d->limit == limit) {
return;
}
d->limit = limit;
if (d->limit > 0) {
d->trimQueue();
} else {
d->sourceQueue.clear();
}
}
uint DataEngine::sourceLimit() const
{
return d->limit;
}
void DataEngine::setMinimumPollingInterval(int minimumMs)
{
d->minPollingInterval = minimumMs;

View File

@ -196,6 +196,14 @@ class PLASMA_EXPORT DataEngine : public QObject
*/
bool isEmpty() const;
/**
* Returns the maximum number of sources this DataEngine will list
* at any given time.
*
* @return the maximum number of sources; zero means no limit.
*/
uint sourceLimit() const;
/**
* @return the name of the icon for this data engine; and empty string
* is returned if there is no associated icon.
@ -307,6 +315,15 @@ class PLASMA_EXPORT DataEngine : public QObject
**/
void addSource(DataContainer* source);
/**
* Sets an upper limit on the number of data sources to keep in this engine.
* If the limit is exceeded, then the oldest data source, as defined by last
* update, is dropped.
*
* @param limit the maximum number of sources to keep active
**/
void setSourceLimit(uint limit);
/**
* Sets the minimum amount of time, in milliseconds, that must pass between
* successive updates of data. This can help prevent too many updates happening

View File

@ -92,6 +92,13 @@ void DataEngineScript::removeData(const QString& source, const QString& key)
}
}
void DataEngineScript::setSourceLimit(uint limit)
{
if (d->dataEngine) {
d->dataEngine->setSourceLimit(limit);
}
}
void DataEngineScript::setMinimumPollingInterval(int minimumMs)
{
if (d->dataEngine) {

View File

@ -80,6 +80,7 @@ protected:
void setData(const QString &source, const QVariant &value);
void clearData(const QString& source);
void removeData(const QString& source, const QString& key);
void setSourceLimit(uint limit);
void setMinimumPollingInterval(int minimumMs);
int minimumPollingInterval() const;
void setPollingInterval(uint frequency);