|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HSDATABASE_H |
|
19 #define HSDATABASE_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <QVariantHash> |
|
23 |
|
24 #include "hsdomainmodel_global.h" |
|
25 #include "hstest_global.h" |
|
26 |
|
27 HOMESCREEN_TEST_CLASS(TestHsDomainModel) |
|
28 |
|
29 class HsSceneData; |
|
30 class HsPageData; |
|
31 class HsWidgetData; |
|
32 class HsWidgetPresentationData; |
|
33 |
|
34 class HSDOMAINMODEL_EXPORT HsDatabase : public QObject |
|
35 { |
|
36 Q_OBJECT |
|
37 Q_PROPERTY(QString connectionName READ connectionName WRITE setConnectionName) |
|
38 Q_PROPERTY(QString databaseName READ databaseName WRITE setDatabaseName) |
|
39 |
|
40 public: |
|
41 HsDatabase(QObject *parent = 0); |
|
42 ~HsDatabase(); |
|
43 |
|
44 void setConnectionName(const QString &name); |
|
45 QString connectionName() const; |
|
46 void setDatabaseName(const QString &name); |
|
47 QString databaseName() const; |
|
48 |
|
49 bool open(); |
|
50 void close(); |
|
51 |
|
52 bool transaction(); |
|
53 bool rollback(); |
|
54 bool commit(); |
|
55 |
|
56 bool scene(HsSceneData &data); |
|
57 |
|
58 bool pages(QList<HsPageData> &data); |
|
59 bool page(HsPageData &data); |
|
60 bool insertPage(HsPageData &data); |
|
61 bool updatePage(const HsPageData &data); |
|
62 bool deletePage(int id); |
|
63 |
|
64 bool widgets(int pageId, QList<HsWidgetData> &data); |
|
65 bool widgets(const QString &uri, QList<HsWidgetData> &data); |
|
66 bool widgets(const QString &uri, const QVariantHash &preferences, int &count); |
|
67 bool widget(HsWidgetData &data); |
|
68 bool insertWidget(HsWidgetData &data); |
|
69 bool updateWidget(const HsWidgetData &data); |
|
70 bool deleteWidget(int id); |
|
71 bool deleteWidgets(const QString &uri); |
|
72 |
|
73 bool widgetPresentation(HsWidgetPresentationData &data); |
|
74 bool setWidgetPresentation(const HsWidgetPresentationData &data); |
|
75 bool deleteWidgetPresentation(int widgetId, Qt::Orientation orientation); |
|
76 |
|
77 bool widgetPreferences(int widgetId, QVariantHash &data); |
|
78 bool widgetPreference(int widgetId, const QString &key, QVariant &value); |
|
79 bool setWidgetPreferences(int widgetId, const QVariantHash &data); |
|
80 |
|
81 bool configuration(QVariantHash &configuration); |
|
82 |
|
83 bool updateWidgetZValues(const QHash<int, qreal> &data, Qt::Orientation orientation); |
|
84 |
|
85 public: |
|
86 static void setInstance(HsDatabase *instance); |
|
87 static HsDatabase *instance(); |
|
88 static HsDatabase *takeInstance(); |
|
89 |
|
90 private: |
|
91 Q_DISABLE_COPY(HsDatabase) |
|
92 bool checkConnection() const; |
|
93 bool matchWidgetPreferences(const QVariantHash &preferences, const QMultiMap<QString, QString>& storedPreferences); |
|
94 |
|
95 private: |
|
96 QString mConnectionName; |
|
97 QString mDatabaseName; |
|
98 |
|
99 static HsDatabase *mInstance; |
|
100 HOMESCREEN_TEST_FRIEND_CLASS(TestHsDomainModel) |
|
101 }; |
|
102 |
|
103 #endif // HSDATABASE_H |