MCPcopy Create free account
hub / github.com/KLayout/klayout / widget_from_path

Function widget_from_path

src/laybasic/laybasic/gtf.cc:182–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182static QWidget *
183widget_from_path (const char *p, int xml_line)
184{
185 tl::Extractor x (p);
186
187 std::string name;
188 std::string cls;
189 int nwidget = 1;
190 bool more = false;
191
192 QObject *w = 0;
193 do {
194
195 more = extract_widget_path (x, name, cls, nwidget);
196
197 int n = nwidget;
198 QObject *pw = w;
199 if (w == 0) {
200 QWidgetList tl_widgets = QApplication::topLevelWidgets ();
201 for (QWidgetList::const_iterator tl = tl_widgets.begin (); tl != tl_widgets.end (); ++tl) {
202 if (is_widget (*tl) && (*tl)->objectName () == tl::to_qstring (name) && (cls.empty () || cls == (*tl)->metaObject ()->className ()) && --n == 0) {
203 w = *tl;
204 break;
205 }
206 }
207 } else {
208 w = 0;
209 QObjectList children = pw->children ();
210 for (QObjectList::const_iterator child = children.begin (); child != children.end (); ++child) {
211 if (is_widget (*child) && (*child)->objectName () == tl::to_qstring (name) && (cls.empty () || cls == (*child)->metaObject ()->className ()) && --n == 0) {
212 w = *child;
213 break;
214 }
215 }
216 }
217
218 if (w == 0) {
219 std::string names;
220 if (pw == 0) {
221 QWidgetList tl_widgets = QApplication::topLevelWidgets ();
222 for (QWidgetList::const_iterator tl = tl_widgets.begin (); tl != tl_widgets.end (); ++tl) {
223 if (is_widget (*tl)) {
224 if (! names.empty ()) {
225 names += ",";
226 }
227 names += tl::to_string ((*tl)->objectName ());
228 names += "(";
229 names += (*tl)->metaObject ()->className ();
230 names += ")";
231 }
232 }
233 } else {
234 QObjectList children = pw->children ();
235 for (QObjectList::const_iterator child = children.begin (); child != children.end (); ++child) {
236 if (is_widget (*child)) {
237 if (! names.empty ()) {
238 names += ",";
239 }

Callers 1

target_widgetMethod · 0.85

Calls 11

extract_widget_pathFunction · 0.85
is_widgetFunction · 0.85
to_qstringFunction · 0.85
dump_widget_treeFunction · 0.85
to_stringFunction · 0.50
ExceptionClass · 0.50
trFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
childrenMethod · 0.45

Tested by

no test coverage detected