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