]> Shamusworld >> Repos - architektonas/blobdiff - src/widgets/qg_dialogfactory.cpp
Final round of dialogs/forms needing to be converted from Qt3 to 4
[architektonas] / src / widgets / qg_dialogfactory.cpp
index 97b28e976ab8dc48a6dbd4c0c22d5a56b2cabd84..b30b5dec48d54b1e713984588fa31cb36d0297e7 100644 (file)
 #include "rs_actiondimlinear.h"
 #include "rs_actioninterface.h"
 #include "rs_document.h"
+#include "rs_hatch.h"
 #include "rs_patternlist.h"
 #include "settings.h"
 #include "rs_system.h"
 #include "rs_text.h"
 
-#if 0
-       #include "ui/qg_arcoptions.h"
-       #include "ui/qg_arctangentialoptions.h"
-       #include "ui/qg_beveloptions.h"
-       #include "ui/qg_blockdialog.h"
-       #include "ui/qg_cadtoolbar.h"
-       #include "ui/qg_circleoptions.h"
-       #include "ui/qg_commandwidget.h"
-       #include "ui/qg_coordinatewidget.h"
-       #include "ui/qg_dimlinearoptions.h"
-       #include "ui/qg_dimoptions.h"
-#include "ui/qg_dlgarc.h"
-       #include "ui/qg_dlgattributes.h"
-#include "ui/qg_dlgcircle.h"
-#include "ui/qg_dlgdimension.h"
-#include "ui/qg_dlgdimlinear.h"
-#include "ui/qg_dlgellipse.h"
-#include "ui/qg_dlghatch.h"
-#include "ui/qg_dlginsert.h"
-#include "ui/qg_dlgline.h"
-#include "ui/qg_dlgmirror.h"
-#include "ui/qg_dlgmove.h"
-#include "ui/qg_dlgmoverotate.h"
-       #include "ui/qg_dlgoptionsdrawing.h"
-       #include "ui/qg_dlgoptionsgeneral.h"
-#include "ui/qg_dlgpoint.h"
-#include "ui/qg_dlgrotate.h"
-#include "ui/qg_dlgrotate2.h"
-#include "ui/qg_dlgscale.h"
-#include "ui/qg_dlgspline.h"
-       #include "ui/qg_dlgtext.h"
-       #include "ui/qg_imageoptions.h"
-#include "ui/qg_insertoptions.h"
-       #include "ui/qg_layerdialog.h"
-#include "ui/qg_libraryinsertoptions.h"
-       #include "ui/qg_lineangleoptions.h"
-       #include "ui/qg_linebisectoroptions.h"
-       #include "ui/qg_lineoptions.h"
-       #include "ui/qg_lineparalleloptions.h"
-       #include "ui/qg_lineparallelthroughoptions.h"
-       #include "ui/qg_linepolygon2options.h"
-       #include "ui/qg_linepolygonoptions.h"
-       #include "ui/qg_linerelangleoptions.h"
-       #include "ui/qg_mousewidget.h"
-       #include "ui/qg_moverotateoptions.h"
-       #include "ui/qg_printpreviewoptions.h"
-       #include "ui/qg_roundoptions.h"
-       #include "ui/qg_selectionwidget.h"
-       #include "ui/qg_snapdistoptions.h"
-       #include "ui/qg_splineoptions.h"
-       #include "ui/qg_textoptions.h"
-       #include "ui/qg_trimamountoptions.h"
-#endif
 #include "arcoptions.h"
 #include "arctangentialoptions.h"
 #include "beveloptions.h"
 #include "coordinatewidget.h"
 #include "dimlinearoptions.h"
 #include "dimoptions.h"
+#include "dlgarc.h"
 #include "dlgattributes.h"
+#include "dlgcircle.h"
+#include "dlgdimension.h"
+#include "dlgdimlinear.h"
+#include "dlgellipse.h"
+#include "dlghatch.h"
+#include "dlginsert.h"
+#include "dlgline.h"
+#include "dlgmirror.h"
+#include "dlgmove.h"
+#include "dlgmoverotate.h"
 #include "dlgoptionsdrawing.h"
 #include "dlgoptionsgeneral.h"
