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