]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/applicationwindow.cpp
Sanity check step 1: Renaming files...
[architektonas] / src / mainapp / applicationwindow.cpp
index 326854eee048c1c6526466da40e94d79f0150ecf..42c90ccc72190f1325e2832dd608fe06b5a61449 100644 (file)
@@ -3,7 +3,9 @@
 // Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Extensively rewritten and refactored by James L. Hammons
-// (C) 2010 Underground Software
+// Portions copyright (C) 2001-2003 RibbonSoft
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
 //
 // JLH = James L. Hammons <jlhamm@acm.org>
 //
@@ -17,9 +19,9 @@
 #include "applicationwindow.h"
 
 #include <fstream>
-#include "rs_actiondrawlinefree.h"
-#include "rs_actionlibraryinsert.h"
-#include "rs_actionprintpreview.h"
+#include "actiondrawlinefree.h"
+#include "actionlibraryinsert.h"
+#include "actionprintpreview.h"
 #include "rs_creation.h"
 #include "rs_dialogfactory.h"
 #include "rs_dimaligned.h"
@@ -30,7 +32,7 @@
 #include "rs_hatch.h"
 #include "rs_insert.h"
 #include "rs_image.h"
-#include "paintintf.h"
+#include "paintinterface.h"
 #include "rs_script.h"
 #include "rs_scriptlist.h"
 #include "settings.h"
 #include "mousewidget.h"
 #include "selectionwidget.h"
 
-#include "mdiwindow.h"
-#include "qc_dialogfactory.h"
 #include "createqtactions.h"
+#include "qc_dialogfactory.h"
+#include "qg_graphicview.h"
 #include "main.h"
+#include "mdiwindow.h"
 
 ApplicationWindow * ApplicationWindow::appWindow = NULL;
 
@@ -89,6 +92,7 @@ ApplicationWindow::ApplicationWindow():
 //     setIcon(qPixmapFromMimeSource(QC_APP_ICON));
 //     setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
        setWindowIcon(QIcon(":/res/" QC_APP_ICON));
+       CreateQtActions(this);
 
        RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
        actionHandler = new QG_ActionHandler(this);
@@ -255,9 +259,9 @@ void ApplicationWindow::slotInsertBlock(const QString & name)
        GraphicView * graphicView = getGraphicView();
        RS_Document * document = getDocument();
 
-       if (graphicView != NULL && document != NULL)
+       if (graphicView && document)
        {
-               RS_ActionLibraryInsert * action = new RS_ActionLibraryInsert(*document, *graphicView);
+               ActionLibraryInsert * action = new ActionLibraryInsert(*document, *graphicView);
                action->setFile(name);
                graphicView->setCurrentAction(action);
        }
