cmmanager/cpdestinationplugin/src/cpdestinationentryitem.cpp
changeset 28 860702281757
parent 20 9c97ad6591ae
child 29 1f1fcd7e941c
--- a/cmmanager/cpdestinationplugin/src/cpdestinationentryitem.cpp	Mon May 03 12:53:07 2010 +0300
+++ b/cmmanager/cpdestinationplugin/src/cpdestinationentryitem.cpp	Thu May 13 23:10:21 2010 +0300
@@ -22,7 +22,6 @@
 #include <HbAction>
 #include <HbDataFormViewItem>
 #include <HbMenu>
-#include <HbListDialog>
 #include <HbInputDialog>
 #include <HbMessageBox>
 #include <HbPopup>
@@ -65,6 +64,7 @@
  */
 CpDestinationEntryItemData::CpDestinationEntryItemData(CpItemDataHelper &itemDataHelper)
     : CpSettingFormEntryItemData(itemDataHelper),
+    mList(0),
     mDialog(0),
     mOkAction(0)
 {
@@ -76,14 +76,7 @@
         OstTrace0(TRACE_NORMAL, CPDESTINATIONENTRYITEMDATA_CPDESTINATIONENTRYITEMDATA, "CpDestinationEntryItemData::CpDestinationEntryItemData: Exception caught");
         mCmm = NULL;
     }
-    mList = new HbListWidget();
-    bool connectionSuccessful = connect(
-        mList,
-        SIGNAL(released(HbListWidgetItem *)),
-        this,
-        SLOT(updateIndex(HbListWidgetItem*)));
-    Q_ASSERT(connectionSuccessful);
-    
+        
     // Fix connections
     itemDataHelper.removeConnection(this,SIGNAL(pressed()),this,SLOT(onLaunchView()));
     itemDataHelper.addConnection(this,SIGNAL(clicked()),this,SLOT(onLaunchView()));
@@ -97,7 +90,6 @@
 CpDestinationEntryItemData::~CpDestinationEntryItemData()
 {
     OstTraceFunctionEntry0(DUP1_CPDESTINATIONENTRYITEMDATA_CPDESTINATIONENTRYITEMDATA_ENTRY);
-    delete mList;
     delete mCmm;
     delete mAps;
     delete mOkAction;
@@ -197,8 +189,11 @@
         bool apProtected = false;
         if (mDestinationId != 0) {
             CmDestinationShim *destination = mCmm->destination(mDestinationId);
-            if (destination->protectionLevel() == CMManagerShim::ProtLevel3) {
+            CMManagerShim::CmmProtectionLevel level = destination->protectionLevel();
+            if (level == CMManagerShim::ProtLevel3) {
                 apProtected = apList[i]->getBoolAttribute(CMManagerShim::CmProtected);
+            } else if (level == CMManagerShim::ProtLevel1) {
+                apProtected = true;
             }
             delete destination;
         }
@@ -212,7 +207,7 @@
             apProtected,
             bearerPlugin);
        
-        // Add name to item
+        // Add name to UI item
         iapDataItem->setContentWidgetData(
             QString("text"), 
             apList[i]->getStringAttribute(CMManagerShim::CmName));
@@ -250,7 +245,7 @@
 void CpDestinationEntryItemData::updateDestinationView()
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_UPDATEDESTINATIONVIEW_ENTRY);
-    HbDataForm *form = static_cast<HbDataForm*>(model()->parent()); 
+    HbDataForm *form = static_cast<HbDataForm*>(QObject::parent()->parent()); 
     HbMainWindow *mainWnd = form->mainWindow();
        
     if (mainWnd) {
@@ -398,17 +393,23 @@
 void CpDestinationEntryItemData::activateArrangeMode()
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_ACTIVATEARRANGEMODE_ENTRY);
-    mList = new HbListWidget();
-    HbDataForm *form = static_cast<HbDataForm*>(model()->parent());             
+    HbDataForm *form = static_cast<HbDataForm*>(QObject::parent()->parent());             
     HbMainWindow *mainWnd = form->mainWindow();
     HbView *view = new HbView();
     createArrangeModeView(view);
     
