Moved most dock widgets into the MapEditor · mapeditor/tiled@5e380ba (original) (raw)
`@@ -65,6 +65,7 @@ void DocumentManager::deleteInstance()
`
65
65
``
66
66
`DocumentManager::DocumentManager(QObject *parent)
`
67
67
` : QObject(parent)
`
``
68
`+
, mMapEditor(nullptr) // todo: look into removing this
`
68
69
` , mUndoGroup(new QUndoGroup(this))
`
69
70
` , mFileSystemWatcher(new FileSystemWatcher(this))
`
70
71
`{
`
`@@ -76,15 +77,12 @@ DocumentManager::DocumentManager(QObject *parent)
`
76
77
`mTabBar->setTabsClosable(true);
`
77
78
`mTabBar->setMovable(true);
`
78
79
``
79
``
`-
mMapEditor = new MapEditor(mWidget);
`
80
``
-
81
80
` QVBoxLayout *vertical = new QVBoxLayout(mWidget);
`
82
81
` vertical->addWidget(mTabBar);
`
83
82
` vertical->setMargin(0);
`
84
83
` vertical->setSpacing(0);
`
85
84
``
86
85
`mEditorStack = new QStackedLayout;
`
87
``
`-
mEditorStack->addWidget(mMapEditor);
`
88
86
` vertical->addLayout(mEditorStack);
`
89
87
``
90
88
`connect(mTabBar, &QTabBar::currentChanged,
`
`@@ -114,6 +112,21 @@ QWidget *DocumentManager::widget() const
`
114
112
`return mWidget;
`
115
113
`}
`
116
114
``
``
115
`+
void DocumentManager::setEditor(Document::DocumentType documentType, QWidget *editor)
`
``
116
`+
{
`
``
117
`+
Q_ASSERT(!mEditorForType.contains(documentType));
`
``
118
`+
mEditorForType.insert(documentType, editor);
`
``
119
`+
mEditorStack->addWidget(editor);
`
``
120
+
``
121
`+
if (MapEditor *mapEditor = qobject_cast<MapEditor*>(editor))
`
``
122
`+
mMapEditor = mapEditor;
`
``
123
`+
}
`
``
124
+
``
125
`+
void DocumentManager::openFile(const QString &path)
`
``
126
`+
{
`
``
127
`+
emit fileOpenRequested(path);
`
``
128
`+
}
`
``
129
+
117
130
`Document *DocumentManager::currentDocument() const
`
118
131
`{
`
119
132
`const int index = mTabBar->currentIndex();
`
`@@ -334,9 +347,10 @@ void DocumentManager::currentIndexChanged()
`
334
347
`{
`
335
348
` Document *document = currentDocument();
`
336
349
``
337
``
`-
if (MapDocument *mapDocument = qobject_cast<MapDocument*>(document)) {
`
338
``
`-
mMapEditor->setCurrentMapDocument(mapDocument);
`
339
``
`-
mEditorStack->setCurrentWidget(mMapEditor);
`
``
350
`+
if (QWidget *editor = mEditorForType.value(document->type())) {
`
``
351
`+
if (MapDocument *mapDocument = qobject_cast<MapDocument*>(document))
`
``
352
`+
mMapEditor->setCurrentMapDocument(mapDocument);
`
``
353
`+
mEditorStack->setCurrentWidget(editor);
`
340
354
` }
`
341
355
``
342
356
`if (!document)
`