+ fixes #0001698: All drawing pages are opened automatically when opening a project file
This commit is contained in:
parent
c47eea61fa
commit
3614a08911
|
@ -58,7 +58,9 @@
|
|||
#include <Base/Stream.h>
|
||||
#include <Base/gzstream.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
|
@ -249,6 +251,10 @@ DrawingView::DrawingView(Gui::Document* doc, QWidget* parent)
|
|||
//setWindowTitle(tr("SVG Viewer"));
|
||||
}
|
||||
|
||||
DrawingView::~DrawingView()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawingView::load (const QString & fileName)
|
||||
{
|
||||
if (!fileName.isEmpty()) {
|
||||
|
@ -274,6 +280,27 @@ void DrawingView::load (const QString & fileName)
|
|||
}
|
||||
}
|
||||
|
||||
void DrawingView::setDocumentObject(const std::string& name)
|
||||
{
|
||||
m_objectName = name;
|
||||
}
|
||||
|
||||
void DrawingView::closeEvent(QCloseEvent* ev)
|
||||
{
|
||||
ev->accept();
|
||||
|
||||
// when closing the view from GUI notify the view provider to mark it invisible
|
||||
if (_pcDocument && !m_objectName.empty()) {
|
||||
App::Document* doc = _pcDocument->getDocument();
|
||||
if (doc) {
|
||||
App::DocumentObject* obj = doc->getObject(m_objectName.c_str());
|
||||
Gui::ViewProvider* vp = _pcDocument->getViewProvider(obj);
|
||||
if (vp)
|
||||
vp->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu menu;
|
||||
|
|
|
@ -80,6 +80,7 @@ class DrawingGuiExport DrawingView : public Gui::MDIView
|
|||
|
||||
public:
|
||||
DrawingView(Gui::Document* doc, QWidget* parent = 0);
|
||||
virtual ~DrawingView();
|
||||
|
||||
public Q_SLOTS:
|
||||
void load(const QString &path = QString());
|
||||
|
@ -94,10 +95,12 @@ public:
|
|||
void printPdf();
|
||||
void printPreview();
|
||||
void print(QPrinter* printer);
|
||||
void setDocumentObject(const std::string&);
|
||||
PyObject* getPyObject();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
private:
|
||||
QAction *m_nativeAction;
|
||||
|
@ -108,6 +111,7 @@ private:
|
|||
QAction *m_outlineAction;
|
||||
|
||||
SvgView *m_view;
|
||||
std::string m_objectName;
|
||||
|
||||
QString m_currentPath;
|
||||
};
|
||||
|
|
|
@ -66,6 +66,10 @@ ViewProviderDrawingPage::ViewProviderDrawingPage()
|
|||
ADD_PROPERTY(HintScale,(10.0));
|
||||
ADD_PROPERTY(HintOffsetX,(10.0));
|
||||
ADD_PROPERTY(HintOffsetY,(10.0));
|
||||
|
||||
// do not show this in the property editor
|
||||
Visibility.StatusBits.set(3, true);
|
||||
DisplayMode.StatusBits.set(3, true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingPage::~ViewProviderDrawingPage()
|
||||
|
@ -91,17 +95,40 @@ std::vector<std::string> ViewProviderDrawingPage::getDisplayModes(void) const
|
|||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderDrawingPage::show(void)
|
||||
{
|
||||
// showing the drawing page should not affect its children but opens the MDI view
|
||||
// therefore do not call the method of its direct base class
|
||||
ViewProviderDocumentObject::show();
|
||||
if (!this->view) {
|
||||
showDrawingView();
|
||||
this->view->load(QString::fromUtf8(getPageObject()->PageResult.getValue()));
|
||||
view->viewAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderDrawingPage::hide(void)
|
||||
{
|
||||
// hiding the drawing page should not affect its children but closes the MDI view
|
||||
// therefore do not call the method of its direct base class
|
||||
ViewProviderDocumentObject::hide();
|
||||
if (view) {
|
||||
view->parentWidget()->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderDrawingPage::updateData(const App::Property* prop)
|
||||
{
|
||||
Gui::ViewProviderDocumentObjectGroup::updateData(prop);
|
||||
if (prop->getTypeId() == App::PropertyFileIncluded::getClassTypeId()) {
|
||||
if (std::string(getPageObject()->PageResult.getValue()) != "") {
|
||||
DrawingView* view = showDrawingView();
|
||||
view->load(QString::fromUtf8(getPageObject()->PageResult.getValue()));
|
||||
if (view->isHidden())
|
||||
QTimer::singleShot(300, view, SLOT(viewAll()));
|
||||
else
|
||||
view->viewAll();
|
||||
if (view) {
|
||||
view->load(QString::fromUtf8(getPageObject()->PageResult.getValue()));
|
||||
if (view->isHidden())
|
||||
QTimer::singleShot(300, view, SLOT(viewAll()));
|
||||
else
|
||||
view->viewAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pcObject && prop == &pcObject->Label) {
|
||||
|
@ -129,11 +156,7 @@ bool ViewProviderDrawingPage::setEdit(int ModNum)
|
|||
|
||||
bool ViewProviderDrawingPage::doubleClicked(void)
|
||||
{
|
||||
if (!this->view) {
|
||||
showDrawingView();
|
||||
this->view->load(QString::fromUtf8(getPageObject()->PageResult.getValue()));
|
||||
view->viewAll();
|
||||
}
|
||||
show();
|
||||
Gui::getMainWindow()->setActiveWindow(this->view);
|
||||
return true;
|
||||
}
|
||||
|
@ -149,6 +172,7 @@ DrawingView* ViewProviderDrawingPage::showDrawingView()
|
|||
const char* objname = pcObject->Label.getValue();
|
||||
view->setObjectName(QString::fromUtf8(objname));
|
||||
view->onRelabel(doc);
|
||||
view->setDocumentObject(pcObject->getNameInDocument());
|
||||
Gui::getMainWindow()->addWindow(view);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@ public:
|
|||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
/// Hides the view provider
|
||||
virtual void hide(void);
|
||||
/// Shows the view provider
|
||||
virtual void show(void);
|
||||
|
||||
/// Is called by the tree if the user double click on the object
|
||||
virtual bool doubleClicked(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user