--- yawp-0.4.3/applet/configdialog/yawpconfig.cpp	2012-04-17 21:17:36.000000000 +0300
+++ yawp_0.4.3-patches/applet/configdialog/yawpconfig.cpp	2013-02-28 19:58:09.000000000 +0200
@@ -53,9 +53,7 @@ struct YawpConfigDialog::Private
 {
 	KConfigDialog              * pConfigDlg;
 	WeatherServiceModel        * pWeatherModel;
-	bool                         bCityModelChanged;
-	bool                         bCitySettingsChanged;
-	bool                         bUnitsChanged;
+	bool                         bWeatherDataUpdateRequired;
 
 // This is used to map localized theme names to the english names
 	QMap <int, QString>          theme_map;
@@ -70,8 +68,7 @@ YawpConfigDialog::YawpConfigDialog( KCon
 {
 	d->pStorage = pStorage;
 	
-	d->bCityModelChanged = false;
-	d->bCitySettingsChanged = false;
+	d->bWeatherDataUpdateRequired = false;
 
 	d->pConfigDlg = parent;
 	d->pWeatherModel = new WeatherServiceModel(pStorage, this);
@@ -299,29 +296,15 @@ YawpConfigDialog::weatherModel() const
 }
 
 bool
-YawpConfigDialog::cityModelChanged() const
+YawpConfigDialog::weatherDataUpdateRequired() const
 {
-	return d->bCityModelChanged;
-}
-
-bool
-YawpConfigDialog::citySettingsChanged() const
-{
-	return d->bCitySettingsChanged;
-}
-
-bool
-YawpConfigDialog::unitsChanged() const
-{
-	return d->bUnitsChanged;
+	return d->bWeatherDataUpdateRequired;
 }
 
 void
 YawpConfigDialog::resetChanges()
 {
-	d->bCityModelChanged = false;
-	d->bCitySettingsChanged = false;
-	d->bUnitsChanged = false;
+	d->bWeatherDataUpdateRequired = false;
 }
 
 void
@@ -453,14 +436,6 @@ YawpConfigDialog::getData( Yawp::ConfigD
 	int iPressureIdx = comboPressure->currentIndex();
 	int iDistanceIdx = comboDistance->currentIndex();
 
-	d->bUnitsChanged = false;
-	if ((int)data->temperatureSystem != comboTemperature->itemData( iTempIdx ).toInt() ||
-	    (int)data->speedSystem       != comboSpeed->itemData( iSpeedIdx ).toInt() ||
-	    (int)data->pressureSystem    != comboPressure->itemData( iPressureIdx ).toInt() ||
-	    (int)data->distanceSystem    != comboDistance->itemData( iDistanceIdx ).toInt() )
-	{
-		d->bUnitsChanged = true;
-	}
 	data->temperatureSystem = (YAWP_TEMPERATURE_UNIT)comboTemperature->itemData( iTempIdx ).toInt();
 	data->speedSystem       = (YAWP_SPEED_UNIT)comboSpeed->itemData( iSpeedIdx ).toInt();
 	data->pressureSystem    = (YAWP_PRESSURE_UNIT)comboPressure->itemData( iPressureIdx ).toInt();
@@ -630,8 +605,7 @@ YawpConfigDialog::addCity(CityWeather *
 		{
 			cityTableView->setCurrentIndex( d->pWeatherModel->index(idx, 0, QModelIndex()) );
 			updateLocationButtons();
-			d->bCitySettingsChanged = true;
-			d->bCityModelChanged = true;
+			d->bWeatherDataUpdateRequired = true;
 			
 			//--- notify config dialog, that settings has been changed ---
 			settingsChanged();
@@ -668,7 +642,6 @@ YawpConfigDialog::deleteCity()
 	{
 		d->pWeatherModel->removeRows( index.row(), 1 );
 		updateLocationButtons();
-		d->bCityModelChanged = true;
 		
 		//--- notify config dialog, that settings has been changed ---
 		settingsChanged();
@@ -699,8 +672,6 @@ YawpConfigDialog::slotSetTimeZone()
 		cityInfo->setTimeZone( dlg.selectedTimeZone() );
 		if( cityInfo->countryCode().isEmpty() )
 			cityInfo->setCountryCode( cityInfo->timeZone().countryCode() );
-		d->bCitySettingsChanged = true;
-		d->bCityModelChanged = true;
 		
 		//--- notify config dialog, that settings has been changed ---
 		settingsChanged();
@@ -760,7 +731,6 @@ YawpConfigDialog::moveSelectedCity( int
 		index = index.sibling(index.row()+offset, 0);
 		cityTableView->setCurrentIndex( index );
 		locationSelected( index );
-		d->bCityModelChanged = true;
 		
 		//--- notify config dialog, that settings has been changed ---
 		settingsChanged();
--- yawp-0.4.3/applet/configdialog/yawpconfig.h	2012-04-17 21:17:36.000000000 +0300
+++ yawp_0.4.3-patches/applet/configdialog/yawpconfig.h	2013-02-28 19:58:09.000000000 +0200
@@ -67,9 +67,13 @@ public:
 	const WeatherServiceModel * weatherModel() const;
 	void copyCities( const WeatherServiceModel * model );
 
-	bool cityModelChanged() const;
-	bool citySettingsChanged() const;
-	bool unitsChanged() const;
+	// Since we remove all cities from original weatherServiceModel and reload from configuration every time user 
+	// changed configuration, we need to know whether new cities has been added only.
+	// When cityServiceModel adds new cities and this model has an WeatherDataProcessor
+	// it retrieves cached data for these cities.
+	// WeatherServiceModel from configDialog does not has an WeatherDataProcessor
+	// therefore it will not maintain weather data for listed cities and these data will not be copied when coping cities.
+	bool weatherDataUpdateRequired() const;
 	
 	// reset the boolean values cityModelChanged, citySettingsChanged and unitsChanged
 	// when we receive accept signal from the config dialog, we have to reset this values,
--- yawp-0.4.3/applet/yawp.cpp	2012-04-17 21:17:36.000000000 +0300
+++ yawp_0.4.3-patches/applet/yawp.cpp	2013-02-28 19:58:10.000000000 +0200
@@ -322,7 +322,7 @@ YaWP::~YaWP()
 	else
 	{
 		// Save settings
-		saveConfig();
+		saveConfig(m_configData, *m_pWeatherModel);
 	}
 
 	if (m_pAppletPainter != 0)
@@ -342,8 +342,6 @@ YaWP::init()
 	m_svg.setContainsMultipleImages( true );
 
 	loadConfig();
-	loadCustomTheme();
-	initAppletPainter();
 	
 	//--- just 4 debug ---
 /*	CityWeather dummyCity1;
@@ -365,20 +363,6 @@ YaWP::init()
 	m_pWeatherModel->addCity(dummyCity2);
 	//--- end of debug section ---
 */
-	updateCitySubMenu();
-	setCityIndex( m_configData.iCityIndex );
-
-	const bool bHasCities = (m_pWeatherModel->rowCount() > 0);
-
-	if (bHasCities)
-		m_iIdPendingEngineConnection = startTimer( m_configData.iStartDelay*60*1000 );
-	else
-		setConfigurationRequired( true );
-
-	m_pManualUpdate->setEnabled( bHasCities );
-	m_pCitySubMenu->setEnabled( bHasCities);
-
-	startTraverseLocationTimeout();
 
 	// Every 5 days, 15 minutes after start of applet, cache directory will be checked to remove old files.
 	if (QDate::currentDate().dayOfYear() % 5 == 0)
@@ -393,6 +377,21 @@ void
 YaWP::loadConfig()
 {
 	dStartFunct();
+	
+	// first of all we stop timer for delayed weather engine connection
+	stopPendingEngineConnection();
+
+	// stop to sliding through cities automatically
+	stopTraverseLocationTimeout();
+	
+	// when we have some old cities, remove them otherwise we get more cities as expected
+	if (m_pWeatherModel->rowCount() > 0)
+	{
+		// first of all we disconnect from weather engine
+		m_pWeatherModel->disconnectEngine();
+		m_pWeatherModel->removeRows(0, m_pWeatherModel->rowCount(), QModelIndex());
+	}
+
 	KConfigGroup cfg = config();
 
 	/*** SETTINGS PAGE ***/
@@ -528,64 +527,91 @@ YaWP::loadConfig()
 	}
 	else
 		m_configData.iCityIndex = 0;
+	
+	// Update yawp visual to new loaded data
+	loadCustomTheme();
+	initAppletPainter();
+
+	updateCitySubMenu();
+	setCityIndex( m_configData.iCityIndex );
+
+	const bool bHasCities = (m_pWeatherModel->rowCount() > 0);
+
+	if (bHasCities)
+	{
+		// start requesting weather information from data engine
+		// the connection with the data engine will be delayed because some
+		// systems need a while to get ready...
+		m_iIdPendingEngineConnection = startTimer( m_configData.iStartDelay*60*1000 );
+	}
+
+	// When no city has been configured inform user
+	// that this applet needs to be configured
+	setConfigurationRequired( !bHasCities );
+
+	m_pManualUpdate->setEnabled( bHasCities );
+	m_pCitySubMenu->setEnabled( bHasCities);
+
+	startTraverseLocationTimeout();
+
 	dEndFunct();
 }
 
 void
-YaWP::saveConfig()
+YaWP::saveConfig( const Yawp::ConfigData & configData, const WeatherServiceModel & weatherModel )
 {
 	dStartFunct();
 	KConfigGroup cfg = config();
 
 	/*** SETTINGS PAGE ***/
-	cfg.writeEntry( "update interval",			(int)m_configData.iUpdateInterval );
-	cfg.writeEntry( "start delay",				(int)m_configData.iStartDelay );
-	cfg.writeEntry( "traverse locations",		m_configData.bTraverseLocationsPeriodically );
-	cfg.writeEntry( "traverse locations timeout",	m_configData.iTraverseLocationTimeout );
-
-	cfg.writeEntry( "system.distance",          (int)m_configData.distanceSystem );
-	cfg.writeEntry( "system.pressure",          (int)m_configData.pressureSystem );
-	cfg.writeEntry( "system.temperature",		(int)m_configData.temperatureSystem );
-	cfg.writeEntry( "system.speed",			(int)m_configData.speedSystem );
-
-	cfg.writeEntry( "animation.daysnames",		(int)m_configData.daynamesAnimation );
-	cfg.writeEntry( "animation.details",		(int)m_configData.detailsAnimation );
-	cfg.writeEntry( "animation.page",		(int)m_configData.pageAnimation );
-	cfg.writeEntry( "animation.icon",		(int)m_configData.iconAnimation );
-	cfg.writeEntry( "animation.duration",		(int)m_configData.iAnimationDuration );
+	cfg.writeEntry( "update interval",			(int)configData.iUpdateInterval );
+	cfg.writeEntry( "start delay",				(int)configData.iStartDelay );
+	cfg.writeEntry( "traverse locations",		configData.bTraverseLocationsPeriodically );
+	cfg.writeEntry( "traverse locations timeout",	configData.iTraverseLocationTimeout );
+
+	cfg.writeEntry( "system.distance",          (int)configData.distanceSystem );
+	cfg.writeEntry( "system.pressure",          (int)configData.pressureSystem );
+	cfg.writeEntry( "system.temperature",		(int)configData.temperatureSystem );
+	cfg.writeEntry( "system.speed",			(int)configData.speedSystem );
+
+	cfg.writeEntry( "animation.daysnames",		(int)configData.daynamesAnimation );
+	cfg.writeEntry( "animation.details",		(int)configData.detailsAnimation );
+	cfg.writeEntry( "animation.page",		(int)configData.pageAnimation );
+	cfg.writeEntry( "animation.icon",		(int)configData.iconAnimation );
+	cfg.writeEntry( "animation.duration",		(int)configData.iAnimationDuration );
 
 	/*** PANEL PAGE ***/
-	cfg.writeEntry( "panel.today.format",		(int)m_configData.todaysWeatherPanelFormat );
-	cfg.writeEntry( "panel.forecast.format",	(int)m_configData.forecastWeatherPanelFormat );
-	cfg.writeEntry( "panel.forecast.days",		m_configData.iPanelForecastDays );
-	cfg.writeEntry( "panel.layout.compact", 	m_configData.bUseCompactPanelLayout );
-
-	cfg.writeEntry( "panel.tooltip.extended.enabled",	m_configData.bUseExtendedTooltip );
-	cfg.writeEntry( "panel.tooltip.extended.format",	(int)m_configData.extendedTooltipOptions );
-	cfg.writeEntry( "panel.weathericon.interactive",	m_configData.bUseInteractivePanelWeatherIcons );
+	cfg.writeEntry( "panel.today.format",		(int)configData.todaysWeatherPanelFormat );
+	cfg.writeEntry( "panel.forecast.format",	(int)configData.forecastWeatherPanelFormat );
+	cfg.writeEntry( "panel.forecast.days",		configData.iPanelForecastDays );
+	cfg.writeEntry( "panel.layout.compact", 	configData.bUseCompactPanelLayout );
+
+	cfg.writeEntry( "panel.tooltip.extended.enabled",	configData.bUseExtendedTooltip );
+	cfg.writeEntry( "panel.tooltip.extended.format",	(int)configData.extendedTooltipOptions );
+	cfg.writeEntry( "panel.weathericon.interactive",	configData.bUseInteractivePanelWeatherIcons );
 
 	/***  THEME PAGE ***/
-	cfg.writeEntry( "theme",				m_configData.sBackgroundName );
-	cfg.writeEntry( "custom.theme.file",			m_configData.sCustomThemeFile );
-	cfg.writeEntry( "custom.theme.enabled",			m_configData.bUseCustomTheme );
-	cfg.writeEntry( "custom.theme.background.enabled",	m_configData.bUseCustomThemeBackground );
-
-	cfg.writeEntry( "custom.fontcolor.normal",	m_configData.fontColor );
-	cfg.writeEntry( "custom.fontcolor.lowtemp",	m_configData.lowFontColor );
-	cfg.writeEntry( "custom.fontcolor.shadows",	m_configData.shadowsFontColor );
-	cfg.writeEntry( "custom.fontcolor.usage",	m_configData.bUseCustomFontColor );
-	cfg.writeEntry( "text.shadows",	m_configData.bDisableTextShadows );
+	cfg.writeEntry( "theme",				configData.sBackgroundName );
+	cfg.writeEntry( "custom.theme.file",			configData.sCustomThemeFile );
+	cfg.writeEntry( "custom.theme.enabled",			configData.bUseCustomTheme );
+	cfg.writeEntry( "custom.theme.background.enabled",	configData.bUseCustomThemeBackground );
+
+	cfg.writeEntry( "custom.fontcolor.normal",	configData.fontColor );
+	cfg.writeEntry( "custom.fontcolor.lowtemp",	configData.lowFontColor );
+	cfg.writeEntry( "custom.fontcolor.shadows",	configData.shadowsFontColor );
+	cfg.writeEntry( "custom.fontcolor.usage",	configData.bUseCustomFontColor );
+	cfg.writeEntry( "text.shadows",	configData.bDisableTextShadows );
 
 	/*** LOCATION PAGE ***/
 	if( cfg.hasGroup("locations") )
 		cfg.group("locations").deleteGroup();	// delete all old entries in this group
-	if( m_pWeatherModel->rowCount() > 0 )
+	if( weatherModel.rowCount() > 0 )
 	{
 		KConfigGroup cityCfg = cfg.group("locations");
-		for( int iCityIndex = 0; iCityIndex < m_pWeatherModel->rowCount(); ++iCityIndex )
+		for( int iCityIndex = 0; iCityIndex < weatherModel.rowCount(); ++iCityIndex )
 		{
 			QStringList lst;
-			const CityWeather * pCity = m_pWeatherModel->getCityInfo( iCityIndex );
+			const CityWeather * pCity = weatherModel.getCityInfo( iCityIndex );
 			lst << pCity->provider()
 			    << pCity->city()
 			    << pCity->country()
@@ -595,7 +621,7 @@ YaWP::saveConfig()
 			QString sKey = QString("city%1").arg(iCityIndex+1, 2, 10, QChar('0'));
 			cityCfg.writeEntry( sKey, lst );
 		}
-		cityCfg.writeEntry("selected", m_configData.iCityIndex);
+		cityCfg.writeEntry("selected", configData.iCityIndex);
 	}
 	dEndFunct();
 }
@@ -732,67 +758,66 @@ YaWP::createConfigurationInterface(KConf
 }
 
 void
-YaWP::configChanged()
+YaWP::configAccepted()
 {
 	dStartFunct();
 	
-	m_pWeatherModel->disconnectEngine();
-	stopPendingEngineConnection();
-
-	stopTraverseLocationTimeout();
-
-	if (!isUserConfiguring())
+	if (m_pConfigDlg != 0)
 	{
-		m_stateMachine.setCurrentCityIndex(-1);
-		m_pWeatherModel->removeRows(0, m_pWeatherModel->rowCount());
-		loadConfig();
+		Yawp::ConfigData configData;
+		m_pConfigDlg->getData( &configData );
+		saveConfig( configData, *m_pConfigDlg->weatherModel() );
+		
+		emit configNeedsSaving();
 	}
-	else if (m_pConfigDlg != 0)
+	dEndFunct();
+}
+
+void
+YaWP::configChanged()
+{
+	dStartFunct();
+	
+	// get oldest date time from city model
+	QDateTime oldestUpdate;
+	bool allCitiesUpdated = true;
+	if (m_pConfigDlg != 0 && isUserConfiguring())
 	{
-		dDebug() << "configuration changed..."
-			<< "    model changed" << m_pConfigDlg->cityModelChanged();
-		if (m_pConfigDlg->cityModelChanged())
+		for( int idx = 0; idx < m_pWeatherModel->rowCount(); ++idx)
 		{
-			dDebug() << "update model";
-			m_pWeatherModel->copyCities( *m_pConfigDlg->weatherModel() );
-			updateCitySubMenu();
+			const CityWeather * pCity = m_pWeatherModel->getCityInfo(idx);
+			if (!pCity->lastUpdate().isValid())
+				allCitiesUpdated = false;
+			else if (!oldestUpdate.isValid() || oldestUpdate > pCity->lastUpdate())
+				oldestUpdate = pCity->lastUpdate();
 		}
-		else
-			dDebug() << "model did not change...";
-
-		m_pConfigDlg->getData( &m_configData );
-		saveConfig();
-		emit configNeedsSaving();
 	}
 
-	m_pAppletPainter->setupAnimationTimeLine();
-	setupWeatherServiceModel();
-
-	if (m_configData.iCityIndex < 0 && m_pWeatherModel->rowCount() > 0)
-		m_configData.iCityIndex = 0;
-	setCityIndex( m_configData.iCityIndex );
-	loadCustomTheme();
-
-	if( !m_configData.bUseCustomFontColor )
-		setDefaultFontColors();
-
-	const bool bHasCities = (m_pWeatherModel->rowCount() > 0);
-	setConfigurationRequired( !bHasCities );
-	m_pManualUpdate->setEnabled( bHasCities);
-	m_pCitySubMenu->setEnabled( bHasCities );
+	//--- load new configuration
+	loadConfig();
 
-	//--- trigger the update-process ---
-	if (bHasCities)
+	// check if we can delay city weather update
+	if (m_pConfigDlg != 0 && isUserConfiguring())
 	{
-		bool bUpdateRequired = true;
-		
-		if (isUserConfiguring() && m_pConfigDlg != 0)
-			bUpdateRequired = (m_pConfigDlg->citySettingsChanged() || m_pConfigDlg->unitsChanged());
-		
-		m_iIdPendingEngineConnection = startTimer( bUpdateRequired ? 0 : 3 * 60 * 1000 );
-		startTraverseLocationTimeout();
+		if (oldestUpdate.isValid() && !m_pConfigDlg->weatherDataUpdateRequired())
+		{
+			int delaySec = oldestUpdate.addSecs(m_configData.iUpdateInterval * 60).toTime_t() - QDateTime::currentDateTime().toTime_t();
+			dDebug() << "Update will be delayed about" << delaySec << "seconds.";
+			
+			if (delaySec > 0 && allCitiesUpdated)
+			{
+				stopPendingEngineConnection();
+				m_iIdPendingEngineConnection = startTimer( delaySec*1000 );
+
+				// we set last update time to all cities, to suppress "(Cache)" string from city name
+				for( int idx = 0; idx < m_pWeatherModel->rowCount(); ++idx)
+					m_pWeatherModel->getCityInfo(idx)->setLastUpdate(oldestUpdate);
+			}
+		}
+		m_pConfigDlg->resetChanges();
 	}
-	else
+	
+	if (m_pWeatherModel->rowCount() == 0)
 	{
 		// When we have no city anymore, make sure popup will be hidden.
 		// This can only happen, when extender is shown and we delete all cities.
@@ -800,17 +825,13 @@ YaWP::configChanged()
 		// handle this events. Therefore there is no way for the user to hide the popup manual,
 		// unless user is adding at least one city to the applet.
 		hidePopup();
-
+		
 		// remove current tooltip
 		Plasma::ToolTipManager::self()->clearContent(this);
 	}
-	
-	if (isUserConfiguring() && m_pConfigDlg != 0)
-		m_pConfigDlg->resetChanges();
 
-	// to make sure we will change the theme
+	// trigger size changed otherwise applet might not full visible after theme/layout changes
 	constraintsEvent( Plasma::FormFactorConstraint | Plasma::SizeConstraint );
-	initAppletPainter();
 	
 	// I noticed applet is not properly repainting after layout changes (in panel mode)
 	// I guess the reason for this is that widget repaint event will be triggered before
@@ -888,7 +909,7 @@ YaWP::slotCityUpdate(WeatherServiceModel
 	if( updateType.testFlag(WeatherServiceModel::CityInfoUpdate) )
 	{
 		updateCitySubMenu();
-		saveConfig();
+		saveConfig(m_configData, *m_pWeatherModel);
 		emit configNeedsSaving();
 	}
 
--- yawp-0.4.3/applet/yawp.h	2012-04-17 21:17:36.000000000 +0300
+++ yawp_0.4.3-patches/applet/yawp.h	2013-02-28 19:58:09.000000000 +0200
@@ -91,8 +91,17 @@ public:
 	 */
 	virtual void createConfigurationInterface( KConfigDialog * parent );
 	
-public slots:
-	void configChanged();
+public Q_SLOTS:
+ 
+	/**
+	 * Called when config is accepted through config dialog
+	 */
+	virtual void configAccepted();
+  
+	/**
+	 * Called when config is changed
+	 */
+	virtual void configChanged();
 
 protected:
 	virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
@@ -103,7 +112,7 @@ protected:
 	virtual void initExtenderItem(Plasma::ExtenderItem * item);
 #endif
 
-private slots:
+private Q_SLOTS:
 	void about() const;
 	
 	void slotCityUpdate( WeatherServiceModel::ServiceUpdate updateType );
@@ -125,7 +134,7 @@ private:
 	
 	void loadConfig();
 	void loadCustomTheme();
-	void saveConfig();
+	void saveConfig( const Yawp::ConfigData & configData, const WeatherServiceModel & weatherModel );
 
 	void setDefaultFontColors();
 
--- yawp-0.4.3/CHANGELOG	2012-04-17 21:17:36.000000000 +0300
+++ yawp_0.4.3-patches/CHANGELOG	2013-02-28 19:58:12.000000000 +0200
@@ -1,3 +1,7 @@
+!!! 
+!!!  This modification based on revision 540 (yawp 0.4.3) to backport hibernation support from trunk (revision 563) to this version.
+!!!
+
 yawp (0.4.3)
   * Show current RealFeel temperature under current temperature (thanks to Alain Soucy)
   * Non-modale city search dialog
