]> Shamusworld >> Repos - architektonas/blobdiff - src/widgets/qg_dialogfactory.cpp
Partially fixed thumbnail rendering on Library Browser.
[architektonas] / src / widgets / qg_dialogfactory.cpp
index b30b5dec48d54b1e713984588fa31cb36d0297e7..b5093ceed36a5d899ca325a28969ffbe280762bb 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>
 //
 
 #include "qg_dialogfactory.h"
 
-#include "qg_layerwidget.h"
+#include "graphicview.h"
+#include "layerwidget.h"
 #include "qg_mainwindowinterface.h"
-#include "rs_actiondimlinear.h"
-#include "rs_actioninterface.h"
+#include "actiondimlinear.h"
+#include "actioninterface.h"
+#include "rs_blocklist.h"
 #include "rs_document.h"
 #include "rs_hatch.h"
+#include "rs_layerlist.h"
 #include "rs_patternlist.h"
 #include "settings.h"
 #include "rs_system.h"
@@ -207,7 +212,7 @@ void QG_DialogFactory::requestWarningDialog(const QString & warning)
 /**
  * Requests a new document from the main window.
  */
-RS_GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, RS_Document * doc)
+GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, RS_Document * doc)
 {
        if (mainWindow != NULL)
        {
@@ -334,17 +339,8 @@ RS_Layer * QG_DialogFactory::requestEditLayerDialog(RS_LayerList * layerList)
 {
        RS_DEBUG->print("QG_DialogFactory::requestEditLayerDialog");
        RS_Layer * layer = NULL;
-       /*
-       if (layerList==NULL) {
-               if (container!=NULL && container->rtti()==RS2::EntityGraphic) {
-                       layerList = (RS_LayerList*)container;
-               } else {
-                       return NULL;
-               }
-       }
-       */
 
-       if (layerList == NULL)
+       if (!layerList)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "QG_DialogFactory::requestEditLayerDialog(): "
                        "layerList is NULL");
@@ -352,7 +348,7 @@ RS_Layer * QG_DialogFactory::requestEditLayerDialog(RS_LayerList * layerList)
        }
 
        // Layer for parameter livery
-       if (layerList->getActive() != NULL)
+       if (layerList->getActive())
        {
                layer = new RS_Layer(*layerList->getActive());
 
@@ -705,7 +701,7 @@ QString QG_DialogFactory::requestImageOpenDialog()
        return fn;
 }
 
-void QG_DialogFactory::requestOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestOptions(ActionInterface * action, bool on, bool update)
 {
        RS_DEBUG->print("QG_DialogFactory::requestOptions");
 
@@ -794,7 +790,7 @@ void QG_DialogFactory::requestOptions(RS_ActionInterface * action, bool on, bool
     case RS2::ActionDimLinear:
         requestDimensionOptions(action, on, update);
 
-               if (((RS_ActionDimLinear *)action)->hasFixedAngle() == false)
+               if (((ActionDimLinear *)action)->hasFixedAngle() == false)
             requestDimLinearOptions(action, on, update);
 
                break;
@@ -841,7 +837,7 @@ void QG_DialogFactory::requestOptions(RS_ActionInterface * action, bool on, bool
 /**
  * Shows a widget for options for the action: "print preview"
  */
-void QG_DialogFactory::requestPrintPreviewOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestPrintPreviewOptions(ActionInterface * action, bool on, bool update)
 {
        static PrintPreviewOptions * toolWidget = NULL;
 
@@ -864,7 +860,7 @@ void QG_DialogFactory::requestPrintPreviewOptions(RS_ActionInterface * action, b
 /**
  * Shows a widget for options for the action: "draw line"
  */
-void QG_DialogFactory::requestLineOptions(RS_ActionInterface * action, bool on)
+void QG_DialogFactory::requestLineOptions(ActionInterface * action, bool on)
 {
 /*
 The way I see it, this is failure. We're constantly creating & deleting
@@ -897,7 +893,7 @@ them over and over. May need to do some more refactoring based on this idea...
 /**
  * Shows a widget for options for the action: "draw polyline"
  */
-void QG_DialogFactory::requestPolylineOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestPolylineOptions(ActionInterface * action, bool on, bool update)
 {
 #ifdef RS_PROF
        static PolylineOptions * toolWidget = NULL;
@@ -922,7 +918,7 @@ void QG_DialogFactory::requestPolylineOptions(RS_ActionInterface * action, bool
 /**
  * Shows a widget for options for the action: "draw line parallel"
  */
-void QG_DialogFactory::requestLineParallelOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLineParallelOptions(ActionInterface * action, bool on, bool update)
 {
     static LineParallelOptions * toolWidget = NULL;
 
@@ -944,7 +940,7 @@ void QG_DialogFactory::requestLineParallelOptions(RS_ActionInterface * action, b
 /**
  * Shows a widget for options for the action: "draw line parallel through"
  */
-void QG_DialogFactory::requestLineParallelThroughOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLineParallelThroughOptions(ActionInterface * action, bool on, bool update)
 {
     static LineParallelThroughOptions * toolWidget = NULL;
 
@@ -963,7 +959,7 @@ void QG_DialogFactory::requestLineParallelThroughOptions(RS_ActionInterface * ac
 /**
  * Shows a widget for options for the action: "line angle"
  */
-void QG_DialogFactory::requestLineAngleOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLineAngleOptions(ActionInterface * action, bool on, bool update)
 {
        static LineAngleOptions * toolWidget = NULL;
 
@@ -986,7 +982,7 @@ void QG_DialogFactory::requestLineAngleOptions(RS_ActionInterface * action, bool
 /**
  * Shows a widget for options for the action: "line relative angle"
  */
-void QG_DialogFactory::requestLineRelAngleOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLineRelAngleOptions(ActionInterface * action, bool on, bool update)
 {
        static LineRelAngleOptions * toolWidget = NULL;
 
@@ -1009,7 +1005,7 @@ void QG_DialogFactory::requestLineRelAngleOptions(RS_ActionInterface * action, b
 /**
  * Shows a widget for options for the action: "line angle"
  */
-void QG_DialogFactory::requestLineBisectorOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLineBisectorOptions(ActionInterface * action, bool on, bool update)
 {
     static LineBisectorOptions * toolWidget = NULL;
 
@@ -1028,7 +1024,7 @@ void QG_DialogFactory::requestLineBisectorOptions(RS_ActionInterface * action, b
 /**
  * Shows a widget for options for the action: "draw polygon"
  */
-void QG_DialogFactory::requestLinePolygonOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLinePolygonOptions(ActionInterface * action, bool on, bool update)
 {
     static LinePolygonOptions * toolWidget = NULL;
 
@@ -1047,7 +1043,7 @@ void QG_DialogFactory::requestLinePolygonOptions(RS_ActionInterface * action, bo
 /**
  * Shows a widget for options for the action: "draw polygon2"
  */
-void QG_DialogFactory::requestLinePolygon2Options(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLinePolygon2Options(ActionInterface * action, bool on, bool update)
 {
     static LinePolygon2Options * toolWidget = NULL;
 
@@ -1066,7 +1062,7 @@ void QG_DialogFactory::requestLinePolygon2Options(RS_ActionInterface * action, b
 /**
  * Shows a widget for arc options.
  */
-void QG_DialogFactory::requestArcOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestArcOptions(ActionInterface * action, bool on, bool update)
 {
        static ArcOptions * toolWidget = NULL;
 
@@ -1090,7 +1086,7 @@ void QG_DialogFactory::requestArcOptions(RS_ActionInterface * action, bool on, b
 /**
  * Shows a widget for tangential arc options.
  */
-void QG_DialogFactory::requestArcTangentialOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestArcTangentialOptions(ActionInterface * action, bool on, bool update)
 {
        static ArcTangentialOptions * toolWidget = NULL;
 
@@ -1114,7 +1110,7 @@ void QG_DialogFactory::requestArcTangentialOptions(RS_ActionInterface * action,
 /**
  * Shows a widget for circle options.
  */
-void QG_DialogFactory::requestCircleOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestCircleOptions(ActionInterface * action, bool on, bool update)
 {
     static CircleOptions * toolWidget = NULL;
 
@@ -1137,26 +1133,30 @@ void QG_DialogFactory::requestCircleOptions(RS_ActionInterface * action, bool on
 /**
  * Shows a widget for spline options.
  */
-void QG_DialogFactory::requestSplineOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestSplineOptions(ActionInterface * action, bool on, bool update)
 {
        static SplineOptions * toolWidget = NULL;
 
-       if (optionWidget!=NULL) {
-               if (toolWidget!=NULL) {
-                       delete toolWidget;
-                       toolWidget = NULL;
-               }
-               if (on==true && toolWidget==NULL) {
-                       toolWidget = new SplineOptions(optionWidget);
-                       toolWidget->setAction(action, update);
-               }
+       if (!optionWidget)
+               return;
+
+       if (toolWidget)
+       {
+               delete toolWidget;
+               toolWidget = NULL;
+       }
+
+       if (on)
+       {
+               toolWidget = new SplineOptions(optionWidget);
+               toolWidget->setAction(action, update);
        }
 }
 
 /**
  * Shows a widget for text options.
  */
-void QG_DialogFactory::requestTextOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestTextOptions(ActionInterface * action, bool on, bool update)
 {
        static TextOptions * toolWidget = NULL;
 
@@ -1179,7 +1179,7 @@ void QG_DialogFactory::requestTextOptions(RS_ActionInterface * action, bool on,
 /**
  * Shows a widget for insert options.
  */
-void QG_DialogFactory::requestInsertOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestInsertOptions(ActionInterface * action, bool on, bool update)
 {
     static InsertOptions * toolWidget = NULL;
 
@@ -1198,7 +1198,7 @@ void QG_DialogFactory::requestInsertOptions(RS_ActionInterface * action, bool on
 /**
  * Shows a widget for image options.
  */
-void QG_DialogFactory::requestImageOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestImageOptions(ActionInterface * action, bool on, bool update)
 {
     static ImageOptions * toolWidget = NULL;
 
@@ -1217,7 +1217,7 @@ void QG_DialogFactory::requestImageOptions(RS_ActionInterface * action, bool on,
 /**
  * Shows a widget for dimension options.
  */
-void QG_DialogFactory::requestDimensionOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestDimensionOptions(ActionInterface * action, bool on, bool update)
 {
     static DimOptions * toolWidget = NULL;
 
@@ -1236,7 +1236,7 @@ void QG_DialogFactory::requestDimensionOptions(RS_ActionInterface * action, bool
 /**
  * Shows a widget for linear dimension options.
  */
-void QG_DialogFactory::requestDimLinearOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestDimLinearOptions(ActionInterface * action, bool on, bool update)
 {
        static DimLinearOptions * toolWidget = NULL;
 
@@ -1282,7 +1282,7 @@ void QG_DialogFactory::requestSnapDistOptions(double & dist, bool on)
 /**
  * Shows a widget for 'snap to a point with a given distance' options.
  */
-void QG_DialogFactory::requestMoveRotateOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestMoveRotateOptions(ActionInterface * action, bool on, bool update)
 {
        static MoveRotateOptions * toolWidget = NULL;
 
@@ -1305,7 +1305,7 @@ void QG_DialogFactory::requestMoveRotateOptions(RS_ActionInterface * action, boo
 /**
  * Shows a widget for 'trim amount' options.
  */
-void QG_DialogFactory::requestTrimAmountOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestTrimAmountOptions(ActionInterface * action, bool on, bool update)
 {
        static TrimAmountOptions * toolWidget = NULL;
 
@@ -1328,7 +1328,7 @@ void QG_DialogFactory::requestTrimAmountOptions(RS_ActionInterface * action, boo
 /**
  * Shows a widget for beveling options.
  */
-void QG_DialogFactory::requestBevelOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestBevelOptions(ActionInterface * action, bool on, bool update)
 {
     static BevelOptions * toolWidget = NULL;
 
@@ -1351,7 +1351,7 @@ void QG_DialogFactory::requestBevelOptions(RS_ActionInterface * action, bool on,
 /**
  * Shows a widget for rounding options.
  */
-void QG_DialogFactory::requestRoundOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestRoundOptions(ActionInterface * action, bool on, bool update)
 {
        static RoundOptions * toolWidget = NULL;
 
@@ -1374,7 +1374,7 @@ void QG_DialogFactory::requestRoundOptions(RS_ActionInterface * action, bool on,
 /**
  * Shows a widget for library insert options.
  */
-void QG_DialogFactory::requestLibraryInsertOptions(RS_ActionInterface * action, bool on, bool update)
+void QG_DialogFactory::requestLibraryInsertOptions(ActionInterface * action, bool on, bool update)
 {
        static LibraryInsertOptions * toolWidget = NULL;
 
@@ -1399,14 +1399,14 @@ void QG_DialogFactory::requestLibraryInsertOptions(RS_ActionInterface * action,
  */
 void QG_DialogFactory::requestToolBar(RS2::ToolBarId id)
 {
-       if (cadToolBar != NULL)
+       if (cadToolBar)
                cadToolBar->showToolBar(id);
 }
 
 /**
  * Shows the select toolbar with the given action to launch.
  */
-void QG_DialogFactory::requestToolBarSelect(RS_ActionInterface * selectAction,
+void QG_DialogFactory::requestToolBarSelect(ActionInterface * selectAction,
         RS2::ActionType nextAction)
 {
        if (cadToolBar != NULL)
@@ -1834,10 +1834,10 @@ void QG_DialogFactory::updateCoordinateWidget(const Vector & abs,
  */
 void QG_DialogFactory::updateMouseWidget(const QString & left, const QString & right)
 {
-       if (mouseWidget != NULL)
+       if (mouseWidget)
                mouseWidget->setHelp(left, right);
 
-       if (commandWidget != NULL)
+       if (commandWidget)
                commandWidget->setCommand(left);
 }