| 180 | } |
| 181 | |
| 182 | static QWidget * |
| 183 | widget_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 | } |
no test coverage detected