]> Shamusworld >> Repos - architektonas/commitdiff
Merged QC_GraphicView into QG_GraphicView...
authorShamus Hammons <jlhamm@acm.org>
Fri, 18 Jun 2010 13:51:08 +0000 (13:51 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 18 Jun 2010 13:51:08 +0000 (13:51 +0000)
13 files changed:
architektonas.pro
src/forms/cadtoolbar.cpp
src/forms/cadtoolbarlines.cpp
src/forms/cadtoolbarmain.cpp
src/forms/cadtoolbarmodify.cpp
src/mainapp/applicationwindow.cpp
src/mainapp/graphicview.h
src/mainapp/mdiwindow.cpp
src/mainapp/mdiwindow.h
src/mainapp/qc_graphicview.cpp [deleted file]
src/mainapp/qc_graphicview.h [deleted file]
src/widgets/qg_graphicview.cpp
src/widgets/qg_graphicview.h

index 9e63187f7c0c63a5f99d19c4e5b33d9328ad3f2e..a7952aafdf040db4e14c234f358b0c67963fb25b 100644 (file)
@@ -637,7 +637,6 @@ HEADERS += \
        src/mainapp/createqtactions.h \
        src/mainapp/qc_dialogfactory.h \
        src/mainapp/graphicview.h \
-       src/mainapp/qc_graphicview.h \
        src/mainapp/main.h \
        src/mainapp/mdiwindow.h \
        src/mainapp/settings.h
@@ -648,7 +647,6 @@ SOURCES += \
        src/mainapp/createqtactions.cpp \
        src/mainapp/qc_dialogfactory.cpp \
        src/mainapp/graphicview.cpp \
-       src/mainapp/qc_graphicview.cpp \
        src/mainapp/main.cpp \
        src/mainapp/mdiwindow.cpp \
        src/mainapp/settings.cpp
index 4bfe299ab4c4a50bd25d75b361d179b2806cb9c4..ec5929dec3a5a824c2a7f53c1755b164bc8d599f 100644 (file)
@@ -36,7 +36,7 @@ CadToolBar::CadToolBar(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
        tbSelect(NULL), tbPolylines(NULL)
 {
        ui.setupUi(this);
-//hm. here maybe?
+//hm. here maybe? Yesh!
 if (parent)
        ((QToolBar *)parent)->addWidget(this);
 }
@@ -66,7 +66,7 @@ void CadToolBar::back()
  */
 void CadToolBar::forceNext()
 {
-       if (currentTb != NULL && currentTb == tbSelect)
+       if (currentTb && currentTb == tbSelect)
                tbSelect->runNextAction();
 }
 
@@ -94,6 +94,7 @@ void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
        actionHandler = ah;
        tbMain = new CadToolBarMain(this);
        tbMain->setCadToolBar(this);
+       currentTb = tbMain;
 
        tbPoints = new CadToolBarPoints(this);
        tbPoints->setCadToolBar(this);
@@ -119,11 +120,9 @@ void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
        tbSplines->setCadToolBar(this);
        tbSplines->hide();
 
-//#ifdef RS_PROF
        tbPolylines = new CadToolBarPolylines(this);
        tbPolylines->setCadToolBar(this);
        tbPolylines->hide();
-//#endif
 
        tbDim = new CadToolBarDim(this);
        tbDim->setCadToolBar(this);
@@ -144,8 +143,6 @@ void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
        tbSelect = new CadToolBarSelect(this);
        tbSelect->setCadToolBar(this);
        tbSelect->hide();
-
-       //showToolBarMain();
 }
 
 void CadToolBar::showToolBar(int id)
@@ -173,11 +170,9 @@ void CadToolBar::showToolBar(int id)
        case RS2::ToolBarSplines:
                newTb = tbSplines;
                break;
-//#ifdef RS_PROF
        case RS2::ToolBarPolylines:
                newTb = tbPolylines;
                break;
-//#endif
        case RS2::ToolBarCircles:
                newTb = tbCircles;
                break;
@@ -201,12 +196,12 @@ void CadToolBar::showToolBar(int id)
        if (currentTb == newTb)
                return;
 
-       if (currentTb != NULL)
+       if (currentTb)
                currentTb->hide();
 
        currentTb = newTb;
 
-       if (currentTb != NULL)
+       if (currentTb)
                currentTb->show();
 }
 
