]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/applicationwindow.cpp
Fixed spurious library paths being added to Library Browser.
[architektonas] / src / mainapp / applicationwindow.cpp
index e91576fcfeb078a2e4a75823032e8651a75bb338..0566beb287f12d6aba77a1d1c78b6f1d4cac238e 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 "rs_simulationcontrols.h"
 #endif
 
-#include "qg_colorbox.h"
-#include "qg_filedialog.h"
-#include "qg_pentoolbar.h"
+#include "colorbox.h"
+#include "filedialog.h"
+#include "pentoolbar.h"
+#include "recentfiles.h"
 #include "cadtoolbar.h"
 #include "cadtoolbarmain.h"
 #include "coordinatewidget.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;
 
@@ -88,9 +92,10 @@ 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);
+       actionHandler = new ActionHandler(this);
        RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
 
 #ifdef RS_SCRIPTING
@@ -210,7 +215,7 @@ void ApplicationWindow::slotRunScript(const QString & name)
     statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
 
        QStringList scriptList = RS_SYSTEM->getScriptList();
-       scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
+       scriptList.append(RS_SYSTEM->getHomeDir() + "/.architektonas/" + name);
 
        for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
        {
@@ -251,12 +256,12 @@ void ApplicationWindow::slotInsertBlock(const QString & name)
 
        statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
 
-       RS_GraphicView * graphicView = getGraphicView();
+       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);
        }
@@ -358,7 +363,6 @@ void ApplicationWindow::initMDI()
 void ApplicationWindow::initActions()
 {
        RS_DEBUG->print("ApplicationWindow::initActions()");
-       CreateQtActions(this);
 
        //
        // File actions:
@@ -1262,7 +1266,7 @@ void ApplicationWindow::initMenuBar()
 //             menuBar()->insertItem(tr("De&bugging"), testMenu);
                menuBar()->addMenu(testMenu);
 
-       recentFiles = new QG_RecentFiles(this, fileMenu);
+       recentFiles = new RecentFiles(this, fileMenu);
 }
 
 /**
@@ -1281,7 +1285,7 @@ void ApplicationWindow::initToolBar()
 //     zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
        zoomToolBar = addToolBar(tr("Zoom Operations"));
        zoomToolBar->setObjectName("zoom");
-       penToolBar = new QG_PenToolBar(this, "Pen Selection");
+       penToolBar = new PenToolBar(this, "Pen Selection");
        penToolBar->setObjectName("pen");
 
        connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
@@ -1446,7 +1450,7 @@ void ApplicationWindow::initView()
 //     dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
        dw = new QDockWidget(tr("Layer List"), this);
        dw->setObjectName("layer");
-       layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
+       layerWidget = new LayerWidget(actionHandler, dw, "Layer");
        layerWidget->setFocusPolicy(Qt::NoFocus);
        connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
        connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
@@ -1463,7 +1467,7 @@ void ApplicationWindow::initView()
 //     dw = new QDockWidget(QDockWidget::InDock, this, "Block");
        dw = new QDockWidget(tr("Block List"), this);
        dw->setObjectName("block");
-       blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
+       blockWidget = new BlockWidget(actionHandler, dw, "Block");
        blockWidget->setFocusPolicy(Qt::NoFocus);
        connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
        connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
@@ -1494,9 +1498,11 @@ void ApplicationWindow::initView()
 //     dw->setCaption(tr("Library Browser"));
 //not sure how to fix this one
 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
-       addDockWidget(Qt::NoDockWidgetArea, dw);
+//     addDockWidget(Qt::NoDockWidgetArea, dw);
+//This works, but sux
+       addDockWidget(Qt::RightDockWidgetArea, dw);
        libraryDockWindow = dw;
-       libraryDockWindow->hide();
+//     libraryDockWindow->hide();
 
        RS_DEBUG->print("  command widget..");
 //     dw = new QDockWidget(QDockWidget::InDock, this, "Command");
@@ -1544,49 +1550,18 @@ void ApplicationWindow::initView()
        }
 }*/
 
