cmmanager/cpipsettingsplugin/src/cpipsettingsview.cpp
changeset 20 9c97ad6591ae
child 23 7ec726f93df1
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2010 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 // System includes
       
    19 #include <QtCore>
       
    20 #include <HbDataForm>
       
    21 #include <HbDataFormModel>
       
    22 #include <cpplugininterface.h>
       
    23 #include <cpsettingformitemdata.h>
       
    24 #include <cpitemdatahelper.h>
       
    25 
       
    26 // User includes
       
    27 #include "cpipsettingsview.h"
       
    28 
       
    29 /*!
       
    30     \class CpIpSettingsView
       
    31     \brief Class implements the "Network Settings" Control Panel view.
       
    32 */
       
    33 
       
    34 // External function prototypes
       
    35 
       
    36 // Local constants
       
    37 static const QString ipSettingsPlugins[] = {
       
    38     "cpwlansettingsplugin.qtplugin",
       
    39     "cpdestinationplugin.qtplugin",
       
    40     "cpvpnmanagementplugin.qtplugin",
       
    41     "" // empty item terminates the list
       
    42 };
       
    43 
       
    44 // ======== LOCAL FUNCTIONS ========
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 /*!
       
    49     Constructor.
       
    50 */
       
    51 CpIpSettingsView::CpIpSettingsView(QGraphicsItem *parent) :
       
    52     CpBaseSettingView(0, parent)
       
    53 {
       
    54     HbDataForm *form = settingForm();
       
    55     if (form) {
       
    56         HbDataFormModelItem *modelItem;
       
    57         CpPluginInterface *plugin = NULL;
       
    58         QDir pluginsDir("\\resource\\qt\\plugins\\controlpanel");
       
    59         QPluginLoader pluginLoader;
       
    60 
       
    61         HbDataFormModel *model = new HbDataFormModel;
       
    62 
       
    63         mItemDataHelper = new CpItemDataHelper();
       
    64         mItemDataHelper->setParent(this);
       
    65         
       
    66         // Load listed child plugins
       
    67         for (int i = 0; !ipSettingsPlugins[i].isEmpty(); i++) {
       
    68             pluginLoader.setFileName(pluginsDir.absoluteFilePath(ipSettingsPlugins[i]));
       
    69             plugin = qobject_cast<CpPluginInterface *>(pluginLoader.instance());
       
    70             if (plugin) {
       
    71                 QList<CpSettingFormItemData*> formDataItemList =
       
    72                     plugin->createSettingFormItemData(*mItemDataHelper);
       
    73                 for (int j = 0; j < formDataItemList.count(); j++) {
       
    74                     modelItem = formDataItemList.at(j);
       
    75                     if (modelItem) {
       
    76                         model->appendDataFormItem(modelItem);
       
    77                     }
       
    78                 }
       
    79             }
       
    80         }
       
    81 
       
    82         form->setModel(model);
       
    83         model->setParent(form);
       
    84         mItemDataHelper->bindToForm(form);
       
    85     }
       
    86 }
       
    87 
       
    88 /*!
       
    89     Destructor.
       
    90 */
       
    91 CpIpSettingsView::~CpIpSettingsView()
       
    92 {
       
    93 }