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

List:       kde-commits
Subject:    KDE/kdebase/workspace/ksysguard/gui
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2006-09-07 22:23:54
Message-ID: 1157667834.336491.932.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 581915 by tokoe:

Fix the bug that displays can't be removed from a worksheet.


 M  +2 -1      KSysGuardApplet.cc  
 M  +11 -2     SensorDisplayLib/SensorDisplay.cc  
 M  +14 -9     SensorDisplayLib/SensorDisplay.h  
 M  +1 -0      WorkSheet.cc  


--- trunk/KDE/kdebase/workspace/ksysguard/gui/KSysGuardApplet.cc #581914:581915
@@ -204,7 +204,7 @@
     if ( mDockList[ dock ]->metaObject()->className() == "QFrame" ) {
       if ( sensorType == "integer" || sensorType == "float" ) {
         KMenu popup;
-        QWidget *wdg = 0;
+        KSGRD::SensorDisplay *wdg = 0;
 
         popup.addTitle( i18n( "Select Display Type" ) );
         QAction *a1 = popup.addAction( i18n( "&Signal Plotter" ) );
@@ -223,6 +223,7 @@
           mDockList[ dock ] = wdg;
           layout();
 
+          wdg->setDeleteNotifier( this );
           connect( wdg, SIGNAL( modified( bool ) ),
                    SLOT( sensorDisplayModified( bool ) ) );
 
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SensorDisplay.cc #581914:581915
@@ -46,6 +46,8 @@
 
 #include "SensorDisplay.h"
 
+#define NONE -1
+
 using namespace KSGRD;
 
 SensorDisplay::DeleteEvent::DeleteEvent( SensorDisplay *display )
@@ -181,8 +183,10 @@
           configureSettings();
           break;
         case 3: {
-            DeleteEvent *event = new DeleteEvent( this );
-            kapp->postEvent( parent(), event );
+            if ( mDeleteNotifier ) {
+              DeleteEvent *event = new DeleteEvent( this );
+              kapp->postEvent( mDeleteNotifier, event );
+            }
           }
           break;
         case 4:
@@ -324,6 +328,11 @@
   sensorError( reqId, true );
 }
 
+void SensorDisplay::setDeleteNotifier( QObject *object )
+{
+  mDeleteNotifier = object;
+}
+
 bool SensorDisplay::restoreSettings( QDomElement &element )
 {
   mShowUnit = element.attribute( "showUnit", "0" ).toInt();
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SensorDisplay.h #581914:581915
@@ -21,18 +21,17 @@
 #ifndef KSG_SENSORDISPLAY_H
 #define KSG_SENSORDISPLAY_H
 
-#include <QLabel>
-#include <QWidget>
-#include <QTimerEvent>
-#include <QEvent>
+#include <QtCore/QEvent>
+#include <QtCore/QPointer>
+#include <QtCore/QTimerEvent>
+#include <QtGui/QLabel>
+#include <QtGui/QWidget>
 
 #include <knotifyclient.h>
 
 #include <ksgrd/SensorClient.h>
 #include "SharedSettings.h"
 
-#define NONE -1
-
 class QDomDocument;
 class QDomElement;
 
@@ -145,7 +144,7 @@
 
     /**
       Add a sensor to the display.
-      
+
       @param hostName The name of the host, the sensor belongs to.
       @param name The sensor name.
       @param type The type of the sensor.
@@ -197,7 +196,7 @@
 
     /**
       Reimplement this method to catch error messages from the SensorManager.
-      
+
       @param sensorId The unique id of the sensor.
       @param mode The mode: true = error, false = everthing ok
      */
@@ -208,6 +207,11 @@
      */
     virtual void sensorLost( int reqId );
 
+    /**
+     * Sets the object where the delete events will be send to.
+     */
+    void setDeleteNotifier( QObject *object );
+
   public Q_SLOTS:
     /**
       If @ref value is true, this method starts the timer that triggers
@@ -234,7 +238,6 @@
      */
     virtual void applyStyle();
 
-		
   Q_SIGNALS:
     void showPopupMenu( KSGRD::SensorDisplay *display );
     void changeTitle(const QString&);
@@ -277,6 +280,8 @@
 
     QWidget* mErrorIndicator;
     QWidget* mPlotterWdg;
+
+    QPointer<QObject> mDeleteNotifier;
 };
 
 class SensorProperties
--- trunk/KDE/kdebase/workspace/ksysguard/gui/WorkSheet.cc #581914:581915
@@ -520,6 +520,7 @@
       mDisplayList[ row ][ column ]->setUpdateInterval( updateInterval() );
     connect( newDisplay, SIGNAL( showPopupMenu( KSGRD::SensorDisplay* ) ),
              SLOT( showPopupMenu( KSGRD::SensorDisplay* ) ) );
+    newDisplay->setDeleteNotifier( this );
   }
 
   SensorFrame *frame = new SensorFrame(mDisplayList[ row ][ column ]);
[prev in list] [next in list] [prev in thread] [next in thread] 

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