+#include "dlgpoint.h"
+#include "dlgrotate.h"
+#include "dlgrotate2.h"
+#include "dlgscale.h"
+#include "dlgspline.h"
 #include "dlgtext.h"
+#include "libraryinsertoptions.h"
 #include "imageoptions.h"
+#include "insertoptions.h"
 #include "layerdialog.h"
 #include "lineangleoptions.h"
 #include "linebisectoroptions.h"
@@ -936,83 +902,23 @@ void QG_DialogFactory::requestPolylineOptions(RS_ActionInterface * action, bool
 #ifdef RS_PROF
        static PolylineOptions * toolWidget = NULL;
 
-       if (optionWidget != NULL)
+       if (!optionWidget)
+               return;
+
+       if (toolWidget)
        {
-               if (toolWidget != NULL)
-               {
-                       delete toolWidget;
-                       toolWidget = NULL;
-               }
-               if (on && toolWidget == NULL)
-               {
-                       toolWidget = new PolylineOptions(optionWidget);
-                       toolWidget->setAction(action, update);
-               }
+               delete toolWidget;
+               toolWidget = NULL;
        }
-#endif
-}
-
-#if 0
-/**
- * Shows a widget for insert options.
- */
-void QG_DialogFactory::requestInsertOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    static QG_InsertOptions* toolWidget = NULL;
 
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_InsertOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-
-/**
- * Shows a widget for image options.
- */
-void QG_DialogFactory::requestImageOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    static QG_ImageOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_ImageOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
+       if (on)
+       {
+               toolWidget = new PolylineOptions(optionWidget);
+               toolWidget->setAction(action, update);
+       }
+#endif
 }
 
-/**
- * Shows a widget for library insert options.
- */
-void QG_DialogFactory::requestLibraryInsertOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    static QG_LibraryInsertOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_LibraryInsertOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-#else
 /**
  * Shows a widget for options for the action: "draw line parallel"
  */
@@ -1270,12 +1176,42 @@ void QG_DialogFactory::requestTextOptions(RS_ActionInterface * action, bool on,
        }
 }
 
-void QG_DialogFactory::requestInsertOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for insert options.
+ */
+void QG_DialogFactory::requestInsertOptions(RS_ActionInterface * action, bool on, bool update)
 {
+    static InsertOptions * toolWidget = NULL;
+
+    if (optionWidget!=NULL) {
+        if (toolWidget!=NULL) {
+            delete toolWidget;
+            toolWidget = NULL;
+        }
+        if (on==true && toolWidget==NULL) {
+            toolWidget = new InsertOptions(optionWidget);
+            toolWidget->setAction(action, update);
+        }
+    }
 }
 
-void QG_DialogFactory::requestImageOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for image options.
+ */
+void QG_DialogFactory::requestImageOptions(RS_ActionInterface * action, bool on, bool update)
 {
+    static ImageOptions * toolWidget = NULL;
+
+    if (optionWidget!=NULL) {
+        if (toolWidget!=NULL) {
+            delete toolWidget;
+            toolWidget = NULL;
+        }
+        if (on==true && toolWidget==NULL) {
+            toolWidget = new ImageOptions(optionWidget);
+            toolWidget->setAction(action, update);
+        }
+    }
 }
 
 /**
@@ -1435,10 +1371,28 @@ void QG_DialogFactory::requestRoundOptions(RS_ActionInterface * action, bool on,
        }
 }
 
-void QG_DialogFactory::requestLibraryInsertOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for library insert options.
+ */
+void QG_DialogFactory::requestLibraryInsertOptions(RS_ActionInterface * action, bool on, bool update)
 {
+       static LibraryInsertOptions * toolWidget = NULL;
+
+       if (!optionWidget)
+               return;
+
+       if (toolWidget)
+       {
+               delete toolWidget;
+               toolWidget = NULL;
+       }
+
+       if (on)
+       {
+               toolWidget = new LibraryInsertOptions(optionWidget);
+               toolWidget->setAction(action, update);
+       }
 }