index cd75a1e3a05d097cf57347aeab1f3a60aa2e2ef1..04554ad96b2b7fe8abbee47f24abd7719fd732ba 100644 (file)
@@ -27,13 +27,6 @@ CadToolBarLines::~CadToolBarLines()
 {
 }
 
-/*void CadToolBarLines::mousePressEvent(QMouseEvent* e) {
-    if (e->button()==RightButton && cadToolBar != NULL) {
-        cadToolBar->back();
-        e->accept();
-    }
-}*/
-
 void CadToolBarLines::contextMenuEvent(QContextMenuEvent * e)
 {
        e->accept();
index 38d598f4d12eea3fae2ce0adb8ecea4316e6cb07..f854a4a8cb9390e2bd0d13e9b61b8a7783f4cdfe 100644 (file)
@@ -46,7 +46,7 @@ void CadToolBarMain::setCadToolBar(CadToolBar * tb)
        if (tb)
                ah = tb->getActionHandler();
        else
-               RS_DEBUG->print(RS_Debug::D_ERROR, "QG_CadToolBarMain::setCadToolBar(): No valid toolbar set.");
+               RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarMain::setCadToolBar(): No valid toolbar set.");
 
        if (ah)
        {
@@ -70,7 +70,5 @@ void CadToolBarMain::setCadToolBar(CadToolBar * tb)
                connect(ui.bMenuSelect, SIGNAL(clicked()), tb, SLOT(showToolBarSelect()));
        }
        else
-       {
-               RS_DEBUG->print(RS_Debug::D_ERROR, "QG_CadToolBarMain::setCadToolBar(): No valid action handler set.");
-       }
+               RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarMain::setCadToolBar(): No valid action handler set.");
 }
index f8129bbaa0cfcf76f8759385bf260cf59f9fb66c..faf53ae882753d0bb4e0602fe03a67fe231fc010 100644 (file)
@@ -17,7 +17,7 @@
 #include "qg_actionhandler.h"
 #include "rs_debug.h"
 
-CadToolBarModify::CadToolBarModify(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+CadToolBarModify::CadToolBarModify(QWidget * parent /*= 0*/, Qt::WindowFlags flags /*= 0*/):
        QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
 {
        ui.setupUi(this);
@@ -36,7 +36,8 @@ void CadToolBarModify::mousePressEvent(QMouseEvent * e)
        }
 }
 
-void CadToolBarModify::contextMenuEvent(QContextMenuEvent *e) {
+void CadToolBarModify::contextMenuEvent(QContextMenuEvent *e)
+{
        e->accept();
 }
 
@@ -44,124 +45,124 @@ void CadToolBarModify::setCadToolBar(CadToolBar * tb)
 {
        cadToolBar = tb;
 
-       if (tb!=NULL) {
+       if (tb != NULL)
                actionHandler = tb->getActionHandler();
-       } else {
+       else
                RS_DEBUG->print(RS_Debug::D_ERROR,
                        "CadToolBarModify::setCadToolBar(): No valid toolbar set.");
-       }
 }
 
-void CadToolBarModify::modifyMove() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyMove()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyMove();
-       }
 }
 
-void CadToolBarModify::modifyRotate() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyRotate()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyRotate();
-       }
 }
 
-void CadToolBarModify::modifyScale() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyScale()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyScale();
-       }
 }
 
-void CadToolBarModify::modifyMirror() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyMirror()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyMirror();
-       }
 }
 
-void CadToolBarModify::modifyMoveRotate() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyMoveRotate()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyMoveRotate();
-       }
 }
 
-void CadToolBarModify::modifyRotate2() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyRotate2()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyRotate2();
-       }
 }
 
-void CadToolBarModify::modifyTrim() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyTrim()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyTrim();
-       }
 }
 
-void CadToolBarModify::modifyTrim2() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyTrim2()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyTrim2();
-       }
 }
 
-void CadToolBarModify::modifyTrimAmount() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyTrimAmount()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyTrimAmount();
-       }
 }
 
-void CadToolBarModify::modifyCut() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyCut()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyCut();
-       }
 }
 
-void CadToolBarModify::modifyBevel() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyBevel()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyBevel();
-       }
 }
 
-void CadToolBarModify::modifyRound() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyRound()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyRound();
-       }
 }
 
-void CadToolBarModify::modifyEntity() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyEntity()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyEntity();
-       }
 }
 
-void CadToolBarModify::modifyDelete() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyDelete()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyDelete();
-       }
 }
 
-void CadToolBarModify::modifyAttributes() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyAttributes()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyAttributes();
-       }
 }
 
-void CadToolBarModify::modifyStretch() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyStretch()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyStretch();
-       }
 }
 
-void CadToolBarModify::modifyExplode() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyExplode()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotBlocksExplode();
-       }
 }
 
-void CadToolBarModify::modifyExplodeText() {
-       if (cadToolBar!=NULL && actionHandler!=NULL) {
+void CadToolBarModify::modifyExplodeText()
+{
+       if (cadToolBar != NULL && actionHandler != NULL)
                actionHandler->slotModifyExplodeText();
-       }
 }
 
-void CadToolBarModify::back() {
-       if (cadToolBar!=NULL) {
+void CadToolBarModify::back()
+{
+       if (cadToolBar != NULL)
                cadToolBar->back();
-       }
 }
+
index 326854eee048c1c6526466da40e94d79f0150ecf..a0cb9716f692ba6e7b93d507f5852e674542e883 100644 (file)
@@ -255,7 +255,7 @@ 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);
                action->setFile(name);
@@ -1552,11 +1552,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 +1566,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 +1627,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);
 
@@ -2718,7 +2718,7 @@ void ApplicationWindow::slotViewDraft(bool toggle)
  */
 void ApplicationWindow::redrawAll()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2726,11 +2726,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 +2742,7 @@ void ApplicationWindow::redrawAll()
  */
 void ApplicationWindow::updateGrids()
 {
-       if (workspace != NULL)
+       if (workspace)
        {
                QList<QMdiSubWindow *> windows = workspace->subWindowList();
 
@@ -2750,11 +2750,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 +2894,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);
@@ -3480,7 +3480,7 @@ void ApplicationWindow::slotTestInsertBlock()
 
                GraphicView * v = getGraphicView();
 
-               if (v != NULL)
+               if (v)
                        v->redraw();
        }
 }
@@ -3964,6 +3964,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 +3978,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 +4073,7 @@ void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
                // forward to actions:
                GraphicView * graphicView = getGraphicView();
 
-               if (graphicView != NULL)
+               if (graphicView)
                        graphicView->keyReleaseEvent(e);
 
                e->accept();
