Mercurial > octave-nkf
comparison libgui/graphics/EditControl.cc @ 20002:3cc0734283dc
style fixes in Qt graphics code
* Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc,
CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc,
Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc, ListBoxControl.cc,
Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc,
ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc,
PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc,
RadioButtonControl.cc, SliderControl.cc, TextControl.cc, TextEdit.cc,
ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc,
__init_qt__.cc: Follow a few more Octave coding conventions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Mar 2015 12:27:54 -0400 |
parents | 2f4406e9dad6 |
children | f0e61a67ad9f |
comparison
equal
deleted
inserted
replaced
20001:40b2c4323c16 | 20002:3cc0734283dc |
---|---|
32 #include "QtHandlesUtils.h" | 32 #include "QtHandlesUtils.h" |
33 | 33 |
34 namespace QtHandles | 34 namespace QtHandles |
35 { | 35 { |
36 | 36 |
37 EditControl* EditControl::create (const graphics_object& go) | 37 EditControl* |
38 EditControl::create (const graphics_object& go) | |
38 { | 39 { |
39 Object* parent = Object::parentObject (go); | 40 Object* parent = Object::parentObject (go); |
40 | 41 |
41 if (parent) | 42 if (parent) |
42 { | 43 { |
60 : BaseControl (go, edit), m_multiLine (false), m_textChanged (false) | 61 : BaseControl (go, edit), m_multiLine (false), m_textChanged (false) |
61 { | 62 { |
62 init (edit); | 63 init (edit); |
63 } | 64 } |
64 | 65 |
65 void EditControl::init (QLineEdit* edit, bool callBase) | 66 void |
67 EditControl::init (QLineEdit* edit, bool callBase) | |
66 { | 68 { |
67 if (callBase) | 69 if (callBase) |
68 BaseControl::init (edit, callBase); | 70 BaseControl::init (edit, callBase); |
69 | 71 |
70 m_multiLine = false; | 72 m_multiLine = false; |
81 connect (edit, SIGNAL (editingFinished (void)), | 83 connect (edit, SIGNAL (editingFinished (void)), |
82 SLOT (editingFinished (void))); | 84 SLOT (editingFinished (void))); |
83 } | 85 } |
84 | 86 |
85 EditControl::EditControl (const graphics_object& go, TextEdit* edit) | 87 EditControl::EditControl (const graphics_object& go, TextEdit* edit) |
86 : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) | 88 : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) |
87 { | 89 { |
88 init (edit); | 90 init (edit); |
89 } | 91 } |
90 | 92 |
91 void EditControl::init (TextEdit* edit, bool callBase) | 93 void |
94 EditControl::init (TextEdit* edit, bool callBase) | |
92 { | 95 { |
93 if (callBase) | 96 if (callBase) |
94 BaseControl::init (edit, callBase); | 97 BaseControl::init (edit, callBase); |
95 | 98 |
96 m_multiLine = true; | 99 m_multiLine = true; |
110 | 113 |
111 EditControl::~EditControl (void) | 114 EditControl::~EditControl (void) |
112 { | 115 { |
113 } | 116 } |
114 | 117 |
115 void EditControl::initCommon (QWidget*) | 118 void |
119 EditControl::initCommon (QWidget*) | |
116 { | 120 { |
117 m_textChanged = false; | 121 m_textChanged = false; |
118 } | 122 } |
119 | 123 |
120 void EditControl::update (int pId) | 124 void |
125 EditControl::update (int pId) | |
121 { | 126 { |
122 bool handled = false; | 127 bool handled = false; |
123 | 128 |
124 if (m_multiLine) | 129 if (m_multiLine) |
125 handled = updateMultiLine (pId); | 130 handled = updateMultiLine (pId); |
135 break; | 140 break; |
136 } | 141 } |
137 } | 142 } |
138 } | 143 } |
139 | 144 |
140 bool EditControl::updateSingleLine (int pId) | 145 bool |
146 EditControl::updateSingleLine (int pId) | |
141 { | 147 { |
142 uicontrol::properties& up = properties<uicontrol> (); | 148 uicontrol::properties& up = properties<uicontrol> (); |
143 QLineEdit* edit = qWidget<QLineEdit> (); | 149 QLineEdit* edit = qWidget<QLineEdit> (); |
144 | 150 |
145 switch (pId) | 151 switch (pId) |
146 { | 152 { |
147 case uicontrol::properties::ID_STRING: | 153 case uicontrol::properties::ID_STRING: |
148 edit->setText (Utils::fromStdString (up.get_string_string ())); | 154 edit->setText (Utils::fromStdString (up.get_string_string ())); |
149 return true; | 155 return true; |
156 | |
150 case uicontrol::properties::ID_HORIZONTALALIGNMENT: | 157 case uicontrol::properties::ID_HORIZONTALALIGNMENT: |
151 case uicontrol::properties::ID_VERTICALALIGNMENT: | 158 case uicontrol::properties::ID_VERTICALALIGNMENT: |
152 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), | 159 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), |
153 up.get_verticalalignment ())); | 160 up.get_verticalalignment ())); |
154 return true; | 161 return true; |
162 | |
155 case uicontrol::properties::ID_MIN: | 163 case uicontrol::properties::ID_MIN: |
156 case uicontrol::properties::ID_MAX: | 164 case uicontrol::properties::ID_MAX: |
157 if ((up.get_max () - up.get_min ()) > 1) | 165 if ((up.get_max () - up.get_min ()) > 1) |
158 { | 166 { |
159 QWidget* container = edit->parentWidget (); | 167 QWidget* container = edit->parentWidget (); |
160 | 168 |
161 delete edit; | 169 delete edit; |
162 init (new TextEdit (container), true); | 170 init (new TextEdit (container), true); |
163 } | 171 } |
164 return true; | 172 return true; |
173 | |
165 default: | 174 default: |
166 break; | 175 break; |
167 } | 176 } |
168 | 177 |
169 return false; | 178 return false; |
170 } | 179 } |
171 | 180 |
172 bool EditControl::updateMultiLine (int pId) | 181 bool |
182 EditControl::updateMultiLine (int pId) | |
173 { | 183 { |
174 uicontrol::properties& up = properties<uicontrol> (); | 184 uicontrol::properties& up = properties<uicontrol> (); |
175 TextEdit* edit = qWidget<TextEdit> (); | 185 TextEdit* edit = qWidget<TextEdit> (); |
176 | 186 |
177 switch (pId) | 187 switch (pId) |
178 { | 188 { |
179 case uicontrol::properties::ID_STRING: | 189 case uicontrol::properties::ID_STRING: |
180 edit->setPlainText (Utils::fromStdString (up.get_string_string ())); | 190 edit->setPlainText (Utils::fromStdString (up.get_string_string ())); |
181 return true; | 191 return true; |
192 | |
182 case uicontrol::properties::ID_MIN: | 193 case uicontrol::properties::ID_MIN: |
183 case uicontrol::properties::ID_MAX: | 194 case uicontrol::properties::ID_MAX: |
184 if ((up.get_max () - up.get_min ()) <= 1) | 195 if ((up.get_max () - up.get_min ()) <= 1) |
185 { | 196 { |
186 QWidget* container = edit->parentWidget (); | 197 QWidget* container = edit->parentWidget (); |
187 | 198 |
188 delete edit; | 199 delete edit; |
189 init (new QLineEdit (container), true); | 200 init (new QLineEdit (container), true); |
190 } | 201 } |
191 return true; | 202 return true; |
203 | |
192 default: | 204 default: |
193 break; | 205 break; |
194 } | 206 } |
195 | 207 |
196 return false; | 208 return false; |
197 } | 209 } |
198 | 210 |
199 void EditControl::textChanged (void) | 211 void |
212 EditControl::textChanged (void) | |
200 { | 213 { |
201 m_textChanged = true; | 214 m_textChanged = true; |
202 } | 215 } |
203 | 216 |
204 void EditControl::editingFinished (void) | 217 void |
218 EditControl::editingFinished (void) | |
205 { | 219 { |
206 if (m_textChanged) | 220 if (m_textChanged) |
207 { | 221 { |
208 QString txt = (m_multiLine | 222 QString txt = (m_multiLine |
209 ? qWidget<TextEdit> ()->toPlainText () | 223 ? qWidget<TextEdit> ()->toPlainText () |