controlpanelplugins/themeplugin/src/cpthemelistview.cpp
changeset 31 e79ce701c376
parent 24 f5dfdd5e4a1b
child 37 cb294e641644
equal deleted inserted replaced
25:19394c261aa5 31:e79ce701c376
    18 
    18 
    19 #include <QGraphicsLinearLayout>
    19 #include <QGraphicsLinearLayout>
    20 #include <QModelIndex>
    20 #include <QModelIndex>
    21 
    21 
    22 #include <hbview.h>
    22 #include <hbview.h>
    23 #include <hblabel.h>
       
    24 #include <hblistview.h>
    23 #include <hblistview.h>
    25 #include <hblistviewitem.h>
    24 #include <hblistviewitem.h>
       
    25 #include <hbdataform.h>
    26 
    26 
    27 #include "cpthemelistview.h"
    27 #include "cpthemelistview.h"
    28 
    28 
    29 /*!
    29 /*!
    30     \class CpThemeListView
    30     \class CpThemeListView
    31     \brief CpThemeListView displays a heading (Select theme) and a list of themes with
    31     \brief CpThemeListView displays a heading (Select theme) and a list of themes with
    32     corresponding icons.
    32     corresponding icons.
    33 
    33 
    34     Note: This class is a subclass of CpBaseSettingView for compatibility with Control Panel
    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
    35           framework.  
    36           it uses SetWidget to set the listview to its widget instead of an HbDataForm.
       
    37  */
    36  */
    38 
    37 
    39 /*!
    38 /*!
    40     constructor.  Creates the heading label and the list and adds it to layout.
    39     constructor.  Creates the heading label and the list and adds it to layout.
    41 */
    40 */
    42 CpThemeListView::CpThemeListView(QGraphicsItem *parent) : CpBaseSettingView(0, parent),
    41 CpThemeListView::CpThemeListView(QGraphicsItem *parent) : CpBaseSettingView(0, parent),
    43     mThemeList(new HbListView(this))
    42     mThemeList(new HbListView(this))
    44 {
    43 {
    45 
    44    
       
    45     
    46     //Create a layout with a heading "Select theme" at top and the list below it.
    46     //Create a layout with a heading "Select theme" at top and the list below it.
    47     HbWidget* contentWidget = new HbWidget(this);
    47     HbWidget* contentWidget = new HbWidget(this);
    48     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
    48     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    49     layout->setContentsMargins(0,0,0,0);
    49     
    50     
    50     //setup the heading.
    51     //setup the heading.
    51     HbLabel* label = new HbLabel(hbTrId("txt_cp_title_select_theme"), contentWidget);//txt_cp_title_select_theme
    52     //Using an empty dataform as heading because the heading should
    52     layout->addItem(label);
    53     //look like an HbDataForm headiing.
    53 
    54     HbDataForm *form = new HbDataForm(contentWidget);
    54     connect(mThemeList, SIGNAL(activated(const QModelIndex&)),
    55     form->setHeading(hbTrId("txt_cp_title_select_theme"));
    55             this, SIGNAL(newThemeSelected(const QModelIndex&)));
    56         
       
    57     layout->addItem(form);
       
    58     //Fixed vertical policy so that the heading doesn't expand.
       
    59     form->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed, QSizePolicy::DefaultType);
       
    60       
       
    61     connect(mThemeList, SIGNAL(activated(QModelIndex)),
       
    62             this, SIGNAL(newThemeSelected(QModelIndex)));
    56     
    63     
       
    64     //set list item icons to be large.
    57     HbListViewItem* listViewItem = mThemeList->listItemPrototype();
    65     HbListViewItem* listViewItem = mThemeList->listItemPrototype();
    58     listViewItem->setGraphicsSize(HbListViewItem::LargeIcon);
    66     listViewItem->setGraphicsSize(HbListViewItem::LargeIcon);
    59    
    67    
    60     //add the list to layout.
    68     //add the list to layout.
    61     layout->addItem(mThemeList);
    69     layout->addItem(mThemeList);
    62 
    70     layout->addStretch();
       
    71     
       
    72     
    63     contentWidget->setLayout(layout);
    73     contentWidget->setLayout(layout);
    64    
    74    
    65     setWidget(contentWidget);
    75     setWidget(contentWidget);
    66 }
    76 }
    67 
    77