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

Function widget_to_path

src/laybasic/laybasic/gtf.cc:260–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260static std::string
261widget_to_path (QWidget *w, const char *pf = 0)
262{
263 std::string n = tl::to_string (w->objectName ());
264 std::string cls = w->metaObject ()->className ();
265 QWidget *pw = w->parentWidget ();
266
267 int i = 1;
268 if (pw) {
269 QObjectList children = pw->children ();
270 for (QObjectList::const_iterator child = children.begin (); child != children.end (); ++child) {
271 if (dynamic_cast<QDialog *> (*child) != 0 || dynamic_cast<QMainWindow *> (*child) != 0 || dynamic_cast <QWidget *> (*child) != 0) {
272 if (*child == w) {
273 break;
274 }
275 if ((*child)->objectName () == tl::to_qstring (n) && cls == (*child)->metaObject ()->className ()) {
276 ++i;
277 }
278 }
279 }
280 } else {
281 QWidgetList tlw = QApplication::topLevelWidgets ();
282 for (QWidgetList::const_iterator itl = tlw.begin (); itl != tlw.end (); ++itl) {
283 // only QDialog or QMainWindow ancestors count as valid top level widgets
284 if (dynamic_cast<QDialog *> (*itl) != 0 || dynamic_cast<QMainWindow *> (*itl) != 0 || dynamic_cast <QWidget *> (*itl) != 0) {
285 if (*itl == w) {
286 break;
287 }
288 if ((*itl)->objectName () == tl::to_qstring (n) && cls == (*itl)->metaObject ()->className ()) {
289 ++i;
290 }
291 }
292 }
293 }
294 n += tl::sprintf ("(%s)", cls);
295 if (i > 1) {
296 n += tl::sprintf ("#%d", i);
297 }
298
299 if (pf) {
300 n += ".";
301 n += pf;
302 }
303
304 if (pw) {
305 return widget_to_path (pw, n.c_str ());
306 } else {
307 return n;
308 }
309}
310
311// --------------------------------------------------------------
312// Widget to track the mouse pointer

Callers 3

actionMethod · 0.85
probeMethod · 0.85
eventFilterMethod · 0.85

Calls 7

to_qstringFunction · 0.85
to_stringFunction · 0.50
sprintfFunction · 0.50
childrenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected