Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 24728 → Rev 24729

/trunk/Scribus/scribus/latexhelpers.cpp
171,11 → 171,11
m_error += new_error + "\n";
}
 
bool LatexConfigParser::StrRefToBool(const QStringRef &str) const
bool LatexConfigParser::StrViewToBool(const QStringView &str) const
{
if (str == "1" || str == "true")
if (str == QStringView(u"1") || str == QStringView(u"true"))
return true;
if (str == "0" || str == "false" || str.isEmpty())
if (str == QStringView(u"0") || str == QStringView(u"false") || str.isEmpty())
return false;
qWarning() << "Invalid bool string:" << str.toString();
return false;
202,10 → 202,10
continue;
}
QString regex = xml.attributes().value("regex").toString();
bool bold = StrRefToBool(xml.attributes().value("bold"));
bool italic = StrRefToBool(xml.attributes().value("italic"));
bool underline = StrRefToBool(xml.attributes().value("underline"));
bool minimal = StrRefToBool(xml.attributes().value("minimal"));
bool bold = StrViewToBool(xml.attributes().value("bold"));
bool italic = StrViewToBool(xml.attributes().value("italic"));
bool underline = StrViewToBool(xml.attributes().value("underline"));
bool minimal = StrViewToBool(xml.attributes().value("minimal"));
QString colorStr = xml.attributes().value("color").toString();
QColor color(colorStr);
if (!color.isValid())
/trunk/Scribus/scribus/latexhelpers.h
23,12 → 23,12
#ifndef LATEXHELPERS_H
#define LATEXHELPERS_H
 
#include <QObject>
#include <QPointer>
#include <QString>
#include <QStringView>
#include <QSyntaxHighlighter>
#include <QXmlStreamReader>
#include <QString>
#include <QStringRef>
#include <QObject>
#include <QPointer>
 
class LatexHighlighterRule
{
89,11 → 89,12
void parseTab();
void parseHighlighter();
void ignoreList();
bool StrRefToBool(const QStringRef &str) const;
bool StrViewToBool(const QStringView& str) const;
};
 
class LatexConfigCache;
class LatexConfigCache {
class LatexConfigCache
{
public:
static LatexConfigCache* instance();
static QStringList defaultConfigs();
/trunk/Scribus/scribus/nftrcreader.cpp
8,6 → 8,8
* Riku Leino, tsoots@gmail.com *
***************************************************************************/
 
#include <QStringView>
 
#include "nftrcreader.h"
 
using namespace std;
34,16 → 36,16
if (tType != QXmlStreamReader::StartElement)
continue;
 
QStringRef tagName = reader.name();
QStringView tagName = reader.name();
if (firstElement)
{
if (tagName != "templates")
if (tagName != QStringView(u"templates"))
return false;
firstElement = false;
continue;
}
 
if (tagName == "template")
if (tagName == QStringView(u"template"))
{
QXmlStreamAttributes attrs = reader.attributes();
QString attrCat = attrs.value("category").toString();
70,8 → 72,8
if (!reader.isStartElement())
return false;
 
QStringRef elemName = reader.name();
if (elemName != "template")
QStringView elemName = reader.name();
if (elemName != QStringView(u"template"))
return false;
 
while (!reader.atEnd() && !reader.hasError())
85,10 → 87,10
if (tType != QXmlStreamReader::StartElement)
continue;
 
QStringRef tagName = reader.name();
if (tagName == "name")
QStringView tagName = reader.name();
if (tagName == QStringView(u"name"))
nftTemplate->name = reader.readElementText();
else if (tagName == "file")
else if (tagName == QStringView(u"file"))
{
QString tmp = reader.readElementText();
if (tmp.left(1) == "/")
96,7 → 98,7
else
nftTemplate->file = currentDir + "/" + tmp;
}
else if (tagName == "tnail")
else if (tagName == QStringView(u"tnail"))
{
QString tmp = reader.readElementText();
if (tmp.left(1) == "/")
104,7 → 106,7
else
nftTemplate->tnail = currentDir + "/" + tmp;
}
else if (tagName == "img")
else if (tagName == QStringView(u"img"))
{
QString tmp = reader.readElementText();
if (tmp.left(1) == "/")
112,21 → 114,21
else
nftTemplate->img = currentDir + "/" + tmp;
}
else if (tagName == "psize")
else if (tagName == QStringView(u"psize"))
nftTemplate->psize = reader.readElementText();
else if (tagName == "color")
else if (tagName == QStringView(u"color"))
nftTemplate->color = reader.readElementText();
else if (tagName == "descr")
else if (tagName == QStringView(u"descr"))
nftTemplate->descr = reader.readElementText();
else if (tagName == "usage")
else if (tagName == QStringView(u"usage"))
nftTemplate->usage = reader.readElementText();
else if (tagName == "scribus_version")
else if (tagName == QStringView(u"scribus_version"))
nftTemplate->scribusVersion = reader.readElementText();
else if (tagName == "date")
else if (tagName == QStringView(u"date"))
nftTemplate->date = reader.readElementText();
else if (tagName == "author")
else if (tagName == QStringView(u"author"))
nftTemplate->author = reader.readElementText();
else if (tagName == "email")
else if (tagName == QStringView(u"email"))
nftTemplate->email = reader.readElementText();
else
{
/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
18,6 → 18,7
#include <QIODevice>
#include <QList>
#include <QScopedPointer>
#include <QStringView>
 
#include "../../formatidlist.h"
#include "commonstrings.h"
/trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
36,7 → 36,7
 
QXmlStreamReader sReader(&qFile);
QXmlStreamReader::TokenType tagType;
QStringRef tagName;
QStringView tagName;
 
while (!sReader.atEnd() && !sReader.hasError())
{
45,7 → 45,7
continue;
 
tagName = sReader.name();
if (tagName != "template")
if (tagName != QStringView(u"template"))
continue;
 
QXmlStreamAttributes attrs = sReader.attributes();
/trunk/Scribus/scribus/scribusXml.cpp
83,7 → 83,7
ff = file;
 
bool succeed = false;
QStringRef tName;
QStringView tName;
QXmlStreamReader sReader(ff);
QXmlStreamReader::TokenType tType;
while (!sReader.atEnd() && !sReader.hasError())
92,7 → 92,7
if (tType == QXmlStreamReader::StartElement)
{
tName = sReader.name();
if ((tName == "SCRIBUSELEM") || (tName == "SCRIBUSELEMUTF8"))
if ((tName == QStringView(u"SCRIBUSELEM")) || (tName == QStringView(u"SCRIBUSELEMUTF8")))
{
QXmlStreamAttributes attrs = sReader.attributes();;
QString attx = attrs.value("XP").toString();
238,4 → 238,4
for (auto item : selectedItems)
items.insert(doc->Items->indexOf(item), item);
return items.values();
}
}
/trunk/Scribus/scribus/ui/helpbrowser.cpp
81,7 → 81,7
 
QXmlStreamReader sReader(&qFile);
QXmlStreamReader::TokenType tagType;
QStringRef tagName;
QStringView tagName;
 
while (!sReader.atEnd() && !sReader.hasError())
{
90,7 → 90,7
continue;
 
tagName = sReader.name();
if (tagName != "item")
if (tagName != QStringView(u"item"))
continue;
 
struct histd2 his;
126,7 → 126,7
 
QXmlStreamReader sReader(&qFile);
QXmlStreamReader::TokenType tagType;
QStringRef tagName;
QStringView tagName;
 
while (!sReader.atEnd() && !sReader.hasError())
{
135,7 → 135,7
continue;
 
tagName = sReader.name();
if (tagName != "item")
if (tagName != QStringView(u"item"))
continue;
 
QXmlStreamAttributes attrs = sReader.attributes();
/trunk/Scribus/scribus/ui/latexeditor.cpp
28,12 → 28,13
 
#include <QDebug>
#include <QFile>
#include <QFontComboBox>
#include <QFrame>
#include <QFontComboBox>
#include <QLineEdit>
#include <QPushButton>
#include <QListWidget>
#include <QMessageBox>
#include <QPushButton>
#include <QStringView>
#include <QTemporaryFile>
#include <cmath>
#include "filewatcher.h"
449,12 → 450,12
{
xml.readNext();
if (xml.isWhitespace() || xml.isComment()) continue;
if (xml.isStartElement() && xml.name() == "tab")
if (xml.isStartElement() && xml.name() == QStringView(u"tab"))
{
if (xml.attributes().value("type") == "settings")
if (xml.attributes().value("type") == QStringView(u"settings"))
{
createNewSettingsTab(&xml);
} else if (xml.attributes().value("type") == "items")
} else if (xml.attributes().value("type") == QStringView(u"items"))
{
createNewItemsTab(&xml);
}
475,7 → 476,7
 
void LatexEditor::createNewSettingsTab(I18nXmlStreamReader *xml)
{
QStringRef tagname;
QStringView tagname;
QFrame *newTab = new QFrame();
newTab->setFrameShape(QFrame::NoFrame);
QGridLayout *layout = new QGridLayout(newTab);
487,24 → 488,32
xml->readNext();
if (xml->isWhitespace() || xml->isComment()) continue;
tagname = xml->name();
if (xml->isEndElement() && (tagname == "tab")) {
if (xml->isEndElement() && (tagname == QStringView(u"tab")))
{
break;
}
if (!xml->isStartElement()) {
if (!xml->isStartElement())
{
xmlError() << "Unexpected element (not a start element)!";
continue;
}
if (tagname == "comment") {
if (tagname == QStringView(u"comment"))
{
QLabel *label = new QLabel(xml->readI18nText());
int row = layout->rowCount();
label->setWordWrap(true);
layout->addWidget(label, row, 0, 1, 3);
} else if (tagname == "title") {
}
else if (tagname == QStringView(u"title"))
{
title = xml->readI18nText();
} else {
}
else
{
XmlWidget *widget = XmlWidget::fromXml(xml);
if (dynamic_cast<QWidget *>(widget)) {
if (dynamic_cast<QWidget *>(widget))
{
QLabel *label = new QLabel(widget->description());
label->setWordWrap(true);
QString name = widget->name();
522,15 → 531,12
this, SLOT(tagButtonClicked(QString)));
layout->addWidget(button, row, 2);*/
if (widgetMap.contains(name)) {
xmlError() << "There is already an widget with name" <<
name << "!";
}
if (widgetMap.contains(name))
xmlError() << "There is already an widget with name" << name << "!";
widgetMap[name] = widget;
} else {
xmlError() << "Unexpected tag" << tagname.toString() <<
"in settings tab";
}
else
xmlError() << "Unexpected tag" << tagname.toString() << "in settings tab";
}
}
layout->setRowStretch(layout->rowCount(), 10);
539,9 → 545,8
 
void LatexEditor::createNewItemsTab(I18nXmlStreamReader *xml)
{
QString title = "No Title!";
QString title("No Title!");
QFrame *newTab = new QFrame();
newTab->setFrameShape(QFrame::NoFrame);
QVBoxLayout *vLayout = new QVBoxLayout(newTab);
567,13 → 572,13
vLayout->addWidget(iconList, 100);
vLayout->addLayout(hLayout, 0);
QStringRef tagname;
QStringView tagname;
while (!xml->atEnd())
{
xml->readNext();
if (xml->isWhitespace() || xml->isComment()) continue;
tagname = xml->name();
if (xml->isEndElement() && (tagname == "tab"))
if (xml->isEndElement() && (tagname == QStringView(u"tab")))
break;
if (!xml->isStartElement())
{
580,11 → 585,11
xmlError() << "Unexpected end element " <<tagname.toString()<<"in item tab";
continue;
}
if (tagname == "title")
if (tagname == QStringView(u"title"))
{
title = xml->readI18nText();
}
else if (tagname == "item")
else if (tagname == QStringView(u"item"))
{
QString value = xml->attributes().value("value").toString();
QString img = xml->attributes().value("image").toString();
611,8 → 616,7
}
else
{
xmlError() << "Unexpected tag" << tagname.toString() <<
"in item tab!";
xmlError() << "Unexpected tag" << tagname.toString() << "in item tab!";
continue;
}
}
652,11 → 656,13
fromString(m_defaultValue);
}
QString toString() const {
QString toString() const
{
return currentFont().toString();
}
void fromString(QString str) {
void fromString(QString str)
{
QFont font;
font.fromString(str);
this->setCurrentFont(font);
730,15 → 736,18
class SCRIBUS_API XmlLineEdit : public XmlWidget, public QLineEdit
{
public:
XmlLineEdit(I18nXmlStreamReader *xml) : XmlWidget(xml) {
XmlLineEdit(I18nXmlStreamReader *xml) : XmlWidget(xml)
{
fromString(m_defaultValue);
}
QString toString() const override {
QString toString() const override
{
return text();
}
void fromString(QString str) override {
void fromString(QString str) override
{
setText(str);
}
};
746,15 → 755,18
class SCRIBUS_API XmlTextEdit : public XmlWidget, public QTextEdit
{
public:
XmlTextEdit(I18nXmlStreamReader *xml) : XmlWidget(xml) {
XmlTextEdit(I18nXmlStreamReader *xml) : XmlWidget(xml)
{
fromString(m_defaultValue);
}
QString toString() const override {
QString toString() const override
{
return toPlainText();
}
void fromString(QString str) override {
void fromString(QString str) override
{
setPlainText(str);
}
};
769,11 → 781,13
fromString(m_defaultValue);
}
QString toString() const override {
QString toString() const override
{
return "Not implemented!";
}
void fromString(QString str) override {
void fromString(QString str) override
{
qDebug() << "Color pickers are not implemented yet!";
}
};
783,37 → 797,45
public:
XmlComboBox(I18nXmlStreamReader *xml) : XmlWidget(xml, false)
{
QStringRef tagname;
QStringView tagname;
while (!xml->atEnd()) {
xml->readNext();
if (xml->isWhitespace() || xml->isComment()) continue;
tagname = xml->name();
if (xml->isEndElement() && (tagname == "list")) {
if (xml->isEndElement() && (tagname == QStringView(u"list")))
{
fromString(m_defaultValue);
return;
}
if (xml->isEndElement()) {
if (xml->isEndElement())
{
xmlError() << "Unexpected end element" << tagname.toString();
continue;
}
if (tagname == "title") {
if (tagname == QStringView(u"title"))
{
m_description = xml->readI18nText();
} else if (tagname == "option") {
}
else if (tagname == QStringView(u"option"))
{
QString value = xml->attributes().value("value").toString();
QString text = xml->readI18nText();
addItem(text, value);
} else {
xmlError() << "Unexpected tag" << tagname.toString() <<
"in list!";
}
else
{
xmlError() << "Unexpected tag" << tagname.toString() << "in list!";
}
}
}
QString toString() const override {
QString toString() const override
{
return itemData(currentIndex()).toString();
}
void fromString(QString str) override {
void fromString(QString str) override
{
setCurrentIndex(findData(str));
}
};
820,24 → 842,24
 
XmlWidget* XmlWidget::fromXml(I18nXmlStreamReader *xml)
{
QStringRef tagname = xml->name();
if (tagname == "font")
QStringView tagname = xml->name();
if (tagname == QStringView(u"font"))
return new XmlFontComboBox(xml);
if (tagname == "spinbox")
if (tagname == QStringView(u"spinbox"))
{
if (xml->attributes().value("type") == "double")
return new XmlDoubleSpinBox(xml);
return new XmlSpinBox(xml);
}
if (tagname == "color")
if (tagname == QStringView(u"color"))
return new XmlColorPicker(xml);
if (tagname == "text")
if (tagname == QStringView(u"text"))
{
if (xml->attributes().value("type") == "long")
return new XmlTextEdit(xml);
return new XmlLineEdit(xml);
}
if (tagname == "list")
if (tagname == QStringView(u"list"))
return new XmlComboBox(xml);
return nullptr;
}
852,7 → 874,8
 
void IconBuffer::loadFile(const QString& filename)
{
if (loadedFiles.contains(filename)) return;
if (loadedFiles.contains(filename))
return;
loadedFiles << filename;
file = new QFile(filename);
if (!file->open(QIODevice::ReadOnly))
873,7 → 896,7
QIcon *IconBuffer::icon(const QString& filename, const QString& name)
{
loadFile(filename);
QString cname = filename + ":" + name;
QString cname(filename + ":" + name);
if (icons.contains(cname))
return &(icons[cname]);
qWarning() << "Icon" << cname << "not found!";