Use Page Label for Tab Text

This commit is contained in:
wandererfan
2018-10-19 11:56:51 -04:00
committed by Yorik van Havre
parent 8280d551a9
commit 3ca8eb0989
3 changed files with 15 additions and 9 deletions

View File

@@ -559,13 +559,12 @@ bool MDIViewPage::onHasMsg(const char* pMsg) const
return false;
}
void MDIViewPage::onRelabel(Gui::Document *pDoc)
//called by ViewProvider when Page feature Label changes
void MDIViewPage::setTabText(std::string t)
{
if (!bIsPassive && pDoc) {
QString cap = QString::fromLatin1("%1 : %2[*]")
.arg(QString::fromUtf8(pDoc->getDocument()->Label.getValue()))
.arg(objectName());
if (!isPassive() && !t.empty()) {
QString cap = QString::fromLatin1("%1 [*]")
.arg(QString::fromUtf8(t.c_str()));
setWindowTitle(cap);
}
}

View File

@@ -72,7 +72,6 @@ public:
bool onMsg(const char* pMsg,const char** ppReturn);
bool onHasMsg(const char* pMsg) const;
void onRelabel(Gui::Document *pDoc);
void print();
void print(QPrinter* printer);
@@ -98,6 +97,9 @@ public:
void redrawAllViews(void);
void redraw1View(TechDraw::DrawView* dv);
void setTabText(std::string t);
public Q_SLOTS:
void setRenderer(QAction *action);

View File

@@ -154,8 +154,12 @@ void ViewProviderPage::updateData(const App::Property* prop)
m_mdiView->matchSceneRectToTemplate();
m_mdiView->updateTemplate();
}
} else if (prop == &(getDrawPage()->Label)) {
if(m_mdiView &&
!getDrawPage()->isUnsetting()) {
m_mdiView->setTabText(getDrawPage()->Label.getValue());
}
}
Gui::ViewProviderDocumentObject::updateData(prop);
}
@@ -214,7 +218,8 @@ bool ViewProviderPage::showMDIViewPage()
Gui::Document* doc = Gui::Application::Instance->getDocument
(pcObject->getDocument());
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
// QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
QString tabTitle = QString::fromUtf8(getDrawPage()->Label.getValue());
m_mdiView->setDocumentObject(getDrawPage()->getNameInDocument());
m_mdiView->setDocumentName(pcObject->getDocument()->getName());