Skip to content

Commit

Permalink
+ fix DrawingView::onRelabel() to accept any page names
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 21, 2014
1 parent 7cc5167 commit 1b4fb56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
20 changes: 5 additions & 15 deletions src/Mod/Drawing/Gui/DrawingView.cpp
Expand Up @@ -349,21 +349,11 @@ bool DrawingView::onHasMsg(const char* pMsg) const

void DrawingView::onRelabel(Gui::Document *pDoc)
{
if (!bIsPassive) {
// Try to separate document name and object name if there is one
QString cap = windowTitle();
QRegExp rx(QString::fromLatin1(" : (\\w|\\s){1,}(\\[\\*\\]){0,1}$"));
int pos = rx.lastIndexIn(cap);
if (pos != -1) {
cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue());
cap += rx.cap();
setWindowTitle(cap);
}
else {
cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue());
cap = QString::fromAscii("%1[*]").arg(cap);
setWindowTitle(cap);
}
if (!bIsPassive && pDoc) {
QString cap = QString::fromLatin1("%1 : %2[*]")
.arg(QString::fromUtf8(pDoc->getDocument()->Label.getValue()))
.arg(objectName());
setWindowTitle(cap);
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/Mod/Drawing/Gui/ViewProviderPage.cpp
Expand Up @@ -106,12 +106,11 @@ void ViewProviderDrawingPage::updateData(const App::Property* prop)
}
else if (pcObject && prop == &pcObject->Label) {
if (view){
const char* docname = pcObject->getDocument()->Label.getValue();
const char* objname = pcObject->Label.getValue();
QString title = QString::fromAscii("%1 : %2[*]")
.arg(QString::fromUtf8(docname))
.arg(QString::fromUtf8(objname));
view->setWindowTitle(title);
view->setObjectName(QString::fromUtf8(objname));
Gui::Document* doc = Gui::Application::Instance->getDocument
(pcObject->getDocument());
view->onRelabel(doc);
}
}
}
Expand Down Expand Up @@ -147,12 +146,9 @@ DrawingView* ViewProviderDrawingPage::showDrawingView()
view = new DrawingView(doc, Gui::getMainWindow());
view->setWindowIcon(Gui::BitmapFactory().pixmap("actions/drawing-landscape"));

const char* docname = pcObject->getDocument()->Label.getValue();
const char* objname = pcObject->Label.getValue();
QString title = QString::fromAscii("%1 : %2[*]")
.arg(QString::fromUtf8(docname))
.arg(QString::fromUtf8(objname));
view->setWindowTitle(title);
view->setObjectName(QString::fromUtf8(objname));
view->onRelabel(doc);
Gui::getMainWindow()->addWindow(view);
}

Expand Down

0 comments on commit 1b4fb56

Please sign in to comment.