+    bool connectionSuccessful = connect(
+            mList,
+            SIGNAL(released(HbListWidgetItem*)),
+            this,
+            SLOT(updateIndex(HbListWidgetItem*)));
+    Q_ASSERT(connectionSuccessful);
+    
     if (mainWnd && view) {
         mPreView = mainWnd->currentView();
         mainWnd->addView(view);
         mainWnd->setCurrentView(view, false);
-        HbAction *arrangeViewBackAction = new HbAction(Hb::BackAction, view);
+        HbAction *arrangeViewBackAction = new HbAction(Hb::BackNaviAction, view);
         bool connected = connect(
             arrangeViewBackAction, 
             SIGNAL(triggered()), 
@@ -447,7 +448,7 @@
         return;
     }
     
-    HbDataForm *form = static_cast<HbDataForm*>(model()->parent());
+    HbDataForm *form = static_cast<HbDataForm*>(QObject::parent()->parent());
     HbMainWindow *mainWnd = form->mainWindow();
     HbView* view = mainWnd->currentView();
     
@@ -467,7 +468,7 @@
 void CpDestinationEntryItemData::viewCancel()
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_VIEWCANCEL_ENTRY);
-    HbDataForm *form = static_cast<HbDataForm*>(model()->parent());
+    HbDataForm *form = static_cast<HbDataForm*>(QObject::parent()->parent());
     HbMainWindow *mainWnd = form->mainWindow();
     HbView* view = mainWnd->currentView();
     
@@ -596,6 +597,8 @@
     QList<QSharedPointer<CmConnectionMethodShim> >  apList;
     fetchReferencedAps(apList, mCmm);   
     CmDestinationShim *destination = NULL;
+    mList = new HbListWidget();
+    view->setWidget(mList);
     
     try {
         destination = mCmm->destination(mDestinationId);
@@ -611,17 +614,6 @@
             mList->addItem(item);
         }
         mList->setArrangeMode(true);
-        view->setWidget(mList);
-                
-        // Toolbar
-        HbToolBar *tb = view->toolBar();
-        HbAction *doneAction = tb->addAction(hbTrId("txt_common_button_ok"));
-        bool connected = connect(
-            doneAction, 
-            SIGNAL(triggered()), 
-            this, 
-            SLOT(viewDone()));
-        Q_ASSERT(connected);
         delete destination;
     } catch (const std::exception&) {
         OstTrace0(TRACE_NORMAL, CPDESTINATIONENTRYITEMDATA_CREATEARRANGEMODEVIEW, "CpDestinationEntryItemData::createArrangeModeView: Exception caught");
@@ -635,6 +627,15 @@
         }
         mList->clear();
     }
+    // Toolbar
+    HbToolBar *tb = view->toolBar();
+    HbAction *doneAction = tb->addAction(hbTrId("txt_common_button_ok"));
+    bool connected = connect(
+        doneAction, 
+        SIGNAL(triggered()), 
+        this, 
+        SLOT(viewDone()));
+    Q_ASSERT(connected);
     OstTraceFunctionExit0(CPDESTINATIONENTRYITEMDATA_CREATEARRANGEMODEVIEW_EXIT);
 }
 
@@ -692,7 +693,9 @@
         cmm = new CmManagerShim();
         if (isDestinationNameValid(destinationName, cmm)) {
             cmm = new CmManagerShim();
-            cmm->destination(mDestinationId)->setName(destinationName);
+            destination = cmm->destination(mDestinationId);
+            destination->setName(destinationName);
+            destination->update();
             mDestinationName = destinationName;
             destinationNameInvalid = false;
         }
@@ -747,7 +750,7 @@
 void CpDestinationEntryItemData::showErrorNote(const QString &info)
 {
     OstTraceFunctionEntry0(CPDESTINATIONENTRYITEMDATA_SHOWERRORNOTE_ENTRY);
-    HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeInformation);
+    HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeWarning);
     note->clearActions();
     note->setAttribute(Qt::WA_DeleteOnClose);
     note->setText(info);