src/mainwindow.cpp

changeset 200
ca23936b455b
parent 191
d355d4c52d51
child 201
5d201ee4a9c3
--- a/src/mainwindow.cpp	Wed May 25 20:36:34 2022 +0300
+++ b/src/mainwindow.cpp	Mon Jun 06 22:01:22 2022 +0300
@@ -28,7 +28,6 @@
 #include "document.h"
 #include "uiutilities.h"
 #include "widgets/colorselectdialog.h"
-#include "modeleditor.h"
 
 template<typename BaseType, typename MemberType, typename DataType>
 struct MemberData
@@ -193,9 +192,13 @@
 
 void MainWindow::openModelForEditing(const ModelId modelId)
 {
-	Document* document = new Document{this->documents.getModelById(modelId), &this->documents, this->colorTable};
+	EditorTabWidget* document = new EditorTabWidget{
+		this->documents.getModelById(modelId),
+		&this->documents,
+		this->colorTable,
+	};
 	document->canvas->setRenderPreferences(this->renderPreferences);
-	connect(document, &Document::newStatusText, [&](const QString& newStatusText)
+	connect(document, &EditorTabWidget::newStatusText, [&](const QString& newStatusText)
 	{
 		this->statusBar()->showMessage(newStatusText);
 	});
@@ -220,25 +223,25 @@
 	}
 }
 
-Document* MainWindow::currentDocument()
+EditorTabWidget* MainWindow::currentDocument()
 {
-	return qobject_cast<Document*>(this->ui->tabs->currentWidget());
+	return qobject_cast<EditorTabWidget*>(this->ui->tabs->currentWidget());
 }
 
-const Document* MainWindow::currentDocument() const
+const EditorTabWidget* MainWindow::currentDocument() const
 {
-	return qobject_cast<const Document*>(this->ui->tabs->currentWidget());
+	return qobject_cast<const EditorTabWidget*>(this->ui->tabs->currentWidget());
 }
 
 void MainWindow::handleDocumentSplitterChange()
 {
-	Document* currentDocument = this->currentDocument();
+	EditorTabWidget* currentDocument = this->currentDocument();
 	if (currentDocument != nullptr)
 	{
 		this->documentSplitterState = currentDocument->saveSplitterState();
 		for (int i = 0; i < this->ui->tabs->count(); i += 1)
 		{
-			Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i));
+			EditorTabWidget* document = qobject_cast<EditorTabWidget*>(this->ui->tabs->widget(i));
 			if (document != nullptr and document != currentDocument)
 			{
 				document->restoreSplitterState(this->documentSplitterState);
@@ -363,7 +366,8 @@
  */
 void MainWindow::actionDelete()
 {
-	Document* document = this->currentDocument();
+	/*
+	EditorTabWidget* document = this->currentDocument();
 	if (document != nullptr)
 	{
 		std::unique_ptr<ModelEditor> modelEditor = document->editModel();
@@ -377,6 +381,7 @@
 			}
 		}
 	}
+	*/
 }
 
 /**
@@ -384,7 +389,8 @@
  */
 void MainWindow::actionInvert()
 {
-	Document* document = this->currentDocument();
+	/*
+	EditorTabWidget* document = this->currentDocument();
 	if (document != nullptr)
 	{
 		// TODO: simplify
@@ -405,6 +411,7 @@
 			}
 		}
 	}
+	*/
 }
 
 /**
@@ -415,7 +422,7 @@
 {
 	if (tabIndex >= 0 and tabIndex < this->ui->tabs->count())
 	{
-		Document* document = qobject_cast<Document*>(this->ui->tabs->widget(tabIndex));
+		EditorTabWidget* document = qobject_cast<EditorTabWidget*>(this->ui->tabs->widget(tabIndex));
 		if (document != nullptr)
 		{
 			this->closeDocument(document);
@@ -427,9 +434,9 @@
  * @brief Closes the specified document
  * @param document
  */
-void MainWindow::closeDocument(Document *document)
+void MainWindow::closeDocument(EditorTabWidget *document)
 {
-	std::optional<ModelId> modelId = this->documents.findIdForModel(&document->getModel());
+	std::optional<ModelId> modelId = this->documents.findIdForModel(document->model);
 	if (modelId.has_value())
 	{
 		this->documents.closeDocument(modelId.value());
@@ -439,10 +446,10 @@
 
 std::optional<ModelId> MainWindow::findCurrentModelId() const
 {
-	const Document* document = this->currentDocument();
+	const EditorTabWidget* document = this->currentDocument();
 	if (document != nullptr)
 	{
-		return this->documents.findIdForModel(&document->getModel());
+		return this->documents.findIdForModel(document->model);
 	}
 	else
 	{
@@ -492,7 +499,7 @@
 {
 	for (int i = 0; i < this->ui->tabs->count(); i += 1)
 	{
-		Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i));
+		EditorTabWidget* document = qobject_cast<EditorTabWidget*>(this->ui->tabs->widget(i));
 		if (document != nullptr)
 		{
 			document->canvas->setRenderPreferences(this->renderPreferences);

mercurial