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

List:       kde-devel
Subject:    [patch] shows weather report in kontacts summaryview
From:       Martin =?iso-8859-1?q?K=F6bele?= <martin () mkoebele ! de>
Date:       2004-03-15 22:34:18
Message-ID: 200403152334.18405.martin () mkoebele ! de
[Download RAW message or body]

Hi,

my patch allows to show the report of kweather which you normally get only by 
clicking on the kweather-applet in your kicker. Now you can click on the 
pixmap in the summaryview to get the report.

My changes:

in kdetoys/kweather:
- added showReport(QString station) to the dcop-functions.

in kontact/plugins/kweather:
- add stationID in WeatherData
- the Pixmap is now a KURLLabel, the url is linked to the 
showReport-dcop-call.

Sometimes, the report doesn't show above all other windows, although there is 
a raise() in showReport().

How do you like the patch?

I sent the patch to both mailinglists, because it affects two different 
modules (kdeoim and kdetoys)

Martin

["kontact_plugin_weather_report.patch" (text/x-diff)]

? Doxyfile
? kontact_plugin_weather_report.patch
? kweathersummaryplugin.kdevelop
? weather.diff
Index: summarywidget.cpp
===================================================================
RCS file: /home/kde/kdepim/kontact/plugins/weather/summarywidget.cpp,v
retrieving revision 1.19
diff -u -p -r1.19 summarywidget.cpp
--- summarywidget.cpp	13 Mar 2004 15:02:56 -0000	1.19
+++ summarywidget.cpp	15 Mar 2004 22:25:30 -0000
@@ -25,6 +25,7 @@
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qtooltip.h>
+#include <qpushbutton.h>
 
 #include <dcopclient.h>
 #include <dcopref.h>
@@ -34,6 +35,7 @@
 #include <kglobalsettings.h>
 #include <kiconloader.h>
 #include <klocale.h>
+#include <kurllabel.h>
 
 #include "summarywidget.h"
 
@@ -109,14 +111,19 @@ void SummaryWidget::updateView()
     mLayout->addStretch( 10 );
     mLayouts.append( layout );
 
-    QLabel *label = new QLabel( this );
-    label->setPixmap( img.smoothScale( 32, 32 ) );
-    label->setMaximumSize(label->sizeHint());
-    label->setAlignment(/* AlignRight |*/ AlignTop );
-    layout->addMultiCellWidget( label, 0, 1, 0, 0 );
-    mLabels.append( label );
-
-    label = new QLabel( this );
+    KURLLabel* urlLabel = new KURLLabel(this);
+    urlLabel->installEventFilter(this);
+    urlLabel->setURL((*it).stationID());
+    urlLabel->setPixmap( img.smoothScale( 32, 32 ) );
+    urlLabel->setMaximumSize(urlLabel->sizeHint());
+    urlLabel->setAlignment(/* AlignRight |*/ AlignTop );
+    layout->addMultiCellWidget( urlLabel, 0, 1, 0, 0 );
+    mLabels.append( urlLabel );
+	
+    connect (urlLabel, SIGNAL(leftClickedURL( const QString&) ),
+    	this, SLOT(slotShowReport(const QString& )));
+    
+    QLabel* label = new QLabel( this );
     label->setText( QString( "%1 (%2)" ).arg( (*it).name() ).arg( \
(*it).temperature() ) );  QFont font = label->font();
     font.setBold( true );
@@ -167,6 +174,7 @@ void SummaryWidget::refresh( QString sta
   mWeatherMap[ station ].setTemperature( dcopCall.call( "temperature(QString)", \
station, true ) );  mWeatherMap[ station ].setWindSpeed( dcopCall.call( \
"wind(QString)", station, true ) );  mWeatherMap[ station ].setRelativeHumidity( \
dcopCall.call( "relativeHumidity(QString)", station, true ) ); +  mWeatherMap[ \
station ].setStationID(station);  
   updateView();
 }
@@ -182,4 +190,10 @@ QStringList SummaryWidget::configModules
   return QStringList( "kcmweatherservice.desktop" );
 }
 
+void SummaryWidget::slotShowReport(const QString &stationID)
+{
+  DCOPRef dcopCall( "KWeatherService", "WeatherService" );
+  DCOPReply reply = dcopCall.call( "showReport(QString)", stationID, true );
+}
+
 #include "summarywidget.moc"
Index: summarywidget.h
===================================================================
RCS file: /home/kde/kdepim/kontact/plugins/weather/summarywidget.h,v
retrieving revision 1.10
diff -u -p -r1.10 summarywidget.h
--- summarywidget.h	22 Jan 2004 22:16:36 -0000	1.10
+++ summarywidget.h	15 Mar 2004 22:25:30 -0000
@@ -60,6 +60,9 @@ class WeatherData
     void setRelativeHumidity( const QString &relativeHumidity ) { mRelativeHumidity \
= relativeHumidity; }  QString relativeHumidity() const { return mRelativeHumidity; }
 
+    void setStationID(const QString &station) { mStationID = station;}
+    QString stationID() { return mStationID; }
+    
     bool operator< ( const WeatherData &data )
     {
       return ( QString::localeAwareCompare( mName, data.mName ) < 0 );
@@ -72,6 +75,7 @@ class WeatherData
     QString mTemperature;
     QString mWindSpeed;
     QString mRelativeHumidity;
+    QString mStationID;
 };
 
 class SummaryWidget : public Kontact::Summary, public DCOPObject
@@ -90,6 +94,7 @@ class SummaryWidget : public Kontact::Su
   private slots:
     void updateView();
     void timeout();
