Handle non-latin1 chars in template
This commit is contained in:
parent
6ad50696b9
commit
3eb9037ada
|
@ -60,10 +60,10 @@ void DlgTemplateField::setFieldContent(std::string content)
|
||||||
leInput->setText(qs);
|
leInput->setText(qs);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DlgTemplateField::getFieldContent()
|
QString DlgTemplateField::getFieldContent()
|
||||||
{
|
{
|
||||||
QString result = leInput->text();
|
QString result = leInput->text();
|
||||||
return result.toStdString();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgTemplateField::accept()
|
void DlgTemplateField::accept()
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define DRAWINGGUI_DLGTEMPLATEFIELD_H
|
#define DRAWINGGUI_DLGTEMPLATEFIELD_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <Mod/TechDraw/Gui/ui_DlgTemplateField.h>
|
#include <Mod/TechDraw/Gui/ui_DlgTemplateField.h>
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public:
|
||||||
|
|
||||||
void setFieldName(std::string name);
|
void setFieldName(std::string name);
|
||||||
void setFieldContent(std::string content);
|
void setFieldContent(std::string content);
|
||||||
std::string getFieldContent();
|
QString getFieldContent();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
|
@ -65,7 +65,6 @@ QGISVGTemplate::QGISVGTemplate(QGraphicsScene *scene, QWidget* srWidget)
|
||||||
|
|
||||||
QGISVGTemplate::~QGISVGTemplate()
|
QGISVGTemplate::~QGISVGTemplate()
|
||||||
{
|
{
|
||||||
clearContents();
|
|
||||||
delete m_svgRender;
|
delete m_svgRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,15 +75,6 @@ QVariant QGISVGTemplate::itemChange(GraphicsItemChange change,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QGISVGTemplate::clearContents()
|
|
||||||
{
|
|
||||||
for (std::vector<TemplateTextField *>::iterator it = textFields.begin();
|
|
||||||
it != textFields.end(); ++it) {
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
textFields.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QGISVGTemplate::openFile(const QFile &file)
|
void QGISVGTemplate::openFile(const QFile &file)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -92,8 +82,6 @@ void QGISVGTemplate::openFile(const QFile &file)
|
||||||
|
|
||||||
void QGISVGTemplate::load(const QString &fileName)
|
void QGISVGTemplate::load(const QString &fileName)
|
||||||
{
|
{
|
||||||
clearContents();
|
|
||||||
|
|
||||||
if (fileName.isEmpty()){
|
if (fileName.isEmpty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,13 +93,11 @@ void QGISVGTemplate::load(const QString &fileName)
|
||||||
m_svgRender->load(file.fileName());
|
m_svgRender->load(file.fileName());
|
||||||
|
|
||||||
QSize size = m_svgRender->defaultSize();
|
QSize size = m_svgRender->defaultSize();
|
||||||
//Base::Console().Log("size of svg document <%i,%i>", size.width(), size.height());
|
|
||||||
m_svgItem->setSharedRenderer(m_svgRender);
|
m_svgItem->setSharedRenderer(m_svgRender);
|
||||||
|
|
||||||
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
||||||
|
|
||||||
|
|
||||||
//std::string temp = tmplte->Template.getValue();
|
|
||||||
std::string temp = tmplte->PageResult.getValue(); //fixes non-drawing of restored template
|
std::string temp = tmplte->PageResult.getValue(); //fixes non-drawing of restored template
|
||||||
if (temp.empty())
|
if (temp.empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -49,8 +49,6 @@ public:
|
||||||
enum {Type = QGraphicsItem::UserType + 153};
|
enum {Type = QGraphicsItem::UserType + 153};
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
|
||||||
/// Currently just frees up textFields
|
|
||||||
void clearContents();
|
|
||||||
void draw();
|
void draw();
|
||||||
virtual void updateView(bool update = false);
|
virtual void updateView(bool update = false);
|
||||||
|
|
||||||
|
@ -66,6 +64,6 @@ protected:
|
||||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||||
}; // class QGISVGTemplate
|
}; // class QGISVGTemplate
|
||||||
|
|
||||||
} // namespace MDIViewPageGui
|
}
|
||||||
|
|
||||||
#endif // DRAWINGGUI_QGRAPHICSITEMSVGTEMPLATE_H
|
#endif // DRAWINGGUI_QGRAPHICSITEMSVGTEMPLATE_H
|
||||||
|
|
|
@ -25,9 +25,10 @@
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
#include<QInputDialog>
|
#include<QInputDialog>
|
||||||
#include<QLineEdit>
|
#include<QLineEdit>
|
||||||
|
#include <QTextDocument>
|
||||||
#endif // #ifndef _PreCmp_
|
#endif // #ifndef _PreCmp_
|
||||||
|
|
||||||
#include <QTextDocument>
|
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
|
||||||
|
@ -58,13 +59,13 @@ TemplateTextField::~TemplateTextField()
|
||||||
void TemplateTextField::execDialog()
|
void TemplateTextField::execDialog()
|
||||||
{
|
{
|
||||||
int uiCode = ui->exec();
|
int uiCode = ui->exec();
|
||||||
std::string newContent = "";
|
QString newContent;
|
||||||
if(uiCode == QDialog::Accepted) {
|
if(uiCode == QDialog::Accepted) {
|
||||||
if (tmplte) {
|
if (tmplte) {
|
||||||
std::string newContent = ui->getFieldContent();
|
newContent = ui->getFieldContent();
|
||||||
QString qsClean = Qt::escape(QString::fromStdString(newContent)); //Qt5 note: this becomes qsNewContent.toHtmlEscaped();
|
QString qsClean = Qt::escape(newContent); //Qt5 note: this becomes qsNewContent.toHtmlEscaped();
|
||||||
newContent = qsClean.toUtf8().constData();
|
std::string utf8Content = qsClean.toUtf8().constData();
|
||||||
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
|
tmplte->EditableTexts.setValue(fieldNameStr, utf8Content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui = nullptr; //ui memory will be release by ui's parent Widget
|
ui = nullptr; //ui memory will be release by ui's parent Widget
|
||||||
|
|
Loading…
Reference in New Issue
Block a user