|
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 #include <QtGui> |
|
19 #include <QStandardItemModel> |
|
20 |
|
21 #include <hbapplication.h> |
|
22 #include <hbmainwindow.h> |
|
23 #include <hbmenu.h> |
|
24 #include <hbview.h> |
|
25 #include <hbmainwindow.h> |
|
26 #include <hbaction.h> |
|
27 #include <hbgridview.h> |
|
28 |
|
29 #include "caservice.h" |
|
30 #include "caentry.h" |
|
31 #include "caquery.h" |
|
32 |
|
33 QStandardItemModel *populateModel() |
|
34 { |
|
35 QStandardItemModel *result = new QStandardItemModel(); |
|
36 |
|
37 |
|
38 QList<QStandardItem *> items; |
|
39 |
|
40 for (int i = 0; i < 10; ++i) { |
|
41 //items << new QStandardItem(QString("Item %1").arg(i+1)); |
|
42 } |
|
43 QSharedPointer<CaService> service = CaService::instance(); |
|
44 |
|
45 //QList<CaEntry*> entryList = service->getEntries(QList<int>() << 1 << 3 << 4); |
|
46 CaQuery query; |
|
47 query.setParentId(2); |
|
48 QList< QSharedPointer<CaEntry> > entryList = service->getEntries(query); |
|
49 foreach(QSharedPointer<CaEntry> entry, entryList) { |
|
50 items << new QStandardItem(entry->makeIcon(), entry->text()); |
|
51 } |
|
52 result->appendColumn(items); |
|
53 |
|
54 return result; |
|
55 } |
|
56 |
|
57 |
|
58 int main(int argc, char *argv[]) |
|
59 { |
|
60 // Each Orbit UI application needs to instantiate HbApplication. |
|
61 // It is the core part of an Orbit UI application. |
|
62 // Note: HbApplication is a specialisation of Qt's QApplication |
|
63 // so your Orbit application does not need to instantiate a |
|
64 // QApplication as well. |
|
65 HbApplication app(argc, argv); |
|
66 |
|
67 // HbMainWindow contains all your application's screen elements |
|
68 // such as widgets and views. |
|
69 // Also, the decorators that make up the standard Orbit UI style |
|
70 // (e.g. indicators, softkeys, menus) are automatically created |
|
71 // when this class is instantiated. |
|
72 HbMainWindow mainWindow; |
|
73 |
|
74 |
|
75 |
|
76 HbGridView *grid = new HbGridView(); |
|
77 grid->setParent(&app); |
|
78 |
|
79 //QStandardItemModel* model = populateModel; |
|
80 grid->setModel(populateModel()); |
|
81 |
|
82 HbView *view = new HbView(); |
|
83 view->setParent(&app); |
|
84 view->setTitle("Test CA app"); |
|
85 view->setWidget(grid); |
|
86 |
|
87 // Add the label widget to the HbMainWindow as a view. |
|
88 mainWindow.addView(view); |
|
89 |
|
90 HbMenu *menu = new HbMenu(); |
|
91 menu->addAction(QString("Exit application"), qApp, SLOT(quit())); |
|
92 mainWindow.currentView()->setMenu(menu); |
|
93 |
|
94 // Show the current view. There is only one view which happens to contain |
|
95 // only a single widget, i.e. the label with the "Hello World" text, so |
|
96 // that is what will be shown. |
|
97 mainWindow.show(); |
|
98 |
|
99 // Start the standard Qt application event processing loop. |
|
100 // In this application the only possible user interaction is to |
|
101 // press the "back" button that was automatically added to |
|
102 // the HbMainWindow. |
|
103 return app.exec(); |
|
104 } |