+    void slotShowReport(const QString&);
 
   private:
     QStringList mStations;


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

? weather_toys.diff
? kweather/kweather.filelist
? kweather/kweather.kdevelop
? kweather/kweather.kdevelop.filelist
? kweather/kweather.kdevelop.pcs
? kweather/kweather.kdevses
Index: kweather/Makefile.am
===================================================================
RCS file: /home/kde/kdetoys/kweather/Makefile.am,v
retrieving revision 1.36
diff -u -r1.36 Makefile.am
--- kweather/Makefile.am	16 Feb 2004 01:20:28 -0000	1.36
+++ kweather/Makefile.am	15 Mar 2004 16:35:36 -0000
@@ -41,8 +41,8 @@
 #globaladd_DATA = weatherbar_add.desktop
 
 kweatherservice_LDFLAGS = $(all_libraries) $(KDE_RPATH)
-kweatherservice_LDADD = $(LIB_KIO)
-kweatherservice_SOURCES = main.cpp weatherlib.cpp weatherservice.cpp \
weatherservice.skel stationdatabase.cpp sun.cpp weatherservice.stub \
+kweatherservice_LDADD = $(LIB_KIO) $(LIB_KHTML) +kweatherservice_SOURCES = main.cpp \
weatherlib.cpp weatherservice.cpp weatherservice.skel stationdatabase.cpp sun.cpp \
weatherservice.stub reportview.cpp  
 service_DATA = kweatherservice.desktop
 servicedir = $(kde_servicesdir)
Index: kweather/reportview.cpp
===================================================================
RCS file: /home/kde/kdetoys/kweather/reportview.cpp,v
retrieving revision 1.43
diff -u -r1.43 reportview.cpp
--- kweather/reportview.cpp	14 Mar 2004 03:41:25 -0000	1.43
+++ kweather/reportview.cpp	15 Mar 2004 16:35:36 -0000
@@ -28,7 +28,7 @@
 #include "reportview.h"
 #include "weatherservice_stub.h"
 
-reportView::reportView(QString reportLocation)
+reportView::reportView(const QString reportLocation)
         : KDialogBase( (QWidget *)0, "report", false, QString::null, Close ) {
     m_locationCode = reportLocation;
     QVBox *vbox = makeVBoxMainWidget();
Index: kweather/reportview.h
===================================================================
RCS file: /home/kde/kdetoys/kweather/reportview.h,v
retrieving revision 1.16
diff -u -r1.16 reportview.h
--- kweather/reportview.h	14 Mar 2004 03:41:25 -0000	1.16
+++ kweather/reportview.h	15 Mar 2004 16:35:36 -0000
@@ -33,7 +33,7 @@
     Q_OBJECT
 
 public:
-    reportView(QString reportLocation);
+    reportView(const QString reportLocation);
     ~reportView();
 
     void render();
Index: kweather/weatherservice.cpp
===================================================================
RCS file: /home/kde/kdetoys/kweather/weatherservice.cpp,v
retrieving revision 1.34
diff -u -r1.34 weatherservice.cpp
--- kweather/weatherservice.cpp	13 Mar 2004 19:36:02 -0000	1.34
+++ kweather/weatherservice.cpp	15 Mar 2004 16:35:36 -0000
@@ -11,7 +11,8 @@
 #include "stationdatabase.h"
 #include "sun.h"
 
-WeatherService::WeatherService(QObject *parent, const char *name) : QObject (parent, \
name),  DCOPObject("WeatherService") +
+WeatherService::WeatherService(QObject *parent, const char *name) : QObject (parent, \
name),  DCOPObject("WeatherService"), m_reportView( 0 )  {
 	kdDebug(12006) << "Starting new service... " << endl;
 
@@ -305,6 +306,17 @@
 	return getTime(stationID, CIVIL_END);
 }
 
+void WeatherService::showReport(const QString &stationID)
+{
+	m_reportView= new reportView(stationID);
+	connect( m_reportView, SIGNAL( finished() ), SLOT( slotReportFinished() ) );
+	m_reportView->show();
+}
 
+void WeatherServive::slotReportFinished()
+{
+	m_reportView->delayedDestruct();
+	m_reportView = 0;
+}
 
 #include "weatherservice.moc"
Index: kweather/weatherservice.h
===================================================================
RCS file: /home/kde/kdetoys/kweather/weatherservice.h,v
retrieving revision 1.25
diff -u -r1.25 weatherservice.h
--- kweather/weatherservice.h	13 Mar 2004 19:36:02 -0000	1.25
+++ kweather/weatherservice.h	15 Mar 2004 16:35:36 -0000
@@ -6,9 +6,12 @@
 #include <dcopobject.h>
 #include <qpixmap.h>
 
+#include "reportview.h"
+
 class WeatherLib;
 class StationDatabase;
 
+
 class WeatherService : public QObject, public DCOPObject
 {
 	Q_OBJECT
@@ -21,6 +24,7 @@
 		void updated(const QString &stationID);
 		void updating(const QString &stationID);
 		void slotStationRemoved(const QString &stationID);
+		void slotReportFinished();
 
 	public:
 		WeatherService(QObject *parent, const char *name);
@@ -67,6 +71,7 @@
 		void addStation(const QString &stationID);
 		QStringList listStations();
 		void exit();
+		void showReport(const QString &stationID);
 
   private:
 		enum TimeType
@@ -80,5 +85,7 @@
 		void saveSettings();
 		QString getTime(const QString &stationID, TimeType timeType);
 		StationDatabase *stationDB;
+		
+		reportView m_reportView;
 };
 #endif



>> 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