#include "rs_text.h"
#if 0
-#include "ui/qg_arcoptions.h"
-#include "ui/qg_arctangentialoptions.h"
-#include "ui/qg_beveloptions.h"
+ #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_circleoptions.h"
#include "ui/qg_commandwidget.h"
#include "ui/qg_coordinatewidget.h"
#include "ui/qg_dimlinearoptions.h"
#include "ui/qg_textoptions.h"
#include "ui/qg_trimamountoptions.h"
#endif
+#include "arcoptions.h"
+#include "arctangentialoptions.h"
+#include "beveloptions.h"
#include "blockdialog.h"
#include "cadtoolbar.h"
+#include "circleoptions.h"
#include "commandwidget.h"
#include "coordinatewidget.h"
#include "dlgattributes.h"
* @param parent Pointer to parent widget which can host dialogs.
* @param ow Pointer to widget that can host option widgets.
*/
-QG_DialogFactory::QG_DialogFactory(QWidget * parent, QWidget * ow):
+//QG_DialogFactory::QG_DialogFactory(QWidget * parent, QWidget * ow):
+QG_DialogFactory::QG_DialogFactory(QWidget * parent, QToolBar * ow):
RS_DialogFactoryInterface()
{
RS_DEBUG->print("QG_DialogFactory::QG_DialogFactory");
/**
* Links factory to a widget that can host tool options.
*/
-/*virtual*/ void QG_DialogFactory::setOptionWidget(QWidget * ow)
+///*virtual*/ void QG_DialogFactory::setOptionWidget(QWidget * ow)
+/*virtual*/ void QG_DialogFactory::setOptionWidget(QToolBar * ow)
{
RS_DEBUG->print("QG_DialogFactory::setOptionWidget");
optionWidget = ow;
{
static PrintPreviewOptions * toolWidget = NULL;
- if (optionWidget != NULL)
+ if (!optionWidget)
+ return;
+
+ if (toolWidget)
{
- if (toolWidget != NULL)
- {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on && toolWidget == NULL)
- {
- toolWidget = new PrintPreviewOptions(optionWidget);
- toolWidget->setAction(action, update);
- }
+ delete toolWidget;
+ toolWidget = NULL;
+ }
+
+ if (on)
+ {
+ toolWidget = new PrintPreviewOptions(optionWidget);
+ toolWidget->setAction(action, update);
}
}
*/
void QG_DialogFactory::requestLineOptions(RS_ActionInterface * action, bool on)
{
+/*
+The way I see it, this is failure. We're constantly creating & deleting
+these objects all the time when we could create them once, and then reuse
+them over and over. May need to do some more refactoring based on this idea...
+*/
+ //ugh.
static LineOptions * toolWidget = NULL;
- if (optionWidget != NULL)
+ if (!optionWidget)
+ return;
+
+ // Get rid of the LineOptions object if it exists...
+ if (toolWidget)
{
- if (toolWidget != NULL)
- {
- delete toolWidget;
- toolWidget = NULL;
- }
+ delete toolWidget;
+ toolWidget = NULL;
+ }
- if (on == true && toolWidget == NULL)
- {
- toolWidget = new LineOptions(optionWidget);
- toolWidget->setAction(action);
- }
+ // Create a new one for the passed in action
+ if (on)
+ {
+ toolWidget = new LineOptions(optionWidget);
+ toolWidget->setAction(action);
}
RS_DEBUG->print("QG_DialogFactory::requestLineOptions: OK");
}
}
-/**
- * Shows a widget for arc options.
- */
-void QG_DialogFactory::requestArcOptions(RS_ActionInterface* action,
- bool on, bool update)
-{
- static QG_ArcOptions* toolWidget = NULL;
-
- if (optionWidget!=NULL) {
- if (toolWidget!=NULL) {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on==true && toolWidget==NULL) {
- toolWidget = new QG_ArcOptions(optionWidget);
- toolWidget->setAction(action, update);
- //toolWidget->setData(&data);
- }
- }
-}
-
-/**
- * Shows a widget for tangential arc options.
- */
-void QG_DialogFactory::requestArcTangentialOptions(RS_ActionInterface* action,
- bool on, bool update)
-{
- static QG_ArcTangentialOptions* toolWidget = NULL;
-
- if (optionWidget!=NULL) {
- if (toolWidget!=NULL) {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on==true && toolWidget==NULL) {
- toolWidget = new QG_ArcTangentialOptions(optionWidget);
- toolWidget->setAction(action, update);
- //toolWidget->setData(&data);
- }
- }
-}
-
-/**
- * Shows a widget for arc options.
- */
-void QG_DialogFactory::requestCircleOptions(RS_ActionInterface* action,
- bool on, bool update)
-{
- static QG_CircleOptions* toolWidget = NULL;
-
- if (optionWidget!=NULL) {
- if (toolWidget!=NULL) {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on==true && toolWidget==NULL) {
- toolWidget = new QG_CircleOptions(optionWidget);
- toolWidget->setAction(action, update);
- }
- }
-}
-
/**
* Shows a widget for spline options.
*/
}
}
-/**
- * Shows a widget for text options.
- */
-void QG_DialogFactory::requestTextOptions(RS_ActionInterface* action,
- bool on, bool update)
-{
- static QG_TextOptions* toolWidget = NULL;
-
- if (optionWidget!=NULL) {
- if (toolWidget!=NULL) {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on==true && toolWidget==NULL) {
- toolWidget = new QG_TextOptions(optionWidget);
- toolWidget->setAction(action, update);
- }
- }
-}
-
/**
* Shows a widget for insert options.
*/
}
}
-/**
- * Shows a widget for beveling options.
- */
-void QG_DialogFactory::requestBevelOptions(RS_ActionInterface* action,
- bool on, bool update)
-{
- static QG_BevelOptions* toolWidget = NULL;
-
- if (optionWidget!=NULL) {
- if (toolWidget!=NULL) {
- delete toolWidget;
- toolWidget = NULL;
- }
- if (on==true && toolWidget==NULL) {
- toolWidget = new QG_BevelOptions(optionWidget);
- toolWidget->setAction(action, update);
- }
- }
-}
-
/**
* Shows a widget for rounding options.
*/
{
}
-void QG_DialogFactory::requestArcOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for arc options.
+ */
+void QG_DialogFactory::requestArcOptions(RS_ActionInterface * action, bool on, bool update)
{
+ static ArcOptions * toolWidget = NULL;
+
+ if (optionWidget != NULL)
+ {
+ if (toolWidget != NULL)
+ {
+ delete toolWidget;
+ toolWidget = NULL;
+ }
+
+ if (on && toolWidget == NULL)
+ {
+ toolWidget = new ArcOptions(optionWidget);
+ toolWidget->setAction(action, update);
+ //toolWidget->setData(&data);
+ }
+ }
}
-void QG_DialogFactory::requestArcTangentialOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for tangential arc options.
+ */
+void QG_DialogFactory::requestArcTangentialOptions(RS_ActionInterface * action, bool on, bool update)
{
+ static ArcTangentialOptions * toolWidget = NULL;
+
+ if (!optionWidget)
+ return;
+
+ if (toolWidget)
+ {
+ delete toolWidget;
+ toolWidget = NULL;
+ }
+
+ if (on)
+ {
+ toolWidget = new ArcTangentialOptions(optionWidget);
+ toolWidget->setAction(action, update);
+ //toolWidget->setData(&data);
+ }
}
-void QG_DialogFactory::requestCircleOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for circle options.
+ */
+void QG_DialogFactory::requestCircleOptions(RS_ActionInterface * action, bool on, bool update)
{
+ static CircleOptions * toolWidget = NULL;
+
+ if (optionWidget)
+ {
+ if (toolWidget)
+ {
+ delete toolWidget;
+ toolWidget = NULL;
+ }
+
+ if (on && toolWidget == NULL)
+ {
+ toolWidget = new CircleOptions(optionWidget);
+ toolWidget->setAction(action, update);
+ }
+ }
}
void QG_DialogFactory::requestSplineOptions(RS_ActionInterface* action, bool on, bool update)
{
static TextOptions * toolWidget = NULL;
- if (optionWidget != NULL)
+ if (!optionWidget)
+ return;
+
+ if (toolWidget)
{
- if (toolWidget != NULL)
- {
- delete toolWidget;
- toolWidget = NULL;
- }
+ delete toolWidget;
+ toolWidget = NULL;
+ }
- if (on == true && toolWidget == NULL)
- {
- toolWidget = new TextOptions(optionWidget);
- toolWidget->setAction(action, update);
- }
+ if (on)
+ {
+ toolWidget = new TextOptions(optionWidget);
+ toolWidget->setAction(action, update);
}
}
{
}
-void QG_DialogFactory::requestBevelOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for beveling options.
+ */
+void QG_DialogFactory::requestBevelOptions(RS_ActionInterface * action, bool on, bool update)
{
+ static BevelOptions * toolWidget = NULL;
+
+ if (optionWidget != NULL)
+ {
+ if (toolWidget != NULL)
+ {
+ delete toolWidget;
+ toolWidget = NULL;
+ }
+
+ if (on && toolWidget == NULL)
+ {
+ toolWidget = new BevelOptions(optionWidget);
+ toolWidget->setAction(action, update);
+ }
+ }
}
void QG_DialogFactory::requestRoundOptions(RS_ActionInterface* action, bool on, bool update)