controlpanelplugins/themeplugin/src/cpthemelistview.cpp
branchRCL_3
changeset 35 5f281e37a2f5
parent 34 90fe62538f66
child 46 ed95320285d0
equal deleted inserted replaced
34:90fe62538f66 35:5f281e37a2f5
     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 
       
    19 #include <QGraphicsLinearLayout>
       
    20 #include <QModelIndex>
       
    21 
       
    22 #include <hbview.h>
       
    23 #include <hblistview.h>
       
    24 #include <hblistviewitem.h>
       
    25 #include <hbtoolbar.h>
       
    26 #include <hbaction.h>
       
    27 #include <hbgroupbox.h>
       
    28 
       
    29 
       
    30 #include "cpthemelistview.h"
       
    31 
       
    32 /*!
       
    33     \class CpThemeListView
       
    34     \brief CpThemeListView displays a heading (e.g Theme) and a list of themes with
       
    35     corresponding icons.
       
    36 
       
    37     Note: This class is a subclass of CpBaseSettingView for compatibility with Control Panel
       
    38           framework.  
       
    39  */
       
    40 
       
    41 /*!
       
    42     constructor.  Creates the heading label and the list and adds it to layout.
       
    43 */
       
    44 CpThemeListView::CpThemeListView(QGraphicsItem *parent) : CpBaseSettingView(0, parent),
       
    45     mThemeList(new HbListView(this))
       
    46 {
       
    47    
       
    48     //Create a layout with a heading at top and the list below it.
       
    49     HbWidget* contentWidget = new HbWidget(this);
       
    50     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    51     layout->setContentsMargins(0,0,0,0);
       
    52     
       
    53     //setup the heading.
       
    54     HbGroupBox *simpleLabel = new HbGroupBox();
       
    55     simpleLabel->setHeading(hbTrId("txt_cp_title_select_theme"));
       
    56      
       
    57     layout->addItem(simpleLabel);
       
    58       
       
    59     connect(mThemeList, SIGNAL(activated(QModelIndex)),
       
    60             this, SIGNAL(newThemeSelected(QModelIndex)));
       
    61     
       
    62     //set list item icons to be large.
       
    63     HbListViewItem* listViewItem = mThemeList->listItemPrototype();
       
    64     listViewItem->setGraphicsSize(HbListViewItem::LargeIcon);
       
    65     //set singleSelection to enable showing an indicator (e.g check mark) next to active theme.
       
    66     mThemeList->setSelectionMode(HbAbstractItemView::SingleSelection);
       
    67   
       
    68     //add the list to layout.
       
    69     layout->addItem(mThemeList);
       
    70     
       
    71     //Create the toolbar for Ovi Store.
       
    72     HbToolBar* toolBar = new HbToolBar(this);
       
    73 
       
    74     HbAction* oviAction = new HbAction(HbIcon("qtg_large_ovistore"), hbTrId("txt_cp_list_get_more_tones"));
       
    75     QObject::connect( oviAction, SIGNAL(triggered()), 
       
    76                           this, SIGNAL(oviClicked()));
       
    77        
       
    78     //Add Action to the toolbar and show toolbar
       
    79     toolBar->addAction(oviAction);
       
    80        
       
    81     setToolBar(toolBar);
       
    82 
       
    83     contentWidget->setLayout(layout);
       
    84    
       
    85     setWidget(contentWidget);
       
    86    
       
    87 }
       
    88 
       
    89 /*!
       
    90     destructor.
       
    91 */
       
    92 CpThemeListView::~CpThemeListView()
       
    93 {
       
    94 }
       
    95 
       
    96 /*!
       
    97     returns the listview instance (list of themes).
       
    98 */
       
    99 HbListView* CpThemeListView::themeList() const
       
   100 {
       
   101     return mThemeList;
       
   102 }
       
   103 
       
   104 /*!
       
   105     Sets the model of its listView.
       
   106 */
       
   107 void CpThemeListView::setModel(QAbstractItemModel* model)
       
   108 {
       
   109     mThemeList->setModel(model);
       
   110 }
       
   111 
       
   112 /*!
       
   113     sets the widget. Reimplementation from HbView. 
       
   114 */
       
   115 void CpThemeListView::setWidget(QGraphicsWidget *widget)
       
   116 {
       
   117     HbView::setWidget(widget);
       
   118 }
       
   119 
       
   120 /*!
       
   121     emits aboutToClose() signal.
       
   122 */
       
   123 void CpThemeListView::closeView()
       
   124 {
       
   125     emit aboutToClose();
       
   126 }
       
   127 
       
   128