-#endif
 
 /**
  * Shows the given toolbar.
@@ -1459,13 +1413,49 @@ void QG_DialogFactory::requestToolBarSelect(RS_ActionInterface * selectAction,
                cadToolBar->showToolBarSelect(selectAction, nextAction);
 }
 
-#if 0
+/**
+ * Shows a dialog to edit the attributes of the given dimension entity.
+ */
+ /*
+bool QG_DialogFactory::requestDimAlignedDialog(RS_DimAligned* dim) {
+    if (dim==NULL) {
+        return false;
+    }
+
+    QG_DlgDimAligned dlg(parent);
+    dlg.setDim(*dim, true);
+    if (dlg.exec()) {
+        dlg.updateDim();
+        return true;
+    }
+
+    return false;
+}
+*/
+
+/**
+ * Shows attributes options dialog presenting the given data.
+ */
+bool QG_DialogFactory::requestAttributesDialog(RS_AttributesData & data, RS_LayerList & layerList)
+{
+       DlgAttributes dlg(parent);
+       dlg.setData(&data, layerList);
+
+       if (dlg.exec())
+       {
+               dlg.updateData();
+               return true;
+       }
+
+       return false;
+}
+
 /**
  * Shows move options dialog presenting the given data.
  */
 bool QG_DialogFactory::requestMoveDialog(RS_MoveData & data)
 {
-       QG_DlgMove dlg(parent);
+       DlgMove dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1482,7 +1472,7 @@ bool QG_DialogFactory::requestMoveDialog(RS_MoveData & data)
  */
 bool QG_DialogFactory::requestRotateDialog(RS_RotateData & data)
 {
-       QG_DlgRotate dlg(parent);
+       DlgRotate dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1499,7 +1489,7 @@ bool QG_DialogFactory::requestRotateDialog(RS_RotateData & data)
  */
 bool QG_DialogFactory::requestScaleDialog(RS_ScaleData & data)
 {
-       QG_DlgScale dlg(parent);
+       DlgScale dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1516,7 +1506,7 @@ bool QG_DialogFactory::requestScaleDialog(RS_ScaleData & data)
  */
 bool QG_DialogFactory::requestMirrorDialog(RS_MirrorData & data)
 {
-       QG_DlgMirror dlg(parent);
+       DlgMirror dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1533,7 +1523,7 @@ bool QG_DialogFactory::requestMirrorDialog(RS_MirrorData & data)
  */
 bool QG_DialogFactory::requestMoveRotateDialog(RS_MoveRotateData & data)
 {
-       QG_DlgMoveRotate dlg(parent);
+       DlgMoveRotate dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1550,7 +1540,7 @@ bool QG_DialogFactory::requestMoveRotateDialog(RS_MoveRotateData & data)
  */
 bool QG_DialogFactory::requestRotate2Dialog(RS_Rotate2Data & data)
 {
-       QG_DlgRotate2 dlg(parent);
+       DlgRotate2 dlg(parent);
        dlg.setData(&data);
 
        if (dlg.exec())
@@ -1576,7 +1566,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
        {
        case RS2::EntityPoint:
        {
-               QG_DlgPoint dlg(parent);
+               DlgPoint dlg(parent);
                dlg.setPoint(*((RS_Point *)entity));
 
                if (dlg.exec())
@@ -1589,7 +1579,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityLine:
        {
-               QG_DlgLine dlg(parent);
+               DlgLine dlg(parent);
                dlg.setLine(*((RS_Line *)entity));
 
                if (dlg.exec())
@@ -1602,7 +1592,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityArc:
        {
-               QG_DlgArc dlg(parent);
+               DlgArc dlg(parent);
                dlg.setArc(*((RS_Arc *)entity));
 
                if (dlg.exec())
@@ -1615,7 +1605,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityCircle:
        {
-               QG_DlgCircle dlg(parent);
+               DlgCircle dlg(parent);
                dlg.setCircle(*((RS_Circle *)entity));
 
                if (dlg.exec())
@@ -1628,7 +1618,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityEllipse:
        {
-               QG_DlgEllipse dlg(parent);
+               DlgEllipse dlg(parent);
                dlg.setEllipse(*((RS_Ellipse *)entity));
 
                if (dlg.exec())
@@ -1641,7 +1631,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntitySpline:
        {
-               QG_DlgSpline dlg(parent);
+               DlgSpline dlg(parent);
                dlg.setSpline(*((RS_Spline *)entity));
 
                if (dlg.exec())
@@ -1654,7 +1644,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityInsert:
        {
-               QG_DlgInsert dlg(parent);
+               DlgInsert dlg(parent);
                dlg.setInsert(*((RS_Insert *)entity));
 
                if (dlg.exec())
@@ -1671,7 +1661,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
        case RS2::EntityDimDiametric:
        case RS2::EntityDimRadial:
        {
-               QG_DlgDimension dlg(parent);
+               DlgDimension dlg(parent);
                dlg.setDim(*((RS_Dimension *)entity));
 
                if (dlg.exec())
@@ -1685,7 +1675,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityDimLinear:
        {
-               QG_DlgDimLinear dlg(parent);
+               DlgDimLinear dlg(parent);
                dlg.setDim(*((RS_DimLinear *)entity));
 
                if (dlg.exec())
@@ -1699,7 +1689,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityText:
        {
-               QG_DlgText dlg(parent);
+               DlgText dlg(parent);
                dlg.setText(*((RS_Text *)entity), false);
 
                if (dlg.exec())
@@ -1713,7 +1703,7 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 
        case RS2::EntityHatch:
        {
-               QG_DlgHatch dlg(parent);
+               DlgHatch dlg(parent);
                dlg.setHatch(*((RS_Hatch *)entity), false);
 
                if (dlg.exec())
@@ -1732,22 +1722,8 @@ bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
        return ret;
 }
 
-/**
- * Shows a dialog to edit the attributes of the given dimension entity.
- */
  /*
 bool QG_DialogFactory::requestDimAlignedDialog(RS_DimAligned* dim) {
-    if (dim==NULL) {
-        return false;
-    }
-
-    QG_DlgDimAligned dlg(parent);
-    dlg.setDim(*dim, true);
-    if (dlg.exec()) {
-        dlg.updateDim();
-        return true;
-    }
-
     return false;
 }
 */
@@ -1760,7 +1736,7 @@ bool QG_DialogFactory::requestTextDialog(RS_Text * text)
        if (text == NULL)
                return false;
 
-       QG_DlgText dlg(parent);
+       DlgText dlg(parent);
        dlg.setText(*text, true);
 
        if (dlg.exec())
@@ -1782,7 +1758,7 @@ bool QG_DialogFactory::requestHatchDialog(RS_Hatch * hatch)
 
        RS_PATTERNLIST->init();
 
-       QG_DlgHatch dlg(parent);
+       DlgHatch dlg(parent);
        dlg.setHatch(*hatch, true);
 
        if (dlg.exec())
@@ -1793,260 +1769,6 @@ bool QG_DialogFactory::requestHatchDialog(RS_Hatch * hatch)
 
        return false;
 }
-#else
-/**
- * Shows attributes options dialog presenting the given data.
- */
-bool QG_DialogFactory::requestAttributesDialog(RS_AttributesData & data, RS_LayerList & layerList)
-{
-       DlgAttributes dlg(parent);
-       dlg.setData(&data, layerList);
-
-       if (dlg.exec())
-       {
-               dlg.updateData();
-               return true;
-       }
-
-       return false;
-}
-
-bool QG_DialogFactory::requestMoveDialog(RS_MoveData & data)
-{
-       return false;
-}
-
-bool QG_DialogFactory::requestRotateDialog(RS_RotateData & data)
-{
-       return false;
-}
-
-bool QG_DialogFactory::requestScaleDialog(RS_ScaleData & data)
-{
-       return false;
-}
-
-bool QG_DialogFactory::requestMirrorDialog(RS_MirrorData & data)
-{
-       return false;
-}
-
-bool QG_DialogFactory::requestMoveRotateDialog(RS_MoveRotateData & data)
-{
-       return false;
-}
-
-bool QG_DialogFactory::requestRotate2Dialog(RS_Rotate2Data & data)
-{
-       return false;
-}
-
-/**
- * Shows a dialog to edit the given entity.
- */
-bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
-{
-       if (entity == NULL)
-               return false;
-
-       bool ret = false;
-
-       switch (entity->rtti())
-       {
-//NOTE: These #if 0's are put here until these missing dialogs can be ported to Qt4.
-#if 0
-       case RS2::EntityPoint:
-       {
-               QG_DlgPoint dlg(parent);
-               dlg.setPoint(*((RS_Point *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updatePoint();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntityLine:
-       {
-               QG_DlgLine dlg(parent);
-               dlg.setLine(*((RS_Line *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateLine();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntityArc:
-       {
-               QG_DlgArc dlg(parent);
-               dlg.setArc(*((RS_Arc *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateArc();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntityCircle:
-       {
-               QG_DlgCircle dlg(parent);
-               dlg.setCircle(*((RS_Circle *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateCircle();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntityEllipse:
-       {
-               QG_DlgEllipse dlg(parent);
-               dlg.setEllipse(*((RS_Ellipse *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateEllipse();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntitySpline:
-       {
-               QG_DlgSpline dlg(parent);
-               dlg.setSpline(*((RS_Spline *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateSpline();
-                       ret = true;
-               }
-       }
-               break;
-
-       case RS2::EntityInsert:
-       {
-               QG_DlgInsert dlg(parent);
-               dlg.setInsert(*((RS_Insert *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateInsert();
-                       ret = true;
-                       entity->update();
-               }
-       }
-               break;
-
-       case RS2::EntityDimAligned:
-       case RS2::EntityDimAngular:
-       case RS2::EntityDimDiametric:
-       case RS2::EntityDimRadial:
-       {
-               QG_DlgDimension dlg(parent);
-               dlg.setDim(*((RS_Dimension *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateDim();
-                       ret = true;
-                       ((RS_Dimension *)entity)->update(true);
-               }
-       }
-               break;
-
-       case RS2::EntityDimLinear:
-       {
-               QG_DlgDimLinear dlg(parent);
-               dlg.setDim(*((RS_DimLinear *)entity));
-
-               if (dlg.exec())
-               {
-                       dlg.updateDim();
-                       ret = true;
-                       ((RS_DimLinear *)entity)->update(true);
-               }
-       }
-               break;
-#endif
-
-       case RS2::EntityText:
-       {
-               DlgText dlg(parent);
-               dlg.setText(*((RS_Text *)entity), false);
-
-               if (dlg.exec())
-               {
-                       dlg.updateText();
-                       ret = true;
-                       ((RS_Text *)entity)->update();
-               }
-       }
-               break;
-
-#if 0
-       case RS2::EntityHatch:
-       {
-               QG_DlgHatch dlg(parent);
-               dlg.setHatch(*((RS_Hatch *)entity), false);
-
-               if (dlg.exec())
-               {
-                       dlg.updateHatch();
-                       ret = true;
-                       ((RS_Hatch *)entity)->update();
-               }
-       }
-               break;
-#endif
-
-       default:
-               break;
-       }
-
-       return ret;
-}
-
- /*
-bool QG_DialogFactory::requestDimAlignedDialog(RS_DimAligned* dim) {
-    return false;
-}
-*/
-
-/**
- * Shows a dialog to edit the attributes of the given text entity.
- */
-bool QG_DialogFactory::requestTextDialog(RS_Text * text)
-{
-       if (text == NULL)
-               return false;
-
-       DlgText dlg(parent);
-       dlg.setText(*text, true);
-
-       if (dlg.exec())
-       {
-               dlg.updateText();
-               return true;
-       }
-
-       return false;
-}
-
-bool QG_DialogFactory::requestHatchDialog(RS_Hatch * hatch)
-{
-       return false;
-}
-#endif
 
 #ifdef RS_CAM
 /**