]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/mdiwindow.cpp
Merged QC_GraphicView into QG_GraphicView...
[architektonas] / src / mainapp / mdiwindow.cpp
index d4f4e1aeddfe6ebfe1419c250dcdc64a6ed34bde..ee6cc3fe009cef478b21250225c836f19c9b97a8 100644 (file)
@@ -18,6 +18,7 @@
 #include "rs_eventhandler.h"
 #include "exitdialog.h"
 #include "qg_filedialog.h"
+#include "qg_graphicview.h"
 
 // Class variable
 int MDIWindow::idCounter = 0;
@@ -31,27 +32,23 @@ 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);
        }
@@ -67,13 +64,13 @@ MDIWindow::MDIWindow(RS_Document * doc, QWidget * parent, const char * name/*= N
  */
 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;
@@ -133,19 +130,19 @@ MDIWindow * MDIWindow::getPrintPreview()
 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);
@@ -161,19 +158,6 @@ bool MDIWindow::closeMDI(bool force, bool ask)
                // 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();
@@ -181,7 +165,6 @@ bool MDIWindow::closeMDI(bool force, bool ask)
                        if (child)
                                child->close();
                }
-#endif
 
                emit(signalClosing());
                ret = true;
@@ -221,7 +204,7 @@ void MDIWindow::initDoc(RS_Document * doc)
 {
        RS_DEBUG->print("MDIWindow::initDoc()");
 
-       if (doc == NULL)
+       if (!doc)
        {
                document = new Drawing();
                document->newDoc();
@@ -241,8 +224,8 @@ void MDIWindow::initView()
 {
        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();
 }
@@ -255,7 +238,7 @@ void MDIWindow::slotPenChanged(RS_Pen pen)
 {
        RS_DEBUG->print("MDIWindow::slotPenChanged() begin");
 
-       if (document != NULL)
+       if (document)
                document->setActivePen(pen);
 
        RS_DEBUG->print("MDIWindow::slotPenChanged() end");
@@ -268,7 +251,7 @@ void MDIWindow::slotFileNew()
 {
        RS_DEBUG->print("MDIWindow::slotFileNew begin");
 
-       if (document != NULL && graphicView != NULL)
+       if (document && graphicView)
        {
                document->newDoc();
                graphicView->redraw();
@@ -288,10 +271,6 @@ bool MDIWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
        if (document != NULL && !fileName.isEmpty())
        {
                document->newDoc();
-
-               // cosmetics..
-//bah          RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
                ret = document->open(fileName, type);
 
                if (ret)
@@ -332,7 +311,7 @@ bool MDIWindow::slotFileSave(bool & cancelled)
        bool ret = false;
        cancelled = false;
 
-       if (document != NULL)
+       if (document)
        {
                if (document->getFilename().isEmpty())
                        ret = slotFileSaveAs(cancelled);
@@ -392,7 +371,7 @@ bool MDIWindow::slotFileClose(bool force)
        bool succ = true;
        int exit = 0;
 
-       if (document != NULL && document->isModified())
+       if (document && document->isModified())
        {
                ExitDialog dlg(this);
                dlg.setForce(force);
@@ -468,13 +447,14 @@ void MDIWindow::slotFilePrint()
                // 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;
 }
@@ -494,7 +474,7 @@ Drawing * MDIWindow::getGraphic()
 /** @return Pointer to current event handler */
 RS_EventHandler * MDIWindow::getEventHandler()
 {
-       if (graphicView != NULL)
+       if (graphicView)
                return graphicView->getEventHandler();
        else
                return NULL;
@@ -529,7 +509,7 @@ std::ostream & operator<<(std::ostream & os, MDIWindow & w)
 {
        os << "MDIWindow[" << w.getId() << "]:\n";
 
-       if (w.parentWindow!=NULL)
+       if (w.parentWindow)
                os << "  parentWindow: " << w.parentWindow->getId() << "\n";
        else
                os << "  parentWindow: NULL\n";