phonesettings/cpphonesettingsplugins/telephonyplugin/src/cptelephonypluginview.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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 #include "cptelephonypluginview.h"
       
    19 #include "cppluginlogging.h"
       
    20 #include <QPluginLoader>
       
    21 #include <hbdataformmodel.h>
       
    22 #include <cpplugininterface.h>
       
    23 #include <cpsettingformitemdata.h>
       
    24 #include <cpitemdatahelper.h>
       
    25 #include <cppluginutility.h>
       
    26 #include <cppluginloader.h>
       
    27 
       
    28 
       
    29 /*!
       
    30     CpTelephonyPluginView::CpTelephonyPluginView()
       
    31 */
       
    32 CpTelephonyPluginView::CpTelephonyPluginView() : 
       
    33     CpBaseSettingView(0,0),
       
    34     m_helper(NULL)
       
    35 {
       
    36     DPRINT << ": IN";
       
    37     
       
    38     HbDataForm *form = qobject_cast<HbDataForm*>(widget());
       
    39     if (form) {
       
    40         HbDataFormModel *model = new HbDataFormModel;
       
    41         form->setHeading(hbTrId("txt_phone_subhead_telephone"));
       
    42         // Create and initialize plugin's item data helper
       
    43         m_helper = initializeItemDataHelper(); 
       
    44         QList<CpSettingFormItemData*> items;
       
    45         
       
    46         // Load calls plugin
       
    47         DPRINT << ": Loading cpcallsplugin";
       
    48         items.append(groupItemFromPlugin("cpcallsplugin"));
       
    49         
       
    50         // Load diverts plugin
       
    51         DPRINT << ": Loading cpdivertsplugin";
       
    52         items.append(groupItemFromPlugin("cpdivertplugin"));
       
    53         
       
    54         // Load call mailboxes plugin
       
    55         DPRINT << ": Loading vmbxcpplugin";
       
    56         items.append(groupItemFromPlugin("vmbxcpplugin"));
       
    57 
       
    58         // Load barring plugin
       
    59         DPRINT << ": Loading cpbarringplugin";
       
    60         items.append(groupItemFromPlugin("cpbarringplugin"));
       
    61         
       
    62         // Insert items to form model
       
    63         foreach (CpSettingFormItemData* i, items) {
       
    64             model->appendDataFormItem(i);
       
    65         }
       
    66         
       
    67         form->setModel(model);
       
    68     }
       
    69     
       
    70     DPRINT << ": OUT";
       
    71 }
       
    72 
       
    73 /*!
       
    74     CpTelephonyPluginView::~CpTelephonyPluginView()
       
    75 */
       
    76 CpTelephonyPluginView::~CpTelephonyPluginView()
       
    77 {
       
    78     DPRINT << ": IN";
       
    79     
       
    80     delete m_helper;
       
    81     
       
    82     DPRINT << ": OUT";
       
    83 }
       
    84 
       
    85 /*!
       
    86     CpTelephonyPluginView::groupItemFromPlugin()
       
    87 */
       
    88 QList<CpSettingFormItemData*> CpTelephonyPluginView::groupItemFromPlugin( const QString& plugin )
       
    89 {
       
    90     DPRINT << ": IN";
       
    91  
       
    92     QList<CpSettingFormItemData*> items;
       
    93     CpPluginInterface *p(NULL);
       
    94     try {
       
    95         p = CpPluginLoader::loadCpPlugin(plugin);
       
    96         if (p && m_helper){
       
    97             items = p->createSettingFormItemData(*m_helper);
       
    98         }
       
    99     } catch(...) {
       
   100         DPRINT << "CATCH ERROR";
       
   101         delete p;
       
   102     }
       
   103     
       
   104     DPRINT << ": OUT";
       
   105     return items;
       
   106 }
       
   107 
       
   108 /*!
       
   109     CpTelephonyPluginView::initializeItemDataHelper()
       
   110 */
       
   111 CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper()
       
   112 {
       
   113     DPRINT;
       
   114     return new CpItemDataHelper(qobject_cast<HbDataForm*>(widget()));
       
   115 }
       
   116 
       
   117 // End of File.