controlpanelui/src/cpplugins/profileactivatorplugin/src/cpprofileactivatorentryitem.cpp
branchRCL_3
changeset 14 5f281e37a2f5
parent 13 90fe62538f66
equal deleted inserted replaced
13:90fe62538f66 14: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 #include "cpprofileactivatorentryitem.h"
       
    18 
       
    19 #include "cpprofileactivatordialog.h"
       
    20 #include <cpitemdatahelper.h>
       
    21 #include <cpprofilemodel.h>
       
    22 #include <QScopedPointer>
       
    23 #include <cpprofilemonitor.h>
       
    24 
       
    25 CpProfileActivatorEntryItem::CpProfileActivatorEntryItem(CpItemDataHelper &itemDataHelper,
       
    26                 const QString &text,
       
    27                 const QString &description,
       
    28                 const QString &icon,
       
    29                 const HbDataFormModelItem *parent)
       
    30                 :CpSettingFormEntryItemData(CpSettingFormEntryItemData::ListEntryItem, itemDataHelper,text,description,
       
    31                                             icon,parent),mProfileModel(0),mProfileMonitor(0)
       
    32 {
       
    33     mProfileMonitor = new CpProfileMonitor();
       
    34     mProfileModel = new CpProfileModel();
       
    35     
       
    36     int currentId = mProfileModel->activeProfileId();
       
    37     QString currentName = mProfileModel->profileName(currentId);
       
    38     this->setDescription(currentName);
       
    39     connect(mProfileMonitor, SIGNAL(profileActivated(int)), this, SLOT(onProfileChanged(int)));        
       
    40 }
       
    41 
       
    42 CpProfileActivatorEntryItem::~CpProfileActivatorEntryItem()
       
    43 {
       
    44     delete mProfileModel;
       
    45     delete mProfileMonitor;
       
    46 }
       
    47 
       
    48 void CpProfileActivatorEntryItem::onLaunchView()
       
    49 {
       
    50     CpProfileActivatorDialog *dialog = 
       
    51         new CpProfileActivatorDialog(this, *mProfileModel);
       
    52     dialog->setAttribute(Qt::WA_DeleteOnClose);
       
    53    // dialog->open(this, SLOT(ultimateDialogSlot(HbAction*)));
       
    54     dialog->show();
       
    55     
       
    56 }
       
    57 
       
    58 void CpProfileActivatorEntryItem::onProfileChanged(int activeProfileId)
       
    59 {
       
    60     QString profileName = mProfileModel->profileName(activeProfileId);
       
    61     this->setDescription(profileName);    
       
    62 }
       
    63 /*void CpPersonalizationEntryItemData::handleOk(const QVariant &result)
       
    64 {
       
    65     if (!result.canConvert<QString>())
       
    66     {
       
    67         setDescription( "Corrupt result" );
       
    68     }
       
    69     else
       
    70     {
       
    71         setDescription( result.value<QString>() );
       
    72     }
       
    73 }
       
    74 void CpPersonalizationEntryItemData::handleError(int errorCode, const QString& errorMessage)
       
    75 {
       
    76     //
       
    77     Q_UNUSED(errorCode);
       
    78     Q_UNUSED(errorMessage);
       
    79     setDescription("Error");
       
    80 }*/
       
    81 
       
    82 CpBaseSettingView *CpProfileActivatorEntryItem::createSettingView() const
       
    83 {
       
    84         return 0;
       
    85 }