@@ -4109,7 +4109,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 +4129,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getGraphicView();
-
-       return NULL;
+       return (m ? m->getGraphicView() : NULL);
 }
 
 /**
@@ -4145,10 +4142,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
-               return m->getDocument();
-
-       return NULL;
+       return (m ? m->getDocument() : NULL);
 }
 
 /**
@@ -4159,7 +4153,7 @@ MDIWindow * ApplicationWindow::getMDIWindow()
 {
        slotFileNew(doc);
 
-       if (fileName != QString::null && getDocument() != NULL)
+       if (fileName != QString::null && getDocument())
                getDocument()->setFilename(fileName);
 }
 
index 96e16260a9f4156bc34f15bda47de4db4ec075ce..8af908b314e60d84dd8ceedb91d82d48ed4655da 100644 (file)
@@ -18,6 +18,7 @@ class RS_Preview;
 class RS_Grid;
 class RS_Pen;
 class RS_EventHandler;
+class QG_ScrollBar;
 
 class GraphicView
 {
@@ -293,7 +294,27 @@ class GraphicView
                bool showCrosshairs1;
 
 //QG
-
+       protected:
+               int lastWidth;
+               int lastHeight;
+               //! Horizontal scrollbar.
+               QG_ScrollBar * hScrollBar;
+               //! Vertical scrollbar.
+               QG_ScrollBar * vScrollBar;
+               //! Layout used to fit in the view and the scrollbars.
+               QGridLayout * layout;
+               //! Label for grid spacing.
+               QLabel * gridStatus;
+               //! CAD mouse cursor
+               QCursor * curCad;
+               //! Delete mouse cursor
+               QCursor * curDel;
+               //! Select mouse cursor
+               QCursor * curSelect;
+               //! Magnifying glass mouse cursor
+               QCursor * curMagnifier;
+               //! Hand mouse cursor
+               QCursor * curHand;
 
 //QC
 };
@@ -392,8 +413,5 @@ class QC_GraphicView: public QG_GraphicView
                virtual ~QC_GraphicView();
 
                virtual void drawIt();
-
-       private:
-               //RS_Document* document;
 };
 #endif
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";
index 8335ba28dbfb0c8d5786f3037764940d5c18e274..fdd821514dc42896423d91afc98c0ee8b39712de 100644 (file)
@@ -2,11 +2,14 @@
 #define QC_MDIWINDOW_H
 
 #include <QtGui>
-#include "qc_graphicview.h"
+//#include "qc_graphicview.h"
 #include "qg_layerwidget.h"
 #include "qg_pentoolbar.h"
 #include "rs_document.h"
 
+class RS_EventHandler;
+class QG_GraphicView;
+
 /**
  * MDI document window. Contains a document and a view (window).
  *
@@ -35,7 +38,8 @@ class MDIWindow: public QMdiSubWindow
                void slotFilePrint();
 
        public:
-               QC_GraphicView * getGraphicView();
+//             QC_GraphicView * getGraphicView();
+               QG_GraphicView * getGraphicView();
                RS_Document * getDocument();
                Drawing * getGraphic();
                RS_EventHandler * getEventHandler();
@@ -64,7 +68,9 @@ class MDIWindow: public QMdiSubWindow
                /** ID counter (class variable) */
                static int idCounter;
                /** Graphic view */
-               QC_GraphicView * graphicView;
+//let's see if we can get rid of this...
+//             QC_GraphicView * graphicView;
+               QG_GraphicView * graphicView;
                /** Document */
                RS_Document * document;
                /** Does the window own the document? */
diff --git a/src/mainapp/qc_graphicview.cpp b/src/mainapp/qc_graphicview.cpp
deleted file mode 100644 (file)
index 33cf23a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// qc_graphicview.cpp
-//
-// 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
-//
-// JLH = James L. Hammons <jlhamm@acm.org>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JLH  05/17/2010  Added this text. :-)
-//
-
-#include "qc_graphicview.h"
-
-#include "rs_actiondefault.h"
-
-QC_GraphicView::QC_GraphicView(RS_Document * doc, QWidget * parent):
-       QG_GraphicView(parent, "graphicview")
-{
-       RS_DEBUG->print("QC_GraphicView::QC_GraphicView()...");
-       //document = doc;
-       RS_DEBUG->print("  Setting Container...");
-
-       if (doc != NULL)
-               setContainer(doc);
-
-       RS_DEBUG->print("  container set.");
-       setFactorX(4.0);
-       setFactorY(4.0);
-       setOffset(50, 50);
-       setBorders(10, 10, 10, 10);
-
-       if (doc != NULL)
-               setDefaultAction(new RS_ActionDefault(*doc, *this));
-}
-
-QC_GraphicView::~QC_GraphicView()
-{
-}
-
-void QC_GraphicView::drawIt()
-{
-       if (!isUpdateEnabled())
-               return;
-
-       GraphicView::drawIt();
-}
diff --git a/src/mainapp/qc_graphicview.h b/src/mainapp/qc_graphicview.h
deleted file mode 100644 (file)
index 066f06f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef QC_GRAPHICVIEW_H
-#define QC_GRAPHICVIEW_H
-
-#include <QtCore>
-
-// Q*G*_graphicview... How retarded is this...
-//very
-#include "qg_graphicview.h"
-
-class RS_Document;
-
-/**
- * A view widget for the visualisation of drawings.
- * Very thin wrapper for QCad specific settings.
- *
- * @author Andrew Mustun
- */
-class QC_GraphicView: public QG_GraphicView
-{
-       public:
-               QC_GraphicView(RS_Document * doc, QWidget * parent = 0);
-               virtual ~QC_GraphicView();
-
-               virtual void drawIt();
-
-       private:
-               //RS_Document* document;
-};
-
-#endif
index 7c0b632076f5eb2281be0f3a53edb0e20343c952..d885f8a0a820a59c2f24def12d029d3d97cf9f61 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "qg_graphicview.h"
 
