src/hierarchyelement.cpp

Tue, 22 Sep 2015 23:38:19 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 22 Sep 2015 23:38:19 +0300
changeset 997
1b49f34e533d
parent 985
ed7b31b9f904
child 1006
a6b462051ae0
permissions
-rw-r--r--

Commit work done on document manager. Happy 3rd birthday LDForge!

970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 #include <QMetaObject>
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 #include "hierarchyelement.h"
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 #include "mainwindow.h"
974
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
5 #include "guiutilities.h"
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 HierarchyElement::HierarchyElement (QObject* parent) :
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 m_window (nullptr),
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 m_config (nullptr)
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 {
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 if (parent)
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 {
985
ed7b31b9f904 Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
13 while (parent->parent())
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 parent = parent->parent();
972
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
15
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 m_window = qobject_cast<MainWindow*> (parent);
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 }
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 if (m_window == nullptr)
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 {
972
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
21 m_window = g_win;
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
22 print ("WARNING: Hierarchy element instance %p should be in the hierarchy of a "
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
23 "MainWindow but isn't.\n", this);
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 }
972
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
25
a34b73114823 Now doesn't crash anymore
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
26 m_config = m_window->configBag();
997
1b49f34e533d Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 985
diff changeset
27 m_documents = m_window->documents();
970
c8aae45afd85 Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 }
974
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
29
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
30 GuiUtilities* HierarchyElement::guiUtilities() const
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
31 {
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
32 return m_window->guiUtilities();
b2fa5f89798a Added a GuiUtilities class to contain useful non-MainWindow-related GUI functions
Teemu Piippo <crimsondusk64@gmail.com>
parents: 972
diff changeset
33 }
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
34
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
35 LDDocument* HierarchyElement::currentDocument()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
36 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
37 return m_window->currentDocument();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
38 }
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
39
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
40 const LDObjectList& HierarchyElement::selectedObjects()
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
41 {
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
42 return m_window->selectedObjects();
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 974
diff changeset
43 }

mercurial