|
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 "simpleview.h" |
|
19 |
|
20 #include <hbview.h> |
|
21 #include <hblabel.h> |
|
22 #include <hbmenu.h> |
|
23 #include <hbaction.h> |
|
24 #include <hbpusHbutton.h> |
|
25 |
|
26 #include <QSizePolicy> |
|
27 #include <QSignalMapper> |
|
28 #include <QGraphicsGridLayout> |
|
29 |
|
30 SimpleView::SimpleView(const QString &name) |
|
31 : |
|
32 HbView() |
|
33 { |
|
34 setObjectName(name); |
|
35 setTitle(name); |
|
36 mapper = new QSignalMapper(this); |
|
37 mapper->setParent(this); |
|
38 |
|
39 setTitle(title()); |
|
40 QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
41 |
|
42 QGraphicsGridLayout *layout = new QGraphicsGridLayout(); |
|
43 |
|
44 label = new HbLabel(); |
|
45 label->setSizePolicy(policy); |
|
46 layout->addItem(label, 7, 1, 3, 1); |
|
47 |
|
48 connect(mapper, SIGNAL(mapped(int)), this, SLOT(setLabelText(int))); |
|
49 |
|
50 bool result = false; |
|
51 |
|
52 } |
|
53 |
|
54 SimpleView::~SimpleView() |
|
55 { |
|
56 } |
|
57 |
|
58 bool SimpleView::connectButton(HbPushButton *button, int commandId) |
|
59 { |
|
60 bool result = connect(button, SIGNAL(clicked()), mapper, SLOT(map())); |
|
61 if (result) { |
|
62 mapper->setMapping(button, commandId); |
|
63 } |
|
64 return result; |
|
65 } |
|
66 |
|
67 void SimpleView::setLabelText(int commandId) |
|
68 { |
|
69 QString ltext("command id: %1"); |
|
70 label->setText(ltext.arg(commandId)); |
|
71 } |
|
72 |