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

List:       kde-devel
Subject:    Re: Question about order of emited signals
From:       Frans Englich <frans.englich () telia ! com>
Date:       2004-01-30 19:13:45
Message-ID: 200401302013.45866.frans.englich () telia ! com
[Download RAW message or body]

On Friday 30 January 2004 19:35, Adriaan de Groot wrote:

While on the subject on signal and slots, I too have a question :)

KCModule has the changed(bool) signal. Some KCMs need to emit it when a line 
edit is changed and use a "bouncer function" to emit the changed(true) 
signal. This, because a connect( lineedit, SIGNAL(textChanged(const 
QString&)), SIGNAL(changed(bool))); obviously doesn't work.
That is inconvenient, one would rather connect directly to a changed() signal, 
instead of letting the codepath include a "converter" function.
Is this possible somehow, or is it possible(and a good idea) to add something 
like he following to KCModule?

Code not tested..

Cheers,

			Frans



Index: kcmodule.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcmodule.cpp,v
retrieving revision 1.20
diff -u -3 -p -r1.20 kcmodule.cpp
--- kcmodule.cpp        22 Nov 2003 10:52:01 -0000      1.20
+++ kcmodule.cpp        30 Jan 2004 19:07:03 -0000
@@ -49,6 +49,13 @@ KCModule::KCModule(QWidget *parent, cons
                d->_instance = new KInstance("kcmunnamed");
     d->_hasOwnInstance = true;
     KGlobal::setActiveInstance(this->instance());
+    connect( this, SIGNAL(changed()), SLOT(bounceChanged()));
+
+}
+
+void KCModule::bounceChanged()
+{
+    emit changed(true);
 }

 KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList 
& )
cvs diff: I know nothing about kcmodule.cpp~
Index: kcmodule.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcmodule.h,v
retrieving revision 1.39
diff -u -3 -p -r1.39 kcmodule.h
--- kcmodule.h  22 Nov 2003 10:52:01 -0000      1.39
+++ kcmodule.h  30 Jan 2004 19:07:03 -0000
@@ -210,6 +210,12 @@ signals:
   void changed(bool state);

   /**
+   * This is a "overload" signal of the above. Emitting it is equivalent
+   * to emitting changed(true)
+   */
+  void changed();
+
+  /**
    * Indicate that the module's quickhelp has changed.
    *
    * Emit this signal whenever the module's quickhelp changes.
@@ -258,6 +264,11 @@ protected:

 private:

+  /**
+   * Simple: Catches changed() and emits changed(true)
+   */
+  void bounceChanged();
+
   int _btn;
 protected:
   virtual void virtual_hook( int id, void* data );
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

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