-#warning "!!! ApplicationWindow::updateRecentFilesMenu() is DEPRECATED !!!"
-/**
- * Updates the recent file list in the file menu.
- */
-void ApplicationWindow::updateRecentFilesMenu()
-{
-       RS_DEBUG->print("ApplicationWindow::updateRecentFilesMenu()");
-       RS_DEBUG->print("Updating recent file menu...");
-
-#if 0
-       for(int i=0; i<recentFiles->getNumber(); ++i)
-       {
-               QString label = QString("&%1 %2").arg(i + 1).arg(recentFiles->get(i));
-
-               if (fileMenu->findItem(i))
-               {
-                       RS_DEBUG->print("Changeing item %d", i);
-                       fileMenu->changeItem(i, label);
-               }
-               else if (i < int(recentFiles->count()))
-               {
-                       RS_DEBUG->print("Adding item %d", i);
-                       fileMenu->insertItem(label, this, SLOT(slotFileOpenRecent(int)), 0, i);
-               }
-       }
-#else
-//#warning "!!! Need to fix ApplicationWindow::updateRecentFilesMenu() !!!"
-       recentFiles->UpdateGUI();
-#endif
-}
-
 /**
  * Goes back to the previous menu or one step in the current action.
  */
 void ApplicationWindow::slotBack()
 {
-       RS_GraphicView * graphicView = getGraphicView();
+       GraphicView * graphicView = getGraphicView();
 
-       if (graphicView != NULL)
+       if (graphicView)
                graphicView->back();
        else
        {
-               if (cadToolBar != NULL)
+               if (cadToolBar)
                        cadToolBar->showToolBar(RS2::ToolBarMain);
        }
 }
@@ -1596,15 +1571,15 @@ void ApplicationWindow::slotBack()
  */
 void ApplicationWindow::slotEnter()
 {
-       if (commandWidget == NULL || !commandWidget->checkFocus())
+       if (!commandWidget || !commandWidget->checkFocus())
        {
-               if (cadToolBar != NULL)
+               if (cadToolBar)
                        cadToolBar->forceNext();
                else
                {
-                       RS_GraphicView * graphicView = getGraphicView();
+                       GraphicView * graphicView = getGraphicView();
 
-                       if (graphicView != NULL)
+                       if (graphicView)
                                graphicView->enter();
                }
        }
@@ -1654,10 +1629,11 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
 //which means the subwindow is NOT being activated!!!
        MDIWindow * m = getMDIWindow();
        RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
+
        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);
 
@@ -1688,7 +1664,7 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
                slotPenChanged(penToolBar->getPen());
 
                // update toggle button status:
-               if (m->getGraphic() != NULL)
+               if (m->getGraphic())
                {
                        emit(gridChanged(m->getGraphic()->isGridOn()));
                        emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
@@ -1930,6 +1906,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
@@ -1939,6 +1916,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);
@@ -1998,7 +1976,7 @@ void ApplicationWindow::slotFileOpen()
        RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
        RS2::FormatType type = RS2::FormatUnknown;
        RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
-       QString fileName = QG_FileDialog::getOpenFileName(this, &type);
+       QString fileName = FileDialog::getOpenFileName(this, &type);
        RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
        slotFileOpen(fileName, type);
        RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
