1 // qc_dialogfactory.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/17/2010 Added this text. :-)
17 #include "qc_dialogfactory.h"
19 #include "applicationwindow.h"
20 #include "blocklist.h"
21 #include "qg_graphicview.h"
23 QC_DialogFactory::QC_DialogFactory(QWidget * parent, QToolBar * ow): QG_DialogFactory(parent, ow)
27 /*virtual*/ QC_DialogFactory::~QC_DialogFactory()
32 * Provides a new window for editing the active block.
34 void QC_DialogFactory::requestEditBlockWindow(BlockList * blockList)
36 DEBUG->print("QC_DialogFactory::requestEditBlockWindow()");
38 ApplicationWindow * appWindow = ApplicationWindow::getAppWindow();
39 MDIWindow * parent = appWindow->getMDIWindow();
41 if (parent && blockList)
43 Block * block = blockList->getActive();
47 MDIWindow * w = appWindow->slotFileNew(block);
48 // the parent needs a pointer to the block window and vice versa
49 parent->addChildWindow(w);
50 w->getGraphicView()->zoomAuto(false);
56 * Closes all windows that are editing the given block.
58 void QC_DialogFactory::closeEditBlockWindow(Block * block)
60 DEBUG->print("QC_DialogFactory::closeEditBlockWindow");
62 ApplicationWindow * appWindow = ApplicationWindow::getAppWindow();
63 QMdiArea * workspace = appWindow->getWorkspace();
67 DEBUG->print("QC_DialogFactory::closeEditBlockWindow: workspace found");
69 QList<QMdiSubWindow *> windows = workspace->subWindowList();
71 for(int i=0; i<windows.count(); i++)
73 DEBUG->print("QC_DialogFactory::closeEditBlockWindow: window: %d", i);
74 MDIWindow * m = (MDIWindow *)windows.at(i);
78 DEBUG->print("QC_DialogFactory::closeEditBlockWindow: got mdi");
80 if (m->getDocument() == block)
82 DEBUG->print("QC_DialogFactory::closeEditBlockWindow: closing mdi");
83 //m->closeMDI(true, false);
91 appWindow->slotWindowActivated(NULL);
93 DEBUG->print("QC_DialogFactory::closeEditBlockWindow: OK");