src/mainwindow.cpp

changeset 147
37f936073cac
parent 142
e085f36e4d9f
child 148
e1ced2523cad
--- a/src/mainwindow.cpp	Tue Sep 28 23:09:09 2021 +0300
+++ b/src/mainwindow.cpp	Sun Oct 24 11:33:32 2021 +0300
@@ -209,6 +209,26 @@
 	return qobject_cast<Document*>(this->ui->tabs->currentWidget());
 }
 
+void MainWindow::closeDocument(Document *document)
+{
+	const int tabIndex = this->ui->tabs->indexOf(document);
+	if (tabIndex != -1)
+	{
+		this->ui->tabs->removeTab(tabIndex);
+		const QString closedDocumentName = pathToName(document->modelPath());
+		delete document;
+	}
+	QSet<QString> openedDocumentNames;
+	for (int i = 0; i < this->ui->tabs->count(); i += 1)
+	{
+		Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i));
+		if (document != nullptr)
+		{
+			openedDocumentNames.insert(pathToName(document->modelPath()));
+		}
+	}
+}
+
 void MainWindow::handleDocumentSplitterChange()
 {
 	Document* currentDocument = this->currentDocument();

mercurial