Merge "Reduce Cyclomatic Complexity of Text classes" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 21 Sep 2020 08:29:47 +0000 (08:29 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 21 Sep 2020 08:29:47 +0000 (08:29 +0000)
1  2 
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp

@@@ -777,35 -690,12 +692,32 @@@ void TextEditor::SetProperty( BaseObjec
        }
        case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
        {
-         if( impl.mController )
-         {
-           const int max = value.Get< int >();
-           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max );
+         const int max = value.Get< int >();
+         DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max );
  
-           impl.mController->SetMaximumNumberOfCharacters( max );
-         }
+         impl.mController->SetMaximumNumberOfCharacters( max );
          break;
        }
 +      case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
 +      {
 +        if( impl.mController )
 +        {
 +          uint32_t start = static_cast<uint32_t>(value.Get< int >());
 +          DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
 +          impl.SetTextSelectionRange( &start, nullptr );
 +        }
 +        break;
 +      }
 +      case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
 +      {
 +        if( impl.mController )
 +        {
 +          uint32_t end = static_cast<uint32_t>(value.Get< int >());
 +          DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
 +          impl.SetTextSelectionRange( nullptr, &end );
 +        }
 +        break;
 +      }
      } // switch
    } // texteditor
  }
@@@ -1208,24 -1007,9 +1029,21 @@@ Property::Value TextEditor::GetProperty
        }
        case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
        {
-         if( impl.mController )
-         {
-           value = impl.mController->GetMaximumNumberOfCharacters();
-         }
+         value = impl.mController->GetMaximumNumberOfCharacters();
          break;
        }
 +      case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
 +      {
 +        Uint32Pair range = impl.GetTextSelectionRange();
 +        value = static_cast<int>(range.first);
 +        break;
 +      }
 +      case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
 +      {
 +        Uint32Pair range = impl.GetTextSelectionRange();
 +        value = static_cast<int>(range.second);
 +        break;
 +      }
      } //switch
    }
  
@@@ -798,36 -702,13 +704,33 @@@ void TextField::SetProperty( BaseObject
        }
        case Toolkit::DevelTextField::Property::BACKGROUND:
        {
-         if( impl.mController )
-         {
-           const Vector4 backgroundColor = value.Get< Vector4 >();
-           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
+         const Vector4 backgroundColor = value.Get< Vector4 >();
+         DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
  
-           impl.mController->SetBackgroundEnabled( true );
-           impl.mController->SetBackgroundColor( backgroundColor );
-         }
+         impl.mController->SetBackgroundEnabled( true );
+         impl.mController->SetBackgroundColor( backgroundColor );
          break;
        }
 +      case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
 +      {
 +        if( impl.mController )
 +        {
 +          uint32_t start = static_cast<uint32_t>(value.Get< int >());
 +          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
 +          impl.SetTextSelectionRange( &start, nullptr );
 +        }
 +        break;
 +      }
 +      case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
 +      {
 +        if( impl.mController )
 +        {
 +          uint32_t end = static_cast<uint32_t>(value.Get< int >());
 +          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
 +          impl.SetTextSelectionRange( nullptr, &end );
 +        }
 +        break;
 +      }
      } // switch
    } // textfield
  }
@@@ -1245,24 -1029,9 +1051,21 @@@ Property::Value TextField::GetProperty
        }
        case Toolkit::DevelTextField::Property::SELECTED_TEXT:
        {
-         if( impl.mController )
-         {
-           value = impl.mController->GetSelectedText( );
-         }
+         value = impl.mController->GetSelectedText( );
          break;
        }
 +      case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
 +      {
 +        Uint32Pair range = impl.GetTextSelectionRange( );
 +        value = static_cast<int>(range.first);
 +        break;
 +      }
 +      case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
 +      {
 +        Uint32Pair range = impl.GetTextSelectionRange( );
 +        value = static_cast<int>(range.second);
 +        break;
 +      }
      } //switch
    }