@@ -359,7 +363,6 @@ void ApplicationWindow::initMDI()
 void ApplicationWindow::initActions()
 {
        RS_DEBUG->print("ApplicationWindow::initActions()");
-       CreateQtActions(this);
 
        //
        // File actions:
@@ -1552,11 +1555,11 @@ void ApplicationWindow::slotBack()
 {
        GraphicView * graphicView = getGraphicView();
 
-       if (graphicView != NULL)
+       if (graphicView)
                graphicView->back();
        else
        {
-               if (cadToolBar != NULL)
+               if (cadToolBar)
                        cadToolBar->showToolBar(RS2::ToolBarMain);
        }
 }
@@ -1566,15 +1569,15 @@ void ApplicationWindow::slotBack()
  */
 void ApplicationWindow::slotEnter()
 {
-       if (commandWidget == NULL || !commandWidget->checkFocus())
+       if (!commandWidget || !commandWidget->checkFocus())
        {
-               if (cadToolBar != NULL)
+               if (cadToolBar)
                        cadToolBar->forceNext();
                else
                {
                        GraphicView * graphicView = getGraphicView();
 
-                       if (graphicView != NULL)
+                       if (graphicView)
                                graphicView->enter();
                }
        }
@@ -1627,7 +1630,7 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
        if (m)
                RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
 
-       if (m != NULL && m->getDocument() != NULL)
+       if (m && m->getDocument())
        {
                //m->setWindowState(WindowMaximized);
 
@@ -1900,6 +1903,7 @@ MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
        RS_DEBUG->print("  adding listeners");
        Drawing * graphic = w->getDocument()->getGraphic();
 
+#if 0
        if (graphic != NULL)
        {
                // Link the graphic's layer list to the pen tool bar
@@ -1909,6 +1913,7 @@ MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
                // Link the block list to the block widget
                graphic->addBlockListListener(blockWidget);
        }
+#endif
 
        // Link the dialog factory to the mouse widget:
        QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
@@ -2594,20 +2599,22 @@ void ApplicationWindow::slotFilePrintPreview(bool on)
                                w->setWindowIcon(QIcon(":/res/document.png"));
                                w->getGraphicView()->setPrintPreview(true);
                                w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
-                               w->getGraphicView()->setDefaultAction(new RS_ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
+                               w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
 
                                // only graphics offer block lists, blocks don't
                                RS_DEBUG->print("  adding listeners");
                                Drawing * graphic = w->getDocument()->getGraphic();
 
-                               if (graphic != NULL)
+                               if (graphic)
                                {
+#if 0
                                        // Link the layer list to the pen tool bar
                                        graphic->addLayerListListener(penToolBar);
                                        // Link the layer list to the layer widget
                                        graphic->addLayerListListener(layerWidget);
                                        // Link the block list to the block widget
                                        graphic->addBlockListListener(blockWidget);
+#endif
                                        // Center by default:
                                        graphic->centerToPage();
                                }
@@ -2718,7 +2725,7 @@ void ApplicationWindow::slotViewDraft(bool toggle)
  */
 void ApplicationWindow::redrawAll()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2726,11 +2733,11 @@ void ApplicationWindow::redrawAll()
                {
                        MDIWindow * m = (MDIWindow *)windows.at(i);
 
-                       if (m != NULL)
+                       if (m)
                        {
                                QG_GraphicView * gv = m->getGraphicView();
 
-                               if (gv != NULL)
+                               if (gv)
                                        gv->redraw();
                        }
                }
@@ -2742,7 +2749,7 @@ void ApplicationWindow::redrawAll()
  */
 void ApplicationWindow::updateGrids()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2750,11 +2757,11 @@ void ApplicationWindow::updateGrids()
                {
                        MDIWindow * m = (MDIWindow *)windows.at(i);
 
-                       if (m != NULL)
+                       if (m)
                        {
                                QG_GraphicView * gv = m->getGraphicView();
 
-                               if (gv != NULL)
+                               if (gv)
                                        gv->updateGrid();
                        }
                }
@@ -2894,11 +2901,11 @@ void ApplicationWindow::slotOptionsGeneral()
        {
                MDIWindow * m = (MDIWindow *)windows.at(i);
 
-               if (m != NULL)
+               if (m)
                {
                        QG_GraphicView * gv = m->getGraphicView();
 
-                       if (gv != NULL)
+                       if (gv)
                        {
                                gv->setBackground(color);
                                gv->setGridColor(gridColor);
@@ -3337,8 +3344,8 @@ void ApplicationWindow::slotTestDrawFreehand()
     //Drawing* g = document->getMarking();
     /*
 
-       RS_ActionDrawLineFree* action =
-          new RS_ActionDrawLineFree(*document->getGraphic(),
+       ActionDrawLineFree* action =
+          new ActionDrawLineFree(*document->getGraphic(),
                                     *graphicView);
 
        for (int i=0; i<100; ++i) {
@@ -3480,7 +3487,7 @@ void ApplicationWindow::slotTestInsertBlock()
 
                GraphicView * v = getGraphicView();
 
-               if (v != NULL)
+               if (v)
                        v->redraw();
        }
 }
@@ -3964,6 +3971,7 @@ bool ApplicationWindow::queryExit(bool force)
  */
 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
 {
+#warning "!!! keyPressEvent(): Do we need this anymore? !!!"
        // timer
        static QTime ts = QTime();
        static QString firstKey = "";
@@ -3977,13 +3985,12 @@ void ApplicationWindow::keyPressEvent(QKeyEvent * e)
        case Qt::Key_Alt:
        case Qt::Key_CapsLock:
        {
-//             Q3MainWindow::keyPressEvent(e);
                QMainWindow::keyPressEvent(e);
 
                // forward to actions:
                GraphicView * graphicView = getGraphicView();
 
-               if (graphicView != NULL)
+               if (graphicView)
                        graphicView->keyPressEvent(e);
 
                e->accept();
@@ -4073,7 +4080,7 @@ void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
                // forward to actions:
                GraphicView * graphicView = getGraphicView();
 
-               if (graphicView != NULL)
+               if (graphicView)
                        graphicView->keyReleaseEvent(e);
 
                e->accept();
@@ -4109,7 +4116,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
 
-       if (workspace != NULL)
+       if (workspace)
        {
                RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
                return (MDIWindow *)workspace->activeSubWindow();
@@ -4129,10 +4136,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getGraphicView();
-
-       return NULL;
+       return (m ? m->getGraphicView() : NULL);
 }
 
 /**
@@ -4145,10 +4149,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getDocument();
-
-       return NULL;
+       return (m ? m->getDocument() : NULL);
 }
 
 /**
@@ -4159,7 +4160,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        slotFileNew(doc);
 
-       if (fileName != QString::null && getDocument() != NULL)
+       if (fileName != QString::null && getDocument())
                getDocument()->setFilename(fileName);
 }