@@ -2043,7 +2021,6 @@ void ApplicationWindow::slotFileOpenRecent(void)
 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
 {
        RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
-
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
        if (!fileName.isEmpty())
@@ -2051,10 +2028,6 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
                // Create new document window:
                MDIWindow * w = slotFileNew();
-//             RS_APP->processEvents(1000);
-//Really, is this needed???
-//             RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
                // link the layer widget to the new document:
                layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
@@ -2066,15 +2039,10 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                // link the layer widget to the new document:
                simulationControls->setGraphicView(w->getGraphicView());
 #endif
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
 
-//             RS_APP->processEvents(1000);
-//We no longer try to do Qt better than the Qt folks...
-//             RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
-               // open the file in the new view:
-               if (w->slotFileOpen(fileName, type) == false)
+               // Open the file in the new view:
+               if (!w->slotFileOpen(fileName, type))
                {
                        // error
                        QApplication::restoreOverrideCursor();
@@ -2095,24 +2063,20 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                        recentFiles->add(fileName);
 
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
-//             updateRecentFilesMenu();
                recentFiles->UpdateGUI();
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
                // update caption:
-//             w->setCaption(fileName);
                w->setWindowTitle(fileName);
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
                // update coordinate widget format:
                RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
-
+               // Update the layer and block widgets (document just loaded may have some)
+               layerWidget->update();
+               blockWidget->update();
                // show output of filter (if any):
-//             commandWidget->processStderr();
                QString message = tr("Loaded document: ") + fileName;
                commandWidget->appendHistory(message);
                statusBar()->showMessage(message, 2000);
@@ -2213,14 +2177,12 @@ void ApplicationWindow::slotFileSaveAs()
 void ApplicationWindow::slotFileExport()
 {
        RS_DEBUG->print("ApplicationWindow::slotFileExport()");
-
        statusBar()->showMessage(tr("Exporting drawing..."));
-
        MDIWindow * w = getMDIWindow();
-       QString fn;
 
-       if (w != NULL)
+       if (w)
        {
+               QString fn;
                // read default settings:
                settings.beginGroup("Paths");
                QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
@@ -2348,7 +2310,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
 {
        MDIWindow * w = getMDIWindow();
 
-       if (w == NULL)
+       if (!w)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
                return false;
@@ -2356,7 +2318,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
 
        Drawing * graphic = w->getDocument()->getGraphic();
 
-       if (graphic == NULL)
+       if (!graphic)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
                return false;
@@ -2413,7 +2375,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
                ret = true;
        }
 #else
-#warning "Need to port to Qt4... !!! FIX !!!"
+#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!"
 #endif
 
        QApplication::restoreOverrideCursor();
@@ -2441,7 +2403,7 @@ void ApplicationWindow::slotFileClose()
 
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
+       if (m)
 //             m->close(true);
                m->close();
 
@@ -2514,6 +2476,7 @@ void ApplicationWindow::slotFilePrint()
        // printer setup:
 //     if (printer->setup(this))
        QPrintDialog dialog(printer, this);
+
        if (dialog.exec())
        {
                //printer->setOutputToFile(true);
@@ -2576,7 +2539,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on)
        RS_DEBUG->print("  creating MDI window");
        MDIWindow * parent = getMDIWindow();
 
-       if (parent == NULL)
+       if (!parent)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
                return;
@@ -2624,20 +2587,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();
                                }
@@ -2683,6 +2648,7 @@ void ApplicationWindow::slotFileQuit()
                qApp->exit(0);
 }
 
+#if 0
 /**
  * Forces termination of QCad (demo version).
  */
@@ -2693,6 +2659,7 @@ void ApplicationWindow::slotFileDemoQuit()
        queryExit(true);
        qApp->exit(0);
 }
+#endif
 
 /**
  * Shows / hides the grid.
@@ -2748,7 +2715,7 @@ void ApplicationWindow::slotViewDraft(bool toggle)
  */
 void ApplicationWindow::redrawAll()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2756,11 +2723,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();
                        }
                }
@@ -2772,7 +2739,7 @@ void ApplicationWindow::redrawAll()
  */
 void ApplicationWindow::updateGrids()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2780,11 +2747,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();
                        }
                }
@@ -2924,11 +2891,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);
@@ -2980,7 +2947,7 @@ void ApplicationWindow::slotHelpAbout()
 
        QString modulesString;
 
-       if (modules.empty() == false)
+       if (!modules.empty())
                modulesString = modules.join(", ");
        else
                modulesString = tr("None");
