phonesettings/cpphonesettingsplugins/telephonyplugin/src/cptelephonypluginview.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 30 ebdbd102c78a
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cptelephonypluginview.h"
    18 
    19 #include "cppluginlogging.h"
       
    20 #include <QPluginLoader>
    19 #include <QPluginLoader>
    21 #include <hbdataformmodel.h>
    20 #include <hbdataformmodel.h>
    22 #include <cpplugininterface.h>
    21 #include <cpplugininterface.h>
    23 #include <cpsettingformitemdata.h>
    22 #include <cpsettingformitemdata.h>
    24 #include <cpitemdatahelper.h>
    23 #include <cpitemdatahelper.h>
    25 #include <cppluginutility.h>
    24 #include <cppluginutility.h>
    26 #include <cppluginloader.h>
    25 #include <cppluginloader.h>
    27 
    26 #include "cptelephonypluginview.h"
       
    27 #include "cppluginlogging.h"
    28 
    28 
    29 /*!
    29 /*!
    30     CpTelephonyPluginView::CpTelephonyPluginView()
    30     \class CpTelephonyPluginView
       
    31     \brief The class CpTelephonyPluginView 
       
    32            loads child setting plugins contained 
       
    33            in "Telephony" view.     
       
    34 */
       
    35 
       
    36 // Local constants
       
    37 const char* PLUGIN_NAME_CALLSPLUGIN = "cpcallsplugin"; 
       
    38 const char* PLUGIN_NAME_VMBXPLUGIN = "vmbxcpplugin"; 
       
    39 const char* PLUGIN_NAME_DIVERTPLUGIN = "cpdivertplugin"; 
       
    40 const char* PLUGIN_NAME_BARRINGPLUGIN = "cpbarringplugin"; 
       
    41 
       
    42 /*!
       
    43     Constructor. 
    31 */
    44 */
    32 CpTelephonyPluginView::CpTelephonyPluginView() : 
    45 CpTelephonyPluginView::CpTelephonyPluginView() : 
    33     CpBaseSettingView(0,0),
    46     CpBaseSettingView(0,0),
    34     m_helper(NULL)
    47     m_helper(NULL)
    35 {
    48 {
    41         form->setHeading(hbTrId("txt_phone_subhead_telephone"));
    54         form->setHeading(hbTrId("txt_phone_subhead_telephone"));
    42         // Create and initialize plugin's item data helper
    55         // Create and initialize plugin's item data helper
    43         m_helper = initializeItemDataHelper(); 
    56         m_helper = initializeItemDataHelper(); 
    44         QList<CpSettingFormItemData*> items;
    57         QList<CpSettingFormItemData*> items;
    45         
    58         
    46         // Load calls plugin
       
    47         DPRINT << ": Loading cpcallsplugin";
    59         DPRINT << ": Loading cpcallsplugin";
    48         items.append(groupItemFromPlugin("cpcallsplugin"));
    60         items.append(groupItemFromPlugin(
    49         
    61                 PLUGIN_NAME_CALLSPLUGIN));
    50         // Load diverts plugin
    62        // CpSettingFormItemData* expandedItem = items.last();  
       
    63 
       
    64         DPRINT << ": Loading vmbxcpplugin";
       
    65         items.append(groupItemFromPlugin(
       
    66                 PLUGIN_NAME_VMBXPLUGIN));
       
    67 
       
    68 
    51         DPRINT << ": Loading cpdivertsplugin";
    69         DPRINT << ": Loading cpdivertsplugin";
    52         items.append(groupItemFromPlugin("cpdivertplugin"));
    70         items.append(groupItemFromPlugin(
    53         
    71                 PLUGIN_NAME_DIVERTPLUGIN));
    54         // Load call mailboxes plugin
       
    55         DPRINT << ": Loading vmbxcpplugin";
       
    56         items.append(groupItemFromPlugin("vmbxcpplugin"));
       
    57 
    72 
    58         // Load barring plugin
       
    59         DPRINT << ": Loading cpbarringplugin";
    73         DPRINT << ": Loading cpbarringplugin";
    60         items.append(groupItemFromPlugin("cpbarringplugin"));
    74         items.append(groupItemFromPlugin(
       
    75                 PLUGIN_NAME_BARRINGPLUGIN));
    61         
    76         
    62         // Insert items to form model
    77         // Insert items to form model
    63         foreach (CpSettingFormItemData* i, items) {
    78         foreach (CpSettingFormItemData* i, items) {
    64             model->appendDataFormItem(i);
    79             model->appendDataFormItem(i);
    65         }
    80         }
    66         
    81         
    67         form->setModel(model);
    82         form->setModel(model);
       
    83         
       
    84         /*
       
    85         if (expandedItem) {
       
    86             QModelIndex expandedItemIndex = model->indexFromItem(expandedItem);
       
    87             
       
    88             if (expandedItemIndex.isValid()) {
       
    89                 form->setExpanded(expandedItemIndex, true);
       
    90             }
       
    91         }
       
    92         */
    68     }
    93     }
    69     
    94     
    70     DPRINT << ": OUT";
    95     DPRINT << ": OUT";
    71 }
    96 }
    72 
    97 
    73 /*!
    98 /*!
    74     CpTelephonyPluginView::~CpTelephonyPluginView()
    99     Constructor with param list. 
       
   100 */
       
   101 CpTelephonyPluginView::CpTelephonyPluginView(const QVariantList &params) :
       
   102     CpBaseSettingView(0,0),
       
   103     m_helper(NULL)
       
   104 {
       
   105     HbDataForm *form = qobject_cast<HbDataForm*>(widget());
       
   106     if (form){
       
   107         HbDataFormModel *model = new HbDataFormModel;
       
   108         form->setHeading(hbTrId("txt_phone_subhead_telephone"));
       
   109         m_helper = initializeItemDataHelper(); 
       
   110         QList<CpSettingFormItemData*> items;
       
   111         TBool expanded(false);
       
   112         CpSettingFormItemData* expandedItem(NULL);
       
   113         foreach (QVariant var, params){
       
   114             items.append(groupItemFromPlugin(var.toString()));
       
   115             if(!expanded){
       
   116                 expandedItem = items.last();
       
   117                 expanded = true;
       
   118             }
       
   119         }
       
   120         // Insert items to form model
       
   121         foreach (CpSettingFormItemData* i, items) {
       
   122             model->appendDataFormItem(i);
       
   123         }
       
   124         form->setModel(model);
       
   125         if (expandedItem) {
       
   126             QModelIndex expandedItemIndex = model->indexFromItem(expandedItem);
       
   127             
       
   128             if (expandedItemIndex.isValid()) {
       
   129                 form->setExpanded(expandedItemIndex, true);
       
   130             }
       
   131         }
       
   132     }
       
   133 }
       
   134 
       
   135 /*!
       
   136     Destructor. 
    75 */
   137 */
    76 CpTelephonyPluginView::~CpTelephonyPluginView()
   138 CpTelephonyPluginView::~CpTelephonyPluginView()
    77 {
   139 {
    78     DPRINT << ": IN";
   140     DPRINT << ": IN";
    79     
       
    80     delete m_helper;
   141     delete m_helper;
    81     
       
    82     DPRINT << ": OUT";
   142     DPRINT << ": OUT";
    83 }
   143 }
    84 
   144 
    85 /*!
   145 /*!
    86     CpTelephonyPluginView::groupItemFromPlugin()
   146     Load group item for given plugin name. 
    87 */
   147 */
    88 QList<CpSettingFormItemData*> CpTelephonyPluginView::groupItemFromPlugin( const QString& plugin )
   148 QList<CpSettingFormItemData*> CpTelephonyPluginView::groupItemFromPlugin( 
       
   149         const QString& plugin)
    89 {
   150 {
    90     DPRINT << ": IN";
   151     DPRINT << ": IN";
    91  
   152  
    92     QList<CpSettingFormItemData*> items;
   153     QList<CpSettingFormItemData*> items;
    93     CpPluginInterface *p(NULL);
   154     CpPluginInterface *p(NULL);
    94     try {
   155     try {
    95         p = CpPluginLoader::loadCpPlugin(plugin);
   156         p = CpPluginLoader::loadCpPluginInterface(plugin);
    96         if (p && m_helper){
   157         if (p && m_helper) {
    97             items = p->createSettingFormItemData(*m_helper);
   158             items = p->createSettingFormItemData(*m_helper);
    98         }
   159         }
    99     } catch(...) {
   160     } catch(...) {
   100         DPRINT << "CATCH ERROR";
   161         DCRITICAL << ": CATCH ERROR, item creation failed!";
   101         delete p;
   162         delete p;
   102     }
   163     }
   103     
   164     
   104     DPRINT << ": OUT";
   165     DPRINT << ": OUT";
   105     return items;
   166     return items;
   106 }
   167 }
   107 
   168 
   108 /*!
   169 /*!
   109     CpTelephonyPluginView::initializeItemDataHelper()
   170     Item data helper initialization. 
   110 */
   171 */
   111 CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper()
   172 CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper()
   112 {
   173 {
   113     DPRINT;
   174     DPRINT;
   114     return new CpItemDataHelper(qobject_cast<HbDataForm*>(widget()));
   175     return new CpItemDataHelper(qobject_cast<HbDataForm*>(widget()));