+#include "rs_actiondefault.h"
 #include "rs_actionzoomin.h"
 #include "rs_actionzoompan.h"
 #include "rs_actionzoomscroll.h"
  */
 QG_GraphicView::QG_GraphicView(QWidget * parent, const char */*name*/, Qt::WindowFlags f):
        QWidget(parent, f), GraphicView()//, refCount(0)
+{
+       RS_DEBUG->print("QG_GraphicView::QG_GraphicView(parent, name, flags)...");
+       CommonInitialization();
+}
+
+/**
+ * Constructor II.
+ */
+QG_GraphicView::QG_GraphicView(RS_Document * doc, QWidget * parent)
+{
+//     QG_GraphicView(parent, "graphicview");
+       CommonInitialization();
+
+       RS_DEBUG->print("QG_GraphicView::QG_GraphicView(doc, parent)...");
+       //document = doc;
+       RS_DEBUG->print("  Setting Container...");
+
+       if (doc)
+               setContainer(doc);
+
+       RS_DEBUG->print("  container set.");
+       setFactorX(4.0);
+       setFactorY(4.0);
+       setOffset(50, 50);
+       setBorders(10, 10, 10, 10);
+
+       if (doc)
+               setDefaultAction(new RS_ActionDefault(*doc, *this));
+}
+
+void QG_GraphicView::CommonInitialization(void)
 {
        setBackground(background);
        buffer = NULL;
@@ -45,6 +77,7 @@ QG_GraphicView::QG_GraphicView(QWidget * parent, const char */*name*/, Qt::Windo
 //hrm.
 painter = NULL;
 
+       RS_DEBUG->print("--> Setting up layout...");
        layout = new QGridLayout(this);
        layout->setColumnStretch(0, 1);
        layout->setColumnStretch(1, 0);
@@ -60,6 +93,7 @@ Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags
 
 A non-zero alignment indicates that the widget should not grow to fill the available space but should be sized according to sizeHint().
 */
+       RS_DEBUG->print("--> Creating hScrollBar...");
        hScrollBar = new QG_ScrollBar(Qt::Horizontal, this);
 //    hScrollBar->setLineStep(50);
        hScrollBar->setSingleStep(50);
@@ -67,8 +101,8 @@ A non-zero alignment indicates that the widget should not grow to fill the avail
        layout->addWidget(hScrollBar, 1, 0);
 //    layout->addRowSpacing(1, hScrollBar->sizeHint().height());
        layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0);
-       connect(hScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotHScrolled(int)));
 
+       RS_DEBUG->print("--> Creating vScrollBar...");
        vScrollBar = new QG_ScrollBar(Qt::Vertical, this);
 //    vScrollBar->setLineStep(50);
        vScrollBar->setSingleStep(50);
@@ -76,6 +110,8 @@ A non-zero alignment indicates that the widget should not grow to fill the avail
        layout->addWidget(vScrollBar, 0, 2);
 //    layout->addColSpacing(2, vScrollBar->sizeHint().width());
        layout->addItem(new QSpacerItem(vScrollBar->sizeHint().width(), 0), 0, 2);
+
+       connect(hScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotHScrolled(int)));
        connect(vScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotVScrolled(int)));
 
 #ifndef __APPLE__
