|
1 /* |
|
2 * Copyright (c) 2008-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 |
|
19 |
|
20 #include <QGraphicsLinearLayout> |
|
21 #include <QModelIndex> |
|
22 |
|
23 #include <hbview> |
|
24 #include <hblabel.h> |
|
25 #include <hblistview.h> |
|
26 |
|
27 #include "cpthemelistview.h" |
|
28 |
|
29 /*! |
|
30 \class CpThemeListView |
|
31 \brief CpThemeListView displays a heading (Select theme) and a list of themes with |
|
32 corresponding icons. |
|
33 |
|
34 Note: This class is a subclass of CpBaseSettingView for compatibility with Control Panel |
|
35 framework. However, it does not use HbDataForm as its widget and as its parent does, so |
|
36 it uses SetWidget to set the listview to its widget instead of an HbDataForm. |
|
37 */ |
|
38 |
|
39 /*! |
|
40 constructor. Creates the heading label and the list and adds it to layout. |
|
41 */ |
|
42 CpThemeListView::CpThemeListView(QGraphicsItem *parent) : CpBaseSettingView(0, parent), |
|
43 mThemeList(new HbListView(this)) |
|
44 { |
|
45 |
|
46 //Create a layout with a heading "Select theme" at top and the list below it. |
|
47 HbWidget* contentWidget = new HbWidget(this); |
|
48 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
49 |
|
50 |
|
51 |
|
52 //setup the heading. |
|
53 HbLabel* label = new HbLabel(hbTrId("txt_cp_title_select_theme"), contentWidget); |
|
54 label->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
55 layout->addItem(label); |
|
56 |
|
57 connect(mThemeList, SIGNAL(activated(const QModelIndex&)), |
|
58 this, SIGNAL(newThemeSelected(const QModelIndex&))); |
|
59 |
|
60 //add the list to layout. |
|
61 layout->addItem(mThemeList); |
|
62 |
|
63 contentWidget->setLayout(layout); |
|
64 |
|
65 setWidget(contentWidget); |
|
66 } |
|
67 |
|
68 /*! |
|
69 destructor. |
|
70 */ |
|
71 CpThemeListView::~CpThemeListView() |
|
72 { |
|
73 } |
|
74 |
|
75 /*! |
|
76 returns the listview instance (list of themes). |
|
77 */ |
|
78 HbListView* CpThemeListView::themeList() const |
|
79 { |
|
80 return mThemeList; |
|
81 } |
|
82 |
|
83 /*! |
|
84 Sets the model of its listView. |
|
85 */ |
|
86 void CpThemeListView::setModel(QAbstractItemModel* model) |
|
87 { |
|
88 mThemeList->setModel(model); |
|
89 } |
|
90 |
|
91 /*! |
|
92 sets the widget. Reimplementation from HbView. |
|
93 */ |
|
94 void CpThemeListView::setWidget(QGraphicsWidget *widget) |
|
95 { |
|
96 HbView::setWidget(widget); |
|
97 } |
|
98 |
|
99 /*! |
|
100 emits aboutToClose() signal. |
|
101 */ |
|
102 void CpThemeListView::closeView() |
|
103 { |
|
104 emit aboutToClose(); |
|
105 } |
|
106 |
|
107 |