@@ -2998,6 +2965,8 @@ void ApplicationWindow::slotHelpAbout()
                tr("Version: %1").arg("1.0.0") + "<br>" +
                tr("Date: %1").arg(__DATE__) + "<br>" +
                QString("&copy; 2010 Underground Software,<br>James Hammons") +
+               "<br>" +
+               QString("Portions &copy; 2001-2003 RibbonSoft") +
                "<br>"
 #ifdef QC_ABOUT_ADD_COMPANY
                + QString("<br>") + QC_ABOUT_ADD_COMPANY
@@ -3367,8 +3336,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) {
@@ -3508,9 +3477,9 @@ void ApplicationWindow::slotTestInsertBlock()
                ins->update();
                graphic->addEntity(ins);
 
-               RS_GraphicView * v = getGraphicView();
+               GraphicView * v = getGraphicView();
 
-               if (v != NULL)
+               if (v)
                        v->redraw();
        }
 }
@@ -3650,7 +3619,7 @@ void ApplicationWindow::slotTestInsertEllipse()
                                }
                */
 
-               RS_GraphicView * v = getGraphicView();
+               GraphicView * v = getGraphicView();
 
                if (v != NULL)
                        v->redraw();
@@ -3752,7 +3721,7 @@ void ApplicationWindow::slotTestInsertText()
                                                RS2::SolidLine));
                graphic->addEntity(s);
 
-               RS_GraphicView* v = getGraphicView();
+               GraphicView* v = getGraphicView();
                if (v!=NULL) {
                        v->redraw();
                }
@@ -3902,7 +3871,7 @@ void ApplicationWindow::slotTestMath01()
         //                   Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
 
 
-        RS_GraphicView* v = getGraphicView();
+        GraphicView* v = getGraphicView();
         if (v!=NULL) {
             v->redraw();
         }
@@ -3994,6 +3963,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 = "";
@@ -4007,13 +3977,12 @@ void ApplicationWindow::keyPressEvent(QKeyEvent * e)
        case Qt::Key_Alt:
        case Qt::Key_CapsLock:
        {
-//             Q3MainWindow::keyPressEvent(e);
                QMainWindow::keyPressEvent(e);
 
                // forward to actions:
-               RS_GraphicView * graphicView = getGraphicView();
+               GraphicView * graphicView = getGraphicView();
 
-               if (graphicView != NULL)
+               if (graphicView)
                        graphicView->keyPressEvent(e);
 
                e->accept();
@@ -4101,9 +4070,9 @@ void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
                QMainWindow::keyReleaseEvent(e);
 
                // forward to actions:
-               RS_GraphicView * graphicView = getGraphicView();
+               GraphicView * graphicView = getGraphicView();
 
-               if (graphicView != NULL)
+               if (graphicView)
                        graphicView->keyReleaseEvent(e);
 
                e->accept();
@@ -4139,7 +4108,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();
@@ -4155,14 +4124,11 @@ MDIWindow * ApplicationWindow::getMDIWindow()
  * @return Pointer to the graphic view of the currently active document
  * window or NULL if no window is available.
  */
-/*virtual*/ RS_GraphicView * ApplicationWindow::getGraphicView()
+/*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getGraphicView();
-
-       return NULL;
+       return (m ? m->getGraphicView() : NULL);
 }
 
 /**
@@ -4175,10 +4141,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getDocument();
-
-       return NULL;
+       return (m ? m->getDocument() : NULL);
 }
 
 /**
@@ -4189,7 +4152,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        slotFileNew(doc);
 
-       if (fileName != QString::null && getDocument() != NULL)
+       if (fileName != QString::null && getDocument())
                getDocument()->setFilename(fileName);
 }
 
@@ -4206,7 +4169,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 /**
  * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
  */
-/*virtual*/ QG_ActionHandler * ApplicationWindow::getActionHandler()
+/*virtual*/ ActionHandler * ApplicationWindow::getActionHandler()
 {
        return actionHandler;
 }