[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: [Panel-devel] engines, applets and timing
From:       Michael Olbrich <michael-olbrich () web ! de>
Date:       2007-09-16 10:12:35
Message-ID: 20070916101235.GA26790 () c027 ! apm ! etc ! tu-bs ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

On Wed, Sep 12, 2007 at 12:10:23PM -0600, Aaron J. Seigo wrote:
> is there anyone interested in going through the existing engines and making 
> the necessary changes? those would be: getting rid of engine-global update 
> timers and implementing updateSource(const QString&) where appropriate.

I think I have some time for that later today. But first some fixes for
that new stuff:

1)
uint timeSinceLastUpdate() const;
to
int timeSinceLastUpdate() const;

it avoids signed/unsigned comparison and internally it's an int anyway.


2)
d->relays.erase(d->relays.find(relay->m_interval));
to
d->relays.remove(relay->m_interval);

in this case it's the same but nicer.

3)
in DataContainer::connectVisualization d->relayObjects[visualization]
was not set for (updateInterval >=3D1)
and related to that fix:
QObject* DataContainer::Private::signalRelay
to
SignalRelay* DataContainer::Private::signalRelay

to avoid casting

4)
it's not possible to disconnect during QObject::destroyed()
checking the sender is a bit ugly but I didn't feel like writing an
extra slot?

5)
DataEngine::setupdateInterval
should be
DataEngine::setUpdateInterval

right?

6) (not yet implemented)
I would like to change minUpdateFreq to minUpdateInterval because that's
what it acually is.

patch for 1-5 attached. ok to commit?

michael


["misc.diff" (text/x-diff)]

Index: dataengine.cpp
===================================================================
--- dataengine.cpp	(revision 713068)
+++ dataengine.cpp	(working copy)
@@ -347,7 +347,7 @@
     return d->minUpdateFreq;
 }
 
-void DataEngine::setupdateInterval(uint frequency)
+void DataEngine::setUpdateInterval(uint frequency)
 {
     killTimer(d->updateTimerId);
     d->updateTimerId = 0;
Index: datacontainer_p.h
===================================================================
--- datacontainer_p.h	(revision 713068)
+++ datacontainer_p.h	(working copy)
@@ -35,8 +35,8 @@
           dirty(false)
     {}
 
-    QObject* signalRelay(const DataContainer* dc, QObject *visualization,
-                         uint updateInterval, Plasma::IntervalAlignment align);
+    SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization,
+                             uint updateInterval, Plasma::IntervalAlignment align);
 
     DataEngine::Data data;
     QMap<QObject *, SignalRelay *> relayObjects;
@@ -151,7 +151,7 @@
     }
 };
 
-QObject* DataContainer::Private::signalRelay(const DataContainer* dc, QObject \
*visualization, uint updateInterval, Plasma::IntervalAlignment align) +SignalRelay* \
DataContainer::Private::signalRelay(const DataContainer* dc, QObject *visualization, \
uint updateInterval, Plasma::IntervalAlignment align)  {
     QMap<uint, SignalRelay *>::const_iterator relayIt = relays.find(updateInterval);
     SignalRelay *relay = 0;
Index: datacontainer.h
===================================================================
--- datacontainer.h	(revision 713068)
+++ datacontainer.h	(working copy)
@@ -84,7 +84,7 @@
         /**
          * Returns how long ago, in msecs, that the data in this container was last \
                updated
          **/
-        uint timeSinceLastUpdate() const;
+        int timeSinceLastUpdate() const;
 
         /**
          * @internal
Index: dataengine.h
===================================================================
--- dataengine.h	(revision 713068)
+++ dataengine.h	(working copy)
@@ -231,8 +231,8 @@
         /**
          * Called by internal updating mechanisms to trigger the engine
          * to refresh the data contained in a given source. Reimplement this
-         * method when using facilities such as setupdateInterval.
-         * @see setupdateInterval
+         * method when using facilities such as setUpdateInterval.
+         * @see setUpdateInterval
          *
          * @param source the name of the source that should be updated
          * @return true if the data was changed, or false if there was no
@@ -325,11 +325,11 @@
          * @param frequency the time, in milliseconds, between updates. A value of 0
          *                  will stop internally triggered updates.
          **/
-        void setupdateInterval(uint frequency);
+        void setUpdateInterval(uint frequency);
 
         /**
          * Returns the current update frequency.
-         * @see setupdateInterval
+         * @see setUpdateInterval
          NOTE: This is not implemented to prevent having to store the value \
                internally.
                When there is a good use case for needing access to this value, we \
                can
                add another member to the Private class and add this method.
Index: datacontainer.cpp
===================================================================
--- datacontainer.cpp	(revision 713068)
+++ datacontainer.cpp	(working copy)
@@ -80,7 +80,7 @@
     }
 }
 
-uint DataContainer::timeSinceLastUpdate() const
+int DataContainer::timeSinceLastUpdate() const
 {
     int msec = QTime::currentTime().msec();
     if (msec < d->updateTs) {
@@ -124,7 +124,7 @@
                     visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
 
             if (relay->isUnused()) {
-                d->relays.erase(d->relays.find(relay->m_interval));
+                d->relays.remove(relay->m_interval);
                 delete relay;
             }
 //            kDebug() << "     already connected, but to a relay";
@@ -145,16 +145,17 @@
                 this, SLOT(disconnectVisualization(QObject*)));//, \
Qt::QueuedConnection);  }
 
-    d->relayObjects[visualization] = 0;
 
     if (updateInterval < 1) {
 //        kDebug() << "    connecting directly";
+        d->relayObjects[visualization] = 0;
         connect(this, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
                 visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
     } else {
 //        kDebug() << "    connecting to a relay";
-        connect(d->signalRelay(this, visualization, updateInterval, alignment),
-                SIGNAL(updated(QString,Plasma::DataEngine::Data)),
+        SignalRelay *relay = d->signalRelay(this, visualization, updateInterval, \
alignment); +        d->relayObjects[visualization] = relay;
+        connect(relay, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
                 visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
     }
 }
@@ -165,15 +166,18 @@
 
     if (objIt == d->relayObjects.end() || !objIt.value()) {
         // it is connected directly to the DataContainer itself
-        disconnect(this, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
-                   visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
+        if (sender() != visualization) { // not called via QObject::destroyed()
+            disconnect(this, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
+                       visualization, \
SLOT(updated(QString,Plasma::DataEngine::Data))); +        }
     } else {
         SignalRelay *relay = objIt.value();
-        disconnect(relay, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
-                   visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
-
+        if (sender() != visualization) { // not called via QObject::destroyed()
+            disconnect(relay, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
+                       visualization, \
SLOT(updated(QString,Plasma::DataEngine::Data))); +        }
         if (relay->isUnused()) {
-            d->relays.erase(d->relays.find(relay->m_interval));
+            d->relays.remove(relay->m_interval);
             delete relay;
         }
 


["signature.asc" (application/pgp-signature)]

_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic