20 #include <QMetaObject> |
20 #include <QMetaObject> |
21 #include "hierarchyelement.h" |
21 #include "hierarchyelement.h" |
22 #include "mainwindow.h" |
22 #include "mainwindow.h" |
23 #include "guiutilities.h" |
23 #include "guiutilities.h" |
24 |
24 |
25 HierarchyElement::HierarchyElement (QObject* parent) : |
25 HierarchyElement::HierarchyElement(QObject* parent) : |
26 m_window (nullptr) |
26 m_window(nullptr) |
27 { |
27 { |
28 if (parent) |
28 if (parent) |
29 { |
29 { |
30 while (parent->parent()) |
30 while (parent->parent()) |
31 parent = parent->parent(); |
31 parent = parent->parent(); |
32 |
32 |
33 m_window = qobject_cast<MainWindow*> (parent); |
33 m_window = qobject_cast<MainWindow*>(parent); |
34 } |
34 } |
35 |
35 |
36 if (m_window == nullptr) |
36 if (m_window == nullptr) |
37 { |
37 { |
38 m_window = g_win; |
38 m_window = g_win; |
39 print ("WARNING: Hierarchy element instance %p should be in the hierarchy of a " |
39 print("WARNING: Hierarchy element instance %p should be in the hierarchy of a " |
40 "MainWindow but isn't.\n", this); |
40 "MainWindow but isn't.\n", this); |
41 } |
41 } |
42 |
42 |
43 m_documents = m_window->documents(); |
43 m_documents = m_window->documents(); |
44 } |
44 } |