widgetmodel/alfwidgetmodel/src/alfmodel.cpp
changeset 3 4526337fb576
parent 0 e83bab7cf002
equal deleted inserted replaced
2:b1a1f09f9110 3:4526337fb576
    25 
    25 
    26 #include <alf/alfmodel.h>
    26 #include <alf/alfmodel.h>
    27 #include "alf/alfmodeloperation.h"
    27 #include "alf/alfmodeloperation.h"
    28 #include <alf/alfvarianttype.h>
    28 #include <alf/alfvarianttype.h>
    29 #include <alf/alfexceptions.h>
    29 #include <alf/alfexceptions.h>
    30 #include "alf/alfperf.h"
    30 //#include "alf/alfperf.h"
    31 #include <osn/osnnew.h>
    31 #include <osn/osnnew.h>
    32 
    32 
    33 using osncore::AlfPtrVector;
    33 using osncore::AlfPtrVector;
    34 using std::auto_ptr;
    34 using std::auto_ptr;
    35 
    35 
   216     {
   216     {
   217     IAlfVariantType* newData = 0;
   217     IAlfVariantType* newData = 0;
   218     IAlfVariantType* parentData = 0;
   218     IAlfVariantType* parentData = 0;
   219     try
   219     try
   220         {
   220         {
   221         ALF_PERF_START( perfdata, "AlfModel-AddData-Adding")
   221         //ALF_PERF_START( perfdata, "AlfModel-AddData-Adding")
   222         newData = aAddOperation->getNewData();     
   222         newData = aAddOperation->getNewData();     
   223         parentData  = aAddOperation->parentData(*data());
   223         parentData  = aAddOperation->parentData(*data());
   224         int index = aAddOperation->index();
   224         int index = aAddOperation->index();
   225         
   225         
   226         if(parentData->type()== IAlfVariantType::EBranch &&
   226         if(parentData->type()== IAlfVariantType::EBranch &&
   246             }
   246             }
   247         else if(parentData->type()== IAlfVariantType::EContainer )
   247         else if(parentData->type()== IAlfVariantType::EContainer )
   248             {
   248             {
   249             parentData->container()->addItem(index, newData);
   249             parentData->container()->addItem(index, newData);
   250             }
   250             }
   251         ALF_PERF_STOP( perfdata, "AlfModel-AddData-Adding")
   251         //ALF_PERF_STOP( perfdata, "AlfModel-AddData-Adding")
   252         }
   252         }
   253 	catch(AlfDataException& e)	        
   253 	catch(AlfDataException& e)	        
   254         {
   254         {
   255         newData = 0;
   255         newData = 0;
   256         parentData = 0;
   256         parentData = 0;
   268     {
   268     {
   269     IAlfVariantType* parentData = 0;
   269     IAlfVariantType* parentData = 0;
   270 
   270 
   271     try
   271     try
   272         {
   272         {
   273         ALF_PERF_START( perfdata, "AlfModel-RemoveData-Removing")
   273         //ALF_PERF_START( perfdata, "AlfModel-RemoveData-Removing")
   274         parentData  = aRemoveOperation->parentData(*data());         
   274         parentData  = aRemoveOperation->parentData(*data());         
   275         int index = aRemoveOperation->index();
   275         int index = aRemoveOperation->index();
   276 
   276 
   277         if(parentData->type()== IAlfVariantType::EBranch )
   277         if(parentData->type()== IAlfVariantType::EBranch )
   278             {
   278             {
   293             }
   293             }
   294         else if(parentData->type()== IAlfVariantType::EContainer )
   294         else if(parentData->type()== IAlfVariantType::EContainer )
   295             {
   295             {
   296             parentData->container()->removeItem(index);
   296             parentData->container()->removeItem(index);
   297             }    
   297             }    
   298         ALF_PERF_STOP( perfdata, "AlfModel-RemoveData-Removing")
   298         //ALF_PERF_STOP( perfdata, "AlfModel-RemoveData-Removing")
   299         }
   299         }
   300     catch(AlfDataException& e)
   300     catch(AlfDataException& e)
   301         {
   301         {
   302         parentData = 0;
   302         parentData = 0;
   303         ALF_THROW(AlfDataException,EInvalidModelOperation,"AlfModel")
   303         ALF_THROW(AlfDataException,EInvalidModelOperation,"AlfModel")
   312     IAlfVariantType* newData = 0;
   312     IAlfVariantType* newData = 0;
   313     IAlfVariantType* parentData = 0;
   313     IAlfVariantType* parentData = 0;
   314 
   314 
   315     try
   315     try
   316         {
   316         {
   317         ALF_PERF_START( perfdata, "AlfModel-UpdateData-Updating")
   317         //ALF_PERF_START( perfdata, "AlfModel-UpdateData-Updating")
   318         newData= aUpdateOperation->getNewData();
   318         newData= aUpdateOperation->getNewData();
   319 
   319 
   320         parentData  = aUpdateOperation->parentData(*data());
   320         parentData  = aUpdateOperation->parentData(*data());
   321         int index = aUpdateOperation->index();
   321         int index = aUpdateOperation->index();
   322 
   322 
   340             }
   340             }
   341         else if(parentData->type()== IAlfVariantType::EContainer )
   341         else if(parentData->type()== IAlfVariantType::EContainer )
   342             {
   342             {
   343             parentData->container()->replaceItem(index,newData);
   343             parentData->container()->replaceItem(index,newData);
   344             }
   344             }
   345         ALF_PERF_STOP( perfdata, "AlfModel-UpdateData-Updating")
   345         //ALF_PERF_STOP( perfdata, "AlfModel-UpdateData-Updating")
   346         }
   346         }
   347     catch(AlfDataException& e)
   347     catch(AlfDataException& e)
   348         {
   348         {
   349         parentData=0;
   349         parentData=0;
   350         newData=0;
   350         newData=0;