diff libgui/graphics/ButtonControl.cc @ 22411:c69805d1fa64

maint: Style check C++ code in libgui/ * Backend.cc, Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, MouseModeActionGroup.cc, MouseModeActionGroup.h, Object.cc, Object.h, ObjectFactory.cc, ObjectFactory.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, color-picker.cc, color-picker.h, dialog.h, documentation-dock-widget.cc, documentation-dock-widget.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.h, find-files-model.cc, find-files-model.h, history-dock-widget.cc, history-dock-widget.h, liboctgui-build-info.h, liboctgui-build-info.in.cc, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc, octave-dock-widget.h, octave-gui.cc, octave-gui.h, octave-interpreter.cc, octave-interpreter.h, octave-qt-link.cc, octave-qt-link.h, parser.cc, parser.h, webinfo.cc, webinfo.h, resource-manager.cc, resource-manager.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.h, thread-manager.cc, thread-manager.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Style check C++ code in libgui/
author Rik <rik@octave.org>
date Wed, 31 Aug 2016 12:20:46 -0700
parents bac0d6f07a3e
children 48c00363dc74
line wrap: on
line diff
--- a/libgui/graphics/ButtonControl.cc	Wed Aug 31 14:37:33 2016 -0400
+++ b/libgui/graphics/ButtonControl.cc	Wed Aug 31 12:20:46 2016 -0700
@@ -34,112 +34,114 @@
 namespace QtHandles
 {
 
-ButtonControl::ButtonControl (const graphics_object& go, QAbstractButton* btn)
-  : BaseControl (go, btn), m_blockCallback (false)
-{
-  uicontrol::properties& up = properties<uicontrol> ();
-
-  QString str = Utils::fromStdString (up.get_string_string ());
-  str.replace ("&", "&&");
-  btn->setText (str);
-  if (btn->isCheckable () || up.style_is ("togglebutton"))
-    {
-      btn->setCheckable (true);
-
-      Matrix value = up.get_value ().matrix_value ();
-
-      if (value.numel () > 0 && value(0) == up.get_max ())
-        btn->setChecked (true);
-    }
+  ButtonControl::ButtonControl (const graphics_object& go, QAbstractButton* btn)
+    : BaseControl (go, btn), m_blockCallback (false)
+  {
+    uicontrol::properties& up = properties<uicontrol> ();
 
-  connect (btn, SIGNAL (clicked (void)), SLOT (clicked (void)));
-  connect (btn, SIGNAL (toggled (bool)), SLOT (toggled (bool)));
-}
-
-ButtonControl::~ButtonControl (void)
-{
-}
+    QString str = Utils::fromStdString (up.get_string_string ());
+    str.replace ("&", "&&");
+    btn->setText (str);
+    if (btn->isCheckable () || up.style_is ("togglebutton"))
+      {
+        btn->setCheckable (true);
 
-void
-ButtonControl::update (int pId)
-{
-  uicontrol::properties& up = properties<uicontrol> ();
-  QAbstractButton* btn = qWidget<QAbstractButton> ();
+        Matrix value = up.get_value ().matrix_value ();
 
-  switch (pId)
-    {
-    case uicontrol::properties::ID_STRING:
-      {
-        QString str = Utils::fromStdString (up.get_string_string ());
-        str.replace ("&", "&&");
-        btn->setText (str);
-        break;
+        if (value.numel () > 0 && value(0) == up.get_max ())
+          btn->setChecked (true);
       }
 
-    case uicontrol::properties::ID_VALUE:
-      m_blockCallback = true;
-      if (btn->isCheckable ())
-        {
-          Matrix value = up.get_value ().matrix_value ();
+    connect (btn, SIGNAL (clicked (void)), SLOT (clicked (void)));
+    connect (btn, SIGNAL (toggled (bool)), SLOT (toggled (bool)));
+  }
 
-          if (value.numel () > 0)
-            {
-              double dValue = value(0);
+  ButtonControl::~ButtonControl (void)
+  {
+  }
+
+  void
+  ButtonControl::update (int pId)
+  {
+    uicontrol::properties& up = properties<uicontrol> ();
+    QAbstractButton* btn = qWidget<QAbstractButton> ();
 
-              if (dValue != 0.0 && dValue != 1.0)
-                warning ("button value not within valid display range");
-              else if (dValue == up.get_min () && btn->isChecked ())
-                {
-                  btn->setChecked (false);
-                  if (up.style_is ("radiobutton") || up.style_is ("togglebutton"))
-                    {
-                      Object* parent = Object::parentObject (gh_manager::get_object (up.get___myhandle__ ()));
-                      ButtonGroup* btnGroup = dynamic_cast<ButtonGroup*>(parent);
-                      if (btnGroup)
-                        btnGroup->selectNothing ();
-                    }
-                }
-              else if (dValue == up.get_max () && ! btn->isChecked ())
-                btn->setChecked (true);
-            }
+    switch (pId)
+      {
+      case uicontrol::properties::ID_STRING:
+        {
+          QString str = Utils::fromStdString (up.get_string_string ());
+          str.replace ("&", "&&");
+          btn->setText (str);
+          break;
         }
-      m_blockCallback = false;
-      break;
+
+      case uicontrol::properties::ID_VALUE:
+        m_blockCallback = true;
+        if (btn->isCheckable ())
+          {
+            Matrix value = up.get_value ().matrix_value ();
+
+            if (value.numel () > 0)
+              {
+                double dValue = value(0);
 
-    default:
-      BaseControl::update (pId);
-      break;
-    }
-}
+                if (dValue != 0.0 && dValue != 1.0)
+                  warning ("button value not within valid display range");
+                else if (dValue == up.get_min () && btn->isChecked ())
+                  {
+                    btn->setChecked (false);
+                    if (up.style_is ("radiobutton") || up.style_is ("togglebutton"))
+                      {
+                        Object* parent = Object::parentObject (gh_manager::get_object (
+                            up.get___myhandle__ ()));
+                        ButtonGroup* btnGroup = dynamic_cast<ButtonGroup*>(parent);
+                        if (btnGroup)
+                          btnGroup->selectNothing ();
+                      }
+                  }
+                else if (dValue == up.get_max () && ! btn->isChecked ())
+                  btn->setChecked (true);
+              }
+          }
+        m_blockCallback = false;
+        break;
 
-void
-ButtonControl::toggled (bool checked)
-{
-  QAbstractButton* btn = qWidget<QAbstractButton> ();
-
-  if (! m_blockCallback && btn->isCheckable ())
-    {
-      gh_manager::auto_lock lock;
-
-      uicontrol::properties& up = properties<uicontrol> ();
+      default:
+        BaseControl::update (pId);
+        break;
+      }
+  }
 
-      Matrix oldValue = up.get_value ().matrix_value ();
-      double newValue = (checked ? up.get_max () : up.get_min ());
+  void
+  ButtonControl::toggled (bool checked)
+  {
+    QAbstractButton* btn = qWidget<QAbstractButton> ();
+
+    if (! m_blockCallback && btn->isCheckable ())
+      {
+        gh_manager::auto_lock lock;
+
+        uicontrol::properties& up = properties<uicontrol> ();
+
+        Matrix oldValue = up.get_value ().matrix_value ();
+        double newValue = (checked ? up.get_max () : up.get_min ());
 
-      if (oldValue.numel() != 1
-          || (newValue != oldValue(0)))
-        gh_manager::post_set (m_handle, "value", newValue, false);
+        if (oldValue.numel() != 1
+            || (newValue != oldValue(0)))
+          gh_manager::post_set (m_handle, "value", newValue, false);
+        gh_manager::post_callback (m_handle, "callback");
+      }
+  }
+
+  void
+  ButtonControl::clicked (void)
+  {
+    QAbstractButton* btn = qWidget<QAbstractButton> ();
+
+    if (! btn->isCheckable ())
       gh_manager::post_callback (m_handle, "callback");
-    }
-}
-
-void
-ButtonControl::clicked (void)
-{
-  QAbstractButton* btn = qWidget<QAbstractButton> ();
-
-  if (! btn->isCheckable ())
-    gh_manager::post_callback (m_handle, "callback");
-}
+  }
 
 };
+