#include "rs_eventhandler.h"
#include "exitdialog.h"
#include "qg_filedialog.h"
+#include "qg_graphicview.h"
// Class variable
int MDIWindow::idCounter = 0;
*/
MDIWindow::MDIWindow(RS_Document * doc, QWidget * parent, const char * name/*= NULL*/,
Qt::WindowFlags wflags/*= Qt::WDestructiveClose*/):
- QMdiSubWindow(parent, Qt::SubWindow)
+ QMdiSubWindow(parent, Qt::SubWindow), owner(false), forceClosing(false)
#warning "!!! wflags is ignored !!!"
{
- owner = false;
- forceClosing = false;
//This warning is most likely coming from the QMdiSubWindow() constructor above...
#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
initDoc(doc);
initView();
id = idCounter++;
-//No worries: Only need to be more vigilant if this were TRUE
-// childWindows.setAutoDelete(false);
parentWindow = NULL;
- if (document != NULL)
+ if (document)
{
- if (document->getLayerList() != NULL)
+ if (document->getLayerList())
// Link the graphic view to the layer widget
document->getLayerList()->addListener(graphicView);
- if (document->getBlockList() != NULL)
+ if (document->getBlockList())
// Link the graphic view to the block widget
document->getBlockList()->addListener(graphicView);
}
*/
MDIWindow::~MDIWindow()
{
- if (document->getLayerList() != NULL)
+ if (document->getLayerList())
document->getLayerList()->removeListener(graphicView);
- if (document->getBlockList() != NULL)
+ if (document->getBlockList())
document->getBlockList()->removeListener(graphicView);
- if (owner == true && document != NULL)
+ if (owner && document)
delete document;
document = NULL;
bool MDIWindow::closeMDI(bool force, bool ask)
{
// should never happen:
- if (document == NULL)
+ if (!document)
return true;
bool ret = false;
bool isBlock = (parentWindow != NULL);
// This is a block and we don't need to ask the user for closing
- // since it's still available in the parent drawing after closing.
+ // since it's still available in the parent drawing after closing.
if (isBlock)
{
RS_DEBUG->print(" closing block");
// tell parent window we're not here anymore.
- if (parentWindow != NULL)
+ if (parentWindow)
{
RS_DEBUG->print(" notifying parent about closing this window");
parentWindow->removeChildWindow(this);
// close all child windows:
bool done;
-#if 0 // UGH! WHY??!??!
- do
- {
- done = true;
-
- if (childWindows.at(0) != NULL)
- {
- childWindows.at(0)->close();
- done = false;
- }
- }
- while (!done);
-#else
while (!childWindows.isEmpty())
{
MDIWindow * child = childWindows.takeFirst();
if (child)
child->close();
}
-#endif
emit(signalClosing());
ret = true;
{
RS_DEBUG->print("MDIWindow::initDoc()");
- if (doc == NULL)
+ if (!doc)
{
document = new Drawing();
document->newDoc();
{
RS_DEBUG->print("MDIWindow::initView()");
- graphicView = new QC_GraphicView(document, this);
-// setCentralWidget(graphicView);
+// graphicView = new QC_GraphicView(document, this);
+ graphicView = new QG_GraphicView(document, this);
setWidget(graphicView);
graphicView->setFocus();
}
{
RS_DEBUG->print("MDIWindow::slotPenChanged() begin");
- if (document != NULL)
+ if (document)
document->setActivePen(pen);
RS_DEBUG->print("MDIWindow::slotPenChanged() end");
{
RS_DEBUG->print("MDIWindow::slotFileNew begin");
- if (document != NULL && graphicView != NULL)
+ if (document && graphicView)
{
document->newDoc();
graphicView->redraw();
if (document != NULL && !fileName.isEmpty())
{
document->newDoc();
-
- // cosmetics..
-//bah RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
ret = document->open(fileName, type);
if (ret)
bool ret = false;
cancelled = false;
- if (document != NULL)
+ if (document)
{
if (document->getFilename().isEmpty())
ret = slotFileSaveAs(cancelled);
bool succ = true;
int exit = 0;
- if (document != NULL && document->isModified())
+ if (document && document->isModified())
{
ExitDialog dlg(this);
dlg.setForce(force);
// TODO: Define printing by using the QPainter methods here
painter.end();
- };
+ }
//statusBar()->message(tr("Ready."));
}
/** @return Pointer to graphic view */
-QC_GraphicView * MDIWindow::getGraphicView()
+//QC_GraphicView * MDIWindow::getGraphicView()
+QG_GraphicView * MDIWindow::getGraphicView()
{
return graphicView;
}
/** @return Pointer to current event handler */
RS_EventHandler * MDIWindow::getEventHandler()
{
- if (graphicView != NULL)
+ if (graphicView)
return graphicView->getEventHandler();
else
return NULL;
{
os << "MDIWindow[" << w.getId() << "]:\n";
- if (w.parentWindow!=NULL)
+ if (w.parentWindow)
os << " parentWindow: " << w.parentWindow->getId() << "\n";
else
os << " parentWindow: NULL\n";