201029
authorhgs
Fri, 23 Jul 2010 13:47:57 +0300
changeset 69 87476091b3f5
parent 67 474929a40a0f
child 71 1db7cc813a4e
201029
homescreen_plat/homescreenclient_api/homescreenclient_api.metaxml
homescreenapp/common.pri
homescreenapp/examples/batterywidgetplugin/resource/batterywidgetplugin.xml
homescreenapp/homescreenapp.pro
homescreenapp/hsapplication/hsapplication.pro
homescreenapp/hsapplication/src/hsstatemachine.cpp
homescreenapp/hsdomainmodel/hsdomainmodel.pri
homescreenapp/hsdomainmodel/hsdomainmodel.pro
homescreenapp/hsdomainmodel/hsdomainmodel.qrc
homescreenapp/hsdomainmodel/inc/hsdocumentloader.h
homescreenapp/hsdomainmodel/inc/hsdomainmodel_global.h
homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h
homescreenapp/hsdomainmodel/inc/hsgui.h
homescreenapp/hsdomainmodel/inc/hshostedwidgetfactory.h
homescreenapp/hsdomainmodel/inc/hsidlewidget.h
homescreenapp/hsdomainmodel/inc/hspage.h
homescreenapp/hsdomainmodel/inc/hspagenewwidgetlayout.h
homescreenapp/hsdomainmodel/inc/hspagevisual.h
homescreenapp/hsdomainmodel/inc/hsscene.h
homescreenapp/hsdomainmodel/inc/hswidgethost.h
homescreenapp/hsdomainmodel/inc/hswidgethostvisual.h
homescreenapp/hsdomainmodel/inc/hswidgettoucharea.h
homescreenapp/hsdomainmodel/resource/controllayer.docml
homescreenapp/hsdomainmodel/src/hsdocumentloader.cpp
homescreenapp/hsdomainmodel/src/hsgui.cpp
homescreenapp/hsdomainmodel/src/hshostedwidgetfactory.cpp
homescreenapp/hsdomainmodel/src/hsidlewidget.cpp
homescreenapp/hsdomainmodel/src/hspage.cpp
homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp
homescreenapp/hsdomainmodel/src/hspagevisual.cpp
homescreenapp/hsdomainmodel/src/hsscene.cpp
homescreenapp/hsdomainmodel/src/hswallpaper.cpp
homescreenapp/hsdomainmodel/src/hswidgetcomponentregistry.cpp
homescreenapp/hsdomainmodel/src/hswidgethost.cpp
homescreenapp/hsdomainmodel/src/hswidgethostvisual.cpp
homescreenapp/hsdomainmodel/src/hswidgettoucharea.cpp
homescreenapp/hsutils/inc/hsmessageboxwrapper.h
homescreenapp/hsutils/inc/hspropertyanimationwrapper.h
homescreenapp/hsutils/inc/hsutils_global.h
homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h
homescreenapp/hsutils/inc/hswidgetpositioningonwidgetmove.h
homescreenapp/hsutils/src/hsmessageboxwrapper.cpp
homescreenapp/hsutils/src/hspropertyanimationwrapper.cpp
homescreenapp/hsutils/src/hssnapline.cpp
homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp
homescreenapp/hsutils/src/hswidgetpositioningonwidgetmove.cpp
homescreenapp/inc/hsapp_defs.h
homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro
homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuentryremovedhandler.h
homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice_global.h
homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuentryremovedhandler.cpp
homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/hsapplibrarystateplugin.qrc
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsbaseviewstate.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmainwindow.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuviewbuilder.h
homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hssearchview.h
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/addcontentlabeledview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/common_objects.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/emptylabeledview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledlistview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledsearchview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/listview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlabeledlistview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlistview.docml
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmainwindow.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp
homescreenapp/stateplugins/hsapplibrarystateplugin/src/hssearchview.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/hshomescreenstateplugin.pro
homescreenapp/stateplugins/hshomescreenstateplugin/hshomescreenstateplugin.qrc
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsdocumentloader.h
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h
homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlewidget.h
homescreenapp/stateplugins/hshomescreenstateplugin/resource/controllayer.docml
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsbackuprestorestate.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsdocumentloader.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlewidget.cpp
homescreenapp/stateplugins/hshomescreenstateplugin/src/hsloadscenestate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.pro
homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddappstocollectionstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hscollectionslistdialog.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsuninstallitemstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappdetailsstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappsettingsstate.h
homescreenapp/stateplugins/hsmenuworkerstateplugin/resource/hsappchecklist.docml
homescreenapp/stateplugins/hsmenuworkerstateplugin/resource/hscollectionslistdialog.docml
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddappstocollectionstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hscollectionslistdialog.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsinstallationlogstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsuninstallitemstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp
homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappsettingsstate.cpp
homescreenapp/widgetplugins/hsclockwidgetplugin/hsclockwidgetplugin.pro
homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsanalogclockwidget.h
homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsdigitalclockwidget.h
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.css
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.widgetml
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.css
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.widgetml
homescreenapp/widgetplugins/hsclockwidgetplugin/resource/qtg_graf_hswidget_preview_clock.svg
homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsanalogclockwidget.cpp
homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsdigitalclockwidget.cpp
homescreenapp/widgetplugins/hsshortcutwidgetplugin/inc/hsshortcutwidget.h
homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.css
homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.widgetml
homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp
screensaver/bwins/screensavermodelu.def
screensaver/devicedialogplugins/snsrdevicedialogplugin/inc/snsrdevicedialog.h
screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialog.cpp
screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialogplugin.cpp
screensaver/eabi/screensavermodelu.def
screensaver/screensavermodel/inc/screensaver.h
screensaver/screensavermodel/src/screensaver.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsranalogclockcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockscreensaver.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrblankcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrdigitalclockcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroledanalogclockcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroleddigitalclockcontainer.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveranalog.docml
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaverdigital.docml
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroledanalog.docml
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroleddigital.docml
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsranalogclockwidget.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsroledclockwidget.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsroledtimelabel.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsranalogclockwidget.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledclockwidget.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledtimelabel.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/inc/snsrindicatormodel.h
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/resource/snsrindicatorwidget.widgetml
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/src/snsrindicatormodel.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsranalogclockcontainer.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockcontainer.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockscreensaver.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrblankcontainer.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdigitalclockcontainer.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdocumentloader.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroledanalogclockcontainer.cpp
screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroleddigitalclockcontainer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreen_plat/homescreenclient_api/homescreenclient_api.metaxml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<api id="8e80718e406ef05ada051bc688cb2d5f" dataversion="2.0">
+  <name>homescreenclient_api</name>
+  <description>Home screen API to create widgets, change wallpaper</description>
+  <type>c++</type>
+  <collection>homescreenapp</collection>
+  <libs/>
+  <release category="platform" sinceversion=""/>
+  <attributes>
+    <htmldocprovided>no</htmldocprovided>
+    <adaptation>no</adaptation>
+  </attributes>
+</api>
--- a/homescreenapp/common.pri	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/common.pri	Fri Jul 23 13:47:57 2010 +0300
@@ -33,7 +33,7 @@
     SUBDIRPART = release
 }
 
-win32: OUTPUT_DIR = $$PWD/../../bin/$$SUBDIRPART
+!symbian: OUTPUT_DIR = $$PWD/../../bin/$$SUBDIRPART
 symbian: OUTPUT_DIR = $$PWD/bin
 
 SOURCE_DIR = $$PWD/inc
@@ -45,6 +45,7 @@
     MOC_DIR = $$OUTPUT_DIR/tmp/$$TARGET/moc
     RCC_DIR = $$OUTPUT_DIR/tmp/$$TARGET/rcc
     UI_DIR = $$OUTPUT_DIR/tmp/$$TARGET/ui
+    CONFIG -= app_bundle
 } else { # test part is NOT DONE
     QT *= testlib
     CONFIG += console
@@ -68,9 +69,7 @@
     INCLUDEPATH += $$MOC_DIR
     TARGET.CAPABILITY = ALL -TCB
     TARGET.EPOCALLOWDLLDATA=1
-}
-
-win32 {
+} else {
     # add platfrom API for windows
     INCLUDEPATH += \                
                 $$PWD/../../homescreensrv/homescreensrv_plat/contentstorage_api \                
@@ -79,7 +78,7 @@
 
 plugin: !isEmpty(PLUGIN_SUBDIR): DESTDIR = $$OUTPUT_DIR/$$PLUGIN_SUBDIR
 
-win32: plugin { # copy manifiers
+!symbian: plugin { # copy manifiers
     manifest.path = $$DESTDIR
     manifest.files = ./resource/*.manifest ./resource/*.xml
     manifest.CONFIG += no_build
@@ -119,8 +118,7 @@
         for(entry, entries) : BLD_INF_RULES.prj_exports += "./$$entry z:/$$replace(2, ^/,)/$$basename(entry)"
     }
     export ( BLD_INF_RULES.prj_exports)
-}
-win32 {
+} else {
     name = $$replace(1, [/\\\\\.\*], _)
     eval ($${name}.path = $${OUTPUT_DIR}/$${2})
     eval ($${name}.files = $$1)
@@ -137,10 +135,15 @@
 }
 }
 
-!exists($${EPOCROOT}epoc32/include/platform/mw/XQSettingsManager) {
-	DEFINES += NO_QT_EXTENSIONS
+symbian {
+    !exists($${EPOCROOT}epoc32/include/platform/mw/XQSettingsManager) {
+        DEFINES += NO_QT_EXTENSIONS
+    }
+} else {
+    DEFINES += NO_QT_EXTENSIONS
 }
 
+
 # support for NFT
 nft:DEFINES += NFT
 
--- a/homescreenapp/examples/batterywidgetplugin/resource/batterywidgetplugin.xml	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/examples/batterywidgetplugin/resource/batterywidgetplugin.xml	Fri Jul 23 13:47:57 2010 +0300
@@ -8,7 +8,5 @@
         <version>1.0</version>
         <description>Example of home screen widget</description>
         <capabilities></capabilities>
-        <customproperty key="iconuri">batterywidgetplugin.png</customproperty>
-        <customproperty key="title">Battery</customproperty>
     </interface>
 </service>
--- a/homescreenapp/homescreenapp.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/homescreenapp.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -30,7 +30,7 @@
             hsapplicationlauncher
 }
 
-SUBDIRS  += ./../tsrc
+exists(./../tsrc/tsrc.pro): SUBDIRS  += ./../tsrc
 
 CONFIG += ordered
 
--- a/homescreenapp/hsapplication/hsapplication.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsapplication/hsapplication.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -27,6 +27,8 @@
 
 fute:DEFINES += FUTE
 
+new_short:DEFINES += HSWIDGETORGANIZER_ALGORITHM
+
 DEPENDPATH += . \
               ./inc \
               ./src
@@ -39,7 +41,8 @@
 TRANSLATIONS = homescreen.ts
 
 LIBS += -lhsutils \
-        -lhsdomainmodel
+        -lhsdomainmodel \
+	-lcaclient
 
 
 symbian: {
@@ -60,7 +63,7 @@
     SERVICE.FILE = ipc_service_conf.xml
 }
 
-win32: {
+!symbian: {
     include(installs_win.pri)
 }
 
--- a/homescreenapp/hsapplication/src/hsstatemachine.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsapplication/src/hsstatemachine.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -92,7 +92,7 @@
 {
     HSTEST_FUNC_ENTRY("HS::HsStateMachine::HsStateMachine");
 
-    HsDatabase *db = new HsDatabase;
+    HsDatabase *db = new HsDatabase(QCoreApplication::instance());
     db->setConnectionName("homescreen.dbc");
 #ifdef Q_OS_SYMBIAN
     db->setDatabaseName("c:/private/20022f35/homescreen.db");
@@ -102,14 +102,18 @@
     db->open();
     HsDatabase::setInstance(db);
 
-    HsConfiguration::setInstance(new HsConfiguration);
+    HsConfiguration::setInstance(new HsConfiguration(QCoreApplication::instance()));
     HsConfiguration::instance()->load();
             
     HsWidgetPositioningOnOrientationChange::setInstance(
         new HsAdvancedWidgetPositioningOnOrientationChange);
-
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    HsWidgetPositioningOnWidgetAdd::setInstance(
+        new HsWidgetOrganizer);
+#else
     HsWidgetPositioningOnWidgetAdd::setInstance(
         new HsAnchorPointInBottomRight);
+#endif
 
     HsWidgetPositioningOnWidgetMove::setInstance(
         new HsSnapToLines);
@@ -138,6 +142,8 @@
 HsStateMachine::~HsStateMachine()
 {
     HsWidgetPositioningOnOrientationChange::setInstance(0);
+    HsWidgetPositioningOnWidgetAdd::setInstance(0);
+    HsWidgetPositioningOnWidgetMove::setInstance(0);
     delete mPublisher;
 }
 
--- a/homescreenapp/hsdomainmodel/hsdomainmodel.pri	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/hsdomainmodel.pri	Fri Jul 23 13:47:57 2010 +0300
@@ -19,6 +19,7 @@
            ./inc/hsdatabase.h  \
            ./inc/hsdomainmodel_global.h  \
            ./inc/hspage.h \
+           ./inc/hspagevisual.h \
            ./inc/hspagenewwidgetlayout.h \
            ./inc/hsgui.h  \
            ./inc/hsscene.h \
@@ -27,18 +28,24 @@
            ./inc/hswallpaper.h \
            ./inc/hswallpaperloader.h \
            ./inc/hswallpaperloaderthread.h \
+           ./inc/hshostedwidgetfactory.h \
            ./inc/hswidgethost.h \
+           ./inc/hswidgethostvisual.h \
            ./inc/hswidgetcomponentregistry.h \
            ./inc/hswidgetcomponent.h \
            ./inc/hswidgetcomponentdescriptor.h \
            ./inc/hsbackuprestoreobserver.h \
            ./inc/hsconfiguration.h \
            ./inc/hswidgettoucharea.h \
-           ./inc/hspagetoucharea.h
+           ./inc/hspagetoucharea.h \
+           ./inc/hsidlewidget.h \
+           ./inc/hsdocumentloader.h
+        
 
 SOURCES += ./src/hscontentservice.cpp \
            ./src/hsdatabase.cpp \
            ./src/hspage.cpp \
+           ./src/hspagevisual.cpp \
            ./src/hspagenewwidgetlayout.cpp \
            ./src/hsgui.cpp \
            ./src/hsscene.cpp \
@@ -46,14 +53,18 @@
            ./src/hswallpaper.cpp \
            ./src/hswallpaperloader.cpp \
            ./src/hswallpaperloaderthread.cpp \
+           ./src/hshostedwidgetfactory.cpp \
            ./src/hswidgethost.cpp \
+           ./src/hswidgethostvisual.cpp \
            ./src/hswidgetcomponentregistry.cpp \
            ./src/hswidgetcomponent.cpp \
            ./src/hswidgetcomponentdescriptor.cpp \
            ./src/hsbackuprestoreobserver.cpp \
            ./src/hsconfiguration.cpp \
            ./src/hswidgettoucharea.cpp \
-           ./src/hspagetoucharea.cpp
+           ./src/hspagetoucharea.cpp \
+           ./src/hsidlewidget.cpp \
+           ./src/hsdocumentloader.cpp
 
 symbian: {
 HEADERS += ./inc/hsbackuprestoreobserver_p.h \
--- a/homescreenapp/hsdomainmodel/hsdomainmodel.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/hsdomainmodel.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -40,11 +40,16 @@
                ../hsutils/inc \
                ../hsapplication/inc
 
+RESOURCES += hsdomainmodel.qrc
+
 symbian: {
     TARGET.UID3 = 0x20022F38
     LIBS += -lxqsettingsmanager -labclient
 }
-win32:{
+!symbian:{
     QT += network 
 }
+
+new_short:DEFINES += HSWIDGETORGANIZER_ALGORITHM
+
 include(hsdomainmodel.pri)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/hsdomainmodel.qrc	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/" >           
+        <file alias="controllayer.docml">resource/controllayer.docml</file>
+    </qresource>    
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hsdocumentloader.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Homescreen document loader class.
+*
+*/
+
+#ifndef HSDOCUMENTLOADER_H
+#define HSDOCUMENTLOADER_H
+
+#include <hbdocumentloader.h>
+#include "hstest_global.h"
+
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
+
+class HsDocumentLoader : public HbDocumentLoader
+{
+public:
+    HsDocumentLoader();
+    virtual ~HsDocumentLoader();
+
+public:
+    QObject *createObject(const QString &type, const QString &name);
+
+private:
+
+    Q_DISABLE_COPY(HsDocumentLoader)
+
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
+};
+
+#endif
--- a/homescreenapp/hsdomainmodel/inc/hsdomainmodel_global.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hsdomainmodel_global.h	Fri Jul 23 13:47:57 2010 +0300
@@ -19,7 +19,7 @@
 #ifndef HSDOMAINMODEL_GLOBAL_H
 #define HSDOMAINMODEL_GLOBAL_H
 
-#include <Qt/qglobal.h>
+#include <qglobal.h>
 
 // services uri; services key names used when the service is passed as property in state
 const char CONTENT_SERVICE_KEY[]  = "http://homescreen.nokia.com/runtimeservices/contentservice";
--- a/homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h	Fri Jul 23 13:47:57 2010 +0300
@@ -19,7 +19,7 @@
 #define HSDOMAINMODELDATASTRUCTURES_H
 
 #include <QPointF>
-
+#include <QString>
 #include "hsdomainmodel_global.h"
 
 class HSDOMAINMODEL_EXPORT HsSceneData
--- a/homescreenapp/hsdomainmodel/inc/hsgui.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hsgui.h	Fri Jul 23 13:47:57 2010 +0300
@@ -18,34 +18,61 @@
 #ifndef HSGUI_H
 #define HSGUI_H
 
+
+#include <QObject>
 #include <QPointer>
-
+#include <Hb> 
 #include "hsdomainmodel_global.h"
 #include "hstest_global.h"
 
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
 HOMESCREEN_TEST_CLASS(HomeScreenStatePluginTest)
 
 class HbView;
-class HbMainWindow;
+class HsIdleWidget;
+class HsPropertyAnimationWrapper;
 
-class HSDOMAINMODEL_EXPORT HsGui
+struct HsGuiImpl;
+
+class HSDOMAINMODEL_EXPORT HsGui: public QObject
 {
+    Q_OBJECT
 public:
-	static HbView *idleView();	
-	static HbView *takeIdleView();
-	static void setIdleView(HbView *idleView);	
-	
-    static HbMainWindow *mainWindow();
+    ~HsGui();
+
+    static HsGui *setInstance(HsGui *);
+    static HsGui *instance();
+    static HsGui *takeInstance();
+
+    void setupIdleUi();
+    void cleanupIdleUi();
+
+    void setOrientation(Qt::Orientation);
+    Qt::Orientation orientation();
+    
+    HbView *idleView() const;
+    HsIdleWidget *idleWidget() const;
+   
+    QRectF layoutRect() const;
+    
+    void show();
+    
+    HsPropertyAnimationWrapper *pageChangeAnimation();
+    HsPropertyAnimationWrapper *pageCrawlingAnimation();
+signals:
+    void orientationChanged(Qt::Orientation);
+    void navigateToApplibrary();
+ 
+private:
+    HsGui(QObject *parent=0);
 
 private:
-    HsGui() {}
-
-private:
-	static QPointer<HbView> mIdleView;
-	
+    static HsGui *mInstance;
+    HsGuiImpl *mImpl;
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
     HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
 };
 
-Q_DECLARE_METATYPE(HsGui*)
+
 
 #endif // HSGUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hshostedwidgetfactory.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HSHOSTEDWIDGETFACTORY_H
+#define HSHOSTEDWIDGETFACTORY_H
+
+#include <QObject>
+
+
+#include "hsdomainmodel_global.h"
+#include "hsdomainmodeldatastructures.h"
+
+#include "hstest_global.h"
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
+
+struct HsHostedWidgetFactoryImpl;
+
+class HSDOMAINMODEL_EXPORT HsHostedWidgetFactory : public QObject
+{
+    Q_OBJECT
+
+public:
+    static HsHostedWidgetFactory *instance();
+    static HsHostedWidgetFactory *takeInstance();
+    static HsHostedWidgetFactory *setInstance(HsHostedWidgetFactory *);
+    ~HsHostedWidgetFactory();
+
+    QObject *createWidget(const QString &uri);
+private:
+    Q_DISABLE_COPY(HsHostedWidgetFactory)
+    HsHostedWidgetFactory(QObject *parent = 0);
+private:
+    static HsHostedWidgetFactory *mInstance;
+    HsHostedWidgetFactoryImpl *mImpl;
+    
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
+};
+
+#endif // HSWIDGETHOST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hsidlewidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef HSIDLEWIDGET_H
+#define HSIDLEWIDGET_H
+
+#include <HbWidget>
+
+#include "hstest_global.h"
+#include "hsdomainmodel_global.h"
+
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
+
+class HsPage;
+class HsTrashBinWidget;
+class HsPageIndicator;
+class HsSnapLine;
+
+class HSDOMAINMODEL_EXPORT HsIdleWidget : public HbWidget
+{
+    Q_OBJECT
+    Q_PROPERTY(qreal sceneX READ sceneX WRITE setSceneX)
+
+public:
+    HsIdleWidget(QGraphicsItem *parent = 0);
+		~HsIdleWidget();
+
+    qreal sceneX() const;
+    void setSceneX(qreal x);
+
+    void setGeometry(const QRectF &rect);
+
+    void setActivePage(int index);
+    void insertPage(int index, HsPage *page);
+    void removePage(int index);
+
+    HbWidget *controlLayer() const { return mControlLayer; }
+    HbWidget *pageLayer() const { return mPageLayer; }
+    HbWidget *pageWallpaperLayer() const { return mPageWallpaperLayer; }
+    HbWidget *sceneLayer() const { return mSceneLayer; }
+
+    HsTrashBinWidget *trashBin() const { return mTrashBin; }
+    HsPageIndicator *pageIndicator() const { return mPageIndicator; }
+
+    qreal parallaxFactor() const;
+
+
+public slots:
+    void showTrashBin();
+    void showPageIndicator();
+
+    void showVerticalSnapLine(const QLineF &snapLine);	
+    void hideVerticalSnapLine();
+    void showHorizontalSnapLine(const QLineF &snapLine);
+    void hideHorizontalSnapLine();
+
+protected:
+    void polishEvent();
+
+private:
+    Q_DISABLE_COPY(HsIdleWidget)
+    void loadControlLayer();
+        
+private:
+    HbWidget *mControlLayer;
+    HbWidget *mPageLayer;
+    HbWidget *mPageWallpaperLayer;
+    HbWidget *mSceneLayer;
+
+    HsTrashBinWidget *mTrashBin;
+    HsPageIndicator *mPageIndicator;
+
+    HsSnapLine *mHorizontalSnapLine;
+    HsSnapLine *mVerticalSnapLine;
+
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
+};
+
+#endif // HSIDLEWIDGET_H
--- a/homescreenapp/hsdomainmodel/inc/hspage.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hspage.h	Fri Jul 23 13:47:57 2010 +0300
@@ -28,20 +28,21 @@
 class HsPageData;
 class HsWallpaper;
 class HsPageTouchArea;
+class HsPageVisual;
 
 HOMESCREEN_TEST_CLASS(TestHsDomainModel)
 
-class HSDOMAINMODEL_EXPORT HsPage : public HbWidget
+class HSDOMAINMODEL_EXPORT HsPage : public QObject
 {
     Q_OBJECT
     Q_PROPERTY(int pageIndex READ pageIndex)
 
 public:
-    HsPage(QGraphicsItem *parent = 0);
+    HsPage(QObject *parent = 0);
     ~HsPage();
     int databaseId() const;
     void setDatabaseId(int id);
-    void setGeometry(const QRectF &rect);
+   // void setGeometry(const QRectF &rect);
     bool load();
     HsWallpaper *wallpaper() const;
     bool addExistingWidget(HsWidgetHost *widgetHost);
@@ -62,7 +63,10 @@
     QRectF contentGeometry(Qt::Orientation orientation);
     QRectF contentRect();
     QRectF contentRect(Qt::Orientation orientation);
-
+    HsPageVisual *visual() const;
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    enum sortOrder { height, width};
+#endif //HSWIDGETORGANIZER_ALGORITHM
 public slots:
     void showWidgets();
     void hideWidgets();
@@ -72,9 +76,12 @@
 
 private:
     Q_DISABLE_COPY(HsPage)
-    void setupTouchArea();
+  //  void setupTouchArea();
     void connectWidget(HsWidgetHost *widget);
     void disconnectWidget(HsWidgetHost *widget);
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    void sortWidgets(sortOrder order, QList<HsWidgetHost*> &widgets);
+#endif //HSWIDGETORGANIZER_ALGORITHM
 
 private slots:
     void onWidgetFinished();
@@ -87,12 +94,13 @@
 
 private:
     int mDatabaseId;
+    HsPageVisual *mPageVisual;
     HsWallpaper *mWallpaper;
     bool mRemovable;
     QList<HsWidgetHost*> mWidgets;
     QList<HsWidgetHost*> mNewWidgets;
     QList<HsWidgetHost*> mUnavailableWidgets;
-    HsPageTouchArea *mTouchArea;
+    //HsPageTouchArea *mTouchArea;
     QPointF mTouchPoint;    
     qreal mPageMargin;
     HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
--- a/homescreenapp/hsdomainmodel/inc/hspagenewwidgetlayout.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hspagenewwidgetlayout.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -35,9 +35,13 @@
     void removeAt(int index);
     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
     void setGeometry(const QRectF &rect);
-    
     void addItem(HsWidgetHost *item);
-    
+    enum sortOrder { height, width};
+
+private:
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    QList<HsWidgetHost*> sortWidgets(sortOrder order);
+#endif    
 private:
     QSizeF mSize;
     QList<HsWidgetHost*> mNewWidgets;
@@ -46,5 +50,4 @@
     HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
 };
 
-
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hspagevisual.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HSPAGEVISUAL_H
+#define HSPAGEVISUAL_H
+
+
+#include <HbWidget>
+#include "hsdomainmodel_global.h"
+#include "hstest_global.h"
+
+
+class HsPageTouchArea;
+
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
+
+class HSDOMAINMODEL_EXPORT HsPageVisual : public HbWidget
+{
+    Q_OBJECT
+   
+
+public:
+    HsPageVisual(QGraphicsItem *parent = 0);
+    ~HsPageVisual();
+   
+    void setGeometry(const QRectF &rect);
+
+private:
+    Q_DISABLE_COPY(HsPageVisual)
+    void setupTouchArea();
+
+private:
+    HsPageTouchArea *mTouchArea;
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
+};
+
+#endif
--- a/homescreenapp/hsdomainmodel/inc/hsscene.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hsscene.h	Fri Jul 23 13:47:57 2010 +0300
@@ -71,8 +71,8 @@
     static HsScene *instance();
     static HsScene *takeInstance();
     static void setInstance(HsScene *instance);
-    static HbMainWindow *mainWindow();
-    static Qt::Orientation orientation();
+    //static HbMainWindow *mainWindow();
+    //static Qt::Orientation orientation();
 
 signals:
     void pageTapAndHoldFinished(QGestureEvent *event);
@@ -105,7 +105,7 @@
 
     friend class HsPage;
     friend class HsPageTouchArea;
-    friend class HsWidgetHost;
+    friend class HsWidgetHostVisual;
     friend class HsWidgetTouchArea;
     friend class HsWidgetMoveTouchArea;
 
--- a/homescreenapp/hsdomainmodel/inc/hswidgethost.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hswidgethost.h	Fri Jul 23 13:47:57 2010 +0300
@@ -18,7 +18,7 @@
 #ifndef HSWIDGETHOST_H
 #define HSWIDGETHOST_H
 
-#include <HbWidget>
+#include <QObject>
 #include <QMetaMethod>
 #include <QMetaProperty>
 
@@ -33,13 +33,14 @@
 class HsWidgetTouchArea;
 class HsWidgetComponent;
 class HsPage;
+class HsWidgetHostVisual;
 
-class HSDOMAINMODEL_EXPORT HsWidgetHost : public HbWidget
+class HSDOMAINMODEL_EXPORT HsWidgetHost : public QObject
 {
     Q_OBJECT
 
 public:
-    HsWidgetHost(int databaseId, QGraphicsItem *parent = 0);
+    HsWidgetHost(int databaseId, QObject *parent = 0);
     ~HsWidgetHost();
 
     static HsWidgetHost *createInstance(
@@ -58,8 +59,8 @@
     bool savePresentation(HsWidgetPresentationData &presentation);
     bool getPresentation(HsWidgetPresentationData &presentation);
     bool removePresentation(Qt::Orientation orientation);
-    QPainterPath shape() const;
-
+    
+    HsWidgetHostVisual *visual() const;
 signals:
     void event_startAndShow();
     void event_startAndHide();
@@ -73,7 +74,6 @@
     
     void finished();
     void faulted();
-    void resized();
     void available();
     void unavailable();
 
@@ -90,22 +90,20 @@
     void startDropEffect();
 
 protected:
-    bool eventFilter(QObject *watched, QEvent *event);
+/*    bool eventFilter(QObject *watched, QEvent *event);
     void gestureEvent(QGestureEvent *event);
     void mousePressEvent(QGraphicsSceneMouseEvent *) {}
-
+*/
 private:
     Q_DISABLE_COPY(HsWidgetHost)
-    void setupTouchArea();
-    void setupEffects();
+  
     void setupStates();
 
     bool setProperty(const char *name, QMetaProperty &property); 
     bool setMethod(const char *signature, QMetaMethod &method);    
     bool hasSignal(const char *signature);
 
-    void setNewSize(const QSizeF &size);
-
+  
     bool setPreferencesToWidget();
 
 private slots:
@@ -127,12 +125,13 @@
     void onSetPreferences(const QStringList &names);
 
 private:
-    int mDatabaseId;        
+    int mDatabaseId;
+    HsWidgetHostVisual *mVisual;
     QStateMachine *mStateMachine;
-    QGraphicsWidget *mWidget;
+    QObject *mWidget;
     HsPage *mPage;    
     HsWidgetComponent *mComponent;
-    HsWidgetTouchArea *mTouchArea;
+
     QMetaMethod mOnInitializeMethod;
     QMetaMethod mOnShowMethod;
     QMetaMethod mOnHideMethod;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/inc/hswidgethostvisual.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HSWIDGETHOSTVISUAL_H
+#define HSWIDGETHOSTVISUAL_H
+
+#include <HbWidget>
+#include <QMetaMethod>
+#include <QMetaProperty>
+
+#include "hsdomainmodel_global.h"
+#include "hsdomainmodeldatastructures.h"
+
+#include "hstest_global.h"
+HOMESCREEN_TEST_CLASS(TestHsDomainModel)
+
+class QStateMachine;
+
+class HsWidgetTouchArea;
+class HsWidgetComponent;
+class HsPage;
+class HsWidgetHost;
+
+class HSDOMAINMODEL_EXPORT HsWidgetHostVisual : public HbWidget
+{
+    Q_OBJECT
+
+public:
+    HsWidgetHostVisual(QGraphicsItem *parent = 0);
+    ~HsWidgetHostVisual();
+    
+    QPainterPath shape() const;
+    void setWidget(QObject *widget);
+    void setVisualModel(HsWidgetHost *model);
+    HsWidgetHost *visualModel() const;
+signals:
+    void resized();
+
+public slots:
+    void startDragEffect();
+    void startDropEffect();
+
+protected:
+    bool eventFilter(QObject *watched, QEvent *event);
+    void gestureEvent(QGestureEvent *event);
+    void mousePressEvent(QGraphicsSceneMouseEvent *) {}
+
+private:
+    Q_DISABLE_COPY(HsWidgetHostVisual)
+    void setupTouchArea();
+    void setupEffects();
+
+    void setNewSize(const QSizeF &size);
+
+
+private:
+    HsWidgetTouchArea *mTouchArea;
+    HsWidgetHost *mVisualModel;
+    QGraphicsWidget *mWidget;
+    HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
+};
+
+#endif // HSWIDGETHOST_H
--- a/homescreenapp/hsdomainmodel/inc/hswidgettoucharea.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/inc/hswidgettoucharea.h	Fri Jul 23 13:47:57 2010 +0300
@@ -24,14 +24,14 @@
 
 HOMESCREEN_TEST_CLASS(TestHsDomainModel)
 
-class HsWidgetHost;
+class HsWidgetHostVisual;
 
 class HsWidgetTouchArea : public HbTouchArea
 {
     Q_OBJECT
 
 public:
-    HsWidgetTouchArea(HsWidgetHost *widgetHost);
+    HsWidgetTouchArea(HsWidgetHostVisual *widgetHost);
     ~HsWidgetTouchArea();
 
     bool sceneEvent(QEvent *event);
@@ -44,7 +44,7 @@
     Q_DISABLE_COPY(HsWidgetTouchArea)
     
 private:
-    HsWidgetHost *mWidgetHost;
+    HsWidgetHostVisual *mWidgetHostVisual;
 
     HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/resource/controllayer.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.9">
+    <widget name="controlLayer" type="HbWidget">
+        <widget name="pageIndicator" type="HsPageIndicator">
+            <sizehint height="2.5un" type="PREFERRED"/>
+        </widget>
+        <widget name="trashBin" type="HsTrashBinWidget">
+            <sizehint type="PREFERRED" height="11un" width="11un"/>
+        </widget>
+        <layout type="anchor">
+            <anchoritem dst="pageIndicator" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+            <anchoritem dst="pageIndicator" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+            <anchoritem dst="pageIndicator" dstEdge="BOTTOM" spacing="-1un" src="" srcEdge="BOTTOM"/>
+            <anchoritem dst="trashBin" dstEdge="CENTERH" spacing="0un" src="" srcEdge="CENTERH"/>
+            <anchoritem dst="trashBin" dstEdge="BOTTOM" spacing="-1un" src="" srcEdge="BOTTOM"/>
+        </layout>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/src/hsdocumentloader.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Homescreen document loader class.
+*
+*/
+
+#include "hsdocumentloader.h"
+#include "hspageindicator.h"
+#include "hstrashbinwidget.h"
+#include "hsconfiguration.h"
+
+/*!
+    \class HsDocumentLoader
+    \ingroup group_hshomescreenstateplugin
+    \brief Homescreen document loader class.
+
+    Loads own widgets from docml.
+*/
+
+/*!
+    Constructor.
+*/
+HsDocumentLoader::HsDocumentLoader()
+    : HbDocumentLoader()
+{
+}
+
+/*!
+    Destructor.
+*/
+HsDocumentLoader::~HsDocumentLoader()
+{
+}
+
+/*!
+    Looks up an object which inherits class type and of which object name equals to name.
+    \a type type of the desired object.
+    \a name object name of the desired object.
+    */
+QObject *HsDocumentLoader::createObject(const QString &type, const QString &name)
+{
+    if (type == HsPageIndicator::staticMetaObject.className()) {
+        QObject *object = new HsPageIndicator(HSCONFIGURATION_GET(pageIndicatorSpacing));
+        object->setObjectName(name);
+        return object;
+    }
+    else if (type == HsTrashBinWidget::staticMetaObject.className()) {
+        QObject *object = new HsTrashBinWidget;
+        object->setObjectName(name);
+        return object;
+    }
+        
+    return HbDocumentLoader::createObject(type, name);
+}
--- a/homescreenapp/hsdomainmodel/src/hsgui.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hsgui.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -16,9 +16,19 @@
 */
 
 #include <HbInstance>
+#include <HbMainWindow>
 #include <HbView>
+#include <HbMenu>
+#include <HbAction>
 
 #include "hsgui.h"
+#include "hsidlewidget.h"
+#include "hsscene.h"
+#include "hsconfiguration.h"
+#include "hspropertyanimationwrapper.h"
+namespace {
+      const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
+}
 
 /*!
     \class HsGui
@@ -27,47 +37,159 @@
     HsGui includes common UI components for Home screen.
 */
 
-/*!
-    Returns the idle view. 
-*/
-HbView *HsGui::idleView()
+HsGui *HsGui::mInstance(0);
+
+struct HsGuiImpl
 {
-    return mIdleView;    
+    HsIdleWidget *mIdleWidget;
+    HbView *mIdleView;
+    HbMainWindow *mWindow;
+    HbAction *mNavigationAction;
+    HsPropertyAnimationWrapper *mPageChangeAnimation;
+    HsPropertyAnimationWrapper *mPageCrawlingAnimation;
+};
+
+
+
+HsGui::~HsGui()
+{
+    if (mImpl->mNavigationAction) {
+        delete mImpl->mNavigationAction;
+    }
+
+    if (mImpl->mPageChangeAnimation) {
+        mImpl->mPageChangeAnimation->stop();
+        delete mImpl->mPageChangeAnimation;
+    }
+    if (mImpl->mPageCrawlingAnimation) {
+        mImpl->mPageCrawlingAnimation->stop();
+        delete mImpl->mPageCrawlingAnimation;
+    }
+    delete mImpl;
 }
 
-/*!
-    Returns the current idle view instance. Callers of this 
-    function take ownership of the instance. The current 
-    view instance will be reset to null.    
-*/
-HbView *HsGui::takeIdleView()
-{	
-    HbView *idleView = mIdleView;
-    mIdleView = 0;
-    return idleView;
+HsGui *HsGui::setInstance(HsGui *instance)
+{
+    HsGui *old = mInstance;
+    if (mInstance != instance) {
+        mInstance = instance;
+    }
+    return old;
+}
+
+HsGui *HsGui::instance()
+{
+    if (!mInstance) {
+        mInstance = new HsGui(QCoreApplication::instance());
+    }
+    return mInstance;
+}
+
+HsGui *HsGui::takeInstance()
+{
+    HsGui *instance = mInstance;
+    mInstance = 0;
+    return instance;
+}
+
+void HsGui::setupIdleUi()
+{
+    if (!mImpl->mIdleWidget) {
+        mImpl->mIdleWidget = new HsIdleWidget;
+        mImpl->mIdleView = mImpl->mWindow->addView(mImpl->mIdleWidget);
+        mImpl->mIdleView->setContentFullScreen();
+
+        delete mImpl->mNavigationAction;
+        mImpl->mNavigationAction = 0;
+        mImpl->mNavigationAction = new HbAction;
+        mImpl->mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
+        mImpl->mNavigationAction->setObjectName("applib_navigation_action");
+        connect(mImpl->mNavigationAction, SIGNAL(triggered()), SIGNAL(navigateToApplibrary()));
+        mImpl->mIdleView->setNavigationAction(mImpl->mNavigationAction);
+    }
+    mImpl->mWindow->setCurrentView(mImpl->mIdleView);    
 }
 
-/*!
-    Sets the idle view instance. The existing instance
-    will be deleted.
-*/
-void HsGui::setIdleView(HbView *idleView)
+void HsGui::cleanupIdleUi()
 {
-    if (mIdleView != idleView) {
-        delete mIdleView;
-        mIdleView = idleView;
+    if (mImpl->mIdleView) {
+        mImpl->mIdleView->setNavigationAction(0);
+        delete mImpl->mNavigationAction;
+        mImpl->mNavigationAction = 0;
+        
+        mImpl->mWindow->removeView(mImpl->mIdleView);
+        delete mImpl->mIdleView;
+        mImpl->mIdleView = 0;
+
+        delete mImpl->mPageChangeAnimation;
+        mImpl->mPageChangeAnimation = 0;
+        
+        delete mImpl->mPageCrawlingAnimation;
+        mImpl->mPageCrawlingAnimation = 0;
     }
+    
+}
+
+void HsGui::setOrientation(Qt::Orientation orientation)
+{
+    mImpl->mWindow->setOrientation(orientation);
+}
+
+Qt::Orientation HsGui::orientation()
+{
+    return mImpl->mWindow->orientation();
+}
+
+HbView *HsGui::idleView() const
+{
+    return mImpl->mIdleView;
+}
+
+HsIdleWidget *HsGui::idleWidget() const
+{
+    return mImpl->mIdleWidget;
 }
 
-/*!
-    Returns the main window.
-*/
-HbMainWindow *HsGui::mainWindow()
+QRectF HsGui::layoutRect() const
 {
-    return hbInstance->allMainWindows().first();
+    return mImpl->mWindow->layoutRect();
+}
+
+void HsGui::show()
+{
+    mImpl->mWindow->raise();
+    mImpl->mWindow->show();
 }
 
-/*!
-    Points to the idle view instance.
-*/
-QPointer<HbView> HsGui::mIdleView(0);
+HsPropertyAnimationWrapper *HsGui::pageChangeAnimation()
+{
+    if (!mImpl->mPageChangeAnimation) {
+        mImpl->mPageChangeAnimation = new HsPropertyAnimationWrapper;
+        mImpl->mPageChangeAnimation->setTargetObject(mImpl->mIdleWidget);
+        mImpl->mPageChangeAnimation->setPropertyName("sceneX"); 
+    }
+    return mImpl->mPageChangeAnimation;
+}
+HsPropertyAnimationWrapper *HsGui::pageCrawlingAnimation()
+{
+    if (!mImpl->mPageCrawlingAnimation) {
+        mImpl->mPageCrawlingAnimation = new HsPropertyAnimationWrapper;
+        mImpl->mPageCrawlingAnimation->setTargetObject(mImpl->mIdleWidget);
+        mImpl->mPageCrawlingAnimation->setPropertyName("sceneX"); 
+    }
+    return mImpl->mPageCrawlingAnimation;
+}
+
+HsGui::HsGui(QObject *parent):
+    QObject(parent),mImpl(new HsGuiImpl)
+{
+    mImpl->mIdleView = 0;
+    mImpl->mIdleWidget = 0;
+    mImpl->mNavigationAction = 0;
+    mImpl->mPageChangeAnimation = 0;
+    mImpl->mPageCrawlingAnimation = 0;
+
+    mImpl->mWindow = hbInstance->allMainWindows().first();
+    connect(mImpl->mWindow, SIGNAL(orientationChanged(Qt::Orientation)),
+        SIGNAL(orientationChanged(Qt::Orientation)));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/src/hshostedwidgetfactory.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#include <qservicemanager.h>
+#include <qservicefilter.h>
+#include <qserviceinterfacedescriptor.h>
+#include <QGraphicsWidget>
+#include "hshostedwidgetfactory.h"
+
+QTM_USE_NAMESPACE
+
+/*!
+    \class HsWidgetFactory
+    \ingroup group_hsdomainmodel
+    \brief Each widget is controlled by the home screen framework through a widget host.
+*/
+
+
+struct HsHostedWidgetFactoryImpl{
+    QServiceManager mServiceManager;
+    QServiceFilter mFilter;
+};
+
+
+
+HsHostedWidgetFactory *HsHostedWidgetFactory::mInstance = 0;
+
+HsHostedWidgetFactory *HsHostedWidgetFactory::instance()
+{
+    if (!mInstance) {
+        mInstance = new HsHostedWidgetFactory;
+    }
+    return mInstance;
+}
+
+HsHostedWidgetFactory *HsHostedWidgetFactory::takeInstance()
+{
+    HsHostedWidgetFactory *instance = mInstance;
+    mInstance = 0;
+    return instance;
+}
+
+HsHostedWidgetFactory *HsHostedWidgetFactory::setInstance
+                                             (HsHostedWidgetFactory *instance)
+{
+    HsHostedWidgetFactory *old = mInstance;
+    if (mInstance != instance) {
+        mInstance = instance;
+    }
+    return old;
+}
+
+QObject *HsHostedWidgetFactory::createWidget(const QString &uri)
+{
+    mImpl->mFilter.setServiceName(uri);
+    QList<QServiceInterfaceDescriptor> interfaces = 
+        mImpl->mServiceManager.findInterfaces(mImpl->mFilter);
+    
+    if (interfaces.isEmpty()) {
+        return 0;
+    }
+    // In theory we support QGraphicsWidget derived widgets
+    QObject *widgetObject = mImpl->mServiceManager.loadInterface(interfaces.first());
+    
+    if (!qobject_cast<QGraphicsWidget *>(widgetObject)) {
+        delete widgetObject;
+        widgetObject = 0;
+    }
+    return widgetObject;
+}
+
+/*!
+    Constructs a new widget host with given \a databaseId and
+    \a parent item.
+*/
+HsHostedWidgetFactory::HsHostedWidgetFactory(QObject *parent)
+  : QObject(parent),
+    mImpl(new HsHostedWidgetFactoryImpl)
+{
+    mImpl->mFilter.setInterface("com.nokia.symbian.IHomeScreenWidget");
+}
+
+/*!
+    Destructor.
+*/
+HsHostedWidgetFactory::~HsHostedWidgetFactory()
+{
+    delete mImpl;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/src/hsidlewidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,409 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <QApplication>
+#include <QGraphicsSceneMouseEvent>
+#include <QGraphicsLinearLayout>
+#include <QDir>
+
+#include <HbMainWindow>
+#include <HbVkbHost>
+
+#include "hsidlewidget.h"
+#include "hsscene.h"
+#include "hspage.h"
+#include "hspagevisual.h"
+#include "hswidgethost.h"
+#include "hswallpaper.h"
+#include "hstrashbinwidget.h"
+#include "hspageindicator.h"
+#include "hsdocumentloader.h"
+#include "hsconfiguration.h"
+#include "hsapp_defs.h"
+#include "hssnapline.h"
+#include "hsgui.h"
+
+
+namespace
+{
+    const char gControlLayerDocmlName[] = "controllayer.docml";
+    const char gControlLayerName[]      = "controlLayer";
+    const char gTrashBinName[]          = "trashBin";
+    const char gPageIndicatorName[]     = "pageIndicator";
+}
+
+/*!
+    \class HsIdleWidget
+    \ingroup group_hshomescreenstateplugin
+    \brief View part of the home screen idle state.
+
+    Maintains the idle view ui layers and takes care of
+    receiving user input and communicating it to the idle
+    state for further processing.
+*/
+
+/*!
+    Constructs a new idle widget with the given \a parent.
+*/
+HsIdleWidget::HsIdleWidget(QGraphicsItem *parent)
+  : HbWidget(parent),
+    mControlLayer(0), mPageLayer(0), mPageWallpaperLayer(0),
+    mSceneLayer(0),
+    mTrashBin(0), mPageIndicator(0),
+    mHorizontalSnapLine(0), mVerticalSnapLine(0)
+{
+    setFlag(ItemHasNoContents);
+
+    loadControlLayer();
+
+    QGraphicsLinearLayout *linearLayout = 0;
+
+    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+    linearLayout->setContentsMargins(0, 0, 0, 0);
+    linearLayout->setSpacing(0);
+    mPageLayer = new HbWidget(this);
+    mPageLayer->setLayout(linearLayout);
+    mPageLayer->setZValue(2);
+    
+    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+    linearLayout->setContentsMargins(0, 0, 0, 0);
+    linearLayout->setSpacing(0);
+    mPageWallpaperLayer = new HbWidget(this);
+    mPageWallpaperLayer->setLayout(linearLayout);
+    mPageWallpaperLayer->setZValue(1);
+    
+    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+    linearLayout->setContentsMargins(0, 0, 0, 0);
+    linearLayout->setSpacing(0);
+    mSceneLayer = new HbWidget(this);
+    mSceneLayer->setLayout(linearLayout);
+    mSceneLayer->setZValue(0);
+}
+
+/*!
+    Destroys this idle widget.
+*/
+HsIdleWidget::~HsIdleWidget()
+{
+    QList<HsPage *> pages = HsScene::instance()->pages();
+    foreach (HsPage *page, pages) {
+        page->visual()->setParentItem(0);
+        if (page->visual()->scene()) {
+            page->visual()->scene()->removeItem(page->visual());
+        }
+        HsWallpaper *pageWallpaper = page->wallpaper();
+        if (pageWallpaper) {
+            pageWallpaper->setParentItem(0);
+            if (pageWallpaper->scene()) {
+                pageWallpaper->scene()->removeItem(pageWallpaper);
+            }
+        }
+    }
+
+    HsWallpaper *sceneWallpaper = HsScene::instance()->wallpaper();
+    if (sceneWallpaper) {
+        sceneWallpaper->setParentItem(0);
+        if (sceneWallpaper->scene()) {
+            sceneWallpaper->scene()->removeItem(sceneWallpaper);
+        }
+    }
+}
+
+qreal HsIdleWidget::sceneX() const
+{
+    return mPageLayer->x();
+}
+
+void HsIdleWidget::setSceneX(qreal x)
+{
+    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
+        mPageLayer->setX(x);
+        mSceneLayer->setX((parallaxFactor() * x) - HSCONFIGURATION_GET(bounceEffect) / 2);
+    } else {
+        mPageLayer->setX(x);
+        mPageWallpaperLayer->setX(x);
+    }
+}
+
+/*!
+    Layouts the ui layers according to the given \a rect.
+    If given \a rect has different size than a fullscreen view, rect
+    is lifted up by statuspane height. Normally HsIdleWidget position is 0,0 
+    relative to it's parent container (HbView). This functionality tackles
+    problem caused by HbStackedLayout which sets top most rect for all items 
+    (views) in a stack (not considering fullscreen mode).
+*/
+void HsIdleWidget::setGeometry(const QRectF &rect)
+{
+    
+    int n = HsScene::instance()->pages().count();
+    QRectF layoutRect(HsGui::instance()->layoutRect());
+    if (layoutRect == rect || (layoutRect.height() == rect.width() && layoutRect.width() == rect.height())) {
+        mControlLayer->resize(rect.size());
+        mPageLayer->resize(n * rect.width(), rect.height());
+        if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+            mPageWallpaperLayer->resize(n * rect.width(), rect.height());
+        }
+        mSceneLayer->resize(2 * rect.width() + HSCONFIGURATION_GET(bounceEffect), rect.height());
+        HbWidget::setGeometry(rect);
+    } else {
+        QRectF sceneRect = mapToScene(rect).boundingRect();
+        // HbView is a container item for widget, thus 0,0 is relative to view's position.
+        // Lift rect by offset. Fullscreen view is in 0,0 position in scene coordinates otherwise
+        // it's e.g 0,68 (statuspane being at 0,0 and view at 0,68)
+        sceneRect.setTop(-sceneRect.top());
+        HbWidget::setGeometry(sceneRect);
+    }
+}
+
+/*!
+    Sets the active page \a index to the page
+    indicator.
+*/
+void HsIdleWidget::setActivePage(int index)
+{
+    mPageIndicator->setActiveItemIndex(index);
+}
+
+/*!
+    Inserts the given \a page at index position
+    \a index in the page layer.
+*/
+void HsIdleWidget::insertPage(int index, HsPage *page)
+{
+    QGraphicsLinearLayout *layout =
+        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
+    layout->insertItem(index, page->visual());
+    mPageLayer->resize(
+        layout->count() * size().width(), size().height());
+
+    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+        QGraphicsLinearLayout *layout =
+            static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
+        layout->insertItem(index, page->wallpaper());
+        mPageWallpaperLayer->resize(
+            layout->count() * size().width(), size().height());
+    }
+}
+
+/*!
+    Removes the page at index position
+    \a index in the page layer.
+*/
+void HsIdleWidget::removePage(int index)
+{
+    QGraphicsLinearLayout *layout =
+        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
+    layout->removeAt(index);
+    mPageLayer->resize(
+        layout->count() * size().width(), size().height());
+
+    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+        QGraphicsLinearLayout *layout =
+            static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
+        layout->removeAt(index);
+        mPageWallpaperLayer->resize(
+            layout->count() * size().width(), size().height());
+    }
+    mPageIndicator->removeItem(index);
+}
+
+/*!
+    \fn HsIdleWidget::controlLayer() const
+
+    Returns the control layer.
+*/
+
+/*!
+    \fn HsIdleWidget::pageLayer() const
+
+    Returns the page layer.
+*/
+
+/*!
+    \fn HsIdleWidget::sceneLayer() const
+
+    Returns the scene layer.
+*/
+
+/*!
+    \fn HsIdleWidget::trashBin() const
+
+    Returns the trashbin widget.
+*/
+
+/*!
+    \fn HsIdleWidget::pageIndicator() const
+
+    Returns the page indicator widget.
+*/
+
+/*!
+    Sets the trashbin visible and hides the page indicator.
+*/
+void HsIdleWidget::showTrashBin()
+{
+    mPageIndicator->hide();
+    mTrashBin->show();
+}
+
+/*!
+    Sets the page indicator visible and hides the trashbin.
+*/
+void HsIdleWidget::showPageIndicator()
+{
+    mTrashBin->hide();
+    mTrashBin->deactivate();
+    mPageIndicator->setSpacing(HSCONFIGURATION_GET(pageIndicatorSpacing)); // for usability optimization widget, can be removed later on
+    mPageIndicator->setVisible(1 < mPageIndicator->itemCount());
+}
+
+/*!
+    Shows the Vertical snapping lines showing the guidance
+*/
+void HsIdleWidget::showVerticalSnapLine(const QLineF &snapLine)
+{
+    QVariantHash snapConfiguration;
+    snapConfiguration[SNAPLINEFADEINDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeInDuration));
+    snapConfiguration[SNAPLINEFADEOUTDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeOutDuration));
+
+    mVerticalSnapLine->setConfiguration(snapConfiguration);
+    mVerticalSnapLine->showLine(snapLine);
+}
+
+/*!
+    Shows the Horizontal snapping lines showing the guidance
+*/
+void HsIdleWidget::showHorizontalSnapLine(const QLineF &snapLine)
+{
+    QVariantHash snapConfiguration;
+    snapConfiguration[SNAPLINEFADEINDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeInDuration));
+    snapConfiguration[SNAPLINEFADEOUTDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeOutDuration));
+
+    mHorizontalSnapLine->setConfiguration(snapConfiguration);
+    mHorizontalSnapLine->showLine(snapLine);
+}
+
+/*!
+    Hides the Vertical snapping line showing the guidance
+*/
+void HsIdleWidget::hideVerticalSnapLine()
+{
+    mVerticalSnapLine->hideLine();
+}
+
+/*!
+    Hides the Horizontal snapping line showing the guidance
+*/
+void HsIdleWidget::hideHorizontalSnapLine()
+{
+    mHorizontalSnapLine->hideLine();
+}
+
+/*!
+    Reimplements QGraphicsWidget::polishEvent().
+*/
+void HsIdleWidget::polishEvent()
+{
+    HsScene *scene = HsScene::instance();
+    Q_ASSERT(scene);
+
+    QGraphicsLinearLayout *pageLayout = 
+        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
+
+    QList<HsPage *> pages = scene->pages();
+
+    foreach (HsPage *page, pages) {
+        pageLayout->addItem(page->visual());
+        if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+            QGraphicsLinearLayout *pageWallpaperLayout = 
+                static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
+            pageWallpaperLayout->addItem(page->wallpaper());
+        }
+    }
+   if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
+        QGraphicsLinearLayout *sceneLayout = 
+            static_cast<QGraphicsLinearLayout *>(mSceneLayer->layout());
+    	HsWallpaper *wallpaper = HsScene::instance()->wallpaper();
+        sceneLayout->addItem(wallpaper);
+    }
+           
+    mPageIndicator->initialize(pages.count(), scene->activePageIndex());    
+    showPageIndicator();
+
+   // HsGui::instance()->scene()->installEventFilter(this);
+}
+
+/*!
+    Loads the control layer declared in a docml file.
+*/
+void HsIdleWidget::loadControlLayer()
+{
+    HsDocumentLoader loader;
+    bool loaded = false;
+
+#ifndef Q_OS_SYMBIAN
+    QString path = QDir::currentPath();
+#else
+    QString path = "c:";
+#endif
+
+    QString file = path + "/hsresources/" + gControlLayerDocmlName;
+    QString fallbackPath = QString(":/") + gControlLayerDocmlName;
+
+    if (QFile::exists(file)) {
+        loader.load(file, &loaded);
+        if (!loaded) {
+            loader.load(fallbackPath, &loaded);
+        }
+    } else {
+        loader.load(fallbackPath, &loaded);
+    }
+
+    if (loaded) {
+        mControlLayer = qobject_cast<HbWidget *>(loader.findWidget(gControlLayerName));
+        mControlLayer->setZValue(3);
+        mControlLayer->setParentItem(this);
+
+        mTrashBin = qobject_cast<HsTrashBinWidget *>(loader.findWidget(gTrashBinName));
+        mTrashBin->setZValue(1e6);
+
+        mPageIndicator = qobject_cast<HsPageIndicator *>(loader.findWidget(gPageIndicatorName));
+        mPageIndicator->setZValue(1e6);
+
+
+        mHorizontalSnapLine = new HsSnapLine(mControlLayer);
+        mHorizontalSnapLine->setZValue(10);
+
+        mVerticalSnapLine = new HsSnapLine(mControlLayer);
+        mVerticalSnapLine->setZValue(10);
+    } else {
+        // TODO: Handle error.
+    }
+}
+
+qreal HsIdleWidget::parallaxFactor() const
+{   
+    qreal clw = mControlLayer->size().width();
+    qreal slw = mSceneLayer->size().width() - HSCONFIGURATION_GET(bounceEffect);
+    int n = HsScene::instance()->pages().count();
+    if (n < 2) {
+        return 1;
+    } else {
+        return (slw - clw) / ((n - 1) * clw);
+    }
+}
--- a/homescreenapp/hsdomainmodel/src/hspage.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hspage.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -19,15 +19,18 @@
 
 #include "hsdomainmodeldatastructures.h"
 #include "hspage.h"
+#include "hspagevisual.h"
 #include "hspagetoucharea.h"
 #include "hspagenewwidgetlayout.h"
 #include "hsscene.h"
 #include "hsdatabase.h"
 #include "hswidgethost.h"
+#include "hswidgethostvisual.h"
 #include "hswallpaper.h"
 #include "hswidgetpositioningonwidgetadd.h"
 #include "hswidgetpositioningonorientationchange.h"
 #include "hsconfiguration.h"
+#include "hsgui.h"
 
 
 /*!
@@ -43,20 +46,15 @@
     \a parent Owner.
     \a aFlags Window flags.
 */
-HsPage::HsPage(QGraphicsItem* parent)
-    : HbWidget(parent),
+HsPage::HsPage(QObject* parent)
+    : QObject(parent),
       mDatabaseId(-1),
+      mPageVisual(new HsPageVisual), 
       mWallpaper(0),
       mRemovable(true),
-      mTouchArea(0),
       mPageMargin(0.0)
 {
-    setFlag(QGraphicsItem::ItemHasNoContents);
-    setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
-                              QSizePolicy::Ignored));
-
-    setupTouchArea();
-
+ 
     //Page margin
     mPageMargin = HSCONFIGURATION_GET(pageMargin);
     connect(HsConfiguration::instance(), SIGNAL(propertyChanged(QString)), SLOT(onPageMarginChanged(QString)));
@@ -67,6 +65,36 @@
 */
 HsPage::~HsPage()
 {
+    // visuals are owned by widget host, detach those from page visual
+    HsWidgetHostVisual *visual(0);
+    foreach (HsWidgetHost *widget, mWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
+    }
+   
+    foreach (HsWidgetHost *widget, mNewWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
+    }
+   
+    foreach (HsWidgetHost *widget, mUnavailableWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
+    }
+    qDeleteAll(mWidgets);
+    qDeleteAll(mNewWidgets);
+    qDeleteAll(mUnavailableWidgets);
+
+    delete mPageVisual;
     delete mWallpaper;
 }
 
@@ -85,7 +113,7 @@
 {
     mDatabaseId = id;
 }
-
+/*
 void HsPage::setGeometry(const QRectF &rect)
 {
     if (mTouchArea) {
@@ -94,7 +122,7 @@
 
     HbWidget::setGeometry(rect);
 }
-
+*/
 /*!
     Loads widgets.
 */
@@ -117,14 +145,23 @@
 
     foreach (HsWidgetData data, datas) {
         HsWidgetHost *widget = new HsWidgetHost(data.id);
-        mWidgets.append(widget);
-        connectWidget(widget);
-        widget->setPage(this);
-        widget->setParentItem(this);
-        widget->startWidget(isDefaultPage());
+        if (!widget->loadPresentation(Qt::Horizontal) &&
+            !widget->loadPresentation(Qt::Vertical)) {
+            widget->setPage(this);
+            widget->visual()->hide();
+            connectWidget(widget);
+            mNewWidgets << widget;            
+        }
+        else {
+            mWidgets.append(widget);
+            connectWidget(widget);
+            widget->setPage(this);
+            widget->visual()->setParentItem(this->visual());
+            widget->startWidget(isDefaultPage());
+        }
     }
 
-    connect(HsScene::mainWindow(),
+    connect(HsGui::instance(),
         SIGNAL(orientationChanged(Qt::Orientation)),
         SLOT(onOrientationChanged(Qt::Orientation)));
 
@@ -157,7 +194,7 @@
 
     connectWidget(widgetHost);
     mWidgets << widgetHost;
-    widgetHost->setParentItem(this);
+    widgetHost->visual()->setParentItem(visual());
 
     return true;
  }
@@ -174,7 +211,7 @@
 
     disconnectWidget(widgetHost);
     mWidgets.removeOne(widgetHost);
-    widgetHost->setParentItem(0);
+    widgetHost->visual()->setParentItem(0);
 
     return true;
 }
@@ -202,20 +239,10 @@
     if (mNewWidgets.contains(widgetHost)) {
         return true;
     }
+    
+    widgetHost->setPage(this);    
 
-    HsWidgetPresentationData presentation;
-    QPointF adjustedWidgetPos = adjustedWidgetPosition(widgetHost->geometry());
-    presentation.orientation = HsScene::orientation();
-    if (!widgetHost->getPresentation(presentation)) {
-        presentation.orientation = HsScene::orientation();
-        presentation.setPos(adjustedWidgetPos);
-        presentation.zValue = 0;
-        widgetHost->savePresentation(presentation);
-    }
-
-    widgetHost->hide();
-    widgetHost->setPos(adjustedWidgetPos);
-    widgetHost->setZValue(presentation.zValue);
+    widgetHost->visual()->hide();
 
     connectWidget(widgetHost);
     mNewWidgets << widgetHost;
@@ -232,10 +259,10 @@
         return;
     }
 
-    HsPageNewWidgetLayout *newWidgetLayout = static_cast<HsPageNewWidgetLayout *>(layout());
+    HsPageNewWidgetLayout *newWidgetLayout = static_cast<HsPageNewWidgetLayout *>(visual()->layout());
     if (!newWidgetLayout) {
         newWidgetLayout = new HsPageNewWidgetLayout(mTouchPoint);
-        setLayout(newWidgetLayout);
+        visual()->setLayout(newWidgetLayout);
     }    
     updateZValues();
     HsWidgetHost *widget = 0;
@@ -243,9 +270,9 @@
         widget = mNewWidgets.at(i);
         newWidgetLayout->addItem(widget);
         widget->setPage(this);
-        widget->setParentItem(this);
+        widget->visual()->setParentItem(visual());
         widget->showWidget();
-        widget->show();
+        widget->visual()->show();
     }
     mWidgets << mNewWidgets;
     mNewWidgets.clear();
@@ -257,7 +284,7 @@
 void HsPage::resetNewWidgets()
 {
     mNewWidgets.clear();
-    setLayout(0);
+    visual()->setLayout(0);
 }
 
 /*!
@@ -265,17 +292,35 @@
 */
 bool HsPage::deleteFromDatabase()
 {
+    
+    HsWidgetHostVisual *visual(0);
     foreach (HsWidgetHost *widget, mWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
         widget->remove();
     }
     mWidgets.clear();
+    
 
     foreach (HsWidgetHost *widget, mNewWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
         widget->remove();
     }
     mNewWidgets.clear();
 
     foreach (HsWidgetHost *widget, mUnavailableWidgets) {
+        visual = widget->visual();
+        visual->setParent(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
         widget->remove();
     }
     mUnavailableWidgets.clear();
@@ -362,7 +407,7 @@
 */
 QRectF HsPage::contentGeometry()
 {
-    return contentGeometry(HsScene::mainWindow()->orientation());
+    return contentGeometry(HsGui::instance()->orientation());
 }
 
 /*!
@@ -370,9 +415,9 @@
 */
 QRectF HsPage::contentGeometry(Qt::Orientation orientation)
 {
-    QRectF pageRect = HsScene::mainWindow()->layoutRect();
+    QRectF pageRect = HsGui::instance()->layoutRect();
 
-    if (orientation != HsScene::orientation()) {
+    if (orientation != HsGui::instance()->orientation()) {
         qreal width = pageRect.width();
         qreal height = pageRect.height();
         pageRect.setWidth(height);
@@ -391,7 +436,7 @@
 */
 QRectF HsPage::contentRect()
 {
-    return contentRect(HsScene::mainWindow()->orientation());
+    return contentRect(HsGui::instance()->orientation());
 }
 
 /*!
@@ -404,13 +449,17 @@
     return rect;
 }
 
+HsPageVisual *HsPage::visual() const
+{
+    return mPageVisual;
+}
 /*!
     Calls onShow() for contained widgets.
 */
 void HsPage::showWidgets()
 {
     foreach (HsWidgetHost *widget, mWidgets) {
-        if (widget->parentItem() == this) {
+        if (widget->visual()->parentItem() == visual()) {
             widget->showWidget();
         }
     }
@@ -422,7 +471,7 @@
 void HsPage::hideWidgets()
 {
     foreach (HsWidgetHost *widget, mWidgets) {
-        if (widget->parentItem() == this) {
+        if (widget->visual()->parentItem() == visual()) {
             widget->hideWidget();
         }
     }
@@ -452,7 +501,7 @@
     if (!mWidgets.isEmpty()) {
         QMultiMap<qreal, HsWidgetHost *> map;
         foreach (HsWidgetHost *widget, mWidgets) {
-            map.insert(widget->zValue(), widget);
+            map.insert(widget->visual()->zValue(), widget);
         }
 
         QList<HsWidgetHost *> sortedWidgets = map.values();
@@ -464,14 +513,14 @@
         }
 
         foreach (HsWidgetHost *widget, sortedWidgets) {
-            widget->setZValue(z++);
+            widget->visual()->setZValue(z++);
             widget->savePresentation();
         }
     }
 
     if (!mNewWidgets.isEmpty()) {
         foreach (HsWidgetHost *widget, mNewWidgets) {
-            widget->setZValue(z++);
+            widget->visual()->setZValue(z++);
             widget->savePresentation();
         }
     }
@@ -486,11 +535,11 @@
 /*!
     Create touch area for page.
 */
-void HsPage::setupTouchArea()
+/*void HsPage::setupTouchArea()
 {
     mTouchArea = new HsPageTouchArea(this);
     mTouchArea->setZValue(-1);
-}
+}*/
 /*!
     Utility to connect widget signals to page.
 */
@@ -498,7 +547,7 @@
 {
     connect(widget, SIGNAL(finished()), SLOT(onWidgetFinished()));
     connect(widget, SIGNAL(faulted()), SLOT(onWidgetFaulted()));
-    connect(widget, SIGNAL(resized()), SLOT(onWidgetResized()));
+    connect(widget->visual(), SIGNAL(resized()), SLOT(onWidgetResized()));
     connect(widget, SIGNAL(available()), SLOT(onWidgetAvailable()));
     connect(widget, SIGNAL(unavailable()), SLOT(onWidgetUnavailable()));
 }
@@ -507,6 +556,7 @@
 */
 void HsPage::disconnectWidget(HsWidgetHost *widget)
 {
+    widget->visual()->disconnect(this);
     widget->disconnect(this);
 }
 /*!
@@ -521,6 +571,14 @@
     if (!mNewWidgets.removeOne(widget)) {
         mWidgets.removeOne(widget);
     }
+    if (widget){     
+        HsWidgetHostVisual *visual = widget->visual();
+        visual->setParentItem(0);
+        if (visual->scene()) {
+            visual->scene()->removeItem(visual);
+        }
+    }
+    
 
     disconnectWidget(widget);
     widget->remove();
@@ -539,11 +597,11 @@
 */
 void HsPage::onWidgetResized()
 {
-    if ( !layout() ) {
-        HsWidgetHost *widget = qobject_cast<HsWidgetHost *>(sender());
-        widget->setPos(adjustedWidgetPosition(widget->geometry()));
+    if (!visual()->layout()) {
+        HsWidgetHostVisual *widgetVisual = qobject_cast<HsWidgetHostVisual *>(sender());
+        widgetVisual->setPos(adjustedWidgetPosition(widgetVisual->geometry()));
     } else {
-        layout()->invalidate();
+        visual()->layout()->invalidate();
     }
 }
 /*!
@@ -552,13 +610,14 @@
 void HsPage::onWidgetAvailable()
 {
     HsWidgetHost *widget = qobject_cast<HsWidgetHost *>(sender());
+    HsWidgetHostVisual *widgetVisual(widget->visual());
 
     mUnavailableWidgets.removeOne(widget);
     mWidgets.append(widget);
 
-    widget->setParentItem(this);
+    widgetVisual->setParentItem(visual());
     widget->startWidget(isActivePage());
-    widget->show();
+    widgetVisual->show();
 }
 /*!
     Update internal bookkeeping and hide widget
@@ -566,6 +625,7 @@
 void HsPage::onWidgetUnavailable()
 {
     HsWidgetHost *widget = qobject_cast<HsWidgetHost *>(sender());
+    HsWidgetHostVisual *widgetVisual(widget->visual());
 
     if (mWidgets.contains(widget)) {
         mWidgets.removeOne(widget);
@@ -577,8 +637,8 @@
 
     mUnavailableWidgets.append(widget);
 
-    widget->hide();
-    widget->setParentItem(0);
+    widgetVisual->hide();
+    widgetVisual->setParentItem(0);
 }
 
 /*!
@@ -596,41 +656,135 @@
 
     HsWidgetPresentationData presentation;
     presentation.orientation = orientation;
-
+    
+    HsWidgetHostVisual *visual(0);
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    QList<HsWidgetHost*> newWidgets;
+#endif //HSWIDGETORGANIZER_ALGORITHM    
     foreach (HsWidgetHost *widget, mWidgets) {
+        visual = widget->visual();
         if (!widget->getPresentation(presentation)) {
+#ifndef HSWIDGETORGANIZER_ALGORITHM
             QList<QRectF> geometries = converter->convert(
-                from, QList<QRectF>() << widget->geometry(), to);
-            widget->setGeometry(geometries.first());
+                from, QList<QRectF>() << visual->geometry(), to);
+            visual->setGeometry(geometries.first());
             widget->savePresentation();
+#else //HSWIDGETORGANIZER_ALGORITHM
+            newWidgets << widget;
+#endif //HSWIDGETORGANIZER_ALGORITHM
         } else {
             QRectF adjustWidgetPosition;
-            adjustWidgetPosition = widget->geometry();
+            adjustWidgetPosition = visual->geometry();
             adjustWidgetPosition.moveTopLeft(presentation.pos());
-            widget->setPos(adjustedWidgetPosition(adjustWidgetPosition));
-            widget->setZValue(presentation.zValue);
+            visual->setPos(adjustedWidgetPosition(adjustWidgetPosition));
+            visual->setZValue(presentation.zValue);
             widget->savePresentation(); //Needed to follow pageMargin dynamic change
         }
     }
+    
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    // sort new widgets in order
+    if (newWidgets.count()) {
+        // TODO: read from configuration? or just use height for portrait and width for landscape (currently only height is used)
+        sortOrder order(height);
+        if(orientation == Qt::Horizontal) {
+            order = width;
+        } 
+        sortWidgets(order, newWidgets);
+        // get rects for new widgets
+        QList<QRectF> newRects;
+        foreach (HsWidgetHost *newWidget, newWidgets) {
+            newRects << QRectF(QPointF(), newWidget->visual()->preferredSize());
+        }
+        
+        // get page rect
+        QRectF pageRect = contentGeometry();
+
+        // scan existing widgets rects
+        QList<QRectF> existingRects;
+        foreach (HsWidgetHost *widget, mWidgets) {
+            if (!newWidgets.contains(widget)) {
+                existingRects << QRectF(widget->visual()->pos(), widget->visual()->preferredSize());
+            }
+        }
+         
+        // calculate new widget positions with "stuck 'em all"-algorithm
+        HsWidgetPositioningOnWidgetAdd *algorithm =
+            HsWidgetPositioningOnWidgetAdd::instance();
+        QList<QRectF> calculatedRects =
+            algorithm->convert(pageRect, existingRects, newRects, QPointF());
+
+        for ( int i=0; i<newWidgets.count(); i++) {            
+            int j = mWidgets.indexOf(newWidgets.at(i));
+            mWidgets.at(j)->visual()->setGeometry(calculatedRects.at(i));
+            mWidgets.at(j)->savePresentation();            
+        }               
+    }    
+#endif //HSWIDGETORGANIZER_ALGORITHM
+    
 }
 
 void HsPage::onPageMarginChanged(const QString &value)
 {
     if (value == "pageMargin") {
         mPageMargin = HSCONFIGURATION_GET(pageMargin);
-
+        HsWidgetHostVisual *visual(0);
         if (!mWidgets.isEmpty()) {
             foreach (HsWidgetHost *widget, mWidgets) {
-                widget->setPos(adjustedWidgetPosition(widget->geometry()));
+                visual = widget->visual();
+                visual->setPos(adjustedWidgetPosition(visual->geometry()));
                 widget->savePresentation();
             }
         }
 
         if (!mNewWidgets.isEmpty()) {
             foreach (HsWidgetHost *widget, mNewWidgets) {
-                widget->setPos(adjustedWidgetPosition(widget->geometry()));
+                visual = widget->visual();
+                visual->setPos(adjustedWidgetPosition(visual->geometry()));
                 widget->savePresentation();
             }
         }
     }
 }
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+// TODO: sorting should be done in algorithm class, make widget<->rect mapping here and move sortWidgets function to algorithm side
+/*!
+    Sorts widgets in height/width order
+*/
+void HsPage::sortWidgets(sortOrder order, QList<HsWidgetHost*> &widgets)
+{
+    QList<HsWidgetHost*> tmpWidgets;
+
+    for ( int i = 0; i < widgets.count(); i++) {
+        int index = 0;
+        // add first widget to sorted list
+        if (i == 0) {
+            tmpWidgets << widgets.at(i);
+        } else {
+            // go through existing widgets in the sorted list
+            for ( int j = 0; j < tmpWidgets.count(); j++) {
+                // sort widgets in height order
+                if (order == height) {
+                    /* if widgets heigth is smaller on already
+                       existing ones in the list -> increment index
+                    */
+                    if (widgets.at(i)->visual()->preferredHeight() <= tmpWidgets.at(j)->visual()->preferredHeight()) {
+                        index++;
+                    }
+                // sort widgets in width order
+                } else {
+                    /* if widgets width is smaller on already
+                       existing ones in the sorted list -> increment index
+                    */
+                    if (widgets.at(i)->visual()->preferredWidth() <= tmpWidgets.at(j)->visual()->preferredWidth()) {
+                        index++;
+                    }
+                }
+            }
+            // add widget to its correct index in sorted list
+            tmpWidgets.insert(index, widgets.at(i));
+        }
+    }
+    widgets = tmpWidgets;    
+}
+#endif //HSWIDGETORGANIZER_ALGORITHM
--- a/homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,18 +15,18 @@
 *
 */
 
-#include <HbInstance>
-
 #include "hsdomainmodeldatastructures.h"
 #include "hspagenewwidgetlayout.h"
 #include "hsscene.h"
 #include "hspage.h"
 #include "hsdatabase.h"
 #include "hswidgethost.h"
+#include "hswidgethostvisual.h"
 #include "hswallpaper.h"
 #include "hswidgetpositioningonwidgetadd.h"
 #include "hswidgetpositioningonorientationchange.h"
 #include "hsconfiguration.h"
+#include "hsgui.h"
 
 
 /*!
@@ -46,7 +46,7 @@
     : QGraphicsLayout(parent),    
     mTouchPoint(touchPoint)
 {
-    mSize = HsScene::mainWindow()->layoutRect().size();
+    mSize = HsGui::instance()->layoutRect().size();
 }
 
 /*!
@@ -69,7 +69,7 @@
 */
 QGraphicsLayoutItem *HsPageNewWidgetLayout::itemAt(int i) const
 {
-    return mNewWidgets.at(i);
+    return mNewWidgets.at(i)->visual();
 }
 
 /*!
@@ -103,10 +103,20 @@
 void HsPageNewWidgetLayout::setGeometry(const QRectF &rect)
 {
     QGraphicsLayout::setGeometry(rect);
-   
-    QList<QRectF> rects;
+
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+    // sort new widgets in order
+    if (mNewWidgets.count() > 1) {
+        // TODO: read from configuration? or just use height for portrait and width for landscape (currently only height is used)
+        sortOrder order(height);
+        mNewWidgets = sortWidgets(order);
+    }
+#endif
+
+    // get rects for new widgets
+    QList<QRectF> newRects;
     foreach (HsWidgetHost *newWidget, mNewWidgets) {
-        rects << QRectF(QPointF(), newWidget->preferredSize());
+        newRects << QRectF(QPointF(), newWidget->visual()->preferredSize());
     }
 
     /* if there is touch point defined (widget added from context menu)
@@ -114,25 +124,38 @@
        -> set widget center point to this touch point
     */
     if (mTouchPoint != QPointF() && mNewWidgets.count() == 1) {
-        QRectF widgetRect = rects.at(0);
+        QRectF widgetRect = newRects.at(0);
         widgetRect.moveCenter(mTouchPoint);
         widgetRect.moveTopLeft(HsScene::instance()->activePage()->adjustedWidgetPosition(widgetRect));
-        mNewWidgets.at(0)->setGeometry(widgetRect);
+        mNewWidgets.at(0)->visual()->setGeometry(widgetRect);
         /* we have to save widget presentation data here after drawing
            to get correct position for later use
         */
         mNewWidgets.at(0)->savePresentation();
     }
-    // otherwise calculate position with algorithm
+    // otherwise calculate widget positions with algorithm
     else {
+        // get page rect
+        QRectF pageRect = HsScene::instance()->activePage()->contentGeometry();
+
+        // scan existing widgets rects
+        QList<HsWidgetHost*> existingWidgets;
+        existingWidgets = HsScene::instance()->activePage()->widgets();
+        QList<QRectF> existingRects;
+        foreach (HsWidgetHost *widget, existingWidgets) {
+            if (!mNewWidgets.contains(widget)) {
+                existingRects << QRectF(widget->visual()->pos(), widget->visual()->preferredSize());
+            }
+        }
+         
+        // calculate new widget positions with "stuck 'em all"-algorithm
         HsWidgetPositioningOnWidgetAdd *algorithm =
             HsWidgetPositioningOnWidgetAdd::instance();
-        QRectF pageRect = HsScene::instance()->activePage()->contentGeometry();
         QList<QRectF> calculatedRects =
-            algorithm->convert(pageRect, rects, QPointF());
+            algorithm->convert(pageRect, existingRects, newRects, QPointF());
 
         for ( int i=0; i<mNewWidgets.count(); i++) {
-            mNewWidgets.at(i)->setGeometry(calculatedRects.at(i));
+            mNewWidgets.at(i)->visual()->setGeometry(calculatedRects.at(i));
             mNewWidgets.at(i)->savePresentation();
         }
     }
@@ -145,3 +168,46 @@
 {
     mNewWidgets.append(item);
 }
+
+#ifdef HSWIDGETORGANIZER_ALGORITHM
+// TODO: sorting should be done in algorithm class, make widget<->rect mapping here and move sortWidgets function to algorithm side
+/*!
+    Sorts widgets in height/width order
+*/
+QList<HsWidgetHost*> HsPageNewWidgetLayout::sortWidgets(sortOrder order)
+{
+    QList<HsWidgetHost*> tmpWidgets;
+
+    for ( int i = 0; i < mNewWidgets.count(); i++) {
+        int index = 0;
+        // add first widget to sorted list
+        if (i == 0) {
+            tmpWidgets << mNewWidgets.at(i);
+        } else {
+            // go through existing widgets in the sorted list
+            for ( int j = 0; j < tmpWidgets.count(); j++) {
+                // sort widgets in height order
+                if (order == height) {
+                    /* if widgets heigth is smaller on already
+                       existing ones in the list -> increment index
+                    */
+                    if (mNewWidgets.at(i)->visual()->preferredHeight() <= tmpWidgets.at(j)->visual()->preferredHeight()) {
+                        index++;
+                    }
+                // sort widgets in width order
+                } else {
+                    /* if widgets width is smaller on already
+                       existing ones in the sorted list -> increment index
+                    */
+                    if (mNewWidgets.at(i)->visual()->preferredWidth() <= tmpWidgets.at(j)->visual()->preferredWidth()) {
+                        index++;
+                    }
+                }
+            }
+            // add widget to its correct index in sorted list
+            tmpWidgets.insert(index, mNewWidgets.at(i));
+        }
+    }
+    return tmpWidgets;
+}
+#endif // HSWIDGETORGANIZER_ALGORITHM
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/src/hspagevisual.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "hspagevisual.h"
+#include "hspagetoucharea.h"
+
+
+
+/*!
+    \class HsPageVisual
+    \ingroup group_hsdomainmodel
+    \brief Represents a page in the framework.
+    HsPageVisual contains group of widgets. HsPageVisual can have a wallpaper.
+*/
+
+/*!
+    Constructor.
+
+    \a parent Owner.
+    \a aFlags Window flags.
+*/
+HsPageVisual::HsPageVisual(QGraphicsItem* parent)
+    : HbWidget(parent),
+      mTouchArea(0)
+{
+    setFlag(QGraphicsItem::ItemHasNoContents);
+    setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
+                              QSizePolicy::Ignored));
+
+    setupTouchArea();
+}
+
+/*!
+    Destructor.
+*/
+HsPageVisual::~HsPageVisual()
+{
+}
+
+void HsPageVisual::setGeometry(const QRectF &rect)
+{
+    if (mTouchArea) {
+        mTouchArea->resize(rect.size());
+    }
+
+    HbWidget::setGeometry(rect);
+}
+
+/*!
+    Create touch area for page.
+*/
+void HsPageVisual::setupTouchArea()
+{
+    mTouchArea = new HsPageTouchArea(this);
+    mTouchArea->setZValue(-1);
+}
+
+
+
--- a/homescreenapp/hsdomainmodel/src/hsscene.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hsscene.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -321,18 +321,18 @@
 /*!
     Return main window.
 */
-HbMainWindow *HsScene::mainWindow()
+/*HbMainWindow *HsGui::instance()
 {
     return hbInstance->allMainWindows().first();
 }
-
+*/
 /*!
     Return current orientation.
 */
-Qt::Orientation HsScene::orientation()
+/*Qt::Orientation HsGui::instance()->orientation()
 {
     return mainWindow()->orientation();
-}
+}*/
 
 /*!
     Listens for application background/foreground changes.
--- a/homescreenapp/hsdomainmodel/src/hswallpaper.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hswallpaper.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -28,6 +28,8 @@
 #include "hspage.h"
 #include "hswallpaperloader.h"
 #include "hsconfiguration.h"
+#include "hsgui.h"
+
 
 /*!
     \class HsWallpaper
@@ -58,7 +60,7 @@
     layout->addItem(mIconItem);
     setLayout(layout);
 
-    connect(HsScene::mainWindow(),
+    connect(HsGui::instance(),
         SIGNAL(orientationChanged(Qt::Orientation)),
         SLOT(updateIconItem(Qt::Orientation)));
 }
@@ -110,7 +112,7 @@
     mLandscapeImagePath = infos.first().absoluteFilePath();
     mPortraitImagePath = infos.last().absoluteFilePath();
 
-    updateIconItem(HsScene::orientation());
+    updateIconItem(HsGui::instance()->orientation());
 }
 
 /*!
@@ -150,7 +152,7 @@
     mLandscapeImagePath = infos.first().absoluteFilePath();
     mPortraitImagePath = infos.last().absoluteFilePath();
 
-    updateIconItem(HsScene::orientation());
+    updateIconItem(HsGui::instance()->orientation());
     return true;
 }
 
--- a/homescreenapp/hsdomainmodel/src/hswidgetcomponentregistry.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hswidgetcomponentregistry.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -25,13 +25,12 @@
 #include "caentry.h" 
 #include "cadefs.h"
 #include "canotifier.h"
-#include "hsscene.h"
 
 #include <QSignalMapper>
 #include <QDir>
 #include <QCoreApplication>
 
-#include <HbMainWindow>
+//#include <HbMainWindow>
 
 /*!
     \class HsWidgetComponentRegistry
@@ -58,7 +57,7 @@
 {
     if (!mInstance) {
         mInstance = new HsWidgetComponentRegistry;
-        mInstance->setParent(HsScene::mainWindow());
+        mInstance->setParent(QCoreApplication::instance());
     }
     return mInstance;
 }
--- a/homescreenapp/hsdomainmodel/src/hswidgethost.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hswidgethost.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -19,31 +19,20 @@
 #include <QStateMachine>
 #include <QState>
 #include <QFinalState>
-#include <QGraphicsLinearLayout>
-#include <QParallelAnimationGroup>
-#include <QPropertyAnimation>
-#include <QGraphicsDropShadowEffect>
-#include <QGraphicsSceneResizeEvent>
-#include <QGesture>
-#include <QGraphicsScene>
-
-#include <qservicemanager.h>
-#include <qservicefilter.h>
-#include <qserviceinterfacedescriptor.h>
-
-#include <HbInstantFeedback>
-#include <HbTouchArea>
 
 #include "hsdatabase.h"
 #include "hsdomainmodeldatastructures.h"
 #include "hsscene.h"
 #include "hspage.h"
 #include "hswidgethost.h"
-#include "hswidgettoucharea.h"
+#include "hswidgethostvisual.h"
+#include "hshostedwidgetfactory.h"
+
 #include "hswidgetcomponentregistry.h"
 #include "hswidgetcomponent.h"
 #include "hsconfiguration.h"
 #include "hscontentservice.h"
+#include "hsgui.h"
 
 // Helper macros for connecting state entry and exit actions.
 #define ENTRY_ACTION(state, action) \
@@ -51,7 +40,7 @@
 #define EXIT_ACTION(state, action) \
     connect(state, SIGNAL(exited()), SLOT(action()));
 
-QTM_USE_NAMESPACE
+
 
 
 /*!
@@ -64,8 +53,9 @@
     Constructs a new widget host with given \a databaseId and
     \a parent item.
 */
-HsWidgetHost::HsWidgetHost(int databaseId, QGraphicsItem *parent)
-  : HbWidget(parent),
+HsWidgetHost::HsWidgetHost(int databaseId, QObject *parent)
+  : QObject(parent),
+    mVisual(new HsWidgetHostVisual),
     mDatabaseId(databaseId),
     mStateMachine(0),
     mWidget(0),
@@ -73,19 +63,8 @@
     mComponent(0),
     mIsFinishing(false)
 {
-    setFlag(QGraphicsItem::ItemClipsChildrenToShape);
-    setFlag(QGraphicsItem::ItemHasNoContents);
-
-    grabGesture(Qt::TapGesture);
-    grabGesture(Qt::TapAndHoldGesture);
-    grabGesture(Qt::PanGesture);
-    grabGesture(Qt::PinchGesture);
-    grabGesture(Qt::SwipeGesture);
-    grabGesture(Qt::CustomGesture);
-    
-    setupTouchArea();
-    setupEffects();
     setupStates();
+    mVisual->setVisualModel(this);
 }
 
 /*!
@@ -93,6 +72,7 @@
 */
 HsWidgetHost::~HsWidgetHost()
 {
+    delete mVisual;
 }
 
 /*!
@@ -145,6 +125,7 @@
     }
 
     mPage = page;
+    
     return true;
 }
  
@@ -163,7 +144,7 @@
 */
 bool HsWidgetHost::loadPresentation()
 {
-    return loadPresentation(HsScene::orientation());
+    return loadPresentation(HsGui::instance()->orientation());
 }
 
 /*!
@@ -180,8 +161,8 @@
     if (!db->widgetPresentation(data)) {
         return false;
     }
-    setPos(data.x, data.y);
-    setZValue(data.zValue);
+    mVisual->setPos(data.x, data.y);
+    mVisual->setZValue(data.zValue);
     return true;
 }
 
@@ -191,7 +172,7 @@
 */
 bool HsWidgetHost::savePresentation()
 {
-    return savePresentation(HsScene::orientation());
+    return savePresentation(HsGui::instance()->orientation());
 }
 
 /*!
@@ -204,8 +185,8 @@
         
     HsWidgetPresentationData data;
     data.orientation = orientation;
-    data.setPos(pos());
-    data.zValue = zValue();
+    data.setPos(mVisual->pos());
+    data.zValue = mVisual->zValue();
     data.widgetId = mDatabaseId;
     return db->setWidgetPresentation(data);
 }
@@ -245,29 +226,9 @@
     return db->deleteWidgetPresentation(mDatabaseId, orientation);
 }
 
-/*!
-    Reimplemented from QGraphicsItem. Returns the shape of the
-    this widget host. The shape is computed based on the contained
-    widget.
-*/
-QPainterPath HsWidgetHost::shape() const
+HsWidgetHostVisual *HsWidgetHost::visual() const
 {
-    QPainterPath path;
-
-    if (mWidget) {
-        QRectF currRect = rect();
-        path = mWidget->shape();
-
-        QRectF pathRect(path.boundingRect());
-
-        if (pathRect.width() > currRect.width()
-            || pathRect.height() > currRect.height()) {
-            QPainterPath newPath(currRect.topLeft());
-            newPath.addRect(currRect);
-            path = path.intersected(newPath);
-        }
-    }
-    return path;
+    return mVisual;
 }
 
 /*!
@@ -327,11 +288,7 @@
     host has moved to faulted state.
 */
 
-/*!
-    \fn HsWidgetHost::resized()
-    Notifies the home screen framework that this widget
-    host has resized itself.
-*/
+
 
 /*!
     \fn HsWidgetHost::available()
@@ -424,29 +381,7 @@
 */
 void HsWidgetHost::startDragEffect()
 {
-    /* TODO: Uncomment after the Qt bug has been fixed.
-    QGraphicsDropShadowEffect *effect =
-        static_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
-    */
-    HbInstantFeedback::play(HbFeedback::ItemPick);
-
-    setTransformOriginPoint(rect().center());
-
-    QParallelAnimationGroup *animationGroup = new QParallelAnimationGroup();
-
-    QPropertyAnimation *animation = new QPropertyAnimation(this, "scale");
-    animation->setDuration(HSCONFIGURATION_GET(widgetDragEffectDuration));
-    animation->setEndValue(1.1);
-    animationGroup->addAnimation(animation);
-
-    /* TODO: Uncomment after the Qt bug has been fixed.
-    animation = new QPropertyAnimation(effect, "offset");
-    animation->setDuration(200);
-    animation->setEndValue(QPointF(8 ,8));
-    animationGroup->addAnimation(animation);
-    */
-
-    animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
+   mVisual->startDragEffect();
 }
 
 /*!
@@ -454,98 +389,7 @@
 */
 void HsWidgetHost::startDropEffect()
 {
-    /* TODO: Uncomment after the Qt bug has been fixed.
-    QGraphicsDropShadowEffect *effect =
-        static_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
-    */
-    HbInstantFeedback::play(HbFeedback::ItemDrop);
-
-    QParallelAnimationGroup *animationGroup = new QParallelAnimationGroup;
-
-    QPropertyAnimation *animation = new QPropertyAnimation(this, "scale");
-    animation->setDuration(HSCONFIGURATION_GET(widgetDropEffectDuration));
-    animation->setEndValue(1);
-    animationGroup->addAnimation(animation);
-
-    /* TODO: Uncomment after the Qt bug has been fixed.
-    animation = new QPropertyAnimation(effect, "offset");
-    animation->setDuration(200);
-    animation->setEndValue(QPointF(3, 3));
-    animationGroup->addAnimation(animation);
-    */
-
-    animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
-}
-
-/*!
-    Reimplemented from QObject for monitoring changes in 
-    contained widget's size.
-*/
-bool HsWidgetHost::eventFilter(QObject *watched, QEvent *event)
-{
-    if (event->type() == QEvent::GraphicsSceneResize ) {
-        QGraphicsSceneResizeEvent *resizeEvent = 
-            static_cast<QGraphicsSceneResizeEvent *>(event);
-        setNewSize(resizeEvent->newSize());
-        emit resized();
-    }
-    return HbWidget::eventFilter(watched, event);
-}
-
-/*!
-    Reimplemented from HbWidget for pan gesture handling.
-*/
-void HsWidgetHost::gestureEvent(QGestureEvent *event)
-{
-    HsScene *scene = HsScene::instance();    
-    QGesture *gesture = event->gesture(Qt::PanGesture);
-    if (gesture) {
-        switch (gesture->state()) {
-            case Qt::GestureStarted:
-                grabMouse();
-                emit scene->pagePanStarted(event);
-                break;
-            case Qt::GestureUpdated:
-                emit scene->pagePanUpdated(event);
-                break;
-            case Qt::GestureFinished:
-            case Qt::GestureCanceled:
-                ungrabMouse();
-                emit scene->pagePanFinished(event);
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-/*!
-    \fn HsWidgetHost::mousePressEvent(QGraphicsSceneMouseEvent *)
-    Reimplemented from QGraphicsItem for eating all mouse presses.
-*/
-
-/*!
-    Configures the touch are for this widget host.
-*/
-void HsWidgetHost::setupTouchArea()
-{
-    mTouchArea = new HsWidgetTouchArea(this);
-    mTouchArea->setZValue(1);
-}
-
-/*!
-    Configures the effects for this widget host.
-*/
-void HsWidgetHost::setupEffects()
-{
-    /* TODO: Uncomment after the Qt bug has been fixed.
-    QGraphicsDropShadowEffect *effect =
-        new QGraphicsDropShadowEffect(this);
-    effect->setColor(QColor(0, 0, 0, 150));
-    effect->setBlurRadius(5);
-    effect->setOffset(3);
-    setGraphicsEffect(effect);
-    */
+    mVisual->startDropEffect();
 }
 
 /*!
@@ -681,15 +525,6 @@
     return index >= 0;
 }
 
-/*!
-    Resizes this widget host to the given \a size.
-*/
-void HsWidgetHost::setNewSize(const QSizeF &size)
-{
-    mTouchArea->resize(size);
-    resize(size);
-    setPreferredSize(size);
-}
 
 /*!
     Assigns preferences for the contained widget.
@@ -752,26 +587,21 @@
 */
 void HsWidgetHost::action_load()
 {
-    QServiceManager manager;
-    QServiceFilter filter("com.nokia.symbian.IHomeScreenWidget");
-    filter.setServiceName(mComponent->uri());
-    QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
-    if (interfaces.isEmpty()) {
+    mWidget = HsHostedWidgetFactory::instance()->createWidget(mComponent->uri());
+    if (!mWidget) {
         emit event_faulted();
         return;
     }
-
-    QObject *widgetObject = manager.loadInterface(interfaces.first());
-    mWidget = qobject_cast<QGraphicsWidget *>(widgetObject);
-
-    if (!mWidget ||
-        !setMethod("onShow()", mOnShowMethod) ||
+    // must have fuctions
+    if (!setMethod("onShow()", mOnShowMethod) || 
         !setMethod("onHide()", mOnHideMethod)) {
+        delete mWidget;
         mWidget = 0;
-        delete widgetObject;
         emit event_faulted();
         return;
     }
+    
+    mVisual->setWidget(mWidget);
 
     setMethod("onInitialize()", mOnInitializeMethod);
     setMethod("onUninitialize()", mOnUninitializeMethod);
@@ -792,21 +622,12 @@
             SLOT(onError()), Qt::QueuedConnection);
     }
 
-    mWidget->installEventFilter(this);
-
-    setMinimumSize(HSCONFIGURATION_GET(minimumWidgetSizeInPixels));
-    setMaximumSize(HSCONFIGURATION_GET(maximumWidgetSizeInPixels));
-    
     loadPresentation();
-
-    mWidget->setParentItem(this);
-
-    setNewSize(mWidget->size());
-
+   
     QString objName(mComponent->uri());
     objName.append(":");
     objName.append(QString::number(mDatabaseId));
-    setObjectName(objName);
+    mVisual->setObjectName(objName);
 }
 
 /*!
@@ -814,6 +635,7 @@
 */
 void HsWidgetHost::action_unload()
 {
+    mVisual->setWidget(0);
     delete mWidget;
     mWidget = 0;
 		// This is needed because QServicePluginCleanup is 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/hsdomainmodel/src/hswidgethostvisual.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,263 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <QGraphicsLinearLayout>
+#include <QParallelAnimationGroup>
+#include <QPropertyAnimation>
+#include <QGraphicsDropShadowEffect>
+#include <QGraphicsSceneResizeEvent>
+#include <QGesture>
+#include <QGraphicsScene>
+
+
+#include <HbInstantFeedback>
+#include <HbTouchArea>
+
+#include "hswidgethostvisual.h"
+#include "hswidgethost.h"
+#include "hsscene.h"
+#include "hsconfiguration.h"
+#include "hswidgettoucharea.h"
+
+
+/*!
+    \class HsWidgetHostVisual
+    \ingroup group_hsdomainmodel
+    \brief Each widget is controlled by the home screen framework through a widget host.
+*/
+
+/*!
+    Constructs a new widget host with given \a databaseId and
+    \a parent item.
+*/
+HsWidgetHostVisual::HsWidgetHostVisual(QGraphicsItem *parent)
+  : HbWidget(parent),mWidget(0)
+  
+{
+    setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+    setFlag(QGraphicsItem::ItemHasNoContents);
+
+    grabGesture(Qt::TapGesture);
+    grabGesture(Qt::TapAndHoldGesture);
+    grabGesture(Qt::PanGesture);
+    grabGesture(Qt::PinchGesture);
+    grabGesture(Qt::SwipeGesture);
+    grabGesture(Qt::CustomGesture);
+    
+    setupTouchArea();
+    setupEffects();
+    
+    setMinimumSize(HSCONFIGURATION_GET(minimumWidgetSizeInPixels));
+    setMaximumSize(HSCONFIGURATION_GET(maximumWidgetSizeInPixels));
+    
+}
+
+/*!
+    Destructor.
+*/
+HsWidgetHostVisual::~HsWidgetHostVisual()
+{
+}
+
+
+/*!
+    Reimplemented from QGraphicsItem. Returns the shape of the
+    this widget host. The shape is computed based on the contained
+    widget.
+*/
+QPainterPath HsWidgetHostVisual::shape() const
+{
+    QPainterPath path;
+
+    if (mWidget) {
+        QRectF currRect = rect();
+        path = mWidget->shape();
+
+        QRectF pathRect(path.boundingRect());
+
+        if (pathRect.width() > currRect.width()
+            || pathRect.height() > currRect.height()) {
+            QPainterPath newPath(currRect.topLeft());
+            newPath.addRect(currRect);
+            path = path.intersected(newPath);
+        }
+    }
+    return path;
+}
+void HsWidgetHostVisual::setWidget(QObject *widget)
+{
+    mWidget = qobject_cast<QGraphicsWidget *>(widget);
+    if (mWidget) {
+        mWidget->installEventFilter(this);
+        mWidget->setParentItem(this);
+        setNewSize(mWidget->size());
+    }
+}
+
+void HsWidgetHostVisual::setVisualModel(HsWidgetHost *model)
+{
+    mVisualModel = model;
+}
+HsWidgetHost *HsWidgetHostVisual::visualModel() const
+{
+    return mVisualModel;
+}
+/*!
+    Starts the drag effect.
+*/
+void HsWidgetHostVisual::startDragEffect()
+{
+    /* TODO: Uncomment after the Qt bug has been fixed.
+    QGraphicsDropShadowEffect *effect =
+        static_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
+    */
+    HbInstantFeedback::play(HbFeedback::ItemPick);
+
+    setTransformOriginPoint(rect().center());
+
+    QParallelAnimationGroup *animationGroup = new QParallelAnimationGroup();
+
+    QPropertyAnimation *animation = new QPropertyAnimation(this, "scale");
+    animation->setDuration(HSCONFIGURATION_GET(widgetDragEffectDuration));
+    animation->setEndValue(1.1);
+    animationGroup->addAnimation(animation);
+
+    /* TODO: Uncomment after the Qt bug has been fixed.
+    animation = new QPropertyAnimation(effect, "offset");
+    animation->setDuration(200);
+    animation->setEndValue(QPointF(8 ,8));
+    animationGroup->addAnimation(animation);
+    */
+
+    animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
+}
+
+/*!
+    Starts the drop effect.
+*/
+void HsWidgetHostVisual::startDropEffect()
+{
+    /* TODO: Uncomment after the Qt bug has been fixed.
+    QGraphicsDropShadowEffect *effect =
+        static_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
+    */
+    HbInstantFeedback::play(HbFeedback::ItemDrop);
+
+    QParallelAnimationGroup *animationGroup = new QParallelAnimationGroup;
+
+    QPropertyAnimation *animation = new QPropertyAnimation(this, "scale");
+    animation->setDuration(HSCONFIGURATION_GET(widgetDropEffectDuration));
+    animation->setEndValue(1);
+    animationGroup->addAnimation(animation);
+
+    /* TODO: Uncomment after the Qt bug has been fixed.
+    animation = new QPropertyAnimation(effect, "offset");
+    animation->setDuration(200);
+    animation->setEndValue(QPointF(3, 3));
+    animationGroup->addAnimation(animation);
+    */
+
+    animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
+}
+/*!
+    \fn HsWidgetHost::resized()
+    Notifies the home screen framework that this widget
+    host has resized itself.
+*/
+
+/*!
+    Reimplemented from QObject for monitoring changes in 
+    contained widget's size.
+*/
+bool HsWidgetHostVisual::eventFilter(QObject *watched, QEvent *event)
+{
+    if (event->type() == QEvent::GraphicsSceneResize ) {
+        QGraphicsSceneResizeEvent *resizeEvent = 
+            static_cast<QGraphicsSceneResizeEvent *>(event);
+        setNewSize(resizeEvent->newSize());
+        emit resized();
+    }
+    return HbWidget::eventFilter(watched, event);
+}
+
+/*!
+    Reimplemented from HbWidget for pan gesture handling.
+*/
+void HsWidgetHostVisual::gestureEvent(QGestureEvent *event)
+{
+    HsScene *scene = HsScene::instance();    
+    QGesture *gesture = event->gesture(Qt::PanGesture);
+    if (gesture) {
+        switch (gesture->state()) {
+            case Qt::GestureStarted:
+                grabMouse();
+                emit scene->pagePanStarted(event);
+                break;
+            case Qt::GestureUpdated:
+                emit scene->pagePanUpdated(event);
+                break;
+            case Qt::GestureFinished:
+            case Qt::GestureCanceled:
+                ungrabMouse();
+                emit scene->pagePanFinished(event);
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+/*!
+    \fn HsWidgetHostVisual::mousePressEvent(QGraphicsSceneMouseEvent *)
+    Reimplemented from QGraphicsItem for eating all mouse presses.
+*/
+
+/*!
+    Configures the touch are for this widget host.
+*/
+void HsWidgetHostVisual::setupTouchArea()
+{
+    mTouchArea = new HsWidgetTouchArea(this);
+    mTouchArea->setZValue(1);
+}
+
+/*!
+    Configures the effects for this widget host.
+*/
+void HsWidgetHostVisual::setupEffects()
+{
+    /* TODO: Uncomment after the Qt bug has been fixed.
+    QGraphicsDropShadowEffect *effect =
+        new QGraphicsDropShadowEffect(this);
+    effect->setColor(QColor(0, 0, 0, 150));
+    effect->setBlurRadius(5);
+    effect->setOffset(3);
+    setGraphicsEffect(effect);
+    */
+}
+
+
+/*!
+    Resizes this widget host to the given \a size.
+*/
+void HsWidgetHostVisual::setNewSize(const QSizeF &size)
+{
+    mTouchArea->resize(size);
+    resize(size);
+    setPreferredSize(size);
+}
+
--- a/homescreenapp/hsdomainmodel/src/hswidgettoucharea.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hswidgettoucharea.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -24,12 +24,12 @@
 #include <HbPanGesture>
 
 #include "hswidgettoucharea.h"
-#include "hswidgethost.h"
+#include "hswidgethostvisual.h"
 #include "hsscene.h"
 
-HsWidgetTouchArea::HsWidgetTouchArea(HsWidgetHost *widgetHost)
-  : HbTouchArea(widgetHost),
-    mWidgetHost(widgetHost)
+HsWidgetTouchArea::HsWidgetTouchArea(HsWidgetHostVisual *visual)
+  : HbTouchArea(visual),
+    mWidgetHostVisual(visual)
 {
     grabGesture(Qt::TapAndHoldGesture);
 }
@@ -44,14 +44,14 @@
     switch (event->type()) {
         case QEvent::TouchBegin:
         case QEvent::GraphicsSceneMousePress:
-            emit scene->widgetTapStarted(mWidgetHost);
+            emit scene->widgetTapStarted(mWidgetHostVisual->visualModel());
             break;        
         case QEvent::TouchEnd:
             {
                 ungrabGesture(Qt::PanGesture);
                 ungrabMouse();
                 QPointF scenePos = static_cast<QTouchEvent *>(event)->touchPoints().first().scenePos();
-                emit scene->widgetMoveFinished(scenePos, mWidgetHost);
+                emit scene->widgetMoveFinished(scenePos, mWidgetHostVisual->visualModel());
             }
             break;
         case QEvent::GraphicsSceneMouseRelease:
@@ -59,7 +59,7 @@
                 ungrabGesture(Qt::PanGesture);
                 ungrabMouse();
                 QPointF scenePos = static_cast<QGraphicsSceneMouseEvent *>(event)->scenePos();
-                emit scene->widgetMoveFinished(scenePos, mWidgetHost);
+                emit scene->widgetMoveFinished(scenePos, mWidgetHostVisual->visualModel());
             }
             break;    
         default:
@@ -71,7 +71,7 @@
 
 QPainterPath HsWidgetTouchArea::shape() const
 {       
-    return mWidgetHost->shape();
+    return mWidgetHostVisual->shape();
 }
 
 void HsWidgetTouchArea::gestureEvent(QGestureEvent *event)
@@ -84,7 +84,7 @@
         if (gesture->state() == Qt::GestureFinished) {
             grabGesture(Qt::PanGesture);
             grabMouse();
-            emit scene->widgetTapAndHoldFinished(event, mWidgetHost);
+            emit scene->widgetTapAndHoldFinished(event, mWidgetHostVisual->visualModel());
         }
         return;
     }
@@ -96,12 +96,12 @@
         switch (gesture->state()) {
             case Qt::GestureStarted:
             case Qt::GestureUpdated:
-                emit scene->widgetMoveUpdated(scenePos, mWidgetHost);
+                emit scene->widgetMoveUpdated(scenePos, mWidgetHostVisual->visualModel());
                 break;
             case Qt::GestureCanceled:
             case Qt::GestureFinished:
                 ungrabGesture(Qt::PanGesture);
-                emit scene->widgetMoveFinished(scenePos, mWidgetHost);
+                emit scene->widgetMoveFinished(scenePos, mWidgetHostVisual->visualModel());
                 break;
             default:
                 break;
--- a/homescreenapp/hsutils/inc/hsmessageboxwrapper.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/inc/hsmessageboxwrapper.h	Fri Jul 23 13:47:57 2010 +0300
@@ -26,6 +26,7 @@
 HOMESCREEN_TEST_CLASS(t_hsUtils)
 
 class HbAction;
+class HbMessageBox;
 struct HsMessageBoxWrapperImpl;
 
 class HSUTILS_EXPORT HsMessageBoxWrapper : public QObject
@@ -38,6 +39,7 @@
 
     void setHeader(const QString &header);
     void setQueryText(const QString &queryText);
+    void close();
 
 signals:
     void accepted();
@@ -53,6 +55,7 @@
  
 private:
     HsMessageBoxWrapperImpl *mImpl;
+    HbMessageBox *mBox;
 
     HOMESCREEN_TEST_FRIEND_CLASS(t_hsUtils)
 };
--- a/homescreenapp/hsutils/inc/hspropertyanimationwrapper.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/inc/hspropertyanimationwrapper.h	Fri Jul 23 13:47:57 2010 +0300
@@ -19,9 +19,10 @@
 #define HSPROPERTYANIMATIONWRAPPER_H
 
 #include <QScopedPointer>
-#include "hsutils_global.h"
 
+#include "hsutils_global.h"
 #include "hstest_global.h"
+
 HOMESCREEN_TEST_CLASS(t_hsUtils)
 
 struct HsPropertyAnimationWrapperImpl;
@@ -38,6 +39,10 @@
     bool isRunning();
     void setEndValue(const QVariant &value);
     void setDuration(int msecs);
+    void setForward();
+    void setBackward();
+    bool isForward() const;
+
 signals:
     void finished();
 
--- a/homescreenapp/hsutils/inc/hsutils_global.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/inc/hsutils_global.h	Fri Jul 23 13:47:57 2010 +0300
@@ -19,7 +19,7 @@
 #ifndef HSUTILS_GLOBAL_H
 #define HSUTILS_GLOBAL_H
 
-#include <Qt/qglobal.h>
+#include <qglobal.h>
 
 
 #ifdef HSUTILS_LIB
--- a/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -20,15 +20,19 @@
 
 #include <QList>
 #include <QRectF>
+#include <QPointF>
 #include "hsutils_global.h"
 
+class HsWidgetHost;
+
 class HSUTILS_EXPORT HsWidgetPositioningOnWidgetAdd
 {
 public:
     virtual ~HsWidgetPositioningOnWidgetAdd() {}
     
     virtual QList<QRectF> convert(const QRectF &contentArea,
-                                  const QList<QRectF> &rects, 
+                                  const QList<QRectF> &existingRects,
+                                  const QList<QRectF> &newRects,
                                   const QPointF &startPoint) = 0;
    
     static void setInstance(HsWidgetPositioningOnWidgetAdd *instance);
@@ -42,7 +46,8 @@
 {
 public:
     QList<QRectF> convert(const QRectF &contentArea,
-                          const QList<QRectF> &rects,
+                          const QList<QRectF> &existingRects,
+                          const QList<QRectF> &newRects,
                           const QPointF &startPoint);
  
 };
@@ -51,9 +56,40 @@
 {
 public:
     QList<QRectF> convert(const QRectF &contentArea,
-                          const QList<QRectF> &rects,
+                          const QList<QRectF> &existingRects,
+                          const QList<QRectF> &newRects,
                           const QPointF &startPoint);
  };
 
+class HSUTILS_EXPORT HsWidgetOrganizer : public HsWidgetPositioningOnWidgetAdd
+{
+public:
+    QList<QRectF> convert(const QRectF &contentArea,
+                          const QList<QRectF> &existingRects,
+                          const QList<QRectF> &newRects,
+                          const QPointF &startPoint);
+
+private:
+    bool initAnchors(const QSizeF &areaSize);
+    bool getAnchorPoint(const QSizeF &contentSize);
+    bool searchWidthSpace(const QSizeF &contentSize);
+    bool searchHeightSpace(int contentHeight);
+    bool markReservedAnchors();
+    QPointF getAnchorCoordinates(int index);
+    int getIndexForCoordinate(QPointF position);
+    int lenghtInAnchorPoints(QVariant length);
+
+private:
+    int mAnchorColumns;
+    int mAnchorRows;
+    int mAnchorDistance;
+    QPointF mStartWidthAnchorPoint;
+    QPointF mEndWidthAnchorPoint;
+    QPointF mEndHeightAnchorPoint;
+    // TODO: is there better way to store anchor points, perhaps with pointers?
+    QList<bool> mAnchors;
+
+};
+
 
 #endif // HSWIDGETPOSITIONINGONWIDGETADD_H
--- a/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetmove.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/inc/hswidgetpositioningonwidgetmove.h	Fri Jul 23 13:47:57 2010 +0300
@@ -103,13 +103,20 @@
 private:
 
     void createSnappableRectangles(const QList<QRectF> &inactiveRects);
-    void checkForCenterSnapping();
     void checkInactiveRectLieAboveOrBelowOfMovingRect();
+    void checkInactiveRectVerticalEdgesInRange(qreal movingRectVerticalEdgePosition);
+    void checkInactiveRectBetterFitForHorizontalSnapping(qreal containerVerticalEdgeToInactiveRectVerticalEdge,
+                                                         qreal containerOtherVerticalEdgeToInactiveRectOtherVerticalEdge);
     void compareLeftSideOfMovingRectForSnapping();
     void compareRightSideOfMovingRectForSnapping();
     void checkInactiveRectLieLeftOrRightOfMovingRect();
+    void checkInactiveRectHorizontalEdgesInRange(qreal movingRectHorizontalEdgePosition);
+    void checkInactiveRectBetterFitForVerticalSnapping(qreal containerHorizontalEdgeToInactiveRectHorizontalEdge,
+                                                       qreal containerOtherHorizontalEdgeToInactiveRectOtherHorizontalEdge);
     void compareTopOfMovingRectForSnapping();
     void compareBottomOfMovingRectForSnapping();
+    void createVerticalLine();
+    void createHorizontalLine();
     void extendVerticalLine();
     void extendHorizontalLine();
     void checkInactiveRectPositionToVerticalLine();
@@ -128,6 +135,8 @@
     QRectF mInactiveRectToCompare;
     HsSnapRectangle mInactiveSnapRectToCompare;
     QRectF mMovingRect;
+
+    qreal mMinDistancePosition;
     qreal mHorizontalSnapPosition;
     qreal mVerticalSnapPosition;
 
@@ -140,6 +149,10 @@
     bool mRectLieAbove;
     bool mLeftInRange;
     bool mRightInRange;
+    bool mIsBetterFitHorizontalSnap;
+    qreal mDistanceVerticalEdges;
+    qreal mVerticalEdgeToLeftOfInactiveRect;
+    qreal mVerticalEdgeToRightOfInactiveRect;
     qreal mMinVerticalEdgesDistance;
     qreal mVerticalDistance;
     qreal mVerticalDistanceFromSelectedRect;
@@ -148,6 +161,10 @@
     bool mRectLieLeft;
     bool mTopInRange;
     bool mBottomInRange;
+    bool mIsBetterFitVerticalSnap;
+    qreal mDistanceHorizontalEdges;
+    qreal mHorizontalEdgeToTopOfInactiveRect;
+    qreal mHorizontalEdgeToBottomOfInactiveRect;
     qreal mMinHorizontalEdgesDistance;
     qreal mHorizontalDistance;
     qreal mHorizontalDistanceFromSelectedRect;
--- a/homescreenapp/hsutils/src/hsmessageboxwrapper.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/src/hsmessageboxwrapper.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -36,7 +36,9 @@
 
 */
 HsMessageBoxWrapper::HsMessageBoxWrapper(QObject *parent)
-  : QObject(parent),mImpl(new HsMessageBoxWrapperImpl)
+  : QObject(parent),
+    mImpl(new HsMessageBoxWrapperImpl),
+    mBox(0)
 {
 }
 
@@ -71,14 +73,23 @@
 
 void HsMessageBoxWrapper::show()
 {
-    HbMessageBox *box = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
-    box->setAttribute(Qt::WA_DeleteOnClose);
-    box->setHeadingWidget(new HbLabel(mImpl->mHeader));
-    box->setText(mImpl->mQueryText);
-    box->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
+    mBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+    mBox->setAttribute(Qt::WA_DeleteOnClose);
+    mBox->setHeadingWidget(new HbLabel(mImpl->mHeader));
+    mBox->setText(mImpl->mQueryText);
+    mBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
+
+    mBox->open(this,SLOT(onDialogClosed(int)));
+}
 
-    box->open(this,SLOT(onDialogClosed(int)));
+void HsMessageBoxWrapper::close()
+{
+    if (mBox) {
+        mBox->close();
+        mBox = NULL;
+    }
 }
+
 /*!
 
 */
--- a/homescreenapp/hsutils/src/hspropertyanimationwrapper.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/src/hspropertyanimationwrapper.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -67,14 +67,31 @@
 {
     return (mImpl->mPropertyAnimation->state() == QAbstractAnimation::Running);
 }
+
 void HsPropertyAnimationWrapper::setEndValue(const QVariant &value)
 {
     mImpl->mPropertyAnimation->setEndValue(value);
 }
+
 void HsPropertyAnimationWrapper::setDuration(int msecs)
 {
     mImpl->mPropertyAnimation->setDuration(msecs);
 }
+
+void HsPropertyAnimationWrapper::setForward()
+{
+    mImpl->mPropertyAnimation->setDirection(QAbstractAnimation::Forward);
+}
+
+void HsPropertyAnimationWrapper::setBackward()
+{
+    mImpl->mPropertyAnimation->setDirection(QAbstractAnimation::Backward);
+}
+
+bool HsPropertyAnimationWrapper::isForward() const
+{
+    return (mImpl->mPropertyAnimation->direction() == QAbstractAnimation::Forward);
+}
 /*!
 
 */
@@ -89,3 +106,4 @@
 {
     mImpl->mPropertyAnimation->stop();
 }
+
--- a/homescreenapp/hsutils/src/hssnapline.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/src/hssnapline.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -17,9 +17,10 @@
 
 #include <QGraphicsOpacityEffect>
 #include <QPropertyAnimation>
+#include <hbcolorscheme.h>
 
 #include "hsapp_defs.h"
-#include "HsSnapLine.h"
+#include "hssnapline.h"
 
 /*!
     Constructor.
@@ -44,11 +45,6 @@
 
     mFadeOutAnimation = new QPropertyAnimation(graphicsEffect(), "opacity", this);
     connect(mFadeOutAnimation, SIGNAL(finished()), SLOT(fadeOutAnimationFinished()));
-
-    QPen pen;
-    pen.setWidth(3);
-    pen.setColor(Qt::darkCyan); //TODO: Change the color to the Theme element
-    setPen(pen);
 }
  
 /*!
@@ -111,6 +107,23 @@
         displayLine.translate(-1.0, 0.0);
     }
 
+    QLinearGradient gradient(displayLine.p1(), displayLine.p2());
+    gradient.setColorAt(0.0, Qt::white);
+    QColor snapLineColor = HbColorScheme::color("qtc_hs_snapguide");
+    if (!snapLineColor.isValid()) {
+        //if valid color is not loaded from the theme, the darkCyan color is used as a backup.color
+        snapLineColor = Qt::darkCyan;
+    }
+    gradient.setColorAt(0.4, snapLineColor);
+    gradient.setColorAt(0.6, snapLineColor);
+    gradient.setColorAt(1.0, Qt::white);
+    QBrush brush(gradient);
+    QPen pen;
+    pen.setWidth(3);
+    pen.setCapStyle(Qt::RoundCap);
+    pen.setBrush(brush);
+    setPen(pen);
+
     setLine(displayLine);
     show();
 }
--- a/homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,10 +15,15 @@
 *
 */
 
+#include <QLineF>
 #include <QtGlobal>
+#include <QPointF>
+#include <math.h>
+
+#include <HbInstance>
+
+
 #include "hswidgetpositioningonwidgetadd.h"
-#include <math.h>
-#include <QLineF>
 
 const qreal offset = 40; //TODO: Implement this as configurable parameter
 
@@ -71,9 +76,12 @@
 */
 QList<QRectF> HsAnchorPointInBottomRight::convert(
     const QRectF &contentArea,
-    const QList<QRectF> &rects,
+    const QList<QRectF> &existingRects,
+    const QList<QRectF> &newRects,
     const QPointF &startPoint)
 {
+    Q_UNUSED(existingRects);
+
     QList<QRectF> toGeometries;
 
     //Offset for widgets' bottom right position to each other
@@ -87,16 +95,16 @@
     if(startPoint.isNull()){
 
         QLineF diagonal(contentArea.topLeft(), contentArea.bottomRight());
-        QLineF widgetRightSide(contentArea.center().x()+ rects.at(0).width()/2,
+        QLineF widgetRightSide(contentArea.center().x()+ newRects.at(0).width()/2,
                            contentArea.top(),
-                           contentArea.center().x()+ rects.at(0).width()/2,
+                           contentArea.center().x()+ newRects.at(0).width()/2,
                            contentArea.bottom());
 
         // right side line intersection with diagonal will be bottom right position
         // for the first rect
         if(QLineF::BoundedIntersection != 
             diagonal.intersect(widgetRightSide, &anchorPoint)) {
-            return rects; //Return original since undefined error.
+            return newRects; //Return original since undefined error.
                             //In this case widget's must be wider than the content area.
         }
     }else{
@@ -104,8 +112,8 @@
     }
 
     QRectF widgetRect;
-    for(int i=0;i<rects.count();++i) {
-        widgetRect = rects.at(i);
+    for(int i=0;i<newRects.count();++i) {
+        widgetRect = newRects.at(i);
         widgetRect.moveBottomRight(anchorPoint);
         //if widget rect doesn't fit, try to move it
         if(!contentArea.contains(widgetRect)) {
@@ -137,9 +145,11 @@
 #endif //COVERAGE_MEASUREMENT
 QList<QRectF> HsAnchorPointInCenter::convert(
     const QRectF &contentArea,
-    const QList<QRectF> &rects,
+    const QList<QRectF> &existingRects,
+    const QList<QRectF> &newRects,
     const QPointF &startPoint )
 {
+    Q_UNUSED(existingRects);
     Q_UNUSED(startPoint)
 
     QList<QRectF> toGeometries;
@@ -152,7 +162,7 @@
 
     //First widget to the center of the content area
     QPointF anchorPoint = contentArea.center();
-    foreach (QRectF g, rects) {
+    foreach (QRectF g, newRects) {
         g.moveCenter(anchorPoint);
         toGeometries << g;
         anchorPoint -= offsetPoint;
@@ -163,6 +173,279 @@
     return toGeometries;
 }
 
+/*!
+    \class HsWidgetOrganizer
+    \brief Advanced widget positioning algorithm.
+    
+    Organizes widget's starting from upper left corner towards right,
+    and then continues the on the next line.
+*/
+QList<QRectF> HsWidgetOrganizer::convert(
+    const QRectF &contentArea,
+    const QList<QRectF> &existingRects,
+    const QList<QRectF> &newRects,
+    const QPointF &startPoint)
+{
+    Q_UNUSED(startPoint)
+
+    // TODO: maybe we can utilize start point in some use cases / optimizations?
+
+    QList<QRectF> toGeometries;
+
+    // TODO: anchor distance to configuration?
+    // TODO: optimize anchor distance based on new content amount
+    // TODO: snap value to same as anchor distance?
+    mAnchorDistance = 5;
+    QList<bool> temp;
+    mAnchors = temp;
+
+    // test flag
+    int test = 0;
+
+    // initialize anchor network for widget positions
+    if (test == 0) {
+        initAnchors(contentArea.size());
+    } else {
+        mAnchorDistance = 2;
+        initAnchors(QSizeF(6,6));
+    }
+
+    // mark existing rects (widgets) reserved
+    foreach (QRectF rect, existingRects) {
+        // TODO: could mStartWidthAnchorPoint, mEndWidthAnchorPoint, mEndHeightAnchorPoint be somehow refactored better way?
+        mStartWidthAnchorPoint.setX(lenghtInAnchorPoints(rect.x() - contentArea.x()));
+        mEndWidthAnchorPoint.setX(lenghtInAnchorPoints(rect.x() + rect.width() - contentArea.x()));
+        mStartWidthAnchorPoint.setY(lenghtInAnchorPoints(rect.y() - contentArea.y()));
+        mEndHeightAnchorPoint.setY(lenghtInAnchorPoints(rect.y() + rect.height() - contentArea.y()));
+        // mark reserved anchor points
+        markReservedAnchors();
+        mStartWidthAnchorPoint = QPointF(0,0);
+        mEndWidthAnchorPoint = QPointF(0,0);
+        mEndHeightAnchorPoint = QPointF(0,0);
+    }
+
+    QList<QRectF> notOrganizedRects;
+
+    // get positions for all new rects (widgets)
+    for ( int i = 0; i < newRects.count(); i++) {
+        bool found = false;
+        if (test == 0) {
+            // find first free anchor point for rect
+            found = getAnchorPoint(newRects.at(i).size());
+        } else {
+            found = getAnchorPoint(QSizeF(2,2));
+        }
+
+        if (found) {
+            // save to geometry list
+            toGeometries << QRectF(mStartWidthAnchorPoint.x() * mAnchorDistance + contentArea.x(),
+                                   mStartWidthAnchorPoint.y() * mAnchorDistance + contentArea.y(),
+                                   newRects.at(i).width(), newRects.at(i).height());
+            // mark new widgets rect reserved
+            markReservedAnchors();
+            // TODO: these optimizations could be used for empty page
+            //mStartWidthAnchorPoint.setX(mEndWidthAnchorPoint.x() + 1);
+            //mStartWidthAnchorPoint.setY(mEndWidthAnchorPoint.y());
+        } else {
+            // collect widgets that do not fit
+            notOrganizedRects << newRects.at(i);
+        }
+        // TODO: remove these to optimize for empty page
+        mStartWidthAnchorPoint = QPointF(0,0);
+        mEndWidthAnchorPoint = QPointF(0,0);
+    }
+
+    // use center algorithm with offset for the rest widget that did not fit to screen
+    if (notOrganizedRects.count() > 0) {
+        QList<QRectF> tmpExistingRects;
+        tmpExistingRects += newRects;
+        tmpExistingRects += existingRects;
+        HsAnchorPointInCenter *centerAlgorithm = new HsAnchorPointInCenter();
+        QList<QRectF> calculatedRects =
+            centerAlgorithm->convert(contentArea, tmpExistingRects, notOrganizedRects, QPointF());
+        toGeometries += calculatedRects;
+    }
+
+    return toGeometries;
+}
+
+
+/*!    
+    Initializes anchor points for context area
+*/
+bool HsWidgetOrganizer::initAnchors(const QSizeF &areaSize)
+{
+    // mandatory check ups
+    // TODO: these mAnchorDistance checks to earlier phase
+    if (areaSize == QSizeF(0,0) || areaSize.width() < mAnchorDistance ||
+        areaSize.height() < mAnchorDistance || mAnchorDistance == 0 || mAnchorDistance == 1) {
+        return false;
+    }
+    mAnchorColumns = 0;
+    mAnchorRows = 0;
+
+    // TODO: can we optimize anchor amount utilizing minimum widget size
+    mAnchorColumns = lenghtInAnchorPoints(areaSize.width());
+    mAnchorRows = lenghtInAnchorPoints(areaSize.height());
+
+    // create anchor network
+    for (int i = 0; i < (mAnchorRows * mAnchorColumns); i = i++) {
+        mAnchors << false;
+    }
+    // zero start points
+    mStartWidthAnchorPoint = QPointF(0,0);
+    mEndWidthAnchorPoint = QPointF(0,0);
+
+    return true;
+}
+
+/*!    
+    Finds anchor points for content size
+*/
+bool HsWidgetOrganizer::getAnchorPoint(const QSizeF &contentSize)
+{
+    bool anchorFound = false;
+
+    while (anchorFound == false) {
+        // if no width found for content
+        if (!searchWidthSpace(contentSize)) {
+            // when content organized in height order remove this line for optimization
+            mStartWidthAnchorPoint = QPointF(0,0);
+            mEndWidthAnchorPoint = QPointF(0,0);
+            return false;
+        }
+        // search height for content
+        int height = lenghtInAnchorPoints(contentSize.height());
+        anchorFound = searchHeightSpace(height);
+    }
+    return true;
+}
+
+/*!    
+    Searches anchor point width for content size
+*/
+bool HsWidgetOrganizer::searchWidthSpace(const QSizeF &contentSize) 
+{
+    int availableWidth = 0;    
+    int contentWidth = lenghtInAnchorPoints(contentSize.width());
+    // TODO: use this optimizations for empty page
+    //int contentHeight = lenghtInAnchorPoints(contentSize.height());
+    bool newRow = true;
+
+    for (int i = getIndexForCoordinate(mStartWidthAnchorPoint); i <= mAnchors.count(); i++) {
+        // no width left on the page
+        if ((newRow == false) && ((i % (mAnchorColumns)) == 0)) {
+            availableWidth = 0;
+            // jump to new row
+            mStartWidthAnchorPoint.setX(0);
+            // TODO: use this optimizations for empty page
+            //mStartWidthAnchorPoint.setY(mStartWidthAnchorPoint.y() + contentHeight + 1);
+            mStartWidthAnchorPoint.setY(mStartWidthAnchorPoint.y() + 1);
+            i = getIndexForCoordinate(mStartWidthAnchorPoint) - 1;
+            // if no height found
+            if (i < 0) {
+                return false;
+            }
+            newRow = true;
+        } else {
+            // if enough width found
+            if (availableWidth == contentWidth) {
+                mEndWidthAnchorPoint = getAnchorCoordinates(i);
+                if (mEndWidthAnchorPoint == QPointF()) {
+                    return false;
+                }
+                return true;
+            }
+            // if anchor reserved
+            if (mAnchors[i] == true) {
+                availableWidth = 0;
+            } else {
+                // update available width
+                availableWidth = availableWidth + 1;
+            }
+            newRow = false;
+        }   
+    }
+    return false;
+}
+
+/*!    
+    Searches anchor point area for content size
+*/
+bool HsWidgetOrganizer::searchHeightSpace(int contentHeight)
+{
+    mEndHeightAnchorPoint = QPointF(0,0);
+ 
+    for (int i = mStartWidthAnchorPoint.x(); i <= mEndWidthAnchorPoint.x(); i = i++) {
+        for (int j = mStartWidthAnchorPoint.y(); j <= (mStartWidthAnchorPoint.y() + contentHeight); j = j++) {
+            int index = getIndexForCoordinate(QPointF(i,j));
+            // check that index is not out of bounds
+            if (index == -1) {
+                // update start width point one step
+                mStartWidthAnchorPoint.setX(mStartWidthAnchorPoint.x() + 1); 
+                return false;
+            }
+            // if anchor reserved
+            if (mAnchors[index] == true) {
+                // update start width point one step
+                mStartWidthAnchorPoint.setX(mStartWidthAnchorPoint.x() + 1);
+                return false;
+            }
+        }
+    }
+    mEndHeightAnchorPoint = QPointF(mEndWidthAnchorPoint.x(), mEndWidthAnchorPoint.y() + contentHeight);
+    return true;
+}
+
+/*!    
+    Marks reserved anchor points based on pre-defined starting and ending points
+*/
+bool HsWidgetOrganizer::markReservedAnchors()
+{
+    for (int i = mStartWidthAnchorPoint.x(); i <= mEndWidthAnchorPoint.x(); i++) {
+        for (int j = mStartWidthAnchorPoint.y(); j <= mEndHeightAnchorPoint.y(); j++) {
+            mAnchors[getIndexForCoordinate(QPointF(i,j))] = true;
+        }
+    }
+    return true;
+}
+
+/*!    
+    Returns pixel coordinate based on anchor coordinate
+*/
+QPointF HsWidgetOrganizer::getAnchorCoordinates(int index)
+{
+    if (index < mAnchors.count()) {
+        int x = index % mAnchorColumns;
+        int y = (index - x) / mAnchorColumns;
+        return QPointF(x,y);
+    } else {
+        return QPointF();
+    }
+}
+
+/*!    
+    Returns anchor coordinate based on pixel coordinate
+*/
+int HsWidgetOrganizer::getIndexForCoordinate(QPointF position)
+{
+    int index = (position.y() * mAnchorColumns) + position.x();
+    if (index < mAnchors.count()) {
+        return index;
+    } else {
+        return -1;
+    }
+}
+
+/*!    
+    Calculates pixel length as anchor points
+*/
+int HsWidgetOrganizer::lenghtInAnchorPoints(QVariant length)
+{
+    // check remainder
+    int remainder = length.toInt() % mAnchorDistance;
+    return ((length.toInt() - remainder) / mAnchorDistance);
+}
 
 #ifdef COVERAGE_MEASUREMENT
 #pragma CTC ENDSKIP
--- a/homescreenapp/hsutils/src/hswidgetpositioningonwidgetmove.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/hsutils/src/hswidgetpositioningonwidgetmove.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -53,14 +53,15 @@
     Constructor.
 */
 HsSnapToLines::HsSnapToLines() :
-    mActiveRectWidth(0.0), mActiveRectHeight(0.0),
+    mActiveRectWidth(0.0), mActiveRectHeight(0.0), mMinDistancePosition(0.0),
     mHorizontalSnapPosition(0.0), mVerticalSnapPosition(0.0),
-    mHorizontalSnapFound(false),
-    mVerticalSnapFound(false),
-    mRectLieAbove(false), mLeftInRange(false), mRightInRange(false),
+    mHorizontalSnapFound(false), mVerticalSnapFound(false),
+    mRectLieAbove(false), mLeftInRange(false), mRightInRange(false), mIsBetterFitHorizontalSnap(false),
+    mDistanceVerticalEdges(0.0), mVerticalEdgeToLeftOfInactiveRect(0.0), mVerticalEdgeToRightOfInactiveRect(0.0),
     mMinVerticalEdgesDistance(0.0), mVerticalDistance(0.0),
     mVerticalDistanceFromSelectedRect(0.0), mContainerVerticalEdgeDistance(0.0),
-    mRectLieLeft(false), mTopInRange(false), mBottomInRange(false),
+    mRectLieLeft(false), mTopInRange(false), mBottomInRange(false), mIsBetterFitVerticalSnap(false),
+    mDistanceHorizontalEdges(0.0), mHorizontalEdgeToTopOfInactiveRect(0.0), mHorizontalEdgeToBottomOfInactiveRect(0.0),
     mMinHorizontalEdgesDistance(0.0), mHorizontalDistance(0.0),
     mHorizontalDistanceFromSelectedRect(0.0), mContainerHorizontalEdgeDistance(0.0),
     mSnapEnabled(false), mSnapForce(0.0), mSnapGap(0.0),
@@ -173,16 +174,14 @@
         mContainerHorizontalEdgeDistance = 0.0;
         mVerticalSnapFound = false;
 
-        checkForCenterSnapping();
         for (int i = 0; i < mInactiveSnapRects.count(); ++i) {
             mInactiveSnapRectToCompare = mInactiveSnapRects[i];
             mInactiveRectToCompare = mInactiveSnapRectToCompare.rectangle;
             if (!movingRect.intersects(mInactiveRectToCompare)) { //Only compare if Inactive Rect and moving rect do not overlap.
-                //TODO: Move the above check to another function...
-                // X - Direction Snapping
+                // Horizontal - Direction Snapping
                 compareLeftSideOfMovingRectForSnapping();
                 compareRightSideOfMovingRectForSnapping();
-                // Y - Direction Snapping
+                // Vertical - Direction Snapping
                 compareTopOfMovingRectForSnapping();
                 compareBottomOfMovingRectForSnapping();
             }
@@ -207,29 +206,6 @@
 }
 
 /*!
-    Check if the center of moving rect is in the snap force in the middle of continer rect.
-*/
-void HsSnapToLines::checkForCenterSnapping()
-{
-    QPointF centerOfContainerRect = mContainerRect.center();
-
-    QRectF verticalSnapField = QRectF(QPointF(centerOfContainerRect.x() - (mSnapForce/2), mContainerRect.top()),
-         QPointF(centerOfContainerRect.x() + (mSnapForce/2), mContainerRect.bottom()));
-
-    //Check that the widget lies in the container rect, if the snapping position is proposed... is not required,
-    //unless some widget is bigger than the page width
-    QPointF centerOfMovingRect = mMovingRect.center();
-    if (verticalSnapField.contains(centerOfMovingRect)) {
-        mHorizontalSnapFound = true;
-        mHorizontalSnapPosition = centerOfContainerRect.x() - mActiveRectWidth/2;
-        mMinVerticalEdgesDistance = qAbs(centerOfContainerRect.x() - centerOfMovingRect.x());
-        //save the points for the Vertical line
-        mVerticalLine.setP1(QPointF(centerOfContainerRect.x(), mMovingRect.top()));
-        mVerticalLine.setP2(QPointF(centerOfContainerRect.x(), mMovingRect.bottom()));
-    }
-}
-
-/*!
     Check if the inactive rect being compared with moving rect lies above or below of moving rect.
 */
 void HsSnapToLines::checkInactiveRectLieAboveOrBelowOfMovingRect()
@@ -259,6 +235,81 @@
     }
 }
 
+/*!
+    Check if the Vertical edges (Left and Right Edges) of the inactive rect being compared
+    is in range of the snapping distance of the vertical edge of moving rect
+    \param movingRectVerticalEdgePosition Position of the Vertical edge(either left or right) of moving rect.
+*/
+void HsSnapToLines::checkInactiveRectVerticalEdgesInRange(qreal movingRectVerticalEdgePosition)
+{
+    mLeftInRange = false;
+    mRightInRange = false;
+
+    //calculate the distance of the moving rect's vertical edge to the inactive rect's left and right edges
+    mVerticalEdgeToLeftOfInactiveRect = qAbs(mInactiveRectToCompare.left() - movingRectVerticalEdgePosition);
+    mVerticalEdgeToRightOfInactiveRect = qAbs(mInactiveRectToCompare.right() - movingRectVerticalEdgePosition);
+
+    if (mVerticalEdgeToLeftOfInactiveRect <= mMinVerticalEdgesDistance 
+        && (mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForBelow
+        || !mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForAbove)) { 
+        mLeftInRange = true;
+    }
+    if (mVerticalEdgeToRightOfInactiveRect <= mMinVerticalEdgesDistance
+        && (mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForBelow
+        || !mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForAbove)) {
+        mRightInRange = true;
+    }
+}
+
+/*!
+    Check if this inactive rect is better fit for Horizontal snapping
+    \param containerVerticalEdgeToInactiveRectVerticalEdge
+           difference between the vertical edge of the container and same vertical edge of inactive rect
+    \param containerOtherVerticalEdgeToInactiveRectOtherVerticalEdge
+           difference between the opposite vertical edges of continer and the inactive rect
+*/
+void HsSnapToLines::checkInactiveRectBetterFitForHorizontalSnapping(qreal containerVerticalEdgeToInactiveRectVerticalEdge,
+                                                                    qreal containerOtherVerticalEdgeToInactiveRectOtherVerticalEdge)
+{
+    //Check if the inactive rect is better fit or if it is inline with already selected position and hence is also a better fit
+    mIsBetterFitHorizontalSnap = false;
+    if (mLeftInRange || mRightInRange) {
+        if (mDistanceVerticalEdges < mMinVerticalEdgesDistance) {
+            mIsBetterFitHorizontalSnap = true;
+        }
+        else if (mDistanceVerticalEdges == mMinVerticalEdgesDistance) { //the distance in the vertical edges is same as from the previously selected rect
+            //check the position of rect with respect to Vertical line
+            checkInactiveRectPositionToVerticalLine();
+            //if horizontal snap position was previously found and the rect's edge is in line with Vertical line
+            if (mHorizontalSnapFound && mRectVerticalEdgeLiesInLineWithVerticalLine) {
+                if (mRectLieAboveVerticalLine || mRectLieBelowVerticalLine) {
+                    extendVerticalLineToIncludeInactiveRect();
+                }
+            }
+            //here the case is that moving rect lies exactly in middle of two same sides of two different inactive widgets.
+            else {
+                //Prioritize first on the fact if the inactive rect is closer to the moving rect in Y - direction.
+                if (mVerticalDistance < mVerticalDistanceFromSelectedRect) {
+                    mIsBetterFitHorizontalSnap = true;
+                }
+                else if (mVerticalDistance == mVerticalDistanceFromSelectedRect) {
+                    //Prioritize next if this Inactive rect's vertical edge is closer to the same vertical edge of the container rect, then the previously selected rect
+                    if (containerVerticalEdgeToInactiveRectVerticalEdge < mContainerVerticalEdgeDistance) {
+                        mIsBetterFitHorizontalSnap = true;
+                    }
+                    //Prioritize next if the Inactive rect's vertical edge lies near to same vertical edge of the container rect than the other pair
+                    else if (containerVerticalEdgeToInactiveRectVerticalEdge < containerOtherVerticalEdgeToInactiveRectOtherVerticalEdge) {
+                        mIsBetterFitHorizontalSnap = true;
+                    }
+                    else {
+                        //This else will happen if this rectangle being compared is exactly the same as the selected rectangle for snapping, but in opposite Y direction.
+                        //In that case it does not matter which is the selected rectangle. Hece we leave the already selected rectangle as the better fit.
+                    }
+                }
+            }
+        }
+    }
+}
 
 /*!
     Check if the left edge of moving rect is snappable to the incative rect's left or right edge.
@@ -268,141 +319,80 @@
 {
     checkInactiveRectLieAboveOrBelowOfMovingRect();
 
-    //calculate the distance of the moving rect's left edge to the inactive rect's left and right edges
-    qreal leftToLeftOfInactiveRect = qAbs(mInactiveRectToCompare.left() - mMovingRect.left());
-    qreal leftToRightOfInactiveRect = qAbs(mInactiveRectToCompare.right() - mMovingRect.left());
-    mLeftInRange = false;
-    mRightInRange = false;
-
-    if (leftToLeftOfInactiveRect <= mMinVerticalEdgesDistance) {
-        if (mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForBelow
-         || !mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForAbove) { 
-            mLeftInRange = true;
-        }
-    }
-    if (leftToRightOfInactiveRect <= mMinVerticalEdgesDistance) {
-        if (mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForBelow
-         || !mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForAbove) {
-            mRightInRange = true;
-        }
-    }
+    checkInactiveRectVerticalEdgesInRange(mMovingRect.left());
 
     //calculate the distance of inactive rect's left edge and container rect's left edge
     qreal differenceContainerLeftEdgeToInactiveRectLeftEdge = mInactiveRectToCompare.left() - mContainerRect.left();
     //calculate the distance of inactive rect's right edge and container rect's right edge
     qreal differenceContainerRightEdgeToInactiveRectRightEdge = mContainerRect.right() - mInactiveRectToCompare.right();
-
-    qreal minDistancePosition = 0.0;
-    qreal distanceVerticalEdges = 0.0;
     qreal xSnapGapAdjustment = 0.0;
+    mDistanceVerticalEdges = 0.0;
+    mMinDistancePosition = 0.0;
 
     //If only one edge of inactive rect is in snappable range, save that position
     if ((mLeftInRange && !mRightInRange)
         || !mLeftInRange && mRightInRange) {
         if (mLeftInRange) {
-            minDistancePosition = mInactiveRectToCompare.left();
-            distanceVerticalEdges = leftToLeftOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.left();
+            mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
             xSnapGapAdjustment = 0.0;
         }
         else {
-            minDistancePosition = mInactiveRectToCompare.right();
-            distanceVerticalEdges = leftToRightOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.right();
+            mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
             xSnapGapAdjustment = mSnapGap;
         }
     }
     //else both edges of inactive rect are in range, check which is a better fit
     else if (mLeftInRange && mRightInRange) {
         //if left edge of moving rect to the left of the inactive rect is closer than the left edge of moving rect to the right of the inactive rect
-        if (leftToLeftOfInactiveRect < leftToRightOfInactiveRect) {
-            minDistancePosition = mInactiveRectToCompare.left();
-            distanceVerticalEdges = leftToLeftOfInactiveRect;
+        if (mVerticalEdgeToLeftOfInactiveRect < mVerticalEdgeToRightOfInactiveRect) {
+            mMinDistancePosition = mInactiveRectToCompare.left();
+            mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
             xSnapGapAdjustment = 0.0;
             mRightInRange = false;
         }
         //if the left edge of inactive rect to left of moving rect is at the same distance as the right edge of inactive rect to the right of moving rect
-        else if (leftToLeftOfInactiveRect == leftToRightOfInactiveRect) {
+        else if (mVerticalEdgeToLeftOfInactiveRect == mVerticalEdgeToRightOfInactiveRect) {
             //if inactive rect lies towards the left or middle of container rect, then the left edge is priortized as the selected edge for outside snapping 
             if (differenceContainerLeftEdgeToInactiveRectLeftEdge <= differenceContainerRightEdgeToInactiveRectRightEdge) { 
-                minDistancePosition = mInactiveRectToCompare.left();
-                distanceVerticalEdges = leftToLeftOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.left();
+                mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
                 xSnapGapAdjustment = 0.0;
                 mRightInRange = false;
             }
             //else right of the inactive rect lies more close to the right of the container rect, and hence prioritize it for snapping.
             else {
-                minDistancePosition = mInactiveRectToCompare.right();
-                distanceVerticalEdges = leftToRightOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.right();
+                mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
                 xSnapGapAdjustment = mSnapGap;
                 mLeftInRange = false;
             }
         }
         //else right edge of inactive rect to the left of the moving rect is closer than the left edge of inactive rect to the left of the moving rect
         else{
-            minDistancePosition = mInactiveRectToCompare.right();
-            distanceVerticalEdges = leftToRightOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.right();
+            mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
             xSnapGapAdjustment = mSnapGap;
             mLeftInRange = false;
         }
     }
 
-    //Check if this inactive rect is better fit than the previous selected rect for X - snapping
-    bool horizontalSnappingBetterFit = false;
-    if (mLeftInRange || mRightInRange) {
-        if (distanceVerticalEdges < mMinVerticalEdgesDistance) {
-            horizontalSnappingBetterFit = true;
-        }
-        else if (distanceVerticalEdges == mMinVerticalEdgesDistance) { //the distance in the vertical edges is same as from the selected rectangle
-            //check the position of rect with respect to Vertical line
-            checkInactiveRectPositionToVerticalLine();
-            //if horizontal snap position was previously found the rect's edges are in line with Vertical line
-            if (mHorizontalSnapFound && mRectVerticalEdgeLiesInLineWithVerticalLine) {
-                if (mRectLieAboveVerticalLine || mRectLieBelowVerticalLine) {
-                    extendVerticalLineToIncludeInactiveRect();
-                }
-            }
-            //here the case is that moving rect lies exactly in middle of two same sides of two inactive widgets.
-            else {
-                //Prioritize first on the fact if the inactive rect is closer to the moving rect in Y - direction.
-                if (mVerticalDistance < mVerticalDistanceFromSelectedRect) {
-                    horizontalSnappingBetterFit = true;
-                }
-                else if (mVerticalDistance == mVerticalDistanceFromSelectedRect) {
-                    //Prioritize next if this Inactive rect is closer to the left edge of the container rect, then the previously selected rect
-                    if (differenceContainerLeftEdgeToInactiveRectLeftEdge < mContainerVerticalEdgeDistance) {
-                        horizontalSnappingBetterFit = true;
-                    }
-                    //Prioritize next if the Inactive widget's left edge lies near to left edge of the container rect
-                    else if (differenceContainerLeftEdgeToInactiveRectLeftEdge < differenceContainerRightEdgeToInactiveRectRightEdge) {
-                        horizontalSnappingBetterFit = true;
-                    }
-                    else {
-                        //This else will happen if this rectangle being compared is exactly the same as the selected rectangle for snapping.
-                        //In that case it does not matter which is the selected rectangle. Hence we leave the already selected rectangle as the better fit.
-                    }
-                }
-            }
-        }
-    }
+    //Check if this inactive rect is better fit than the previous selected rect for Horizontal - snapping
+    checkInactiveRectBetterFitForHorizontalSnapping(differenceContainerLeftEdgeToInactiveRectLeftEdge,
+                                                    differenceContainerRightEdgeToInactiveRectRightEdge);
 
-    if (horizontalSnappingBetterFit) {
-        qreal proposedRightOfActiveRect = minDistancePosition + xSnapGapAdjustment + mActiveRectWidth;
+    if (mIsBetterFitHorizontalSnap) {
+        qreal proposedRightOfActiveRect = mMinDistancePosition + xSnapGapAdjustment + mActiveRectWidth;
         if (qBound(mContainerRect.left(), proposedRightOfActiveRect, mContainerRect.right())
             == proposedRightOfActiveRect) {
             mHorizontalSnapFound = true;
-            mHorizontalSnapPosition = minDistancePosition + xSnapGapAdjustment;
-            mMinVerticalEdgesDistance = distanceVerticalEdges;
+            mHorizontalSnapPosition = mMinDistancePosition + xSnapGapAdjustment;
+            mMinVerticalEdgesDistance = mDistanceVerticalEdges;
             mVerticalDistanceFromSelectedRect = mVerticalDistance;
             //Save the new distance of the Chosen Rectangle's left edge from Container's left edge
             mContainerVerticalEdgeDistance = differenceContainerLeftEdgeToInactiveRectLeftEdge;
-
-            if (mRectLieAbove) {
-                mVerticalLine.setP1(QPointF(minDistancePosition, mInactiveRectToCompare.top()));
-                mVerticalLine.setP2(QPointF(minDistancePosition, mMovingRect.bottom()));
-            }
-            else {
-                mVerticalLine.setP1(QPointF(minDistancePosition, mInactiveRectToCompare.bottom()));
-                mVerticalLine.setP2(QPointF(minDistancePosition, mMovingRect.top()));
-            }
+            createVerticalLine();
         }
     }
 }
@@ -415,143 +405,96 @@
 {
     checkInactiveRectLieAboveOrBelowOfMovingRect();
 
-    //calculate the distance of the moving rect's right edge to the inactive rect's left and right edges
-    qreal rightToLeftOfInactiveRect = qAbs(mInactiveRectToCompare.left() - mMovingRect.right());
-    qreal rightToRightOfInactiveRect = qAbs(mInactiveRectToCompare.right() - mMovingRect.right());
-    mLeftInRange = false;
-    mRightInRange = false;
-
-    if (rightToLeftOfInactiveRect <= mMinVerticalEdgesDistance) {
-        if (mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForBelow
-         || !mRectLieAbove && mInactiveSnapRectToCompare.isLeftSnapableForAbove) {
-            mLeftInRange = true;
-        }
-    }
-    if (rightToRightOfInactiveRect <= mMinVerticalEdgesDistance) {
-        if (mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForBelow
-         || !mRectLieAbove && mInactiveSnapRectToCompare.isRightSnapableForAbove) {
-            mRightInRange = true;
-        }
-    }
+    checkInactiveRectVerticalEdgesInRange(mMovingRect.right());
 
     //calculate the distance of inactive rect's left edge and container rect's left edge
     qreal differenceContainerLeftEdgeToInactiveRectLeftEdge = mInactiveRectToCompare.left() - mContainerRect.left();
     //calculate the distance of inactive rect's right edge and container rect's right edge
     qreal differenceContainerRightEdgeToInactiveRectRightEdge = mContainerRect.right() - mInactiveRectToCompare.right();
-    qreal minDistancePosition = 0.0;
-    qreal distanceVerticalEdges = 0.0;
     qreal xSnapGapAdjustment = 0.0;
+    mDistanceVerticalEdges = 0.0;
+    mMinDistancePosition = 0.0;
 
     //If only one edge of inactive rect is in snappable range, save that position
     if ((mLeftInRange && !mRightInRange)
         || !mLeftInRange && mRightInRange) {
         if (mLeftInRange) {
-            minDistancePosition = mInactiveRectToCompare.left();
-            distanceVerticalEdges = rightToLeftOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.left();
+            mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
             xSnapGapAdjustment = mSnapGap;
         }
         else {
-            minDistancePosition = mInactiveRectToCompare.right();
-            distanceVerticalEdges = rightToRightOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.right();
+            mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
             xSnapGapAdjustment = 0.0;
         }
     }
     //else both edges of inactive rect are in range, check which is a better fit
     else if (mLeftInRange && mRightInRange) {
         //if right edge of moving rect to the right of the inactive rect is closer than the right edge of moving rect to the left of inactive rect
-        if (rightToRightOfInactiveRect < rightToLeftOfInactiveRect) {
-            minDistancePosition = mInactiveRectToCompare.right();
-            distanceVerticalEdges = rightToRightOfInactiveRect;
+        if (mVerticalEdgeToRightOfInactiveRect < mVerticalEdgeToLeftOfInactiveRect) {
+            mMinDistancePosition = mInactiveRectToCompare.right();
+            mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
             xSnapGapAdjustment = 0.0;
             mLeftInRange = false;
         }
         //if the right edge of moving rect to right of inactive rect is at the same distance as the right edge of moving rect to the left of inactive rect
-        else if (rightToRightOfInactiveRect == rightToLeftOfInactiveRect) {
+        else if (mVerticalEdgeToRightOfInactiveRect == mVerticalEdgeToLeftOfInactiveRect) {
             //if inactive rect lies towards the right of container rect, then the right edge is priortized as the selected edge for outside snapping
             if (differenceContainerRightEdgeToInactiveRectRightEdge < differenceContainerLeftEdgeToInactiveRectLeftEdge ) { 
-                minDistancePosition = mInactiveRectToCompare.right();
-                distanceVerticalEdges = rightToRightOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.right();
+                mDistanceVerticalEdges = mVerticalEdgeToRightOfInactiveRect;
                 xSnapGapAdjustment = 0.0;
                 mLeftInRange = false;
             }
             //else left of the inactive rect lies more close to the left or middle of the container rect, and hence prioritize it
             else {
-                minDistancePosition = mInactiveRectToCompare.left();
-                distanceVerticalEdges = rightToLeftOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.left();
+                mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
                 xSnapGapAdjustment = mSnapGap;
                 mRightInRange = false;
             }
         }
         //else right edge of moving rect to the left of the inactive rect is closer than the right edge of moving rect to the right of the incoming rect
         else{
-            minDistancePosition = mInactiveRectToCompare.left();
-            distanceVerticalEdges = rightToLeftOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.left();
+            mDistanceVerticalEdges = mVerticalEdgeToLeftOfInactiveRect;
             xSnapGapAdjustment = mSnapGap;
             mRightInRange = false;
         }
     }
 
     //Check if this inactive rect is better fit than the previous selected rect 
-    bool horizontalSnappingBetterFit = false;
-    if (mLeftInRange || mRightInRange) {
-        if (distanceVerticalEdges < mMinVerticalEdgesDistance) {
-            horizontalSnappingBetterFit = true;
-        }
-        else if (distanceVerticalEdges == mMinVerticalEdgesDistance) { //the distance in the vertical edge is same as from the selected rectangle
-            //check the position of rect with respect to Vertical line
-            checkInactiveRectPositionToVerticalLine();
-            //if horizontal snap position was previously found and the rect's edge is in line with Vertical line
-            if (mHorizontalSnapFound && mRectVerticalEdgeLiesInLineWithVerticalLine) {
-                if (mRectLieAboveVerticalLine || mRectLieBelowVerticalLine) {
-                    extendVerticalLineToIncludeInactiveRect();
-                }
-            }
-            //here the case is that moving rect lies exactly in middle of two same sides of two inactive widgets.
-            else {
-                //Prioritize first on the fact if the inactive rect is closer to the moving rect in Y - direction.
-                if (mVerticalDistance < mVerticalDistanceFromSelectedRect) {
-                    horizontalSnappingBetterFit = true;
-                }
-                else if (mVerticalDistance == mVerticalDistanceFromSelectedRect) {
-                    //Prioritize next if this Inactive rect is closer to the right edge of the container rect, then the previously selected rect
-                    if (differenceContainerRightEdgeToInactiveRectRightEdge < mContainerVerticalEdgeDistance) {
-                        horizontalSnappingBetterFit = true;
-                    }
-                    //Prioritize next if the Inactive rect's right edge lies near to right edge of the container rect
-                    else if (differenceContainerRightEdgeToInactiveRectRightEdge < differenceContainerLeftEdgeToInactiveRectLeftEdge) {
-                        horizontalSnappingBetterFit = true;
-                    }
-                    else {
-                        //This else will happen if this rectangle being compared is exactly the same as the selected rectangle for snapping, but in opposite Y direction.
-                        //In that case it does not matter which is the selected rectangle. Hece we leave the already selected rectangle as the better fit.
-                    }
-                }
-            }
-        }
-    }
+    checkInactiveRectBetterFitForHorizontalSnapping(differenceContainerRightEdgeToInactiveRectRightEdge,
+                                                    differenceContainerLeftEdgeToInactiveRectLeftEdge);
 
-    if (horizontalSnappingBetterFit) {
-        qreal proposedLeftOfActiveRect = minDistancePosition - mActiveRectWidth - xSnapGapAdjustment;
+    if (mIsBetterFitHorizontalSnap) {
+        qreal proposedLeftOfActiveRect = mMinDistancePosition - mActiveRectWidth - xSnapGapAdjustment;
         if (qBound(mContainerRect.left(), proposedLeftOfActiveRect, mContainerRect.right())
             == proposedLeftOfActiveRect) {
             mHorizontalSnapFound = true;
             mHorizontalSnapPosition = proposedLeftOfActiveRect;
-            mMinVerticalEdgesDistance = distanceVerticalEdges;
+            mMinVerticalEdgesDistance = mDistanceVerticalEdges;
             mVerticalDistanceFromSelectedRect = mVerticalDistance;
             //Save the new distance of the Chosen Rectangle's right edge from Container's right edge
             mContainerVerticalEdgeDistance = differenceContainerRightEdgeToInactiveRectRightEdge;
+            createVerticalLine();
+        }
+    }
+}
 
-            if (mRectLieAbove) {
-                //save the points for the Vertical line
-                mVerticalLine.setP1(QPointF(minDistancePosition, mInactiveRectToCompare.top()));
-                mVerticalLine.setP2(QPointF(minDistancePosition, mMovingRect.bottom()));
-            }
-            else {
-                //save the points for the Vertical line
-                mVerticalLine.setP1(QPointF(minDistancePosition, mInactiveRectToCompare.bottom()));
-                mVerticalLine.setP2(QPointF(minDistancePosition, mMovingRect.top()));
-            }
-        }
+/*!
+    Create the vertical line for horizontal snap guidance
+*/
+void HsSnapToLines::createVerticalLine()
+{
+    if (mRectLieAbove) {
+        mVerticalLine.setP1(QPointF(mMinDistancePosition, mInactiveRectToCompare.top()));
+        mVerticalLine.setP2(QPointF(mMinDistancePosition, mMovingRect.bottom()));
+    }
+    else {
+        mVerticalLine.setP1(QPointF(mMinDistancePosition, mInactiveRectToCompare.bottom()));
+        mVerticalLine.setP2(QPointF(mMinDistancePosition, mMovingRect.top()));
     }
 }
 
@@ -585,97 +528,49 @@
 }
 
 /*!
-    Check if the top edge of moving rect is snappable to the incative rect's top or bottom edge.
-    The inactive rect's edge is only chosen if it is a better fit for vertical snapping.
+    Check if the Horizontal edges (Top and Bottom Edges) of the inactive rect being compared
+    is in range of the snapping distance of the horizontal edge of moving rect
+    \param movingRectHorizontalEdgePosition Position of the Horizontal edge(either top or bottom) of moving rect.
 */
-void HsSnapToLines::compareTopOfMovingRectForSnapping()
+void HsSnapToLines::checkInactiveRectHorizontalEdgesInRange(qreal movingRectHorizontalEdgePosition)
 {
-    //Check if the inactive rect lies to the left or right of the moving rect
-    checkInactiveRectLieLeftOrRightOfMovingRect();
-
-    //calculate the distance of the moving rect's top edge to the inactive rect's top and bottom edges
-    qreal topToTopOfInactiveRect = qAbs(mInactiveRectToCompare.top() - mMovingRect.top());
-    qreal topToBottomOfInactiveRect = qAbs(mInactiveRectToCompare.bottom() - mMovingRect.top());
     mTopInRange = false;
     mBottomInRange = false;
 
-    if (topToTopOfInactiveRect <= mMinHorizontalEdgesDistance) {
+    //calculate the distance of the moving rect's horizontal edge to the inactive rect's top and bottom edges
+    mHorizontalEdgeToTopOfInactiveRect = qAbs(mInactiveRectToCompare.top() - movingRectHorizontalEdgePosition);
+    mHorizontalEdgeToBottomOfInactiveRect = qAbs(mInactiveRectToCompare.bottom() - movingRectHorizontalEdgePosition);
+
+    if (mHorizontalEdgeToTopOfInactiveRect <= mMinHorizontalEdgesDistance) {
         if (mRectLieLeft && mInactiveSnapRectToCompare.isTopSnapableForRight
          || !mRectLieLeft && mInactiveSnapRectToCompare.isTopSnapableForLeft) {
             mTopInRange = true;
         }
     }
-    if (topToBottomOfInactiveRect <= mMinHorizontalEdgesDistance) {
+    if (mHorizontalEdgeToBottomOfInactiveRect <= mMinHorizontalEdgesDistance) {
         if (mRectLieLeft && mInactiveSnapRectToCompare.isBottomSnapableForRight
          || !mRectLieLeft && mInactiveSnapRectToCompare.isBottomSnapableForLeft) {
             mBottomInRange = true;
         }
     }
-
-    //calculate the distance of inactive rect's top edge and container rect's top edge
-    qreal differenceContainerTopEdgeToInactiveRectTopEdge = mInactiveRectToCompare.top() - mContainerRect.top();
-    //calculate the distance of inactive rect's bottom edge and container rect's bottom edge
-    qreal differenceContainerBottomEdgeToInactiveRectBottomEdge = mContainerRect.bottom() - mInactiveRectToCompare.bottom();
-    qreal minDistancePosition = 0.0;
-    qreal distanceHorizontalEdges = 0.0;
-    qreal ySnapGapAdjustment = 0.0;
+}
 
-    //If only one edge of inactive rect is in snappable range, save that position
-    if ((mTopInRange && !mBottomInRange)
-        || !mTopInRange && mBottomInRange) {
-        if (mTopInRange) {
-            minDistancePosition = mInactiveRectToCompare.top();
-            distanceHorizontalEdges = topToTopOfInactiveRect;
-            ySnapGapAdjustment = 0.0;
-        }
-        else {
-            minDistancePosition = mInactiveRectToCompare.bottom();
-            distanceHorizontalEdges = topToBottomOfInactiveRect;
-            ySnapGapAdjustment = mSnapGap;
-        }
-    }
-    //else both edges of inactive rect are in range, check which is a better fit
-    else if (mTopInRange && mBottomInRange) {
-        //if top edge of moving rect to the top of the inactive rect is closer than the bottom edge of moving rect to the bottom of the inactive rect
-        if (topToTopOfInactiveRect < topToBottomOfInactiveRect) {
-            minDistancePosition = mInactiveRectToCompare.top();
-            distanceHorizontalEdges = topToTopOfInactiveRect;
-            ySnapGapAdjustment = 0.0;
-            mBottomInRange = false;
+/*!
+    Check if this inactive rect is better fit for Vertical snapping
+    \param containerHorizontalEdgeToInactiveRectHorizontalEdge
+           difference between the horizontal edge of the container and same horizontal edge of inactive rect
+    \param containerOtherHorizontalEdgeToInactiveRectOtherHorizontalEdge
+           difference between the opposite horizontal edges of continer and the inactive rect
+*/
+void HsSnapToLines::checkInactiveRectBetterFitForVerticalSnapping(qreal containerHorizontalEdgeToInactiveRectHorizontalEdge,
+                                                       qreal containerOtherHorizontalEdgeToInactiveRectOtherHorizontalEdge)
+{
+    mIsBetterFitVerticalSnap = false;
+    if (mTopInRange || mBottomInRange) {
+        if (mDistanceHorizontalEdges < mMinHorizontalEdgesDistance) {
+            mIsBetterFitVerticalSnap = true;
         }
-        //if the top edge of moving rect to top of inactive rect is at the same distance as the top edge of moving rect to the bottom of inactive rect
-        else if (topToTopOfInactiveRect == topToBottomOfInactiveRect) {
-            //if inactive rect lies towards the top or middle of container rect, then the top edge is priortized as the selected edge for outside snapping
-            if (differenceContainerTopEdgeToInactiveRectTopEdge <= differenceContainerBottomEdgeToInactiveRectBottomEdge) { 
-                minDistancePosition = mInactiveRectToCompare.top();
-                distanceHorizontalEdges = topToTopOfInactiveRect;
-                ySnapGapAdjustment = 0.0;
-                mBottomInRange = false;
-            }
-            //else bottom of the inactive rect lies more close to the bottom of the container rect, and hence prioritize it for snapping.
-            else {
-                minDistancePosition = mInactiveRectToCompare.bottom();
-                distanceHorizontalEdges = topToBottomOfInactiveRect;
-                ySnapGapAdjustment = mSnapGap;
-                mTopInRange = false;
-            }
-        }
-        //else top edge of moving rect to the bottom of the inactive rect is closer than the top edge of moving rect to the top of the inactive rect
-        else{
-            minDistancePosition = mInactiveRectToCompare.bottom();
-            distanceHorizontalEdges = topToBottomOfInactiveRect;
-            ySnapGapAdjustment = mSnapGap;
-            mTopInRange = false;
-        }
-    }
-
-    //Check if this inactive rect is better fit than the previous selected rect 
-    bool verticalSnappingBetterFit = false;
-    if (mTopInRange || mBottomInRange) {
-        if (distanceHorizontalEdges < mMinHorizontalEdgesDistance) {
-            verticalSnappingBetterFit = true;
-        }
-        else if (distanceHorizontalEdges == mMinHorizontalEdgesDistance) { //the distance in the horizontal edge is same as from the selected rectangle
+        else if (mDistanceHorizontalEdges == mMinHorizontalEdgesDistance) { //the distance in the horizontal edge is same as from the selected rectangle
             //check the position of rect with respect to horizontal line
             checkInactiveRectPositionToHorizontalLine();
             //if vertical snap position was already found and this rect's horizontal edges lies in line with Horizontal snap line
@@ -687,16 +582,16 @@
             else {
                 //Prioritize first on the fact if the inactive rect is closer to the moving rect in X - direction.
                 if (mHorizontalDistance < mHorizontalDistanceFromSelectedRect) {
-                    verticalSnappingBetterFit = true;
+                    mIsBetterFitVerticalSnap = true;
                 }
                 else if (mHorizontalDistance == mHorizontalDistanceFromSelectedRect) {
                     //Prioritize next if this Inactive rect is closer to the top edge of the container rect, then the previously selected rect
-                    if (differenceContainerTopEdgeToInactiveRectTopEdge < mContainerHorizontalEdgeDistance) {
-                        verticalSnappingBetterFit = true;
+                    if (containerHorizontalEdgeToInactiveRectHorizontalEdge < mContainerHorizontalEdgeDistance) {
+                        mIsBetterFitVerticalSnap = true;
                     }
                     //Prioritize next if the Inactive widget's top edge lies near to top edge of the container rect
-                    else if (differenceContainerTopEdgeToInactiveRectTopEdge < differenceContainerBottomEdgeToInactiveRectBottomEdge) {
-                        verticalSnappingBetterFit = true;
+                    else if (containerHorizontalEdgeToInactiveRectHorizontalEdge < containerOtherHorizontalEdgeToInactiveRectOtherHorizontalEdge) {
+                        mIsBetterFitVerticalSnap = true;
                     }
                     else {
                         //This else will happen if this rectangle being compared is exactly the same as the selected rectangle for snapping, or in opposite X direction.
@@ -707,27 +602,91 @@
         }
     }
 
-    if (verticalSnappingBetterFit) {
-        qreal proposedBottomOfActiveRect = minDistancePosition + mActiveRectHeight + ySnapGapAdjustment;
+}
+
+/*!
+    Check if the top edge of moving rect is snappable to the incative rect's top or bottom edge.
+    The inactive rect's edge is only chosen if it is a better fit for vertical snapping.
+*/
+void HsSnapToLines::compareTopOfMovingRectForSnapping()
+{
+    //Check if the inactive rect lies to the left or right of the moving rect
+    checkInactiveRectLieLeftOrRightOfMovingRect();
+
+    checkInactiveRectHorizontalEdgesInRange(mMovingRect.top());
+
+    //calculate the distance of inactive rect's top edge and container rect's top edge
+    qreal differenceContainerTopEdgeToInactiveRectTopEdge = mInactiveRectToCompare.top() - mContainerRect.top();
+    //calculate the distance of inactive rect's bottom edge and container rect's bottom edge
+    qreal differenceContainerBottomEdgeToInactiveRectBottomEdge = mContainerRect.bottom() - mInactiveRectToCompare.bottom();
+    qreal ySnapGapAdjustment = 0.0;
+    mDistanceHorizontalEdges = 0.0;
+    mMinDistancePosition = 0.0;
+
+    //If only one edge of inactive rect is in snappable range, save that position
+    if ((mTopInRange && !mBottomInRange)
+        || !mTopInRange && mBottomInRange) {
+        if (mTopInRange) {
+            mMinDistancePosition = mInactiveRectToCompare.top();
+            mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
+            ySnapGapAdjustment = 0.0;
+        }
+        else {
+            mMinDistancePosition = mInactiveRectToCompare.bottom();
+            mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
+            ySnapGapAdjustment = mSnapGap;
+        }
+    }
+    //else both edges of inactive rect are in range, check which is a better fit
+    else if (mTopInRange && mBottomInRange) {
+        //if top edge of moving rect to the top of the inactive rect is closer than the bottom edge of moving rect to the bottom of the inactive rect
+        if (mHorizontalEdgeToTopOfInactiveRect < mHorizontalEdgeToBottomOfInactiveRect) {
+            mMinDistancePosition = mInactiveRectToCompare.top();
+            mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
+            ySnapGapAdjustment = 0.0;
+            mBottomInRange = false;
+        }
+        //if the top edge of moving rect to top of inactive rect is at the same distance as the top edge of moving rect to the bottom of inactive rect
+        else if (mHorizontalEdgeToTopOfInactiveRect == mHorizontalEdgeToBottomOfInactiveRect) {
+            //if inactive rect lies towards the top or middle of container rect, then the top edge is priortized as the selected edge for outside snapping
+            if (differenceContainerTopEdgeToInactiveRectTopEdge <= differenceContainerBottomEdgeToInactiveRectBottomEdge) { 
+                mMinDistancePosition = mInactiveRectToCompare.top();
+                mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
+                ySnapGapAdjustment = 0.0;
+                mBottomInRange = false;
+            }
+            //else bottom of the inactive rect lies more close to the bottom of the container rect, and hence prioritize it for snapping.
+            else {
+                mMinDistancePosition = mInactiveRectToCompare.bottom();
+                mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
+                ySnapGapAdjustment = mSnapGap;
+                mTopInRange = false;
+            }
+        }
+        //else top edge of moving rect to the bottom of the inactive rect is closer than the top edge of moving rect to the top of the inactive rect
+        else{
+            mMinDistancePosition = mInactiveRectToCompare.bottom();
+            mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
+            ySnapGapAdjustment = mSnapGap;
+            mTopInRange = false;
+        }
+    }
+
+    //Check if this inactive rect is better fit than the previous selected rect 
+    checkInactiveRectBetterFitForVerticalSnapping(differenceContainerTopEdgeToInactiveRectTopEdge,
+                                                  differenceContainerBottomEdgeToInactiveRectBottomEdge);
+
+    if (mIsBetterFitVerticalSnap) {
+        qreal proposedBottomOfActiveRect = mMinDistancePosition + mActiveRectHeight + ySnapGapAdjustment;
         if (qBound(mContainerRect.top(), proposedBottomOfActiveRect, mContainerRect.bottom())
             == proposedBottomOfActiveRect) {
             mVerticalSnapFound = true;
-            mVerticalSnapPosition = minDistancePosition + ySnapGapAdjustment;
-            mMinHorizontalEdgesDistance = distanceHorizontalEdges;
+            mVerticalSnapPosition = mMinDistancePosition + ySnapGapAdjustment;
+            mMinHorizontalEdgesDistance = mDistanceHorizontalEdges;
             mHorizontalDistanceFromSelectedRect = mHorizontalDistance;
             //Save the new distance of the Chosen Rectangle's top edge from Container's top edge
             mContainerHorizontalEdgeDistance = differenceContainerTopEdgeToInactiveRectTopEdge;
-
-            if (mRectLieLeft) {
-                //save the points for the Horizontal line
-                mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.left(), minDistancePosition));
-                mHorizontalLine.setP2(QPointF(mMovingRect.right(), minDistancePosition));
-            }
-            else {
-                //save the points for the Horizontal line
-                mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.right(), minDistancePosition));
-                mHorizontalLine.setP2(QPointF(mMovingRect.left(), minDistancePosition));
-            }
+            createHorizontalLine();
         }
     }
 }
@@ -742,142 +701,99 @@
     checkInactiveRectLieLeftOrRightOfMovingRect();
 
     //calculate the distance of the moving rect's bottom edge to the inactive rect's top and bottom edges
-    qreal bottomToTopOfInactiveRect = qAbs(mInactiveRectToCompare.top() - mMovingRect.bottom());
-    qreal bottomToBottomOfInactiveRect = qAbs(mInactiveRectToCompare.bottom() - mMovingRect.bottom());
-    mTopInRange = false;
-    mBottomInRange = false;
-
-    if (bottomToTopOfInactiveRect <= mMinHorizontalEdgesDistance) {
-        if (mRectLieLeft && mInactiveSnapRectToCompare.isTopSnapableForRight
-         || !mRectLieLeft && mInactiveSnapRectToCompare.isTopSnapableForLeft) {
-            mTopInRange = true;
-        }
-    }
-    if (bottomToBottomOfInactiveRect <= mMinHorizontalEdgesDistance) {
-        if (mRectLieLeft && mInactiveSnapRectToCompare.isBottomSnapableForRight
-         || !mRectLieLeft && mInactiveSnapRectToCompare.isBottomSnapableForLeft) {
-            mBottomInRange = true;
-        }
-    }
+    checkInactiveRectHorizontalEdgesInRange(mMovingRect.bottom());
 
     //calculate the distance of inactive rect's top edge and container rect's top edge
     qreal differenceContainerTopEdgeToInactiveRectTopEdge = mInactiveRectToCompare.top() - mContainerRect.top();
     //calculate the distance of inactive rect's bottom edge and container rect's bottom edge
     qreal differenceContainerBottomEdgeToInactiveRectBottomEdge = mContainerRect.bottom() - mInactiveRectToCompare.bottom();
-    qreal minDistancePosition = 0.0;
-    qreal distanceHorizontalEdges = 0.0;
     qreal ySnapGapAdjustment = 0.0;
+    mDistanceHorizontalEdges = 0.0;
+    mMinDistancePosition = 0.0;
 
     //If only one edge of inactive rect is in snappable range, save that position
     if ((mTopInRange && !mBottomInRange)
         || !mTopInRange && mBottomInRange) {
         if (mTopInRange) {
-            minDistancePosition = mInactiveRectToCompare.top();
-            distanceHorizontalEdges = bottomToTopOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.top();
+            mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
             ySnapGapAdjustment = mSnapGap;
         }
         else {
-            minDistancePosition = mInactiveRectToCompare.bottom();
-            distanceHorizontalEdges = bottomToBottomOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.bottom();
+            mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
             ySnapGapAdjustment = 0.0;
         }
     }
     //else both edges of inactive rect are in range, check which is a better fit
     else if (mTopInRange && mBottomInRange) {
         //if bottom edge of moving rect to the bottom of inactive rect is closer than the bottom edge of moving rect to the top of the inactive rect
-        if (bottomToBottomOfInactiveRect < bottomToTopOfInactiveRect ) {
-            minDistancePosition = mInactiveRectToCompare.bottom();
-            distanceHorizontalEdges = bottomToBottomOfInactiveRect;
+        if (mHorizontalEdgeToBottomOfInactiveRect < mHorizontalEdgeToTopOfInactiveRect ) {
+            mMinDistancePosition = mInactiveRectToCompare.bottom();
+            mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
             ySnapGapAdjustment = 0.0;
             mTopInRange = false;
         }
         //if bottom edge of moving rect to the bottom of inactive rect is at the same distance as the bottom edge of moving rect to the top of inactive rect
-        else if (bottomToBottomOfInactiveRect == bottomToTopOfInactiveRect) {
+        else if (mHorizontalEdgeToBottomOfInactiveRect == mHorizontalEdgeToTopOfInactiveRect) {
             //if inactive rect lies towards the bottom of container rect, then the bottom edge is priortized as the selected edge for snapping
             //This is done for outside snapping
             if (differenceContainerBottomEdgeToInactiveRectBottomEdge < differenceContainerTopEdgeToInactiveRectTopEdge) {
-                minDistancePosition = mInactiveRectToCompare.bottom();
-                distanceHorizontalEdges = bottomToBottomOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.bottom();
+                mDistanceHorizontalEdges = mHorizontalEdgeToBottomOfInactiveRect;
                 ySnapGapAdjustment = 0.0;
                 mTopInRange = false;
             }
             //else top of the inactive rect lies more close to the top of the container rect or at the same distance, and hence prioritize it
             else {
-                minDistancePosition = mInactiveRectToCompare.top();
-                distanceHorizontalEdges = bottomToTopOfInactiveRect;
+                mMinDistancePosition = mInactiveRectToCompare.top();
+                mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
                 ySnapGapAdjustment = mSnapGap;
                 mBottomInRange = false;
             }
         }
         //else bottom edge of moving rect to the top of inactive rect is closer than the bottom edge of moving rect to the bottom of the inactive rect
         else{
-            minDistancePosition = mInactiveRectToCompare.top();
-            distanceHorizontalEdges = bottomToTopOfInactiveRect;
+            mMinDistancePosition = mInactiveRectToCompare.top();
+            mDistanceHorizontalEdges = mHorizontalEdgeToTopOfInactiveRect;
             ySnapGapAdjustment = mSnapGap;
             mBottomInRange = false;
         }
     }
 
     //Check if this inactive rect is better fit than the previous selected rect 
-    bool verticalSnappingBetterFit = false;
-    if (mTopInRange || mBottomInRange) {
-        if (distanceHorizontalEdges < mMinHorizontalEdgesDistance) {
-            verticalSnappingBetterFit = true;
-        }
-        else if (distanceHorizontalEdges == mMinHorizontalEdgesDistance) { //the distance in the horizontal edge is same as from the selected rectangle
-            //check the position of rect with respect to horizontal line
-            checkInactiveRectPositionToHorizontalLine();
-            //if vertical snap was already found and the horizontal line of rect is in line with horizontal snap line
-            if (mVerticalSnapFound && mRectHorizontalEdgeLiesInLineWithHorizontalLine) {
-                if (mRectLieLeftOfHorizontalLine || mRectLiesRightOfHorizontalLine) {
-                    extendHorizontalLineToIncludeInactiveRect();
-                }
-            }
-            else {
-                //Prioritize first on the fact if the inactive rect is closer to the moving rect in X - direction.
-                if (mHorizontalDistance < mHorizontalDistanceFromSelectedRect) {
-                    verticalSnappingBetterFit = true;
-                }
-                else if (mHorizontalDistance == mHorizontalDistanceFromSelectedRect) {
-                    //Prioritize next if this Inactive rect is closer to the bottom edge of the container rect, then the previously selected rect
-                    if (differenceContainerBottomEdgeToInactiveRectBottomEdge < mContainerHorizontalEdgeDistance) {
-                        verticalSnappingBetterFit = true;
-                    }
-                    //Prioritize next if the Inactive widget's bottom edge lies near to bottom edge of the container rect
-                    else if (differenceContainerBottomEdgeToInactiveRectBottomEdge < differenceContainerTopEdgeToInactiveRectTopEdge) {
-                        verticalSnappingBetterFit = true;
-                    }
-                    else {
-                        //This else will happen if this rectangle being compared is exactly the same as the selected rectangle for snapping, or in opposite X direction.
-                        //In that case it does not matter which is the selected rectangle. Hence we leave the already selected rectangle as the better fit.
-                    }
-                }
-            }
-        }
-    }
+    checkInactiveRectBetterFitForVerticalSnapping(differenceContainerBottomEdgeToInactiveRectBottomEdge,
+                                                  differenceContainerTopEdgeToInactiveRectTopEdge);
 
-    if (verticalSnappingBetterFit) {
-        qreal proposedTopOfActiveRect = minDistancePosition - mActiveRectHeight - ySnapGapAdjustment;
+    if (mIsBetterFitVerticalSnap) {
+        qreal proposedTopOfActiveRect = mMinDistancePosition - mActiveRectHeight - ySnapGapAdjustment;
         if (qBound(mContainerRect.top(), proposedTopOfActiveRect, mContainerRect.bottom())
             == proposedTopOfActiveRect) {
             mVerticalSnapFound = true;
             mVerticalSnapPosition = proposedTopOfActiveRect;
-            mMinHorizontalEdgesDistance = distanceHorizontalEdges;
+            mMinHorizontalEdgesDistance = mDistanceHorizontalEdges;
             mHorizontalDistanceFromSelectedRect = mHorizontalDistance;
             //Save the new distance of the Selected Rectangle's bottom edge from Container's bottom edge
             mContainerHorizontalEdgeDistance = differenceContainerBottomEdgeToInactiveRectBottomEdge;
+            createHorizontalLine();
+        }
+    }
+}
 
-            if (mRectLieLeft) {
-                //save the points for the Horizontal line
-                mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.left(), minDistancePosition));
-                mHorizontalLine.setP2(QPointF(mMovingRect.right(), minDistancePosition));
-            }
-            else {
-                //save the points for the Horizontal line
-                mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.right(), minDistancePosition));
-                mHorizontalLine.setP2(QPointF(mMovingRect.left(), minDistancePosition));
-            }
-        }
+/*!
+    Create the horizontal line for vertical snap guidance
+*/
+void HsSnapToLines::createHorizontalLine()
+{
+    if (mRectLieLeft) {
+        //save the points for the Horizontal line
+        mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.left(), mMinDistancePosition));
+        mHorizontalLine.setP2(QPointF(mMovingRect.right(), mMinDistancePosition));
+    }
+    else {
+        //save the points for the Horizontal line
+        mHorizontalLine.setP1(QPointF(mInactiveRectToCompare.right(), mMinDistancePosition));
+        mHorizontalLine.setP2(QPointF(mMovingRect.left(), mMinDistancePosition));
     }
 }
 
--- a/homescreenapp/inc/hsapp_defs.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/inc/hsapp_defs.h	Fri Jul 23 13:47:57 2010 +0300
@@ -71,7 +71,8 @@
     RenameContextAction, 
     DeleteContextAction, 
     RemoveFromCollectionContextAction,
-    AppDetailsContextAction
+    AppDetailsContextAction,
+    OpenContextAction
 };
 
 
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -26,4 +26,4 @@
 LIBS += -lcaclient
 
 symbian::TARGET.UID3 = 0x20026FA9
-win32:exportResources(./resource/*.png, resource)
+!symbian:exportResources(./resource/*.png, resource)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuentryremovedhandler.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Entry removal handler.
+*
+*/
+
+
+#ifndef HS_MENU_ENTRY_REMOVED_HANDLER_H
+#define HS_MENU_ENTRY_REMOVED_HANDLER_H
+
+#include <QScopedPointer>
+
+#include <cadefs.h>
+#include <canotifier.h>
+
+#include "hsmenuservice_global.h"
+
+class MENUSERVICE_EXPORT  HsMenuEntryRemovedHandler: public QObject
+{
+    Q_OBJECT
+public:
+    HsMenuEntryRemovedHandler(
+        int entryId, QObject *receiver, const char *callback);
+    virtual ~HsMenuEntryRemovedHandler();
+
+signals:
+    void notify();
+private slots:
+    virtual void entryChanged(int entryId, ChangeType changeType);
+    
+private:
+    void subscribe(int entryId);
+
+private:
+    QScopedPointer<CaNotifier> mNotifier;
+};
+#endif
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice_global.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice_global.h	Fri Jul 23 13:47:57 2010 +0300
@@ -19,7 +19,7 @@
 #define HSMENUSERVICE_GLOBAL_H
 
 // System includes
-#include <Qt/qglobal.h>
+#include <qglobal.h>
 
 #ifdef MENUSERVICE_LIB
 #define MENUSERVICE_EXPORT Q_DECL_EXPORT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuentryremovedhandler.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Photos image fetcher client.
+*
+*/
+
+#include <QList>
+
+#include <caservice.h>
+#include <canotifier.h>
+#include <canotifierfilter.h>
+
+#include "hsmenuentryremovedhandler.h"
+/*!
+    \class HsMenuEntryRemovedHandler
+    Listens for entry removal notifications and calls a callback.
+    \ingroup group_hsutils
+    \brief 
+*/
+
+/*!
+ Constructor.
+ \param entryId identifies entry which removal is to be observed.
+ \param receiver object which \a callback is to be called on requested entry
+ removal. If \receiver is passed 0 no action will be taken on the entry removal.
+ \param callback signal or slot that will be called on entry removal. The \a callback
+ signature should correspond to void (*)(int, ChangeType) signal otherwise
+ runtime warning will be provided. If \a callback is 0 no action will be
+ taken on the entry removal.
+*/
+HsMenuEntryRemovedHandler::HsMenuEntryRemovedHandler(
+    int entryId, 
+    QObject *receiver,
+    const char *callback):
+    mNotifier(0)
+{
+    if (receiver != 0 && callback != 0) {
+        connect(this, SIGNAL(notify()), receiver, callback);
+        subscribe(entryId);
+    }
+};
+
+/*!
+ Destructor.
+*/
+HsMenuEntryRemovedHandler::~HsMenuEntryRemovedHandler() {};
+
+/*!
+  Subscribes the observer for notifications for a given entryId and
+  makes sure the \a HsMenuEntryRemovedObserver::entryChagned will be called
+  on any notification for the entry.
+  \param entryId identifier of the entry to be observed.
+
+*/
+void HsMenuEntryRemovedHandler::subscribe(int entryId)
+{
+    // create notifier for a given entryId
+    CaNotifierFilter filter;
+    QList<int> entryIds;
+    entryIds.append(entryId);
+    filter.setIds(entryIds);
+    mNotifier.reset(CaService::instance()->createNotifier(filter));
+
+    connect(mNotifier.data(),
+        SIGNAL(entryChanged(int, ChangeType)),
+        this,
+        SLOT(entryChanged(int, ChangeType)),
+        Qt::UniqueConnection);
+}
+
+
+/*!
+ Handles notification about entry change
+ \param entryId ignored as the observer is subscribed for exactly one entry.
+ \param changeType notified change type.
+ */
+void HsMenuEntryRemovedHandler::entryChanged(int entryId, 
+    ChangeType changeType)
+{
+    Q_UNUSED(entryId); // CaNotifier should care about matching id, skip it here
+    
+    if (changeType == RemoveChangeType) {
+        emit notify();
+        mNotifier.reset(0);
+    }
+}
--- a/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -34,7 +34,7 @@
 
 // Initialization of a static member variable.
 int HsMenuService::mAllCollectionsId = 0;
-
+const char COLLECTION_TITLE_NAME[] = "title_name";
 /*!
  Returns all applications model
  \param sortAttribute ::  SortAttribute
@@ -236,6 +236,7 @@
     CaEntry collection(GroupEntryRole);
     collection.setEntryTypeName(collectionTypeName());
     collection.setText(name);
+	collection.setAttribute(COLLECTION_TITLE_NAME, name);
     collection.setAttribute(groupNameAttributeName(),name);
     CaIconDescription iconDescription;
     iconDescription.setFilename(defaultCollectionIconId());
@@ -270,6 +271,7 @@
                  << collection;
 
         collection->setText(newCollectionName);
+        collection->setAttribute(COLLECTION_TITLE_NAME, newCollectionName);
         result = CaService::instance()->updateEntry(*collection);
     }
     HSMENUTEST_FUNC_EXIT("HsMenuService::renameCollection");
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/hsapplibrarystateplugin.qrc	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/hsapplibrarystateplugin.qrc	Fri Jul 23 13:47:57 2010 +0300
@@ -1,6 +1,13 @@
 <RCC>
     <qresource prefix="/xml">
-        <file alias="applibrary.docml">resource/applibrary.docml</file>
+        <file alias="addcontentlabeledview.docml">resource/addcontentlabeledview.docml</file>
+        <file alias="common_objects.docml">resource/common_objects.docml</file>
+        <file alias="emptylabeledview.docml">resource/emptylabeledview.docml</file>
+        <file alias="labeledlistview.docml">resource/labeledlistview.docml</file>
+        <file alias="labeledsearchview.docml">resource/labeledsearchview.docml</file>
+        <file alias="listview.docml">resource/listview.docml</file>
+        <file alias="searchlabeledlistview.docml">resource/searchlabeledlistview.docml</file>
+        <file alias="searchlistview.docml">resource/searchlistview.docml</file>        
     </qresource>
     <qresource prefix="/css">
         <file alias="hsapplibrarystateplugin.css">resource/hsapplibrarystateplugin.css</file>
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -18,14 +18,11 @@
 #ifndef HSALLCOLLECTIONSSTATE_H
 #define HSALLCOLLECTIONSSTATE_H
 
-#include <QState>
-#include <QPointF>
-
 #include "hsbaseviewstate.h"
-#include "hsmenumodewrapper.h"
 
 HS_STATES_TEST_CLASS(MenuStatesTest)
 
+class QPointF;
 class HsMenuViewBuilder;
 class HbAbstractViewItem;
 class HbAction;
@@ -33,6 +30,7 @@
 class HsMenuItemModel;
 class HsMenuView;
 class HsMainWindow;
+class HsMenuModeWrapper;
 
 class HsAllCollectionsState: public HsBaseViewState
 {
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsbaseviewstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsbaseviewstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -26,6 +26,7 @@
 #include "hsmenuservice.h"
 #include "hsmenuview.h"
 
+
 class HbMenu;
 class HbAction;
 class HbMessageBox;
@@ -52,7 +53,6 @@
 
 private slots:
 
-    virtual void applicationLaunchFailMessageFinished(HbAction*);
     virtual void openAppLibrary();
 
 protected slots:
@@ -67,27 +67,21 @@
     virtual void showContextMenu(HbAbstractViewItem *item, const QPointF &coords);
     virtual int checkSoftwareUpdates();
     virtual bool openTaskSwitcher();
+    virtual void closeContextMenu();
 protected:
     
-    void initialize(HsMenuViewBuilder &menuViewBuilder, HsViewContext viewContext);
+    void initialize(HsMenuViewBuilder &menuViewBuilder, HsStateContext stateContext);
     void createApplicationLaunchFailMessage(int errorCode,int itemId);
-    void subscribeForMemoryCardRemove();
-
     void defineTransitions();
 
 private:
-    
-    void cleanUpApplicationLaunchFailMessage();
-
     virtual void setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags) = 0;
     virtual void setMenuOptions() = 0;
 
 
 private:
     
-    CaNotifier *mNotifier;
-    int mMessageRelatedItemId;
-    HbMessageBox *mApplicationLaunchFailMessage;
+    QPointer<HbMessageBox> mApplicationLaunchFailMessage;
 
 protected:
     HsMenuItemModel *mModel;
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmainwindow.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmainwindow.h	Fri Jul 23 13:47:57 2010 +0300
@@ -24,15 +24,15 @@
 
 HS_STATES_TEST_CLASS(MenuStatesTest)
 
-class HsMenuView;
+class HbView;
+
 class HsMainWindow
 {
-
 public:
     HsMainWindow();
     virtual ~HsMainWindow();
 
-    virtual void setCurrentView(const HsMenuView &menuView);     
+    virtual void setCurrentView(HbView *view);
 
 };
 
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h	Fri Jul 23 13:47:57 2010 +0300
@@ -26,6 +26,7 @@
 #include <HbAbstractItemView>
 #include "hsmenustates_global.h"
 #include "hsmenuviewbuilder.h"
+#include "hssearchview.h"
 #include "hsapp_defs.h"
 
 class QPointF;
@@ -33,32 +34,29 @@
 class HbView;
 class HbMainWindow;
 class HbAction;
-class HbAbstractItemView;
 class HbListView;
 class HbGroupBox;
 class HbWidget;
 class HbShrinkingVkbHost;
+class HsMainWindow;
 class HsMenuItemModel;
 
+HS_STATES_TEST_CLASS(MenuStatesTest)
 
-HS_STATES_TEST_CLASS(MenuStatesTest)
 
 class HsMenuView: public QObject
 {
     Q_OBJECT
 
 public:
-    HsMenuView(HsMenuViewBuilder &builder, HsViewContext viewContext);
+    HsMenuView(HsMenuViewBuilder &builder, HsStateContext stateContext,
+               HsMainWindow& mainWindow);
     ~HsMenuView();
 
-    void setSearchPanelVisible(bool visible);
-    void setContext(HsViewContext viewContext,
-                    HsOperationalContext context);
-
     HbView *view() const;
 
     HbListView *listView() const;
-    HbPushButton *collectionButton() const;
+    HbPushButton *contentButton() const;
 
     void activate();
     void inactivate();
@@ -67,63 +65,42 @@
 
     void setModel(HsMenuItemModel *model);
 
-
+    void reset(HsOperationalContext operationalContext);
 signals:
     void activated(const QModelIndex &index);
     void longPressed(HbAbstractViewItem *item, const QPointF &coords);
-
+    void listViewChange();
 public slots:
 
-    void activatedProxySlot(const QModelIndex &index);
-    void longPressedProxySlot(HbAbstractViewItem *item,
-                              const QPointF &coords);
-
     void showSearchPanel();
     void hideSearchPanel();
 
     void disableSearch(bool disable);
 
-
 private slots:
     void scrollToRow(int row,
                      QAbstractItemView::ScrollHint hint =
                          QAbstractItemView::PositionAtTop);
-    void findItem(QString criteriaStr);
-
-private:
-
-    QModelIndex firstVisibleItemIndex(const HbListView *view) const;
-
-    void connectSearchPanelSignals();
-    void disconnectSearchPanelSignals();
-    void connectSearchItemViewsSignals();
-    void disconnectSearchItemViewsSignals();
-
-    void searchFinished();
-    void searchBegins();
-    HbAbstractItemView::ScrollHint convertScrollHint(
-        QAbstractItemView::ScrollHint hint);
 
 private:
 
-    const HsViewContext mViewContext;
-    HsMenuViewBuilder &mBuilder;
-
-    QModelIndex mSearchViewInitialIndex;
-    QModelIndex mIndexToScrollAfterSearchDone;
-    QModelIndex mSearchViewLongPressedIndex;
-
-    QSortFilterProxyModel *mProxyModel; // owned
+    HbAbstractItemView::ScrollHint convertScrollHint(
+        QAbstractItemView::ScrollHint hint);
 
-    HbView *mView;
-    HbListView *mListView;
-    HbGroupBox *mViewLabel;
+    void switchBuilderContext();
+    void synchronizeCache();
+private:
+    HsMenuViewBuilder &mBuilder;
+    const HsStateContext mStateContext;
+    HsOperationalContext mOperationalContext;
+    HsMainWindow &mMainWindow;
 
-    HbListView *mSearchListView;
-    HbSearchPanel *mSearchPanel;
-    QScopedPointer<HbShrinkingVkbHost> mVkbHost;
+    HbView *mView; // once this is constructed it is not NULL
+    HbListView *mListView; // may be NULL in some contexts
+    HbGroupBox *mViewLabel; // may be NULL in some contexts
+    HbPushButton *mAddContentButton; // may be NULL in some contexts
 
-    HbPushButton *mCollectionButton;
+    QScopedPointer<HsSearchView> mHsSearchView;
 
     HS_STATES_TEST_FRIEND_CLASS(MenuStatesTest)
 };
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuviewbuilder.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuviewbuilder.h	Fri Jul 23 13:47:57 2010 +0300
@@ -20,7 +20,9 @@
 
 #include <QFlags>
 #include <QMap>
+#include <QPair>
 #include <QSet>
+#include <QSharedPointer>
 #include <QString>
 #include <qnamespace.h>
 #include <HbDocumentLoader>
@@ -38,18 +40,20 @@
 class HbToolBarExtension;
 class HbPushButton;
 
-enum HsViewContext {
-    HsAllAppsContext,
+enum HsStateContext {
+    HsAllAppsContext = 0,
     HsAllCollectionsContext,
     HsInstalledAppsContext,
     HsCollectionContext,
+    InvalidStateContext
 };
 
 enum HsOperationalContext {
-    HsItemViewContext,
+    HsItemViewContext = 0,
     HsSearchContext,
     HsButtonContext,
-    HsEmptyLabelContext
+    HsEmptyLabelContext,
+    InvalidOperationalContext
 };
 
 HS_STATES_TEST_CLASS(MenuStatesTest)
@@ -71,37 +75,33 @@
     HbToolBarExtension *toolBarExtension() const;
 
     // mandatory context dependent widgets accessors
-    HbView *currentView() const;
-    HbListView *currentListView() const;
+    HbView *currentView();
+    HbListView *currentListView();
 
 
     // optional widgets accessors
-    HbGroupBox *currentViewLabel() const;
-    HbSearchPanel *currentSearchPanel() const;
-    HbPushButton *collectionButton() const;
+    HbGroupBox *currentViewLabel();
+    HbSearchPanel *currentSearchPanel();
+    HbPushButton *currentAddContentButton();
 
 
-    void setViewContext(HsViewContext viewContext);
+    void setStateContext(HsStateContext stateContext);
     void setOperationalContext(HsOperationalContext operationalContext);
-    bool build();
 
 private:
-    void init();
+    typedef QPair<HsStateContext, HsOperationalContext> Context;
+    typedef QMap<Context, QSharedPointer<HbDocumentLoader> > LoaderMap;
+
+    QSharedPointer<HbDocumentLoader>
+            parseDocument(const QString &documentBaseName);
 
-    bool parseSection(const QString &sectionName = QString());
+    QSharedPointer<HbDocumentLoader> readContextConfiguration();
 
+    Context context() const;
 
-    bool readContextConfiguration(HsViewContext, HsOperationalContext);
+    QSharedPointer<HbDocumentLoader> currentLoader();
 
 
-    void searchPanelVisibilityChange(bool visible);
-
-    HbLineEdit *searchPanelLineEdit() const;
-
-    QMap<HsViewContext, QString > mViewContextToStringMap;
-    QMap<HsOperationalContext, QString > mOperationalContextToStringMap;
-
-    HbDocumentLoader mDocumentLoader;
     QSet<QObject *> mLoadedObjects;
 
     const QString DOCUMENT_FILE_NAME;
@@ -119,10 +119,13 @@
     HbToolBarExtension *mToolBarExtension;
     HbAction *mToolBarExtensionAction;
 
-    HsViewContext mViewContext;
+    HsStateContext mStateContext;
     HsOperationalContext mOperationalContext;
 
     HS_STATES_TEST_FRIEND_CLASS(MenuStatesTest)
+
+    LoaderMap mLoaderMap;
+    QSharedPointer<HbDocumentLoader> mCommonObjectsLoader;
 };
 
 #endif // HSMENUVIEWBUILDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hssearchview.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Search view.
+ *
+ */
+
+#ifndef HSSEARCHVIEW_H
+#define HSSEARCHVIEW_H
+
+#include <QModelIndex>
+#include <QScopedPointer>
+
+#include <HbShrinkingVkbHost>
+
+#include "hsmenustates_global.h"
+#include "hsmenuviewbuilder.h"
+
+class QSortFilterProxyModel;
+class HsMainWindow;
+class HbAbstractViewItem;
+class HbLineEdit;
+class HbSearchPanel;
+
+HS_STATES_TEST_CLASS(MenuStatesTest)
+
+class HsSearchView : public QObject
+{
+    Q_OBJECT
+
+    HS_STATES_TEST_FRIEND_CLASS(MenuStatesTest)
+
+public:
+
+    HsSearchView(
+            HsMenuViewBuilder &builder,
+            HsStateContext stateContext,
+            HsMainWindow &mainWindow);
+    ~HsSearchView();
+
+    void setSearchPanelVisible(bool visible);
+    bool isActive() const;
+private:
+
+    QModelIndex firstVisibleItemIndex(const HbListView *view) const;
+    void searchBegins();
+
+    void connectSearchItemViewsSignals();
+    void disconnectSearchItemViewsSignals();
+
+    void connectSearchPanelSignals();
+
+    void disconnectSearchPanelSignals();
+
+    void searchFinished();
+
+signals:
+    void activated(const QModelIndex &index);
+    void longPressed(HbAbstractViewItem *item, const QPointF &coords);
+
+public slots:
+    void hideSearchPanel();
+    void activatedProxySlot(const QModelIndex &index);
+    void longPressedProxySlot(
+            HbAbstractViewItem *item, const QPointF &coords);
+
+private slots:
+    void findItem(QString criteriaStr);
+private:
+    void setOriginatingContext();
+    void setSearchContext();
+    void initSearchPanel(HbSearchPanel &searchPanel);
+    HbLineEdit *searchPanelLineEdit(HbSearchPanel &searchPanel) const;
+
+private:
+
+    QModelIndex mSearchViewInitialIndex;
+    QModelIndex mIndexToScrollAfterSearchDone;
+    QModelIndex mSearchViewLongPressedIndex;
+    QSortFilterProxyModel *mProxyModel; // owned
+    HbView *mSearchView;
+    HbListView *mSearchListView;
+    HbSearchPanel *mSearchPanel;
+    const HsStateContext mStateContext;
+    HsOperationalContext mAfterSearchContext;
+    HsMenuViewBuilder &mBuilder;
+    HsMainWindow &mMainWindow;
+    HbListView *mListView;
+    QScopedPointer<HbShrinkingVkbHost> mVkbHost;
+
+};
+
+#endif /* HSSEARCHVIEW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/addcontentlabeledview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <widget name="view" type="HbView">
+        <widget name="container" role="HbView:widget" type="HbWidget">
+            <widget name="label" type="HbGroupBox">
+                <string name="heading" value="."/>
+                <bool name="marqueeHeading" value="TRUE"/>
+                <fontspec name="fontSpec" role="Title" textheight="0"/>
+            </widget>
+            <widget name="buttonContainer" type="HbWidget">
+                <widget name="addContentButton" type="HbPushButton">
+                    <string locid="txt_applib_button_add_to_collection" name="text"/>
+                    <bool name="checkable" value="TRUE"/>
+                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+                </widget>
+                <layout orientation="Horizontal" spacing="0.0un" type="linear">
+                    <stretchitem stretchfactor="1"/>
+                    <linearitem itemname="addContentButton" stretchfactor="5"/>
+                    <stretchitem stretchfactor="1"/>
+                </layout>
+            </widget>
+            <layout orientation="Vertical" spacing="0.0un" type="linear">
+                <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                <linearitem itemname="label"/>
+                <stretchitem stretchfactor="1"/>
+                <linearitem itemname="buttonContainer"/>
+                <stretchitem stretchfactor="5"/>
+            </layout>
+        </widget>
+        <string locid="txt_applib_title_applications" name="title"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/common_objects.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="allAppsAction" type="HbAction">
+        <bool name="checkable" value="TRUE"/>
+        <icon iconName="qtg_mono_applications_all" name="icon"/>
+    </object>
+    <object name="allCollectionsAction" type="HbAction">
+        <bool name="checkable" value="TRUE"/>
+        <icon iconName="qtg_mono_applications_collections" name="icon"/>
+    </object>
+    <object name="searchAction" type="HbAction">
+        <icon iconName="qtg_mono_search" name="icon"/>
+    </object>
+    <object name="oviStoreAction" type="HbAction">
+        <icon iconName="qtg_mono_ovistore" name="icon"/>
+    </object>
+    <object name="operatorAction" type="HbAction"/>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/emptylabeledview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+        <widget name="view" type="HbView">
+            <widget name="container" role="HbView:widget" type="HbWidget">
+                <widget name="label" type="HbGroupBox">
+                    <string name="heading" value="."/>
+                    <bool name="marqueeHeading" value="TRUE"/>
+                    <fontspec name="fontSpec" role="Title" textheight="0"/>
+                </widget>
+                <widget name="emptyViewLabelContainer" type="HbWidget">
+                    <widget name="emptyViewLabel" type="HbLabel">
+                        <enums name="alignment" value="AlignHCenter"/>
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
+                        <enums name="elideMode" value="ElideMiddle"/>
+                        <bool name="visible" value="TRUE"/>
+                        <string locid="txt_applib_formlabel_empty" name="plainText"/>
+                        <fontspec name="fontSpec" role="Title" textheight="4un"/>
+                    </widget>
+                    <layout orientation="Horizontal" spacing="0.0un" type="linear">
+                        <stretchitem stretchfactor="1"/>
+                        <linearitem itemname="emptyViewLabel"/>
+                        <stretchitem stretchfactor="1"/>
+                    </layout>
+                </widget>
+                <layout orientation="Vertical" spacing="0.0un" type="linear">
+                    <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                    <linearitem itemname="label"/>
+                    <stretchitem stretchfactor="1"/>
+                    <linearitem itemname="emptyViewLabelContainer"/>
+                    <stretchitem stretchfactor="5"/>
+                </layout>
+            </widget>
+            <string locid="txt_applib_title_applications" name="title"/>
+        </widget>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledlistview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+        <widget name="view" type="HbView">
+            <widget name="container" role="HbView:widget" type="HbWidget">
+                <widget name="label" type="HbGroupBox">
+                    <string name="heading" value="."/>
+                    <bool name="marqueeHeading" value="TRUE"/>
+                    <fontspec name="fontSpec" role="Title" textheight="0"/>
+                </widget>
+                <widget name="listView" type="HbListView">
+                     <bool name="itemRecycling" value="TRUE"/>
+                     <enums name="horizontalScrollBarPolicy" value="ScrollBarAutoHide"/>
+                     <bool name="frictionEnabled" value="TRUE"/>
+                 </widget>
+                <layout orientation="Vertical" spacing="0.0un" type="linear">
+                    <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                    <linearitem itemname="label"/>
+                    <linearitem itemname="listView"/>
+                </layout>
+            </widget>
+            <string locid="txt_applib_title_applications" name="title"/>
+        </widget>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledsearchview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+        <widget name="view" type="HbView">
+            <widget name="container" role="HbView:widget" type="HbWidget">
+                <widget name="label" type="HbGroupBox">
+                </widget>
+                <widget name="searchPanel" type="HbSearchPanel">
+                </widget>
+                <widget name="listView" type="HblistView">
+                    <sizehint height="0un" type="MAXIMUM" width="0un"/>
+                </widget>
+                <layout orientation="Vertical" spacing="0.0un" type="linear">
+                    <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                    <linearitem itemname="label"/>
+                    <linearitem itemname="listView"/>
+                    <linearitem itemname="searchPanel"/>
+                </layout>
+            </widget>
+            <string locid="txt_applib_title_applications" name="title"/>
+            <bool name="contentFullScreen" value="TRUE"/>
+        </widget>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/listview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <widget name="view" type="HbView">
+        <widget name="container" role="HbView:widget" type="HbWidget">
+            <widget name="listView" type="HbListView">
+                <bool name="itemRecycling" value="TRUE"/>
+                <enums name="horizontalScrollBarPolicy" value="ScrollBarAutoHide"/>
+                <bool name="frictionEnabled" value="TRUE"/>
+            </widget>
+            <layout orientation="Vertical" spacing="0.0un" type="linear">
+                <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                <linearitem itemname="listView"/>
+            </layout>
+        </widget>
+        <string locid="txt_applib_title_applications" name="title"/>
+    </widget>
+</hbdocument>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlabeledlistview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+        <widget name="view" type="HbView">
+            <widget name="container" role="HbView:widget" type="HbWidget">
+                <widget name="label" type="HbGroupBox">
+                    <string name="heading" value="."/>
+                    <bool name="marqueeHeading" value="TRUE"/>
+                    <fontspec name="fontSpec" role="Title" textheight="0"/>
+                </widget>
+                <widget name="searchPanel" type="HbSearchPanel"/>
+                <widget name="listView" type="HbListView">
+                     <bool name="itemRecycling" value="TRUE"/>
+                     <enums name="horizontalScrollBarPolicy" value="ScrollBarAutoHide"/>
+                     <bool name="frictionEnabled" value="TRUE"/>
+                 </widget>
+                <layout orientation="Vertical" spacing="0.0un" type="linear">
+                    <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                    <linearitem itemname="label"/>
+                    <linearitem itemname="listView"/>
+                    <linearitem itemname="searchPanel"/>
+                </layout>
+            </widget>
+        <string locid="txt_applib_title_applications" name="title"/>
+        <bool name="contentFullScreen" value="TRUE"/>
+    </widget>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlistview.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+     <widget name="view" type="HbView">
+         <widget name="container" role="HbView:widget" type="HbWidget">
+             <widget name="searchPanel" type="HbSearchPanel"/>
+             <widget name="listView" type="HbListView">
+                 <bool name="itemRecycling" value="TRUE"/>
+                 <enums name="horizontalScrollBarPolicy" value="ScrollBarAutoHide"/>
+                 <bool name="frictionEnabled" value="TRUE"/>
+             </widget>
+             <layout orientation="Vertical" spacing="0.0un" type="linear">
+                 <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                 <linearitem itemname="listView"/>
+                 <linearitem itemname="searchPanel"/>
+             </layout>
+         </widget>
+         <string locid="txt_applib_title_applications" name="title"/>
+         <bool name="contentFullScreen" value="TRUE"/>
+     </widget>
+</hbdocument>
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -175,7 +175,7 @@
     HSMENUTEST_FUNC_ENTRY("HsAllAppsState::stateExited");
 
     HsBaseViewState::stateExited();
-    
+
     HSMENUTEST_FUNC_EXIT("HsAllAppsState::stateExited");
     qDebug("AllAppsState::stateExited()");
 }
@@ -198,7 +198,7 @@
  */
 void HsAllAppsState::contextMenuAction(HbAction *action)
 {
-    HsContextAction command = 
+    HsContextAction command =
         static_cast<HsContextAction>(action->data().toInt());
 
     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
@@ -218,18 +218,21 @@
             machine()->postEvent(
                 HsMenuEventFactory::createUninstallApplicationEvent(itemId));
             break;
-        case AppSettingContextAction: 
+        case AppSettingContextAction:
             machine()->postEvent(
                 HsMenuEventFactory::createAppSettingsViewEvent(itemId));
             break;
-        case AppDetailsContextAction: 
+        case AppDetailsContextAction:
             machine()->postEvent(
                 HsMenuEventFactory::createAppDetailsViewEvent(itemId));
-            break;            
+            break;
+        case OpenContextAction:
+            launchItem(mContextModelIndex);
+            break;
         default:
             break;
     }
-    mMenuView->setSearchPanelVisible(false);
+    mMenuView->hideSearchPanel();
 }
 
 /*!
@@ -298,6 +301,10 @@
  */
 void HsAllAppsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
 {
+    HbAction *openAction = mContextMenu->addAction(hbTrId(
+        "txt_common_menu_open"));
+    openAction->setData(OpenContextAction);
+
     HbAction *addToHomeScreenAction = mContextMenu->addAction(
         hbTrId("txt_applib_menu_add_to_home_screen"));
     addToHomeScreenAction->setData(AddToHomeScreenContextAction);
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -14,6 +14,7 @@
  * Description: Menu All Collections state.
  *
  */
+#include <QPointF>
 #include <QScopedPointer>
 #include <QStateMachine>
 #include <HbView>
@@ -24,12 +25,12 @@
 
 #include <cadefs.h>
 
+#include "hsmenumodewrapper.h"
 #include "hsmenueventfactory.h"
 #include "hsmenumodewrapper.h"
 #include "hsmenuitemmodel.h"
 #include "hsallcollectionsstate.h"
 #include "hsaddappstocollectionstate.h"
-//#include "hsmenumodetransition.h"
 #include "hsmainwindow.h"
 
 /*!
@@ -107,6 +108,11 @@
 void HsAllCollectionsState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
 {
     Q_UNUSED(item)
+
+    HbAction *openAction = mContextMenu->addAction(hbTrId(
+        "txt_common_menu_open"));
+    openAction->setData(OpenContextAction);
+
     // create context menu
     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
                                       "txt_applib_menu_add_to_home_screen"));
@@ -200,7 +206,7 @@
  */
 void HsAllCollectionsState::contextMenuAction(HbAction *action)
 {
-    HsContextAction command = 
+    HsContextAction command =
         static_cast<HsContextAction>(action->data().toInt());
 
     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
@@ -209,7 +215,9 @@
         case AddToHomeScreenContextAction:
             machine()->postEvent(
                 HsMenuEventFactory::createAddToHomeScreenEvent(
-                    itemId, mMenuMode->getHsMenuMode(), mMenuMode->getHsToken()));
+                    itemId,
+                    mMenuMode->getHsMenuMode(),
+                    mMenuMode->getHsToken()));
             break;
         case RenameContextAction:
             machine()->postEvent(
@@ -218,12 +226,15 @@
         case DeleteContextAction:
              machine()->postEvent(
                 HsMenuEventFactory::createDeleteCollectionEvent(itemId));
-            break;      
+            break;
+        case OpenContextAction:
+            openCollection(mContextModelIndex);
+            break;
         default:
             break;
     }
-                                    
-    mMenuView->setSearchPanelVisible(false);
+
+    mMenuView->hideSearchPanel();
 }
 
 /*!
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -15,6 +15,7 @@
  *
  */
 
+#include <QScopedPointer>
 #include <QStateMachine>
 #include <HbMessageBox>
 #include <HbParameterLengthLimiter>
@@ -31,6 +32,7 @@
 #include "hsmenudialogfactory.h"
 #include "hsmenuitemmodel.h"
 #include "hsmenumodetransition.h"
+#include "hsmenuentryremovedhandler.h"
 #include "hsmainwindow.h"
 
 
@@ -41,8 +43,6 @@
  */
 HsBaseViewState::HsBaseViewState(HsMainWindow &mainWindow, QState *parent):
     QState(parent),
-    mNotifier(0),
-    mMessageRelatedItemId(0),
     mApplicationLaunchFailMessage(0),
     mModel(0),
     mContextMenu(0),
@@ -61,12 +61,10 @@
  \param menuMode menu mode object.
  \param parent Owner.
  */
-HsBaseViewState::HsBaseViewState(HsMainWindow &mainWindow, 
-    HsMenuModeWrapper& menuMode, 
+HsBaseViewState::HsBaseViewState(HsMainWindow &mainWindow,
+    HsMenuModeWrapper& menuMode,
     QState *parent):
     QState(parent),
-    mNotifier(0),
-    mMessageRelatedItemId(0),
     mApplicationLaunchFailMessage(0),
     mModel(0),
     mContextMenu(0),
@@ -81,12 +79,13 @@
 /*!
  Initialize contained objects.
  \param menuViewBuilder object providing widgets for menu view.
- \param viewContext state context of the view the builder is to provide widgets for.
+ \param stateContext state context of the view the builder
+     is to provide widgets for.
  */
-void HsBaseViewState::initialize(HsMenuViewBuilder &menuViewBuilder, 
-    HsViewContext viewContext)
+void HsBaseViewState::initialize(HsMenuViewBuilder &menuViewBuilder,
+    HsStateContext stateContext)
 {
-    mMenuView.reset(new HsMenuView(menuViewBuilder, viewContext));
+    mMenuView.reset(new HsMenuView(menuViewBuilder, stateContext, mMainWindow));
     mMenuView->view()->setNavigationAction(mBackKeyAction);
 
     connect(this, SIGNAL(entered()),SLOT(stateEntered()));
@@ -105,73 +104,29 @@
     message.append(
         HbParameterLengthLimiter("txt_applib_info_launching_the_application_failed").arg(
             errorCode));
-    
-    mMessageRelatedItemId = itemId;
 
     // create and show message box
-    mApplicationLaunchFailMessage = HsMenuDialogFactory().create(message, HsMenuDialogFactory::Close);
-
-    mApplicationLaunchFailMessage->open(this, SLOT(applicationLaunchFailMessageFinished(HbAction*)));
-    
-    subscribeForMemoryCardRemove();
-}
-
-/*!
- Subscribe for memory card remove.
- */
-void HsBaseViewState::subscribeForMemoryCardRemove()
-{
-    if (mMessageRelatedItemId !=0 ) {
-        CaNotifierFilter filter;
-        filter.setIds(QList<int>() << mMessageRelatedItemId);
-        mNotifier = CaService::instance()->createNotifier(filter);
-        mNotifier->setParent(this);
-        connect(mNotifier,
-            SIGNAL(entryChanged(CaEntry,ChangeType)),
-            SLOT(cleanUpApplicationLaunchFailMessage()));
-    }
-}
+    mApplicationLaunchFailMessage = HsMenuDialogFactory().create(
+            message, HsMenuDialogFactory::Close);
 
-/*!
- Clean up application launch fail message box.
- \retval void
- */
-void HsBaseViewState::cleanUpApplicationLaunchFailMessage()
-{
-    if (mApplicationLaunchFailMessage) {
-        mApplicationLaunchFailMessage->close();
-        mApplicationLaunchFailMessage = NULL;
-    }
-    if (mNotifier) {
-        delete mNotifier;
-        mNotifier = NULL;
-    }
-    mMessageRelatedItemId = 0;
+    QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+        new HsMenuEntryRemovedHandler(itemId, mApplicationLaunchFailMessage.data(), SLOT(close())));
+
+    entryObserver.take()->setParent(mApplicationLaunchFailMessage.data());
+
+    mApplicationLaunchFailMessage->open();
 }
 
 /*!
- Action after closed application launch fail dialog.
- \param finishedAction chosen action.
- \retval void
- */
-void HsBaseViewState::applicationLaunchFailMessageFinished(HbAction*)
-{
-    mApplicationLaunchFailMessage = NULL;
-    cleanUpApplicationLaunchFailMessage();
-}
-
-
-/*!
  Slot invoked when a state is entered.
  */
 void HsBaseViewState::stateEntered()
 {
     qDebug("HsBaseViewState::stateEntered()");
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::stateEntered");
-
-    mMainWindow.setCurrentView(*mMenuView);
     mMenuView->activate();
-
+    connect(mMenuView.data(), SIGNAL(listViewChange()),
+            this, SLOT(closeContextMenu()));
     HSMENUTEST_FUNC_EXIT("HsBaseViewState::stateEntered");
 }
 
@@ -181,14 +136,15 @@
 void HsBaseViewState::stateExited()
 {
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::stateExited");
-    mMenuView->setSearchPanelVisible(false);
+
+    mMenuView->hideSearchPanel();
     mMenuView->disconnect(this);
     mMenuView->view()->setMenu(NULL);
     mMenuView->inactivate();
-    cleanUpApplicationLaunchFailMessage();
-    if (mContextMenu){
-        mContextMenu->close();
+    if (!mApplicationLaunchFailMessage.isNull()) {
+        mApplicationLaunchFailMessage->close();
     }
+    closeContextMenu();
     HSMENUTEST_FUNC_EXIT("HsBaseViewState::stateExited");
 }
 
@@ -225,7 +181,6 @@
  */
 HsBaseViewState::~HsBaseViewState()
 {
-    mMenuView->setModel(NULL);
     delete mModel;
 }
 
@@ -238,28 +193,23 @@
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::launchItem");
 
     QSharedPointer<const CaEntry> entry = mModel->entry(index);
-
-    if (entry->entryTypeName() == widgetTypeName()) {
-        EntryFlags flags = index.data(CaItemModel::FlagsRole).value<
-                               EntryFlags> ();
-        if (!(flags & UninstallEntryFlag)) {
-            machine()->postEvent(
-                HsMenuEventFactory::createPreviewHSWidgetEvent(
-                    entry->id(), entry->entryTypeName(), entry->attribute(
-                        widgetUriAttributeName()), entry->attribute(
-                        widgetLibraryAttributeName())));
-
-            const int itemId = index.data(CaItemModel::IdRole).toInt();
-            HsMenuService::touch(itemId);
+    if (!entry.isNull()) {
+        if (entry->entryTypeName() == widgetTypeName()) {
+            EntryFlags flags = entry->flags();
+            if (!(flags & UninstallEntryFlag)) {
+                machine()->postEvent(HsMenuEventFactory::createPreviewHSWidgetEvent(entry->id(),
+                    entry->entryTypeName(), entry->attribute(widgetUriAttributeName()),
+                    entry->attribute(widgetLibraryAttributeName())));
+                HsMenuService::touch(entry->id());
+            }
         }
-    } else {
-        QVariant data = mModel->data(index, CaItemModel::IdRole);
-        int errCode = HsMenuService::executeAction(data.toInt());
-        if (errCode != 0) {
-            createApplicationLaunchFailMessage(errCode,index.data(CaItemModel::IdRole).toInt());
+        else {
+            int errCode = HsMenuService::executeAction(entry->id());
+            if (errCode != 0) {
+                createApplicationLaunchFailMessage(errCode, entry->id());
+            }
         }
     }
-
     HSMENUTEST_FUNC_EXIT("HsBaseViewState::launchItem");
 }
 
@@ -272,13 +222,13 @@
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::openCollection");
     QVariant data = mModel->data(index, CaItemModel::IdRole);
     int id = data.toInt();
-    QString collectionType =
-        mModel->data(index, CaItemModel::TypeRole).toString();
-    qDebug("HsBaseViewState::openCollection - MCS ID: %d",
-           data.toInt());
+    QString collectionType = mModel->data(
+            index, CaItemModel::TypeRole).toString();
+    qDebug("HsBaseViewState::openCollection - MCS ID: %d", data.toInt());
 
-    machine()->postEvent(HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(id,
-                         collectionType));
+    machine()->postEvent(
+            HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(
+                    id, collectionType));
     HSMENUTEST_FUNC_EXIT("HsBaseViewState::openCollection");
 }
 
@@ -288,11 +238,10 @@
  */
 void HsBaseViewState::showContextMenu(HbAbstractViewItem *item, const QPointF &coords)
 {
-
     HSMENUTEST_FUNC_ENTRY("HsBaseViewState::showContextMenu");
 
     EntryFlags flags = item->modelIndex().data(
-                           CaItemModel::FlagsRole).value<EntryFlags> ();
+            CaItemModel::FlagsRole).value<EntryFlags> ();
 
     if (!(flags & UninstallEntryFlag)) {
         mContextMenu = new HbMenu;
@@ -335,13 +284,23 @@
     }
     return errCode;
 }
+
+/*!
+ close context menu
+ */
+void HsBaseViewState::closeContextMenu()
+{
+    if (mContextMenu) {
+        mContextMenu->close();
+    }    
+}
 /*!
  Scrolls view to first item at top
  */
 void HsBaseViewState::scrollToBeginning()
 {
     mMenuView->listView()->scrollTo(
-        mModel->index(0), HbAbstractItemView::PositionAtTop);
+            mModel->index(0), HbAbstractItemView::PositionAtTop);
 }
 
 /*!
@@ -367,7 +326,7 @@
     connect(normalModeState, SIGNAL(exited()),SLOT(normalModeExited()));
 
     initialState->addTransition(new HsMenuModeTransition(
-                                    *mMenuMode, NormalHsMenuMode, normalModeState));
+            *mMenuMode, NormalHsMenuMode, normalModeState));
     initialState->addTransition(new HsMenuModeTransition(
-                                    *mMenuMode, AddHsMenuMode, addModeState));
+            *mMenuMode, AddHsMenuMode, addModeState));
 }
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -26,6 +26,7 @@
 
 #include <cadefs.h>
 #include <caentry.h>
+#include <caitemmodel.h>
 
 #include "hsapp_defs.h"
 #include "hsmenuevent.h"
@@ -103,8 +104,6 @@
         parent() != 0 ? parent()->objectName() : QString("");
     setObjectName(parentName + "/collectionstate");
 
-    mMenuView->collectionButton()->setCheckable(true);
-
     HSMENUTEST_FUNC_EXIT("HsCollectionState::construct");
 }
 
@@ -144,45 +143,20 @@
 void HsCollectionState::stateEntered()
 {
     HSMENUTEST_FUNC_ENTRY("HsCollectionState::stateEntered");
-    HsBaseViewState::stateEntered();
-    makeConnect();
     if (!mModel) {
         mModel =
             HsMenuService::getCollectionModel(
                 mCollectionId, mSortAttribute, mCollectionType);
     }
 
-    EntryFlags flags =
-        mModel->root().data(CaItemModel::FlagsRole).value<
-        EntryFlags> ();
-
-    if (mModel->rowCount() == 0){
-        if (flags & RemovableEntryFlag){
-            mMenuView->setContext(HsCollectionContext,HsButtonContext);
-        } else {
-            mMenuView->setContext(HsCollectionContext,HsEmptyLabelContext);
-        }
-        mMenuView->disableSearch(true);
-    } else {
-        mMenuView->setContext(HsCollectionContext,HsItemViewContext);
-        mMenuView->disableSearch(false);
-    }
+    handleEmptyChange(mModel->rowCount() == 0);
 
-    connect(mModel, SIGNAL(modelReset()), SLOT(updateLabel()));
-    connect(mModel, SIGNAL(empty(bool)),this,
-            SLOT(handleEmptyChange(bool)));
-    connect(mModel, SIGNAL(empty(bool)),this,
-            SLOT(lockSearchButton(bool)));
-
-    mMenuView->setModel(mModel);
+    makeConnect();
+    
+    mMenuView->viewLabel()->setHeading(
+        mModel->root().data(CaItemModel::CollectionTitleRole).toString());
 
-    mMenuView->listView()->scrollTo(
-        mModel->index(0), HbAbstractItemView::PositionAtTop);
-
-    mMenuView->viewLabel()->setHeading(
-        mModel->root().data(Qt::DisplayRole).toString());
-    setMenuOptions();
-
+    HsBaseViewState::stateEntered();
     HSMENUTEST_FUNC_EXIT("HsCollectionState::stateEntered");
 }
 
@@ -257,16 +231,9 @@
 void HsCollectionState::stateExited()
 {
     HSMENUTEST_FUNC_ENTRY("HsCollectionState::stateExited");
+    mMenuView->disableSearch(false);
     makeDisconnect();
-    mMenuView->disableSearch(false);
-    disconnect(mModel, SIGNAL(empty(bool)),this,
-               SLOT(handleEmptyChange(bool)));
 
-    disconnect(mModel, SIGNAL(empty(bool)),this,
-               SLOT(lockSearchButton(bool)));
-
-    disconnect(mModel, SIGNAL(modelReset()),
-                   this, SLOT(updateLabel()));
     delete mModel;
     mModel = NULL;
     this->mSortAttribute = NoHsSortAttribute;
@@ -296,8 +263,11 @@
             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
             static_cast<HsBaseViewState*>(this),
             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
-    connect(mMenuView->collectionButton(),
-            SIGNAL(toggled(bool)), this, SLOT(addAppsAction(bool)));
+    connect(mModel, SIGNAL(modelReset()), SLOT(updateLabel()));
+    connect(mModel, SIGNAL(empty(bool)),this,
+            SLOT(handleEmptyChange(bool)));
+    connect(mModel, SIGNAL(empty(bool)),this,
+            SLOT(lockSearchButton(bool)));
 }
 
 /*!
@@ -305,9 +275,6 @@
  */
 void HsCollectionState::makeDisconnect()
 {
-    disconnect(mMenuView->collectionButton(),
-            SIGNAL(toggled(bool)), this, SLOT(addAppsAction(bool)));
-
     disconnect(mBackKeyAction, SIGNAL(triggered()),
                static_cast<HsBaseViewState*>(this), SLOT(openAppLibrary()));
 
@@ -323,6 +290,14 @@
                SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
                static_cast<HsBaseViewState*>(this),
                SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
+    disconnect(mModel, SIGNAL(empty(bool)),this,
+               SLOT(handleEmptyChange(bool)));
+
+    disconnect(mModel, SIGNAL(empty(bool)),this,
+               SLOT(lockSearchButton(bool)));
+
+    disconnect(mModel, SIGNAL(modelReset()),
+                   this, SLOT(updateLabel()));
 }
 
 /*!
@@ -362,32 +337,48 @@
             machine()->postEvent(
                 HsMenuEventFactory::createAppDetailsViewEvent(itemId));
             break;
+        case OpenContextAction:
+            launchItem(mContextModelIndex);
+            break;
         default:
             break;
     }
 
-    mMenuView->setSearchPanelVisible(false);
+    mMenuView->hideSearchPanel();
 }
 
 /*!
- Handles button visibility
-  \param empty if true set empty text label or button to add entries to collection.
+ Handler to be called when model becomes not empty or model becomes empty.
+  \param empty \a true when model becomes empty \a false otherwise.
  */
 void HsCollectionState::handleEmptyChange(bool empty)
 {
+
     EntryFlags flags =
         mModel->root().data(CaItemModel::FlagsRole).value<
         EntryFlags> ();
 
     if (empty){
         if (flags & RemovableEntryFlag){
-            mMenuView->setContext(HsCollectionContext,HsButtonContext);
+            mMenuView->reset(HsButtonContext);
+            connect(mMenuView->contentButton(),
+                    SIGNAL(toggled(bool)), this, SLOT(addAppsAction(bool)),
+                    Qt::UniqueConnection);
         } else {
-            mMenuView->setContext(HsCollectionContext,HsEmptyLabelContext);
+            mMenuView->reset(HsEmptyLabelContext);
         }
+
     } else {
-        mMenuView->setContext(HsCollectionContext,HsItemViewContext);
+        mMenuView->reset(HsItemViewContext);
+        mMenuView->setModel(mModel);
+        mMenuView->listView()->scrollTo(
+            mModel->index(0), HbAbstractItemView::PositionAtTop);
     }
+	
+    mMenuView->disableSearch(empty);
+    
+    mMenuView->activate();
+
     setMenuOptions();
 }
 
@@ -411,7 +402,11 @@
 {
     // Add applications
     if (addApps) {
-        mMenuView->collectionButton()->setChecked(false);
+
+        if (mMenuView->contentButton()) {
+            mMenuView->contentButton()->setChecked(false);
+        }
+
         machine()->postEvent(
             HsMenuEventFactory::createAddAppsFromCollectionViewEvent(
                 mCollectionId));
@@ -476,15 +471,18 @@
 }
 
 /*!
- Method seting context menu options.
+ Method setting context menu options.
  */
 void HsCollectionState::setContextMenuOptions(HbAbstractViewItem *item, EntryFlags flags)
 {
+    HbAction *openAction = mContextMenu->addAction(hbTrId(
+        "txt_common_menu_open"));
+    openAction->setData(OpenContextAction);
     HbAction *addShortcutAction = mContextMenu->addAction(hbTrId(
-                                      "txt_applib_menu_add_to_home_screen"));
+        "txt_applib_menu_add_to_home_screen"));
     addShortcutAction->setData(AddToHomeScreenContextAction);
     HbAction *addToCollection = mContextMenu->addAction(hbTrId(
-                                    "txt_applib_menu_add_to_collection"));
+        "txt_applib_menu_add_to_collection"));
     addToCollection->setData(AddToCollectionContextAction);
     HbAction *removeAction(NULL);
     HbAction *uninstallAction(NULL);
@@ -553,12 +551,14 @@
     // Arrange collection via the Arrange view
     int topItemId(0);
 
-    const QList<HbAbstractViewItem *> array =
-        mMenuView->listView()->visibleItems();
+    if (mMenuView->listView() != NULL) {
+        const QList<HbAbstractViewItem *> array =
+            mMenuView->listView()->visibleItems();
 
-    if (array.count() >= 1) {
-        QModelIndex idx = array[0]->modelIndex();
-        topItemId = idx.data(CaItemModel::IdRole).toInt();
+        if (array.count() >= 1) {
+            QModelIndex idx = array[0]->modelIndex();
+            topItemId = idx.data(CaItemModel::IdRole).toInt();
+        }
     }
 
     machine()->postEvent(
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -132,21 +132,24 @@
     qDebug("AllAppsState::stateEntered()");
     HSMENUTEST_FUNC_ENTRY("HsInstalledAppsState::stateEntered");
 
-    HsBaseViewState::stateEntered();
-    setMenuOptions();
+    mMenuView->viewLabel()->setHeading(
+            hbTrId("txt_applib_subtitle_installed"));
+
     if (!mModel) {
         mModel
-        = HsMenuService::getInstalledModel(AscendingNameHsSortAttribute);
-        mMenuView->setModel(mModel);
+            = HsMenuService::getInstalledModel(AscendingNameHsSortAttribute);
     }
 
-    if (mModel->rowCount() == 0){
-        mMenuView->setContext(HsInstalledAppsContext,HsEmptyLabelContext);
-        }
-
-    mMenuView->listView()->scrollTo(
-        mModel->index(0));
-
+    if (mModel->rowCount() == 0) {
+        mMenuView->reset(HsEmptyLabelContext);
+    }
+    else {
+		mMenuView->reset(HsItemViewContext);
+        mMenuView->setModel(mModel);
+        mMenuView->listView()->scrollTo(
+            mModel->index(0));
+    }
+    setMenuOptions();
     connect(mMenuView.data(),
             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
@@ -154,6 +157,8 @@
     connect(mModel, SIGNAL(empty(bool)),this,
             SLOT(setEmptyLabelVisibility(bool)));
 
+    HsBaseViewState::stateEntered();
+
     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateEntered");
 }
 
@@ -172,7 +177,7 @@
             SLOT(showContextMenu(HbAbstractViewItem *, QPointF)));
 
     HsBaseViewState::stateExited();
-    
+
     HSMENUTEST_FUNC_EXIT("HsInstalledAppsState::stateExited");
     qDebug("AllAppsState::stateExited()");
 }
@@ -184,10 +189,12 @@
 void HsInstalledAppsState::setEmptyLabelVisibility(bool visibility)
 {
     if(visibility){
-        mMenuView->setContext(HsInstalledAppsContext,HsEmptyLabelContext);
+        mMenuView->reset(HsEmptyLabelContext);
     } else {
-        mMenuView->setContext(HsInstalledAppsContext,HsItemViewContext);
+        mMenuView->reset(HsItemViewContext);
+        mMenuView->setModel(mModel);
     }
+    mMenuView->activate();
 }
 
 /*!
@@ -204,24 +211,24 @@
  \param action to handle.
  */
 void HsInstalledAppsState::contextMenuAction(HbAction *action)
-{    
-    HsContextAction command = 
+{
+    HsContextAction command =
             static_cast<HsContextAction>(action->data().toInt());
-    
+
     const int itemId = mContextModelIndex.data(CaItemModel::IdRole).toInt();
-    
+
     switch (command) {
         case UninstallContextAction:
             machine()->postEvent(
                 HsMenuEventFactory::createUninstallApplicationEvent(
                     itemId));
             break;
-        case AppDetailsContextAction: 
+        case AppDetailsContextAction:
             machine()->postEvent(
                 HsMenuEventFactory::createAppDetailsViewEvent(itemId));
-            break;            
+            break;
         default:
-            break;            
+            break;
     }
-    mMenuView->setSearchPanelVisible(false);
+    mMenuView->hideSearchPanel();
 }
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmainwindow.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmainwindow.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -51,12 +51,10 @@
  Add the \menuView to first instance of HbMainWindow registered in HbInstance.
  \param view View to be added to HbMainWindow.
 */
-void HsMainWindow::setCurrentView(const HsMenuView &menuView)
+void HsMainWindow::setCurrentView(HbView *view)
 {
     HbMainWindow *const hbW(
         HbInstance::instance()->allMainWindows().value(0));
-
-    HbView *const view = menuView.view();
     
     if (!hbW->views().contains(view)) {
         hbW->addView(view);
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -33,9 +33,11 @@
 #include "hsallappsstate.h"
 #include "hsallcollectionsstate.h"
 #include "hscollectionstate.h"
+#include "hsmainwindow.h"
 #include "hsmenuitemmodel.h"
 #include "hsmenuview.h"
 #include "hslistviewitem.h"
+#include "hssearchview.h"
 
 /*!
     \class HsMenuView
@@ -49,41 +51,24 @@
 */
 
 /*!
- Constructor
 
- Builds UI objects
- Sets up signals connections.
+ Retrieves UI objects for a requested context and sets up signals' connections.
 
  \param builder Menu View builder.
- \param viewContext variable representing view context the view is to be prepared for.
+ \param stateContext Variable representing view context the view is to be prepared for.
+ \param mainWindow Object responsible for making a given view
+    a currently displayed view.
  */
-HsMenuView::HsMenuView(HsMenuViewBuilder &builder, HsViewContext viewContext):
-    mViewContext(viewContext),
+HsMenuView::HsMenuView(HsMenuViewBuilder &builder,
+                       HsStateContext stateContext,
+                       HsMainWindow &mainWindow):
     mBuilder(builder),
-    mProxyModel(new QSortFilterProxyModel(this)),
-    mView(NULL),
-    mListView(NULL),
-    mViewLabel(NULL),
-    mSearchListView(NULL),
-    mSearchPanel(NULL),
-    mVkbHost(NULL)
+    mStateContext(stateContext),
+    mOperationalContext(HsItemViewContext),
+    mMainWindow(mainWindow),
+    mHsSearchView(new HsSearchView(mBuilder, mStateContext, mMainWindow))
 {
-    mBuilder.setOperationalContext(HsItemViewContext);
-    mBuilder.setViewContext(mViewContext);
-    mBuilder.build();
-
-    mView = mBuilder.currentView();
-    mListView = mBuilder.currentListView();
-
-    mViewLabel= mBuilder.currentViewLabel();
-
-    mCollectionButton = mBuilder.collectionButton();
-
-    mProxyModel->setFilterRole(CaItemModel::TextRole);
-    mProxyModel->setFilterKeyColumn(1);
-    mProxyModel->setSortRole(CaItemModel::TextRole);
-
-    mVkbHost.reset(new HbShrinkingVkbHost(mView));
+    synchronizeCache();
 
     connect(mListView,
             SIGNAL(activated(QModelIndex)),
@@ -91,12 +76,16 @@
     connect(mListView,
             SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
             this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
+    
+    connect(mHsSearchView.data(), SIGNAL(activated(QModelIndex)),
+            this, SIGNAL(activated(QModelIndex)));
+    connect(mHsSearchView.data(),
+            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
+                        this, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)));
 }
 
 /*!
- Destructor
-
- Disconnects signals.
+    Empty.
  */
 HsMenuView::~HsMenuView()
 {
@@ -104,7 +93,8 @@
 
 
 /*!
- Sets model for item view.
+ Sets model for list item view if available in current context otherwise
+ ingores the request.
 
  \param model Model the view is to represent in HsItemViewMode.
  */
@@ -112,93 +102,31 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsMenuView::setModel");
 
-    if (mListView->model()) {
-        disconnect(mListView->model(),
-                   SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
-                   this,
-                   SLOT(scrollToRow(int, QAbstractItemView::ScrollHint)));
-    }
-    mListView->setModel(model);
-    mListView->setItemPrototype(new HsListViewItem());
-    if (mListView->model()) {
-        connect(mListView->model(),
-                SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
-                this,
-                SLOT(scrollToRow(int, QAbstractItemView::ScrollHint)));
-    }
-    HSMENUTEST_FUNC_EXIT("HsMenuView::setModel");
-}
-
+    if (mListView != NULL) {
+        if (mListView->model()) {
+            disconnect(mListView->model(),
+                       SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
+                       this,
+                       SLOT(scrollToRow(int, QAbstractItemView::ScrollHint)));
+            disconnect(mListView->model(), SIGNAL(countChange()),
+                       this,
+                        SIGNAL(listViewChange()));
+        }
 
-/*!
-    Returns label appropriate for the view.
-    \return pointer to the label or NULL if the view has no label.
- */
-HbGroupBox *HsMenuView::viewLabel() const
-{
-    return mViewLabel;
-}
-
-/*!
-    \return first visible item index if any or default QModelIndex otherwise.
- */
-QModelIndex HsMenuView::firstVisibleItemIndex(const HbListView *view) const
-{
-    QModelIndex result;
-
-    const QList<HbAbstractViewItem *> array =
-        view->visibleItems();
-
-    if (array.count() >= 1) {
-        result = array[0]->modelIndex();
-    }
-    return result;
-}
+        mListView->setModel(model, new HsListViewItem());
 
-/*!
-    Makes the UI to show or hide view search panel.
-    When search panel is shown the view toolbar and status pane
-    are hidden until search panel is hidden.
-    \param visible When true search panel will be shown,
-     otherwise it will be hidden.
- */
-void HsMenuView::setSearchPanelVisible(bool visible)
-{
-    HSMENUTEST_FUNC_ENTRY("HsMenuView::setSearchPanelVisible");
-
-    if (visible) {
-
-        mSearchViewInitialIndex = firstVisibleItemIndex(mListView);
-
-        searchBegins();
-
-        connectSearchItemViewsSignals();
-        connectSearchPanelSignals();
-        
-    } else if (mSearchListView != NULL) {
+        if (mListView->model()) {
+            connect(mListView->model(),
+                    SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)),
+                    this,
+                    SLOT(scrollToRow(int, QAbstractItemView::ScrollHint)));
+            connect(mListView->model(), SIGNAL(countChange()),
+                    this,
+                    SIGNAL(listViewChange()));
+        }
+    }
 
-        mIndexToScrollAfterSearchDone =
-            firstVisibleItemIndex(mSearchListView);
-
-        disconnectSearchPanelSignals();
-        disconnectSearchItemViewsSignals();
-
-        searchFinished();
-    }
-    HSMENUTEST_FUNC_EXIT("HsMenuView::setSearchPanelVisible");
-}
-
-/*!
-    Makes the UI to show or hide view add collection button
-    \param visibility When true button will be shown,
-     otherwise it will be hidden.
- */
-void HsMenuView::setContext(HsViewContext viewContext,
-                            HsOperationalContext context)
-{
-    mBuilder.setViewContext(viewContext);
-    mBuilder.setOperationalContext(context);
-    mBuilder.build();
+    HSMENUTEST_FUNC_EXIT("HsMenuView::setModel");
 }
 
 
@@ -211,7 +139,8 @@
 }
 
 /*!
-\return List view widget of the menu view.
+\return List view widget of the menu view 
+ if available in the context or NULL otherwise.
  */
 HbListView *HsMenuView::listView() const
 {
@@ -219,11 +148,22 @@
 }
 
 /*!
-\return Collection button
+    Returns label appropriate for the view.
+    \return Pointer to the label 
+    if available in the context or NULL otherwise.
  */
-HbPushButton *HsMenuView::collectionButton() const
+HbGroupBox *HsMenuView::viewLabel() const
 {
-    return mCollectionButton;
+    return mViewLabel;
+}
+
+/*!
+\return Collection button 
+ if available in the context or NULL otherwise.
+ */
+HbPushButton *HsMenuView::contentButton() const
+{
+    return mAddContentButton;
 }
 
 /*!
@@ -234,13 +174,10 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsMenuView::showSearchPanel");
 
-    setSearchPanelVisible(true);
+    mHsSearchView->setSearchPanelVisible(true);
 
     HSMENUTEST_FUNC_EXIT("HsMenuView::showSearchPanel");
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT skipped: it doubles other method
 
 /*!
  Makes search panel invisible.
@@ -249,16 +186,15 @@
 void HsMenuView::hideSearchPanel()
 {
     HSMENUTEST_FUNC_ENTRY("HsMenuView::hideSearchPanel");
-    setSearchPanelVisible(false);
+
+    mHsSearchView->setSearchPanelVisible(false);
+
     HSMENUTEST_FUNC_EXIT("HsMenuView::hideSearchPanel");
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
 
 /*!
  Disable or enable search action button.
- \param disable If true action is disabled.
+ \param disable If true action gets disabled.
  */
 void HsMenuView::disableSearch(bool disable)
 {
@@ -266,7 +202,7 @@
 }
 
 /*!
- Scrolls item view to requested row.
+ Scrolls list item view to requested row.
  \param row The row which is to get at the position pointed by \a hint.
  \param hint Position in the view the row should be scrolled to.
   */
@@ -274,8 +210,10 @@
 {
     HSMENUTEST_FUNC_ENTRY("HsMenuView::scrollToRow");
 
-    mListView->scrollTo(mListView->model()->index(row, 0),
-                        convertScrollHint(hint));
+    if (mListView != NULL) {
+        mListView->scrollTo(
+            mListView->model()->index(row, 0), convertScrollHint(hint));
+    }
 
     HSMENUTEST_FUNC_EXIT("HsMenuView::scrollToRow");
 }
@@ -301,176 +239,19 @@
     }
 }
 
-/*
- Connects \a activated and \a longPressed signals coming from search list
- view to emit corresponding signal of this object with translated model index
-*/
-void HsMenuView::connectSearchItemViewsSignals()
-{
-    connect(mSearchListView, SIGNAL(activated(QModelIndex)),
-            this, SLOT(activatedProxySlot(QModelIndex)));
-    connect(mSearchListView, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
-            this, SLOT(longPressedProxySlot(HbAbstractViewItem *, QPointF)));
-
-}
-
 /*!
- Disconnects \a activated and \a longPressed signals coming from list
- view from to emit corresponding signal
- of this object with translated model index.
-*/
-void HsMenuView::disconnectSearchItemViewsSignals()
-{
-    disconnect(mSearchListView, SIGNAL(activated(QModelIndex)),
-               this, SLOT(activatedProxySlot(QModelIndex)));
-    disconnect(mSearchListView, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
-               this,
-               SLOT(longPressedProxySlot(HbAbstractViewItem *, QPointF)));
-}
-
-
-/*!
- Connects signals \a exitClicked and \a criteriaChanged emitted
- by search panel with handling slots of the object or its members.
-*/
-void HsMenuView::connectSearchPanelSignals()
-{
-    connect(mSearchPanel, SIGNAL(exitClicked()),
-            this, SLOT(hideSearchPanel()));
-    connect(mSearchPanel, SIGNAL(criteriaChanged(QString)),
-            this, SLOT(findItem(QString)));
-
-
-}
-
-/*!
- Disconnects signals \a exitClicked and \a criteriaChanged emitted
- by search panel from handling slots of the object or its members
- Scrolls view to state before connections.
-*/
-void HsMenuView::disconnectSearchPanelSignals()
-{
-    disconnect(mSearchPanel, SIGNAL(exitClicked()),
-               this, SLOT(hideSearchPanel()));
-
-    disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)),
-               this, SLOT(findItem(QString)));
-
-}
-
-
-/*!
- Looks up for item and if found scrolls to it.
- \param criteriaStr The item name to find.
- */
-void HsMenuView::findItem(QString criteriaStr)
-{
-   qDebug() << QString("hsmenuview::findItem: %1").arg(criteriaStr);
-    HSMENUTEST_FUNC_ENTRY("hsmenuview::findItem");
-
-    mProxyModel->invalidate();
-    mProxyModel->setSourceModel(mListView->model());
-    mProxyModel->setFilterRegExp(QRegExp(
-            QString("(^|\\b)%1").arg(criteriaStr), Qt::CaseInsensitive));
-
-    mSearchListView->scrollTo(mProxyModel->index(0,0),
-                              HbAbstractItemView::PositionAtTop);
-    
-    HSMENUTEST_FUNC_EXIT("hsmenuview::findItem");
-}
-
-/*!
- Makes the view display search panel with view representing search results.
- */
-void HsMenuView::searchBegins()
-{
-    HSMENUTEST_FUNC_ENTRY("hsmenuview::searchBegins");
-
-
-    mBuilder.setViewContext(mViewContext);
-    mBuilder.setOperationalContext(HsSearchContext);
-    mBuilder.build();
-    mSearchListView = mBuilder.currentListView();
-    mSearchPanel = mBuilder.currentSearchPanel();
-
-    mView->hideItems(Hb::AllItems);
-
-    mProxyModel->invalidate();
-    mProxyModel->setSourceModel(mListView->model());
-    mProxyModel->setFilterRegExp(QRegExp(QString(".*"), Qt::CaseInsensitive,
-                                         QRegExp::RegExp));
-    mSearchListView->setModel(mProxyModel);
-    mSearchListView->setItemPrototype(new HsListViewItem());
-    
-    mSearchListView->scrollTo(
-        mProxyModel->mapFromSource(mSearchViewInitialIndex),
-        HbAbstractItemView::PositionAtTop);
-    HSMENUTEST_FUNC_EXIT("hsmenuview::searchBegins");
-}
-
-/*!
-  Ensures view does not contain search related elements and is scrolled
-  to item chosen in search mode.
- */
-void HsMenuView::searchFinished()
-{
-    HSMENUTEST_FUNC_ENTRY("hsmenuview::searchFinished");
-    
-    mBuilder.setViewContext(mViewContext);
-    mBuilder.setOperationalContext(HsItemViewContext);
-    mBuilder.build();
-    mView->showItems(Hb::AllItems);
-
-    const QModelIndex indexToScroll =
-        mProxyModel->mapToSource(mIndexToScrollAfterSearchDone);
-
-    mListView->scrollTo(indexToScroll, HbAbstractItemView::PositionAtTop);
-
-    mSearchListView = NULL;
-    mSearchPanel = NULL;
-    HSMENUTEST_FUNC_EXIT("hsmenuview::searchFinished");
-}
-
-/*!
- Slot used to translate activated signal from proxy model to normal model.
- \param index representing an item activated in search list view.
- */
-void HsMenuView::activatedProxySlot(const QModelIndex &index)
-{
-    emit activated(mProxyModel->mapToSource(index));
-}
-
-/*!
- Slot used to forward 'long pressed' signal with item description transladed 
- from search view context to context of the view search was requested from. 
- */
-void HsMenuView::longPressedProxySlot(HbAbstractViewItem *item,
-                                      const QPointF &coords)
-{
-    /*
-      this is a kind of hack, introduced for reasons:
-      item object should be reusable later, but orbit (or qt) prevents setting
-      its index model to previous state
-      */
-    mSearchViewLongPressedIndex =
-        mProxyModel->mapToSource(item->modelIndex());
-    QScopedPointer<HbAbstractViewItem> itemNew(item->createItem());
-    itemNew->setModelIndex(mSearchViewLongPressedIndex);
-    emit longPressed(itemNew.data(), coords);
-}
-
-/*!
- Add the view to main window and search action with \a showSearchPanel
+ Add the view to main window and connect search action with \a showSearchPanel
  slot of the window.
  */
 void HsMenuView::activate()
 {
+    mMainWindow.setCurrentView(mView);
     connect(mBuilder.searchAction(), SIGNAL(triggered()),
-            this, SLOT(showSearchPanel()));
+            this, SLOT(showSearchPanel()), Qt::UniqueConnection);
 }
 
 /*!
- Disconnecs search action and \a showSearchPanel slot of the window.
+ Disconnects search action and disconnects \a showSearchPanel slot from the window.
  */
 void HsMenuView::inactivate()
 {
@@ -480,3 +261,63 @@
     disconnect(mBuilder.searchAction(), SIGNAL(triggered()),
                this, SLOT(showSearchPanel()));
 }
+
+/*!
+  Makes a new view to be activated. Ensure navigation action and view label
+  heading are preserved after reset.
+  \param operationalContext Context indicating which view to activate.
+ */
+void HsMenuView::reset(HsOperationalContext operationalContext)
+{
+    QString viewLabelHeading;
+
+    // before changing context read current view label heading ...
+    synchronizeCache();
+
+    if (mBuilder.currentViewLabel() != 0) {
+        viewLabelHeading = mBuilder.currentViewLabel()->heading();
+    }
+    // ... and back-key action
+    HbAction *const backKeyAction(mView->navigationAction());
+
+    // now we can switch the context
+
+    if (operationalContext != HsSearchContext) {
+
+        mOperationalContext = operationalContext;
+        synchronizeCache();
+
+        if (mBuilder.currentViewLabel() != 0) {
+            mBuilder.currentViewLabel()->setHeading(viewLabelHeading);
+        }
+
+        mView->setNavigationAction(backKeyAction);
+
+    } else {
+        showSearchPanel();
+    }
+}
+
+/*!
+ Builder can be shared between many instances of HsMenuView
+ being in different contexts. Before using builder make sure
+ it is in context matching the current HsMenuView.
+ */
+
+void HsMenuView::switchBuilderContext() {
+    mBuilder.setStateContext(mStateContext);
+    mBuilder.setOperationalContext(mOperationalContext);
+}
+
+/*!
+ Updates internal data references to widgets.
+ */
+void HsMenuView::synchronizeCache()
+{
+    switchBuilderContext();
+
+    mView = mBuilder.currentView();
+    mListView = mBuilder.currentListView();
+    mViewLabel = mBuilder.currentViewLabel();
+    mAddContentButton = mBuilder.currentAddContentButton();
+}
--- a/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -21,7 +21,6 @@
 #include <HbAction>
 #include <HbGroupBox>
 #include <HbListView>
-#include <HbLineEdit>
 #include <HbSearchPanel>
 #include <HbPushButton>
 #include <HbToolBar>
@@ -35,6 +34,27 @@
 #include "hsmenuviewbuilder.h"
 #include "hsmenustates_global.h"
 
+static const char* DOCUMENT_BASE_NAME_MAP
+        [InvalidStateContext][InvalidOperationalContext] =
+    /*HsItemViewContext,    HsSearchContext,    HsButtonContext,    HsEmptyLabelContext*/
+{
+/*HsAllAppsContext*/        {"listview", "searchlistview", "listview", "listview"},
+/*HsAllCollectionsContext*/ {"listview", "searchlistview", "listview", "listview"},
+/*HsInstalledAppsContext*/  {"labeledlistview", "labeledlistview",
+                                "labeledlistview", "emptylabeledview"},
+/*HsCollectionContext*/     {"labeledlistview", "searchlabeledlistview",
+                                "addcontentlabeledview", "emptylabeledview"}
+};
+
+static const QString DOCUMENT_NAME_PREFIX(QLatin1String(":/xml/"));
+static const QString DOCUMENT_NAME_EXT(QLatin1String(".docml"));
+static const QString COMMON_OBJECTS_DOCUMENT_BASE_NAME(
+        QLatin1String("common_objects"));
+static const QString VIEW_NAME(QLatin1String("view"));
+static const QString LIST_VIEW_NAME(QLatin1String("listView"));
+static const QString VIEW_LABEL_NAME(QLatin1String("label"));
+static const QString SEARCH_PANEL_NAME(QLatin1String("searchPanel"));
+static const QString ADD_CONTENT_BUTTON_NAME(QLatin1String("addContentButton"));
 
 /*!
     \class HsMenuViewBuilder
@@ -48,160 +68,144 @@
 */
 
 
-/*!
-  Cleanup search text on showing search panel. Ensures vkb host instance
-  is appears on show and disappears on hide search panel.
-  
-  \param visible When true search panel is to show up,
-  hide otherwise.
- */
-void HsMenuViewBuilder::searchPanelVisibilityChange(bool visible)
-{
-    if (visible) {
 
-        HbLineEdit *const lineEdit(searchPanelLineEdit());
-
-        lineEdit->setText("");
-        lineEdit->setFocus();
-        lineEdit->setInputMethodHints(Qt::ImhNoPredictiveText | 
-            Qt::ImhNoAutoUppercase);
-    } 
-
-}
 
 /*!
- \return pointer to the view resulting from last \a build call or NULL if 
+ \return Pointer to the view resulting from last \a build call or NULL if 
  the \a build has not yet been called.
  Memory ownership is not changed.
  */
-HbView *HsMenuViewBuilder::currentView() const
+HbView *HsMenuViewBuilder::currentView()
 {
-    const QString VIEW_NAME =
-        mViewContextToStringMap[mViewContext]
-        + "View";
+    HbView *const view =
+        qobject_cast<HbView *>(currentLoader()->findWidget(VIEW_NAME));
 
-    HbView *const view =
-        qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME));
-
-    if (view != NULL && mViewContext != HsInstalledAppsContext) {
+    if (view != NULL && mStateContext != HsInstalledAppsContext) {
         view->setToolBar(mToolBar);
     }
     return view;
 }
 
 /*!
- \return pointer to list view resulting from last \a build call or NULL if 
+ \return Pointer to list view resulting from last \a build call or NULL if 
  the \a build has not yet been called.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
-HbListView *HsMenuViewBuilder::currentListView() const
+HbListView *HsMenuViewBuilder::currentListView()
 {
-    QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext];
-    if (mOperationalContext == HsSearchContext) {
-        LIST_VIEW_NAME.append(mOperationalContextToStringMap[mOperationalContext]);
-    }
-    LIST_VIEW_NAME.append("ListView");
+    HbListView *const listView =
+        qobject_cast<HbListView *>(
+                currentLoader()->findWidget(LIST_VIEW_NAME));
 
-    return qobject_cast<HbListView *>(
-               mDocumentLoader.findWidget(LIST_VIEW_NAME));
+    return listView;
 }
 
 /*!
- \return pointer to the view label resulting from last \a build call. It is 
+ \return Pointer to the view label resulting from last \a build call. It is 
+ guaranteed to be not NULL if the \a build was called for the context
+ related to view including label.
+ The pointer is valid until the HsMenuViewBuilder instance is destroyed.
+ Memory ownership is not changed.
+ */
+HbGroupBox *HsMenuViewBuilder::currentViewLabel()
+{
+    HbGroupBox *viewLabel =
+            qobject_cast<HbGroupBox *>(
+                    currentLoader()->findWidget(VIEW_LABEL_NAME));
+
+    return viewLabel;
+}
+
+/*!
+ \return Pointer to the search panel resulting from last \a build call. It is
+ guaranteed to be not NULL if the \a build was called for the context
+ related to view including label.
+ The pointer is valid until the HsMenuViewBuilder instance is destroyed.
+ Memory ownership is not changed.
+ */
+HbSearchPanel *HsMenuViewBuilder::currentSearchPanel()
+{
+    HbSearchPanel *searchPanel =
+            qobject_cast<HbSearchPanel *>(currentLoader()->findWidget(
+                        SEARCH_PANEL_NAME));
+    return searchPanel;
+
+}
+
+/*!
+ \return Pointer to the 'Add content' button resulting from last
+ \a build call. It is
  guaranteed to be not NULL if the \a build was called for the context
  related to view including label.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
-HbGroupBox *HsMenuViewBuilder::currentViewLabel() const
+HbPushButton *HsMenuViewBuilder::currentAddContentButton()
 {
-    const QString LABEL_NAME = mViewContextToStringMap[mViewContext]
-                               + "Label";
-
-    return qobject_cast<HbGroupBox *>(
-               mDocumentLoader.findWidget(LABEL_NAME));
+    HbPushButton *pushButton =
+            qobject_cast<HbPushButton *>(currentLoader()->findWidget(
+                        ADD_CONTENT_BUTTON_NAME));
+    return pushButton;
 }
 
 /*!
- \return pointer to search panel.
- The pointer is valid until the HsMenuViewBuilder instance is destroyed.
- Memory ownership is not changed.
- */
-HbSearchPanel *HsMenuViewBuilder::currentSearchPanel() const
-{
-    return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget(
-            SEARCH_PANEL_NAME));
-}
-
-/*!
- \return pointer to a button
- The pointer is valid until the HsMenuViewBuilder instance is destroyed.
- Memory ownership is not changed.
- */
-HbPushButton *HsMenuViewBuilder::collectionButton() const
-{
-    return qobject_cast<HbPushButton *>(mDocumentLoader.findWidget(
-            BUTTON_NAME));
-}
-
-/*!
- \return pointer to All Applications Action. Guaranteed to be not NULL.
+ \return Pointer to All Applications Action. Guaranteed to be not NULL.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
 HbAction *HsMenuViewBuilder::allAppsAction() const
 {
-    return qobject_cast<HbAction *>(mDocumentLoader.findObject(
+    return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject(
                                         ALL_APPS_ACTION_NAME));
 }
 
 /*!
- \return pointer to All Collections Action. Guaranteed to be not NULL.
+ \return Pointer to All Collections Action. Guaranteed to be not NULL.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
 HbAction *HsMenuViewBuilder::allCollectionsAction() const
 {
-    return qobject_cast<HbAction *>(mDocumentLoader.findObject(
+    return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject(
                                         ALL_COLLECTIONS_ACTION_NAME));
 }
 
 /*!
- \return pointer to Search Action. Guaranteed to be not NULL.
+ \return Pointer to Search Action. Guaranteed to be not NULL.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
 HbAction *HsMenuViewBuilder::searchAction() const
 {
-    return qobject_cast<HbAction *>(mDocumentLoader.findObject(
+    return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject(
                                         SEARCH_ACTION_NAME));
 }
 
 /*!
- \return pointer to Ovi Store Action. Guaranteed to be not NULL.
+ \return Pointer to Ovi Store Action. Guaranteed to be not NULL.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
 HbAction *HsMenuViewBuilder::oviStoreAction() const
 {
-    return qobject_cast<HbAction *>(mDocumentLoader.findObject(
+    return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject(
                                         OVI_STORE_ACTION_NAME));
 }
 
 /*!
- \return pointer to Operator Action. Guaranteed to be not NULL.
+ \return Pointer to Operator Action. Guaranteed to be not NULL.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
 HbAction *HsMenuViewBuilder::operatorAction() const
 {
-    return qobject_cast<HbAction *>(mDocumentLoader.findObject(
+    return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject(
                                         OPERATOR_ACTION_NAME));
 }
 
 /*!
- \return pointer to the main view toolbar.
+ \return Pointer to the main view toolbar.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
@@ -211,7 +215,7 @@
 }
 
 /*!
- \return pointer to the toolbar extension.
+ \return Pointer to the toolbar extension.
  The pointer is valid until the HsMenuViewBuilder instance is destroyed.
  Memory ownership is not changed.
  */
@@ -221,7 +225,7 @@
 }
 
 /*!
- \return action group for \a allAppsState and \a allCollectionsState action.
+ \return Action group for \a allAppsState and \a allCollectionsState action.
  */
 QActionGroup *HsMenuViewBuilder::toolBarActionGroup() const
 {
@@ -230,18 +234,22 @@
 
 /*!
  Reads docml configuration corresponding to current context.
+ \return Shared pointer to loader serving current context.
  */
-bool HsMenuViewBuilder::build()
+QSharedPointer<HbDocumentLoader> HsMenuViewBuilder::currentLoader()
 {
-    return readContextConfiguration(mViewContext, mOperationalContext);
+    if (!mLoaderMap.contains(context())) {
+        QSharedPointer<HbDocumentLoader> loader =
+                readContextConfiguration();
+        mLoaderMap.insert(context(), loader);
+    }
+
+    return mLoaderMap[context()];
 }
 
 
-
 /*!
- Constructor.
- Makes object be initialized with with hidden but existing
- search panel and view label.
+  Loads non-context sensitive objects.
  */
 HsMenuViewBuilder::HsMenuViewBuilder():
     DOCUMENT_FILE_NAME(":/xml/applibrary.docml"),
@@ -255,17 +263,10 @@
     TOOL_BAR_NAME("toolBar"),
     mToolBar(new HbToolBar),
     mToolBarExtension(new HbToolBarExtension),
-    mViewContext(HsAllAppsContext),
+    mStateContext(HsAllAppsContext),
     mOperationalContext(HsItemViewContext)
 {
-    init();
-
-    // parse common section and the one specified by view options
-    const bool result = parseSection();
-
-    Q_ASSERT_X(result,
-               "HsMenuViewBuilder::HsMenuViewBuilder()",
-               "construction failed");
+    mCommonObjectsLoader = parseDocument(COMMON_OBJECTS_DOCUMENT_BASE_NAME);
 
     mToolBar->addAction(allAppsAction());
     mToolBar->addAction(allCollectionsAction());
@@ -278,8 +279,7 @@
 }
 
 /*!
- Destructor.
- Deletes widgets owned by the Menu View Builder.
+ Deletes loaded objects.
  */
 HsMenuViewBuilder::~HsMenuViewBuilder()
 {
@@ -291,81 +291,43 @@
 /*!
  Parses requested docml file section and reflects its contents in the
  object state.
- \param sectionName Name of the section to parse.
- \retval \a true on success, \a false otherwise.
+ \param documentName Identifies document to parse.
+ \return Document loader instance containing parsed
+    objects for requested \documentName.
  */
-bool HsMenuViewBuilder::parseSection(const QString &sectionName)
+QSharedPointer<HbDocumentLoader> HsMenuViewBuilder::parseDocument(
+        const QString &documentBaseName)
 {
-    HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection");
+    HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseDocument");
 
     bool loadStatusOk = false;
+
+    QSharedPointer<HbDocumentLoader> loader(new HbDocumentLoader());
+
+    const QString documentFullName = DOCUMENT_NAME_PREFIX +
+                                     documentBaseName +
+                                     DOCUMENT_NAME_EXT;
     const QObjectList loadedObjects =
-        mDocumentLoader.load(DOCUMENT_FILE_NAME,
-                             sectionName,
-                             &loadStatusOk); 
+            loader->load(documentFullName, &loadStatusOk);
+
     mLoadedObjects |= loadedObjects.toSet();
 
     Q_ASSERT_X(loadStatusOk,
-               DOCUMENT_FILE_NAME.toLatin1().data(),
+               documentFullName.toLatin1().data(),
                "Error while loading docml file.");
 
-    HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseSection");
-
-    return loadStatusOk;
-}
-
-
-/*!
- \return Line edit of the searchPanel on success, NULL otherwise.
- */
-HbLineEdit *HsMenuViewBuilder::searchPanelLineEdit() const
-{
-    HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::searchPanelLineEdit");
-
-    HbLineEdit *result(0);
-
-    foreach(QGraphicsItem *obj, currentSearchPanel()->childItems()) {
-
-        QGraphicsWidget *const widget = static_cast<QGraphicsWidget *>(obj);
-
-        if (widget != NULL) {
-
-            HbLineEdit *const lineEdit = qobject_cast<HbLineEdit *>(widget);
+    HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseDocument");
 
-            if (lineEdit != NULL) {
-                result = lineEdit;
-                break;
-            }
-        }
-    }
-    HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::searchPanelLineEdit");
-
-    return result;
-}
-
-/*!
-    Builds mapping between context and docml name buidling blocks.
- */
-void HsMenuViewBuilder::init()
-{
-    mViewContextToStringMap[HsAllAppsContext] = "allApps";
-    mViewContextToStringMap[HsAllCollectionsContext] = "allCollections";
-    mViewContextToStringMap[HsInstalledAppsContext] = "installedApps";
-    mViewContextToStringMap[HsCollectionContext] = "collection";
-    mOperationalContextToStringMap[HsItemViewContext] = "";
-    mOperationalContextToStringMap[HsSearchContext] = "Search";
-    mOperationalContextToStringMap[HsButtonContext] = "Button";
-    mOperationalContextToStringMap[HsEmptyLabelContext] = "EmptyLabel";
-
+    return loader;
 }
 
 /*!
  Sets view context. Not reflected in widgets returned by the builder
  until \a build is not run.
  */
-void HsMenuViewBuilder::setViewContext(HsViewContext viewContext)
+void HsMenuViewBuilder::setStateContext(HsStateContext stateContext)
 {
-    mViewContext = viewContext;
+    mStateContext = stateContext;
 }
 
 /*!
@@ -381,20 +343,23 @@
 /*!
  Reads configuration for requested context and ensures search panel and corresponding
  vkb host are managed properly.
+ \return Document loader with objects for current context.
  */
-bool HsMenuViewBuilder::readContextConfiguration(HsViewContext viewContext,
-        HsOperationalContext operationalContext)
+QSharedPointer<HbDocumentLoader> HsMenuViewBuilder::readContextConfiguration()
 {
-    const QString sectionName = mViewContextToStringMap[viewContext]
-        + mOperationalContextToStringMap[operationalContext] 
-        + "ViewDefinition";
+    const QLatin1String documentName(
+            DOCUMENT_BASE_NAME_MAP[mStateContext][mOperationalContext]);
 
-    const bool result = parseSection(sectionName);
+    QSharedPointer<HbDocumentLoader> loader =
+            parseDocument(QString(documentName));
 
-    if (currentSearchPanel()) {
-        searchPanelVisibilityChange(mOperationalContext == HsSearchContext);
-    }
-
-    return result;
+    return loader;
 }
 
+/*!
+ \return Current context.
+ */
+HsMenuViewBuilder::Context HsMenuViewBuilder::context() const
+{
+    return Context(mStateContext, mOperationalContext);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hssearchview.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: hssearchview.cpp
+ *
+ */
+
+#include <QSortFilterProxyModel>
+
+#include <HbGroupBox>
+#include <HbLineEdit>
+#include <HbListView>
+#include <HbAbstractViewItem>
+#include <HbView>
+#include <HbSearchPanel>
+#include <QApplication>
+#include <QInputContext>
+
+#include <caitemmodel.h>
+
+#include "hslistviewitem.h"
+#include "hsmainwindow.h"
+#include "hssearchview.h"
+
+/*!
+  Set up proxy model for search.
+  \param builder Retrieves UI widgets.
+  \param stateContext Identifies the state where search starts from.
+  \param mainWindow Enables switching between originating and search view.
+ */
+HsSearchView::HsSearchView(HsMenuViewBuilder &builder,
+        HsStateContext stateContext, HsMainWindow &mainWindow) :
+    mProxyModel(new QSortFilterProxyModel(this)),
+    mSearchView(NULL),
+    mSearchListView(NULL), mSearchPanel(NULL), mStateContext(stateContext),
+    mBuilder(builder), mMainWindow(mainWindow), mListView(NULL),
+    mVkbHost(NULL)
+{
+    mProxyModel->setFilterRole(CaItemModel::TextRole);
+    mProxyModel->setFilterKeyColumn(1);
+    mProxyModel->setSortRole(CaItemModel::TextRole);
+}
+
+/*!
+  Empty.
+ */
+HsSearchView::~HsSearchView()
+{
+}
+
+/*!
+    Makes the UI to show or hide view search panel.
+    When search panel is shown the view toolbar and status pane
+    are hidden until search panel is hidden.
+    \param visible When true search panel will be shown,
+     otherwise it will be hidden.
+ */
+void HsSearchView::setSearchPanelVisible(bool visible)
+{
+    HSMENUTEST_FUNC_ENTRY("HsMenuView::setSearchPanelVisible");
+
+    if (visible && !isActive()) {
+
+        searchBegins();
+
+        connectSearchItemViewsSignals();
+        connectSearchPanelSignals();
+
+    } else if (isActive()) {
+
+        disconnectSearchPanelSignals();
+        disconnectSearchItemViewsSignals();
+
+        searchFinished();
+    }
+    HSMENUTEST_FUNC_EXIT("HsMenuView::setSearchPanelVisible");
+}
+
+/*!
+    \param view List view to operate on.
+    \return Index of F=first visible item of \a view if any 
+    or default QModelIndex otherwise.
+ */
+QModelIndex HsSearchView::firstVisibleItemIndex(const HbListView *view) const
+{
+    QModelIndex result;
+
+    const QList<HbAbstractViewItem *> array =
+        view->visibleItems();
+
+    if (array.count() >= 1) {
+        result = array[0]->modelIndex();
+    }
+    return result;
+}
+
+/*!
+ Displays search panel with view representing search results.
+ */
+void HsSearchView::searchBegins()
+{
+    HSMENUTEST_FUNC_ENTRY("HsSearchView::searchBegins");
+
+    setOriginatingContext();
+
+    mListView = mBuilder.currentListView();
+    mSearchViewInitialIndex = firstVisibleItemIndex(mListView);
+
+    mProxyModel->invalidate();
+    mProxyModel->setSourceModel(mListView->model());
+    mProxyModel->setFilterRegExp(
+            QRegExp(QString(".*"), Qt::CaseInsensitive, QRegExp::RegExp));
+
+    QString viewLabelHeading;
+
+    if (mBuilder.currentViewLabel() != 0) {
+        viewLabelHeading = mBuilder.currentViewLabel()->heading();
+    }
+
+    setSearchContext();
+
+    mSearchView = mBuilder.currentView();
+    mSearchListView = mBuilder.currentListView();
+    mSearchPanel = mBuilder.currentSearchPanel();
+    initSearchPanel(*mSearchPanel);
+    mVkbHost.reset(new HbShrinkingVkbHost(mSearchView));
+
+    if (mBuilder.currentViewLabel() != 0) {
+        mBuilder.currentViewLabel()->setHeading(viewLabelHeading);
+    }
+
+
+    mSearchView->hideItems(Hb::AllItems);
+    mSearchListView->setModel(mProxyModel);
+    mSearchListView->setItemPrototype(new HsListViewItem());
+
+    mMainWindow.setCurrentView(mSearchView);
+
+    mSearchListView->scrollTo(
+        mProxyModel->mapFromSource(mSearchViewInitialIndex),
+        HbAbstractItemView::PositionAtTop);
+    HSMENUTEST_FUNC_EXIT("HsSearchView::searchBegins");
+}
+
+
+/*
+ Connects \a activated and \a longPressed signals coming from search list
+ view to emit corresponding signal of this object with translated model index.
+*/
+void HsSearchView::connectSearchItemViewsSignals()
+{
+    connect(mSearchListView, SIGNAL(activated(QModelIndex)),
+            this, SLOT(activatedProxySlot(QModelIndex)));
+    connect(mSearchListView, SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
+            this, SLOT(longPressedProxySlot(HbAbstractViewItem *, QPointF)));
+}
+
+/*!
+ Disconnects \a activated and \a longPressed signals coming from list
+ view from to emit corresponding signal
+ of this object with translated model index.
+*/
+void HsSearchView::disconnectSearchItemViewsSignals()
+{
+    disconnect(mSearchListView, SIGNAL(activated(QModelIndex)),
+            this, SLOT(activatedProxySlot(QModelIndex)));
+    disconnect(mSearchListView,
+            SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
+            this, SLOT(longPressedProxySlot(HbAbstractViewItem *, QPointF)));
+}
+
+
+/*!
+ Makes search panel invisible.
+ Equivalent to \a setSearchPanelVisible(false).
+ */
+void HsSearchView::hideSearchPanel()
+{
+    HSMENUTEST_FUNC_ENTRY("HsMenuView::hideSearchPanel");
+    setSearchPanelVisible(false);
+    HSMENUTEST_FUNC_EXIT("HsMenuView::hideSearchPanel");
+}
+
+/*!
+ Connects signals \a exitClicked and \a criteriaChanged emitted
+ by search panel with handling slots of the object or its members.
+*/
+void HsSearchView::connectSearchPanelSignals()
+{
+    connect(mSearchPanel, SIGNAL(exitClicked()),
+            this, SLOT(hideSearchPanel()));
+    connect(mSearchPanel, SIGNAL(criteriaChanged(QString)),
+            this, SLOT(findItem(QString)));
+}
+
+/*!
+ Disconnects signals \a exitClicked and \a criteriaChanged emitted
+ by search panel from handling slots of the object or its members
+ Scrolls view to state before connections.
+*/
+void HsSearchView::disconnectSearchPanelSignals()
+{
+    disconnect(mSearchPanel, SIGNAL(exitClicked()),
+           this, SLOT(hideSearchPanel()));
+    disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)),
+           this, SLOT(findItem(QString)));
+}
+
+/*!
+  Scrolls originating view to first item matching search criteria.
+ */
+void HsSearchView::searchFinished()
+{
+    HSMENUTEST_FUNC_ENTRY("HsSearchView::searchFinished");
+
+    mIndexToScrollAfterSearchDone =
+            firstVisibleItemIndex(mSearchListView);
+
+    setOriginatingContext();
+
+    mMainWindow.setCurrentView(mBuilder.currentView());
+
+    mListView->scrollTo(mProxyModel->mapToSource(mIndexToScrollAfterSearchDone),
+            HbAbstractItemView::PositionAtTop);
+
+    HbVkbHost::detachHost(mSearchView);
+    mVkbHost.reset(NULL);
+    mSearchListView = NULL;
+    mSearchPanel = NULL;
+    HSMENUTEST_FUNC_EXIT("HsSearchView::searchFinished");
+}
+
+/*!
+ Looks up for item and if found scrolls to it.
+ \param criteriaStr The item name to find.
+ */
+void HsSearchView::findItem(QString criteriaStr)
+{
+    qDebug() << "HsSearchView::findItem: " + criteriaStr;
+    HSMENUTEST_FUNC_ENTRY("HsSearchView::findItem");
+
+    mProxyModel->invalidate();
+    mProxyModel->setSourceModel(mListView->model());
+    mProxyModel->setFilterRegExp(
+            QRegExp("(^|\\b)" + criteriaStr, Qt::CaseInsensitive));
+
+    mSearchListView->scrollTo(
+            mProxyModel->index(0,0), HbAbstractItemView::PositionAtTop);
+
+    HSMENUTEST_FUNC_EXIT("HsSearchView::findItem");
+}
+
+/*!
+ Slot used to translate activated signal from proxy model to normal model.
+ \param index Represents an item activated in search list view.
+ */
+void HsSearchView::activatedProxySlot(const QModelIndex &index)
+{
+    emit activated(mProxyModel->mapToSource(index));
+}
+
+/*!
+ Slot used to forward 'long pressed' signal with item description transladed
+ from search view context to context of the view search was requested from.
+  \param item Long pressed item.
+  \param coords Coordinates of the long press action.
+ */
+void HsSearchView::longPressedProxySlot(HbAbstractViewItem *item,
+                                      const QPointF &coords)
+{
+    /*
+    this is a kind of hack, introduced for reasons:
+    item object should be reusable later, but orbit (or qt) prevents setting
+    its index model to previous state
+    */
+    mSearchViewLongPressedIndex =
+        mProxyModel->mapToSource(item->modelIndex());
+    QScopedPointer<HbAbstractViewItem> itemNew(item->createItem());
+    itemNew->setModelIndex(mSearchViewLongPressedIndex);
+    emit longPressed(itemNew.data(), coords);
+}
+
+/*!
+  Sets up search panel.
+
+ \param searchPanel Search panel to initialize.
+ */
+void HsSearchView::initSearchPanel(HbSearchPanel &searchPanel)
+{
+    HbLineEdit *const lineEdit(searchPanelLineEdit(searchPanel));
+
+    lineEdit->setText("");
+    lineEdit->setFocus();
+    lineEdit->setInputMethodHints(Qt::ImhNoPredictiveText |
+        Qt::ImhNoAutoUppercase);
+}
+
+/*!
+ \param searchPanel Search panel to operate on.
+ \return Line edit of the searchPanel on success, NULL otherwise.
+ */
+HbLineEdit *HsSearchView::searchPanelLineEdit(
+        HbSearchPanel &searchPanel) const
+{
+    HSMENUTEST_FUNC_ENTRY("HsSearchView::searchPanelLineEdit");
+
+    HbLineEdit *result(0);
+
+    foreach(QGraphicsItem *obj, searchPanel.childItems()) {
+
+        QGraphicsWidget *const widget = static_cast<QGraphicsWidget *>(obj);
+
+        if (widget != NULL) {
+
+            HbLineEdit *const lineEdit = qobject_cast<HbLineEdit *>(widget);
+
+            if (lineEdit != NULL) {
+                result = lineEdit;
+                break;
+            }
+        }
+    }
+    HSMENUTEST_FUNC_EXIT("HsSearchView::searchPanelLineEdit");
+
+    return result;
+}
+
+/*!
+  Sets the builder context to the one determined by \a mStateContext and
+  \a HsItemViewContext.
+ */
+void HsSearchView::setOriginatingContext()
+{
+    mBuilder.setStateContext(mStateContext);
+    mBuilder.setOperationalContext(HsItemViewContext);
+}
+
+/*!
+  Sets the builder context to the one determined by \a mStateContext and
+  \a HsSearchContext.
+ */
+void HsSearchView::setSearchContext()
+{
+    mBuilder.setStateContext(mStateContext);
+    mBuilder.setOperationalContext(HsSearchContext);
+}
+/*!
+  \retval true when search view is already invoked, \a false otherwise.
+ */
+bool HsSearchView::isActive() const
+{
+    return mSearchListView != NULL;
+}
+
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/hshomescreenstateplugin.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/hshomescreenstateplugin.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -29,7 +29,7 @@
 HB += hbfeedback
 
 CONFIG += plugin hb mobility
-MOBILITY = serviceframework
+MOBILITY = serviceframework systeminfo
 
 PLUGIN_SUBDIR = /private/20022F35/plugins/stateplugins
 
@@ -39,7 +39,6 @@
         -lhsdomainmodel \
         -lhsmenuserviceprovider
 
-RESOURCES += hshomescreenstateplugin.qrc
 
 symbian: {
     TARGET.UID3 = 0x20022F41
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/hshomescreenstateplugin.qrc	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-<RCC>
-    <qresource prefix="/" >           
-        <file alias="controllayer.docml">resource/controllayer.docml</file>
-    </qresource>    
-</RCC>
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsdocumentloader.h	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Homescreen document loader class.
-*
-*/
-
-#ifndef HSDOCUMENTLOADER_H
-#define HSDOCUMENTLOADER_H
-
-#include <hbdocumentloader.h>
-#include "hstest_global.h"
-
-HOMESCREEN_TEST_CLASS(HomeScreenStatePluginTest)
-
-class HsDocumentLoader : public HbDocumentLoader
-{
-public:
-    HsDocumentLoader();
-    virtual ~HsDocumentLoader();
-
-public:
-    QObject *createObject(const QString &type, const QString &name);
-
-private:
-
-    Q_DISABLE_COPY(HsDocumentLoader)
-
-    HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
-};
-
-#endif
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlestate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -31,11 +31,11 @@
 
 class QGraphicsItem;
 class QGraphicsSceneMouseEvent;
-class QPropertyAnimation;
+
 class QGestureEvent;
 class HbAction;
 class HbContinuousFeedback;
-class HsIdleWidget;
+
 class HsTitleResolver;
 class QParallelAnimationGroup;
 class HbMenu;
@@ -46,7 +46,7 @@
 class HsWidgetHost;
 class HsPage;
 class HsMessageBoxWrapper;
-class HsPropertyAnimationWrapper;
+
 
 class HsIdleState : public QState
 {
@@ -120,6 +120,7 @@
     void action_moveScene_disconnectGestureHandlers();    
     void action_addPage_addPage();
     void action_preRemovePage_showQuery();
+    void action_preRemovePage_exit();
     void action_removePage_startRemovePageAnimation();
     void action_removePage_removePage();
     void action_toggleConnection_toggleConnection();
@@ -146,11 +147,11 @@
    
 private:
     HbAction *mNavigationAction;
-    HsIdleWidget *mUiWidget;  
+    
     HsTitleResolver *mTitleResolver;
-    QPropertyAnimation *mZoneAnimation;
+  
     bool mAllowZoneAnimation;
-    HsPropertyAnimationWrapper *mPageChangeAnimation;
+    
     HbContinuousFeedback *mContinuousFeedback;
     bool mTrashBinFeedbackAlreadyPlayed;    
     QPointF mPageHotSpot;
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/inc/hsidlewidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-#ifndef HSIDLEWIDGET_H
-#define HSIDLEWIDGET_H
-
-#include <HbWidget>
-
-#include "hstest_global.h"
-HOMESCREEN_TEST_CLASS(HomeScreenStatePluginTest)
-
-class HsPage;
-class HsTrashBinWidget;
-class HsPageIndicator;
-class HsSnapLine;
-
-class HsIdleWidget : public HbWidget
-{
-    Q_OBJECT
-    Q_PROPERTY(qreal sceneX READ sceneX WRITE setSceneX)
-
-public:
-    HsIdleWidget(QGraphicsItem *parent = 0);
-	~HsIdleWidget();
-
-    qreal sceneX() const;
-    void setSceneX(qreal x);
-
-    void setGeometry(const QRectF &rect);
-
-    void setActivePage(int index);
-    void insertPage(int index, HsPage *page);
-    void removePage(int index);
-
-    HbWidget *controlLayer() const { return mControlLayer; }
-    HbWidget *pageLayer() const { return mPageLayer; }
-    HbWidget *pageWallpaperLayer() const { return mPageWallpaperLayer; }
-    HbWidget *sceneLayer() const { return mSceneLayer; }
-
-    HsTrashBinWidget *trashBin() const { return mTrashBin; }
-    HsPageIndicator *pageIndicator() const { return mPageIndicator; }
-
-    qreal parallaxFactor() const;
-
-
-public slots:
-    void showTrashBin();
-    void showPageIndicator();
-
-    void showVerticalSnapLine(const QLineF &snapLine);	
-    void hideVerticalSnapLine();
-    void showHorizontalSnapLine(const QLineF &snapLine);
-    void hideHorizontalSnapLine();
-
-protected:
-    void polishEvent();
-
-private:
-    Q_DISABLE_COPY(HsIdleWidget)
-    void loadControlLayer();
-        
-private:
-    HbWidget *mControlLayer;
-    HbWidget *mPageLayer;
-    HbWidget *mPageWallpaperLayer;
-    HbWidget *mSceneLayer;
-
-    HsTrashBinWidget *mTrashBin;
-    HsPageIndicator *mPageIndicator;
-
-    HsSnapLine *mHorizontalSnapLine;
-    HsSnapLine *mVerticalSnapLine;
-
-    HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
-};
-
-#endif // HSIDLEWIDGET_H
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/resource/controllayer.docml	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="0.9">
-    <widget name="controlLayer" type="HbWidget">
-        <widget name="pageIndicator" type="HsPageIndicator">
-            <sizehint height="2.5un" type="PREFERRED"/>
-        </widget>
-        <widget name="trashBin" type="HsTrashBinWidget">
-            <sizehint type="PREFERRED" height="11un" width="11un"/>
-        </widget>
-        <layout type="anchor">
-            <anchoritem dst="pageIndicator" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-            <anchoritem dst="pageIndicator" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-            <anchoritem dst="pageIndicator" dstEdge="BOTTOM" spacing="-1un" src="" srcEdge="BOTTOM"/>
-            <anchoritem dst="trashBin" dstEdge="CENTERH" spacing="0un" src="" srcEdge="CENTERH"/>
-            <anchoritem dst="trashBin" dstEdge="BOTTOM" spacing="-1un" src="" srcEdge="BOTTOM"/>
-        </layout>
-    </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
-        <uistate name="Common ui state" sections="#common"/>
-    </metadata>
-</hbdocument>
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsbackuprestorestate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsbackuprestorestate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -27,6 +27,7 @@
 #include "hsscene.h"
 #include "hsgui.h"
 
+
 /*!
     \class HsBackupRestoreState
     \ingroup group_hshomescreenstateplugin
@@ -95,12 +96,5 @@
 void HsBackupRestoreState::deleteIdleView()
 {
     // Delete idle view
-    QScopedPointer<HbView> idleView(HsGui::takeIdleView());
-
-    if (idleView){
-        HbAction *navigationAction(idleView->navigationAction());
-        idleView->setNavigationAction(0);
-        delete navigationAction;
-        HsScene::mainWindow()->removeView(idleView.data());
-    }
+    HsGui::instance()->cleanupIdleUi();
 }
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsdocumentloader.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Homescreen document loader class.
-*
-*/
-
-#include "hsdocumentloader.h"
-#include "hspageindicator.h"
-#include "hstrashbinwidget.h"
-#include "hsconfiguration.h"
-
-/*!
-    \class HsDocumentLoader
-    \ingroup group_hshomescreenstateplugin
-    \brief Homescreen document loader class.
-
-    Loads own widgets from docml.
-*/
-
-/*!
-    Constructor.
-*/
-HsDocumentLoader::HsDocumentLoader()
-    : HbDocumentLoader()
-{
-}
-
-/*!
-    Destructor.
-*/
-HsDocumentLoader::~HsDocumentLoader()
-{
-}
-
-/*!
-    Looks up an object which inherits class type and of which object name equals to name.
-    \a type type of the desired object.
-    \a name object name of the desired object.
-    */
-QObject *HsDocumentLoader::createObject(const QString &type, const QString &name)
-{
-    if (type == HsPageIndicator::staticMetaObject.className()) {
-        QObject *object = new HsPageIndicator(HSCONFIGURATION_GET(pageIndicatorSpacing));
-        object->setObjectName(name);
-        return object;
-    }
-    else if (type == HsTrashBinWidget::staticMetaObject.className()) {
-        QObject *object = new HsTrashBinWidget;
-        object->setObjectName(name);
-        return object;
-    }
-        
-    return HbDocumentLoader::createObject(type, name);
-}
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -42,7 +42,9 @@
 #include "hsdomainmodeldatastructures.h"
 #include "hsscene.h"
 #include "hspage.h"
+#include "hspagevisual.h"
 #include "hswidgethost.h"
+#include "hswidgethostvisual.h"
 #include "hswallpaper.h"
 #include "hswallpaperselectionstate.h"
 #include "hstrashbinwidget.h"
@@ -51,21 +53,15 @@
 #include "hshomescreenstatecommon.h"
 #include "hstitleresolver.h"
 #include "hsmenuservice.h"
-#include "hsgui.h"
 #include "hsconfiguration.h"
 #include "hsmessageboxwrapper.h"
 #include "hspropertyanimationwrapper.h"
+#include "hsgui.h"
 
-// Helper macros for connecting state entry and exit actions.
-#define ENTRY_ACTION(state, action) \
-    connect(state, SIGNAL(entered()), SLOT(action()));
-#define EXIT_ACTION(state, action) \
-    connect(state, SIGNAL(exited()), SLOT(action()));
 
 namespace
 {
-    const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
-
+  
     //User adds a new page to home screen
     const char hsLocTextId_OptionsMenu_AddPage[] = "txt_homescreen_opt_add_page";
 
@@ -92,13 +88,15 @@
 
     //Text in confirmation dialog while removing page with content
     const char hsLocTextId_Confirmation_RemovePage[] = "txt_homescreen_info_page_and_content_will_be_remov";
-
-    //Button in confirmation dialog while removing page with content
-    //const char hsLocTextId_ConfirmationButton_Ok[] = "txt_homescreen_button_ok";
+}
 
-    //Button in confirmation dialog while removing page with content
-    //const char hsLocTextId_ConfirmationButton_Cancel[] = "txt_homescreen_button_cancel";
-}
+// Helper macros for connecting state entry and exit actions.
+#define ENTRY_ACTION(state, action) \
+    connect(state, SIGNAL(entered()), SLOT(action()));
+#define EXIT_ACTION(state, action) \
+    connect(state, SIGNAL(exited()), SLOT(action()));
+
+
 
 /*!
     \class HsIdleState
@@ -117,11 +115,8 @@
 HsIdleState::HsIdleState(QState *parent)
   : QState(parent),
     mNavigationAction(0), 
-    mUiWidget(0),
     mTitleResolver(0),
-    mZoneAnimation(0),
     mAllowZoneAnimation(false),
-    mPageChangeAnimation(0),
     mContinuousFeedback(0),
     mTrashBinFeedbackAlreadyPlayed(false),
     mDeltaX(0),
@@ -149,15 +144,6 @@
 */
 HsIdleState::~HsIdleState()
 {
-    if (mZoneAnimation) {
-        mZoneAnimation->stop();
-        delete mZoneAnimation;
-    }
-    if (mPageChangeAnimation) {
-        mPageChangeAnimation->stop();
-        delete mPageChangeAnimation;
-    }
-    
     // TODO: Uncomment when updated API available
     //delete mContinuousFeedback;
 }
@@ -321,6 +307,7 @@
     ENTRY_ACTION(state_addPage, action_addPage_addPage)
     
     ENTRY_ACTION(state_preRemovePage, action_preRemovePage_showQuery)
+    EXIT_ACTION(state_preRemovePage, action_preRemovePage_exit);
 
     ENTRY_ACTION(state_removePage, action_removePage_startRemovePageAnimation)
     EXIT_ACTION(state_removePage, action_removePage_removePage)
@@ -333,7 +320,7 @@
 */
 qreal HsIdleState::pageLayerXPos(int pageIndex) const
 {
-    return -pageIndex * HsScene::mainWindow()->layoutRect().width();
+    return -pageIndex * HsGui::instance()->layoutRect().width();
 }
 
 /*!
@@ -342,22 +329,23 @@
 */
 void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration)
 {
-    if (mPageChangeAnimation->isRunning()) {
-        mPageChangeAnimation->stop();
+    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
+    if (animation->isRunning()) {
+        animation->stop();
     }        
-    mPageChangeAnimation->disconnect(this);
-    mPageChangeAnimation->setEndValue(pageLayerXPos(targetPageIndex));
-    mPageChangeAnimation->setDuration(duration);
-    connect(mPageChangeAnimation,
+    animation->disconnect(this);
+    animation->setEndValue(pageLayerXPos(targetPageIndex));
+    animation->setDuration(duration);
+    connect(animation,
             SIGNAL(finished()),
             SLOT(pageChangeAnimationFinished()), 
             Qt::UniqueConnection);
-    mPageChangeAnimation->start();
+    animation->start();
     
     HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
     
-    mUiWidget->showPageIndicator();
-    mUiWidget->setActivePage(targetPageIndex);
+    HsGui::instance()->idleWidget()->showPageIndicator();
+    HsGui::instance()->idleWidget()->setActivePage(targetPageIndex);
 }
 
 /*!
@@ -379,21 +367,24 @@
     }
 
     int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
+    
+    HsPropertyAnimationWrapper *pageCrawlingAnimation =
+        HsGui::instance()->pageCrawlingAnimation();
 
     if (isInLeftPageChangeZone()) {
-        mZoneAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) + bounceEffect);
+        pageCrawlingAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) + bounceEffect);
     } else {
-        mZoneAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) - bounceEffect);
+        pageCrawlingAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) - bounceEffect);
     }
-    mZoneAnimation->setDuration(duration);
-    mZoneAnimation->setDirection(QAbstractAnimation::Forward);
+    pageCrawlingAnimation->setDuration(duration);
+    pageCrawlingAnimation->setForward();
 
-    connect(mZoneAnimation,
+    connect(pageCrawlingAnimation,
             SIGNAL(finished()),
             SLOT(zoneAnimationFinished()),
             Qt::UniqueConnection);
     
-    mZoneAnimation->start();
+    pageCrawlingAnimation->start();
 }
 
 /*!
@@ -421,7 +412,7 @@
 */
 bool HsIdleState::isInRightPageChangeZone()
 {
-    qreal pageWidth = HsScene::mainWindow()->layoutRect().width();
+    qreal pageWidth = HsGui::instance()->layoutRect().width();
     return mWidgetHotSpot.x() > pageWidth - HSCONFIGURATION_GET(pageChangeZoneWidth);
 }
 
@@ -435,7 +426,7 @@
     HsPage *page = HsPage::createInstance(data);
     page->load();
     HsScene::instance()->addPage(page);
-    mUiWidget->insertPage(pageIndex, page);
+    HsGui::instance()->idleWidget()->insertPage(pageIndex, page);
 }
 
 /*!
@@ -443,20 +434,23 @@
 */
 void HsIdleState::updateZoneAnimation()
 {
+    HsPropertyAnimationWrapper *pageCrawlingAnimation = 
+        HsGui::instance()->pageCrawlingAnimation();
+
     if (!mAllowZoneAnimation) {
-        mZoneAnimation->stop();
+        pageCrawlingAnimation->stop();
     } else if (isInPageChangeZone()) {
         // should we start it
-        if (mZoneAnimation->state() == QAbstractAnimation::Stopped &&
-            !mPageChangeAnimation->isRunning()) {
+        if (!pageCrawlingAnimation->isRunning() &&
+            !HsGui::instance()->pageChangeAnimation()->isRunning()) {
             startPageChangeZoneAnimation(HSCONFIGURATION_GET(pageChangeZoneAnimationDuration));
         } 
-    } else if (mZoneAnimation->state() == QAbstractAnimation::Running) {
+    } else if (pageCrawlingAnimation->isRunning()) {
         // Not in zone, but still running     
-        if (mZoneAnimation->direction() == QAbstractAnimation::Forward){
+        if (pageCrawlingAnimation->isForward()){
             // reverse
-            mZoneAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
-            mZoneAnimation->setDirection(QAbstractAnimation::Backward);
+            pageCrawlingAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
+            pageCrawlingAnimation->setBackward();
         } 
     } 
 }
@@ -466,19 +460,19 @@
 */
 void HsIdleState::showTrashBin()
 {
-    if (mUiWidget->trashBin()->isUnderMouse()) {
+    if (HsGui::instance()->idleWidget()->trashBin()->isUnderMouse()) {
         if (!mTrashBinFeedbackAlreadyPlayed) {
             HbInstantFeedback::play(HSCONFIGURATION_GET(widgetOverTrashbinFeedbackEffect));
             mTrashBinFeedbackAlreadyPlayed = true;
         }
-        mUiWidget->trashBin()->activate();
+        HsGui::instance()->idleWidget()->trashBin()->activate();
     } else {
-        mUiWidget->trashBin()->deactivate();
+        HsGui::instance()->idleWidget()->trashBin()->deactivate();
         mTrashBinFeedbackAlreadyPlayed = false;
     }
 
-    if (!mUiWidget->pageIndicator()->isAnimationRunning()) {
-        mUiWidget->showTrashBin();
+    if (!HsGui::instance()->idleWidget()->pageIndicator()->isAnimationRunning()) {
+        HsGui::instance()->idleWidget()->showTrashBin();
     }
 }
 
@@ -489,32 +483,9 @@
 */
 void HsIdleState::action_idle_setupView()
 {
-    HbView *idleView = HsGui::idleView();
-    if (!idleView) {
-        mUiWidget = new HsIdleWidget;
-        idleView = HsScene::mainWindow()->addView(mUiWidget);
-        idleView->setContentFullScreen();
-
-        mNavigationAction = new HbAction(this);
-        mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
-        mNavigationAction->setObjectName("applib_navigation_action");
-        connect(mNavigationAction, SIGNAL(triggered()), SIGNAL(event_applicationLibrary()));
-        idleView->setNavigationAction(mNavigationAction);
+    HsGui::instance()->setupIdleUi();
+    connect(HsGui::instance(),SIGNAL(navigateToApplibrary()),SIGNAL(event_applicationLibrary()),Qt::UniqueConnection);
 
-        HsGui::setIdleView(idleView);
-        
-        delete mPageChangeAnimation;
-        mPageChangeAnimation = NULL;
-        mPageChangeAnimation = new HsPropertyAnimationWrapper;
-        mPageChangeAnimation->setTargetObject(mUiWidget);
-        mPageChangeAnimation->setPropertyName("sceneX"); 
-        delete mZoneAnimation;
-        mZoneAnimation = NULL;
-        mZoneAnimation = new QPropertyAnimation(mUiWidget, "sceneX");
-       
-    }
-
-    HsScene::mainWindow()->setCurrentView(idleView);
 }
 
 /*!
@@ -534,7 +505,7 @@
 void HsIdleState::onTitleChanged(QString title)
 {
     qDebug() << "HsIdleState::onTitleChanged() to title: " << title;
-    HsGui::idleView()->setTitle(title);
+    HsGui::instance()->idleView()->setTitle(title);
 }
 
 /*!
@@ -611,11 +582,11 @@
 
     HsScene *scene = HsScene::instance();
     int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
-    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1) - bounceEffect / 2 / mUiWidget->parallaxFactor(),
+    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1) - bounceEffect / 2 / HsGui::instance()->idleWidget()->parallaxFactor(),
                      pageLayerXPos(scene->activePageIndex()) + mDeltaX,
-                     pageLayerXPos(0) + (bounceEffect / 2 / mUiWidget->parallaxFactor()));
+                     pageLayerXPos(0) + (bounceEffect / 2 / HsGui::instance()->idleWidget()->parallaxFactor()));
 
-    mUiWidget->setSceneX(x);
+    HsGui::instance()->idleWidget()->setSceneX(x);
 }
  
 void HsIdleState::onPagePanFinished(QGestureEvent *event)
@@ -641,14 +612,14 @@
     
     mWidgetHotSpot = qobject_cast<HbTapAndHoldGesture *>(
         event->gesture(Qt::TapAndHoldGesture))->scenePosition();
-    mWidgetHotSpotOffset = mWidgetHotSpot - widget->pos();
+    mWidgetHotSpotOffset = mWidgetHotSpot - widget->visual()->pos();
     
     emit event_moveWidget();
 }
  
 void HsIdleState::onWidgetMoveUpdated(const QPointF &scenePos, HsWidgetHost *widget)
 {
-    QRectF widgetRect = widget->geometry();
+    QRectF widgetRect = widget->visual()->geometry();
 
     // Move widget to updated position.
     mWidgetHotSpot = scenePos;
@@ -658,7 +629,7 @@
     qreal lowerBoundX = -widgetRect.width();
 
     // When moving widget can go over the pages right border.
-    QRectF pageRect = HsGui::idleView()->rect();
+    QRectF pageRect = HsGui::instance()->idleView()->rect();
     qreal upperBoundX = pageRect.width();
 
     // When moving widget can go under the chrome at the pages upper border.
@@ -673,10 +644,10 @@
 
     // If using ItemClipsChildrenToShape-flag in widgethost then
     // setPos does not update position here, however setGeometry does it, QT bug?
-    widget->setGeometry(widgetX, widgetY, widgetRect.width(), widgetRect.height());
+    widget->visual()->setGeometry(widgetX, widgetY, widgetRect.width(), widgetRect.height());
     
     if (HSCONFIGURATION_GET(isSnapEnabled)) {
-        mSnapResult = HsWidgetPositioningOnWidgetMove::instance()->run(widget->sceneBoundingRect());
+        mSnapResult = HsWidgetPositioningOnWidgetMove::instance()->run(widget->visual()->sceneBoundingRect());
 
         if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
             if (mSnapResult.hasHorizontalSnap) {
@@ -759,7 +730,7 @@
     QApplication::instance()->installEventFilter(scene);
     scene->activePage()->showWidgets();
     qreal x = pageLayerXPos(scene->activePageIndex());
-    mUiWidget->setSceneX(x);
+    HsGui::instance()->idleWidget()->setSceneX(x);
 }
 
 /*!
@@ -767,7 +738,7 @@
 */
 void HsIdleState::action_idle_connectOrientationChangeEventHandler()
 {
-    connect(HsScene::mainWindow(),
+    connect(HsGui::instance(),
         SIGNAL(orientationChanged(Qt::Orientation)),
         SLOT(action_idle_orientationChanged()));
 }
@@ -814,9 +785,10 @@
     HsScene *scene = HsScene::instance();
     QApplication::instance()->removeEventFilter(scene);
     scene->activePage()->hideWidgets();
-
+    
+    HsGui::instance()->disconnect(this,SIGNAL(event_applicationLibrary()));
     //Close options menu on view change
-    HsGui::idleView()->setMenu(NULL);
+    HsGui::instance()->idleView()->setMenu(NULL);
 
     //Close context menu on view change
     if (mSceneMenu) {
@@ -829,7 +801,7 @@
 */
 void HsIdleState::action_idle_disconnectOrientationChangeEventHandler()
 {
-    disconnect(HsScene::mainWindow(),
+    disconnect(HsGui::instance(),
         SIGNAL(orientationChanged(Qt::Orientation)),
         this, SLOT(action_idle_orientationChanged()));
 }
@@ -884,7 +856,7 @@
             this, SIGNAL(event_toggleConnection()));
     }
 
-    HsGui::idleView()->setMenu(menu);
+    HsGui::instance()->idleView()->setMenu(menu);
 }
 
 void HsIdleState::action_waitInput_connectGestureHandlers()
@@ -933,9 +905,9 @@
 {
     HsWidgetHost *widget = HsScene::instance()->activeWidget();
     Q_ASSERT(widget);
-    widget->setParentItem(mUiWidget->controlLayer());
+    widget->visual()->setParentItem(HsGui::instance()->idleWidget()->controlLayer());
 
-    mUiWidget->showTrashBin();
+    HsGui::instance()->idleWidget()->showTrashBin();
 }
 
 /*!
@@ -1013,7 +985,7 @@
         if (widget == activeWidget) {
            continue;
         }
-        QRectF widgetRect = widget->geometry();
+        QRectF widgetRect = widget->visual()->geometry();
         incativeWidgetRects.append(widgetRect);
     }
     return incativeWidgetRects;
@@ -1024,18 +996,20 @@
 */
 void HsIdleState::action_moveWidget_reparentToPage()
 {
-    if (mZoneAnimation
-        && mZoneAnimation->state() == QAbstractAnimation::Running
-        && mZoneAnimation->direction() == QAbstractAnimation::Forward) {
-        mZoneAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
-        mZoneAnimation->setDirection(QAbstractAnimation::Backward);
+    HsPropertyAnimationWrapper *pageCrawlingAnimation =
+        HsGui::instance()->pageCrawlingAnimation();
+    if (pageCrawlingAnimation->isRunning()&& 
+        pageCrawlingAnimation->isForward()) {
+
+        pageCrawlingAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
+        pageCrawlingAnimation->setBackward();
     }
 
     HsScene *scene = HsScene::instance();
     HsPage *page = scene->activePage();
     HsWidgetHost *widget = scene->activeWidget();
 
-    if (mUiWidget->trashBin()->isUnderMouse()) {
+    if (HsGui::instance()->idleWidget()->trashBin()->isUnderMouse()) {
         HbInstantFeedback::play(HSCONFIGURATION_GET(widgetDropToTrashbinFeedbackEffect));
         widget->page()->removeWidget(widget);
         widget->remove();
@@ -1044,7 +1018,7 @@
         if (widget->page() != page) {
             widget->page()->removeWidget(widget);
             page->addExistingWidget(widget);
-            if (HsScene::orientation() == Qt::Horizontal) {
+            if (HsGui::instance()->orientation() == Qt::Horizontal) {
                 widget->removePresentation(Qt::Vertical);
             } else {
                 widget->removePresentation(Qt::Horizontal);
@@ -1052,7 +1026,7 @@
         }
 
         //Set the snap position of the widget and save the position
-        QRectF widgetRect = widget->geometry();
+        QRectF widgetRect = widget->visual()->geometry();
         if (mSnapResult.hasHorizontalSnap) {
             widgetRect.moveLeft(mSnapResult.horizontalSnapPosition);
         }
@@ -1061,15 +1035,15 @@
         }
 
         QPointF adjustedWidgetPosition = page->adjustedWidgetPosition(widgetRect);
-        widget->setPos(adjustedWidgetPosition);
+        widget->visual()->setPos(adjustedWidgetPosition);
 
         widget->savePresentation();
         page->updateZValues();
     }
 
-    widget->setParentItem(HsScene::instance()->activePage());
+    widget->visual()->setParentItem(HsScene::instance()->activePage()->visual());
 
-    mUiWidget->showPageIndicator();
+    HsGui::instance()->idleWidget()->showPageIndicator();
 }
 
 /*!
@@ -1140,7 +1114,7 @@
 void HsIdleState::action_moveScene_moveToNearestPage()
 {
     QList<HsPage *> pages = HsScene::instance()->pages();
-    QSizeF pageSize = pages.first()->size();
+    QSizeF pageSize = pages.first()->visual()->size();
 
     int pageIndex = HsScene::instance()->activePageIndex();
 
@@ -1152,6 +1126,17 @@
 
     HsScene::instance()->setActivePageIndex(pageIndex);
 
+    HsPage *page = HsScene::instance()->activePage();
+    if (page) {
+        QList<HsWidgetHost *> widgets = page->newWidgets();
+        if (!widgets.isEmpty()) {
+            foreach (HsWidgetHost *widget, widgets) {
+                widget->startWidget();
+            }
+        }
+    page->layoutNewWidgets();
+    }
+
     startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
 }
 
@@ -1171,10 +1156,13 @@
     addPageToScene(pageIndex);
     scene->setActivePageIndex(pageIndex);
     startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(newPageAddedAnimationDuration));
-    mUiWidget->pageIndicator()->addItem(pageIndex);
-    mUiWidget->showPageIndicator();
+    HsGui::instance()->idleWidget()->pageIndicator()->addItem(pageIndex);
+    HsGui::instance()->idleWidget()->showPageIndicator();
 }
 
+/*!
+    Displays a confirmation query before page is removed if there are widgets on page 
+*/
 void HsIdleState::action_preRemovePage_showQuery()
 {
     HsScene *scene = HsScene::instance();
@@ -1196,6 +1184,16 @@
 }
 
 /*!
+    Make sure confirmation query gets closed if user exits preRemovePage state e.g. by pressing application key
+*/
+void HsIdleState::action_preRemovePage_exit()
+{
+    if (mMessageBoxWrapper) {
+        mMessageBoxWrapper->close();
+    }
+}
+
+/*!
     Start remove page animation.
 */
 void HsIdleState::action_removePage_startRemovePageAnimation()
@@ -1210,19 +1208,19 @@
     if (isLastPage) {
         nextPageIndex--; 
     }
-    
-    if (mPageChangeAnimation->isRunning()) {
-        mPageChangeAnimation->stop();
+    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
+    if (animation->isRunning()) {
+        animation->stop();
     }
-    mPageChangeAnimation->disconnect(this);
-    connect(mPageChangeAnimation,
+    animation->disconnect(this);
+    connect(animation,
             SIGNAL(finished()),
             SIGNAL(event_waitInput()), 
             Qt::UniqueConnection);
-    mPageChangeAnimation->setEndValue(pageLayerXPos(nextPageIndex));
-    mPageChangeAnimation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
+    animation->setEndValue(pageLayerXPos(nextPageIndex));
+    animation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
    
-    mPageChangeAnimation->start();
+    animation->start();
     
     HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
     
@@ -1233,20 +1231,22 @@
 */
 void HsIdleState::action_removePage_removePage()
 {
-    if (mPageChangeAnimation->isRunning()) {
-        mPageChangeAnimation->stop();
-    }
+    HsIdleWidget *idleWidget = HsGui::instance()->idleWidget();
+    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
     HsScene *scene = HsScene::instance();
     HsPage *pageToRemove = scene->activePage();
-    
+
+    if (animation->isRunning()) {
+        animation->stop();
+    }
     // remove from ui
-    mUiWidget->removePage(pageToRemove->pageIndex());
-    mUiWidget->showPageIndicator();
+    idleWidget->removePage(pageToRemove->pageIndex());
+    idleWidget->showPageIndicator();
     // update data model
-    HsScene::instance()->removePage(pageToRemove);
+    scene->removePage(pageToRemove);
     // Take new active page (previous was removed) and move scene to right position
     qreal x = pageLayerXPos(scene->activePageIndex());
-    mUiWidget->setSceneX(x);
+    idleWidget->setSceneX(x);
     // delete it   
     pageToRemove->deleteLater();
    
@@ -1283,8 +1283,8 @@
 {
     HsScene *scene = HsScene::instance();
     int pageIndex = scene->activePageIndex();
-
-    if (mZoneAnimation->direction() == QAbstractAnimation::Forward) {
+    HsGui *gui(HsGui::instance());
+    if (gui->pageCrawlingAnimation()->isForward()) {
         if (isInLeftPageChangeZone() &&
             0 < pageIndex) {
             --pageIndex;
@@ -1295,15 +1295,15 @@
         if (pageIndex == scene->pages().count()) {
             if (pageIndex < HSCONFIGURATION_GET(maximumPageCount)) {
                 addPageToScene(pageIndex);
-                mUiWidget->showPageIndicator();
-                mUiWidget->pageIndicator()->addItem(pageIndex);
+                gui->idleWidget()->showPageIndicator();
+                gui->idleWidget()->pageIndicator()->addItem(pageIndex);
             }
         }
         scene->setActivePageIndex(pageIndex);
         startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
     } else {
         scene->setActivePageIndex(pageIndex);
-        mUiWidget->setActivePage(pageIndex);
+        gui->idleWidget()->setActivePage(pageIndex);
     }
 }
 
@@ -1323,7 +1323,8 @@
 {
     QRectF containerRect = HsScene::instance()->activePage()->contentGeometry();
     HsWidgetHost *activeWidget = HsScene::instance()->activeWidget();
-    HsWidgetPositioningOnWidgetMove::instance()->setPagePresentation(containerRect, createInactiveWidgetRects(), activeWidget->geometry());
+    HsWidgetPositioningOnWidgetMove::instance()->setPagePresentation(
+        containerRect, createInactiveWidgetRects(), activeWidget->visual()->geometry());
 }
 
 /*!
@@ -1352,7 +1353,7 @@
         //the line will be shown when the timer expires.
         //If timer has already expired, just show the line, which is redrawn to new geometry.
         if (!mVerticalSnapLineTimer.isActive()) {
-            mUiWidget->showVerticalSnapLine(mSnapResult.verticalSnapLine);
+            HsGui::instance()->idleWidget()->showVerticalSnapLine(mSnapResult.verticalSnapLine);
         }
     }
 }
@@ -1362,7 +1363,7 @@
 */
 void HsIdleState::onVerticalSnapLineTimerTimeout()
 {
-    mUiWidget->showVerticalSnapLine(mSnapResult.verticalSnapLine);
+    HsGui::instance()->idleWidget()->showVerticalSnapLine(mSnapResult.verticalSnapLine);
 }
 
 /*!
@@ -1370,7 +1371,7 @@
 */
 void HsIdleState::hideVerticalLine()
 {
-    mUiWidget->hideVerticalSnapLine();
+    HsGui::instance()->idleWidget()->hideVerticalSnapLine();
     mVerticalSnapLineTimer.stop();
 }
 
@@ -1385,7 +1386,7 @@
     }
     else {
         if (!mHorizontalSnapLineTimer.isActive()) {
-            mUiWidget->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
+            HsGui::instance()->idleWidget()->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
         }
     }
 }
@@ -1395,7 +1396,7 @@
 */
 void HsIdleState::onHorizontalSnapLineTimerTimeout()
 {
-    mUiWidget->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
+    HsGui::instance()->idleWidget()->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
 }
 
 /*!
@@ -1403,7 +1404,7 @@
 */
 void HsIdleState::hideHorizontalLine()
 {
-    mUiWidget->hideHorizontalSnapLine();
+    HsGui::instance()->idleWidget()->hideHorizontalSnapLine();
     mHorizontalSnapLineTimer.stop();
 }
 
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlewidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,406 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include <QApplication>
-#include <QGraphicsSceneMouseEvent>
-#include <QGraphicsLinearLayout>
-#include <QDir>
-
-#include <HbMainWindow>
-#include <HbVkbHost>
-
-#include "hsidlewidget.h"
-#include "hsscene.h"
-#include "hspage.h"
-#include "hswidgethost.h"
-#include "hswallpaper.h"
-#include "hstrashbinwidget.h"
-#include "hspageindicator.h"
-#include "hsdocumentloader.h"
-#include "hsconfiguration.h"
-#include "hsapp_defs.h"
-#include "hssnapline.h"
-
-namespace
-{
-    const char gControlLayerDocmlName[] = "controllayer.docml";
-    const char gControlLayerName[]      = "controlLayer";
-    const char gTrashBinName[]          = "trashBin";
-    const char gPageIndicatorName[]     = "pageIndicator";
-}
-
-/*!
-    \class HsIdleWidget
-    \ingroup group_hshomescreenstateplugin
-    \brief View part of the home screen idle state.
-
-    Maintains the idle view ui layers and takes care of
-    receiving user input and communicating it to the idle
-    state for further processing.
-*/
-
-/*!
-    Constructs a new idle widget with the given \a parent.
-*/
-HsIdleWidget::HsIdleWidget(QGraphicsItem *parent)
-  : HbWidget(parent),
-    mControlLayer(0), mPageLayer(0), mPageWallpaperLayer(0),
-    mSceneLayer(0),
-    mTrashBin(0), mPageIndicator(0),
-    mHorizontalSnapLine(0), mVerticalSnapLine(0)
-{
-    setFlag(ItemHasNoContents);
-
-    loadControlLayer();
-
-    QGraphicsLinearLayout *linearLayout = 0;
-
-    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
-    linearLayout->setContentsMargins(0, 0, 0, 0);
-    linearLayout->setSpacing(0);
-    mPageLayer = new HbWidget(this);
-    mPageLayer->setLayout(linearLayout);
-    mPageLayer->setZValue(2);
-    
-    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
-    linearLayout->setContentsMargins(0, 0, 0, 0);
-    linearLayout->setSpacing(0);
-    mPageWallpaperLayer = new HbWidget(this);
-    mPageWallpaperLayer->setLayout(linearLayout);
-    mPageWallpaperLayer->setZValue(1);
-    
-    linearLayout = new QGraphicsLinearLayout(Qt::Horizontal);
-    linearLayout->setContentsMargins(0, 0, 0, 0);
-    linearLayout->setSpacing(0);
-    mSceneLayer = new HbWidget(this);
-    mSceneLayer->setLayout(linearLayout);
-    mSceneLayer->setZValue(0);
-}
-
-/*!
-    Destroys this idle widget.
-*/
-HsIdleWidget::~HsIdleWidget()
-{
-    QList<HsPage *> pages = HsScene::instance()->pages();
-    foreach (HsPage *page, pages) {
-        page->setParentItem(0);
-        if (page->scene()) {
-            page->scene()->removeItem(page);
-        }
-        HsWallpaper *pageWallpaper = page->wallpaper();
-        if (pageWallpaper) {
-            pageWallpaper->setParentItem(0);
-            if (pageWallpaper->scene()) {
-                pageWallpaper->scene()->removeItem(pageWallpaper);
-            }
-        }
-    }
-
-    HsWallpaper *sceneWallpaper = HsScene::instance()->wallpaper();
-    if (sceneWallpaper) {
-        sceneWallpaper->setParentItem(0);
-        if (sceneWallpaper->scene()) {
-            sceneWallpaper->scene()->removeItem(sceneWallpaper);
-        }
-    }
-}
-
-qreal HsIdleWidget::sceneX() const
-{
-    return mPageLayer->x();
-}
-
-void HsIdleWidget::setSceneX(qreal x)
-{
-    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
-        mPageLayer->setX(x);
-        mSceneLayer->setX((parallaxFactor() * x) - HSCONFIGURATION_GET(bounceEffect) / 2);
-    } else {
-        mPageLayer->setX(x);
-        mPageWallpaperLayer->setX(x);
-    }
-}
-
-/*!
-    Layouts the ui layers according to the given \a rect.
-    If given \a rect has different size than a fullscreen view, rect
-    is lifted up by statuspane height. Normally HsIdleWidget position is 0,0 
-    relative to it's parent container (HbView). This functionality tackles
-    problem caused by HbStackedLayout which sets top most rect for all items 
-    (views) in a stack (not considering fullscreen mode).
-*/
-void HsIdleWidget::setGeometry(const QRectF &rect)
-{
-    
-    int n = HsScene::instance()->pages().count();
-    QRectF layoutRect(HsScene::instance()->mainWindow()->layoutRect());
-    if (layoutRect == rect || (layoutRect.height() == rect.width() && layoutRect.width() == rect.height())) {
-        mControlLayer->resize(rect.size());
-        mPageLayer->resize(n * rect.width(), rect.height());
-        if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
-            mPageWallpaperLayer->resize(n * rect.width(), rect.height());
-        }
-        mSceneLayer->resize(2 * rect.width() + HSCONFIGURATION_GET(bounceEffect), rect.height());
-        HbWidget::setGeometry(rect);
-    } else {
-        QRectF sceneRect = mapToScene(rect).boundingRect();
-        // HbView is a container item for widget, thus 0,0 is relative to view's position.
-        // Lift rect by offset. Fullscreen view is in 0,0 position in scene coordinates otherwise
-        // it's e.g 0,68 (statuspane being at 0,0 and view at 0,68)
-        sceneRect.setTop(-sceneRect.top());
-        HbWidget::setGeometry(sceneRect);
-    }
-}
-
-/*!
-    Sets the active page \a index to the page
-    indicator.
-*/
-void HsIdleWidget::setActivePage(int index)
-{
-    mPageIndicator->setActiveItemIndex(index);
-}
-
-/*!
-    Inserts the given \a page at index position
-    \a index in the page layer.
-*/
-void HsIdleWidget::insertPage(int index, HsPage *page)
-{
-    QGraphicsLinearLayout *layout =
-        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
-    layout->insertItem(index, page);
-    mPageLayer->resize(
-        layout->count() * size().width(), size().height());
-
-    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
-        QGraphicsLinearLayout *layout =
-            static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
-        layout->insertItem(index, page->wallpaper());
-        mPageWallpaperLayer->resize(
-            layout->count() * size().width(), size().height());
-    }
-}
-
-/*!
-    Removes the page at index position
-    \a index in the page layer.
-*/
-void HsIdleWidget::removePage(int index)
-{
-    QGraphicsLinearLayout *layout =
-        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
-    layout->removeAt(index);
-    mPageLayer->resize(
-        layout->count() * size().width(), size().height());
-
-    if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
-        QGraphicsLinearLayout *layout =
-            static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
-        layout->removeAt(index);
-        mPageWallpaperLayer->resize(
-            layout->count() * size().width(), size().height());
-    }
-    mPageIndicator->removeItem(index);
-}
-
-/*!
-    \fn HsIdleWidget::controlLayer() const
-
-    Returns the control layer.
-*/
-
-/*!
-    \fn HsIdleWidget::pageLayer() const
-
-    Returns the page layer.
-*/
-
-/*!
-    \fn HsIdleWidget::sceneLayer() const
-
-    Returns the scene layer.
-*/
-
-/*!
-    \fn HsIdleWidget::trashBin() const
-
-    Returns the trashbin widget.
-*/
-
-/*!
-    \fn HsIdleWidget::pageIndicator() const
-
-    Returns the page indicator widget.
-*/
-
-/*!
-    Sets the trashbin visible and hides the page indicator.
-*/
-void HsIdleWidget::showTrashBin()
-{
-    mPageIndicator->hide();
-    mTrashBin->show();
-}
-
-/*!
-    Sets the page indicator visible and hides the trashbin.
-*/
-void HsIdleWidget::showPageIndicator()
-{
-    mTrashBin->hide();
-    mTrashBin->deactivate();
-    mPageIndicator->setSpacing(HSCONFIGURATION_GET(pageIndicatorSpacing)); // for usability optimization widget, can be removed later on
-    mPageIndicator->setVisible(1 < mPageIndicator->itemCount());
-}
-
-/*!
-    Shows the Vertical snapping lines showing the guidance
-*/
-void HsIdleWidget::showVerticalSnapLine(const QLineF &snapLine)
-{
-    QVariantHash snapConfiguration;
-    snapConfiguration[SNAPLINEFADEINDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeInDuration));
-    snapConfiguration[SNAPLINEFADEOUTDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeOutDuration));
-
-    mVerticalSnapLine->setConfiguration(snapConfiguration);
-    mVerticalSnapLine->showLine(snapLine);
-}
-
-/*!
-    Shows the Horizontal snapping lines showing the guidance
-*/
-void HsIdleWidget::showHorizontalSnapLine(const QLineF &snapLine)
-{
-    QVariantHash snapConfiguration;
-    snapConfiguration[SNAPLINEFADEINDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeInDuration));
-    snapConfiguration[SNAPLINEFADEOUTDURATION] = QString::number(HSCONFIGURATION_GET(snapLineFadeOutDuration));
-
-    mHorizontalSnapLine->setConfiguration(snapConfiguration);
-    mHorizontalSnapLine->showLine(snapLine);
-}
-
-/*!
-    Hides the Vertical snapping line showing the guidance
-*/
-void HsIdleWidget::hideVerticalSnapLine()
-{
-    mVerticalSnapLine->hideLine();
-}
-
-/*!
-    Hides the Horizontal snapping line showing the guidance
-*/
-void HsIdleWidget::hideHorizontalSnapLine()
-{
-    mHorizontalSnapLine->hideLine();
-}
-
-/*!
-    Reimplements QGraphicsWidget::polishEvent().
-*/
-void HsIdleWidget::polishEvent()
-{
-    HsScene *scene = HsScene::instance();
-    Q_ASSERT(scene);
-
-    QGraphicsLinearLayout *pageLayout = 
-        static_cast<QGraphicsLinearLayout *>(mPageLayer->layout());
-
-    QList<HsPage *> pages = scene->pages();
-
-    foreach (HsPage *page, pages) {
-        pageLayout->addItem(page);
-        if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
-            QGraphicsLinearLayout *pageWallpaperLayout = 
-                static_cast<QGraphicsLinearLayout *>(mPageWallpaperLayer->layout());
-            pageWallpaperLayout->addItem(page->wallpaper());
-        }
-    }
-   if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
-        QGraphicsLinearLayout *sceneLayout = 
-            static_cast<QGraphicsLinearLayout *>(mSceneLayer->layout());
-    	HsWallpaper *wallpaper = HsScene::instance()->wallpaper();
-        sceneLayout->addItem(wallpaper);
-    }
-           
-    mPageIndicator->initialize(pages.count(), scene->activePageIndex());    
-    showPageIndicator();
-
-    HsScene::mainWindow()->scene()->installEventFilter(this);
-}
-
-/*!
-    Loads the control layer declared in a docml file.
-*/
-void HsIdleWidget::loadControlLayer()
-{
-    HsDocumentLoader loader;
-    bool loaded = false;
-
-#ifndef Q_OS_SYMBIAN
-    QString path = QDir::currentPath();
-#else
-    QString path = "c:";
-#endif
-
-    QString file = path + "/hsresources/" + gControlLayerDocmlName;
-    QString fallbackPath = QString(":/") + gControlLayerDocmlName;
-
-    if (QFile::exists(file)) {
-        loader.load(file, &loaded);
-        if (!loaded) {
-            loader.load(fallbackPath, &loaded);
-        }
-    } else {
-        loader.load(fallbackPath, &loaded);
-    }
-
-    if (loaded) {
-        mControlLayer = qobject_cast<HbWidget *>(loader.findWidget(gControlLayerName));
-        mControlLayer->setZValue(3);
-        mControlLayer->setParentItem(this);
-
-        mTrashBin = qobject_cast<HsTrashBinWidget *>(loader.findWidget(gTrashBinName));
-        mTrashBin->setZValue(1e6);
-
-        mPageIndicator = qobject_cast<HsPageIndicator *>(loader.findWidget(gPageIndicatorName));
-        mPageIndicator->setZValue(1e6);
-
-
-        mHorizontalSnapLine = new HsSnapLine(mControlLayer);
-        mHorizontalSnapLine->setZValue(10);
-
-        mVerticalSnapLine = new HsSnapLine(mControlLayer);
-        mVerticalSnapLine->setZValue(10);
-    } else {
-        // TODO: Handle error.
-    }
-}
-
-qreal HsIdleWidget::parallaxFactor() const
-{   
-    qreal clw = mControlLayer->size().width();
-    qreal slw = mSceneLayer->size().width() - HSCONFIGURATION_GET(bounceEffect);
-    int n = HsScene::instance()->pages().count();
-    if (n < 2) {
-        return 1;
-    } else {
-        return (slw - clw) / ((n - 1) * clw);
-    }
-}
--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsloadscenestate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsloadscenestate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -15,13 +15,15 @@
 *
 */
 
-#include <HbMainWindow>
+#include "hsloadscenestate.h"
+#include "hsscene.h"
+#include "hsgui.h"
+
 #ifdef Q_OS_SYMBIAN
 #include <XQSettingsManager>
 #include <startupdomainpskeys.h>
 #endif
-#include "hsloadscenestate.h"
-#include "hsscene.h"
+
 
 /*!
     \class HsLoadSceneState
@@ -121,7 +123,7 @@
 void HsLoadSceneState::showUi()
 {
     qDebug() << "HsLoadSceneState::showUi";
-    HsScene::mainWindow()->raise();
-    HsScene::mainWindow()->show();
+  
+    HsGui::instance()->show();
     emit event_history();
 }
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -31,7 +31,7 @@
 DEPENDPATH += ./inc \
     ./src
 INCLUDEPATH += ./inc \
-    ../../serviceproviders\hsmenuserviceprovider\inc \
+    ../../serviceproviders/hsmenuserviceprovider/inc \
     ../../hsutils/inc \
     ../../hsdomainmodel/inc
 
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/hsmenuworkerstateplugin.qrc	Fri Jul 23 13:47:57 2010 +0300
@@ -6,5 +6,6 @@
         <file alias="hsdetailsdialog.docml">resource/hsdetailsdialog.docml</file>
         <file alias="hsuninstalldialog.docml">resource/hsuninstalldialog.docml</file>
         <file alias="hsinstallationlogdialog.docml">resource/hsinstallationlogdialog.docml</file>
+        <file alias="hscollectionslistdialog.docml">resource/hscollectionslistdialog.docml</file>
     </qresource>
 </RCC>
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddappstocollectionstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddappstocollectionstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -25,10 +25,11 @@
 HS_STATES_TEST_CLASS(MenuStatesTest)
 
 class QStandardItemModel;
+class QModelIndex;
 class HbAction;
 class HsAppsCheckList;
 class HsCollectionNameDialog;
-class HsCollectionsListDialog;
+class HbDialog;
 
 class HsAddAppsToCollectionState: public QState
 {
@@ -54,11 +55,9 @@
 
     void transitToSaveState(const QString &collectionName);
 
-    void transitToAppsCheckListState(const QString &collectionName);
-
     void transitToSaveState(int collectionId);
 
-    void transitToAppsCheckListState(int collectionId);
+    void transitToSelectCollectionState();
 
     void transitToNewCollectionState();
 
@@ -85,6 +84,8 @@
     void cleanData();
 
     void selectApplicationsDone(const QList<int> &appList);
+    
+    void collectionSelected(const QModelIndex &modelIndex);
 
 private slots:
 
@@ -105,6 +106,8 @@
     void construct();
 
     void createStates();
+    
+    QStandardItemModel *standardItemModel(int collectionId);
 
 private:
 
@@ -132,8 +135,9 @@
 
     HsCollectionNameDialog *mEditorDialog;
 
-    HsCollectionsListDialog *mListDialog;
+    HbDialog *mListDialog; // not owned
 
+    QStandardItemModel *mModel; // delete with dialog
 };
 
 #endif /* ADDAPPSTOCOLLECTIONSTATE_H */
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsaddtohomescreenstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -34,6 +34,7 @@
 class CaNotifier;
 class HsContentService;
 
+
 class HsAddToHomeScreenState: public  QState
 {
     Q_OBJECT
@@ -53,8 +54,6 @@
     void cleanUp();
 
     void messageWidgetCorruptedFinished(HbAction* finishedAction);
-    
-    void memoryCardRemoved();
 
 signals:
 
@@ -72,7 +71,6 @@
 
     void logActionResult(QString operationName, int entryId,
                          bool operationSucceded);
-    void subscribeForMemoryCardRemove();
 
 private:
 
@@ -87,8 +85,6 @@
     
     HsMenuMode mMenuMode;
     
-    CaNotifier *mNotifier;
-    
     QVariant mToken;
 
 };
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsappschecklist.h	Fri Jul 23 13:47:57 2010 +0300
@@ -20,13 +20,12 @@
 
 #include <QModelIndexList>
 #include <hsmenuservice.h>
-#include "hbmainwindow.h"
 
 #include "hsmenustates_global.h"
 HS_STATES_TEST_CLASS(MenuStatesTest)
 
 //forward declarations
-class HbView;
+class HbDialog;
 class HbAction;
 class HbListView;
 class QStandardItemModel;
@@ -56,32 +55,28 @@
 
 protected slots:
 
-    void selectApplicationsDone();
+    void appsSelectionDialogFinished(HbAction* finishedAction);
+
+    void selectedItemsChanged();
 
 private:
 
     void constructControls();
 
-    HbMainWindow *mainWindow() const;
-
     QList<int> getSortedItemsList(const QModelIndexList &modelIndexList);
 
 private:
 
-    HbView *mView;
+    HbDialog *mAppsSelectDialog;
 
-    HbView *mPreviousView;
+    HbAction *mActionConfirm; // delete with dialog
 
-    HbAction *mActionConfirm;
+    HbListView *mListView; // delete with dialog
 
-    HbListView *mListView;
-
-    HsMenuItemModel *mModel;
+    HsMenuItemModel *mModel; // delete with dialog
 
     HsSortAttribute mSortAttribute;
 
-    QObjectList mLoadedObjects;
-
 };
 
 #endif /* APPSCHECKLIST_H */
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hscollectionslistdialog.h	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description:
- *
- */
-
-#ifndef HS_LIST_DIALOG_H
-#define HS_LIST_DIALOG_H
-
-#include <HbSelectionDialog>
-#include <hsmenuservice.h>
-
-#include "hsmenustates_global.h"
-HS_STATES_TEST_CLASS(MenuStatesTest)
-class QStandardItemModel;
-
-class HsCollectionsListDialog: public HbSelectionDialog
-{
-    Q_OBJECT
-
-    HS_STATES_TEST_FRIEND_CLASS(MenuStatesTest)
-
-public:
-
-    HsCollectionsListDialog(int collectionId = 0);
-
-    virtual ~HsCollectionsListDialog();
-
-    void open(QObject* receiver, const char* member );
-
-    int getItemId();
-
-protected:
-    void closeEvent( QCloseEvent * event );
-
-private:
-
-    void makeConnect();
-
-    void makeDisconnect();
-
-    QStandardItemModel *standardItemModel(int collectionId);
-
-    void insertNewCollectionItem(QStandardItemModel *model);
-
-private:
-
-    QStandardItemModel *mModel;
-
-    int mItemId;
-};
-
-#endif /* HS_LIST_DIALOG_H */
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsmenustates_global.h	Fri Jul 23 13:47:57 2010 +0300
@@ -64,6 +64,12 @@
 static const char *const HS_INSTALLATION_LOG_DIALOG_NAME="installation_log_dialog";
 static const char *const HS_INSTALLATION_LOG_DIALOG_LOG_LABEL="log_label";
 
+static const char *const HS_COLLECTION_DIALOG_LAYOUT =":/xml/hscollectionslistdialog.docml";
+static const char *const HS_COLLECTION_DIALOG_NAME="collection_list_dialog";
+static const char *const HS_COLLECTION_DIALOG_LIST_VIEW="listView";
+static const char *const HS_COLLECTION_DIALOG_CREATE_NEW_ACTION="qtl_dialog_softkey_2_left";
+static const char *const HS_COLLECTION_DIALOG_CANCEL_ACTION="qtl_dialog_softkey_2_right";
+
 
 /*!
  To enable logging of function entry and exit use the following flag for qmake:
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hspreviewhswidgetstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -23,6 +23,8 @@
 #include <QVariant>
 
 #include "hsmenustates_global.h"
+#include "hsmenuentryremovedhandler.h"
+
 HS_STATES_TEST_CLASS(MenuStatesTest)
 
 class QAction;
@@ -34,7 +36,6 @@
 class HbScrollArea;
 class HbMessageBox;
 
-
 class HsPreviewHSWidgetState : public QState
 {
     Q_OBJECT
@@ -52,7 +53,7 @@
     void previewDialogFinished(HbAction* finishedAction);
 
     void messageWidgetCorruptedFinished(HbAction* finishedAction);
-
+    
     void onEntry(QEvent *event);
 
     void cleanUp();
@@ -63,23 +64,20 @@
 private:
 
     void showMessageWidgetCorrupted();
-
-    void subscribeForMemoryCardRemove();
     
     HbDialog* buildPreviewDialog(const CaEntry& entry) const;
 
 private:
     
     HbDialog *mPreviewDialog;
-
-    CaNotifier *mNotifier;
-
+    QScopedPointer<HsMenuEntryRemovedHandler> mEntryObserver;
     int mEntryId;
 
     HbMessageBox *mCorruptedMessage;
 
-    QAction *mConfirmAction;
-
+    QAction *mConfirmRemovalAction;
+    QAction *mAddToHomescreenAction;
+    
     QVariant mToken;
     
     QString mUri;
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsuninstallitemstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsuninstallitemstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -73,14 +73,12 @@
     
     void createUninstallMessage();
     void createUninstallJavaMessage();
-    void subscribeForMemoryCardRemove();
+    void createSimpleUninstallJavaMessage();
 
 private:
 
     int mItemId;
     
-    CaNotifier *mNotifier;
-
     HbMessageBox *mUninstallMessage; // deletes itself automatically on close
     HbDialog *mUninstallJavaMessage;
     UninstallDialogType mDialogType;
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappdetailsstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappdetailsstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -18,6 +18,7 @@
 #ifndef HSVIEWAPPDETAILSSTATE_H_
 #define HSVIEWAPPDETAILSSTATE_H_
 
+
 #include <QState>
 #include <QVariant>
 
@@ -59,7 +60,6 @@
 private:
 
     void construct();
-    void subscribeForMemoryCardRemove(int entryId);
     void setFieldPresentation(QString key,
             CaSoftwareRegistry::DetailMap &detailMap,
             HbDocumentLoader &loader);
@@ -67,8 +67,6 @@
 private:
 
     HbDialog *mDialog;
-    
-    CaNotifier *mNotifier;
 };
 
 #endif /* HSVIEWAPPDETAILSSTATE_H_ */
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappsettingsstate.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/inc/hsviewappsettingsstate.h	Fri Jul 23 13:47:57 2010 +0300
@@ -43,12 +43,8 @@
 
     virtual ~HsViewAppSettingsState();
     
-private slots:
-    
-    void settingsDone();
-    
 signals:
-        void initialize(const QString &aUid);      
+    void initialize(const QString &aUid);      
     void exit();
 
 protected:
@@ -61,8 +57,6 @@
     void construct();
     
     HbMainWindow *mainWindow() const; 
-    
-    void subscribeForMemoryCardRemove(int entryId);
 
 private:
 
@@ -71,9 +65,6 @@
     HbView *mPreviousView;
     
     HbAction *mActionConfirm;
-    
-    CaNotifier *mNotifier;
-
 };
 
 
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/resource/hsappchecklist.docml	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/resource/hsappchecklist.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -1,17 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="0.9">
-    <widget name="view" type="HbView">
-        <widget name="listView" role="HbView:widget" type="HbListView">
+<hbdocument version="1.1">
+    <object name="aps_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string locid="txt_common_button_ok" name="text"/>
+    </object>
+    <object name="aps_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string locid="txt_common_button_cancel" name="text"/>
+    </object>
+    <widget name="applications_selection_dialog" type="HbDialog">
+        <contentsmargins bottom="var(hb-param-margin-view-bottom)" left="var(hb-param-margin-view-left)" right="var(hb-param-margin-view-right)" top="var(hb-param-margin-view-top)"/>
+        <enums name="dismissPolicy" value="NoDismiss"/>
+        <widget name="aps_dialog_pri_heading" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string locid="txt_applib_title_select_applications" name="plainText"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="listView" role="HbDialog:contentWidget" type="HbListView">
             <widget name="listViewItemPrototype" role="HbAbstractView:prototype" type="HbListViewItem">
                 <enums name="graphicsSize" value="LargeIcon"/>
             </widget>
             <enums name="selectionMode" value="MultiSelection"/>
-            <bool name="visible" value="TRUE"/>
-            <string name="orientation" value="Horizontal"/>
+            <real name="z" value="1"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup-list)" left="var(hb-param-margin-gene-popup-list)" right="var(hb-param-margin-gene-popup-list)" top="var(hb-param-margin-gene-popup-list)"/>
         </widget>
-        <string locid="txt_applib_title_select_applications" name="title"/>
+        <ref object="aps_dialog_softkey_2_left" role="HbWidget:addAction"/>
+        <ref object="aps_dialog_softkey_2_right" role="HbWidget:addAction"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
+        <dummydata objectName="listView" section="#common" value="app_list_template5"/>
     </metadata>
 </hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/resource/hscollectionslistdialog.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string locid="txt_applib_button_create_new" name="text"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string locid="txt_common_button_cancel" name="text"/>
+    </object>
+    <widget name="collection_list_dialog" type="HbDialog">
+        <widget name="qtl_dialog_pri_heading" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string locid="txt_applib_title_add_to" name="plainText"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="listView" role="HbDialog:contentWidget" type="HbListView">
+            <widget name="qtl_list_pri" role="HbAbstractView:prototype" type="HbListViewItem">
+                <enums name="graphicsSize" value="LargeIcon"/>
+            </widget>
+            <enums name="selectionMode" value="SingleSelection"/>
+            <real name="z" value="1"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup-list)" left="var(hb-param-margin-gene-popup-list)" right="var(hb-param-margin-gene-popup-list)" top="var(hb-param-margin-gene-popup-list)"/>
+        </widget>
+        <ref object="qtl_dialog_softkey_2_left" role="HbWidget:addAction"/>
+        <ref object="qtl_dialog_softkey_2_right" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+        <dummydata objectName="listView" section="#common" value="app_list_template1"/>
+    </metadata>
+</hbdocument>
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddappstocollectionstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddappstocollectionstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -15,6 +15,10 @@
  *
  */
 
+#include <HbDocumentLoader>
+#include <HbDialog>
+#include <HbListView>
+#include <QStandardItemModel>
 #include <qfinalstate.h>
 #include <QDebug>
 #include <hsmenuservice.h>
@@ -25,8 +29,8 @@
 #include "hsaddappstocollectionstate.h"
 #include "hsmenuevent.h"
 #include "hscollectionnamedialog.h"
-#include "hscollectionslistdialog.h"
 #include "hsappschecklist.h"
+#include "hsmenuitemmodel.h"
 
 /*!
  \class HsAddAppsToCollectionState
@@ -133,24 +137,16 @@
  */
 
 /*!
- \fn void HsAddAppsToCollectionState::transitToAppsCheckListState(const QString &collectionName);
- Signal emitted when collection name is selected - version to trigger
- transition to mAppCheckListState.
- \param collectionName name of collection.
- */
-
-/*!
  \fn void void HsAddAppsToCollectionState::transitToSaveState(int collectionId);
  Signal emitted when collection id is selected.
  \param collectionId id of collection.
  */
 
 /*!
- \fn void HsAddAppsToCollectionState::transitToAppsCheckListState(int collectionId);
- Signal emitted when collection name is selected - version to trigger
- transition to mAppCheckListState.
- \param collectionId id of collection.
- */
+ \fn void HsAddAppsToCollectionState::transitToSelectCollectionState();
+ Signal emitted after close multiselection list when CollectionActionType is ViaAllViewOptionMenuType   
+ transition to mSelectCollectionState.
+  */
 
 /*!
  \fn void HsAddAppsToCollectionState::transitToNewCollectionState();
@@ -179,14 +175,13 @@
     mShowConfirmation(0), mInitialState(0), mSelectCollectionState(0),
     mNewCollectionState(0), mAppsCheckListState(0), mActionType(
         NoActionType), mApplicationsSortAttribute(NoHsSortAttribute),
-    mAppsCheckList(0), mEditorDialog(0), mListDialog(0)
+    mAppsCheckList(0), mEditorDialog(0), mListDialog(0), mModel(0)
 {
     construct();
 }
 
 /*!
  Destructor.
-
  */
 HsAddAppsToCollectionState::~HsAddAppsToCollectionState()
 {
@@ -237,10 +232,6 @@
             SLOT(setCollectionId(int)));
     connect(this, SIGNAL(transitToSaveState(QString)),
             SLOT(setCollectionName(QString)));
-    connect(this, SIGNAL(transitToAppsCheckListState(int)),
-            SLOT(setCollectionId(int)));
-    connect(this, SIGNAL(transitToAppsCheckListState(QString)),
-            SLOT(setCollectionName(QString)));
     connect(this, SIGNAL(transitToSaveState(QList<int>)),
             SLOT(setAppList(QList<int>)));
 
@@ -249,28 +240,29 @@
     // Add a specific item to a collection via collection specific menu.
     // Adding a new collection via the Collections view.
     mSelectCollectionState->addTransition(this,
-    		SIGNAL(transitToNewCollectionState()), mNewCollectionState);
+            SIGNAL(transitToNewCollectionState()), mNewCollectionState);
     mSelectCollectionState->addTransition(this,
-    		SIGNAL(transitToSaveState(int)), saveState);
+            SIGNAL(transitToSaveState(int)), saveState);
     mNewCollectionState->addTransition(this,
-    		SIGNAL(transitToSaveState(QString)), saveState);
+            SIGNAL(transitToSaveState(QString)), saveState);
 
     // Add one/many applications to an existing/a new collection
     // via the All view options menu.
-    // Add items to a collection via the collection's view options menu.
+    // Add items to a collection via the collection's view options menu.    
     mSelectCollectionState->addTransition(this,
-    		SIGNAL(transitToAppsCheckListState(int)), mAppsCheckListState);
+            SIGNAL(transitToSaveState(int)), saveState);
     mNewCollectionState->addTransition(this,
-    		SIGNAL(transitToAppsCheckListState(QString)), mAppsCheckListState);
+            SIGNAL(transitToSaveState(QString)), saveState);
     mAppsCheckListState->addTransition(this,
-    		SIGNAL(transitToSaveState(QList<int>)), saveState);
-
+                    SIGNAL(transitToSaveState(QList<int>)), saveState);
     mSelectCollectionState->addTransition(this,
-    		SIGNAL(transitToFinalState()),finalState);
+            SIGNAL(transitToFinalState()),finalState);
     mNewCollectionState->addTransition(this,
-    		SIGNAL(transitToFinalState()), finalState);
+            SIGNAL(transitToFinalState()), finalState);
     mAppsCheckListState->addTransition(this,
-    		SIGNAL(transitToFinalState()), finalState);
+            SIGNAL(transitToSelectCollectionState()), mSelectCollectionState);
+    mAppsCheckListState->addTransition(this,
+            SIGNAL(transitToFinalState()), finalState);
 
     //transition to final state after save
     saveState->addTransition(finalState);
@@ -341,7 +333,7 @@
     } else if (mApplicationsSortAttribute != NoHsSortAttribute) {
         //add apps from allAppView options menu
         mActionType = ViaAllViewOptionMenuType;
-        mInitialState->addTransition(mSelectCollectionState);
+        mInitialState->addTransition(mAppsCheckListState);
         mShowConfirmation = true;
     } else if (mCollectionId) {
         //add apps from collectionView options menu
@@ -397,22 +389,18 @@
 }
 
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void HsAddAppsToCollectionState::editorDialogFinished(HbAction* finishedAction)
+/*!
+ Slot invoked when editor dialog with name of created collection is finished.
+ */
+void HsAddAppsToCollectionState::editorDialogFinished(
+        HbAction* finishedAction)
 {
     if (finishedAction == mEditorDialog->actions().value(0)) {
-        QString newName(mEditorDialog->newName(mEditorDialog->value().toString(), true));
-        if (mActionType == ViaAllViewOptionMenuType) {
-            qDebug("HsAddAppsToCollectionState::newCollection() "
-                   "- emit collectionNameSelectedCl(newName)");
-            emit transitToAppsCheckListState(newName);
-        } else {
-            qDebug("HsAddAppsToCollectionState::newCollection() "
-                   "- emit collectionNameSelected(newName)");
-            emit transitToSaveState(newName);
-        }
+        QString newName(mEditorDialog->newName(
+                mEditorDialog->value().toString(), true));
+        qDebug("HsAddAppsToCollectionState::newCollection() "
+               "- emit collectionNameSelectedCl(newName)");
+        emit transitToSaveState(newName);
     } else {
         qDebug(
             "HsAddAppsToCollectionState::newCollection() - emit cancel()");
@@ -428,35 +416,76 @@
 {
     qDebug("HsAddAppsToCollectionState::selectCollection()");
     HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::selectCollection");
-    mListDialog = new HsCollectionsListDialog(mCollectionId);
-    mListDialog->open(this, SLOT(listDialogFinished(HbAction*)));
+    
+    HbDocumentLoader loader;
+    bool loadStatusOk = false;
+    loader.load(HS_COLLECTION_DIALOG_LAYOUT, &loadStatusOk);
+    Q_ASSERT_X(loadStatusOk, HS_COLLECTION_DIALOG_LAYOUT,
+           "Error while loading docml file.");
+
+    mListDialog = qobject_cast<HbDialog*>(
+        loader.findWidget(HS_COLLECTION_DIALOG_NAME));
+    
+    HbListView *listView = qobject_cast<HbListView*>(
+        loader.findWidget(HS_COLLECTION_DIALOG_LIST_VIEW));
+    
+    HbAction* createNewCollection = 
+            qobject_cast<HbAction*>(loader.findObject(
+            HS_COLLECTION_DIALOG_CREATE_NEW_ACTION));
+    
+    HbAction* cancel = qobject_cast<HbAction*>(loader.findObject(
+            HS_COLLECTION_DIALOG_CANCEL_ACTION));
+    
+    if (mListDialog != NULL) {
+        mListDialog->setTimeout(HbPopup::NoTimeout);
+        mListDialog->setAttribute(Qt::WA_DeleteOnClose, true);
+        
+        createNewCollection->setParent(mListDialog);
+        cancel->setParent(mListDialog);
+        
+        mModel = standardItemModel(mCollectionId);
+        mModel->setParent(mListDialog);
+        listView->setModel(mModel);
+        
+        connect(listView, SIGNAL(activated(const QModelIndex &)),
+                this, SLOT(collectionSelected(const QModelIndex &)));
+        
+        mListDialog->open(this, SLOT(listDialogFinished(HbAction*)));
+    }
+    
     HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::selectCollection");
 }
 
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
+/*!
+ Slot invoked when collection list dialog is finished
+ */
 void HsAddAppsToCollectionState::listDialogFinished(HbAction* finishedAction)
 {
-    if (finishedAction != mListDialog->actions().value(0)) {
-        int itemId = mListDialog->getItemId();
-        if (itemId) {
-            if (mActionType == ViaAllViewOptionMenuType) {
-                qDebug("emit collectionSelectedCl(%d)", itemId);
-                emit transitToAppsCheckListState(itemId);
-            } else {
-                qDebug("emit collectionSelected(%d)", itemId);
-                emit transitToSaveState(itemId);
-            }
-        } else {
-            qDebug("emit createNewCollection()");
-            emit transitToNewCollectionState();
-        }
-    } else {
+    if (finishedAction == mListDialog->actions().value(0)) {
+        qDebug("emit createNewCollection()");
+        emit transitToNewCollectionState();
+	} else if (finishedAction == mListDialog->actions().value(1)) {
         qDebug("emit cancel()");
         emit transitToFinalState();
-    }
+	}
+    
     mListDialog = NULL; // set to null since this will be deleted after close
+    mModel = NULL;// set to null since this will be deleted with dialog
+}
+
+/*!
+ Slot invoked when collection is selected
+  \param modelIndex Index of selected item.
+ */
+void HsAddAppsToCollectionState::collectionSelected(
+        const QModelIndex &modelIndex)
+{
+    int selectedCollection = mModel->data(
+            modelIndex, CaItemModel::IdRole).toInt();
+    mListDialog->close();
+    
+    qDebug("emit collectionSelected(%d)", selectedCollection);
+    emit transitToSaveState(selectedCollection);
 }
 
 /*!
@@ -469,9 +498,9 @@
     HSMENUTEST_FUNC_ENTRY("HsAddAppsToCollectionState::showMessageAppsAdded");
     HbNotificationDialog *notificationDialog = new HbNotificationDialog();
     notificationDialog->setAttribute(Qt::WA_DeleteOnClose);
-    notificationDialog->setTitle(hbTrId(
-                                     "txt_applib_dpopinfo_added_to_collection_1") .arg(
-                                     HsMenuService::getName(id)));
+    notificationDialog->setTitle(
+            hbTrId("txt_applib_dpopinfo_added_to_collection_1") .arg(
+                    HsMenuService::getName(id)));
     notificationDialog->show();
     mShowConfirmation = false;
     HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::showMessageAppsAdded");
@@ -517,9 +546,6 @@
 /*!
  Slot invoked when apps checklist state is entered.
  */
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
 void HsAddAppsToCollectionState::appsCheckListState()
 {
     qDebug("HsAddAppsToCollectionState::appsCheckListState()");
@@ -534,29 +560,60 @@
     mAppsCheckList->showAppsCheckboxList(mApplicationsSortAttribute);
     HSMENUTEST_FUNC_EXIT("HsAddAppsToCollectionState::appsCheckListState");
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
 /*!
  Slot connected trrigger action of secondary soft key of check list box.
  It is called when done button is selected.
  */
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
 void HsAddAppsToCollectionState::selectApplicationsDone(
     const QList<int> &appList)
 {
     if (appList.count()) {
         qDebug("AppsCheckListState::selectApplicationsDone() "
                "- emit appsSelected(mAppList)");
-        emit transitToSaveState(appList);
+        if (mActionType == ViaAllViewOptionMenuType) {
+            setAppList(appList);
+            emit transitToSelectCollectionState();
+        } else {
+            emit transitToSaveState(appList);
+        }
     } else {
         qDebug(
             "AppsCheckListState::selectApplicationsDone() - emit cancel()");
         emit transitToFinalState();
     }
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
+/*!
+ Creates standard item model.
+ \param collectionId id of collection to remove from model.
+ \return QStandardItemModel - caller takes ownership.
+ */
+QStandardItemModel *HsAddAppsToCollectionState::standardItemModel(
+    int collectionId)
+{
+    HSMENUTEST_FUNC_ENTRY("HsListDialog::standartItemModel");
+    QScopedPointer<HsMenuItemModel> caModel(
+        HsMenuService::getAllCollectionsModel());
+    caModel->setSecondLineVisibility(true);
+    QStandardItemModel *model = new QStandardItemModel(this);
+    QList<QStandardItem *> items;
+    for (int row = 0; row < caModel->rowCount(); row++) {
+        uint flags = caModel->data(caModel->index(row, 0),
+                CaItemModel::FlagsRole).value<EntryFlags> ();
+        int itemId = caModel->data(caModel->index(row, 0),
+                                   CaItemModel::IdRole).toInt();
+        if ((flags & RemovableEntryFlag) && (itemId != collectionId)) {
+            QStandardItem *standardItem = new QStandardItem();
+            standardItem->setData(caModel->data(caModel->index(row, 0),
+                CaItemModel::IdRole), CaItemModel::IdRole);
+            standardItem->setData(caModel->data(caModel->index(row, 0),
+                Qt::DisplayRole), Qt::DisplayRole);
+            standardItem->setData(caModel->data(caModel->index(row, 0),
+                Qt::DecorationRole), Qt::DecorationRole);
+            items << standardItem;
+        }
+    }
+    model->insertColumn(0, items);
+
+    HSMENUTEST_FUNC_EXIT("HsListDialog::standartItemModel");
+    return model;
+}
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsaddtohomescreenstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -24,6 +24,8 @@
 #include <hbnotificationdialog.h>
 #include <hsmenueventfactory.h>
 #include "hsmenudialogfactory.h"
+#include "hsmenuentryremovedhandler.h"
+
 #include "hsaddtohomescreenstate.h"
 #include "hsmenuevent.h"
 #include "canotifier.h"
@@ -55,8 +57,7 @@
 HsAddToHomeScreenState::HsAddToHomeScreenState(QState *parent) :
     QState(parent), 
     mCorruptedMessage(NULL), mConfirmAction(NULL),
-    mMenuMode(NormalHsMenuMode),
-    mNotifier(0)
+    mMenuMode(NormalHsMenuMode)
 {
     setObjectName("/AddToHomeScreenState");
     
@@ -139,7 +140,6 @@
     params[HOMESCREENDATA] = mToken;
     bool success = contentService.createWidget(params);
     if (!success) {
-        subscribeForMemoryCardRemove();
         showMessageWidgetCorrupted();
     } else {
         emit exit();
@@ -165,6 +165,13 @@
     mCorruptedMessage = HsMenuDialogFactory().create(
             hbTrId("txt_applib_dialog_file_corrupted_unable_to_use_wi"));
     mConfirmAction = mCorruptedMessage->actions().value(0);
+    
+    QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+        new HsMenuEntryRemovedHandler(mEntryId, 
+            mCorruptedMessage, SLOT(close())));
+    
+    entryObserver.take()->setParent(mCorruptedMessage); 
+    
     mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
 
     HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted");
@@ -196,19 +203,11 @@
 void HsAddToHomeScreenState::cleanUp()
 {
     // Close popups if App key was pressed
-    if (mCorruptedMessage) {
-        disconnect(mCorruptedMessage, SIGNAL(finished(HbAction*)),
-                   this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
+    if (mCorruptedMessage != NULL) {
         mCorruptedMessage->close();
         mCorruptedMessage = NULL;
     }
     
-    disconnect(mNotifier,
-               SIGNAL(entryChanged(CaEntry,ChangeType)),
-               this, SLOT(memoryCardRemoved()));
-
-    delete mNotifier;
-    mNotifier = NULL;
     mToken = NULL;
 }
 
@@ -305,32 +304,6 @@
     }
 }
 
-/*!
- Subscribe for memory card remove.
- \retval void
- */
-void HsAddToHomeScreenState::subscribeForMemoryCardRemove()
-{
-    CaNotifierFilter filter;
-    QList<int> entryIds;
-    entryIds.append(mEntryId);
-    filter.setIds(entryIds);
-    mNotifier = CaService::instance()->createNotifier(filter);
-    mNotifier->setParent(this);
-    connect(mNotifier,
-            SIGNAL(entryChanged(CaEntry,ChangeType)),
-            SLOT(memoryCardRemoved()));
-}
+
 
-/*!
- Memory card with instaled widget was removed.
- \retval void
- */
-void HsAddToHomeScreenState::memoryCardRemoved()
-{
-    if (mCorruptedMessage) {
-        mCorruptedMessage->close();
-        mCorruptedMessage = NULL;
-    }
-    // exit not needed, it is called after dialog closed
-}
+
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsappschecklist.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -17,7 +17,7 @@
 
 #include <hbaction.h>
 #include <hbinstance.h>
-#include <hbview.h>
+#include <hbdialog.h>
 #include <hblistview.h>
 #include <hbdocumentloader.h>
 #include <hsmenuservice.h>
@@ -81,7 +81,7 @@
  \retval void
  */
 HsAppsCheckList::HsAppsCheckList() :
-    mView(0), mPreviousView(0), mActionConfirm(0), mListView(0), mModel(0),
+    mAppsSelectDialog(0), mActionConfirm(0), mListView(0), mModel(0),
     mSortAttribute(AscendingNameHsSortAttribute)
 {
 }
@@ -101,16 +101,10 @@
 void HsAppsCheckList::cleanUp()
 {
     //clean up
+    if (mAppsSelectDialog) {
+        mAppsSelectDialog->close();
+    }
 
-    qDeleteAll(mLoadedObjects);
-    mLoadedObjects.clear();
-    mListView = NULL;
-    mView = NULL;
-
-    delete mActionConfirm;
-    mActionConfirm = NULL;
-    delete mModel;
-    mModel = NULL;
     mSortAttribute = AscendingNameHsSortAttribute;
 }
 
@@ -127,9 +121,6 @@
  Shows check box list with all application.
  \param sortAttribute order to sort applications.
  */
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
 void HsAppsCheckList::showAppsCheckboxList(HsSortAttribute sortOrder)
 {
     HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::showAppsCheckboxList");
@@ -139,84 +130,81 @@
     // fills model with data
     // constucts controls such as checklist
     constructControls();
-
-    // Add mListView to main window
-    HbMainWindow *hbMainWindow = mainWindow();
+    
+    if (mAppsSelectDialog) {
+        mAppsSelectDialog->setTimeout(HbPopup::NoTimeout);
+        mAppsSelectDialog->setAttribute(Qt::WA_DeleteOnClose);
+        mAppsSelectDialog->open(this,
+            SLOT(appsSelectionDialogFinished(HbAction*)));
+    }
 
-    // add confirm action
-    mView->setNavigationAction(mActionConfirm);
-
-    hbMainWindow->addView(mView);
-    // record the current view in order to activate it once done
-    mPreviousView = hbMainWindow->currentView();
-    hbMainWindow->setCurrentView(mView);
-    hbMainWindow->show();
     HSMENUTEST_FUNC_EXIT("HsAppsCheckList::showAppsCheckboxList");
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
+
 /*!
  Construct contrlos.
  */
 void HsAppsCheckList::constructControls()
 {
     HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::constructControls");
-    if (!mActionConfirm) {
-        mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView);
-        connect(mActionConfirm, SIGNAL(triggered()),SLOT(selectApplicationsDone()));
-    }
+
+    bool loadStatusOk = false;
+    HbDocumentLoader loader;
+    loader.load(HS_APP_CHECK_LIST_LAYOUT, &loadStatusOk);
 
-    if (!mView) { // it implies that mListView is NULL as well
-        bool loadStatusOk = false;
+    Q_ASSERT_X(loadStatusOk,
+                HS_APP_CHECK_LIST_LAYOUT,
+               "Error while loading docml file.");
 
-        HbDocumentLoader loader;
-        mLoadedObjects = loader.load(HS_APP_CHECK_LIST_LAYOUT, &loadStatusOk);
+    static const QString APPS_SELECTION_DIALOG("applications_selection_dialog");
+    mAppsSelectDialog =
+        qobject_cast<HbDialog *>(loader.findWidget(APPS_SELECTION_DIALOG));
 
-        Q_ASSERT_X(loadStatusOk,
-                    HS_APP_CHECK_LIST_LAYOUT,
-                   "Error while loading docml file.");
+    if (mAppsSelectDialog) {
+        static const QString LIST_VIEW_WIDGET("listView");
+        mListView = qobject_cast<HbListView *> (loader.findWidget(
+            LIST_VIEW_WIDGET));
+        mModel->setParent(mAppsSelectDialog);
+        mListView->setModel(mModel);
 
-        static const QString VIEW_WIDGET_NAME("view");
-        mView = qobject_cast<HbView *> (loader.findWidget(VIEW_WIDGET_NAME));
-        mView->setParent(this);
+        connect(mListView,SIGNAL(activated(const QModelIndex&) ),this
+                ,SLOT(selectedItemsChanged()));
+        connect(mModel,SIGNAL(rowsRemoved(const QModelIndex&, int,int)),
+        		this, SLOT(selectedItemsChanged()));
 
-        static const QString LIST_VIEW_WIDGET_NAME("listView");
-        mListView = qobject_cast<HbListView *> (loader.findWidget(
-                LIST_VIEW_WIDGET_NAME));
-        mListView->setModel(mModel);
+        // add confirm action
+        static const QString HS_APPS_SELECTION_DIALOG_CONFIRMATION_ACTION
+                ("aps_dialog_softkey_2_left");
+        mActionConfirm = qobject_cast<HbAction*>(loader.findObject(
+                        HS_APPS_SELECTION_DIALOG_CONFIRMATION_ACTION));
+        mActionConfirm->setEnabled(false);
+        mAppsSelectDialog->actions()[0]->setParent(mAppsSelectDialog);
+        mAppsSelectDialog->actions()[1]->setParent(mAppsSelectDialog);
     }
     HSMENUTEST_FUNC_EXIT("HsAppsCheckList::constructControls");
 }
 
 /*!
- Slot connected trrigger action of secondary soft key of check list box.
- It is called when done button is selected.
+ Action after closed application selection dialog.
+ \param finishedAction chosen action.
+ \retval void
  */
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
-void HsAppsCheckList::selectApplicationsDone()
+void HsAppsCheckList::appsSelectionDialogFinished(HbAction* finishedAction)
 {
-    HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::selectApplicationsDone");
-    // Remove mListView from main window and restore previous view.
-    HbMainWindow *hbMainWindow = mainWindow();
-    hbMainWindow->setCurrentView(mPreviousView);
-    hbMainWindow->removeView(mView);
-    
-    QItemSelectionModel *itemSelectionModel = mListView->selectionModel();
+    HSMENUTEST_FUNC_ENTRY("HsAppsCheckList::appsSelectionDialogFinished");
     QList<int> itemsList;
-    if (itemSelectionModel) {
-        QModelIndexList modelIndexList =
-            itemSelectionModel->selectedIndexes();
-        itemsList = getSortedItemsList(modelIndexList);
+    if (finishedAction == mActionConfirm) {
+        QItemSelectionModel *itemSelectionModel = mListView->selectionModel();
+        if (itemSelectionModel) {
+            QModelIndexList modelIndexList =
+                itemSelectionModel->selectedIndexes();
+            itemsList = getSortedItemsList(modelIndexList);
+        }
     }
+    mAppsSelectDialog = NULL;
     emit commit(itemsList);
-    HSMENUTEST_FUNC_EXIT("HsAppsCheckList::selectApplicationsDone");
+    HSMENUTEST_FUNC_EXIT("HsAppsCheckList::appsSelectionDialogFinished");
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
 
 /*!
  Returns list with selected items ids.
@@ -251,16 +239,13 @@
 }
 
 /*!
- Returns pointer to tha main window.
- \return Pointer to the main window.
+ Slot activated then user select or unselect item
  */
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC SKIP
-#endif //COVERAGE_MEASUREMENT
-HbMainWindow *HsAppsCheckList::mainWindow() const
+void HsAppsCheckList::selectedItemsChanged()
 {
-    return HbInstance::instance()->allMainWindows().value(0);
+    if (mListView->selectionModel()->hasSelection()) {
+        mActionConfirm->setEnabled(true);
+    } else {
+        mActionConfirm->setEnabled(false);
+    }
 }
-#ifdef COVERAGE_MEASUREMENT
-#pragma CTC ENDSKIP
-#endif //COVERAGE_MEASUREMENT
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hscollectionslistdialog.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description: Hs list dialog
- *
- */
-
-#include <HbAction>
-#include <HbLabel>
-#include <QDebug>
-#include <QStandardItemModel>
-
-#include <hsmenuservice.h>
-#include <hsmenuitemmodel.h>
-#include "hscollectionslistdialog.h"
-
-/*!
- \class HsCollectionsListDialog
- \ingroup group_hsworkerstateplugin
- \brief Hs List Dialog
- Hs List Dialog
- */
-
-/*!
- \var HsCollectionsListDialog::mModel
- Model.
- */
-
-/*!
- \var HsCollectionsListDialog::mItemId
- Selected item id.
- */
-
-/*!
- \fn void HsCollectionsListDialog::makeConnect();
- Connects edit line signals to slots.
-*/
-
-/*!
- \fn void HsCollectionsListDialog::makeDisconnect();
- Disconnects edit line signals from slots.
- */
-
-/*!
- Constructor
- \param sortOrder sort order.
- \param collectionId collectionId id of collection
- to remove from list.
- \retval void
- */
-HsCollectionsListDialog::HsCollectionsListDialog(int collectionId) :
-    HbSelectionDialog(), mItemId(0)
-{
-    clearActions();
-    HbAction *cancelAction = new HbAction(
-        hbTrId("txt_common_button_cancel"), this);
-    addAction(cancelAction);
-
-    setHeadingWidget(new HbLabel(hbTrId("txt_applib_title_add_to")));
-    // it must be single selection, although it shows checkboxes -
-    // it is Orbit defect and will be fixed in next release
-    setSelectionMode(HbAbstractItemView::SingleSelection);
-    mModel = standardItemModel(collectionId);
-    setModel(mModel);
-}
-
-/*!
- Destructor
- */
-HsCollectionsListDialog::~HsCollectionsListDialog()
-{
-    delete mModel;
-}
-
-/*!
- Executes dialog.
- \retval Selected action.
- */
-void HsCollectionsListDialog::open(QObject* receiver, const char* member)
-{
-    this->setAttribute(Qt::WA_DeleteOnClose);
-    HbSelectionDialog::open(receiver, member);
-}
-
-/*!
-    \reimp
-    Disconnects signals and calls base class impl. which emits finished(HbAction*)
- */
-void HsCollectionsListDialog::closeEvent (QCloseEvent * event)
-{
-    qDebug("HsCollectionsListDialog::closeEvent");
-    HbAction *closingAction = qobject_cast<HbAction *>(sender());
-
-    if (closingAction != actions().value(0)) {
-        QModelIndexList modlist = selectedModelIndexes();
-        if (modlist.count()) {
-            mItemId
-            = mModel-> data(modlist[0], CaItemModel::IdRole).toInt();
-        }
-    }
-
-    HbDialog::closeEvent(event); // emits finished(HbAction*)
-}
-
-/*!
- Creates standard item model.
- \param sortOrder sort order.
- \param collectionId id of collection to remove from model.
- \return QStandardItemModel - caller takes ownership.
- */
-QStandardItemModel *HsCollectionsListDialog::standardItemModel(
-    int collectionId)
-{
-    HSMENUTEST_FUNC_ENTRY("HsListDialog::standartItemModel");
-    QScopedPointer<HsMenuItemModel> caModel(
-        HsMenuService::getAllCollectionsModel());
-    caModel->setSecondLineVisibility(false);
-    QStandardItemModel *model = new QStandardItemModel(this);
-    QList<QStandardItem *> items;
-    for (int row = 0; row < caModel->rowCount(); row++) {
-        uint flags = caModel->data(caModel->index(row, 0),
-                                   CaItemModel::FlagsRole).value<EntryFlags> ();
-        int itemId = caModel->data(caModel->index(row, 0),
-                                   CaItemModel::IdRole).toInt();
-        if ((flags & RemovableEntryFlag) && (itemId != collectionId)) {
-            QStandardItem *standardItem = new QStandardItem();
-            standardItem->setData(caModel->data(caModel->index(row, 0),
-                                                CaItemModel::IdRole), CaItemModel::IdRole);
-            standardItem->setData(caModel->data(caModel->index(row, 0),
-                                                Qt::DisplayRole), Qt::DisplayRole);
-            standardItem->setData(caModel->data(caModel->index(row, 0),
-                                                Qt::DecorationRole), Qt::DecorationRole);
-            items << standardItem;
-        }
-    }
-    model->insertColumn(0, items);
-
-    insertNewCollectionItem(model);
-    HSMENUTEST_FUNC_EXIT("HsListDialog::standartItemModel");
-    return model;
-}
-
-/*!
- Inserts "new collection" item into model.
- \param model a model.
- */
-void HsCollectionsListDialog::insertNewCollectionItem(
-    QStandardItemModel *model)
-{
-    HSMENUTEST_FUNC_ENTRY("HsListDialog::insertNewCollectionItem");
-    QStandardItem *standardItem = new QStandardItem();
-    standardItem->setData(0, CaItemModel::IdRole);
-    standardItem->setData(hbTrId("txt_applib_list_new_collection"),
-                          Qt::DisplayRole);
-
-    standardItem->setData(HbIcon(defaultCollectionIconId()),
-                          Qt::DecorationRole);
-
-    QList<QStandardItem *> items;
-    items << standardItem;
-    model->insertRow(0, items);
-    HSMENUTEST_FUNC_EXIT("HsListDialog::insertNewCollectionItem");
-}
-
-/*!
- Gets selected item id.
- \retval Selected item id.
- */
-int HsCollectionsListDialog::getItemId()
-{
-    return mItemId;
-}
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsinstallationlogstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsinstallationlogstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -140,6 +140,8 @@
                         newLine + newLine;
             }
         }
+
+        applicationsList.chop(2 * newLine.size());
         logList->setPlainText(applicationsList);
     
         mInstalationLogDialog->open(this, SLOT(stateExited()));
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hspreviewhswidgetstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -15,7 +15,6 @@
  *
 */
 
-
 #include <hblabel.h>
 #include <hbmessagebox.h>
 #include <qstatemachine.h>
@@ -40,6 +39,7 @@
 #include "hsscene.h"
 #include "hspage.h"
 
+
 #include "canotifier.h"
 #include "canotifierfilter.h"
 #include "caservice.h"
@@ -64,9 +64,10 @@
 HsPreviewHSWidgetState::HsPreviewHSWidgetState(QState *parent) :
     QState(parent),
     mPreviewDialog(0),
-    mNotifier(0),
     mEntryId(0),
     mCorruptedMessage(0),
+    mConfirmRemovalAction(0),
+    mAddToHomescreenAction(0),
     mToken(),
     mUri()
 {
@@ -112,10 +113,14 @@
         CaService::instance()->getEntry(mEntryId);
     mUri = entry->attribute(widgetUriAttributeName());
     mPreviewDialog = buildPreviewDialog(*entry);
-
+    mAddToHomescreenAction = mPreviewDialog->actions().value(0);
+    
     if (mPreviewDialog != NULL) {
-        subscribeForMemoryCardRemove();
         // Launch popup asyncronously
+        
+        mEntryObserver.reset(
+            new HsMenuEntryRemovedHandler(mEntryId, this, SIGNAL(exit())));
+        
         mPreviewDialog->open(this, SLOT(previewDialogFinished(HbAction*)));
     }
 
@@ -128,29 +133,17 @@
  */
 void HsPreviewHSWidgetState::cleanUp()
 {
-    // Close popups if App key was pressed or memory card removed
-    if (mPreviewDialog) {
-        disconnect(mPreviewDialog, SIGNAL(finished(HbAction*)), 
-            this, SLOT(previewDialogFinished(HbAction*)));
+    if (mPreviewDialog != NULL) {
         mPreviewDialog->close();
         mPreviewDialog = NULL;
     }
-
-    if (mCorruptedMessage) {
-        disconnect(mCorruptedMessage, SIGNAL(finished(HbAction*)), 
-            this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
+    
+    if (mCorruptedMessage != NULL) {
         mCorruptedMessage->close();
         mCorruptedMessage = NULL;
     }
-
+    mEntryObserver.reset(0);
     mToken = NULL;
-
-    disconnect(mNotifier,
-               SIGNAL(entryChanged(CaEntry,ChangeType)),
-               this, SIGNAL(exit()));
-
-    delete mNotifier;
-    mNotifier = NULL;
 }
 
 /*!
@@ -159,7 +152,9 @@
  */
 void HsPreviewHSWidgetState::previewDialogFinished(HbAction* finishedAction)
 {
-    if (static_cast<QAction*>(finishedAction) == mPreviewDialog->actions().value(0)) {
+    mPreviewDialog = NULL;
+
+    if (finishedAction == mAddToHomescreenAction) {
 
         QVariantHash widgetData;
         widgetData[URI] = mUri;
@@ -175,29 +170,12 @@
             emit exit();
         }
         else {
-            mPreviewDialog = NULL;
             showMessageWidgetCorrupted();            
         }
     } else {
         emit exit();
     }
-}
-
-/*!
- Subscribe for memory card remove.
- \retval void
- */
-void HsPreviewHSWidgetState::subscribeForMemoryCardRemove()
-{
-    CaNotifierFilter filter;
-    QList<int> entryIds;
-    entryIds.append(mEntryId);
-    filter.setIds(entryIds);
-    mNotifier = CaService::instance()->createNotifier(filter);
-    mNotifier->setParent(this);
-    connect(mNotifier,
-            SIGNAL(entryChanged(CaEntry,ChangeType)),
-            SIGNAL(exit()));
+    mAddToHomescreenAction = 0;
 }
 
 /*!
@@ -211,7 +189,9 @@
     mCorruptedMessage = HsMenuDialogFactory().create(
             hbTrId("txt_applib_dialog_file_corrupted_unable_to_use_wi"));
 
-    mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
+    mConfirmRemovalAction = mCorruptedMessage->actions().value(0);
+    mCorruptedMessage
+        ->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*)));
 
     HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted");
 }
@@ -222,10 +202,14 @@
  */
 void HsPreviewHSWidgetState::messageWidgetCorruptedFinished(HbAction* finishedAction)
 {
-    if (static_cast<QAction*>(finishedAction) == mCorruptedMessage->actions().value(0)) {
+    mCorruptedMessage = NULL;
+	
+    if (static_cast<QAction*>(finishedAction) == mConfirmRemovalAction) {
         HsMenuService::executeAction(mEntryId, removeActionIdentifier());
     }
     emit exit();
+    
+    mConfirmRemovalAction = NULL;
 }
 
 /*!
@@ -249,7 +233,7 @@
     HbLabel *const iconBox =
         qobject_cast<HbLabel*>(
             loader.findWidget(HS_WIDGET_PREVIEW_ICON_BOX_NAME));
-    
+
     loadStatusOk = loadStatusOk && (previewDialog != NULL)
         && (headingLabel != NULL) && (iconBox != NULL);
     
@@ -258,8 +242,8 @@
            "Cannot initialize widgets based on docml file.");
     
     if (loadStatusOk) {
-        previewDialog->actions()[0]->setParent(previewDialog);
-        previewDialog->actions()[1]->setParent(previewDialog);
+        previewDialog->actions().value(0)->setParent(previewDialog);
+        previewDialog->actions().value(1)->setParent(previewDialog);
         
         previewDialog->setTimeout(HbPopup::NoTimeout);
         previewDialog->setAttribute(Qt::WA_DeleteOnClose, true);
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsuninstallitemstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsuninstallitemstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -24,7 +24,7 @@
 #include <HbListView>
 #include <HbParameterLengthLimiter>
 
-
+#include <QScopedPointer>
 #include <QStandardItemModel>
 #include <QStandardItem>
 #include <casoftwareregistry.h>
@@ -34,7 +34,7 @@
 #include "hsuninstallitemstate.h"
 #include "hsmenuevent.h"
 #include "hsmenudialogfactory.h"
-
+#include "hsmenuentryremovedhandler.h"
 /*!
  \class HsUninstallItemState
  \ingroup group_hsworkerstateplugin
@@ -49,7 +49,6 @@
 HsUninstallItemState::HsUninstallItemState(QState *parent) :
     QState(parent),
     mItemId(0),
-    mNotifier(NULL),
     mUninstallMessage(NULL),
     mUninstallJavaMessage(NULL),
     mConfirmAction(NULL)
@@ -75,6 +74,7 @@
         setObjectName(this->parent()->objectName() + objectName());
     }
     connect(this, SIGNAL(exited()), SLOT(cleanUp()));
+    
 }
 
 /*!
@@ -99,9 +99,7 @@
         // other
         createUninstallMessage();
     }
-    
-    subscribeForMemoryCardRemove();
-
+        
     HSMENUTEST_FUNC_EXIT("HsUninstallItemState::onEntry");
 }
 
@@ -116,6 +114,8 @@
         HsMenuService::executeAction(mItemId, removeActionIdentifier());
     }
     mConfirmAction = NULL;
+    mUninstallMessage = NULL;
+	mUninstallJavaMessage = NULL;
     emit exit();
 }
 
@@ -165,19 +165,6 @@
     return retval;
 }
 
-/*!
- Subscribe for memory card remove.
- */
-void HsUninstallItemState::subscribeForMemoryCardRemove()
-{
-    CaNotifierFilter filter;
-    filter.setIds(QList<int>() << mItemId);
-    mNotifier = CaService::instance()->createNotifier(filter);
-    mNotifier->setParent(this);
-    connect(mNotifier,
-        SIGNAL(entryChanged(CaEntry,ChangeType)),
-        SIGNAL(exit()));
-}
 
 /*!
  Slot launched after state has exited and in destructor.
@@ -186,21 +173,16 @@
 void HsUninstallItemState::cleanUp()
 {
     // Close messagebox if App key was pressed
-    if (mUninstallMessage) {
-        disconnect(mUninstallMessage, SIGNAL(finished(HbAction*)),
-            this, SLOT(uninstallMessageFinished(HbAction*)));
+    if (mUninstallMessage != NULL) {
         mUninstallMessage->close();
         mUninstallMessage = NULL;
     }
     
-    if (mUninstallJavaMessage) {
-        disconnect(mUninstallJavaMessage, SIGNAL(finished(HbAction*)), this, SLOT(uninstallMessageFinished(HbAction*)));
+    if (mUninstallJavaMessage != NULL) {
         mUninstallJavaMessage->close();
         mUninstallJavaMessage = NULL;
     }
 
-    delete mNotifier;
-    mNotifier = NULL;
     mConfirmAction = NULL;
     mItemId = 0;
 }
@@ -230,6 +212,39 @@
     // create and show message box
     mUninstallMessage = HsMenuDialogFactory().create(message);
     mConfirmAction = mUninstallMessage->actions().value(0);
+    
+    QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+        new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit())));
+    entryObserver.take()->setParent(mUninstallMessage);
+    
+    mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
+}
+
+/*!
+ Method create uninstall confirmation message.
+ Used for java applications without deletion confirmation
+ and with midlet name equal to app name
+ \retval void
+ */
+void HsUninstallItemState::createSimpleUninstallJavaMessage()
+{
+    QString message;
+    message.append(
+        HbParameterLengthLimiter("txt_applib_info_remove_1_all_its_shortcuts_and").arg(
+            HsMenuService::getName(mItemId)));
+
+    // create and show message box
+    mUninstallMessage = HsMenuDialogFactory().create(message);
+    
+    QSharedPointer<CaEntry> entry = CaService::instance()->getEntry(mItemId);
+    HbIcon icon = entry->makeIcon();
+    mUninstallMessage->setIcon(icon);
+    mConfirmAction = mUninstallMessage->actions().value(0);
+
+    QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+        new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit())));
+    entryObserver.take()->setParent(mUninstallMessage);
+
     mUninstallMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
 }
 
@@ -253,74 +268,80 @@
     getApplicationsNames(componentName, applicationsNames, detailsMessage);
     
     QString section;
-    if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) {
-        mDialogType = UninstallDialogDefinition01;
-        section = QString("uninstallDialogDefinition01");
-        loader.load(
+    if (applicationsNames.isEmpty() && detailsMessage.isEmpty()) {        
+        createSimpleUninstallJavaMessage();        
+    }
+    else {
+        if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) {
+            mDialogType = UninstallDialogDefinition02;
+            section = QString("uninstallDialogDefinition02");
+            loader.load(
                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
-    } else if ( (!applicationsNames.isEmpty()) && (!detailsMessage.isEmpty())) {
-        mDialogType = UninstallDialogDefinition02;
-        section = QString("uninstallDialogDefinition02");
-        loader.load(
-                HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
-    } else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) {
-        mDialogType = UninstallDialogDefinition03;
-        section = QString("uninstallDialogDefinition03");
-        loader.load(
+        }
+        else if ( (!applicationsNames.isEmpty() && detailsMessage.isEmpty())) {
+            mDialogType = UninstallDialogDefinition03;
+            section = QString("uninstallDialogDefinition03");
+            loader.load(
                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
-    } else if (applicationsNames.isEmpty()  && (!detailsMessage.isEmpty())) {
-        mDialogType = UninstallDialogDefinition04;
-        section = QString("uninstallDialogDefinition04");
-        loader.load(
+        }
+        else if (applicationsNames.isEmpty() && (!detailsMessage.isEmpty())) {
+            mDialogType = UninstallDialogDefinition04;
+            section = QString("uninstallDialogDefinition04");
+            loader.load(
                 HS_UNINSTALL_DIALOG_LAYOUT, section, &loadStatusOk);
-    }
- 
-    mUninstallJavaMessage = 
-        qobject_cast<HbDialog*>(
+        }
+
+        mUninstallJavaMessage = qobject_cast<HbDialog*>(
             loader.findWidget(HS_UNINSTALL_DIALOG_NAME));
-    if (mUninstallJavaMessage != NULL) {
-        mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose);
-        mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout);
-        mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage);
-        mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage);
-    
-        HbLabel* iconLabel =
+
+        if (mUninstallJavaMessage) {
+            mUninstallJavaMessage->setAttribute(Qt::WA_DeleteOnClose);
+            mUninstallJavaMessage->setTimeout(HbPopup::NoTimeout);
+            mUninstallJavaMessage->actions()[0]->setParent(mUninstallJavaMessage);
+            mUninstallJavaMessage->actions()[1]->setParent(mUninstallJavaMessage);
+
+            HbLabel* iconLabel =
             qobject_cast<HbLabel*>(
                 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_ICON));
-        QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId);
-        HbIcon icon = entry2->makeIcon();
-        iconLabel->setIcon(icon);
-    
-        HbLabel* textLabel =
+            QSharedPointer<CaEntry> entry2 = CaService::instance()->getEntry(mItemId);
+            HbIcon icon = entry2->makeIcon();
+            iconLabel->setIcon(icon);
+
+            HbLabel* textLabel =
             qobject_cast<HbLabel*>(
                 loader.findWidget(HS_UNINSTALL_DIALOG_CONFIRMATION_DIALOG_LABEL));
-        textLabel->setPlainText(textLabel->plainText().arg(componentName));
-    
-        HbLabel* detailsUninstalLabel;
-        if ((mDialogType == UninstallDialogDefinition02) ||
-            (mDialogType == UninstallDialogDefinition04)) {
-            detailsUninstalLabel= qobject_cast<HbLabel*>(
+            textLabel->setPlainText(textLabel->plainText().arg(componentName));
+
+            HbLabel* detailsUninstalLabel;
+            if ((mDialogType == UninstallDialogDefinition02) ||
+                (mDialogType == UninstallDialogDefinition04)) {
+                detailsUninstalLabel= qobject_cast<HbLabel*>(
                     loader.findWidget(HS_UNINSTALL_DIALOG_DELETE_LABEL));
-            detailsUninstalLabel->setPlainText(detailsMessage);
-        }
+                detailsUninstalLabel->setPlainText(detailsMessage);
+            }
 
-        HbLabel* listView;
-        QString applicationsList;
-        QString newLine("\n");
-        if ((mDialogType == UninstallDialogDefinition02) ||
-            (mDialogType == UninstallDialogDefinition03)) {
-            listView = qobject_cast<HbLabel*>(
+            HbLabel* listView;
+            QString applicationsList;
+            QString newLine("\n");
+            if ((mDialogType == UninstallDialogDefinition02) ||
+                (mDialogType == UninstallDialogDefinition03)) {
+                listView = qobject_cast<HbLabel*>(
                     loader.findWidget(HS_UNINSTALL_DIALOG_LIST_VIEW_LABEL));
 
-            for (int i=0; i<applicationsNames.count(); i++) {
-                applicationsList = applicationsList + applicationsNames[i] + newLine;
+                for (int i=0; i<applicationsNames.count(); i++) {
+                    applicationsList = applicationsList + applicationsNames[i] + newLine;
+                }
+                listView->setPlainText(applicationsList);
             }
-            listView->setPlainText(applicationsList);
+
+            mConfirmAction = qobject_cast<HbAction*>(loader.findObject(
+                    HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION));
+        
+            QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+                new HsMenuEntryRemovedHandler(mItemId, this, SIGNAL(exit())));
+            entryObserver.take()->setParent(mUninstallJavaMessage);
+            
+            mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
         }
-
-        mConfirmAction = qobject_cast<HbAction*>(loader.findObject(
-                HS_UNINSTALL_DIALOG_CONFIRMATION_ACTION));
-    
-        mUninstallJavaMessage->open(this, SLOT(uninstallMessageFinished(HbAction*)));
     }
 }
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappdetailsstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -16,6 +16,7 @@
 */
 
 #include <QDebug>
+#include <QScopedPointer>
 #include <HbDialog>
 #include <HbDocumentLoader>
 #include <HbLabel>
@@ -30,6 +31,7 @@
 #include "hsviewappdetailsstate.h"
 #include "hsmenuevent.h"
 #include "hsmenuitemmodel.h"
+#include "hsmenuentryremovedhandler.h"
 
 static const char *const HS_VIEWAPPDETAILS_JAVA_DIALOG_SECTION_NAME=
         "detailsDialogForJavaApplication";
@@ -39,7 +41,7 @@
  /param parent Parent state.
  */
 HsViewAppDetailsState::HsViewAppDetailsState(QState *parent) :
-    QState(parent), mDialog(0), mNotifier(0)
+    QState(parent), mDialog(0)
 {
     construct();
 }
@@ -49,9 +51,7 @@
  */
 HsViewAppDetailsState::~HsViewAppDetailsState()
 {
-    if (mDialog) {
-        delete mDialog;
-    }
+    delete mDialog;
 }
 
 /*!
@@ -92,6 +92,7 @@
     
     //TODO: Should we display something In that case?
     if (detailMap.size() < 1){
+        stateExited();
         return;
     }
     
@@ -114,9 +115,7 @@
         mDialog->setTimeout(HbPopup::NoTimeout);
         mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
         mDialog->actions()[0]->setParent(mDialog);
-
-        subscribeForMemoryCardRemove(entryId);
-      
+        
         setFieldPresentation(CaSoftwareRegistry::componentNameKey(),
             detailMap, loader);
         setFieldPresentation(CaSoftwareRegistry::componentVersionKey(),
@@ -136,7 +135,15 @@
             setFieldPresentation(CaSoftwareRegistry::componentProtectionDomainKey(),
                 detailMap, loader);
         }
-        mDialog->open(this, SLOT(stateExited())); 
+        
+        QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+            new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit())));
+        
+        entryObserver.take()->setParent(mDialog);
+        
+        mDialog->open(this, SLOT(stateExited()));
+    } else {
+        stateExited();
     }
     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::onEntry");
 }
@@ -174,7 +181,6 @@
 void HsViewAppDetailsState::stateExited()
 {
     HSMENUTEST_FUNC_ENTRY("HsViewAppDetailsState::stateExited");
-    mDialog = NULL;
     emit exit();
     HSMENUTEST_FUNC_EXIT("HsViewAppDetailsState::stateExited");
     qDebug("HsViewAppDetailsState::stateExited()");
@@ -188,26 +194,9 @@
     QState::onExit(event);
     // Close popups if App key was pressed or
     // memory card removed
-    if (mDialog) {
+    if (mDialog != NULL) {
         mDialog->close();
+        mDialog = NULL;
     }
-    mDialog = NULL;
 }
 
-/*!
- Subscribe for memory card remove.
- \param entryId: entry id.
- \retval void
- */
-void HsViewAppDetailsState::subscribeForMemoryCardRemove(int entryId)
-{
-    CaNotifierFilter filter;
-    QList<int> entryIds;
-    entryIds.append(entryId);
-    filter.setIds(entryIds);
-    mNotifier = CaService::instance()->createNotifier(filter);
-    mNotifier->setParent(this);
-    connect(mNotifier,
-            SIGNAL(entryChanged(CaEntry,ChangeType)),
-            SIGNAL(exit()));
-}
--- a/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappsettingsstate.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsviewappsettingsstate.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -14,7 +14,7 @@
 * Description:  Menu Application Library state.
  *
 */
-
+#include <QScopedPointer>
 #include <hbmainwindow.h>
 #include <hbview.h>
 #include <hbinstance.h>
@@ -26,6 +26,7 @@
 #include "hsapp_defs.h"
 #include "hsmenuevent.h"
 #include "hsviewappsettingsstate.h"
+#include "hsmenuentryremovedhandler.h"
 #include "caentry.h"
 #include "canotifier.h"
 #include "canotifierfilter.h"
@@ -64,9 +65,7 @@
         QState(parent),
         mView(0), 
         mPreviousView(0), 
-        mActionConfirm(0),
-        mNotifier(0)
-        
+        mActionConfirm(0)
 {
     construct();
 }
@@ -87,9 +86,6 @@
  */
 HsViewAppSettingsState::~HsViewAppSettingsState()
 {
-    if (mNotifier) {
-        delete mNotifier;
-    }    
 }
 
 /*!
@@ -109,15 +105,20 @@
     QSharedPointer<const CaEntry> entry = CaService::instance()->getEntry(entryId);    
     
     QString pluginPath;
-    pluginPath = pluginPath.append("/resource/qt/plugins/appsettings/").append(entry->attribute(appSettingsPlugin())).append(".qtplugin");
+    pluginPath = pluginPath.append("/resource/qt/plugins/appsettings/")
+        .append(entry->attribute(appSettingsPlugin())).append(".qtplugin");
     QPluginLoader loader(pluginPath);
     mView = qobject_cast<HbView *>(loader.instance()); 
     
     mActionConfirm = new HbAction(Hb::ConfirmNaviAction, mView);
-    connect(mActionConfirm, SIGNAL(triggered()),SLOT(settingsDone()));
+    connect(mActionConfirm, SIGNAL(triggered()), SIGNAL(exit()));
     
     if (mView) {    
-        subscribeForMemoryCardRemove(entryId);
+        QScopedPointer<HsMenuEntryRemovedHandler> entryObserver(
+            new HsMenuEntryRemovedHandler(entryId, this, SIGNAL(exit())));
+        
+        entryObserver.take()->setParent(mView);
+        
         QObject::connect(this, SIGNAL(initialize(QString)), mView, SLOT(initialize(QString)));        
         mView->setParent(this);
         emit initialize(entry->attribute(applicationUidEntryKey()));        
@@ -154,32 +155,6 @@
 #endif //COVERAGE_MEASUREMENT
 
 
-/*!
- Invoked when plugin view exits
- */
-void HsViewAppSettingsState::settingsDone()
-{
-    emit exit();
-}
-
-/*!
- Subscribe for memory card remove.
- \param entryId: entry id.
- \retval void
- */
-void HsViewAppSettingsState::subscribeForMemoryCardRemove(int entryId)
-{
-    CaNotifierFilter filter;
-    QList<int> entryIds;
-    entryIds.append(entryId);
-    filter.setIds(entryIds);
-    mNotifier = CaService::instance()->createNotifier(filter);
-    mNotifier->setParent(this);
-    connect(mNotifier,
-            SIGNAL(entryChanged(CaEntry,ChangeType)),
-            SLOT(settingsDone()));
-}
-
 void HsViewAppSettingsState::onExit(QEvent *event)
 {
     
@@ -188,12 +163,7 @@
     HbMainWindow *hbMainWindow = mainWindow();
     hbMainWindow->setCurrentView(mPreviousView);
     hbMainWindow->removeView(mView);
-    disconnect(mNotifier,
-               SIGNAL(entryChanged(CaEntry,ChangeType)),
-               this,
-               SLOT(settingsDone()));
-    delete mNotifier;
-    mNotifier = NULL;
+
     
     delete mActionConfirm;
     mActionConfirm = NULL;
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/hsclockwidgetplugin.pro	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/hsclockwidgetplugin.pro	Fri Jul 23 13:47:57 2010 +0300
@@ -38,7 +38,7 @@
     
 }
 
-win32:include(hsclockwidgetplugin_win.pri)
+!symbian:include(hsclockwidgetplugin_win.pri)
 symbian:include(hsclockwidgetplugin_symbian.pri)
 
 RESOURCES = hsclockwidgetplugin.qrc
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsanalogclockwidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsanalogclockwidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -25,7 +25,7 @@
 HOMESCREEN_TEST_CLASS(TestClockWidget)
 
 class HbIconItem;
-class HbTouchArea;
+class QGestureEvent;
 
 class HsAnalogClockWidget : public HbWidget
 {
@@ -35,7 +35,6 @@
     explicit HsAnalogClockWidget(QGraphicsItem *parent = 0);
     ~HsAnalogClockWidget();
 
-    bool eventFilter(QObject *watched, QEvent *event);
     QRectF boundingRect() const;
     QPainterPath shape() const;
 
@@ -47,19 +46,18 @@
 
 protected:
     void resizeEvent(QGraphicsSceneResizeEvent *event);
+    void gestureEvent(QGestureEvent *event);
 
 private:
     Q_DISABLE_COPY(HsAnalogClockWidget)
     void createPrimitives();
     void updatePrimitives();
-    void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
 
 private:
     HbIconItem *mBackground;
     HbIconItem *mHourHand;
     HbIconItem *mMinuteHand;
     HbIconItem *mSecondHand;
-    HbTouchArea *mTouchArea;
 
     HOMESCREEN_TEST_FRIEND_CLASS(TestClockWidget)
 };
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsdigitalclockwidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/inc/hsdigitalclockwidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -26,7 +26,7 @@
 
 class HbFrameItem;
 class HbIconItem;
-class HbTouchArea;
+class QGestureEvent;
 
 class HsDigitalClockWidget : public HbWidget
 {
@@ -36,7 +36,6 @@
     explicit HsDigitalClockWidget(bool useAmPm = true, QGraphicsItem *parent = 0);
     ~HsDigitalClockWidget();
 
-    bool eventFilter(QObject *watched, QEvent *event);
     QPainterPath shape() const;
 signals:
     void clockTapped();
@@ -47,12 +46,12 @@
 
 protected:
     void resizeEvent(QGraphicsSceneResizeEvent *event);
+    void gestureEvent(QGestureEvent *event);
 
 private:
     Q_DISABLE_COPY(HsDigitalClockWidget)
     void createPrimitives();
     void updatePrimitives();
-    void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
 
 private:
     HbFrameItem *mBackground;
@@ -63,7 +62,6 @@
     HbIconItem *mDigit5;
     HbIconItem *mDigit6;
     HbIconItem *mAmPm;
-    HbTouchArea *mTouchArea;
     bool mUseAmPm;
     QMap<QChar, QString> mDigitMap;
     
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.css	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.css	Fri Jul 23 13:47:57 2010 +0300
@@ -25,7 +25,3 @@
   fixed-height: 25.0un;
   zvalue: 1;
 }
-
-HsAnalogClockWidget::toucharea {  
-  zvalue: 4;
-}
\ No newline at end of file
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.widgetml	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsanalogclockwidget.widgetml	Fri Jul 23 13:47:57 2010 +0300
@@ -21,10 +21,6 @@
         <meshitem src="second_hand" srcEdge="LEFT" dst="" dstEdge="LEFT" />
         <meshitem src="second_hand" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
 
-        <meshitem src="toucharea" srcEdge="TOP" dst="" dstEdge="TOP" />
-        <meshitem src="toucharea" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
-        <meshitem src="toucharea" srcEdge="LEFT" dst="" dstEdge="LEFT" />
-        <meshitem src="toucharea" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     </layout>
 
 </hbwidget>
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.css	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.css	Fri Jul 23 13:47:57 2010 +0300
@@ -65,6 +65,3 @@
   zvalue: 2;
 }
 
-HsDigitalClockWidget::toucharea {  
-  zvalue: 4;
-}
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.widgetml	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/hsdigitalclockwidget.widgetml	Fri Jul 23 13:47:57 2010 +0300
@@ -27,10 +27,6 @@
         <meshitem src="digit6" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
         <meshitem src="digit6" srcEdge="LEFT" dst="digit5" dstEdge="RIGHT" />
 
-        <meshitem src="toucharea" srcEdge="TOP" dst="" dstEdge="TOP" />
-        <meshitem src="toucharea" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
-        <meshitem src="toucharea" srcEdge="LEFT" dst="" dstEdge="LEFT" />
-        <meshitem src="toucharea" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     </layout>
     
 </hbwidget>
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/qtg_graf_hswidget_preview_clock.svg	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/resource/qtg_graf_hswidget_preview_clock.svg	Fri Jul 23 13:47:57 2010 +0300
@@ -1,49 +1,161 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="224px" height="140px" viewBox="0 0 224 140">
-<rect fill="#FFFFFF" width="224" height="140"/>
-<rect x="57" y="14.619" fill="none" width="110" height="110"/>
-<circle fill="none" stroke="#404040" stroke-width="3.5" stroke-opacity="0.4" cx="111.999" cy="69.618" r="54.053"/>
-<circle fill="none" stroke="#404040" stroke-width="1.4883" stroke-opacity="0.4" cx="111.999" cy="69.617" r="54.069"/>
-<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.02" y1="206.9834" x2="21.02" y2="98.1177" gradientTransform="matrix(1 0 0 -1 90.98 221.9902)">
-<stop offset="0" style="stop-color:#DBDBDB"/>
-<stop offset="0" style="stop-color:#C1C1C1"/>
-<stop offset="0.53" style="stop-color:#DBDBDB"/>
-<stop offset="0.53" style="stop-color:#C1C1C1"/>
-<stop offset="1" style="stop-color:#A8A8A8"/>
+<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="320px" height="210px" viewBox="-9 14 320 210">
+<path fill-opacity="0.4" stroke-opacity="0.4" d="M150.999,188.197c-38.155,0-69.195-31.039-69.195-69.195  c0-38.154,31.04-69.196,69.195-69.196c38.155,0,69.194,31.042,69.194,69.196C220.193,157.158,189.154,188.197,150.999,188.197  L150.999,188.197z"/>
+<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="336.9785" y1="-63.1782" x2="336.9785" y2="-201.4114" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
+<stop offset="0" style="stop-color:#DCDCDC"/>
+<stop offset="0.6" style="stop-color:#C0C0C0"/>
+<stop offset="1" style="stop-color:#A7A7A7"/>
 </linearGradient>
-<circle fill="url(#SVGID_1_)" cx="111.999" cy="69.619" r="53.991"/>
-<circle fill="none" stroke="#FFFFFF" stroke-width="1.1" stroke-opacity="0.4" cx="111.999" cy="69.619" r="53.728"/>
-<circle fill="none" stroke="#E6E6E6" stroke-width="2.3" cx="111.999" cy="69.618" r="48.839"/>
-<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="21.02" y1="201.0898" x2="21.02" y2="104.9416" gradientTransform="matrix(1 0 0 -1 90.98 221.9902)">
+<circle fill="url(#SVGID_1_)" cx="150.999" cy="119.002" r="68.555"/>
+<path fill-opacity="0.4" stroke-opacity="0.4" fill="#FFFFFF" d="M150.999,50.447c-37.862,0-68.556,30.691-68.556,68.555  c0,37.861,30.693,68.555,68.556,68.555c37.862,0,68.556-30.693,68.556-68.555C219.555,81.139,188.861,50.447,150.999,50.447z   M150.999,186.916c-37.448,0-67.914-30.467-67.914-67.914c0-37.449,30.466-67.915,67.914-67.915  c37.446,0,67.914,30.466,67.914,67.915C218.913,156.449,188.445,186.916,150.999,186.916z"/>
+<path fill="#E5E5E5" d="M150.999,181.791c-34.622,0-62.789-28.166-62.789-62.789s28.167-62.789,62.789-62.789  s62.788,28.166,62.788,62.789S185.621,181.791,150.999,181.791L150.999,181.791z"/>
+<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="336.9795" y1="-194.0273" x2="336.9795" y2="-71.0137" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
+<stop offset="0" style="stop-color:#FFFFFF"/>
+<stop offset="0.4121" style="stop-color:#DCDCDC"/>
+<stop offset="0.9455" style="stop-color:#CBCBCB"/>
+<stop offset="1" style="stop-color:#CBCBCB"/>
+</linearGradient>
+<circle fill="url(#SVGID_2_)" cx="150.999" cy="119.001" r="61.507"/>
+<path fill-opacity="0.5" stroke-opacity="0.5" d="M150.999,57.494c-33.971,0-61.508,27.538-61.508,61.508  c0,33.969,27.537,61.506,61.508,61.506c33.97,0,61.508-27.537,61.508-61.506C212.507,85.032,184.969,57.494,150.999,57.494z   M150.999,179.875c-33.565,0-60.874-27.307-60.874-60.873c0-33.565,27.309-60.873,60.874-60.873  c33.565,0,60.876,27.308,60.876,60.873C211.875,152.568,184.564,179.875,150.999,179.875z"/>
+<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="336.9795" y1="-186.9824" x2="336.9795" y2="-78.0605" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
+<stop offset="0" style="stop-color:#B4B4B4"/>
+<stop offset="1" style="stop-color:#A0A0A0"/>
+</linearGradient>
+<circle fill="url(#SVGID_3_)" cx="150.999" cy="119.002" r="54.461"/>
+<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="336.9785" y1="-79.3413" x2="336.9785" y2="-185.6992" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
 <stop offset="0" style="stop-color:#FFFFFF"/>
-<stop offset="0.56" style="stop-color:#CCCCCC"/>
-<stop offset="1" style="stop-color:#E6E6E6"/>
-</linearGradient>
-<circle fill="url(#SVGID_2_)" cx="111.999" cy="69.618" r="48.44"/>
-<circle fill="none" stroke="#000000" stroke-opacity="0.5" cx="111.999" cy="69.617" r="48.157"/>
-<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="40.4355" y1="184.1553" x2="40.4355" y2="156.1365" gradientTransform="matrix(1 0 0 -1 90.98 221.9902)">
-<stop offset="0" style="stop-color:#FFFFFF"/>
-<stop offset="1" style="stop-color:#B3B3B3"/>
+<stop offset="0.9455" style="stop-color:#CBCBCB"/>
+<stop offset="1" style="stop-color:#CBCBCB"/>
 </linearGradient>
-<path fill="url(#SVGID_3_)" fill-opacity="0.5" d="M120.316,66.446c-3.05,0-4.729-1.768-4.729-4.977V50.475  c0-3.331,2.766-4.513,5.135-4.513h0.222c0.198,0,0.215-0.002,0.375-0.007l0.13-0.005c1.279-0.044,2.646-0.969,2.644-3.433  c-0.001-2.085,0.564-3.615,1.682-4.544c0.958-0.795,2.099-0.961,2.889-0.961c0.558,0,0.952,0.083,0.968,0.089  c11.037,1.901,16.931,11.18,17.581,17.158c0.188,1.701-0.431,3.575-1.609,4.889c-0.792,0.879-2.201,1.928-4.439,1.928  c-3.351,0-4.679,1.155-5.387,2.025l-0.2,0.249c-0.919,1.159-2.459,3.097-5.764,3.097H120.316z"/>
-<path fill="#B3B3B3" fill-opacity="0.4" d="M147.211,54.258c-0.65-5.978-6.544-15.256-17.581-17.158  c-0.016-0.005-0.41-0.089-0.968-0.089c-0.789,0-1.931,0.166-2.889,0.961c-1.117,0.93-1.683,2.459-1.682,4.544  c0.002,2.463-1.364,3.389-2.644,3.433l-0.13,0.005c-0.16,0.005-0.179,0.007-0.375,0.007h-0.222c-2.369,0-5.135,1.182-5.135,4.513  v10.995c0,3.209,1.68,4.977,4.729,4.977h9.495c3.305,0,4.845-1.938,5.764-3.097l0.2-0.249c0.708-0.87,2.036-2.025,5.387-2.025  c2.238,0,3.647-1.049,4.439-1.928C146.78,57.833,147.398,55.959,147.211,54.258z M141.162,60.571c-3.538,0-4.989,1.242-5.777,2.211  c-0.919,1.13-2.279,3.16-5.572,3.16c-3.295,0-5.888,0-9.496,0c-3.604,0-4.224-2.559-4.224-4.473c0-1.914,0-10.995,0-10.995  c0-2.97,2.403-4.009,4.629-4.009c0.503,0,0.382,0.002,0.746-0.01c1.671-0.059,3.134-1.298,3.13-3.939  c-0.003-6.013,4.927-4.923,4.927-4.923c10.858,1.872,16.565,11.015,17.187,16.72C147,56.975,145.119,60.571,141.162,60.571z"/>
-<ellipse fill="#FFFFFF" fill-opacity="0.25" cx="111.999" cy="44.893" rx="32.798" ry="22.203"/>
-<path fill="#808080" d="M107.654,32.983h-0.033l-1.853,1.001l-0.28-1.1l2.329-1.246h1.229v10.659h-1.393V32.983z M111.702,42.298  v-0.885l1.133-1.099c2.722-2.591,3.969-3.968,3.969-5.575c0-1.084-0.51-2.084-2.101-2.084c-0.966,0-1.771,0.493-2.263,0.903  l-0.458-1.017c0.723-0.608,1.786-1.083,3.001-1.083c2.296,0,3.264,1.575,3.264,3.1c0,1.968-1.427,3.56-3.673,5.724l-0.835,0.787  v0.034h4.772v1.197L111.702,42.298L111.702,42.298z M75.029,73.937c0.311,0.034,0.673,0,1.164-0.048  c0.837-0.115,1.625-0.442,2.231-1.034c0.704-0.641,1.213-1.576,1.41-2.82h-0.049c-0.59,0.723-1.443,1.13-2.527,1.13  c-1.901,0-3.131-1.441-3.131-3.263c0-2.018,1.46-3.788,3.642-3.788c2.18,0,3.525,1.755,3.525,4.51c0,2.325-0.787,3.969-1.836,4.983  c-0.819,0.807-1.951,1.295-3.101,1.427c-0.523,0.081-0.983,0.098-1.327,0.081V73.937L75.029,73.937z M75.554,67.82  c0,1.33,0.803,2.261,2.051,2.261c0.967,0,1.722-0.474,2.099-1.112c0.082-0.147,0.13-0.297,0.13-0.542  c0-1.82-0.671-3.214-2.197-3.214C76.424,65.213,75.554,66.294,75.554,67.82z M133.846,30.986l-0.46,0.788  c0.039,0.02,0.109,0.059,0.209,0.116c0.316,0.186,0.512,0.41,0.581,0.676c0.073,0.266,0.017,0.559-0.17,0.878  c-0.212,0.362-0.462,0.578-0.75,0.648c-0.289,0.068-0.624-0.009-1.003-0.231c-0.221-0.126-0.431-0.294-0.644-0.503l0.22-0.375  l0.005,0.002c0.221,0.223,0.401,0.376,0.545,0.459c0.213,0.125,0.4,0.161,0.568,0.11c0.165-0.051,0.317-0.196,0.454-0.435  c0.122-0.208,0.158-0.399,0.108-0.57c-0.049-0.171-0.188-0.322-0.411-0.453c-0.154-0.09-0.315-0.173-0.477-0.25l0.898-1.544  l1.641,0.957l-0.214,0.367L133.846,30.986z M148.161,48.604l-0.345,0.194l-1.077-1.89l0.345-0.194l0.382,0.672l2.389-1.36  l-0.537-0.585l0.345-0.195l0.834,0.775l0.178,0.31l-2.877,1.638L148.161,48.604z M151.886,48.442  c0.187,0.329,0.212,0.645,0.073,0.946c-0.137,0.302-0.503,0.622-1.096,0.958c-0.648,0.37-1.139,0.536-1.469,0.496  c-0.327-0.037-0.586-0.223-0.775-0.555c-0.167-0.291-0.214-0.556-0.144-0.792c0.067-0.236,0.206-0.444,0.416-0.622  c0.212-0.179,0.483-0.364,0.817-0.554c0.579-0.331,1.042-0.478,1.378-0.443C151.427,47.914,151.694,48.101,151.886,48.442z   M148.971,50.08c0.084,0.146,0.225,0.206,0.427,0.182c0.203-0.026,0.58-0.195,1.13-0.508c0.528-0.299,0.847-0.527,0.954-0.681  c0.107-0.154,0.121-0.302,0.041-0.444c-0.075-0.128-0.179-0.193-0.316-0.195c-0.137-0.002-0.293,0.036-0.466,0.115  c-0.176,0.08-0.405,0.2-0.692,0.363c-0.566,0.322-0.907,0.562-1.024,0.717C148.907,49.784,148.888,49.935,148.971,50.08z   M148.192,90.153l-0.374-0.211l1.084-1.914l0.234,0.136c0.222,0.125,0.398,0.274,0.529,0.451c0.127,0.175,0.222,0.353,0.279,0.535  c0.06,0.183,0.112,0.402,0.161,0.655c0.056,0.308,0.117,0.515,0.18,0.625c0.066,0.108,0.148,0.187,0.243,0.239  c0.163,0.096,0.314,0.121,0.447,0.081c0.134-0.042,0.249-0.15,0.349-0.326c0.106-0.185,0.187-0.436,0.238-0.756l0.002-0.005  l0.384,0.218c-0.07,0.326-0.18,0.619-0.328,0.884c-0.184,0.325-0.396,0.531-0.632,0.62c-0.238,0.086-0.496,0.053-0.772-0.103  c-0.156-0.089-0.288-0.214-0.396-0.377c-0.108-0.157-0.201-0.447-0.274-0.864c-0.046-0.232-0.087-0.419-0.126-0.556  c-0.038-0.14-0.095-0.271-0.165-0.389c-0.073-0.122-0.171-0.223-0.294-0.298L148.192,90.153z M150.175,93.316  c-0.186,0.329-0.445,0.511-0.775,0.549c-0.328,0.035-0.789-0.115-1.384-0.45c-0.65-0.368-1.042-0.705-1.179-1.006  c-0.136-0.306-0.11-0.62,0.079-0.954c0.166-0.29,0.366-0.468,0.606-0.53c0.239-0.059,0.487-0.047,0.75,0.043  c0.26,0.09,0.559,0.227,0.893,0.417c0.581,0.329,0.944,0.648,1.086,0.959C150.393,92.65,150.368,92.974,150.175,93.316z   M147.274,91.653c-0.081,0.145-0.061,0.299,0.064,0.459s0.463,0.396,1.012,0.709c0.53,0.301,0.889,0.454,1.075,0.469  c0.188,0.012,0.322-0.05,0.402-0.19c0.072-0.132,0.075-0.255,0.005-0.371c-0.065-0.119-0.179-0.234-0.337-0.343  c-0.157-0.108-0.378-0.243-0.666-0.408c-0.565-0.32-0.948-0.49-1.141-0.513C147.495,91.445,147.356,91.508,147.274,91.653z   M133.36,105.639l-0.236-0.355l1.831-1.213l0.149,0.224c0.138,0.214,0.227,0.427,0.266,0.643c0.034,0.213,0.038,0.415,0.008,0.603  c-0.034,0.189-0.082,0.407-0.157,0.658c-0.089,0.298-0.127,0.51-0.118,0.637c0.009,0.128,0.043,0.237,0.103,0.326  c0.105,0.159,0.227,0.25,0.363,0.273c0.139,0.024,0.291-0.018,0.461-0.13c0.177-0.116,0.362-0.307,0.555-0.565l0.004-0.003  l0.241,0.364c-0.209,0.26-0.44,0.473-0.691,0.642c-0.311,0.205-0.593,0.294-0.845,0.262c-0.253-0.026-0.468-0.174-0.641-0.44  c-0.1-0.148-0.162-0.319-0.185-0.514c-0.022-0.19,0.025-0.489,0.147-0.895c0.064-0.227,0.114-0.412,0.141-0.553  c0.028-0.14,0.037-0.282,0.029-0.422c-0.01-0.14-0.051-0.271-0.128-0.4L133.36,105.639z M133.727,108.782l-0.503-0.763  c-0.036,0.027-0.102,0.072-0.198,0.136c-0.305,0.203-0.595,0.275-0.863,0.225c-0.271-0.055-0.509-0.235-0.713-0.542  c-0.23-0.352-0.315-0.669-0.248-0.961c0.064-0.289,0.28-0.554,0.651-0.799c0.208-0.139,0.453-0.256,0.733-0.354l0.241,0.362h-0.003  c-0.301,0.104-0.518,0.199-0.654,0.289c-0.205,0.137-0.322,0.289-0.348,0.459c-0.029,0.173,0.033,0.373,0.184,0.604  c0.133,0.202,0.291,0.318,0.467,0.348c0.175,0.034,0.371-0.023,0.589-0.167c0.147-0.101,0.295-0.206,0.435-0.319l0.986,1.489  l-1.581,1.045l-0.234-0.352L133.727,108.782z M92.177,108.299c-0.42-0.237-0.706-0.345-0.858-0.319  c-0.154,0.027-0.28,0.129-0.38,0.308c-0.089,0.153-0.113,0.297-0.076,0.422c0.039,0.125,0.142,0.235,0.309,0.33  c0.146,0.084,0.37,0.161,0.676,0.24l0.004,0.002l-0.215,0.379c-0.307-0.085-0.568-0.191-0.785-0.314  c-0.327-0.188-0.536-0.391-0.624-0.616c-0.09-0.224-0.059-0.468,0.089-0.731c0.103-0.179,0.241-0.31,0.414-0.382  c0.171-0.077,0.366-0.089,0.582-0.04c-0.18-0.148-0.284-0.318-0.316-0.51c-0.033-0.193,0.009-0.39,0.123-0.588  c0.186-0.327,0.42-0.518,0.704-0.572c0.284-0.057,0.617,0.024,0.997,0.239c0.229,0.133,0.445,0.299,0.646,0.502l-0.211,0.373  l-0.003-0.004c-0.241-0.228-0.441-0.39-0.603-0.48c-0.196-0.11-0.368-0.145-0.521-0.102c-0.154,0.042-0.287,0.158-0.396,0.357  c-0.12,0.208-0.146,0.394-0.083,0.551c0.065,0.159,0.312,0.358,0.735,0.599L92.177,108.299z M88.768,107.63l0.454-0.796  c-0.041-0.019-0.111-0.056-0.211-0.113c-0.319-0.18-0.516-0.403-0.59-0.67c-0.075-0.264-0.02-0.557,0.162-0.879  c0.208-0.366,0.455-0.585,0.743-0.656c0.287-0.072,0.622,0,1.008,0.219c0.218,0.126,0.434,0.292,0.647,0.496l-0.214,0.377  l-0.004-0.002c-0.226-0.22-0.408-0.371-0.552-0.452c-0.213-0.122-0.402-0.158-0.567-0.104c-0.166,0.052-0.315,0.199-0.453,0.438  c-0.12,0.211-0.154,0.403-0.103,0.574c0.052,0.17,0.192,0.318,0.417,0.445c0.156,0.09,0.316,0.174,0.481,0.246l-0.882,1.554  l-1.648-0.938L87.664,107L88.768,107.63z M75.081,91.36l0.363-0.218l0.195,0.326l0.694-0.411l0.34,0.572l-0.696,0.413l0.756,1.271  l-0.347,0.207l-2.214-0.028l-0.694-0.009l-0.319-0.54l2.114-1.257L75.081,91.36z M76.107,93.087l-0.492-0.828l-1.392,0.828H76.107z   M72.124,91.238c-0.196-0.323-0.227-0.641-0.094-0.944c0.133-0.303,0.492-0.63,1.078-0.979c0.642-0.381,1.128-0.556,1.458-0.524  c0.329,0.035,0.592,0.213,0.789,0.543c0.171,0.287,0.225,0.554,0.159,0.788c-0.064,0.238-0.201,0.449-0.407,0.632  c-0.207,0.182-0.475,0.371-0.806,0.568c-0.575,0.341-1.031,0.499-1.369,0.468C72.591,91.759,72.321,91.575,72.124,91.238z   M75.004,89.547c-0.085-0.146-0.229-0.2-0.431-0.175c-0.202,0.031-0.574,0.207-1.117,0.531c-0.521,0.31-0.835,0.542-0.941,0.699  c-0.104,0.157-0.116,0.304-0.033,0.443c0.076,0.128,0.183,0.191,0.319,0.191c0.137,0,0.293-0.043,0.466-0.126  c0.172-0.083,0.399-0.208,0.685-0.376c0.558-0.333,0.896-0.58,1.009-0.735C75.075,89.841,75.09,89.689,75.004,89.547z   M69.072,69.765l0.425-0.007l0.007,0.378l0.809-0.014l0.012,0.665l-0.809,0.016l0.029,1.478l-0.405,0.009l-1.911-1.122l-0.599-0.35  l-0.011-0.624l2.461-0.047L69.072,69.765z M69.112,71.773l-0.02-0.964l-1.618,0.031L69.112,71.773z M67.031,68.535l0.915-0.018  c-0.004-0.048-0.007-0.126-0.009-0.24c-0.009-0.367,0.083-0.65,0.273-0.85c0.19-0.198,0.468-0.302,0.839-0.311  c0.42-0.008,0.735,0.094,0.944,0.305c0.208,0.209,0.317,0.537,0.326,0.977c0.004,0.253-0.028,0.521-0.096,0.812l-0.433,0.007V69.21  c0.075-0.304,0.11-0.538,0.106-0.7c-0.004-0.247-0.072-0.429-0.201-0.544c-0.128-0.115-0.333-0.169-0.608-0.164  c-0.242,0.005-0.425,0.073-0.544,0.205c-0.119,0.133-0.178,0.328-0.171,0.587c0.002,0.179,0.014,0.359,0.034,0.538l-1.786,0.037  l-0.037-1.898l0.425-0.008L67.031,68.535z M154.084,69.496h-0.396l0.006-2.177l0.395,0.001l-0.001,0.774l2.747,0.006l-0.175-0.774  l0.394,0.001l0.341,1.087v0.356l-3.31-0.008L154.084,69.496z M156.935,70.862l-0.912-0.002c0.003,0.042,0.004,0.121,0.004,0.236  c0,0.368-0.1,0.649-0.294,0.845c-0.193,0.196-0.475,0.291-0.846,0.291c-0.421,0-0.732-0.108-0.936-0.324  c-0.203-0.213-0.305-0.544-0.305-0.984c0.001-0.251,0.037-0.521,0.113-0.807h0.434v0.005c-0.081,0.305-0.122,0.537-0.122,0.702  c-0.001,0.247,0.062,0.429,0.188,0.546c0.128,0.116,0.328,0.178,0.605,0.178c0.242,0.001,0.426-0.063,0.549-0.193  c0.123-0.128,0.185-0.324,0.186-0.581c0-0.18-0.008-0.359-0.023-0.539l1.785,0.003l-0.005,1.896l-0.425-0.001L156.935,70.862z   M72.231,48.142l0.789,0.462c0.02-0.041,0.058-0.11,0.116-0.209c0.185-0.316,0.411-0.511,0.677-0.582  c0.266-0.073,0.558-0.015,0.877,0.171c0.363,0.212,0.579,0.462,0.647,0.75c0.07,0.289-0.008,0.624-0.23,1.005  c-0.126,0.217-0.294,0.431-0.503,0.643l-0.375-0.219l0.003-0.003c0.221-0.222,0.375-0.404,0.458-0.546  c0.125-0.212,0.161-0.402,0.109-0.567c-0.05-0.167-0.195-0.318-0.434-0.458c-0.209-0.122-0.399-0.158-0.57-0.108  c-0.17,0.05-0.322,0.189-0.452,0.412c-0.091,0.155-0.174,0.314-0.251,0.479l-1.542-0.9l0.957-1.639l0.366,0.213L72.231,48.142z   M73.423,45.179c0.191-0.329,0.452-0.508,0.783-0.54c0.33-0.032,0.789,0.124,1.377,0.467c0.646,0.377,1.034,0.717,1.168,1.022  c0.129,0.303,0.1,0.62-0.094,0.951c-0.168,0.29-0.373,0.463-0.612,0.522c-0.239,0.057-0.488,0.041-0.748-0.051  c-0.261-0.093-0.558-0.235-0.889-0.429c-0.579-0.337-0.936-0.66-1.073-0.972C73.198,45.839,73.226,45.515,73.423,45.179z   M76.302,46.879c0.085-0.146,0.065-0.299-0.058-0.461c-0.122-0.162-0.457-0.402-1.004-0.721c-0.524-0.307-0.88-0.468-1.067-0.484  c-0.188-0.017-0.321,0.045-0.405,0.186c-0.074,0.128-0.078,0.253-0.011,0.372c0.067,0.121,0.178,0.235,0.334,0.347  c0.156,0.111,0.376,0.25,0.663,0.416c0.561,0.328,0.939,0.505,1.132,0.527C76.078,47.083,76.218,47.022,76.302,46.879z   M88.294,31.414l0.452,0.793c0.038-0.025,0.105-0.065,0.206-0.122c0.318-0.181,0.611-0.236,0.877-0.165  c0.266,0.071,0.491,0.267,0.674,0.589c0.208,0.365,0.27,0.69,0.184,0.974c-0.085,0.285-0.32,0.534-0.705,0.753  c-0.219,0.126-0.471,0.227-0.756,0.304l-0.215-0.376l0.004-0.002c0.304-0.081,0.528-0.161,0.671-0.244  c0.214-0.121,0.34-0.267,0.379-0.436s-0.01-0.373-0.146-0.612c-0.12-0.211-0.266-0.337-0.439-0.379  c-0.175-0.043-0.373,0.001-0.599,0.128c-0.156,0.089-0.308,0.186-0.458,0.288l-0.883-1.551l1.648-0.938l0.21,0.368L88.294,31.414z   M90.74,30.021l0.454,0.795c0.035-0.026,0.105-0.067,0.204-0.124c0.319-0.181,0.612-0.235,0.878-0.165  c0.268,0.071,0.492,0.267,0.673,0.589c0.208,0.365,0.269,0.69,0.185,0.974c-0.086,0.284-0.32,0.535-0.704,0.753  c-0.22,0.125-0.472,0.227-0.757,0.305l-0.215-0.377l0.004-0.002c0.303-0.081,0.526-0.161,0.669-0.242  c0.214-0.122,0.34-0.268,0.379-0.436c0.039-0.169-0.01-0.373-0.146-0.612c-0.12-0.211-0.268-0.337-0.441-0.38  c-0.172-0.042-0.373,0.001-0.598,0.129c-0.155,0.088-0.308,0.185-0.457,0.288l-0.883-1.552l1.65-0.939l0.209,0.37L90.74,30.021z   M114.219,113.636c-0.485,0.002-0.787,0.053-0.905,0.15c-0.119,0.099-0.179,0.249-0.178,0.452c0,0.181,0.049,0.314,0.146,0.405  c0.095,0.09,0.237,0.134,0.428,0.134c0.167,0,0.405-0.04,0.71-0.127l0.004,0.002l0.002,0.433c-0.309,0.077-0.591,0.116-0.84,0.116  c-0.376,0.002-0.659-0.07-0.848-0.224c-0.19-0.15-0.285-0.376-0.286-0.68c0-0.206,0.055-0.389,0.17-0.538  c0.113-0.149,0.275-0.258,0.487-0.319c-0.23-0.039-0.407-0.137-0.529-0.288c-0.122-0.152-0.185-0.344-0.186-0.57  c0-0.377,0.108-0.66,0.326-0.848c0.221-0.188,0.549-0.285,0.989-0.287c0.26,0,0.532,0.041,0.807,0.116l0.001,0.43h-0.005  c-0.324-0.079-0.576-0.12-0.761-0.119c-0.225,0-0.39,0.057-0.502,0.17c-0.116,0.114-0.17,0.283-0.17,0.507  c0.003,0.242,0.069,0.415,0.204,0.521c0.135,0.104,0.447,0.155,0.935,0.153L114.219,113.636z M110.583,115.208  c-0.381,0.002-0.667-0.134-0.861-0.399c-0.195-0.27-0.292-0.745-0.295-1.428c-0.001-0.747,0.097-1.251,0.292-1.521  c0.195-0.268,0.485-0.402,0.867-0.402c0.334-0.003,0.588,0.087,0.759,0.264c0.171,0.178,0.283,0.403,0.336,0.671  c0.051,0.273,0.08,0.6,0.08,0.982c0.001,0.671-0.097,1.144-0.296,1.417C111.268,115.069,110.974,115.208,110.583,115.208z   M110.593,111.864c-0.167,0-0.292,0.097-0.369,0.285c-0.077,0.188-0.115,0.601-0.115,1.229c0.003,0.609,0.043,0.999,0.125,1.169  c0.081,0.169,0.202,0.256,0.364,0.256c0.148-0.002,0.256-0.062,0.326-0.18c0.069-0.118,0.112-0.275,0.129-0.463  c0.017-0.192,0.025-0.453,0.025-0.783c-0.002-0.65-0.042-1.066-0.119-1.243C110.882,111.956,110.76,111.864,110.593,111.864z   M110.625,24.026c0.381,0.001,0.667,0.138,0.859,0.408c0.193,0.27,0.29,0.746,0.287,1.425c0,0.749-0.101,1.256-0.299,1.523  c-0.196,0.266-0.486,0.398-0.869,0.397c-0.335,0-0.587-0.09-0.758-0.268c-0.17-0.178-0.281-0.402-0.331-0.673  c-0.053-0.272-0.078-0.6-0.077-0.984c0.001-0.668,0.102-1.141,0.302-1.416C109.94,24.163,110.235,24.025,110.625,24.026z   M110.602,27.37c0.167,0,0.29-0.092,0.368-0.281c0.078-0.188,0.119-0.598,0.12-1.231c0.002-0.606-0.037-0.995-0.118-1.166  c-0.081-0.17-0.202-0.255-0.364-0.255c-0.148,0-0.257,0.058-0.327,0.177c-0.069,0.117-0.113,0.272-0.13,0.463  c-0.02,0.19-0.028,0.451-0.029,0.78c0,0.65,0.036,1.065,0.113,1.245C110.312,27.28,110.434,27.37,110.602,27.37z M113.441,24.033  c0.381,0.001,0.668,0.136,0.859,0.406c0.193,0.27,0.289,0.747,0.287,1.427c-0.001,0.748-0.103,1.254-0.299,1.522  c-0.197,0.266-0.484,0.398-0.869,0.397c-0.335,0-0.586-0.09-0.759-0.268c-0.17-0.177-0.281-0.402-0.332-0.673  s-0.075-0.601-0.075-0.984c0.002-0.668,0.102-1.14,0.302-1.415C112.756,24.17,113.052,24.031,113.441,24.033z M113.417,27.376  c0.168,0.001,0.292-0.092,0.37-0.281c0.075-0.188,0.117-0.599,0.119-1.23c0-0.607-0.039-0.996-0.117-1.167  c-0.08-0.168-0.2-0.254-0.365-0.256c-0.147,0-0.257,0.059-0.327,0.178c-0.069,0.117-0.116,0.271-0.131,0.462  c-0.019,0.19-0.028,0.451-0.03,0.781c-0.001,0.65,0.038,1.064,0.116,1.244C113.127,27.287,113.251,27.376,113.417,27.376z   M141.838,73.309c0.41,0.246,1.343,0.654,2.361,0.654c1.839,0,2.427-1.162,2.41-2.066c-0.017-1.493-1.359-2.132-2.755-2.132h-0.805  v-1.083h0.805c1.048,0,2.378-0.54,2.378-1.803c0-0.853-0.541-1.606-1.871-1.606c-0.852,0-1.67,0.377-2.131,0.705l-0.393-1.049  c0.572-0.41,1.654-0.821,2.804-0.821c2.098,0,3.05,1.248,3.05,2.543c0,1.114-0.672,2.049-1.967,2.525v0.032  c1.314,0.246,2.363,1.232,2.378,2.724c0,1.705-1.343,3.198-3.886,3.198c-1.195,0-2.245-0.376-2.771-0.722L141.838,73.309z   M114.606,97.213c-0.293-0.015-0.672,0.016-1.083,0.083c-2.279,0.359-3.458,1.998-3.706,3.772h0.033  c0.508-0.691,1.411-1.248,2.591-1.248c1.887,0,3.214,1.377,3.214,3.442c0,1.969-1.327,3.772-3.558,3.772  c-2.263,0-3.754-1.771-3.754-4.542c0-2.097,0.737-3.755,1.804-4.805c0.885-0.869,2.066-1.409,3.409-1.572  c0.427-0.068,0.79-0.081,1.05-0.081L114.606,97.213L114.606,97.213z M114.195,103.363c0-1.525-0.869-2.446-2.196-2.446  c-0.869,0-1.689,0.525-2.083,1.314c-0.082,0.162-0.147,0.361-0.147,0.621c0.017,1.757,0.836,3.068,2.362,3.068  C113.361,105.921,114.195,104.887,114.195,103.363z"/>
-<path fill="#666666" d="M112.504,30.561h-1.008v-1.201h1.008V30.561z M111.494,109.877h1.01v-1.2h-1.01V109.877z M152.258,70.124  v-1.012h-1.2v1.012H152.258z M71.742,69.112v1.01h1.201v-1.01H71.742z M92.309,34.5l-0.875,0.506l0.6,1.04l0.876-0.505L92.309,34.5z   M131.689,104.736l0.874-0.507l-0.598-1.04l-0.874,0.506L131.689,104.736z M147.118,49.926l-0.507-0.874l-1.038,0.6l0.504,0.875  L147.118,49.926z M76.882,89.308l0.505,0.874l1.04-0.598l-0.505-0.874L76.882,89.308z M77.389,49.051l-0.505,0.875l1.039,0.6  l0.505-0.874L77.389,49.051z M146.611,90.184l0.506-0.873l-1.041-0.601l-0.504,0.874L146.611,90.184z M132.566,35.007l-0.875-0.505  l-0.599,1.041l0.874,0.504L132.566,35.007z M91.433,104.229l0.873,0.505l0.602-1.039l-0.875-0.506L91.433,104.229z"/>
-<path fill="#808080" d="M107.395,26.71l-0.172,0.018l-0.177-1.677l0.173-0.018L107.395,26.71z M116.783,114.203l0.17-0.017  l-0.177-1.68l-0.172,0.018L116.783,114.203z M156.584,64.837l-0.017-0.172l-1.679,0.177l0.018,0.172L156.584,64.837z M67.416,74.4  l0.017,0.173l1.677-0.178l-0.017-0.173L67.416,74.4z M102.585,25.777l-0.17,0.035l0.35,1.65l0.17-0.037L102.585,25.777z   M121.415,113.459l0.169-0.035l-0.351-1.651l-0.171,0.038L121.415,113.459z M155.841,60.204l-0.036-0.17l-1.65,0.351l0.037,0.17  L155.841,60.204z M68.159,79.034l0.036,0.169l1.65-0.351l-0.037-0.172L68.159,79.034z M98.054,27.002l-0.166,0.054l0.521,1.604  l0.166-0.053L98.054,27.002z M125.946,112.236l0.164-0.055l-0.519-1.605l-0.167,0.055L125.946,112.236z M154.618,55.671  l-0.056-0.165l-1.604,0.522l0.055,0.165L154.618,55.671z M69.383,83.564l0.054,0.165l1.604-0.521l-0.054-0.166L69.383,83.564z   M93.676,28.693l-0.158,0.071l0.686,1.541l0.159-0.07L93.676,28.693z M130.324,110.544l0.159-0.072l-0.687-1.54l-0.159,0.072  L130.324,110.544z M152.925,51.294l-0.071-0.159l-1.541,0.686l0.072,0.159L152.925,51.294z M71.074,87.942l0.07,0.159l1.542-0.685  l-0.071-0.161L71.074,87.942z M86.558,34.762l-0.139,0.102l-0.993-1.365l0.141-0.102L86.558,34.762z M138.434,105.84l0.139-0.103  l-0.991-1.365l-0.14,0.103L138.434,105.84z M148.222,43.185l-0.103-0.14l-1.364,0.992l0.101,0.14L148.222,43.185z M75.779,96.052  l0.102,0.139l1.364-0.991l-0.102-0.139L75.779,96.052z M81.925,36.358l-0.128,0.116l1.129,1.253l0.128-0.116L81.925,36.358z   M142.075,102.879l0.128-0.115l-1.127-1.255l-0.131,0.115L142.075,102.879z M145.262,39.544l-0.116-0.129l-1.255,1.128l0.115,0.129  L145.262,39.544z M78.74,99.692l0.116,0.128l1.253-1.126l-0.117-0.131L78.74,99.692z M78.613,39.685l-0.117,0.128l1.255,1.128  l0.116-0.128L78.613,39.685z M145.386,99.554l0.117-0.131l-1.255-1.127l-0.115,0.128L145.386,99.554z M141.935,36.232l-0.131-0.116  l-1.127,1.254l0.128,0.116L141.935,36.232z M82.065,103.006l0.129,0.115l1.128-1.255l-0.128-0.114L82.065,103.006z M75.668,43.338  l-0.103,0.14l1.364,0.993l0.103-0.141L75.668,43.338z M148.331,95.899l0.103-0.144l-1.365-0.989l-0.1,0.14L148.331,95.899z   M138.281,33.286l-0.142-0.102l-0.992,1.365l0.141,0.102L138.281,33.286z M85.72,105.949l0.14,0.102l0.992-1.364l-0.141-0.1  L85.72,105.949z M72.538,52.152l-0.071,0.159l-1.541-0.687l0.072-0.158L72.538,52.152z M153.003,87.771l0.069-0.157l-1.541-0.687  l-0.071,0.159L153.003,87.771z M130.152,28.617l-0.156-0.072l-0.688,1.542l0.16,0.07L130.152,28.617z M93.847,110.62l0.158,0.071  l0.686-1.54l-0.159-0.073L93.847,110.62z M69.324,55.851l-0.054,0.166l1.604,0.52l0.054-0.165L69.324,55.851z M154.674,83.384  l0.056-0.163l-1.605-0.522l-0.056,0.164L154.674,83.384z M125.767,26.943l-0.165-0.055l-0.521,1.605l0.164,0.054L125.767,26.943z   M98.233,112.292l0.165,0.056l0.52-1.605l-0.165-0.055L98.233,112.292z M68.12,60.388l-0.037,0.169l1.651,0.352l0.036-0.17  L68.12,60.388z M155.879,78.849l0.038-0.171l-1.651-0.349l-0.036,0.172L155.879,78.849z M121.229,25.738l-0.17-0.036l-0.35,1.65  l0.172,0.036L121.229,25.738z M102.769,113.498l0.17,0.038l0.351-1.653l-0.17-0.035L102.769,113.498z M67.396,65.023l-0.02,0.174  l1.678,0.176l0.019-0.173L67.396,65.023z M156.604,74.212l0.018-0.174l-1.676-0.175l-0.02,0.171L156.604,74.212z M116.593,25.014  l-0.173-0.019l-0.174,1.678l0.171,0.02L116.593,25.014z M107.405,114.222l0.175,0.019l0.175-1.675l-0.173-0.02L107.405,114.222z"/>
-<polygon fill-opacity="0.4" points="120.303,64.168 90.39,94.083 87.194,94.245 87.549,91.215 117.451,61.313 "/>
-<polygon points="117.451,62.029 119.592,64.17 90.17,93.589 87.766,93.711 88.029,91.446 "/>
-<polygon fill-opacity="0.4" points="108.156,62.206 130.577,84.627 130.383,88.182 126.997,88.183 104.588,65.773 "/>
-<polygon fill="#1A1A1A" points="105.301,65.773 108.156,62.919 130.082,84.847 129.849,87.609 127.229,87.701 "/>
-<path fill-opacity="0.4" d="M108.789,66.406c1.771-1.771,4.65-1.77,6.423,0.001c1.769,1.771,1.769,4.65,0,6.422  c-1.772,1.77-4.651,1.771-6.423,0C107.018,71.058,107.018,68.178,108.789,66.406L108.789,66.406z"/>
-<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="-297.3677" y1="401.4014" x2="-297.3677" y2="393.2246" gradientTransform="matrix(-0.7071 0.7071 0.7071 0.7071 -379.2077 -1.0529)">
+<path fill="url(#SVGID_4_)" d="M150.999,172.18c-29.323,0-53.179-23.854-53.179-53.178c0-29.323,23.855-53.18,53.179-53.18  c29.323,0,53.179,23.857,53.179,53.18C204.178,148.325,180.322,172.18,150.999,172.18L150.999,172.18z"/>
+<circle fill="#C8C8C8" cx="150.999" cy="119.002" r="1.922"/>
+<path fill="none" d="M150.999,172.18c-29.323,0-53.179-23.854-53.179-53.178c0-29.323,23.855-53.18,53.179-53.18  c29.323,0,53.179,23.857,53.179,53.18C204.178,148.325,180.322,172.18,150.999,172.18L150.999,172.18z"/>
+<circle fill="#646464" cx="150.999" cy="69.026" r="1.923"/>
+<path fill="#646464" d="M147.145,73.971h-0.028l-1.643,0.887l-0.248-0.975l2.065-1.104h1.09v9.45h-1.236V73.971z"/>
+<path fill="#646464" d="M150.738,82.229v-0.786l1.002-0.975c2.412-2.295,3.52-3.517,3.52-4.942c0-0.96-0.451-1.847-1.861-1.847  c-0.856,0-1.57,0.438-2.005,0.801l-0.41-0.9c0.642-0.539,1.587-0.96,2.662-0.96c2.035,0,2.894,1.395,2.894,2.747  c0,1.744-1.265,3.155-3.256,5.074l-0.741,0.697v0.03h4.23v1.061H150.738z"/>
+<circle fill="#646464" cx="175.986" cy="75.723" r="1.922"/>
+<circle fill="#646464" cx="194.277" cy="94.014" r="1.921"/>
+<circle fill="#646464" cx="200.975" cy="119.002" r="1.922"/>
+<path fill="#646464" d="M191.912,122.219c0.357,0.215,1.171,0.572,2.061,0.572c1.6,0,2.113-1.016,2.102-1.803  c-0.014-1.301-1.188-1.859-2.402-1.859h-0.699v-0.943h0.699c0.915,0,2.074-0.473,2.074-1.573c0-0.743-0.473-1.401-1.633-1.401  c-0.743,0-1.459,0.329-1.858,0.613l-0.344-0.914c0.5-0.357,1.444-0.715,2.446-0.715c1.83,0,2.66,1.087,2.66,2.217  c0,0.971-0.588,1.788-1.717,2.202v0.028c1.145,0.215,2.061,1.072,2.072,2.375c0,1.486-1.172,2.789-3.391,2.789  c-1.043,0-1.957-0.33-2.416-0.629L191.912,122.219z"/>
+<path fill="#646464" d="M194.277,142.066c1.063,0,1.924,0.861,1.924,1.924c0,1.059-0.861,1.922-1.924,1.922  c-1.062,0-1.922-0.863-1.922-1.922C192.355,142.928,193.217,142.066,194.277,142.066z"/>
+<rect x="183.879" y="133.423" transform="matrix(0.5006 -0.8657 0.8657 0.5006 -27.6308 229.1995)" fill="#646464" width="1.923" height="10.251"/>
+<path fill="#646464" d="M175.986,160.359c1.063,0,1.922,0.863,1.922,1.922c0,1.063-0.859,1.924-1.922,1.924  s-1.924-0.861-1.924-1.924C174.063,161.223,174.924,160.359,175.986,160.359z"/>
+<rect x="169.591" y="147.724" transform="matrix(0.8657 -0.5006 0.5006 0.8657 -53.609 105.9139)" fill="#646464" width="1.923" height="10.254"/>
+<circle fill="#646464" cx="150.998" cy="168.978" r="1.923"/>
+<path fill="#646464" d="M153.275,156.805c-0.258-0.016-0.588,0.014-0.944,0.068c-1.992,0.316-3.023,1.75-3.237,3.295h0.027  c0.445-0.602,1.233-1.088,2.264-1.088c1.648,0,2.809,1.203,2.809,3.008c0,1.719-1.159,3.293-3.107,3.293  c-1.977,0-3.28-1.545-3.28-3.967c0-1.834,0.645-3.279,1.574-4.197c0.775-0.758,1.807-1.23,2.979-1.373  c0.373-0.061,0.688-0.07,0.918-0.07v1.031H153.275z M152.917,162.174c0-1.332-0.758-2.131-1.919-2.131  c-0.758,0-1.474,0.457-1.819,1.145c-0.07,0.144-0.128,0.314-0.128,0.543c0.014,1.533,0.73,2.679,2.063,2.679  C152.188,164.408,152.917,163.508,152.917,162.174z"/>
+<circle fill="#646464" cx="126.012" cy="162.281" r="1.922"/>
+<rect x="130.504" y="147.719" transform="matrix(0.8652 0.5015 -0.5015 0.8652 94.3752 -45.32)" fill="#646464" width="1.924" height="10.25"/>
+<rect x="169.748" y="79.205" transform="matrix(0.8657 0.5006 -0.5006 0.8657 65.1487 -74.1317)" fill="#646464" width="1.923" height="10.25"/>
+<path fill="#646464" d="M107.72,142.066c1.061,0,1.921,0.861,1.921,1.924c0,1.059-0.86,1.922-1.921,1.922  c-1.062,0-1.923-0.863-1.923-1.922C105.797,142.928,106.658,142.066,107.72,142.066z"/>
+<rect x="116.19" y="133.411" transform="matrix(0.5003 0.8659 -0.8659 0.5003 178.5003 -32.2056)" fill="#646464" width="1.922" height="10.254"/>
+<rect x="184.436" y="93.813" transform="matrix(0.5003 0.8658 -0.8658 0.5003 178.2984 -111.0867)" fill="#646464" width="1.923" height="10.252"/>
+<circle fill="#646464" cx="101.023" cy="119.002" r="1.922"/>
+<path fill="#646464" d="M106.139,122.797c0.273,0.027,0.591,0,1.023-0.044c0.735-0.101,1.428-0.39,1.96-0.907  c0.621-0.563,1.067-1.385,1.241-2.479h-0.044c-0.519,0.635-1.269,0.993-2.22,0.993c-1.673,0-2.754-1.268-2.754-2.868  c0-1.773,1.283-3.33,3.2-3.33s3.099,1.544,3.099,3.965c0,2.047-0.69,3.487-1.613,4.381c-0.721,0.709-1.715,1.142-2.725,1.255  c-0.462,0.072-0.866,0.088-1.168,0.072L106.139,122.797L106.139,122.797z M106.6,117.42c0,1.168,0.707,1.99,1.803,1.99  c0.85,0,1.514-0.42,1.846-0.98c0.071-0.131,0.115-0.261,0.115-0.477c0-1.6-0.592-2.825-1.933-2.825  C107.363,115.128,106.6,116.079,106.6,117.42z"/>
+<circle fill="#646464" cx="107.72" cy="94.014" r="1.921"/>
+<rect x="116.202" y="94.334" transform="matrix(-0.5006 0.8657 -0.8657 -0.5006 261.918 47.8307)" fill="#646464" width="1.922" height="10.251"/>
+<circle fill="#646464" cx="126.012" cy="75.722" r="1.923"/>
+<rect x="130.503" y="80.027" transform="matrix(-0.8659 0.5002 -0.5002 -0.8659 287.8932 93.1373)" fill="#646464" width="1.922" height="10.252"/>
+<rect x="144.655" y="59.73" transform="matrix(-0.9946 0.1039 -0.1039 -0.9946 295.5698 107.9097)" fill="#646464" width="0.639" height="3.844"/>
+<rect x="156.703" y="174.428" transform="matrix(-0.9943 0.1067 -0.1067 -0.9943 331.9748 334.9315)" fill="#646464" width="0.64" height="3.846"/>
+<rect x="138.682" y="60.684" transform="matrix(-0.9782 0.2075 -0.2075 -0.9782 287.9719 94.9994)" fill="#646464" width="0.64" height="3.844"/>
+<rect x="162.672" y="173.466" transform="matrix(-0.977 0.2131 -0.2131 -0.977 359.6113 312.0218)" fill="#646464" width="0.642" height="3.845"/>
+<rect x="132.859" y="62.234" transform="matrix(-0.9512 0.3085 -0.3085 -0.9512 279.6555 84.1022)" fill="#646464" width="0.643" height="3.844"/>
+<rect x="168.492" y="171.929" transform="matrix(-0.9505 0.3107 -0.3107 -0.9505 383.2836 286.6476)" fill="#646464" width="0.638" height="3.846"/>
+<rect x="127.219" y="64.404" transform="matrix(-0.9141 0.4054 -0.4054 -0.9141 271.0186 75.246)" fill="#646464" width="0.643" height="3.843"/>
+<rect x="174.138" y="169.753" transform="matrix(-0.9139 0.4059 -0.4059 -0.9139 403.5764 257.7682)" fill="#646464" width="0.64" height="3.841"/>
+<rect x="116.787" y="70.428" transform="matrix(-0.8096 0.587 -0.587 -0.8096 254.3857 62.1845)" fill="#646464" width="0.641" height="3.845"/>
+<rect x="184.572" y="163.727" transform="matrix(-0.8098 0.5867 -0.5867 -0.8098 431.8035 191.3113)" fill="#646464" width="0.639" height="3.844"/>
+<rect x="112.089" y="74.227" transform="matrix(-0.7441 0.6681 -0.6681 -0.7441 246.9279 57.7112)" fill="#646464" width="0.642" height="3.844"/>
+<rect x="189.259" y="159.939" transform="matrix(-0.7427 0.6696 -0.6696 -0.7427 438.7674 155.124)" fill="#646464" width="0.642" height="3.845"/>
+<rect x="107.82" y="78.497" transform="matrix(-0.6691 0.7431 -0.7431 -0.6691 240.262 53.8664)" fill="#646464" width="0.64" height="3.843"/>
+<rect x="193.507" y="155.676" transform="matrix(-0.6696 0.7427 -0.7427 -0.6696 440.6693 119.1786)" fill="#646464" width="0.642" height="3.846"/>
+<rect x="104.032" y="83.187" transform="matrix(-0.5869 0.8097 -0.8097 -0.5869 234.5073 50.5697)" fill="#646464" width="0.642" height="3.843"/>
+<rect x="197.331" y="150.964" transform="matrix(-0.587 0.8096 -0.8096 -0.587 437.4468 82.6123)" fill="#646464" width="0.641" height="3.845"/>
+<rect x="98" y="93.625" transform="matrix(-0.4074 0.9132 -0.9132 -0.4074 225.6352 44.6846)" fill="#646464" width="0.64" height="3.844"/>
+<rect x="203.359" y="140.543" transform="matrix(-0.4078 0.9131 -0.9131 -0.4078 416.8253 14.5954)" fill="#646464" width="0.642" height="3.844"/>
+<rect x="95.833" y="99.264" transform="matrix(-0.3066 0.9518 -0.9518 -0.3066 221.9467 40.688)" fill="#646464" width="0.64" height="3.845"/>
+<rect x="205.522" y="134.9" transform="matrix(-0.3116 0.9502 -0.9502 -0.3116 399.9991 -16.1291)" fill="#646464" width="0.639" height="3.844"/>
+<rect x="94.271" y="105.085" transform="matrix(-0.2072 0.9783 -0.9783 -0.2072 218.8786 36.6457)" fill="#646464" width="0.641" height="3.845"/>
+<rect x="207.09" y="129.056" transform="matrix(-0.2087 0.978 -0.978 -0.2087 378.7904 -44.5298)" fill="#646464" width="0.641" height="3.845"/>
+<rect x="93.335" y="111.049" transform="matrix(-0.1022 0.9948 -0.9948 -0.1022 215.6073 31.3552)" fill="#646464" width="0.64" height="3.845"/>
+<rect x="208.031" y="123.119" transform="matrix(-0.1098 0.994 -0.994 -0.1098 355.5052 -68.328)" fill="#646464" width="0.641" height="3.843"/>
+<rect x="93.33" y="123.116" transform="matrix(0.1052 0.9944 -0.9944 0.1052 208.1383 18.7487)" fill="#646464" width="0.64" height="3.844"/>
+<rect x="208.037" y="111.046" transform="matrix(0.1008 0.9949 -0.9949 0.1008 299.7495 -105.7131)" fill="#646464" width="0.639" height="3.844"/>
+<rect x="94.28" y="129.078" transform="matrix(0.2049 0.9788 -0.9788 0.2049 203.4314 11.5621)" fill="#646464" width="0.639" height="3.842"/>
+<rect x="207.083" y="105.067" transform="matrix(0.2079 0.9782 -0.9782 0.2079 268.9449 -118.1214)" fill="#646464" width="0.639" height="3.846"/>
+<rect x="95.837" y="134.894" transform="matrix(0.3087 0.9512 -0.9512 0.3087 196.6118 3.123)" fill="#646464" width="0.641" height="3.845"/>
+<rect x="205.527" y="99.265" transform="matrix(0.3066 0.9518 -0.9518 0.3066 239.0479 -125.7694)" fill="#646464" width="0.64" height="3.844"/>
+<rect x="98.001" y="140.536" transform="matrix(0.4078 0.9131 -0.9131 0.4078 188.2951 -5.4151)" fill="#646464" width="0.642" height="3.844"/>
+<rect x="203.38" y="93.62" transform="matrix(0.4061 0.9138 -0.9138 0.4061 208.2778 -129.4044)" fill="#646464" width="0.64" height="3.845"/>
+<rect x="104.025" y="150.966" transform="matrix(0.5873 0.8094 -0.8094 0.5873 166.8141 -21.3547)" fill="#646464" width="0.642" height="3.845"/>
+<rect x="197.325" y="83.182" transform="matrix(0.586 0.8103 -0.8103 0.586 150.7878 -124.9214)" fill="#646464" width="0.64" height="3.843"/>
+<rect x="107.839" y="155.664" transform="matrix(0.6707 0.7417 -0.7417 0.6707 152.4944 -28.3337)" fill="#646464" width="0.64" height="3.843"/>
+<rect x="193.534" y="78.483" transform="matrix(0.6704 0.742 -0.742 0.6704 123.557 -117.3383)" fill="#646464" width="0.641" height="3.846"/>
+<rect x="112.101" y="159.932" transform="matrix(0.7439 0.6683 -0.6683 0.7439 136.9672 -33.6781)" fill="#646464" width="0.64" height="3.843"/>
+<rect x="189.271" y="74.219" transform="matrix(0.7413 0.6712 -0.6712 0.7413 100.1464 -107.548)" fill="#646464" width="0.64" height="3.846"/>
+<rect x="116.771" y="163.73" transform="matrix(0.8102 0.5862 -0.5862 0.8102 119.3294 -37.1933)" fill="#646464" width="0.643" height="3.846"/>
+<rect x="184.58" y="70.434" transform="matrix(0.8087 0.5882 -0.5882 0.8087 77.9324 -94.9199)" fill="#646464" width="0.64" height="3.845"/>
+<rect x="127.237" y="169.758" transform="matrix(0.9128 0.4084 -0.4084 0.9128 81.2365 -37.1244)" fill="#646464" width="0.641" height="3.843"/>
+<rect x="174.128" y="64.385" transform="matrix(0.9128 0.4083 -0.4083 0.9128 42.2816 -65.4531)" fill="#646464" width="0.64" height="3.844"/>
+<rect x="132.858" y="171.933" transform="matrix(0.9515 0.3078 -0.3078 0.9515 59.9693 -32.5487)" fill="#646464" width="0.641" height="3.843"/>
+<rect x="168.491" y="62.239" transform="matrix(0.9508 0.3098 -0.3098 0.9508 28.1799 -49.1374)" fill="#646464" width="0.637" height="3.845"/>
+<rect x="138.683" y="173.483" transform="matrix(0.979 0.204 -0.204 0.979 38.7088 -24.6697)" fill="#646464" width="0.641" height="3.844"/>
+<rect x="162.676" y="60.67" transform="matrix(0.9778 0.2097 -0.2097 0.9778 16.7533 -32.7942)" fill="#646464" width="0.64" height="3.845"/>
+<rect x="144.665" y="174.417" transform="matrix(0.9949 0.1009 -0.1009 0.9949 18.5261 -13.7246)" fill="#646464" width="0.639" height="3.848"/>
+<rect x="156.703" y="59.731" transform="matrix(0.9943 0.1071 -0.1071 0.9943 7.504 -16.4585)" fill="#646464" width="0.638" height="3.844"/>
+<path fill="#646464" d="M149.543,58.717c0.483,0,0.847,0.17,1.094,0.514c0.247,0.342,0.368,0.945,0.368,1.812  c0,0.948-0.124,1.593-0.374,1.931c-0.249,0.34-0.617,0.508-1.103,0.508c-0.426,0-0.747-0.111-0.964-0.338  c-0.217-0.223-0.357-0.508-0.424-0.852c-0.065-0.344-0.098-0.762-0.098-1.249c0-0.849,0.125-1.448,0.379-1.799  C148.674,58.893,149.048,58.717,149.543,58.717z M149.522,62.963c0.213,0,0.368-0.119,0.468-0.359  c0.099-0.238,0.148-0.76,0.148-1.562c0-0.772-0.051-1.267-0.152-1.482c-0.104-0.214-0.257-0.323-0.464-0.323  c-0.188,0-0.326,0.075-0.414,0.225c-0.089,0.15-0.146,0.348-0.167,0.588c-0.021,0.243-0.033,0.572-0.033,0.993  c0,0.825,0.049,1.353,0.147,1.581C149.153,62.848,149.31,62.963,149.522,62.963z"/>
+<path fill="#646464" d="M152.801,58.717c0.48,0,0.846,0.17,1.092,0.514c0.246,0.342,0.369,0.945,0.369,1.812  c0,0.948-0.125,1.593-0.373,1.931c-0.25,0.34-0.617,0.508-1.104,0.508c-0.428,0-0.747-0.111-0.965-0.338  c-0.217-0.223-0.357-0.508-0.424-0.852c-0.065-0.344-0.098-0.762-0.098-1.249c0-0.849,0.126-1.448,0.379-1.799  S152.303,58.717,152.801,58.717z M152.777,62.963c0.213,0,0.369-0.119,0.468-0.359c0.099-0.238,0.146-0.76,0.146-1.562  c0-0.772-0.05-1.267-0.15-1.482c-0.102-0.214-0.258-0.323-0.465-0.323c-0.188,0-0.326,0.075-0.414,0.225s-0.145,0.348-0.164,0.588  c-0.022,0.243-0.034,0.572-0.034,0.993c0,0.825,0.05,1.353,0.147,1.581C152.409,62.848,152.564,62.963,152.777,62.963z"/>
+<path fill="#646464" d="M98.354,90.792l1.006,0.579c0.024-0.05,0.072-0.139,0.147-0.266c0.23-0.402,0.517-0.65,0.854-0.742  c0.338-0.093,0.71-0.023,1.116,0.213c0.463,0.266,0.737,0.582,0.826,0.947c0.09,0.366-0.008,0.791-0.288,1.278  c-0.159,0.274-0.371,0.548-0.634,0.817l-0.478-0.276l0.004-0.005c0.281-0.283,0.474-0.515,0.578-0.695  c0.156-0.272,0.202-0.513,0.137-0.723c-0.065-0.209-0.25-0.4-0.554-0.576c-0.267-0.154-0.51-0.199-0.726-0.135  c-0.218,0.064-0.409,0.24-0.574,0.526c-0.113,0.196-0.219,0.399-0.314,0.607l-1.965-1.134l1.205-2.086l0.467,0.27L98.354,90.792z"/>
+<path fill="#646464" d="M99.691,87.299c0.24-0.417,0.57-0.646,0.99-0.689c0.419-0.041,1.004,0.154,1.753,0.588  c0.823,0.474,1.317,0.902,1.487,1.289c0.168,0.387,0.132,0.787-0.111,1.209c-0.213,0.369-0.472,0.592-0.775,0.665  c-0.304,0.076-0.622,0.057-0.951-0.06c-0.332-0.115-0.707-0.295-1.131-0.539c-0.734-0.424-1.191-0.834-1.368-1.227  C99.408,88.141,99.443,87.729,99.691,87.299z M103.357,89.441c0.106-0.186,0.08-0.381-0.076-0.586  c-0.157-0.203-0.584-0.508-1.279-0.91c-0.668-0.385-1.121-0.588-1.359-0.607c-0.238-0.019-0.409,0.061-0.512,0.238  c-0.094,0.164-0.098,0.32-0.013,0.473c0.087,0.151,0.228,0.298,0.427,0.438c0.198,0.141,0.479,0.314,0.841,0.524  c0.716,0.414,1.196,0.633,1.443,0.663C103.074,89.702,103.25,89.625,103.357,89.441z"/>
+<path fill="#646464" d="M93.864,118.926h0.538v0.48h1.027v0.844h-1.027v1.879h-0.514l-2.398-1.469l-0.751-0.458v-0.796h3.125  V118.926z M93.864,121.475v-1.225H91.81L93.864,121.475z"/>
+<path fill="#646464" d="M91.303,117.632h1.161c-0.005-0.057-0.008-0.157-0.008-0.306c0-0.465,0.124-0.821,0.37-1.071  c0.245-0.249,0.604-0.374,1.072-0.374c0.535,0,0.932,0.137,1.191,0.41c0.259,0.272,0.389,0.688,0.389,1.248  c0,0.32-0.047,0.661-0.141,1.026h-0.55v-0.005c0.102-0.387,0.152-0.684,0.152-0.893c0-0.313-0.081-0.545-0.242-0.693  c-0.162-0.148-0.418-0.225-0.769-0.225c-0.308,0-0.54,0.083-0.695,0.248c-0.156,0.164-0.234,0.413-0.234,0.74  c0,0.229,0.012,0.457,0.032,0.686h-2.269v-2.408h0.539v1.617H91.303z"/>
+<path fill="#646464" d="M101.485,147.51l0.466-0.27l0.241,0.418l0.889-0.516l0.422,0.731l-0.89,0.515l0.938,1.625l-0.442,0.256  l-2.813-0.068l-0.88-0.023l-0.397-0.688l2.707-1.566L101.485,147.51z M102.76,149.717l-0.611-1.059l-1.781,1.027L102.76,149.717z"/>
+<path fill="#646464" d="M97.89,147.586c-0.241-0.418-0.274-0.82-0.102-1.205c0.174-0.385,0.635-0.791,1.385-1.225  c0.821-0.473,1.44-0.688,1.859-0.643c0.419,0.047,0.749,0.28,0.992,0.7c0.213,0.369,0.275,0.705,0.188,1.004  c-0.086,0.3-0.262,0.563-0.526,0.791c-0.267,0.229-0.609,0.47-1.032,0.712c-0.734,0.424-1.317,0.614-1.747,0.571  C98.477,148.25,98.139,148.012,97.89,147.586z M101.576,145.48c-0.105-0.185-0.287-0.26-0.543-0.226  c-0.256,0.031-0.732,0.25-1.428,0.651c-0.668,0.386-1.071,0.679-1.207,0.871c-0.136,0.197-0.151,0.388-0.048,0.563  c0.093,0.164,0.228,0.246,0.402,0.246c0.175,0.002,0.372-0.047,0.591-0.149c0.222-0.101,0.514-0.256,0.877-0.465  c0.715-0.412,1.146-0.72,1.294-0.918C101.664,145.855,101.684,145.666,101.576,145.48z"/>
+<path fill="#646464" d="M124.009,170.736c-0.531-0.309-0.894-0.443-1.089-0.41c-0.194,0.029-0.356,0.16-0.485,0.383  c-0.113,0.195-0.147,0.373-0.099,0.533s0.178,0.303,0.388,0.422c0.185,0.109,0.47,0.213,0.857,0.313l0.005,0.004l-0.274,0.478  c-0.388-0.112-0.721-0.246-0.995-0.403c-0.414-0.238-0.677-0.502-0.787-0.789c-0.112-0.285-0.072-0.595,0.12-0.929  c0.132-0.229,0.308-0.392,0.528-0.481c0.22-0.097,0.467-0.105,0.738-0.041c-0.227-0.191-0.359-0.408-0.397-0.654  c-0.038-0.244,0.016-0.492,0.16-0.742c0.239-0.412,0.54-0.652,0.899-0.723c0.361-0.066,0.781,0.037,1.265,0.318  c0.289,0.163,0.561,0.379,0.813,0.637l-0.271,0.473l-0.005-0.004c-0.304-0.293-0.558-0.498-0.761-0.615  c-0.247-0.143-0.467-0.188-0.662-0.137c-0.195,0.055-0.362,0.205-0.508,0.451c-0.152,0.266-0.188,0.498-0.106,0.699  c0.082,0.2,0.391,0.457,0.926,0.766L124.009,170.736z"/>
+<path fill="#646464" d="M119.964,170.016l0.581-1.006c-0.052-0.025-0.14-0.074-0.268-0.146c-0.402-0.231-0.649-0.518-0.742-0.854  c-0.094-0.338-0.021-0.711,0.212-1.119c0.269-0.459,0.584-0.736,0.95-0.826c0.364-0.09,0.791,0.011,1.276,0.289  c0.276,0.16,0.55,0.371,0.819,0.638l-0.277,0.475l-0.005-0.004c-0.283-0.28-0.516-0.474-0.695-0.578  c-0.271-0.155-0.513-0.198-0.722-0.135c-0.211,0.063-0.402,0.25-0.578,0.551c-0.154,0.269-0.199,0.511-0.134,0.726  c0.064,0.221,0.24,0.41,0.525,0.574c0.197,0.112,0.4,0.221,0.608,0.317l-1.134,1.963l-2.086-1.207l0.27-0.467L119.964,170.016z"/>
+<path fill="#646464" d="M153.499,177.301c-0.614,0-0.996,0.061-1.149,0.186c-0.152,0.125-0.229,0.316-0.229,0.578  c0,0.226,0.063,0.396,0.184,0.513s0.305,0.174,0.547,0.174c0.213,0,0.512-0.056,0.896-0.162h0.008v0.552  c-0.393,0.1-0.748,0.146-1.064,0.146c-0.478,0-0.838-0.097-1.075-0.285c-0.24-0.194-0.36-0.481-0.36-0.864  c0-0.269,0.072-0.496,0.217-0.685c0.144-0.188,0.349-0.326,0.619-0.404c-0.292-0.051-0.516-0.176-0.672-0.366  c-0.155-0.193-0.233-0.437-0.233-0.728c0-0.478,0.14-0.834,0.418-1.074c0.276-0.237,0.695-0.358,1.252-0.358  c0.334,0,0.678,0.049,1.026,0.146v0.543h-0.006c-0.41-0.101-0.731-0.151-0.966-0.151c-0.284,0-0.497,0.071-0.643,0.217  c-0.144,0.145-0.213,0.356-0.213,0.643c0,0.305,0.084,0.525,0.254,0.658c0.174,0.135,0.568,0.201,1.188,0.201V177.301  L153.499,177.301z"/>
+<path fill="#646464" d="M149.197,179.285c-0.482,0-0.845-0.17-1.092-0.514c-0.245-0.34-0.367-0.943-0.367-1.81  c0-0.948,0.122-1.594,0.373-1.933c0.249-0.34,0.616-0.51,1.103-0.51c0.426,0,0.747,0.111,0.964,0.338  c0.218,0.228,0.358,0.511,0.424,0.854c0.065,0.347,0.098,0.761,0.098,1.248c0,0.851-0.125,1.451-0.377,1.799  C150.068,179.111,149.694,179.285,149.197,179.285z M149.22,175.041c-0.213,0-0.369,0.121-0.468,0.359  c-0.098,0.236-0.147,0.76-0.147,1.563c0,0.771,0.05,1.266,0.153,1.482c0.102,0.217,0.256,0.322,0.463,0.322  c0.188,0,0.325-0.072,0.414-0.226c0.088-0.149,0.145-0.349,0.166-0.588c0.021-0.242,0.033-0.574,0.033-0.992  c0-0.828-0.051-1.353-0.147-1.582C149.587,175.154,149.433,175.041,149.22,175.041z"/>
+<path fill="#646464" d="M179.164,167.535l-0.273-0.469l2.418-1.396l0.17,0.295c0.164,0.283,0.258,0.559,0.287,0.836  c0.027,0.275,0.014,0.531-0.039,0.766c-0.054,0.238-0.136,0.515-0.248,0.822c-0.135,0.369-0.201,0.639-0.199,0.799  c0.002,0.158,0.037,0.299,0.104,0.418c0.12,0.209,0.268,0.334,0.441,0.379c0.171,0.039,0.369-0.002,0.59-0.131  c0.234-0.137,0.484-0.358,0.75-0.676l0.005-0.002l0.278,0.482c-0.285,0.313-0.598,0.564-0.928,0.756  c-0.412,0.238-0.773,0.326-1.09,0.27c-0.316-0.055-0.576-0.26-0.781-0.608c-0.112-0.197-0.176-0.416-0.189-0.664  c-0.016-0.246,0.068-0.623,0.252-1.125c0.104-0.281,0.176-0.513,0.227-0.688c0.047-0.178,0.069-0.354,0.068-0.533  c-0.002-0.18-0.043-0.352-0.131-0.518L179.164,167.535z"/>
+<path fill="#646464" d="M179.66,171.387l-0.58-1.006c-0.046,0.029-0.135,0.084-0.26,0.156c-0.402,0.232-0.773,0.307-1.112,0.215  c-0.338-0.088-0.626-0.334-0.86-0.74c-0.266-0.463-0.348-0.873-0.24-1.236c0.104-0.356,0.399-0.68,0.887-0.961  c0.277-0.16,0.599-0.291,0.96-0.389l0.274,0.475l-0.006,0.004c-0.386,0.104-0.666,0.207-0.849,0.314  c-0.271,0.155-0.431,0.342-0.479,0.555c-0.045,0.215,0.017,0.475,0.192,0.779c0.153,0.266,0.341,0.426,0.562,0.479  s0.474-0.004,0.761-0.17c0.196-0.111,0.389-0.236,0.577-0.369l1.135,1.965l-2.087,1.203l-0.269-0.465L179.66,171.387z"/>
+<path fill="#646464" d="M199.659,146.943l-0.47-0.271l1.395-2.416l0.295,0.171c0.283,0.161,0.504,0.356,0.666,0.577  c0.162,0.226,0.281,0.453,0.352,0.685c0.072,0.231,0.139,0.512,0.196,0.836c0.067,0.389,0.146,0.652,0.228,0.791  s0.182,0.242,0.302,0.311c0.209,0.121,0.397,0.156,0.569,0.107c0.168-0.051,0.317-0.187,0.445-0.408  c0.135-0.236,0.239-0.557,0.311-0.961l0.004-0.006l0.482,0.279c-0.094,0.414-0.233,0.786-0.427,1.12  c-0.235,0.41-0.506,0.669-0.81,0.779c-0.303,0.108-0.629,0.062-0.979-0.142c-0.198-0.112-0.362-0.272-0.497-0.479  c-0.136-0.206-0.25-0.574-0.345-1.102c-0.052-0.297-0.103-0.531-0.147-0.707c-0.049-0.176-0.117-0.342-0.207-0.498  c-0.092-0.152-0.213-0.281-0.369-0.381L199.659,146.943z"/>
+<path fill="#646464" d="M202.305,150.705c-0.24,0.414-0.57,0.645-0.99,0.688c-0.418,0.041-1.002-0.154-1.752-0.586  c-0.821-0.475-1.317-0.904-1.485-1.291c-0.17-0.385-0.132-0.787,0.11-1.209c0.213-0.369,0.471-0.59,0.774-0.664  c0.304-0.076,0.622-0.057,0.95,0.06c0.332,0.114,0.708,0.295,1.131,0.541c0.734,0.422,1.191,0.834,1.371,1.226  C202.59,149.861,202.555,150.273,202.305,150.705z M198.641,148.564c-0.107,0.182-0.082,0.375,0.075,0.582  c0.157,0.205,0.582,0.51,1.278,0.912c0.669,0.385,1.122,0.588,1.357,0.604c0.238,0.02,0.41-0.059,0.516-0.238  c0.094-0.162,0.096-0.318,0.012-0.471c-0.086-0.15-0.227-0.297-0.426-0.438c-0.199-0.142-0.48-0.314-0.844-0.521  c-0.715-0.414-1.195-0.637-1.44-0.664C198.922,148.301,198.746,148.377,198.641,148.564z"/>
+<path fill="#646464" d="M119.518,68.245l0.58,1.005c0.047-0.032,0.134-0.084,0.26-0.156c0.404-0.232,0.773-0.307,1.113-0.217  c0.337,0.09,0.626,0.336,0.859,0.742c0.268,0.463,0.348,0.873,0.241,1.236c-0.105,0.359-0.401,0.682-0.888,0.963  c-0.276,0.156-0.596,0.289-0.959,0.389l-0.275-0.477l0.006-0.004c0.387-0.102,0.668-0.207,0.848-0.312  c0.272-0.155,0.431-0.341,0.479-0.558c0.049-0.214-0.015-0.472-0.19-0.775c-0.154-0.266-0.341-0.428-0.562-0.479  c-0.22-0.055-0.474,0.003-0.759,0.168c-0.197,0.113-0.39,0.237-0.578,0.371l-1.133-1.965l2.085-1.205l0.27,0.465L119.518,68.245z"/>
+<path fill="#646464" d="M122.338,66.618l0.58,1.004c0.046-0.031,0.134-0.083,0.259-0.156c0.403-0.232,0.774-0.306,1.113-0.216  c0.339,0.088,0.626,0.336,0.86,0.742c0.267,0.463,0.348,0.873,0.24,1.234c-0.104,0.361-0.401,0.682-0.887,0.963  c-0.276,0.16-0.596,0.29-0.958,0.391l-0.276-0.475l0.006-0.006c0.385-0.104,0.668-0.207,0.849-0.312  c0.271-0.157,0.431-0.343,0.479-0.558c0.048-0.214-0.015-0.474-0.19-0.775c-0.155-0.269-0.342-0.429-0.562-0.479  c-0.221-0.055-0.473,0.002-0.76,0.166c-0.197,0.114-0.39,0.238-0.577,0.371l-1.135-1.965l2.087-1.203l0.269,0.464L122.338,66.618z"/>
+<path fill="#646464" d="M207.07,118.969h-0.502v-2.763h0.502v0.982h3.49l-0.227-0.982h0.501l0.435,1.378v0.455h-4.201  L207.07,118.969L207.07,118.969z"/>
+<path fill="#646464" d="M210.693,120.371h-1.16c0.005,0.057,0.008,0.158,0.008,0.304c0,0.466-0.123,0.821-0.369,1.073  c-0.246,0.248-0.604,0.373-1.074,0.373c-0.533,0-0.93-0.137-1.188-0.408c-0.262-0.271-0.391-0.689-0.391-1.251  c0-0.317,0.047-0.659,0.143-1.026h0.55v0.007c-0.104,0.386-0.153,0.684-0.153,0.894c0,0.312,0.082,0.543,0.242,0.692  c0.162,0.148,0.416,0.225,0.768,0.225c0.31,0,0.543-0.083,0.697-0.249c0.155-0.164,0.232-0.411,0.232-0.739  c0-0.228-0.012-0.457-0.031-0.685h2.268v2.407h-0.539v-1.617H210.693z"/>
+<path fill="#646464" d="M180.623,67.174l-0.58,1.006c0.053,0.023,0.141,0.072,0.266,0.146c0.402,0.233,0.652,0.519,0.744,0.855  c0.094,0.339,0.021,0.712-0.213,1.117c-0.267,0.462-0.584,0.737-0.949,0.827c-0.365,0.087-0.791-0.008-1.275-0.289  c-0.276-0.158-0.549-0.371-0.816-0.634l0.275-0.478l0.007,0.004c0.28,0.28,0.515,0.474,0.694,0.578  c0.271,0.156,0.511,0.201,0.722,0.136c0.21-0.065,0.401-0.25,0.577-0.552c0.152-0.268,0.199-0.51,0.134-0.729  c-0.065-0.215-0.24-0.406-0.524-0.57c-0.197-0.114-0.399-0.22-0.609-0.315l1.135-1.965l2.086,1.203l-0.268,0.468L180.623,67.174z"/>
+<path fill="#646464" d="M199.538,90.932l-0.433,0.25l-1.383-2.392l0.434-0.25l0.492,0.851l3.023-1.746l-0.688-0.738l0.437-0.25  l1.065,0.977l0.226,0.393l-3.639,2.101L199.538,90.932z"/>
+<path fill="#646464" d="M204.107,90.42c0.242,0.418,0.274,0.816,0.102,1.202c-0.173,0.384-0.634,0.792-1.385,1.226  c-0.819,0.475-1.441,0.688-1.859,0.641c-0.416-0.047-0.748-0.28-0.99-0.701c-0.213-0.366-0.275-0.703-0.189-1.002  c0.088-0.3,0.264-0.566,0.527-0.795c0.267-0.228,0.609-0.465,1.031-0.709c0.734-0.425,1.318-0.615,1.748-0.572  S203.859,89.99,204.107,90.42z M200.42,92.523c0.105,0.185,0.288,0.26,0.545,0.225c0.256-0.031,0.732-0.25,1.428-0.652  c0.67-0.385,1.07-0.678,1.207-0.871c0.135-0.197,0.151-0.386,0.049-0.564c-0.094-0.162-0.229-0.245-0.402-0.246  c-0.174-0.002-0.372,0.049-0.592,0.15c-0.223,0.102-0.514,0.256-0.877,0.467c-0.715,0.412-1.146,0.719-1.295,0.917  C200.335,92.148,200.313,92.34,200.42,92.523z"/>
+<circle fill="none" cx="150.999" cy="119.001" r="61.507"/>
+<rect x="81.162" y="49.164" fill="none" width="139.674" height="139.676"/>
+<rect x="81.165" y="49.164" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -39.9185 141.6281)" fill="none" width="139.672" height="139.672"/>
+<path fill-opacity="0.4" d="M166.857,135.764c-0.252,0.25-0.654,0.25-0.903,0.004l-50.748-50.75c-0.248-0.248-0.247-0.65,0.003-0.9  l0.906-0.906c0.25-0.25,0.654-0.252,0.901-0.006l50.751,50.75c0.246,0.248,0.246,0.651-0.006,0.899L166.857,135.764z"/>
+<rect x="140.849" y="73.605" transform="matrix(0.7067 -0.7075 0.7075 0.7067 -35.968 132.2127)" fill="#FFFFFF" width="1.281" height="71.77"/>
+<linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="354.7988" y1="-95.1782" x2="354.7988" y2="-130.7611" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
+<stop offset="0" style="stop-color:#FFFFFF"/>
+<stop offset="0.9455" style="stop-color:#CBCBCB"/>
+<stop offset="1" style="stop-color:#CBCBCB"/>
+</linearGradient>
+<path display="none" fill="url(#SVGID_5_)" d="M154.729,117.99c-3.874,0-6.007-2.244-6.007-6.319v-13.96  c0-4.23,3.511-5.73,6.517-5.73h0.287c0.248,0,0.271-0.002,0.472-0.01l0.164-0.006c1.626-0.056,3.36-1.23,3.358-4.359  c-0.002-2.646,0.717-4.59,2.139-5.769c1.215-1.011,2.662-1.222,3.664-1.222c0.71,0,1.21,0.107,1.229,0.112  c14.013,2.417,21.496,14.197,22.324,21.788c0.235,2.158-0.549,4.537-2.044,6.206c-1.003,1.117-2.794,2.45-5.637,2.45  c-4.256,0-5.939,1.467-6.84,2.57l-0.254,0.317c-1.168,1.472-3.125,3.933-7.32,3.933L154.729,117.99L154.729,117.99z"/>
+<linearGradient id="SVGID_6_" gradientUnits="userSpaceOnUse" x1="354.7988" y1="-131.1069" x2="354.7988" y2="-94.4508" gradientTransform="matrix(1 0 0 -1 -185.98 -13.5195)">
+<stop offset="0" style="stop-color:#B4B4B4"/>
+<stop offset="1" style="stop-color:#A0A0A0"/>
+</linearGradient>
+<path display="none" fill="url(#SVGID_6_)" d="M188.876,102.516c-0.828-7.591-8.312-19.371-22.323-21.788  c-0.021-0.005-0.521-0.112-1.23-0.112c-1.002,0-2.449,0.211-3.664,1.222c-1.422,1.179-2.141,3.122-2.139,5.769  c0.002,3.129-1.732,4.304-3.358,4.359l-0.164,0.006c-0.2,0.008-0.224,0.01-0.472,0.01h-0.287c-3.006,0-6.517,1.5-6.517,5.73v13.96  c0,4.075,2.134,6.319,6.007,6.319h12.054c4.194,0,6.151-2.461,7.319-3.931l0.254-0.317c0.898-1.104,2.586-2.57,6.842-2.57  c2.842,0,4.632-1.333,5.636-2.45C188.326,107.053,189.111,104.674,188.876,102.516z M181.193,110.531  c-4.494,0-6.334,1.576-7.336,2.807c-1.164,1.436-2.895,4.014-7.076,4.014s-7.477,0-12.055,0c-4.579,0-5.365-3.25-5.365-5.681  c0-2.429,0-13.96,0-13.96c0-3.771,3.05-5.091,5.876-5.091c0.639,0,0.482,0.002,0.947-0.015c2.119-0.072,3.977-1.645,3.975-4.998  c-0.006-7.635,6.253-6.255,6.253-6.255c13.789,2.379,21.036,13.987,21.825,21.231C188.607,105.965,186.218,110.531,181.193,110.531z  "/>
+<rect x="81.163" y="49.163" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 173.6274 309.9154)" fill="none" width="139.672" height="139.671"/>
+<polygon fill-opacity="0.4" points="161.545,112.082 123.561,150.064 119.503,150.271 119.953,146.424 157.92,108.457 "/>
+<polygon points="157.92,109.363 160.639,112.082 123.281,149.438 120.229,149.594 120.563,146.719 "/>
+<rect x="81.162" y="49.164" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 341.915 96.3727)" fill="none" width="139.673" height="139.671"/>
+<polygon fill-opacity="0.4" points="146.12,109.589 174.588,138.059 174.344,142.57 170.041,142.572 141.589,114.119 "/>
+<polygon fill="#1A1A1A" points="142.495,114.119 146.12,110.495 173.962,138.336 173.665,141.844 170.337,141.963 "/>
+<path fill-opacity="0.4" d="M146.924,114.924c2.247-2.25,5.905-2.248,8.154,0c2.248,2.248,2.248,5.905,0,8.152  c-2.249,2.249-5.906,2.251-8.154,0.002C144.675,120.829,144.675,117.17,146.924,114.924L146.924,114.924z"/>
+<linearGradient id="SVGID_7_" gradientUnits="userSpaceOnUse" x1="-3819.5313" y1="-1695.1787" x2="-3819.5313" y2="-1684.7993" gradientTransform="matrix(-0.7071 0.7071 -0.7071 -0.7071 -3744.7813 1624.7996)">
 <stop offset="0" style="stop-color:#999999"/>
 <stop offset="0.31" style="stop-color:#4D4D4D"/>
 <stop offset="1" style="stop-color:#000000"/>
 </linearGradient>
-<circle fill="url(#SVGID_4_)" cx="112" cy="69.618" r="4.088"/>
-<path fill="#E6E6E6" d="M109.432,67.049c1.417-1.416,3.72-1.417,5.138,0c1.417,1.416,1.416,3.721,0,5.138  c-1.417,1.415-3.722,1.416-5.138,0.001C108.015,70.772,108.015,68.464,109.432,67.049L109.432,67.049z"/>
-<path fill="#595959" d="M126.015,58.987l-0.303-1.292h-1.688l-0.315,1.292h-1.268l1.737-6.196h1.705l1.623,6.196H126.015z   M125.541,56.892l-0.665-2.917l-0.681,2.917H125.541z"/>
-<path fill="#595959" d="M133.559,52.791v6.196h-1.389v-4.111l-1.071,2.095h-0.512l-1.072-2.095v4.111h-1.397v-6.196h1.226l1.5,2.93  l1.497-2.93H133.559z"/>
+<circle fill="url(#SVGID_7_)" cx="151" cy="119" r="5.19"/>
+<path fill="#E6E6E6" d="M147.739,115.738c1.798-1.797,4.725-1.799,6.525,0c1.797,1.799,1.797,4.725-0.002,6.524  c-1.798,1.799-4.726,1.799-6.523,0C145.939,120.463,145.941,117.537,147.739,115.738L147.739,115.738z"/>
+<rect fill="none" width="302" height="238"/>
 </svg>
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsanalogclockwidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsanalogclockwidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -20,7 +20,7 @@
 
 #include <HbStyleLoader>
 #include <HbIconItem>
-#include <HbTouchArea>
+#include <HbTapGesture>
 #include <HbInstantFeedback>
 
 #include "hsconfiguration.h"
@@ -38,12 +38,13 @@
 HsAnalogClockWidget::HsAnalogClockWidget(QGraphicsItem *parent)
     : HbWidget(parent),
       mBackground(0), mHourHand(0), mMinuteHand(0), 
-      mSecondHand(0), mTouchArea(0)
+      mSecondHand(0)
 {
     HbStyleLoader::registerFilePath(":/hsanalogclockwidget.widgetml");
     HbStyleLoader::registerFilePath(":/hsanalogclockwidget.css");
 
     createPrimitives();
+    grabGesture(Qt::TapGesture);
 }
 
 /*!
@@ -53,28 +54,27 @@
 {
     HbStyleLoader::unregisterFilePath(":/hsanalogclockwidget.widgetml");
     HbStyleLoader::unregisterFilePath(":/hsanalogclockwidget.css");
-    mTouchArea->removeEventFilter(this);
 }
 
-/*!
-    Filters touch area events.
-*/
-bool HsAnalogClockWidget::eventFilter(QObject *watched, QEvent *event)
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+void HsAnalogClockWidget::gestureEvent(QGestureEvent *event)
 {
-    Q_UNUSED(watched)
+    HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
+    if (gesture) {
+        if (gesture->state() == Qt::GestureFinished) {
+            if (gesture->tapStyleHint() == HbTapGesture::Tap) {
+                    HbInstantFeedback::play(HSCONFIGURATION_GET(clockWidgetTapFeedbackEffect));
+                    emit clockTapped();                
+            }
+        }
+    }
+}
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
 
-    switch (event->type()) {
-        case QEvent::GraphicsSceneMousePress:
-            return true;
-        case QEvent::GraphicsSceneMouseRelease:
-            handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-            return true;
-        default:
-            break;
-    }
-
-    return false;
-}
 
 /*!
     Return bounding rect
@@ -130,10 +130,6 @@
 
     mSecondHand = new HbIconItem(QLatin1String("qtg_graf_clock_day_sec"), this);
     HbStyle::setItemName(mSecondHand, QLatin1String("second_hand"));
-
-    mTouchArea = new HbTouchArea(this);
-    mTouchArea->installEventFilter(this);    
-    HbStyle::setItemName(mTouchArea, QLatin1String("toucharea"));
 }
 
 /*!
@@ -160,17 +156,3 @@
     mSecondHand->setTransformOriginPoint(originPoint);
     mSecondHand->setRotation(s);
 }
-
-/*!
-    \internal
-*/
-void HsAnalogClockWidget::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    if (!contains(event->pos())) {
-        return;
-    }
-
-    HbInstantFeedback::play(HSCONFIGURATION_GET(clockWidgetTapFeedbackEffect));
-
-    emit clockTapped();
-}
--- a/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsdigitalclockwidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsclockwidgetplugin/src/hsdigitalclockwidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -22,10 +22,11 @@
 #include <HbIconItem>
 #include <HbFrameItem>
 #include <HbFrameDrawer>
-#include <HbTouchArea>
+#include <HbTapGesture>
 #include <HbInstantFeedback>
 
 #include "hsdigitalclockwidget.h"
+#include "hsconfiguration.h"
 
 /*!
     \class HsDigitalClockWidget
@@ -41,7 +42,7 @@
     mBackground(0),
     mDigit1(0), mDigit2(0), mDigit3(0),
     mDigit4(0), mDigit5(0), mDigit6(0),
-    mAmPm(0), mTouchArea(0), mUseAmPm(useAmPm)
+    mAmPm(0), mUseAmPm(useAmPm)
 {
     HbStyleLoader::registerFilePath(":/hsdigitalclockwidget.widgetml");
     HbStyleLoader::registerFilePath(":/hsdigitalclockwidget.css");
@@ -69,6 +70,7 @@
     mDigitMap.insert(QChar('9'), QString(":/clock_widget_nine.svg"));
 
     createPrimitives();
+    grabGesture(Qt::TapGesture);
 }
 
 /*!
@@ -78,28 +80,26 @@
 {
     HbStyleLoader::unregisterFilePath(":/hsdigitalclockwidget.widgetml");
     HbStyleLoader::unregisterFilePath(":/hsdigitalclockwidget.css");
-    mTouchArea->removeEventFilter(this);
 }
 
-/*!
-    Filters touch area events.
-*/
-bool HsDigitalClockWidget::eventFilter(QObject *watched, QEvent *event)
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+void HsDigitalClockWidget::gestureEvent(QGestureEvent *event)
 {
-    Q_UNUSED(watched)
-
-    switch (event->type()) {
-        case QEvent::GraphicsSceneMousePress:
-            return true;
-        case QEvent::GraphicsSceneMouseRelease:
-            handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-            return true;
-        default:
-            break;
+    HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
+    if (gesture) {
+        if (gesture->state() == Qt::GestureFinished) {
+            if (gesture->tapStyleHint() == HbTapGesture::Tap) {
+                    HbInstantFeedback::play(HSCONFIGURATION_GET(clockWidgetTapFeedbackEffect));
+                    emit clockTapped();                
+            }
+        }
     }
-
-    return false;
 }
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
 
 /*!
     Return shape
@@ -202,10 +202,6 @@
         mAmPm = new HbIconItem(QLatin1String(":/clock_widget_am.svg"), this);
         HbStyle::setItemName(mAmPm, QLatin1String("ampm"));
     }
-
-    mTouchArea = new HbTouchArea(this);
-    mTouchArea->installEventFilter(this);
-    HbStyle::setItemName(mTouchArea, QLatin1String("toucharea"));
 }
 
 /*!
@@ -248,17 +244,3 @@
         }
     }
 }
-
-/*!
-    \internal
-*/
-void HsDigitalClockWidget::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    if (!contains(event->pos())) {
-        return;
-    }
-
-    HbInstantFeedback::play(HbFeedback::BasicItem);
-
-    emit clockTapped();
-}
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/inc/hsshortcutwidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/inc/hsshortcutwidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -28,7 +28,7 @@
 class HbFrameItem;    
 class HbIconItem;
 class HbTextItem;
-class HbTouchArea;
+class QGestureEvent;
 class CaEntry;
 
 class HsShortcutWidget : public HbWidget
@@ -51,8 +51,6 @@
     QString text() const;
     void setText(const QString& textItem);
 
-    bool eventFilter(QObject *watched, QEvent *event);
-
 signals:
     void finished();
     void setPreferences(const QStringList &names);
@@ -62,12 +60,13 @@
     void onShow();
     void onHide();
 
+protected:
+    void gestureEvent(QGestureEvent *event);
+
 private:
     Q_DISABLE_COPY(HsShortcutWidget)
-
-    void handleMousePressEvent(QGraphicsSceneMouseEvent *event);
-    void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event);
-    void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+    
+    void launch();
             
     void createPrimitives();
     void updateContent(const CaEntry &caEntry);
@@ -85,8 +84,7 @@
     HbFrameItem *mBackground;
     HbIconItem *mIcon;
     HbTextItem *mText;
-    HbTouchArea *mTouchArea;
-    
+        
     int mCaEntryId;
     QString mUid;
     EntryRole mCaEntryRole;
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.css	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.css	Fri Jul 23 13:47:57 2010 +0300
@@ -54,7 +54,3 @@
 	color: var(qtc_hs_list_item_title_normal);
 	zvalue: 2;
 }
-
-HsShortcutWidget::toucharea {  
-  zvalue: 3;
-}
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.widgetml	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/resource/hsshortcutwidget.widgetml	Fri Jul 23 13:47:57 2010 +0300
@@ -10,12 +10,7 @@
     <meshitem src="icon" srcEdge="CENTERH" dst="" dstEdge="CENTERH" />
     
     <meshitem src="text" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
-    <meshitem src="text" srcEdge="CENTERH" dst="" dstEdge="CENTERH" />  
-    
-    <meshitem src="toucharea" srcEdge="LEFT" dst="" dstEdge="LEFT" />
-    <meshitem src="toucharea" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
-    <meshitem src="toucharea" srcEdge="TOP" dst="" dstEdge="TOP" />
-    <meshitem src="toucharea" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />  
+    <meshitem src="text" srcEdge="CENTERH" dst="" dstEdge="CENTERH" />
   </layout>
   
   <layout name="icon_shortcut" type="mesh">    
@@ -25,12 +20,7 @@
     <meshitem src="background" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
     
     <meshitem src="icon" srcEdge="CENTERV" dst="" dstEdge="CENTERV" />
-    <meshitem src="icon" srcEdge="CENTERH" dst="" dstEdge="CENTERH" /> 
-    
-    <meshitem src="toucharea" srcEdge="LEFT" dst="" dstEdge="LEFT" />
-    <meshitem src="toucharea" srcEdge="RIGHT" dst="" dstEdge="RIGHT" />
-    <meshitem src="toucharea" srcEdge="TOP" dst="" dstEdge="TOP" />
-    <meshitem src="toucharea" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
+    <meshitem src="icon" srcEdge="CENTERH" dst="" dstEdge="CENTERH" />
   </layout>
   
 </hbwidget>
--- a/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/homescreenapp/widgetplugins/hsshortcutwidgetplugin/src/hsshortcutwidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -22,8 +22,8 @@
 #include <HbFrameDrawer>
 #include <HbIconItem>
 #include <HbTextItem>
-#include <HbTouchArea>
 #include <HbInstantFeedback>
+#include <HbTapGesture>
 
 #include "hsshortcutwidget.h"
 #include "hsshortcutservice.h"
@@ -47,9 +47,11 @@
 */
 HsShortcutWidget::HsShortcutWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
   : HbWidget(parent, flags),
-    mBackground(0), mIcon(0), mText(0), mTouchArea(0),
+    mBackground(0), mIcon(0), mText(0),
     mCaEntryId(-1), mCaEntryRole(ItemEntryRole)
 {
+    grabGesture(Qt::TapGesture);
+
     HbStyleLoader::registerFilePath(":/hsshortcutwidget.widgetml");
     HbStyleLoader::registerFilePath(":/hsshortcutwidget.css");
 
@@ -120,33 +122,6 @@
 }
 
 /*!
-    Filters touch area events.
-*/
-bool HsShortcutWidget::eventFilter(QObject *watched, QEvent *event)
-{
-    Q_UNUSED(watched)
-
-    switch (event->type()) {
-        case QEvent::GraphicsSceneMousePress:
-            handleMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-            return true;
-        case QEvent::GraphicsSceneMouseMove:
-            handleMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-            return true;
-        case QEvent::GraphicsSceneMouseRelease:
-            handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-            return true;
-        case QEvent::UngrabMouse:
-            setBackgroundToNormal();
-            return true;
-        default:
-            break;
-    }
-
-    return false;
-}
-
-/*!
     Initializes this widget.
 */
 void HsShortcutWidget::onInitialize()
@@ -204,37 +179,42 @@
 }
 
 /*!
-    \internal
+    \internal  
 */
-void HsShortcutWidget::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+void HsShortcutWidget::gestureEvent(QGestureEvent *event)
 {
-    Q_UNUSED(event)
-    setBackgroundToPressed();
+    HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
+    if (gesture) {
+        switch (gesture->state()) {
+            case Qt::GestureStarted:
+                setBackgroundToPressed();
+                break;            
+            case Qt::GestureCanceled:
+                setBackgroundToNormal();
+                break;
+            case Qt::GestureFinished:
+                setBackgroundToNormal();
+                if (gesture->tapStyleHint() == HbTapGesture::Tap) {
+                    launch();
+                }
+                break;
+            default:
+                break;
+        }
+    }
 }
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
 
 /*!
     \internal
 */
-void HsShortcutWidget::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
+void HsShortcutWidget::launch()
 {
-    if (contains(event->pos())) {
-        setBackgroundToPressed();
-    } else {
-        setBackgroundToNormal();
-    }
-}
-
-/*!
-    \internal
-*/
-void HsShortcutWidget::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    setBackgroundToNormal();
-
-    if (!contains(event->pos())) {
-        return;
-    }
-
     HbInstantFeedback::play(HSCONFIGURATION_GET(shortcutWidgetTapFeedbackEffect));
     
     if (mCaEntryRole == ItemEntryRole) {
@@ -267,12 +247,6 @@
     if (HSCONFIGURATION_GET(isShortcutLabelVisible) && !mText ) {
         mText = new HbTextItem(this);
         HbStyle::setItemName(mText, QLatin1String("text"));
-        }
-    // Touch Area
-    if (!mTouchArea) {
-        mTouchArea = new HbTouchArea(this);
-        mTouchArea->installEventFilter(this);
-        HbStyle::setItemName(mTouchArea, QLatin1String("toucharea"));
     }
 }
 
@@ -350,6 +324,3 @@
         emit finished();
     }
 }
-
-
-
--- a/screensaver/bwins/screensavermodelu.def	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/bwins/screensavermodelu.def	Fri Jul 23 13:47:57 2010 +0300
@@ -54,4 +54,5 @@
 	?handleDeactivatedIndicator@Screensaver@@QAEXPAVHbIndicatorInterface@@@Z @ 53 NONAME ; void Screensaver::handleDeactivatedIndicator(class HbIndicatorInterface *)
 	?onHandleActiveIndicators@Screensaver@@MAEXABV?$QList@PAVHbIndicatorInterface@@@@@Z @ 54 NONAME ; void Screensaver::onHandleActiveIndicators(class QList<class HbIndicatorInterface *> const &)
 	?handleActiveIndicators@Screensaver@@QAEXABV?$QList@PAVHbIndicatorInterface@@@@@Z @ 55 NONAME ; void Screensaver::handleActiveIndicators(class QList<class HbIndicatorInterface *> const &)
+	?screenPowerModeRequested@Screensaver@@IAEXW4ScreenPowerMode@1@@Z @ 56 NONAME ; void Screensaver::screenPowerModeRequested(enum Screensaver::ScreenPowerMode)
 
--- a/screensaver/devicedialogplugins/snsrdevicedialogplugin/inc/snsrdevicedialog.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/devicedialogplugins/snsrdevicedialogplugin/inc/snsrdevicedialog.h	Fri Jul 23 13:47:57 2010 +0300
@@ -23,18 +23,17 @@
 
 
 
-
+#include "screensaver.h"
 #include "snsrtest_global.h"
 
 class Screensaver;
 class SnsrUserActivityServiceInterface;
 class QGraphicsLinearLayout;
 class XQSettingsManager;
+class HbIndicatorInterface;
 
 SCREENSAVER_TEST_CLASS(T_SnsrDeviceDialogPlugin)
 
-class HbIndicatorInterface;
-
 
 class SnsrDeviceDialog: public HbPopup, public HbDeviceDialogInterface
 {
@@ -55,6 +54,8 @@
     };
     
     static const char *dataKeyUnlock;
+    static const char *dataKeySwitchLights;
+    static const char *dataKeySwitchLowPower;
 
 public: // methods
 
@@ -77,6 +78,7 @@
     void screensaverFaulted();
     void changeLayout(Qt::Orientation);
     void requestUnlock();
+    void requestScreenMode(Screensaver::ScreenPowerMode mode);
     // slots for signals emitted by HbIndicatorPluginManager
     void indicatorsActivated(const QList<HbIndicatorInterface*> &activatedIndicators);
     void indicatorActivated(HbIndicatorInterface *activatedIndicator);
--- a/screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialog.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialog.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,22 +15,20 @@
 *
 */
 
-#include <HbMainWindow>
 #include <QGraphicsLinearLayout>
+#include <QGraphicsSceneResizeEvent>
 #include <QPainter>
 #include <QDebug>
+#include <QServiceManager>
+#include <QServiceFilter>
+#include <QServiceInterfaceDescriptor>
+#include <XQSettingsManager>
+#include <HbMainWindow>
 #include <HbIndicatorInterface>
 
-#include <qservicemanager.h>
-#include <qservicefilter.h>
-#include <qserviceinterfacedescriptor.h>
-
 #include <screensaver.h>
-
+#include <screensaverdomaincrkeys.h>
 #include "snsrdevicedialog.h"
-#include <screensaverdomaincrkeys.h>
-#include <xqsettingsmanager.h> 
-
 
 const char *gBigClockInterfaceName = "com.nokia.screensaver.ISnsrBigClockScreensaver";
 
@@ -43,6 +41,8 @@
 extern const char *lViewType;
 
 const char *SnsrDeviceDialog::dataKeyUnlock = "unlock";
+const char *SnsrDeviceDialog::dataKeySwitchLights = "switch_lights";
+const char *SnsrDeviceDialog::dataKeySwitchLowPower = "switch_low_power";
 
 QTM_USE_NAMESPACE
 
@@ -52,7 +52,10 @@
     \param parent Parent.
  */
 SnsrDeviceDialog::SnsrDeviceDialog(const QVariantMap &parameters, QGraphicsItem *parent) :
-        HbPopup(parent) , mScreensaver(0), mLayout(0), m_setManager (0)
+        HbPopup(parent), 
+        mScreensaver(0), 
+        mLayout(0), 
+        m_setManager(0)
 {
     qDebug("SnsrDeviceDialog::SnsrDeviceDialog()");
 
@@ -76,6 +79,10 @@
         SLOT(changeView(QGraphicsWidget*)));
     connect(mScreensaver, SIGNAL(faulted()),
         SLOT(screensaverFaulted()));
+    connect( mScreensaver, SIGNAL(unlockRequested()),
+        SLOT(requestUnlock()) );
+    connect( mScreensaver, SIGNAL(screenPowerModeRequested(Screensaver::ScreenPowerMode)),
+        SLOT(requestScreenMode(Screensaver::ScreenPowerMode)) );
     
     mScreensaver->initialize();
 
@@ -83,10 +90,10 @@
 
     setDismissPolicy(HbPopup::NoDismiss);
     setTimeout(HbPopup::NoTimeout);
+    
+    mainWindow()->setAutomaticOrientationEffectEnabled(false);
 
     setDeviceDialogParameters( parameters );
-    
-    connect( mScreensaver, SIGNAL(unlockRequested()), SLOT(requestUnlock()) );
 }
 
 /*!
@@ -123,18 +130,19 @@
         
     // Check initial view from repository
     if (viewType == ViewTypeInitial ) {
-    XQSettingsManager::Error error;
+        XQSettingsManager::Error error;
         int startupView = 0; 
-        XQSettingsKey settingsKey( XQSettingsKey::TargetCentralRepository, 
+        XQCentralRepositorySettingsKey settingsKey(
                  KCRUidScreensaverSettings.iUid, KScreensaverStartupView ); // TUid as same repository used in control panel via Symbian APIs 
         m_setManager = new XQSettingsManager(this);
-         if (m_setManager) {
-            startupView = m_setManager->readItemValue(settingsKey, XQSettingsManager::TypeInt).toUInt();
+        if (m_setManager) {
+            startupView = m_setManager->readItemValue(settingsKey, XQSettingsManager::TypeInt).toInt();
             error = m_setManager->error();
-            if (error == XQSettingsManager::NoError)
+            if (error == XQSettingsManager::NoError) {
                 viewType = startupView;
+            }
             delete m_setManager;
-         }
+        }
     }
 
     switch (viewType) {
@@ -253,11 +261,17 @@
     
     if (mLayout->count()) {
         mLayout->removeAt(0);
-    }    
+    }
     if (widget) {
         widget->show();
         mLayout->addItem(widget);
+
+        if ( isVisible() ) {
+           changeLayout( mainWindow()->orientation() );
+        }
     }
+    
+
 }
 
 /*!
@@ -280,6 +294,10 @@
     QRectF rect = mainWindow()->layoutRect();
     setMinimumSize( rect.size() );
     setPreferredPos( QPointF(0,0) );
+    QGraphicsSceneResizeEvent sceneResize;
+    sceneResize.setNewSize( rect.size() );
+    event( &sceneResize );
+    mScreensaver->updateLayout();
 }
 
 /*!
@@ -291,6 +309,35 @@
     data.insert(dataKeyUnlock, 1);
     emit deviceDialogData(data);
 }
+
+/*!
+    Send low power mode on/off request to autolock.
+ */
+void SnsrDeviceDialog::requestScreenMode(Screensaver::ScreenPowerMode mode)
+{
+    QVariantMap data;
+    QVariantList rowLimits;
+    if ( mode == Screensaver::ScreenModeOff ) {
+        data.insert(dataKeySwitchLights, 0);
+        data.insert(dataKeySwitchLowPower, rowLimits); // empty list means "low power off"
+    }
+    else if ( mode == Screensaver::ScreenModeLowPower ) {
+        //data.insert(dataKeySwitchLights, 0);
+        int firstRow;
+        int lastRow;
+        mScreensaver->getActiveScreenRows(&firstRow, &lastRow);
+        rowLimits.append( firstRow );
+        rowLimits.append( lastRow );
+        data.insert(dataKeySwitchLowPower, rowLimits);
+    }
+    else if ( mode == Screensaver::ScreenModeFullPower ) {
+        data.insert(dataKeySwitchLights, 30);
+        data.insert(dataKeySwitchLowPower, rowLimits); // empty list means "low power off"
+    }
+    
+    emit deviceDialogData(data);
+}
+
 /*!
     Called when the dialog is created if they are any currently
     activate universal indicators present.
--- a/screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialogplugin.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialogplugin.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -122,7 +122,7 @@
     Q_UNUSED(deviceDialogType)
 
     info->group = SecurityGroup;
-    info->flags = NoDeviceDialogFlags;
+    info->flags = ReceiveIndicatorStatus;
     info->priority = DefaultPriority;
 
     return true;
--- a/screensaver/eabi/screensavermodelu.def	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/eabi/screensavermodelu.def	Fri Jul 23 13:47:57 2010 +0300
@@ -53,4 +53,5 @@
 	_ZN11Screensaver26handleDeactivatedIndicatorEP20HbIndicatorInterface @ 52 NONAME
 	_ZN11Screensaver26onHandleActivatedIndicatorEP20HbIndicatorInterface @ 53 NONAME
 	_ZN11Screensaver28onHandleDeactivatedIndicatorEP20HbIndicatorInterface @ 54 NONAME
+	_ZN11Screensaver24screenPowerModeRequestedENS_15ScreenPowerModeE @ 55 NONAME
 
--- a/screensaver/screensavermodel/inc/screensaver.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensavermodel/inc/screensaver.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -42,10 +42,20 @@
 
 public:
 
+    Q_ENUMS(ScreenPowerMode)
+    
+    enum ScreenPowerMode {
+        ScreenModeOff = 0,
+        ScreenModeLowPower,
+        ScreenModeFullPower
+    };
+    
     Screensaver(QObject *parent = 0);
     virtual ~Screensaver();
 
     ScreensaverState currentState();
+    virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow) = 0;
+    virtual void updateLayout() = 0;
 
 public slots:
 
@@ -80,6 +90,7 @@
     void faulted();
     void viewChanged(QGraphicsWidget *widget);
     void unlockRequested();
+    void screenPowerModeRequested(Screensaver::ScreenPowerMode mode);
 
 private:
 
--- a/screensaver/screensavermodel/src/screensaver.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensavermodel/src/screensaver.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -108,6 +108,19 @@
  */
 
 /*!
+    \fn void Screensaver::unlockRequested()
+
+    This signal is emitted if screensaver wants the device to be unlocked.
+ */
+
+/*!
+    \fn void Screensaver::screenPowerModeRequested(ScreenPowerMode mode)
+
+    This signal is emitted when screensaver wants to switch the power
+    mode of the screen, or update the visible area in power save mode.
+ */
+
+/*!
     Returns the state that the Screensaver is currently in.
     \return The current state.
  */
@@ -117,6 +130,26 @@
 }
 
 /*!
+    \fn virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow) = 0
+
+    Inherited screensavers must implement this function to return the rows where 
+    the screensaver wants to draw graphics. This is called when screen is set to the
+    power save mode. The values returned do not matter in case the screensaver doesn't
+    ask for power save mode.
+    Note that the returned rows should reflect the rows in the natural orientation
+    of the screen device. That is, if default orientation of the screen is portrait,
+    then the return value in landscape mode must reflect the columns between which
+    the graphics are drawn.
+ */
+
+/*!
+    \fn virtual void updateLayout() = 0
+
+    Inherited screensavers must implement this function to reload the screen layout
+    for the current screen orientation.
+ */
+
+/*!
     Initializes the Screensaver
  */
 void Screensaver::initialize()
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsranalogclockcontainer.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsranalogclockcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -22,7 +22,7 @@
 
 SCREENSAVER_TEST_CLASS(T_SnsrBigClockScreensaverPlugin)
 
-class HbLabel;
+class SnsrLabel;
 class SnsrAnalogClockWidget;
 class SnsrSwipeWidget;
 
@@ -38,15 +38,18 @@
 public slots:
 
     virtual void update();
-    virtual void changeLayout(Qt::Orientation orientation);
 
 public: // from base classes
 
     virtual int updateIntervalInMilliseconds();
 
+protected: // from base classes
+
+    virtual void loadWidgets();
+
 private: // data
 
-    HbLabel *mDateLabel;
+    SnsrLabel *mDateLabel;
     SnsrAnalogClockWidget *mAnalogClockWidget;
     SnsrSwipeWidget *mSwipeWidget;
 
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockcontainer.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -42,22 +42,26 @@
 public slots:
 
     virtual void update() = 0;
-    virtual void changeLayout(Qt::Orientation orientation) = 0;
+    virtual void changeLayout(Qt::Orientation orientation);
     
 public:
     
+    void setIndicatorModel(SnsrIndicatorModel &model);
+    virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow);
+    virtual bool isOrientationLocked();
     virtual int updateIntervalInMilliseconds() = 0;
-    void initIndicators(SnsrIndicatorModel &model);
 
 protected:
 
+    virtual void loadWidgets() = 0;
     virtual void changeEvent(QEvent * event);
     QPointF randomPosition(const QRectF &rect);
     QPointF nextRandomPosition(const QPointF &curPos, QPointF &destPos, const QRectF &containerRect);
-
+    void initIndicatorWidget();
+    void resetIndicatorConnections();
+    
 private:
 
-    void resetIndicatorConnections();
     void setBackgroundColor(); 
     void paint(
             QPainter *painter,
@@ -68,6 +72,7 @@
 signals:
 
     void unlockRequested();
+    void activeAreaMoved();
 
 protected:
 
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockscreensaver.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrbigclockscreensaver.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -28,6 +28,7 @@
 class HbMainWindow;
 class SnsrBigClockContainer;
 class SnsrIndicatorModel;
+class XQSettingsManager;
 
 class SnsrBigClockScreensaver : public Screensaver
 {
@@ -60,7 +61,12 @@
     virtual void onHandleActiveIndicators(const QList<HbIndicatorInterface*> &activeIndicators);
     virtual void onHandleActivatedIndicator(HbIndicatorInterface *activatedIndicator);
     virtual void onHandleDeactivatedIndicator(HbIndicatorInterface *deactivatedIndicator);
+    virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow);
+    virtual void updateLayout();
 
+private slots:
+
+    void updateActiveAreaForLowPower();
 
 private:
 
@@ -68,7 +74,8 @@
     HbMainWindow *mMainWindow;
     SnsrBigClockContainer *mCurrentContainer;
     SnsrIndicatorModel *mIndicatorModel;
-    
+    XQSettingsManager *m_setManager;
+
     SCREENSAVER_TEST_FRIEND_CLASS(T_SnsrBigClockScreensaverPlugin)
 
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrblankcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Container for blank screen.
+*
+*/
+
+#ifndef SNSRBLANKCONTAINER_H
+#define SNSRBLANKCONTAINER_H
+
+#include "snsrbigclockcontainer.h"
+
+//SCREENSAVER_TEST_CLASS(T_SnsrBigClockScreensaverPlugin)
+
+class SnsrBlankContainer : public SnsrBigClockContainer
+{
+    Q_OBJECT
+
+public:
+
+    SnsrBlankContainer();
+    ~SnsrBlankContainer();
+
+public slots:
+
+    virtual void update();
+
+public: // from base classes
+
+    virtual int updateIntervalInMilliseconds();
+
+protected: // from base classes
+
+    virtual void loadWidgets();
+
+private:
+
+//    SCREENSAVER_TEST_FRIEND_CLASS(T_SnsrBigClockScreensaverPlugin)
+};
+
+#endif // SNSRBLANKCONTAINER_H
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrdigitalclockcontainer.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsrdigitalclockcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -22,7 +22,7 @@
 
 SCREENSAVER_TEST_CLASS(T_SnsrBigClockScreensaverPlugin)
 
-class HbLabel;
+class SnsrLabel;
 class SnsrSwipeWidget;
 
 class SnsrDigitalClockContainer : public SnsrBigClockContainer
@@ -37,17 +37,20 @@
 public slots:
 
     virtual void update();
-    virtual void changeLayout(Qt::Orientation orientation);
 
 public: // from base classes
 
     virtual int updateIntervalInMilliseconds();
 
+protected: // from base classes
+
+    virtual void loadWidgets();
+
 private: // data
 
-    HbLabel *mTimeLabel;
-    HbLabel *mAmPmLabel;
-    HbLabel *mDateLabel;
+    SnsrLabel *mTimeLabel;
+    SnsrLabel *mAmPmLabel;
+    SnsrLabel *mDateLabel;
     SnsrSwipeWidget *mSwipeWidget;
 
     SCREENSAVER_TEST_FRIEND_CLASS(T_SnsrBigClockScreensaverPlugin)
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroledanalogclockcontainer.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroledanalogclockcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -23,7 +23,7 @@
 SCREENSAVER_TEST_CLASS(T_SnsrBigClockScreensaverPlugin)
 
 class SnsrOledClockWidget;
-class HbLabel;
+class SnsrLabel;
 
 class SnsrOledAnalogClockContainer : public SnsrBigClockContainer
 {
@@ -37,19 +37,24 @@
 public slots:
 
     virtual void update();
-    virtual void changeLayout(Qt::Orientation orientation);
     void updatePosition();
 
 public: // from base classes
 
     virtual int updateIntervalInMilliseconds();
+    virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow);
+    virtual bool isOrientationLocked();
+
+protected: // from base classes
+
+    virtual void loadWidgets();
 
 private:
 
     QGraphicsWidget *mClockContainer;
     
     SnsrOledClockWidget *mOledClockWidget;
-    HbLabel *mDateLabel;
+    SnsrLabel *mDateLabel;
     
     QPointF mDestPosition;
     bool mInitialize;
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroleddigitalclockcontainer.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/inc/snsroleddigitalclockcontainer.h	Fri Jul 23 13:47:57 2010 +0300
@@ -20,9 +20,11 @@
 
 #include "snsrbigclockcontainer.h"
 
+
 SCREENSAVER_TEST_CLASS(T_SnsrBigClockScreensaverPlugin)
 
-class HbLabel;
+class SnsrLabel;
+class SnsrOledTimeLabel;
 
 class SnsrOledDigitalClockContainer : public SnsrBigClockContainer
 {
@@ -36,21 +38,26 @@
 public slots:
 
     virtual void update();
-    virtual void changeLayout(Qt::Orientation orientation);
     void updatePosition();
 
 public: // from base classes
 
     virtual int updateIntervalInMilliseconds();
+    virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow);
+    virtual bool isOrientationLocked();
+    
+protected: // from base classes
+
+    virtual void loadWidgets();
 
 private:
 
     QGraphicsWidget *mClockContainer;
 
-    HbLabel *mTimeLabel;
-    HbLabel *mDateLabel;
-    HbLabel *mAmPmLabel;
-
+    SnsrLabel *mAmPmLabel;
+    SnsrOledTimeLabel *mTimeLabel;
+    SnsrLabel *mDateLabel;
+    
     QPointF mDestPosition;
     bool mInitialize;
 
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveranalog.docml	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveranalog.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -10,16 +10,16 @@
             </widget>
             <widget name="indicatorWidget" type="SnsrIndicatorWidget">
                 <sizehint height="2.5un" type="PREFERRED"/>
-                <sizehint width="0" type="MINIMUM"/>
+                <sizehint width="2.5un" type="MINIMUM"/>
                 <sizepolicy horizontalPolicy="Expanding" verticalPolicy="Preferred"/>
                 <real name="z" value="2"/>
             </widget>
             <widget name="dateLabel" type="SnsrLabel">
                 <real name="z" value="3"/>
                 <sizepolicy horizontalPolicy="Expanding" verticalPolicy="Preferred"/>
-                <sizehint height="5.8209un" type="PREFERRED"/>
-                <sizehint width="0un" type="MINIMUM"/>
-                <fontspec name="fontSpec" role="Secondary" textheight="30"/>
+                <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED"/>
+                <sizehint width="1.0un" type="MINIMUM"/>
+                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
                 <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
             </widget>
             <layout type="anchor">
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaverdigital.docml	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaverdigital.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -3,9 +3,9 @@
     <widget name="view" type="HbView">
         <widget name="mainContainer" role="HbView:widget" type="HbWidget">
             <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
-            <contentsmargins bottom="var(hb-param-margin-gene-screen)" left="var(hb-param-margin-gene-screen)" right="var(hb-param-margin-gene-screen)" top="var(hb-param-margin-gene-screen)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
             <widget name="amPmLabel" type="SnsrLabel">
-                <sizehint type="MINIMUM" width="0"/>
+                <sizehint type="MINIMUM" width="1.0un"/>
                 <sizehint height="var(hb-param-text-height-primary)" type="PREFERRED"/>
                 <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <real name="z" value="1"/>
@@ -13,7 +13,7 @@
                 <string name="alignment" value="AlignVCenter|AlignLeft"/>
              </widget>
             <widget name="timeLabel" type="SnsrLabel">
-                <sizehint type="MINIMUM" width="0un"/>
+                <sizehint type="MINIMUM" width="1.0un"/>
                 <sizehint height="14.7un" type="PREFERRED"/>
                 <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <real name="z" value="2"/>
@@ -21,13 +21,13 @@
                 <string name="alignment" value="AlignVCenter|AlignHCenter"/>
              </widget>
              <widget name="indicatorWidget" type="SnsrIndicatorWidget">
-                <sizehint type="MINIMUM" width="0"/>
+                <sizehint type="MINIMUM" width="2.5un"/>
                 <sizehint height="2.5un" type="PREFERRED"/>
                 <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <real name="z" value="3"/>
               </widget>
               <widget name="dateLabel" type="SnsrLabel">
-                <sizehint type="MINIMUM" width="0"/>
+                <sizehint type="MINIMUM" width="1.0un"/>
                 <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED"/>
                 <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <real name="z" value="4"/>
@@ -35,7 +35,7 @@
                 <string name="alignment" value="AlignVCenter|AlignHCenter"/>
              </widget>
              <layout type="anchor">
-                <anchoritem dst="amPmLabel" dstEdge="BOTTOM" spacing="1.0un" src="timeLabel" srcEdge="TOP"/>
+                <anchoritem dst="amPmLabel" dstEdge="BOTTOM" spacing="-0.5un" src="timeLabel" srcEdge="TOP"/>
                 <anchoritem dst="amPmLabel" dstEdge="LEFT" spacing="0" src="timeLabel" srcEdge="LEFT"/>
                 <anchoritem dst="timeLabel" dstEdge="TOP" spacing="26.4un" src="" srcEdge="TOP"/>
                 <anchoritem dst="timeLabel" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
@@ -45,12 +45,14 @@
                 <anchoritem dst="dateLabel" dstEdge="CENTERH" spacing="0" src="timeLabel" srcEdge="CENTERH"/>
             </layout>
         </widget>
-        <string name="title" value=""/>
+        <string name="title" value="View"/>
     </widget>
     <section name="landscape">
-        <widget name="mainContainer" type="HbWidget">
+        <widget name="mainContainer" role="HbView:widget" type="HbWidget">
+            <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
             <layout type="anchor">
-                <anchoritem dst="amPmLabel" dstEdge="BOTTOM" spacing="1.0un" src="timeLabel" srcEdge="TOP"/>
+                <anchoritem dst="amPmLabel" dstEdge="BOTTOM" spacing="-0.5un" src="timeLabel" srcEdge="TOP"/>
                 <anchoritem dst="amPmLabel" dstEdge="LEFT" spacing="0" src="timeLabel" srcEdge="LEFT"/>
                 <anchoritem dst="timeLabel" dstEdge="TOP" spacing="17.3un" src="" srcEdge="TOP"/>
                 <anchoritem dst="timeLabel" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroledanalog.docml	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroledanalog.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -2,15 +2,17 @@
 <hbdocument version="0.9">
     <widget name="view" type="HbView">
         <widget name="mainContainer" role="HbView:widget" type="HbWidget">
+            <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
             <widget name="clockContainer" type="HbWidget">
-                <sizehint height="49.5un" type="PREFERRED" width="45un"/>
+                <sizehint height="expr( 32.8un + 2.5un + var(hb-param-text-height-tiny) + var(hb-param-margin-gene-top) + var(hb-param-margin-gene-bottom) + var(hb-param-margin-gene-bottom) + var(hb-param-margin-gene-top) )" type="PREFERRED" width="45un"/>
                 <widget name="oledAnalogClockWidget" type="SnsrOledClockWidget">
                     <real name="z" value="1"/>
                     <sizehint height="32.8un" type="PREFERRED" width="32.8un"/>
                 </widget>
                 <widget name="indicatorWidget" type="SnsrIndicatorWidget">
                     <sizehint height="2.5un" type="PREFERRED"/>
-                    <sizehint width="0" type="MINIMUM"/>
+                    <sizehint width="2.5un" type="MINIMUM"/>
                     <sizepolicy horizontalPolicy="Expanding" verticalPolicy="Preferred"/>
                     <real name="z" value="2"/>
                 </widget>
@@ -18,7 +20,7 @@
                     <real name="z" value="3"/>
                     <sizepolicy horizontalPolicy="Expanding" verticalPolicy="Preferred"/>
                     <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED"/>
-                    <sizehint width="0un" type="MINIMUM"/>
+                    <sizehint width="1.0un" type="MINIMUM"/>
                     <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                 </widget>
@@ -33,14 +35,22 @@
             </widget>
             <layout type="anchor">
                 <anchoritem dst="clockContainer" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
-                <anchoritem dst="clockContainer" dstEdge="CENTERV" spacing="0" src="" srcEdge="CENTERV"/>
+                <anchoritem dst="clockContainer" dstEdge="TOP" spacing="22un" src="" srcEdge="TOP"/>
             </layout>
         </widget>
         <string name="title" value="View"/>
     </widget>
     <section name="landscape">
+        <widget name="mainContainer" role="HbView:widget" type="HbWidget">
+            <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
+            <layout type="anchor">
+                <anchoritem dst="clockContainer" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
+                <anchoritem dst="clockContainer" dstEdge="TOP" spacing="3.3un" src="" srcEdge="TOP"/>
+            </layout>
+        </widget>
     </section>
-    <metadata activeUIState="landscape" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <uistate name="landscape" sections="#common landscape"/>
     </metadata>
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroleddigital.docml	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/resource/snsrbigclockscreensaveroleddigital.docml	Fri Jul 23 13:47:57 2010 +0300
@@ -2,18 +2,21 @@
 <hbdocument version="0.9">
     <widget name="view" type="HbView">
         <widget name="mainContainer" role="HbView:widget" type="HbWidget">
-        <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
             <widget name="clockContainer" type="HbWidget">
+                <sizehint height="expr(var(hb-param-text-height-primary)+(0.5un)+(14.7un)+var(hb-param-margin-gene-top)+(2.5un)+var(hb-param-margin-gene-bottom)+var(hb-param-text-height-tiny) + var(hb-param-margin-gene-bottom) + var(hb-param-margin-gene-top) )" type="PREFERRED" width="45un"/>
+                <real name="z" value="1"/>
                 <widget name="amPmLabel" type="SnsrLabel">
-                    <sizehint type="MINIMUM" width="0"/>
+                    <sizehint type="MINIMUM" width="1.0un"/>
                     <sizehint height="var(hb-param-text-height-primary)" type="PREFERRED"/>
                     <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                     <real name="z" value="1"/>
                     <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
                     <string name="alignment" value="AlignVCenter|AlignLeft"/>
                 </widget>
-                <widget name="timeLabel" type="SnsrLabel">
-                    <sizehint type="MINIMUM" width="0un"/>
+                <widget name="oledTimeLabel" type="SnsrOledTimeLabel">
+                    <sizehint type="MINIMUM" width="1.0un"/>
                     <sizehint height="14.7un" type="PREFERRED"/>
                     <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                     <real name="z" value="2"/>
@@ -21,40 +24,47 @@
                     <string name="alignment" value="AlignVCenter|AlignHCenter"/>
                 </widget>
                 <widget name="indicatorWidget" type="SnsrIndicatorWidget">
-                    <sizehint type="MINIMUM" width="0"/>
+                    <sizehint type="MINIMUM" width="2.5un"/>
                     <sizehint height="2.5un" type="PREFERRED"/>
                     <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                     <real name="z" value="3"/>
                 </widget>
                 <widget name="dateLabel" type="SnsrLabel">
-                    <sizehint type="MINIMUM" width="0"/>
+                    <sizehint type="MINIMUM" width="1.0un"/>
                     <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED"/>
                     <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                     <real name="z" value="4"/>
                     <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
                     <string name="alignment" value="AlignVCenter|AlignHCenter"/>
                 </widget>
-                <sizehint height="expr(var(hb-param-text-height-primary)+(1.0un)+(14.7un)+var(hb-param-margin-gene-top)+(2.5un)+var(hb-param-margin-gene-bottom)+var(hb-param-text-height-tiny))" type="PREFERRED" width="45un"/>
-                <real name="z" value="1"/>
                 <layout type="anchor">
                     <anchoritem dst="amPmLabel" dstEdge="TOP" spacing="0" src="" srcEdge="TOP"/>
-                    <anchoritem dst="amPmLabel" dstEdge="LEFT" spacing="0" src="timeLabel" srcEdge="LEFT"/>
-                    <anchoritem dst="timeLabel" dstEdge="TOP" spacing="1.0un" src="amPmLabel" srcEdge="BOTTOM"/>
-                    <anchoritem dst="timeLabel" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
-                    <anchoritem dst="indicatorWidget" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="timeLabel" srcEdge="BOTTOM"/>
-                    <anchoritem dst="indicatorWidget" dstEdge="CENTERH" spacing="0" src="timeLabel" srcEdge="CENTERH"/>
+                    <anchoritem dst="amPmLabel" dstEdge="LEFT" spacing="0" src="oledTimeLabel" srcEdge="LEFT"/>
+                    <anchoritem dst="oledTimeLabel" dstEdge="TOP" spacing="0.5un" src="amPmLabel" srcEdge="BOTTOM"/>
+                    <anchoritem dst="oledTimeLabel" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>      
+                    <anchoritem dst="indicatorWidget" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="oledTimeLabel" srcEdge="BOTTOM"/>
+                    <anchoritem dst="indicatorWidget" dstEdge="CENTERH" spacing="0" src="oledTimeLabel" srcEdge="CENTERH"/>
                     <anchoritem dst="dateLabel" dstEdge="TOP" spacing="var(hb-param-margin-gene-bottom)" src="indicatorWidget" srcEdge="BOTTOM"/>
-                    <anchoritem dst="dateLabel" dstEdge="CENTERH" spacing="0" src="timeLabel" srcEdge="CENTERH"/>
+                    <anchoritem dst="dateLabel" dstEdge="CENTERH" spacing="0" src="oledTimeLabel" srcEdge="CENTERH"/>
                 </layout>
             </widget>
             <layout type="anchor">
-                <anchoritem dst="clockContainer" dstEdge="TOP" spacing="1un" src="" srcEdge="TOP"/>
+                <anchoritem dst="clockContainer" dstEdge="TOP" spacing="expr((26.4un)-var(hb-param-text-height-primary)-(0.5un))" src="" srcEdge="TOP"/>
                 <anchoritem dst="clockContainer" dstEdge="CENTERH" spacing="0un" src="" srcEdge="CENTERH"/>
             </layout>
         </widget>
-        <string name="title" value=""/>
+        <string name="title" value="View"/>
     </widget>
-    <section name="landscape"/>
+    <section name="landscape">
+        <widget name="mainContainer" role="HbView:widget" type="HbWidget">
+            <sizehint height="var(hb-param-screen-height)" type="PREFERRED" width="var(hb-param-screen-width)"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-bottom)" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="var(hb-param-margin-gene-top)"/>
+            <layout type="anchor">
+                <anchoritem dst="clockContainer" dstEdge="CENTERH" spacing="0" src="" srcEdge="CENTERH"/>
+                <anchoritem dst="clockContainer" dstEdge="TOP" spacing="expr((17.3un)-var(hb-param-text-height-primary)-(0.5un))" src="" srcEdge="TOP"/>
+            </layout>
+        </widget>
+    </section>
     <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <uistate name="landscape" sections="#common landscape"/>
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsranalogclockwidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsranalogclockwidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsroledclockwidget.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsroledclockwidget.h	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -53,6 +53,9 @@
     HbIconItem *mClockHourHand;
     HbIconItem *mClockMinuteHand;
     // TODO: not known yet what label (or any) is shown in clock face (day or am/pm or none)
+    // If some label will be put onto the clock face, then it's color must come
+    // from theme and is most propably different than SnsrLabel uses (=text/icon color
+    // used in screensaver in general
     //HbIconItem *mClockDateFrame;
     //SnsrLabel *mClockDateLabel;
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/inc/snsroledtimelabel.h	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Time label for oled digital clock.
+*
+*/
+
+#ifndef SNSROLEDTIMELABEL_H
+#define SNSROLEDTIMELABEL_H
+
+#include <HbTextItem>
+#include "snsrtest_global.h"
+
+SCREENSAVER_TEST_CLASS(T_SnsrClockWidgets)
+
+class SnsrOledTimeLabel : public HbTextItem
+{
+    Q_OBJECT
+
+    Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+    
+public:
+    
+    SnsrOledTimeLabel(QGraphicsItem *parent = 0);
+    ~SnsrOledTimeLabel();
+    
+    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+protected:
+    
+    virtual void changeEvent(QEvent *event);
+
+private:
+
+    void setThemedTextColor();
+    
+private:
+        
+    Q_DISABLE_COPY(SnsrOledTimeLabel)
+    SCREENSAVER_TEST_FRIEND_CLASS(T_SnsrClockWidgets)
+};
+    
+#endif //  SNSROLEDTIMELABEL_H
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsranalogclockwidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsranalogclockwidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledclockwidget.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledclockwidget.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -131,9 +131,12 @@
     Q_ASSERT( mClockHourHand && mClockMinuteHand /*&& mClockDateLabel */);
     
     // Calculate angles for clock hands.
+    // Use granularity of one minute so that minute hand is always exactly
+    // on some minute and not between minutes. OLED clock is not updated more
+    // frequently than once per minute and using finer granularity would cause
+    // the minute hand to be always between even minutes.
     QTime time = QTime::currentTime();
-    qreal s = 6 * time.second();
-    qreal m = 6 * (time.minute() + s/360);
+    qreal m = 6 * time.minute();
     qreal h = 30 * ((time.hour() % 12) + m/360);
     
     int x = mClockHourHand->preferredSize().width()/2;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrclockwidgets/src/snsroledtimelabel.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Time label for oled digital clock.
+*
+*/
+
+#include "snsroledtimelabel.h"
+
+#include <hbevent.h>
+#include <hbcolorscheme.h>
+#include <QPainter>
+
+
+const QString snsrForegroundColorRole("snsrforeground");
+
+/*!
+    \class SnsrOledTimeLabel
+    \ingroup group_snsrbigclockscreensaverprovider
+    \brief Screensaver oled digital clock's time label
+ */
+
+/*!
+    Constructs a new SnsrOledTimeLabel.
+    \param parent Parent object.
+ */
+
+SnsrOledTimeLabel::SnsrOledTimeLabel(QGraphicsItem *parent)
+    : HbTextItem(parent)
+{
+    setThemedTextColor();
+    
+    setMinimumLines( 1 );
+    setMaximumLines( 1 );
+    setAlignment(Qt::AlignCenter);
+    
+    // as we do own painting, must disable the flag that is enabled
+    // by default due to performance optimatizations.
+    setFlag(QGraphicsItem::ItemHasNoContents,false);
+}
+
+SnsrOledTimeLabel::~SnsrOledTimeLabel()
+{
+}
+
+/*!
+    \reimp
+    We want to draw only the outlines of the time label text and thus
+    text is drawn here with QPainterPath and pen (no brush) which seems to be the
+    only way to accomplish this. 
+    Base class's Paint method must not be called!
+    We use base class only to get the bounding rect inside which to draw the text
+    (boundingRect has been adjusted to current text, font, alignment etc.)
+ */
+void SnsrOledTimeLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+    
+    // TODO: changes needed for mirrored layout and/or other than latin digits??
+    
+    painter->save();   //saves the painter state.
+    
+    QPainterPath path;
+    
+    QRectF boundingRect = this->boundingRect();   
+    QString timeText = this->text();
+    QFont font = this->font();
+
+    // As painterPath takes the left end of the text's baseline as 
+    // a parameter we must calculate that point from boundingRect's bottom left 
+    // so that font's descent (and baseline (=1)) are taken into account. 
+    // We want to center the text horizontally too. The logic
+    // is basically the same as used inside the base class for drawing the text
+    // within boundingRect.
+    QPointF leftEndOfBaseline(0,0);  // for painterPath
+    QFontMetrics fontMetrics(font);
+    int descent = fontMetrics.descent();
+    int width = fontMetrics.width(timeText);   
+    leftEndOfBaseline.setY(boundingRect.bottomLeft().y() - descent -1);
+    leftEndOfBaseline.setX((boundingRect.width() - width) / 2 ); // centerH
+    
+    path.addText(leftEndOfBaseline, font, timeText);  
+    
+    painter->setFont(font);
+
+    QPen newPen = painter->pen();
+    newPen.setWidth( 1 ); // TODO: is this width ok?
+    newPen.setColor(this->textColor());
+    painter->setPen(newPen);
+    
+    painter->setBrush(QBrush(Qt::NoBrush));
+
+  //  painter->setLayoutDirection ( layoutDirection() ); // TODO: needed or not?
+    
+    painter->setRenderHint(QPainter::Antialiasing, true); // TODO: use or not?
+    
+    painter->drawPath(path);
+    
+    // Must restore the painter or the whole UI will be messed up!
+    painter->restore();
+
+}
+
+/*!
+    \reimp
+ */
+void SnsrOledTimeLabel::changeEvent(QEvent * event)
+{
+    if (event->type() == HbEvent::ThemeChanged) {
+        setThemedTextColor();
+    }
+    return HbTextItem::changeEvent(event);
+}
+
+
+/*!
+    Sets the time label's color to follow the theme.
+ */
+void SnsrOledTimeLabel::setThemedTextColor()
+{
+    QColor textColor(HbColorScheme::color(snsrForegroundColorRole));
+    if (textColor.isValid()) {
+        setTextColor(textColor);
+    } else {
+        // fallback mechanism when color definition is missing in default theme
+        setTextColor(Qt::white);
+    }
+}
+
+
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/inc/snsrindicatormodel.h	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/inc/snsrindicatormodel.h	Fri Jul 23 13:47:57 2010 +0300
@@ -42,6 +42,8 @@
     void handleActivatedIndicator(HbIndicatorInterface *activatedIndicator);
     void handleDeactivatedIndicator(HbIndicatorInterface *deactivatedIndicator);
     
+    void handleUpdatedIndicator();
+    
     void initializeIndicatorWidget();
 
     /*
@@ -53,15 +55,18 @@
 
     void indicatorsUpdated(const QList<SnsrIndicatorInfo> &activeIndicators);
     void allIndicatorsDeactivated();
-   
+
 private:
 
-    void addIndicator(const SnsrIndicatorInfo &indicatorInfo);
-
+    bool addIndicator(const SnsrIndicatorInfo &indicatorInfo);
+    bool isIndicatorAlreadyAdded(const SnsrIndicatorInfo &indicatorInfo) const;
+    
     bool findAndRemoveIndicator(const SnsrIndicatorInfo &indicatorInfo);
-    
+   
     bool showIndicatorInScreensaver(const HbIndicatorInterface &indicatorInterface,
                                     SnsrIndicatorInfo &indicatorInfo);
+    
+    void connectToIndicatorsUpdateSignal(const HbIndicatorInterface &indicatorInterface);
 
     bool anyActiveIndicators() const;
     
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/resource/snsrindicatorwidget.widgetml	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/resource/snsrindicatorwidget.widgetml	Fri Jul 23 13:47:57 2010 +0300
@@ -1,16 +1,16 @@
 <hbwidget version="0.1">
   <layout name="indicatorlayout" type="mesh">
-    <meshitem src="icon1" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon1" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon1" srcEdge="LEFT" dst="" dstEdge="LEFT" />   
-    <meshitem src="icon2" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon2" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon2" srcEdge="LEFT" dst="icon1" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" />   
-    <meshitem src="icon3" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon3" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon3" srcEdge="LEFT" dst="icon2" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" />   
-    <meshitem src="icon4" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon4" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon4" srcEdge="LEFT" dst="icon3" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" />   
-    <meshitem src="icon5" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon5" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon5" srcEdge="LEFT" dst="icon4" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" />
-    <meshitem src="icon6" srcEdge="TOP" dst="" dstEdge="TOP" />
+    <meshitem src="icon6" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
     <meshitem src="icon6" srcEdge="LEFT" dst="icon5" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" />
   </layout>  
 </hbwidget>
\ No newline at end of file
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/src/snsrindicatormodel.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/snsrindicatorwidget/src/snsrindicatormodel.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -29,10 +29,10 @@
     \brief Model for handling indicator data.
  */
 
-// TODO: what is the type string of silent indicator? couldn't
+// TODO: what is the final type string of silent indicator? couldn't
 // find it in wk22 -> workaround solution: assume that it contains
-// substring "silent"
-const char *gSilentIndicatorTypeString = "silent";
+// substring "silence" like in their demo app.
+const char *gSilentIndicatorTypeString = "silence";
 const char *gOfflineIndicatorTypeString = "offline";
 
 
@@ -80,6 +80,7 @@
         if (activatedIndicator 
             && showIndicatorInScreensaver(*activatedIndicator,indicatorInfo)) {
             addIndicator(indicatorInfo);
+            connectToIndicatorsUpdateSignal(*activatedIndicator);
             addedAny = true;
         }
     }
@@ -89,12 +90,6 @@
     if (addedAny) {
         emitChangeSignal();
     }
-    
-    // TODO: no we need to listen to update signals?
-    // used for changing icon?
-    /* //connect indicator's update signal
-     QObject::connect(activatedIndicator, SIGNAL(dataChanged()),
-                      this, SLOT(indicatorUpdated()));*/
 }
 
 /*!
@@ -107,8 +102,10 @@
     SnsrIndicatorInfo indicatorInfo;
     if (activatedIndicator
         && showIndicatorInScreensaver(*activatedIndicator,indicatorInfo)) {
-        addIndicator(indicatorInfo);
-        emitChangeSignal();
+        if (addIndicator(indicatorInfo)) {
+            connectToIndicatorsUpdateSignal(*activatedIndicator);
+            emitChangeSignal();
+        }
     }
 }
 
@@ -132,6 +129,35 @@
 }
 
 /*!
+    Called when some universal indicator updates its data by
+    emitting dataChanged signal. 
+    We listen to this signal because at least the silent indicator plugin demo 
+    uses this method to inform the clients when it gets deactivated/activated 
+    once it has been activated once by setting its icon path to empty/valid string.
+    Don't know if this is going to be the final solution as it's unconventional (?) 
+    but let's be prepared also to this kind of approach. 
+ */
+void SnsrIndicatorModel::handleUpdatedIndicator()
+{
+    HbIndicatorInterface* indicator =
+        qobject_cast<HbIndicatorInterface*>(sender());
+    if (!indicator) {
+        return;
+    }
+    
+    // If indicator's icon path was set to empty string, then treat it
+    // like it were deactivated. And if not empty, then it's active again.
+    if (indicator->indicatorData(
+            HbIndicatorInterface::MonoDecorationNameRole).toString().isEmpty()) {
+        handleDeactivatedIndicator(indicator);
+    }
+    else {
+        handleActivatedIndicator(indicator);
+    }
+    
+}
+
+/*!
     Sends a signal with a list of all currently active indicators.
     No signal is sent if there are no active indicators currently.
  */
@@ -175,24 +201,50 @@
     Add the indicator into this model. Handle here the order in which
     indicators are shown in screensaver: notification indicators should be
     shown in the same order as shown in statusbar, that is in reversed
-    chronological order. Silent indicator should always be the right-most.
+    chronological order. Silent indicator should always be the right-most one.
+    /retval true if indicator was added (not found already in the listings)
  */
-void SnsrIndicatorModel::addIndicator(const SnsrIndicatorInfo &indicatorInfo)
+bool SnsrIndicatorModel::addIndicator(const SnsrIndicatorInfo &indicatorInfo)
 {
-    // info from pattern library - todo: remove
-    //Indicators are displayed inside of each group in reversed chronological order 
-    // according to the arrival time; the indicator that appeared most recently is placed on top of the group.
+    // To be on the safe side, check that the indicator doesn't already
+    // exists in the active indicator listings.
+    bool added(false);
+    
+    // Use prepend to keep the list in reversed chronological order
+    if (indicatorInfo.category == HbIndicatorInterface::NotificationCategory
+        && !isIndicatorAlreadyAdded(indicatorInfo)) {
+        mNotificationIndicators.prepend(indicatorInfo);
+        added = true;
+    }
+    else if (indicatorInfo.category == HbIndicatorInterface::SettingCategory
+             && !isIndicatorAlreadyAdded(indicatorInfo)) {
+        mSettingIndicators.append(indicatorInfo);
+        added = true;
+    }
+    
+    return added;
+}
 
-    //Status bar indicators follow the same order; the most recent notification indicator (4) is on the left 
-    // and similarly the most recent settings indicator (5) is on the right.
-
-    // use prepend to keep the list in reversed chronological order
-    if (indicatorInfo.category == HbIndicatorInterface::NotificationCategory) {
-        mNotificationIndicators.prepend(indicatorInfo);
+/*!
+    Check whether the indicator is already added in the active 
+    indicator listing.
+    /retval true if indicator is already added; false if not.
+ */
+bool SnsrIndicatorModel::isIndicatorAlreadyAdded(const SnsrIndicatorInfo &indicatorInfo) const
+{
+    bool alreadyExits(false);
+    
+    const QList<SnsrIndicatorInfo> &indicatorList = 
+        indicatorInfo.category == HbIndicatorInterface::NotificationCategory 
+        ? mNotificationIndicators : mSettingIndicators;
+    
+    for (int i = 0; i < indicatorList.size(); ++i) {
+        if (indicatorList.at(i).type == indicatorInfo.type) {
+            alreadyExits = true;
+            break;
+        }
     }
-    else {
-        mSettingIndicators.append(indicatorInfo);
-    }
+    return alreadyExits;
 }
 
 /*!
@@ -254,7 +306,7 @@
              && !iconPath.isEmpty()
              // TODO: what is the type string of silent indicator? couldn't
              // find it in wk22 -> workaround solution: assume that it contains
-             // substring "silent"
+             // substring "silence" like in their demo app.
              // && type == gSilentIndicatorTypeString ) { 
              && typeString.contains(gSilentIndicatorTypeString, Qt::CaseInsensitive)) {  
         show = true;
@@ -272,6 +324,27 @@
 }
 
 /*!
+   Start listening to indicator's dataChanged signals.
+   /parameter indicator whose dataChanged signal we want to listen
+ */
+void SnsrIndicatorModel::connectToIndicatorsUpdateSignal(const HbIndicatorInterface &indicatorInterface)
+{
+    // Connect to silent indicator's dataChanged signal as it seems to 
+    // use unconventional method (demo at least) to inform when
+    // it's get deactivated/activated: dataChanged signal is emitted and
+    // icon path is set to empty string/valid string.
+    // It's assumed that we don't need to listen to other indicators
+    // as we are not interested e.g. when primary/secondary texts change etc.
+    
+    // NOTE: do NOT disconnect the indicator signal anywhere explicitly here
+    // or we won't get activation/deactivation messages.
+    if (indicatorInterface.indicatorType().contains(gSilentIndicatorTypeString, Qt::CaseInsensitive)) {
+        QObject::connect( &indicatorInterface, SIGNAL(dataChanged()),
+                          this, SLOT(handleUpdatedIndicator()));
+    }
+}
+
+/*!
    Check whether there is any active indicator currently.
    /retval true if there is at least one indicator to show
  */
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsranalogclockcontainer.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsranalogclockcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -21,12 +21,13 @@
 #include <QTime>
 #include <QGraphicsLinearLayout>
 
-#include <hblabel.h>
-#include <hbextendedlocale.h>
+#include <HbExtendedLocale>
+#include <HbMainWindow>
 
 #include "snsranalogclockwidget.h"
 #include "snsrindicatorwidget.h"
 #include "snsrswipewidget.h"
+#include "snsrlabel.h"
 
 /*!
     \class SnsrAnalogClockContainer
@@ -61,41 +62,8 @@
     mDateLabel(0),
     mAnalogClockWidget(0)/*,
     mSwipeWidget(0)*/
-    {
+{
     SCREENSAVER_TEST_FUNC_ENTRY("SnsrAnalogClockContainer::SnsrAnalogClockContainer")
-
-    bool ok(true);
-
-    // load analog clock
-    qDebug() << gAnalogLayoutDocml;
-    mDocumentObjects = mDocumentLoader.load(gAnalogLayoutDocml, &ok);
-    Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid DocML file.");
-    if (ok) {
-        mMainView = mDocumentLoader.findWidget(gMainViewName);
-        mDateLabel = qobject_cast<HbLabel *>(
-            mDocumentLoader.findWidget(gDateLabelName));
-        mAnalogClockWidget = qobject_cast<SnsrAnalogClockWidget *>(
-            mDocumentLoader.findWidget(gAnalogClockWidgetName));
-        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
-            mDocumentLoader.findWidget(gIndicatorWidgetName));
-        //We don't implement swipe widget at this poin
-        /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>(
-            mDocumentLoader.findWidget(gSwipeWidgetName));*/
-        
-        Q_ASSERT_X(
-                mMainView && mDateLabel && mAnalogClockWidget &&
-                mIndicatorWidget /*&& mSwipeWidget*/,
-                gAnalogLayoutDocml, "Objects not found in DocML file."
-                );
-        
-        //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) );
-
-        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
-        
-        mBackgroundContainerLayout->addItem(mMainView);
- //       mSwipeWidget->start();
-    }
-
     SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::SnsrAnalogClockContainer")
 }
 
@@ -104,6 +72,7 @@
  */
 SnsrAnalogClockContainer::~SnsrAnalogClockContainer()
 {
+    resetIndicatorConnections();
     //mDateLabel, mAnalogClockWidget - deleted by the parent
 }
 
@@ -131,43 +100,57 @@
     SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::update")
 }
 
-/*!
-    Changes screensaver layout basing on orientation changes.
-    \param orientation Current orientation.
- */
-void SnsrAnalogClockContainer::changeLayout(Qt::Orientation orientation)
-{
-    SCREENSAVER_TEST_FUNC_ENTRY("SnsrAnalogClockContainer::changeLayout")
-
-    bool ok(false);
-    if (mCurrentOrientation != orientation) {
-        mCurrentOrientation = orientation;
-
-        // hide controls to avoid screen flickering
-        mMainView->hide();
-
-        QString sectionToLoad("");
-        if (mCurrentOrientation == Qt::Horizontal) {
-            sectionToLoad = gLandscapeSectionName;
-        }
-        qDebug() << "loading: " << gAnalogLayoutDocml << ", section: " << sectionToLoad;
-        mDocumentLoader.load(gAnalogLayoutDocml, sectionToLoad, &ok);
-        // view is rebuilt and ready to show
-        update();
-        mMainView->show();
-        Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid section in DocML file.");
-    }
-    // update anyway - this is needed in situations when screensaver goes to
-    // foreground but layout change did not occur
-    if (!ok) {
-        update();
-    }
-
-    SCREENSAVER_TEST_FUNC_EXIT("SnsrAnalogClockContainer::changeLayout")
-}
-
 int SnsrAnalogClockContainer::updateIntervalInMilliseconds()
 {
     return 1000;
 }
 
+void SnsrAnalogClockContainer::loadWidgets()
+{
+    bool ok(true);
+
+    // reset widget pointers, any previous widgets are already deleted by now
+    mMainView = 0;
+    mDateLabel = 0;
+    mAnalogClockWidget = 0;
+    mIndicatorWidget = 0;
+    
+    // load widgets from docml
+    qDebug() << gAnalogLayoutDocml;
+    mDocumentObjects = mDocumentLoader.load(gAnalogLayoutDocml, &ok);
+    Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid DocML file.");
+    if (ok) {
+        mMainView = mDocumentLoader.findWidget(gMainViewName);
+        mDateLabel = qobject_cast<SnsrLabel *>(
+            mDocumentLoader.findWidget(gDateLabelName));
+        mAnalogClockWidget = qobject_cast<SnsrAnalogClockWidget *>(
+            mDocumentLoader.findWidget(gAnalogClockWidgetName));
+        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
+            mDocumentLoader.findWidget(gIndicatorWidgetName));
+        //We don't implement swipe widget at this poin
+        /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>(
+            mDocumentLoader.findWidget(gSwipeWidgetName));*/
+        
+        Q_ASSERT_X(
+                mMainView && mDateLabel && mAnalogClockWidget &&
+                mIndicatorWidget /*&& mSwipeWidget*/,
+                gAnalogLayoutDocml, "Objects not found in DocML file."
+                );
+        
+        // In case of landscape layout, read also the landscape delta section
+        if ( mCurrentOrientation == Qt::Horizontal ) {
+            qDebug() << "loading: " << gAnalogLayoutDocml << ", section: " << gLandscapeSectionName;
+            mDocumentLoader.load(gAnalogLayoutDocml, gLandscapeSectionName, &ok);
+            Q_ASSERT_X(ok, gAnalogLayoutDocml, "Invalid section in DocML file.");
+        }
+
+        initIndicatorWidget();
+        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
+        
+        mBackgroundContainerLayout->addItem(mMainView);
+
+        //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) );
+        //mSwipeWidget->start();
+    }
+}
+
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockcontainer.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -22,11 +22,9 @@
 #include <QTime>
 #include <QGraphicsLinearLayout>
 
-#include <hblabel.h>
-#include <hbevent.h>
-#include <hbcolorscheme.h>
-
-#include <qsysteminfo.h>
+#include <HbEvent>
+#include <HbColorScheme>
+#include <HbMainWindow>
 
 #include "snsrbigclockcontainer.h"
 #include "snsrindicatorwidget.h"
@@ -41,7 +39,6 @@
 const QString snsrBackgroundColorRole("snsrbackground");
 const int gStep(5);
 
-QTM_USE_NAMESPACE
 
 /*!
     Constructs a new SnsrBigClockContainer.
@@ -55,7 +52,7 @@
     mCurrentOrientation(-1)
 {
     setBackgroundColor();
-    mBackgroundContainerLayout = new QGraphicsLinearLayout(Qt::Vertical);
+    mBackgroundContainerLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
     setLayout(mBackgroundContainerLayout);
     qsrand(QTime::currentTime().msec());
 }
@@ -64,9 +61,7 @@
     Destructs the class.
  */
 SnsrBigClockContainer::~SnsrBigClockContainer()
-{
-    resetIndicatorConnections();
-    
+{    
     // e.g. mIndicatorWidget gets deleted during these calls
     mDocumentLoader.reset();
     qDeleteAll(mDocumentObjects);
@@ -83,10 +78,74 @@
  */
 
 /*!
-    \fn virtual void changeLayout(Qt::Orientation orientation) = 0;
+    Changes screensaver layout based on orientation changes.
+    \param orientation Current orientation.
+ */
+void SnsrBigClockContainer::changeLayout(Qt::Orientation orientation)
+{
+    SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockContainer::changeLayout")
+
+    if (mCurrentOrientation != orientation) {
+        mCurrentOrientation = orientation;
+        
+        // delete any old widgets
+        if ( mBackgroundContainerLayout->count() ) {
+            mBackgroundContainerLayout->removeAt(0);
+        }
+        mDocumentLoader.reset();
+        qDeleteAll(mDocumentObjects);
+        mDocumentObjects.clear();
+
+        // reload widgets from docml
+        loadWidgets();
+    }
+    mBackgroundContainerLayout->setGeometry( mainWindow()->layoutRect() );
+    update();
+
+    SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockContainer::changeLayout")
+}
 
-    Slot for members update in container when orientation changed.
+/*!
+    Set used indicator model that is owned by the screensaver class. 
+    Model's life cycle must be the same as screensaver's so that indicators'
+    status data can be kept in memory and one can receive updates. 
+    This method should be called when the current container is set.
+ */
+void SnsrBigClockContainer::setIndicatorModel(SnsrIndicatorModel &model)
+{
+    mIndicatorModel = &model;
+}
+
+/*!
+    @copydoc Screensaver::getActiveScreenRows()
  */
+void SnsrBigClockContainer::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow)
+{
+    // This default implementation return the whole area of the
+    // container. Inherited low power mode containers can and should
+    // return smaller area which just barely encloses all the content.
+    if ( mMainContainer ) {
+        QRect mainRect = mMainContainer->rect().toRect();
+        if ( mCurrentOrientation == Qt::Vertical ) {
+            *firstActiveRow = mainRect.top();
+            *lastActiveRow = mainRect.bottom();
+        }
+        else {
+            *firstActiveRow = mainRect.left();
+            *lastActiveRow = mainRect.right();
+        }
+    }
+}
+
+/*!
+    Tell if this container wants to lock the screen orientation.
+    Default implementation in not locked but inherited classes may
+    override this.
+ */
+bool SnsrBigClockContainer::isOrientationLocked()
+{
+    return false;
+}
 
 /*!
     \fn virtual int updateIntervalInMilliseconds() = 0;
@@ -96,22 +155,16 @@
  */
 
 /*!
-    Set used indicator model and do necessary initializations to show currently
-    active indicators.
+    \fn virtual int loadWidgets() = 0;
+
+    Concrete inherited container classes must implement this to instantiate
+    all the widgets shown in the container. The base class calls this
+    method when screen layuot is changed. The old widgets are already 
+    deleted by the base class before this is called. Also changing the visible
+    container is treated as a layout change, and results in call to this method.
+    Thus, inherited containers don't have to load their widgets yet in their
+    constructors.
  */
-void SnsrBigClockContainer::initIndicators(SnsrIndicatorModel &model)
-{
-    mIndicatorModel = &model;
-    if (mIndicatorWidget) {
-        connect(mIndicatorModel, SIGNAL(indicatorsUpdated(QList<SnsrIndicatorInfo>)),
-                mIndicatorWidget, SLOT(showIndicators(QList<SnsrIndicatorInfo>)));
-                
-        connect(mIndicatorModel, SIGNAL(allIndicatorsDeactivated()),
-                mIndicatorWidget, SLOT(removeAllIndicators()));
-        
-        mIndicatorModel->initializeIndicatorWidget();
-    }
-}
 
 /*!
     \reimp
@@ -229,15 +282,35 @@
 }
 
 /*!
+    Do necessary initializations to show currently active indicators.
+    Should be called after the indicator widget is created.
+ */
+void SnsrBigClockContainer::initIndicatorWidget()
+{
+    Q_ASSERT(mIndicatorModel && mIndicatorWidget);
+    
+    connect(mIndicatorModel, SIGNAL(indicatorsUpdated(QList<SnsrIndicatorInfo>)),
+            mIndicatorWidget, SLOT(showIndicators(QList<SnsrIndicatorInfo>)));
+                
+    connect(mIndicatorModel, SIGNAL(allIndicatorsDeactivated()),
+            mIndicatorWidget, SLOT(removeAllIndicators()));
+        
+    mIndicatorModel->initializeIndicatorWidget();
+}
+
+/*!
     Disconnect connections between indicator model and widget.
+    Should be called before deleting the indicator widget.
  */
 void SnsrBigClockContainer::resetIndicatorConnections()
-{
-    disconnect(mIndicatorModel, SIGNAL(indicatorsUpdated(QList<SnsrIndicatorInfo>)),
-               mIndicatorWidget, SLOT(showIndicators(QList<SnsrIndicatorInfo>)));
-    
-    disconnect(mIndicatorModel, SIGNAL(allIndicatorsDeactivated()),
-               mIndicatorWidget, SLOT(removeAllIndicators()));
+{   
+    if (mIndicatorWidget && mIndicatorModel) {
+        disconnect(mIndicatorModel, SIGNAL(indicatorsUpdated(QList<SnsrIndicatorInfo>)),
+                   mIndicatorWidget, SLOT(showIndicators(QList<SnsrIndicatorInfo>)));
+        
+        disconnect(mIndicatorModel, SIGNAL(allIndicatorsDeactivated()),
+                   mIndicatorWidget, SLOT(removeAllIndicators()));
+    }
 }
 
 /*!
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockscreensaver.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrbigclockscreensaver.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -24,14 +24,16 @@
 #include <QDebug>
 #include <QTime>
 #include <QTimer>
+#include <XQSettingsManager> 
+#include <HbInstance>
+#include <HbMainWindow>
 
-#include <hbinstance.h>
-#include <hbmainwindow.h>
-
+#include <screensaverdomaincrkeys.h>
 #include "snsranalogclockcontainer.h"
 #include "snsrdigitalclockcontainer.h"
 #include "snsroledanalogclockcontainer.h"
 #include "snsroleddigitalclockcontainer.h"
+#include "snsrblankcontainer.h"
 #include "snsrindicatormodel.h"
 
 /*!
@@ -40,15 +42,14 @@
     \brief Screensaver with big digital clock.
  */
 
-const int gTimeInterval(100);
-
 /*!
     Constructs a new SnsrBigClockScreensaver.
  */
 SnsrBigClockScreensaver::SnsrBigClockScreensaver() :
     mMainWindow(0),
     mCurrentContainer(0),
-    mIndicatorModel(0)
+    mIndicatorModel(0),
+    m_setManager(0)
 {
     mMainWindow = HbInstance::instance()->allMainWindows().at(0);
     // for nice looking clock hand transformations
@@ -64,6 +65,7 @@
  */
 SnsrBigClockScreensaver::~SnsrBigClockScreensaver()
 {
+    mMainWindow->unsetOrientation( /*animate*/false );
     // mCurrentContainer, mIndicatorModel - deleted by the parent
 }
 
@@ -86,6 +88,8 @@
 
     removeCurrentContainer();
 
+    emit screenPowerModeRequested( Screensaver::ScreenModeFullPower );
+    
     SnsrBigClockContainer* newContainer( 0 );
     if (clockFormat() == ClockFormatAnalog) {
         newContainer = new SnsrAnalogClockContainer();
@@ -95,7 +99,7 @@
     }
 
     setCurrentContainer( newContainer );
-
+    
     SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onForeground")
     return true;
 }
@@ -111,13 +115,34 @@
     removeCurrentContainer();
     
     SnsrBigClockContainer* newContainer( 0 );
-    if (clockFormat() == ClockFormatAnalog) {
-        newContainer = new SnsrOledAnalogClockContainer();
+        
+    // Check ScreensaverStatus from repository
+    XQSettingsManager::Error error;
+    int screensaverOn = 1; 
+    XQCentralRepositorySettingsKey settingsKey(
+            KCRUidScreensaverSettings.iUid, KScreensaverStatus ); // TUid as same repository used in control panel via Symbian APIs 
+    m_setManager = new XQSettingsManager(this);
+    if (m_setManager) {
+        screensaverOn = m_setManager->readItemValue(settingsKey, XQSettingsManager::TypeInt).toInt();
+        error = m_setManager->error();
+        if (error != XQSettingsManager::NoError) {
+            qDebug("Error reading value from XQSettingsManager.. error = %d", error);
+        }
+        delete m_setManager;
+    }
+    
+    if (screensaverOn) {
+        if (clockFormat() == ClockFormatAnalog) {
+            newContainer = new SnsrOledAnalogClockContainer();
+        }
+        else {
+            newContainer = new SnsrOledDigitalClockContainer();
+        }
     }
     else {
-        newContainer = new SnsrOledDigitalClockContainer();
+        newContainer = new SnsrBlankContainer();
     }
-
+    
     setCurrentContainer( newContainer );
 
     SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onPartialForeground")
@@ -196,6 +221,46 @@
     mIndicatorModel->handleDeactivatedIndicator(deactivatedIndicator);
 }
 
+/*!
+    @copydoc Screensaver::getActiveScreenRows
+ */
+void SnsrBigClockScreensaver::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow)
+{
+    if ( mCurrentContainer ) {
+        mCurrentContainer->getActiveScreenRows( firstActiveRow, lastActiveRow );
+    }
+    else {
+        qWarning() << "No current container when active rows queried.";
+    }
+}
+
+/*!
+    @copydoc Screensaver::updateLayout
+ */
+void SnsrBigClockScreensaver::updateLayout()
+{
+    if ( mCurrentContainer ) {
+        if ( mCurrentContainer->isOrientationLocked() ) {
+            mMainWindow->setOrientation( mMainWindow->orientation(), /*animate*/false );
+        }
+        else {
+            mMainWindow->unsetOrientation( /*animate*/false );
+        }
+        mCurrentContainer->changeLayout( mMainWindow->orientation() );
+    }
+    else {
+        qWarning() << "No current container when updateLayout called.";
+    }
+}
+
+/*!
+    Update the area visible in the power save screen mode. Power save mode gets
+    also activated on call if not already active.
+ */
+void SnsrBigClockScreensaver::updateActiveAreaForLowPower()
+{
+    emit screenPowerModeRequested( Screensaver::ScreenModeLowPower );
+}
 
 /*!
     Determines the curent clock format settings.
@@ -223,38 +288,41 @@
 {
     if ( mCurrentContainer ) {
         disconnect(
-            mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
-            mCurrentContainer, SLOT(changeLayout(Qt::Orientation))
-            );
-        disconnect(
             &mTimer, SIGNAL(timeout()),
             mCurrentContainer, SLOT(update())
             );
         disconnect( 
             mCurrentContainer, SIGNAL(unlockRequested()), 
             this, SIGNAL(unlockRequested()) );
-        mTimer.stop();
+        if (mTimer.timerId()!= -1) {
+            mTimer.stop();
+        }
         emit viewChanged(0);
         
         delete mCurrentContainer;
         mCurrentContainer = 0;
     }
+    
+    mMainWindow->unsetOrientation( /*animate*/false );
 }
 
 void SnsrBigClockScreensaver::setCurrentContainer( SnsrBigClockContainer* newContainer )
 {
     mCurrentContainer = newContainer;
-    connect(
-            mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
-            mCurrentContainer, SLOT(changeLayout(Qt::Orientation))
-        );
+    mCurrentContainer->setParent(this);
     connect( &mTimer, SIGNAL(timeout()), mCurrentContainer, SLOT(update()) );
     connect( mCurrentContainer, SIGNAL(unlockRequested()), SIGNAL(unlockRequested()) );
+    connect( mCurrentContainer, SIGNAL(activeAreaMoved()), SLOT(updateActiveAreaForLowPower()) );
 
-    mCurrentContainer->initIndicators(*mIndicatorModel);
+    mCurrentContainer->setIndicatorModel(*mIndicatorModel);
+
+    int updateInterval = mCurrentContainer->updateIntervalInMilliseconds(); 
+    // blankcontainer is empty one, don't start timer with -1 return value
+    if ( updateInterval != -1) {
+        mTimer.start(updateInterval);
+    }
     
-    mCurrentContainer->changeLayout(mMainWindow->orientation());
-    mTimer.start( mCurrentContainer->updateIntervalInMilliseconds() );
+    
     emit viewChanged(mCurrentContainer);
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrblankcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Container for blank screen.
+*
+*/
+
+#include "snsrblankcontainer.h"
+
+/*!
+    \class SnsrBlankContainer
+    \ingroup group_snsrbigclockscreensaverplugin
+    \brief Container used for preparing layout for blank screen.
+ */
+
+/*!
+    Constructs a new SnsrBlankContainer.
+ */
+SnsrBlankContainer::SnsrBlankContainer() :
+    SnsrBigClockContainer()
+{
+}
+
+/*!
+    Destructs the class.
+ */
+SnsrBlankContainer::~SnsrBlankContainer()
+{
+}
+
+void SnsrBlankContainer::update()
+{
+    // nothing to do
+}
+
+int SnsrBlankContainer::updateIntervalInMilliseconds()
+{
+    // don't start timer
+    return -1;
+}
+
+void SnsrBlankContainer::loadWidgets()
+{
+    // nothing to do as we have no visual components
+}
+
+// end of file
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdigitalclockcontainer.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdigitalclockcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -21,11 +21,12 @@
 #include <QTime>
 #include <QGraphicsLinearLayout>
 
-#include <hblabel.h>
-#include <hbextendedlocale.h>
+#include <HbExtendedLocale>
+#include <HbMainWindow>
 
 #include "snsrswipewidget.h"
 #include "snsrindicatorwidget.h"
+#include "snsrlabel.h"
 
 /*!
     \class SnsrDigitalClockContainer
@@ -66,41 +67,6 @@
     mSwipeWidget(0)*/
 {
     SCREENSAVER_TEST_FUNC_ENTRY("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
-
-    bool ok(false);
-    // load digital clock
-    qDebug() << gDigitalLayoutDocml;
-    mDocumentObjects = mDocumentLoader.load(gDigitalLayoutDocml, &ok);
-    Q_ASSERT_X(ok, gDigitalLayoutDocml, "Invalid DocML file.");
-
-    if (ok) {
-        mMainView = mDocumentLoader.findWidget(gMainViewName);
-        mDateLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gDateLabelName));
-        mTimeLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gTimeLabelName));
-        mAmPmLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gAmPmLabelName));
-        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
-                mDocumentLoader.findWidget(gIndicatorWidgetName));
-        // implement swipewidget later on
-        /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>(
-                mDocumentLoader.findWidget(gSwipeWidgetName));*/
-
-        Q_ASSERT_X(
-                mMainView && mDateLabel && mTimeLabel && mAmPmLabel &&
-                mIndicatorWidget /*&& mSwipeWidget*/,
-                gDigitalLayoutDocml, "Objects not found in DocML file."
-                );
-        
-        //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) );
-
-        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
-        
-        mBackgroundContainerLayout->addItem(mMainView);
- //       mSwipeWidget->start();
-    }
-
     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::SnsrDigitalClockContainer")
 }
 
@@ -109,6 +75,7 @@
  */
 SnsrDigitalClockContainer::~SnsrDigitalClockContainer()
 {
+    resetIndicatorConnections();
     //mTimeLabel, mAmPmLabel, mDateLabel - deleted by the parent
 }
 
@@ -130,7 +97,8 @@
     mTimeLabel->setPlainText(
         HbExtendedLocale().format(QTime::currentTime(), gTimeFormatStr)
         );
-    // if clock type is 24, this will return an empty string.
+    
+    // if clock type is 24h, this will return an empty string.
     mAmPmLabel->setPlainText(
         HbExtendedLocale().format(QTime::currentTime(), gAmPmFormatStr)
         );
@@ -151,44 +119,60 @@
     SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::update")
 }
 
-/*!
-    Changes screensaver layout basing on orientation changes.
-    \param orientation Current orientation.
- */
-void SnsrDigitalClockContainer::changeLayout(Qt::Orientation orientation)
-{
-    SCREENSAVER_TEST_FUNC_ENTRY("SnsrDigitalClockContainer::changeLayout")
-
-    bool ok(false);
-    if (mCurrentOrientation != orientation) {
-        mCurrentOrientation = orientation;
-
-        // hide controls to avoid screen flickering
-        mMainView->hide();
-
-        QString sectionToLoad("");
-        if (mCurrentOrientation == Qt::Horizontal) {
-            sectionToLoad = gLandscapeSectionName;
-        }
-        qDebug() << "loading: " << gDigitalLayoutDocml << ", section: "
-                << sectionToLoad;
-        mDocumentLoader.load(gDigitalLayoutDocml, sectionToLoad, &ok);
-        // view is rebuilt and ready to show
-        update();
-        mMainView->show();
-        Q_ASSERT_X(ok, gDigitalLayoutDocml, "Invalid section in DocML file.");
-    }
-    // update anyway - this is needed in situations when screensaver goes to
-    // foreground but layout change did not occur
-    if (!ok) {
-        update();
-    }
-
-    SCREENSAVER_TEST_FUNC_EXIT("SnsrDigitalClockContainer::changeLayout")
-}
-
 int SnsrDigitalClockContainer::updateIntervalInMilliseconds()
 {
     return 1000;
 }
 
+void SnsrDigitalClockContainer::loadWidgets()
+{
+    // reset widget pointers, any previous widgets are already deleted by now
+    mMainView = 0;
+    mDateLabel = 0;
+    mTimeLabel = 0;
+    mAmPmLabel = 0;
+    mIndicatorWidget = 0;
+    
+    // load widgets from docml
+    bool ok(false);
+    qDebug() << gDigitalLayoutDocml;
+    mDocumentObjects = mDocumentLoader.load(gDigitalLayoutDocml, &ok);
+    Q_ASSERT_X(ok, gDigitalLayoutDocml, "Invalid DocML file.");
+
+    if (ok) {
+        mMainView = mDocumentLoader.findWidget(gMainViewName);
+        mDateLabel = qobject_cast<SnsrLabel *>(
+                mDocumentLoader.findWidget(gDateLabelName));
+        mTimeLabel = qobject_cast<SnsrLabel *>(
+                mDocumentLoader.findWidget(gTimeLabelName));
+        mAmPmLabel = qobject_cast<SnsrLabel *>(
+                mDocumentLoader.findWidget(gAmPmLabelName));
+        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
+                mDocumentLoader.findWidget(gIndicatorWidgetName));
+        // implement swipewidget later on
+        /*mSwipeWidget = qobject_cast<SnsrSwipeWidget *>(
+                mDocumentLoader.findWidget(gSwipeWidgetName));*/
+
+        Q_ASSERT_X(
+                mMainView && mDateLabel && mTimeLabel && mAmPmLabel &&
+                mIndicatorWidget /*&& mSwipeWidget*/,
+                gDigitalLayoutDocml, "Objects not found in DocML file."
+                );
+
+        // In case of landscape layout, read also the landscape delta section
+        if ( mCurrentOrientation == Qt::Horizontal ) {
+            qDebug() << "loading: " << gDigitalLayoutDocml << ", section: " << gLandscapeSectionName;
+            mDocumentLoader.load(gDigitalLayoutDocml, gLandscapeSectionName, &ok);
+            Q_ASSERT_X(ok, gDigitalLayoutDocml, "Invalid section in DocML file.");
+        }
+
+        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
+        initIndicatorWidget();
+        
+        mBackgroundContainerLayout->addItem(mMainView);
+
+        //connect( mSwipeWidget, SIGNAL(swipeDownDetected()), SIGNAL(unlockRequested()) );
+        //mSwipeWidget->start();
+    }
+}
+
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdocumentloader.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsrdocumentloader.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -21,6 +21,7 @@
 #include "snsroledclockwidget.h"
 #include "snsrlabel.h"
 #include "snsrindicatorwidget.h"
+#include "snsroledtimelabel.h"
 #include "snsrswipewidget.h"
 
 /*!
@@ -28,11 +29,11 @@
     \ingroup group_snsrbigclockscreensaverplugin
     \brief Custom screensaver docml layout loader.
 
-    Used mainly to create the analog clock widget from docml.
+    Used to create the widgets from docml.
  */
 
 /*!
-    Creates the analog clock.
+    Creates the requested widget.
     \param type Static type name.
     \param name Object name.
     \retval Created object.
@@ -63,6 +64,12 @@
         return object;
     }
 
+    if (type == SnsrOledTimeLabel::staticMetaObject.className()) {
+        QObject *object = new SnsrOledTimeLabel();
+        object->setObjectName(name);
+        return object;
+    }
+    
     /* Add swipeWidget implementation later on
      
      if (type == SnsrSwipeWidget::staticMetaObject.className()) {
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroledanalogclockcontainer.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroledanalogclockcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -21,11 +21,12 @@
 #include <QGraphicsLinearLayout>
 #include <QTimer>
 #include <QTime>
-#include <hblabel.h>
-#include <hbextendedlocale.h>
+#include <HbExtendedLocale>
+#include <HbMainWindow>
 
 #include "snsroledclockwidget.h"
 #include "snsrindicatorwidget.h"
+#include "snsrlabel.h"
 
 /*!
     \class SnsrOledAnalogClockContainer
@@ -57,34 +58,6 @@
     mDateLabel(0), mDestPosition(QPointF()), mInitialize(false)
 {
     SCREENSAVER_TEST_FUNC_ENTRY("SnsrOledAnalogClockContainer::SnsrOledAnalogClockContainer")
-
-    bool ok(false);
-    qDebug() << gOledAnalogLayoutDocml;
-
-    // load oled analog clock
-    mDocumentObjects = mDocumentLoader.load(gOledAnalogLayoutDocml, &ok);
-    Q_ASSERT_X(ok, gOledAnalogLayoutDocml, "Invalid DocML file.");
-    if (ok) {
-        mMainView = mDocumentLoader.findWidget(gMainViewName);
-        mMainContainer = mDocumentLoader.findWidget(gMainContainerName);
-        mClockContainer = mDocumentLoader.findWidget(gClockContainerName);
-        mOledClockWidget = qobject_cast<SnsrOledClockWidget *>(
-              mDocumentLoader.findWidget(gOledAnalogClockWidgetName));
-        mDateLabel = qobject_cast<HbLabel *>(
-              mDocumentLoader.findWidget(gDateLabelName));
-        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
-              mDocumentLoader.findWidget(gIndicatorWidgetName));
-        Q_ASSERT_X(
-                mMainView && mMainContainer && mClockContainer
-                && mOledClockWidget && mDateLabel && mIndicatorWidget,
-                gOledAnalogLayoutDocml, "Objects not found in DocML file."
-                );
-        
-        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
-        
-        mBackgroundContainerLayout->addItem(mMainView);
-    }
-
     SCREENSAVER_TEST_FUNC_EXIT("SnsrOledAnalogClockContainer::SnsrOledAnalogClockContainer")
 }
 
@@ -93,6 +66,7 @@
  */
 SnsrOledAnalogClockContainer::~SnsrOledAnalogClockContainer()
 {
+    resetIndicatorConnections();
     //mOledClockWidget etc - deleted by the parent
 }
 
@@ -106,9 +80,14 @@
     // Container must have a valid size to enable calculating the 
     // destination position for the clock.
     if ( containerSize.width() > 0 && containerSize.height() > 0 ) {
-        containerSize -= mClockContainer->boundingRect().size();
+        containerSize -= mClockContainer->size();
         QRectF containerRect( mMainContainer->pos(), containerSize );
         if ( mInitialize ) {
+            // disconnect container from parent layout,
+            // connected container resets its position to the one defined in docml
+            // after label text updates
+            mClockContainer->setParentLayoutItem(0);
+
             QPointF clockPos = nextRandomPosition( mClockContainer->pos(), mDestPosition, containerRect );
             mClockContainer->setPos( clockPos );
         }
@@ -116,6 +95,8 @@
             mDestPosition = randomPosition( containerRect );
             mInitialize = true;
         }
+        // the active area of power save mode needs to be updated when clock container is moved
+        emit activeAreaMoved();
     }
 }
 
@@ -143,57 +124,86 @@
     // position
     updatePosition();
     
-    // TODO: Currently, both time and position are updated 10 times per second.
-    // These should happen only once per minute in the power save mode.
-
     SCREENSAVER_TEST_FUNC_EXIT("SnsrOledAnalogClockContainer::update")
 }
 
-/*!
-    Changes screensaver layout basing on orientation changes.
-    \param orientation Current orientation.
- */
-void SnsrOledAnalogClockContainer::changeLayout(Qt::Orientation orientation)
-{
-    SCREENSAVER_TEST_FUNC_ENTRY("SnsrOledAnalogClockContainer::changeLayout")
-
-    bool ok(false);
-    if (mCurrentOrientation != orientation) {
-        mCurrentOrientation = orientation;
-        // hide controls to avoid screen flickering
-        mMainView->hide();
-
-        QString sectionToLoad("");
-        if (mCurrentOrientation == Qt::Horizontal) {
-            sectionToLoad = gLandscapeSectionName;
-        }
-        qDebug() << "loading: " << gOledAnalogLayoutDocml << ", section: " << sectionToLoad;
-        mDocumentLoader.load(gOledAnalogLayoutDocml, sectionToLoad, &ok);
-        Q_ASSERT_X(ok, gOledAnalogLayoutDocml, "Invalid section in DocML file.");
-
-        // disconnect container from parent layout,
-        // connected container resets its position to the one defined in docml
-        // after label text updates
-        mClockContainer->setParentLayoutItem(0);
-
-        update();
-
-        // view is rebuilt and ready to show
-        mMainView->show();
-    }
-
-    // update anyway - this is needed in situations when screensaver goes to
-    // foreground but layout change did not occur
-    if (!ok) {
-        update();
-    }
-
-    SCREENSAVER_TEST_FUNC_EXIT("SnsrOledAnalogClockContainer::changeLayout")
-}
-
 int SnsrOledAnalogClockContainer::updateIntervalInMilliseconds()
 {
     return 60*1000;
 }
 
+/*!
+    @copydoc SnsrBigClockContainer::getActiveScreenRows()
+ */
+void SnsrOledAnalogClockContainer::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow)
+{
+    if ( mClockContainer ) {
+        QRect clockRect( mClockContainer->pos().toPoint(), 
+                         mClockContainer->size().toSize() );
+        if ( mCurrentOrientation == Qt::Vertical ) {
+            *firstActiveRow = clockRect.top();
+            *lastActiveRow = clockRect.bottom() + 1;
+        }
+        else {
+            *firstActiveRow = clockRect.left();
+            *lastActiveRow = clockRect.right() + 1;
+        }
+    }
+}
+
+/*!
+    Orientation is locked in power save mode as sensors are off anyway,
+    at least after some timeout.
+ */
+bool SnsrOledAnalogClockContainer::isOrientationLocked()
+{
+    return true;
+}
+
+void SnsrOledAnalogClockContainer::loadWidgets()
+{
+    bool ok(true);
+
+    // reset widget pointers, any previous widgets are already deleted by now
+    mMainView = 0;
+    mMainContainer = 0;
+    mClockContainer = 0;
+    mOledClockWidget = 0;
+    mDateLabel = 0;
+    mIndicatorWidget = 0;
+    
+    // load widgets from docml
+    qDebug() << gOledAnalogLayoutDocml;
+    mDocumentObjects = mDocumentLoader.load(gOledAnalogLayoutDocml, &ok);
+    Q_ASSERT_X(ok, gOledAnalogLayoutDocml, "Invalid DocML file.");
+    if (ok) {
+        mMainView = mDocumentLoader.findWidget(gMainViewName);
+        mMainContainer = mDocumentLoader.findWidget(gMainContainerName);
+        mClockContainer = mDocumentLoader.findWidget(gClockContainerName);
+        mOledClockWidget = qobject_cast<SnsrOledClockWidget *>(
+              mDocumentLoader.findWidget(gOledAnalogClockWidgetName));
+        mDateLabel = qobject_cast<SnsrLabel *>(
+              mDocumentLoader.findWidget(gDateLabelName));
+        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
+              mDocumentLoader.findWidget(gIndicatorWidgetName));
+        Q_ASSERT_X(
+                mMainView && mMainContainer && mClockContainer
+                && mOledClockWidget && mDateLabel && mIndicatorWidget,
+                gOledAnalogLayoutDocml, "Objects not found in DocML file."
+                );
+        
+        // In case of landscape layout, read also the landscape delta section
+        if ( mCurrentOrientation == Qt::Horizontal ) {
+            qDebug() << "loading: " << gOledAnalogLayoutDocml << ", section: " << gLandscapeSectionName;
+            mDocumentLoader.load(gOledAnalogLayoutDocml, gLandscapeSectionName, &ok);
+            Q_ASSERT_X(ok, gOledAnalogLayoutDocml, "Invalid section in DocML file.");
+        }
+
+        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
+        initIndicatorWidget();
+        
+        mBackgroundContainerLayout->addItem(mMainView);
+    }
+}
+
 // end of file
--- a/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroleddigitalclockcontainer.cpp	Wed Jul 14 15:53:30 2010 +0300
+++ b/screensaver/screensaverplugins/snsrbigclockscreensaverplugin/src/snsroleddigitalclockcontainer.cpp	Fri Jul 23 13:47:57 2010 +0300
@@ -22,10 +22,14 @@
 #include <QTime>
 #include <QTimer>
 
-#include <hblabel.h>
-#include <hbextendedlocale.h>
+
+#include <HbExtendedLocale>
+#include <HbMainWindow>
 
+#include "snsrlabel.h"
 #include "snsrindicatorwidget.h"
+#include "snsroledtimelabel.h"
+
 
 /*!
     \class SnsrOledDigitalClockContainer
@@ -41,7 +45,7 @@
 extern const char *gMainContainerName;
 extern const char *gClockContainerName;
 
-extern const char *gTimeLabelName;
+extern const char *gOledTimeLabelName = "oledTimeLabel";
 extern const char *gAmPmLabelName;
 extern const char *gDateLabelName;
 
@@ -54,46 +58,16 @@
 extern const char *gIndicatorWidgetName;
 
 
+
 /*!
     Constructs a new SnsrOledDigitalClockContainer.
  */
 SnsrOledDigitalClockContainer::SnsrOledDigitalClockContainer() :
-    SnsrBigClockContainer(), mClockContainer(0), mTimeLabel(0),
-    mDateLabel(0), mAmPmLabel(0), mDestPosition(QPointF()), mInitialize(false)
+    SnsrBigClockContainer(), mClockContainer(0), mAmPmLabel(0),
+    mTimeLabel(0), mDateLabel(0), mDestPosition(QPointF()),
+    mInitialize(false)
 {
     SCREENSAVER_TEST_FUNC_ENTRY("SnsrOledDigitalClockContainer::SnsrOledDigitalClockContainer")
-
-    bool ok(false);
-    qDebug() << gOledDigitalLayoutDocml;
-
-    // load digital clock
-    mDocumentObjects = mDocumentLoader.load(gOledDigitalLayoutDocml, &ok);
-    Q_ASSERT_X(ok, gOledDigitalLayoutDocml, "Invalid DocML file.");
-
-    if (ok) {
-        mMainView = mDocumentLoader.findWidget(gMainViewName);
-        mMainContainer = mDocumentLoader.findWidget(gMainContainerName);
-        mClockContainer = mDocumentLoader.findWidget(gClockContainerName);
-        mDateLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gDateLabelName));
-        mTimeLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gTimeLabelName));
-        mAmPmLabel = qobject_cast<HbLabel *>(
-                mDocumentLoader.findWidget(gAmPmLabelName));
-        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
-                mDocumentLoader.findWidget(gIndicatorWidgetName));
-        Q_ASSERT_X(
-                mMainView && mMainContainer && mClockContainer 
-                && mDateLabel && mTimeLabel && mAmPmLabel
-                && mIndicatorWidget,
-                gOledDigitalLayoutDocml, "Objects not found in DocML file."
-                );
-
-        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
-        
-        mBackgroundContainerLayout->addItem(mMainView);
-    }
-
     SCREENSAVER_TEST_FUNC_EXIT("SnsrOledDigitalClockContainer::SnsrOledDigitalClockContainer")
 }
 
@@ -102,6 +76,7 @@
  */
 SnsrOledDigitalClockContainer::~SnsrOledDigitalClockContainer()
 {
+    resetIndicatorConnections();
     //mTimeLabel, mAmPmLabel, mDateLabel, mMoveTimer - deleted by the parent
 }
 
@@ -118,6 +93,11 @@
         containerSize -= mClockContainer->boundingRect().size();
         QRectF containerRect( mMainContainer->pos(), containerSize );
         if ( mInitialize ) {
+            // disconnect container from parent layout,
+            // connected container resets its position to the one defined in docml
+            // after label text updates
+            mClockContainer->setParentLayoutItem(0);
+
             QPointF clockPos = nextRandomPosition( mClockContainer->pos(), mDestPosition, containerRect );
             mClockContainer->setPos( clockPos );
         }
@@ -125,6 +105,8 @@
             mDestPosition = randomPosition( containerRect );
             mInitialize = true;
         }
+        // the active area of power save mode needs to be updated when clock container is moved
+        emit activeAreaMoved();
     }
 }
 
@@ -136,9 +118,11 @@
     SCREENSAVER_TEST_FUNC_ENTRY("SnsrOledDigitalClockContainer::update")
 
     // time
-    mTimeLabel->setPlainText(
+    mTimeLabel->setText(
         HbExtendedLocale().format(QTime::currentTime(), gTimeFormatStr)
         );
+    
+    // if clock type is 24h, this will return an empty string.
     mAmPmLabel->setPlainText(
         HbExtendedLocale().format(QTime::currentTime(), gAmPmFormatStr)
         );
@@ -161,48 +145,87 @@
     SCREENSAVER_TEST_FUNC_EXIT("SnsrOledDigitalClockContainer::update")
 }
 
-/*!
-    Changes screensaver layout basing on orientation changes.
-    \param orientation Current orientation.
- */
-void SnsrOledDigitalClockContainer::changeLayout(Qt::Orientation orientation)
-{
-    SCREENSAVER_TEST_FUNC_ENTRY("SnsrOledDigitalClockContainer::changeLayout")
-
-    if (mCurrentOrientation != orientation) {
-        mCurrentOrientation = orientation;
-
-        // hide controls to avoid screen flickering
-        mMainView->hide();
-
-        QString sectionToLoad("");
-        if (mCurrentOrientation == Qt::Horizontal) {
-            sectionToLoad = gLandscapeSectionName;
-        }
-        qDebug() << "loading: " << gOledDigitalLayoutDocml << ", section: "
-            << sectionToLoad;
-        bool ok(false);
-        mDocumentLoader.load(gOledDigitalLayoutDocml, sectionToLoad, &ok);
-        Q_ASSERT_X(ok, gOledDigitalLayoutDocml, "Invalid section in DocML file.");
-
-        // disconnect container from parent layout,
-        // connected container resets its position to the one defined in docml
-        // after label text updates
-        mClockContainer->setParentLayoutItem(0);
-
-        // update labels before showing the view
-        update();
-
-        // view is rebuilt and ready to show
-        mMainView->show();
-    }
-
-    SCREENSAVER_TEST_FUNC_EXIT("SnsrOledDigitalClockContainer::changeLayout")
-}
-
 int SnsrOledDigitalClockContainer::updateIntervalInMilliseconds()
 {
     return 60*1000;
 }
 
+/*!
+    @copydoc SnsrBigClockContainer::getActiveScreenRows()
+ */
+void SnsrOledDigitalClockContainer::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow)
+{
+    if ( mClockContainer ) {
+        QRect clockRect( mClockContainer->pos().toPoint(), 
+                         mClockContainer->size().toSize() );
+        if ( mCurrentOrientation == Qt::Vertical ) {
+            *firstActiveRow = clockRect.top();
+            *lastActiveRow = clockRect.bottom() + 1;
+        }
+        else {
+            *firstActiveRow = clockRect.left();
+            *lastActiveRow = clockRect.right() + 1;
+        }
+    }
+}
+
+/*!
+    Orientation is locked in power save mode as sensors are off anyway,
+    at least after some timeout.
+ */
+bool SnsrOledDigitalClockContainer::isOrientationLocked()
+{
+    return true;
+}
+
+void SnsrOledDigitalClockContainer::loadWidgets()
+{
+    // reset widget pointers, any previous widgets are already deleted by now
+    mMainView = 0;
+    mMainContainer = 0;
+    mClockContainer = 0;
+    mDateLabel = 0;
+    mTimeLabel = 0;
+    mAmPmLabel = 0;
+    mIndicatorWidget = 0;
+    
+    // load widgets from docml
+    bool ok(false);
+    qDebug() << gOledDigitalLayoutDocml;
+    mDocumentObjects = mDocumentLoader.load(gOledDigitalLayoutDocml, &ok);
+    Q_ASSERT_X(ok, gOledDigitalLayoutDocml, "Invalid DocML file.");
+
+    if (ok) {
+        mMainView = mDocumentLoader.findWidget(gMainViewName);
+        mMainContainer = mDocumentLoader.findWidget(gMainContainerName);
+        mClockContainer = mDocumentLoader.findWidget(gClockContainerName);
+        mDateLabel = qobject_cast<SnsrLabel *>(
+                mDocumentLoader.findWidget(gDateLabelName));
+        mTimeLabel = qobject_cast<SnsrOledTimeLabel *>(
+                mDocumentLoader.findWidget(gOledTimeLabelName));
+        mAmPmLabel = qobject_cast<SnsrLabel *>(
+                mDocumentLoader.findWidget(gAmPmLabelName));
+        mIndicatorWidget = qobject_cast<SnsrIndicatorWidget *>(
+                mDocumentLoader.findWidget(gIndicatorWidgetName));
+        Q_ASSERT_X(
+                mMainView && mMainContainer && mClockContainer 
+                && mDateLabel && mTimeLabel && mAmPmLabel
+                && mIndicatorWidget,
+                gOledDigitalLayoutDocml, "Objects not found in DocML file."
+                );
+
+        // In case of landscape layout, read also the landscape delta section
+        if ( mCurrentOrientation == Qt::Horizontal ) {
+            qDebug() << "loading: " << gOledDigitalLayoutDocml << ", section: " << gLandscapeSectionName;
+            mDocumentLoader.load(gOledDigitalLayoutDocml, gLandscapeSectionName, &ok);
+            Q_ASSERT_X(ok, gOledDigitalLayoutDocml, "Invalid section in DocML file.");
+        }
+
+        mIndicatorWidget->setLayoutType(SnsrIndicatorWidget::IndicatorsCentered);
+        initIndicatorWidget();
+               
+        mBackgroundContainerLayout->addItem(mMainView);
+    }
+}
+
 // end of file