Skip to content

Commit

Permalink
Merge pull request #126 from QtExcel/qt6beta
Browse files Browse the repository at this point in the history
Qt6beta
  • Loading branch information
j2doll authored Dec 13, 2020
2 parents 893f5f0 + bfea4c6 commit b78cf0c
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 149 deletions.
21 changes: 3 additions & 18 deletions QXlsx/source/xlsxchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,7 @@ bool ChartPrivate::loadXmlPlotAreaElement(QXmlStreamReader &reader)

bool ChartPrivate::loadXmlXxxChart(QXmlStreamReader &reader)
{
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
QStringView name = reader.name();
#else
QStringRef name = reader.name();
#endif
const auto& name = reader.name();

if (name == QLatin1String("areaChart"))
{
Expand Down Expand Up @@ -650,13 +646,7 @@ bool ChartPrivate::loadXmlSer(QXmlStreamReader &reader)
if (reader.readNextStartElement())
{
//TODO beide Header noch auswerten RTR 2019.11

#if QT_VERSION >= 0x060000 // Qt 6.0 or over
QStringView name = reader.name();
#else
QStringRef name = reader.name();
#endif

const auto& name = reader.name();
if ( name == QLatin1String("tx") )
{
while ( !reader.atEnd() &&
Expand Down Expand Up @@ -2249,12 +2239,7 @@ QString ChartPrivate::readSubTree(QXmlStreamReader &reader)
{
QString treeString;
QString prefix;

#if QT_VERSION >= 0x060000 // Qt 6.0 or over
QStringView treeName = reader.name();
#else
QStringRef treeName = reader.name();
#endif
const auto& treeName = reader.name();

while (!reader.atEnd())
{
Expand Down
39 changes: 15 additions & 24 deletions QXlsx/source/xlsxcolor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// xlsxcolor.cpp

#include <QtGlobal>
#include <QDataStream>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
Expand Down Expand Up @@ -32,9 +31,7 @@ XlsxColor::XlsxColor(int index)

bool XlsxColor::isRgbColor() const
{
if (val.userType() == qMetaTypeId<QColor>() && val.value<QColor>().isValid())
return true;
return false;
return val.userType() == qMetaTypeId<QColor>() && val.value<QColor>().isValid();
}

bool XlsxColor::isIndexedColor() const
Expand All @@ -54,23 +51,17 @@ bool XlsxColor::isInvalid() const

QColor XlsxColor::rgbColor() const
{
if (isRgbColor())
return val.value<QColor>();
return QColor();
return isRgbColor() ? val.value<QColor>() : QColor();
}

int XlsxColor::indexedColor() const
{
if (isIndexedColor())
return val.toInt();
return -1;
return isIndexedColor() ? val.toInt() : -1;
}

QStringList XlsxColor::themeColor() const
{
if (isThemeColor())
return val.toStringList();
return QStringList();
return isThemeColor() ? val.toStringList() : QStringList();
}

bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
Expand Down Expand Up @@ -98,29 +89,31 @@ bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const

bool XlsxColor::loadFromXml(QXmlStreamReader &reader)
{
QXmlStreamAttributes attributes = reader.attributes();
const auto& attributes = reader.attributes();

if (attributes.hasAttribute(QLatin1String("rgb"))) {
QString colorString = attributes.value(QLatin1String("rgb")).toString();
const auto& colorString = attributes.value(QLatin1String("rgb")).toString();
val.setValue(fromARGBString(colorString));
} else if (attributes.hasAttribute(QLatin1String("indexed"))) {
int index = attributes.value(QLatin1String("indexed")).toString().toInt();
val.setValue(index);
} else if (attributes.hasAttribute(QLatin1String("theme"))) {
QString theme = attributes.value(QLatin1String("theme")).toString();
QString tint = attributes.value(QLatin1String("tint")).toString();
const auto& theme = attributes.value(QLatin1String("theme")).toString();
const auto& tint = attributes.value(QLatin1String("tint")).toString();
val.setValue(QStringList()<<theme<<tint);
}
return true;
}

XlsxColor::operator QVariant() const
{
const auto& cref
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
return QVariant((QMetaType) qMetaTypeId<XlsxColor>(), this);
= QMetaType::fromType<XlsxColor>();
#else
return QVariant(qMetaTypeId<XlsxColor>(), this);
= qMetaTypeId<XlsxColor>() ;
#endif
return QVariant(cref, this);
}


Expand All @@ -146,15 +139,13 @@ QColor XlsxColor::fromARGBString(const QString &c)

QString XlsxColor::toARGBString(const QColor &c)
{
QString color;

#if QT_VERSION >= 0x050600 // Qt 5.6 or over
color = QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
return QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
#else
QString color;
color.sprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
#endif

return color;
#endif
}

#if !defined(QT_NO_DATASTREAM)
Expand Down
9 changes: 2 additions & 7 deletions QXlsx/source/xlsxdocpropscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,8 @@ bool DocPropsCore::loadFromXmlFile(QIODevice *device)
if (token == QXmlStreamReader::StartElement)
{

#if QT_VERSION >= 0x060000 // Qt 6.0 or over
const QStringView nsUri = reader.namespaceUri();
const QStringView name = reader.name();
#else
const QStringRef nsUri = reader.namespaceUri();
const QStringRef name = reader.name();
#endif
const auto& nsUri = reader.namespaceUri();
const auto& name = reader.name();

if (name == QStringLiteral("subject") && nsUri == dc)
{
Expand Down
8 changes: 5 additions & 3 deletions QXlsx/source/xlsxrichstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ RichString &RichString::operator =(const RichString &other)
*/
RichString::operator QVariant() const
{
#if QT_VERSION >= 0x060000 // ver 6.0
return QVariant((QMetaType) qMetaTypeId<RichString>(), this);
const auto& cref
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
= QMetaType::fromType<RichString>();
#else
return QVariant(qMetaTypeId<RichString>(), this);
= qMetaTypeId<RichString>() ;
#endif
return QVariant(cref, this);
}

/*!
Expand Down
Loading

0 comments on commit b78cf0c

Please sign in to comment.