controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatordialog.cpp
changeset 21 2883a5458389
parent 19 36aa4756ee82
child 33 0cfa53de576f
equal deleted inserted replaced
20:22d3abee08da 21:2883a5458389
    18 
    18 
    19 #include <hbradiobuttonlist.h>
    19 #include <hbradiobuttonlist.h>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hbdataformmodelitem.h>
    21 #include <hbdataformmodelitem.h>
    22 #include <hbpopup.h>
    22 #include <hbpopup.h>
       
    23 #include <hblabel.h>
    23 #include "cpprofileactivatorentryitem.h"
    24 #include "cpprofileactivatorentryitem.h"
       
    25 #include <QGraphicsLinearLayout>
       
    26 #include <QGraphicsWidget>
       
    27 
    24 CpProfileActivatorDialog::CpProfileActivatorDialog(CpSettingFormItemData *profileActivator,
    28 CpProfileActivatorDialog::CpProfileActivatorDialog(CpSettingFormItemData *profileActivator,
    25                                                     CpProfileModel &profileModel,
    29                                                     CpProfileModel &profileModel,
    26                                                     QGraphicsItem *parent):HbDialog(parent),
    30                                                     QGraphicsItem *parent):HbDialog(parent),
    27                                                      mProfileModel(profileModel),
    31                                                      mProfileModel(profileModel),
    28                                                      mProfileList(0),
    32                                                      mProfileList(0),
    29                                                      mProfileActivator(profileActivator)
    33                                                      mProfileActivator(profileActivator)
    30 {
    34 {
       
    35     mTitleLabel = new HbLabel(this);
       
    36     mTitleLabel->setPlainText(hbTrId("txt_cp_title_profile"));
       
    37     mContentWidget = new QGraphicsWidget(this);
       
    38     setContentWidget(mContentWidget);
       
    39     mLayout = new QGraphicsLinearLayout();
       
    40     mLayout->setOrientation( Qt::Vertical );
    31     mProfileIds << EProfileWrapperGeneralId
    41     mProfileIds << EProfileWrapperGeneralId
    32                 << EProfileWrapperMeetingId;
    42                 << EProfileWrapperMeetingId;
    33     mProfileList = new HbRadioButtonList();
    43     mProfileList = new HbRadioButtonList();
    34     mProfileList->setItems(profileModel.profileNames());
    44     mProfileList->setItems(profileModel.profileNames());
    35     
    45     mLayout->addItem(mTitleLabel);
       
    46     mLayout->addItem(mProfileList);
       
    47        
    36     int currentId = mProfileModel.activeProfileId();
    48     int currentId = mProfileModel.activeProfileId();
    37     mProfileList->setSelected(mProfileIds.indexOf(static_cast<ProfileWrapperProfileId>(currentId)));
    49     mProfileList->setSelected(mProfileIds.indexOf(static_cast<ProfileWrapperProfileId>(currentId)));
    38     
    50     
    39     
    51     
    40         
    52         
    44     connect(mConfirmProfile, SIGNAL(triggered(bool)), this, SLOT(confirmProfileSelection()));
    56     connect(mConfirmProfile, SIGNAL(triggered(bool)), this, SLOT(confirmProfileSelection()));
    45     connect(mCancelProfile, SIGNAL(triggered(bool)), this, SLOT(cancelProfileSelection()));
    57     connect(mCancelProfile, SIGNAL(triggered(bool)), this, SLOT(cancelProfileSelection()));
    46         
    58         
    47     
    59     
    48     this->addAction(mConfirmProfile);
    60     this->addAction(mConfirmProfile);
    49     this->addAction(mCancelProfile);
    61     this->addAction(mCancelProfile);    
    50     
       
    51     this->setContentWidget(mProfileList);
       
    52     this->setModal(true);
    62     this->setModal(true);
    53     this->setDismissPolicy(HbPopup::NoDismiss);
    63     this->setDismissPolicy(HbPopup::NoDismiss);
    54     this->setTimeout(HbPopup::NoTimeout);
    64     this->setTimeout(HbPopup::NoTimeout);
       
    65     mContentWidget->setLayout( mLayout );
    55 }
    66 }
    56 
    67 
    57 CpProfileActivatorDialog::~CpProfileActivatorDialog()
    68 CpProfileActivatorDialog::~CpProfileActivatorDialog()
    58 {
    69 {
    59     
    70     
    60 }
    71 }
    61 void CpProfileActivatorDialog::confirmProfileSelection()
    72 void CpProfileActivatorDialog::confirmProfileSelection()
    62 {
    73 {
    63     int currentIndex = mProfileList->selected();
    74     int currentIndex = mProfileList->selected();
       
    75     if (currentIndex == -1) {
       
    76         return;
       
    77     }
    64     
    78     
    65     // the best choice is no need to convert the index to id
    79     // the best choice is no need to convert the index to id
    66     mProfileModel.activateProfile(mProfileIds.at(currentIndex));
    80     mProfileModel.activateProfile(mProfileIds.at(currentIndex));
    67     // ret should be remove from here
    81     // ret should be remove from here
    68     // no invalid profile exsit
    82     // no invalid profile exsit