--- a/homescreenapp/hsdomainmodel/src/hsscene.cpp Fri Jun 11 13:30:16 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hsscene.cpp Wed Jun 23 18:03:36 2010 +0300
@@ -19,7 +19,6 @@
#include <HbInstance>
#include <HbMainWindow>
-#include <HbDeviceProfile>
#include "hsdomainmodeldatastructures.h"
#include "hsscene.h"
@@ -29,6 +28,14 @@
#include "hswallpaper.h"
#include "hsconfiguration.h"
+
+/*!
+ \class HsScene
+ \ingroup group_hsdomainmodel
+ \brief Represents a scene in the framework.
+ HsScene can have a wallpaper.
+*/
+
/*!
Destructor.
*/
@@ -58,23 +65,17 @@
return false;
}
- mMaximumPageCount = HsConfiguration::maximumPageCount();
-
- calculateWidgetSizeLimitations();
-
- if (sceneData.portraitWallpaper.isEmpty()) {
- mWallpaper->setImagesById();
- } else {
- mWallpaper->setImagesByPaths(
- sceneData.landscapeWallpaper,
- sceneData.portraitWallpaper);
- }
+ mDatabaseId = sceneData.id;
QList<HsPageData> pageDatas;
if (!db->pages(pageDatas) || pageDatas.empty()) {
return false;
}
+ if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
+ mWallpaper = new HsSceneWallpaper(this);
+ }
+
foreach (HsPageData pageData, pageDatas) {
HsPage *page = new HsPage;
page->setDatabaseId(pageData.id);
@@ -84,35 +85,17 @@
delete page;
continue;
}
- if (pageData.id == HsConfiguration::defaultPageId()) {
+ if (pageData.id == HSCONFIGURATION_GET(defaultPageId)) {
mActivePage = page;
mActivePage->setRemovable(false);
}
}
-
- QApplication::instance()->installEventFilter(this);
-
+
return true;
}
/*!
- Calculate maximum and minimum widget sizes
-*/
-void HsScene::calculateWidgetSizeLimitations()
-{
- // 1un = 6.7px = 2mm
- mMaximumWidgetSizeInUnits = QSizeF(HsConfiguration::maximumWidgetWidth(),
- HsConfiguration::maximumWidgetHeight());
- mMinimumWidgetSizeInUnits = QSizeF(HsConfiguration::minimumWidgetWidth(),
- HsConfiguration::minimumWidgetHeight());
- HbDeviceProfile profile;
- qreal unitToPixelFactor = profile.unitValue();
- mMaximumWidgetSizeInPixels = unitToPixelFactor * mMaximumWidgetSizeInUnits;
- mMinimumWidgetSizeInPixels = unitToPixelFactor * mMinimumWidgetSizeInUnits;
-}
-
-/*!
- Return wallpaper.
+ Return wallpaper.
*/
HsWallpaper *HsScene::wallpaper() const
{
@@ -126,7 +109,7 @@
{
return mPages;
}
-
+
/*!
Add page \a page.
*/
@@ -135,13 +118,13 @@
if (!page) {
return false;
}
-
+
if (mPages.contains(page)) {
return true;
}
HsDatabase *db = HsDatabase::instance();
-
+
HsPageData data;
data.id = page->databaseId();
if (!db->page(data)) {
@@ -160,13 +143,13 @@
return false;
}
}
-
+
db->commit();
-
+
mPages.insert(addPosition, page);
return true;
}
-
+
/*!
Removes page \a page.
*/
@@ -205,7 +188,7 @@
mPages.removeOne(page);
return true;
}
-
+
/*!
Set active page \a page.
*/
@@ -214,7 +197,7 @@
if (!page) {
return false;
}
-
+
if (!mPages.contains(page)) {
return false;
}
@@ -264,53 +247,13 @@
}
/*!
- Return maximum number of pages.
-*/
-int HsScene::maximumPageCount() const
-{
- return mMaximumPageCount;
-}
-
-/*!
- Return maximum widget size in pixels.
-*/
-QSizeF HsScene::maximumWidgetSizeInPixels() const
-{
- return mMaximumWidgetSizeInPixels;
-}
-
-/*!
- Return minimum widget size in pixels.
-*/
-QSizeF HsScene::minimumWidgetSizeInPixels() const
-{
- return mMinimumWidgetSizeInPixels;
-}
-
-/*!
- Return maximum widget size in units.
-*/
-QSizeF HsScene::maximumWidgetSizeInUnits() const
-{
- return mMaximumWidgetSizeInUnits;
-}
-
-/*!
- Return minimum widget size in units.
-*/
-QSizeF HsScene::minimumWidgetSizeInUnits() const
-{
- return mMinimumWidgetSizeInUnits;
-}
-
-/*!
Set active widget \a widget.
*/
void HsScene::setActiveWidget(HsWidgetHost *widget)
{
mActiveWidget = widget;
}
-
+
/*!
Return active widget.
*/
@@ -319,7 +262,7 @@
return mActiveWidget;
}
/*!
- Toggle application online state. Defaults
+ Toggle application online state. Defaults
to true.
*/
void HsScene::setOnline(bool online)
@@ -339,17 +282,28 @@
}
/*!
- Singleton.
+ Singleton.
*/
HsScene *HsScene::instance()
{
- if (!mInstance) {
- mInstance = new HsScene;
- mInstance->setParent(HsScene::mainWindow());
- }
return mInstance;
}
+HsScene *HsScene::takeInstance()
+{
+ HsScene *instance = mInstance;
+ mInstance = 0;
+ return instance;
+}
+
+void HsScene::setInstance(HsScene *instance)
+{
+ if (mInstance != instance) {
+ delete mInstance;
+ mInstance = instance;
+ }
+}
+
/*!
Return main window.
*/
@@ -389,18 +343,12 @@
*/
HsScene::HsScene(QObject *parent)
: QObject(parent),
- mDatabaseId(-1),
- mWallpaper(0),
+ mDatabaseId(-1),
+ mWallpaper(0),
mActivePage(0),
mActiveWidget(0),
- mIsOnline(true),
- mMaximumPageCount(1),
- mMaximumWidgetSizeInPixels(321.6, 261.3),
- mMinimumWidgetSizeInPixels(58.625, 58.625),
- mMaximumWidgetSizeInUnits(48, 39),
- mMinimumWidgetSizeInUnits(8.75, 8.75)
+ mIsOnline(true)
{
- mWallpaper = new HsWallpaper;
}
/*!