diff -r bab96b7ed1a4 -r f39ed5e045e0 phonesettings/cpphonesettingsplugins/telephonyplugin/src/cptelephonypluginview.cpp --- a/phonesettings/cpphonesettingsplugins/telephonyplugin/src/cptelephonypluginview.cpp Tue Jun 15 14:14:38 2010 +0100 +++ b/phonesettings/cpphonesettingsplugins/telephonyplugin/src/cptelephonypluginview.cpp Thu Jul 22 16:33:21 2010 +0100 @@ -15,8 +15,7 @@ * */ -#include "cptelephonypluginview.h" -#include "cppluginlogging.h" + #include #include #include @@ -24,10 +23,24 @@ #include #include #include - +#include "cptelephonypluginview.h" +#include "cppluginlogging.h" /*! - CpTelephonyPluginView::CpTelephonyPluginView() + \class CpTelephonyPluginView + \brief The class CpTelephonyPluginView + loads child setting plugins contained + in "Telephony" view. +*/ + +// Local constants +const char* PLUGIN_NAME_CALLSPLUGIN = "cpcallsplugin"; +const char* PLUGIN_NAME_VMBXPLUGIN = "vmbxcpplugin"; +const char* PLUGIN_NAME_DIVERTPLUGIN = "cpdivertplugin"; +const char* PLUGIN_NAME_BARRINGPLUGIN = "cpbarringplugin"; + +/*! + Constructor. */ CpTelephonyPluginView::CpTelephonyPluginView() : CpBaseSettingView(0,0), @@ -43,21 +56,23 @@ m_helper = initializeItemDataHelper(); QList items; - // Load calls plugin DPRINT << ": Loading cpcallsplugin"; - items.append(groupItemFromPlugin("cpcallsplugin")); - - // Load diverts plugin + items.append(groupItemFromPlugin( + PLUGIN_NAME_CALLSPLUGIN)); + // CpSettingFormItemData* expandedItem = items.last(); + + DPRINT << ": Loading vmbxcpplugin"; + items.append(groupItemFromPlugin( + PLUGIN_NAME_VMBXPLUGIN)); + + DPRINT << ": Loading cpdivertsplugin"; - items.append(groupItemFromPlugin("cpdivertplugin")); - - // Load call mailboxes plugin - DPRINT << ": Loading vmbxcpplugin"; - items.append(groupItemFromPlugin("vmbxcpplugin")); + items.append(groupItemFromPlugin( + PLUGIN_NAME_DIVERTPLUGIN)); - // Load barring plugin DPRINT << ": Loading cpbarringplugin"; - items.append(groupItemFromPlugin("cpbarringplugin")); + items.append(groupItemFromPlugin( + PLUGIN_NAME_BARRINGPLUGIN)); // Insert items to form model foreach (CpSettingFormItemData* i, items) { @@ -65,39 +80,85 @@ } form->setModel(model); + + /* + if (expandedItem) { + QModelIndex expandedItemIndex = model->indexFromItem(expandedItem); + + if (expandedItemIndex.isValid()) { + form->setExpanded(expandedItemIndex, true); + } + } + */ } DPRINT << ": OUT"; } /*! - CpTelephonyPluginView::~CpTelephonyPluginView() + Constructor with param list. +*/ +CpTelephonyPluginView::CpTelephonyPluginView(const QVariantList ¶ms) : + CpBaseSettingView(0,0), + m_helper(NULL) +{ + HbDataForm *form = qobject_cast(widget()); + if (form){ + HbDataFormModel *model = new HbDataFormModel; + form->setHeading(hbTrId("txt_phone_subhead_telephone")); + m_helper = initializeItemDataHelper(); + QList items; + TBool expanded(false); + CpSettingFormItemData* expandedItem(NULL); + foreach (QVariant var, params){ + items.append(groupItemFromPlugin(var.toString())); + if(!expanded){ + expandedItem = items.last(); + expanded = true; + } + } + // Insert items to form model + foreach (CpSettingFormItemData* i, items) { + model->appendDataFormItem(i); + } + form->setModel(model); + if (expandedItem) { + QModelIndex expandedItemIndex = model->indexFromItem(expandedItem); + + if (expandedItemIndex.isValid()) { + form->setExpanded(expandedItemIndex, true); + } + } + } +} + +/*! + Destructor. */ CpTelephonyPluginView::~CpTelephonyPluginView() { DPRINT << ": IN"; - delete m_helper; - DPRINT << ": OUT"; } /*! - CpTelephonyPluginView::groupItemFromPlugin() + Load group item for given plugin name. */ -QList CpTelephonyPluginView::groupItemFromPlugin( const QString& plugin ) +QList CpTelephonyPluginView::groupItemFromPlugin( + const QString& plugin) { DPRINT << ": IN"; QList items; CpPluginInterface *p(NULL); try { - p = CpPluginLoader::loadCpPlugin(plugin); - if (p && m_helper){ + p = CpPluginLoader::loadCpPluginInterface(plugin); + if (p && m_helper) { items = p->createSettingFormItemData(*m_helper); } } catch(...) { - DPRINT << "CATCH ERROR"; + DCRITICAL << ": CATCH ERROR, item creation failed!"; delete p; } @@ -106,7 +167,7 @@ } /*! - CpTelephonyPluginView::initializeItemDataHelper() + Item data helper initialization. */ CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper() {