]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/applicationwindow.cpp
In the middle of major refactoring...
[architektonas] / src / mainapp / applicationwindow.cpp
index e91576fcfeb078a2e4a75823032e8651a75bb338..c0da383fafe889ebad0f4bd5379180246910cbb7 100644 (file)
@@ -17,9 +17,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 +30,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"
@@ -48,6 +48,7 @@
 #include "qg_colorbox.h"
 #include "qg_filedialog.h"
 #include "qg_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,6 +90,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);
@@ -251,12 +254,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 +361,6 @@ void ApplicationWindow::initMDI()
 void ApplicationWindow::initActions()
 {
        RS_DEBUG->print("ApplicationWindow::initActions()");
-       CreateQtActions(this);
 
        //
        // File actions:
@@ -1262,7 +1264,7 @@ void ApplicationWindow::initMenuBar()
 //             menuBar()->insertItem(tr("De&bugging"), testMenu);
                menuBar()->addMenu(testMenu);
 
-       recentFiles = new QG_RecentFiles(this, fileMenu);
+       recentFiles = new RecentFiles(this, fileMenu);
 }
 
 /**
@@ -1544,49 +1546,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 +1567,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();
                }
        }
@@ -1657,7 +1628,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);
 
@@ -2624,7 +2595,7 @@ 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");
@@ -2748,7 +2719,7 @@ void ApplicationWindow::slotViewDraft(bool toggle)
  */
 void ApplicationWindow::redrawAll()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2756,11 +2727,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 +2743,7 @@ void ApplicationWindow::redrawAll()
  */
 void ApplicationWindow::updateGrids()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2780,11 +2751,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 +2895,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);
@@ -3367,8 +3338,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 +3479,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 +3621,7 @@ void ApplicationWindow::slotTestInsertEllipse()
                                }
                */
 
-               RS_GraphicView * v = getGraphicView();
+               GraphicView * v = getGraphicView();
 
                if (v != NULL)
                        v->redraw();
@@ -3752,7 +3723,7 @@ void ApplicationWindow::slotTestInsertText()
                                                RS2::SolidLine));
                graphic->addEntity(s);
 
-               RS_GraphicView* v = getGraphicView();
+               GraphicView* v = getGraphicView();
                if (v!=NULL) {
                        v->redraw();
                }
@@ -3902,7 +3873,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 +3965,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 +3979,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 +4072,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 +4110,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 +4126,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 +4143,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getDocument();
-
-       return NULL;
+       return (m ? m->getDocument() : NULL);
 }
 
 /**
@@ -4189,7 +4154,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        slotFileNew(doc);
 
-       if (fileName != QString::null && getDocument() != NULL)
+       if (fileName != QString::null && getDocument())
                getDocument()->setFilename(fileName);
 }