Fix template field dialog multiple instances
This commit is contained in:
parent
277a00dc3c
commit
2ac560e7b0
|
@ -66,4 +66,14 @@ std::string DlgTemplateField::getFieldContent()
|
|||
return result.toStdString();
|
||||
}
|
||||
|
||||
void DlgTemplateField::accept()
|
||||
{
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void DlgTemplateField::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
#include "moc_DlgTemplateField.cpp"
|
||||
|
|
|
@ -43,10 +43,11 @@ public:
|
|||
std::string getFieldContent();
|
||||
|
||||
public Q_SLOTS:
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
//Ui_dlgTemplateField* ui;
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<class>TechDrawGui::dlgTemplateField</class>
|
||||
<widget class="QDialog" name="TechDrawGui::dlgTemplateField">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
@ -95,11 +95,11 @@
|
|||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>195</x>
|
||||
<x>209</x>
|
||||
<y>126</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>193</x>
|
||||
<x>209</x>
|
||||
<y>79</y>
|
||||
</hint>
|
||||
</hints>
|
||||
|
@ -111,11 +111,11 @@
|
|||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>195</x>
|
||||
<x>209</x>
|
||||
<y>126</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>193</x>
|
||||
<x>209</x>
|
||||
<y>79</y>
|
||||
</hint>
|
||||
</hints>
|
||||
|
|
|
@ -48,7 +48,7 @@ using namespace TechDrawGui;
|
|||
|
||||
QGISVGTemplate::QGISVGTemplate(QGraphicsScene *scene, QWidget* srWidget)
|
||||
: QGITemplate(scene),
|
||||
upperLevelWidget(srWidget)
|
||||
qgview(srWidget)
|
||||
{
|
||||
m_svgItem.setSharedRenderer(&m_svgRender);
|
||||
|
||||
|
@ -167,7 +167,7 @@ void QGISVGTemplate::load(const QString &fileName)
|
|||
double width = editClickBoxSize;
|
||||
double height = editClickBoxSize;
|
||||
|
||||
TemplateTextField *item = new TemplateTextField(this, tmplte, nameMatch[1].str(), upperLevelWidget);
|
||||
TemplateTextField *item = new TemplateTextField(this, tmplte, nameMatch[1].str(), qgview);
|
||||
float pad = 1;
|
||||
item->setRect(x - pad, -tmplte->getHeight() + y - height - pad,
|
||||
width + 2 * pad, height + 2 * pad);
|
||||
|
|
|
@ -61,7 +61,7 @@ Q_SIGNALS:
|
|||
protected:
|
||||
void openFile(const QFile &file);
|
||||
void load (const QString & fileName);
|
||||
QWidget* upperLevelWidget; //for parenting dlgTemplateField
|
||||
QWidget* qgview; //for parenting dlgTemplateField
|
||||
|
||||
protected:
|
||||
TechDraw::DrawSVGTemplate * getSVGTemplate();
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <Base/Console.h>
|
||||
|
||||
#include "TemplateTextField.h"
|
||||
#include "DlgTemplateField.h"
|
||||
|
||||
//#include<QDebug>
|
||||
|
||||
|
@ -41,11 +40,12 @@ using namespace TechDrawGui;
|
|||
TemplateTextField::TemplateTextField(QGraphicsItem*parent,
|
||||
TechDraw::DrawTemplate *myTmplte,
|
||||
const std::string &myFieldName,
|
||||
QWidget* upperWidget)
|
||||
QWidget* qgview)
|
||||
: QGraphicsRectItem(parent),
|
||||
ui(nullptr),
|
||||
tmplte(myTmplte),
|
||||
fieldNameStr(myFieldName),
|
||||
dlgOwner(upperWidget)
|
||||
dlgOwner(qgview)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,11 +54,8 @@ TemplateTextField::~TemplateTextField()
|
|||
{
|
||||
}
|
||||
|
||||
void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
void TemplateTextField::execDialog()
|
||||
{
|
||||
DlgTemplateField* ui = new DlgTemplateField(dlgOwner);
|
||||
ui->setFieldName(fieldNameStr);
|
||||
ui->setFieldContent(tmplte->EditableTexts[fieldNameStr]);
|
||||
int uiCode = ui->exec();
|
||||
std::string newContent = "";
|
||||
if(uiCode == QDialog::Accepted) {
|
||||
|
@ -69,5 +66,15 @@ void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
|
||||
}
|
||||
}
|
||||
ui->deleteLater();
|
||||
ui = nullptr; //ui memory will be release by ui's parent Widget
|
||||
}
|
||||
|
||||
void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (!ui) {
|
||||
ui = new DlgTemplateField(dlgOwner);
|
||||
ui->setFieldName(fieldNameStr);
|
||||
ui->setFieldContent(tmplte->EditableTexts[fieldNameStr]);
|
||||
execDialog();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,9 @@
|
|||
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
#include "DlgTemplateField.h"
|
||||
#include "../App/DrawTemplate.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGI;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
/// QGraphicsRectItem-derived class for the text fields in title blocks
|
||||
|
@ -42,28 +39,31 @@ namespace TechDrawGui
|
|||
* Property in the Drawing's template can be modified.
|
||||
* Dear English, I'm sorry.
|
||||
*/
|
||||
class TechDrawGuiExport TemplateTextField : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
TemplateTextField(QGraphicsItem*parent,
|
||||
TechDraw::DrawTemplate *myTmplte,
|
||||
const std::string &myFieldName,
|
||||
QWidget* upperWidget=0);
|
||||
class TechDrawGuiExport TemplateTextField : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
TemplateTextField(QGraphicsItem*parent,
|
||||
TechDraw::DrawTemplate *myTmplte,
|
||||
const std::string &myFieldName,
|
||||
QWidget* upperWidget=0);
|
||||
|
||||
~TemplateTextField();
|
||||
~TemplateTextField();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 160};
|
||||
int type() const { return Type;}
|
||||
enum {Type = QGraphicsItem::UserType + 160};
|
||||
int type() const { return Type;}
|
||||
|
||||
|
||||
/// Returns the field name that this TemplateTextField represents
|
||||
std::string fieldName() const { return fieldNameStr; }
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
TechDraw::DrawTemplate *tmplte;
|
||||
std::string fieldNameStr;
|
||||
QWidget* dlgOwner;
|
||||
};
|
||||
/// Returns the field name that this TemplateTextField represents
|
||||
std::string fieldName() const { return fieldNameStr; }
|
||||
|
||||
protected:
|
||||
void execDialog(void);
|
||||
DlgTemplateField* ui;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
TechDraw::DrawTemplate *tmplte;
|
||||
std::string fieldNameStr;
|
||||
QWidget* dlgOwner;
|
||||
};
|
||||
} // namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef DRAWINGGUI_TEMPLATETEXTFIELD_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user