# HG changeset patch
# User hgs
# Date 1279882077 -10800
# Node ID 87476091b3f5bff5990f0c4f73d7c9401657f370
# Parent 474929a40a0fa25beae832c15e31a8a5ec137cef
201029
diff -r 474929a40a0f -r 87476091b3f5 homescreen_plat/homescreenclient_api/homescreenclient_api.metaxml
--- /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 @@
+
+
+ homescreenclient_api
+ Home screen API to create widgets, change wallpaper
+ c++
+ homescreenapp
+
+
+
+ no
+ no
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/common.pri
--- 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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/examples/batterywidgetplugin/resource/batterywidgetplugin.xml
--- 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 @@
1.0
Example of home screen widget
- batterywidgetplugin.png
- Battery
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/homescreenapp.pro
--- 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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsapplication/hsapplication.pro
--- 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)
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsapplication/src/hsstatemachine.cpp
--- 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;
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/hsdomainmodel.pri
--- 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 \
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/hsdomainmodel.pro
--- 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)
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/hsdomainmodel.qrc
--- /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 @@
+
+
+ resource/controllayer.docml
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsdocumentloader.h
--- /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
+#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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsdomainmodel_global.h
--- 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
+#include
// 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";
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsdomainmodeldatastructures.h
--- 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
-
+#include
#include "hsdomainmodel_global.h"
class HSDOMAINMODEL_EXPORT HsSceneData
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsgui.h
--- 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
#include
-
+#include
#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 mIdleView;
-
+ static HsGui *mInstance;
+ HsGuiImpl *mImpl;
+ HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
HOMESCREEN_TEST_FRIEND_CLASS(HomeScreenStatePluginTest)
};
-Q_DECLARE_METATYPE(HsGui*)
+
#endif // HSGUI_H
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hshostedwidgetfactory.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
+
+
+#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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsidlewidget.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
+
+#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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hspage.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 &widgets);
+#endif //HSWIDGETORGANIZER_ALGORITHM
private slots:
void onWidgetFinished();
@@ -87,12 +94,13 @@
private:
int mDatabaseId;
+ HsPageVisual *mPageVisual;
HsWallpaper *mWallpaper;
bool mRemovable;
QList mWidgets;
QList mNewWidgets;
QList mUnavailableWidgets;
- HsPageTouchArea *mTouchArea;
+ //HsPageTouchArea *mTouchArea;
QPointF mTouchPoint;
qreal mPageMargin;
HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hspagenewwidgetlayout.h
--- 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 sortWidgets(sortOrder order);
+#endif
private:
QSizeF mSize;
QList mNewWidgets;
@@ -46,5 +50,4 @@
HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel)
};
-
#endif
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hspagevisual.h
--- /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
+#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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hsscene.h
--- 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;
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hswidgethost.h
--- 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
+#include
#include
#include
@@ -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;
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hswidgethostvisual.h
--- /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
+#include
+#include
+
+#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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/inc/hswidgettoucharea.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)
};
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/resource/controllayer.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hsdocumentloader.cpp
--- /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);
+}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hsgui.cpp
--- 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
+#include
#include
+#include
+#include
#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 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)));
+}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hshostedwidgetfactory.cpp
--- /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
+#include
+#include
+#include
+#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 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(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;
+}
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hsidlewidget.cpp
--- /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
+#include
+#include
+#include
+
+#include
+#include
+
+#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 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(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(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(mPageLayer->layout());
+ layout->removeAt(index);
+ mPageLayer->resize(
+ layout->count() * size().width(), size().height());
+
+ if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+ QGraphicsLinearLayout *layout =
+ static_cast(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(mPageLayer->layout());
+
+ QList pages = scene->pages();
+
+ foreach (HsPage *page, pages) {
+ pageLayout->addItem(page->visual());
+ if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::PageWallpapers) {
+ QGraphicsLinearLayout *pageWallpaperLayout =
+ static_cast(mPageWallpaperLayer->layout());
+ pageWallpaperLayout->addItem(page->wallpaper());
+ }
+ }
+ if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
+ QGraphicsLinearLayout *sceneLayout =
+ static_cast(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(loader.findWidget(gControlLayerName));
+ mControlLayer->setZValue(3);
+ mControlLayer->setParentItem(this);
+
+ mTrashBin = qobject_cast(loader.findWidget(gTrashBinName));
+ mTrashBin->setZValue(1e6);
+
+ mPageIndicator = qobject_cast(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);
+ }
+}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hspage.cpp
--- 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(layout());
+ HsPageNewWidgetLayout *newWidgetLayout = static_cast(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 map;
foreach (HsWidgetHost *widget, mWidgets) {
- map.insert(widget->zValue(), widget);
+ map.insert(widget->visual()->zValue(), widget);
}
QList 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(sender());
- widget->setPos(adjustedWidgetPosition(widget->geometry()));
+ if (!visual()->layout()) {
+ HsWidgetHostVisual *widgetVisual = qobject_cast(sender());
+ widgetVisual->setPos(adjustedWidgetPosition(widgetVisual->geometry()));
} else {
- layout()->invalidate();
+ visual()->layout()->invalidate();
}
}
/*!
@@ -552,13 +610,14 @@
void HsPage::onWidgetAvailable()
{
HsWidgetHost *widget = qobject_cast(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(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 newWidgets;
+#endif //HSWIDGETORGANIZER_ALGORITHM
foreach (HsWidgetHost *widget, mWidgets) {
+ visual = widget->visual();
if (!widget->getPresentation(presentation)) {
+#ifndef HSWIDGETORGANIZER_ALGORITHM
QList geometries = converter->convert(
- from, QList() << widget->geometry(), to);
- widget->setGeometry(geometries.first());
+ from, QList() << 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 newRects;
+ foreach (HsWidgetHost *newWidget, newWidgets) {
+ newRects << QRectF(QPointF(), newWidget->visual()->preferredSize());
+ }
+
+ // get page rect
+ QRectF pageRect = contentGeometry();
+
+ // scan existing widgets rects
+ QList 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 calculatedRects =
+ algorithm->convert(pageRect, existingRects, newRects, QPointF());
+
+ for ( int i=0; ivisual()->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 &widgets)
+{
+ QList 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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp
--- 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
-
#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 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 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 existingWidgets;
+ existingWidgets = HsScene::instance()->activePage()->widgets();
+ QList 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 calculatedRects =
- algorithm->convert(pageRect, rects, QPointF());
+ algorithm->convert(pageRect, existingRects, newRects, QPointF());
for ( int i=0; isetGeometry(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 HsPageNewWidgetLayout::sortWidgets(sortOrder order)
+{
+ QList 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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hspagevisual.cpp
--- /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);
+}
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hsscene.cpp
--- 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.
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hswallpaper.cpp
--- 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;
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hswidgetcomponentregistry.cpp
--- 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
#include
#include
-#include
+//#include
/*!
\class HsWidgetComponentRegistry
@@ -58,7 +57,7 @@
{
if (!mInstance) {
mInstance = new HsWidgetComponentRegistry;
- mInstance->setParent(HsScene::mainWindow());
+ mInstance->setParent(QCoreApplication::instance());
}
return mInstance;
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hswidgethost.cpp
--- 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
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
#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(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(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(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 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(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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hswidgethostvisual.cpp
--- /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
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+#include
+#include
+
+#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(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(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(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(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);
+}
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsdomainmodel/src/hswidgettoucharea.cpp
--- 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
#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(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(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;
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/inc/hsmessageboxwrapper.h
--- 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)
};
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/inc/hspropertyanimationwrapper.h
--- 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
-#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();
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/inc/hsutils_global.h
--- 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
+#include
#ifdef HSUTILS_LIB
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/inc/hswidgetpositioningonwidgetadd.h
--- 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
#include
+#include
#include "hsutils_global.h"
+class HsWidgetHost;
+
class HSUTILS_EXPORT HsWidgetPositioningOnWidgetAdd
{
public:
virtual ~HsWidgetPositioningOnWidgetAdd() {}
virtual QList convert(const QRectF &contentArea,
- const QList &rects,
+ const QList &existingRects,
+ const QList &newRects,
const QPointF &startPoint) = 0;
static void setInstance(HsWidgetPositioningOnWidgetAdd *instance);
@@ -42,7 +46,8 @@
{
public:
QList convert(const QRectF &contentArea,
- const QList &rects,
+ const QList &existingRects,
+ const QList &newRects,
const QPointF &startPoint);
};
@@ -51,9 +56,40 @@
{
public:
QList convert(const QRectF &contentArea,
- const QList &rects,
+ const QList &existingRects,
+ const QList &newRects,
const QPointF &startPoint);
};
+class HSUTILS_EXPORT HsWidgetOrganizer : public HsWidgetPositioningOnWidgetAdd
+{
+public:
+ QList convert(const QRectF &contentArea,
+ const QList &existingRects,
+ const QList &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 mAnchors;
+
+};
+
#endif // HSWIDGETPOSITIONINGONWIDGETADD_H
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/inc/hswidgetpositioningonwidgetmove.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 &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;
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/src/hsmessageboxwrapper.cpp
--- 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;
+ }
}
+
/*!
*/
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/src/hspropertyanimationwrapper.cpp
--- 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();
}
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/src/hssnapline.cpp
--- 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
#include
+#include
#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();
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/src/hswidgetpositioningonwidgetadd.cpp
--- 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
#include
+#include
+#include
+
+#include
+
+
#include "hswidgetpositioningonwidgetadd.h"
-#include
-#include
const qreal offset = 40; //TODO: Implement this as configurable parameter
@@ -71,9 +76,12 @@
*/
QList HsAnchorPointInBottomRight::convert(
const QRectF &contentArea,
- const QList &rects,
+ const QList &existingRects,
+ const QList &newRects,
const QPointF &startPoint)
{
+ Q_UNUSED(existingRects);
+
QList 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 HsAnchorPointInCenter::convert(
const QRectF &contentArea,
- const QList &rects,
+ const QList &existingRects,
+ const QList &newRects,
const QPointF &startPoint )
{
+ Q_UNUSED(existingRects);
Q_UNUSED(startPoint)
QList 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 HsWidgetOrganizer::convert(
+ const QRectF &contentArea,
+ const QList &existingRects,
+ const QList &newRects,
+ const QPointF &startPoint)
+{
+ Q_UNUSED(startPoint)
+
+ // TODO: maybe we can utilize start point in some use cases / optimizations?
+
+ QList 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 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 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 tmpExistingRects;
+ tmpExistingRects += newRects;
+ tmpExistingRects += existingRects;
+ HsAnchorPointInCenter *centerAlgorithm = new HsAnchorPointInCenter();
+ QList 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
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/hsutils/src/hswidgetpositioningonwidgetmove.cpp
--- 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));
}
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/inc/hsapp_defs.h
--- 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
};
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/serviceproviders/hsmenuserviceprovider/hsmenuserviceprovider.pro
--- 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)
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuentryremovedhandler.h
--- /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
+
+#include
+#include
+
+#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 mNotifier;
+};
+#endif
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/serviceproviders/hsmenuserviceprovider/inc/hsmenuservice_global.h
--- 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
+#include
#ifdef MENUSERVICE_LIB
#define MENUSERVICE_EXPORT Q_DECL_EXPORT
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuentryremovedhandler.cpp
--- /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
+
+#include
+#include
+#include
+
+#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 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);
+ }
+}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/serviceproviders/hsmenuserviceprovider/src/hsmenuservice.cpp
--- 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");
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/hsapplibrarystateplugin.qrc
--- 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 @@
- resource/applibrary.docml
+ resource/addcontentlabeledview.docml
+ resource/common_objects.docml
+ resource/emptylabeledview.docml
+ resource/labeledlistview.docml
+ resource/labeledsearchview.docml
+ resource/listview.docml
+ resource/searchlabeledlistview.docml
+ resource/searchlistview.docml
resource/hsapplibrarystateplugin.css
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsallcollectionsstate.h
--- 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
-#include
-
#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
{
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsbaseviewstate.h
--- 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 mApplicationLaunchFailMessage;
protected:
HsMenuItemModel *mModel;
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmainwindow.h
--- 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);
};
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuview.h
--- 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
#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 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 mHsSearchView;
HS_STATES_TEST_FRIEND_CLASS(MenuStatesTest)
};
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hsmenuviewbuilder.h
--- 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
#include
+#include
#include
+#include
#include
#include
#include
@@ -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 Context;
+ typedef QMap > LoaderMap;
+
+ QSharedPointer
+ parseDocument(const QString &documentBaseName);
- bool parseSection(const QString §ionName = QString());
+ QSharedPointer readContextConfiguration();
+ Context context() const;
- bool readContextConfiguration(HsViewContext, HsOperationalContext);
+ QSharedPointer currentLoader();
- void searchPanelVisibilityChange(bool visible);
-
- HbLineEdit *searchPanelLineEdit() const;
-
- QMap mViewContextToStringMap;
- QMap mOperationalContextToStringMap;
-
- HbDocumentLoader mDocumentLoader;
QSet 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 mCommonObjectsLoader;
};
#endif // HSMENUVIEWBUILDER_H
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/inc/hssearchview.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
+#include
+
+#include
+
+#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 mVkbHost;
+
+};
+
+#endif /* HSSEARCHVIEW_H_ */
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/addcontentlabeledview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/common_objects.docml
--- /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 @@
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/emptylabeledview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledlistview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/labeledsearchview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/listview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlabeledlistview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/resource/searchlistview.docml
--- /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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallappsstate.cpp
--- 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(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);
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsallcollectionsstate.cpp
--- 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
#include
#include
#include
@@ -24,12 +25,12 @@
#include
+#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(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();
}
/*!
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsbaseviewstate.cpp
--- 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
#include
#include
#include
@@ -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() << 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 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 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 ();
+ CaItemModel::FlagsRole).value ();
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));
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hscollectionstate.cpp
--- 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
#include
+#include
#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(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(this), SLOT(openAppLibrary()));
@@ -323,6 +290,14 @@
SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
static_cast(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 array =
- mMenuView->listView()->visibleItems();
+ if (mMenuView->listView() != NULL) {
+ const QList 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(
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsinstalledappsstate.cpp
--- 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(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();
}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmainwindow.cpp
--- 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);
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuview.cpp
--- 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 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 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();
+}
diff -r 474929a40a0f -r 87476091b3f5 homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsmenuviewbuilder.cpp
--- 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
#include
#include
-#include
#include
#include
#include
@@ -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(currentLoader()->findWidget(VIEW_NAME));
- HbView *const view =
- qobject_cast(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(
+ currentLoader()->findWidget(LIST_VIEW_NAME));
- return qobject_cast(
- 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(
+ 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(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