@@ -141,14 +177,10 @@ A non-zero alignment indicates that the widget should not grow to fill the avail
  */
 QG_GraphicView::~QG_GraphicView()
 {
-       if (painter != NULL)
-       {
-//Not sure about this...
-//             ((RS_PainterQt *)painter)->end();
+       if (painter)
                delete painter;
-       }
 
-       if (buffer != NULL)
+       if (buffer)
        {
                delete buffer;
                buffer = NULL;
@@ -373,7 +405,7 @@ void QG_GraphicView::mouseReleaseEvent(QMouseEvent * e)
 
        if (!e->isAccepted())
        {
-               if (QG_DIALOGFACTORY != NULL && QG_DIALOGFACTORY->getCadToolBar() != NULL)
+               if (QG_DIALOGFACTORY && QG_DIALOGFACTORY->getCadToolBar())
                {
                        RS_DEBUG->print("QG_GraphicView::mouseReleaseEvent: fwd to cadtoolbar");
                        QG_DIALOGFACTORY->getCadToolBar()->mouseReleaseEvent(e);
@@ -512,11 +544,10 @@ void QG_GraphicView::wheelEvent(QWheelEvent * e)
 
        //printf("state: %d\n", e->state());
        //printf("ctrl: %d\n", Qt::ControlButton);
-Qt::KeyboardModifiers keyState = QApplication::keyboardModifiers();
-
-       if (container == NULL)
+       if (!container)
                return;
 
+       Qt::KeyboardModifiers keyState = QApplication::keyboardModifiers();
        Vector mouse = toGraph(Vector(e->x(), e->y()));
 
        bool scroll = false;
@@ -562,7 +593,7 @@ Qt::KeyboardModifiers keyState = QApplication::keyboardModifiers();
 
 void QG_GraphicView::keyPressEvent(QKeyEvent * e)
 {
-       if (container == NULL)
+       if (!container)
                return;
 
        bool scroll = false;
@@ -628,11 +659,11 @@ void QG_GraphicView::adjustOffsetControls()
        Vector max = container->getMax();
 
        // no drawing yet - still allow to scroll
-       if (max.x < min.x+1.0e-6 || max.y < min.y+1.0e-6 ||
-               max.x > RS_MAXDOUBLE || max.x < RS_MINDOUBLE ||
-               min.x > RS_MAXDOUBLE || min.x < RS_MINDOUBLE ||
-               max.y > RS_MAXDOUBLE || max.y < RS_MINDOUBLE ||
-               min.y > RS_MAXDOUBLE || min.y < RS_MINDOUBLE)
+       if (max.x < min.x + 1.0e-6 || max.y < min.y + 1.0e-6
+               || max.x > RS_MAXDOUBLE || max.x < RS_MINDOUBLE
+               || min.x > RS_MAXDOUBLE || min.x < RS_MINDOUBLE
+               || max.y > RS_MAXDOUBLE || max.y < RS_MINDOUBLE
+               || min.y > RS_MAXDOUBLE || min.y < RS_MINDOUBLE)
        {
                min = Vector(-10, -10);
                max = Vector(100, 100);
@@ -774,6 +805,15 @@ have something back in portage. We can make it better, faster, stronger. ;-)
 
 If we can make the UI more like Inkscape we'll be in good shape. Plus elements
 of VectorWorks & etc. as well...
+
+-------------------------------------------------------------------------------
+
+What's needed:
+
+- Draw the entities
+- Draw the preview (if any)
+- Draw the snapper (if any)
+
 */
 
 // Qt4 handles double buffering of screen writes now, so this needs
index af3528c14be074f90dbbcd916cc46a4985d81c08..2a5c3a8d1848c465ec22fa7d17be423e697295dc 100644 (file)
@@ -7,8 +7,9 @@
 #include "rs_blocklistlistener.h"
 #include "qg_scrollbar.h"
 
-class RS_Preview;
+class RS_Document;
 class PaintInterface;
+class RS_Preview;
 
 /**
  * This is the Qt implementation of a widget which can view a
@@ -25,6 +26,7 @@ class QG_GraphicView: public QWidget, public GraphicView, //public Q3FilePreview
 
        public:
                QG_GraphicView(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0);
+               QG_GraphicView(RS_Document * doc, QWidget * parent = 0);
                virtual ~QG_GraphicView();
 
                virtual int getWidth();
@@ -61,6 +63,9 @@ class QG_GraphicView: public QWidget, public GraphicView, //public Q3FilePreview
 #warning "!!! File preview needs porting to Qt4 !!!"
 //             void previewUrl(const Q3Url &u);
 
+       private:
+               void CommonInitialization(void);
+
        private slots:
                void slotHScrolled(int value);
                void slotVScrolled(int value);