src/mainwindow.cpp

changeset 1291
9c570a30c98a
parent 1283
3c3a5eb965f7
child 1306
be85306198a2
--- a/src/mainwindow.cpp	Fri Mar 16 12:20:16 2018 +0200
+++ b/src/mainwindow.cpp	Fri Mar 16 16:28:39 2018 +0200
@@ -86,6 +86,12 @@
 		connect (act, SIGNAL (triggered()), this, SLOT (actionTriggered()));
 		m_defaultShortcuts[act] = act->shortcut();
 	});
+	connect(
+		ui.header,
+		&HeaderEdit::descriptionChanged,
+		this,
+		&MainWindow::updateTitle
+	);
 
 	updateGridToolBar();
 	updateEditModeActions();
@@ -277,7 +283,7 @@
 //
 void MainWindow::updateTitle()
 {
-	QString title = format (APPNAME " " VERSION_STRING);
+	QString title = APPNAME " " VERSION_STRING;
 
 	// Append our current file if we have one
 	if (m_currentDocument)
@@ -285,13 +291,8 @@
 		title += ": ";
 		title += m_currentDocument->getDisplayName();
 
-		if (m_currentDocument->size() > 0 and
-		    m_currentDocument->getObject(0)->type() == LDObjectType::Comment)
-		{
-			// Append title
-			LDComment* comm = static_cast <LDComment*> (m_currentDocument->getObject (0));
-			title += format (": %1", comm->text());
-		}
+		if (not m_currentDocument->header.description.isEmpty())
+			title += format (": %1", m_currentDocument->header.description);
 
 		if (m_currentDocument->hasUnsavedChanges())
 			title += '*';
@@ -947,6 +948,7 @@
 		updateTitle();
 		print ("Changed document to %1", document->getDisplayName());
 		ui.objectList->setModel(document);
+		ui.header->setHeader(&document->header);
 		QItemSelectionModel* selection = m_selections.value(document);
 
 		if (selection == nullptr)

mercurial