Skip to content

Commit b78cf0c

Browse files
authored
Merge pull request #126 from QtExcel/qt6beta
Qt6beta
2 parents 893f5f0 + bfea4c6 commit b78cf0c

File tree

9 files changed

+100
-149
lines changed

9 files changed

+100
-149
lines changed

QXlsx/source/xlsxchart.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,7 @@ bool ChartPrivate::loadXmlPlotAreaElement(QXmlStreamReader &reader)
516516

517517
bool ChartPrivate::loadXmlXxxChart(QXmlStreamReader &reader)
518518
{
519-
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
520-
QStringView name = reader.name();
521-
#else
522-
QStringRef name = reader.name();
523-
#endif
519+
const auto& name = reader.name();
524520

525521
if (name == QLatin1String("areaChart"))
526522
{
@@ -650,13 +646,7 @@ bool ChartPrivate::loadXmlSer(QXmlStreamReader &reader)
650646
if (reader.readNextStartElement())
651647
{
652648
//TODO beide Header noch auswerten RTR 2019.11
653-
654-
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
655-
QStringView name = reader.name();
656-
#else
657-
QStringRef name = reader.name();
658-
#endif
659-
649+
const auto& name = reader.name();
660650
if ( name == QLatin1String("tx") )
661651
{
662652
while ( !reader.atEnd() &&
@@ -2249,12 +2239,7 @@ QString ChartPrivate::readSubTree(QXmlStreamReader &reader)
22492239
{
22502240
QString treeString;
22512241
QString prefix;
2252-
2253-
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
2254-
QStringView treeName = reader.name();
2255-
#else
2256-
QStringRef treeName = reader.name();
2257-
#endif
2242+
const auto& treeName = reader.name();
22582243

22592244
while (!reader.atEnd())
22602245
{

QXlsx/source/xlsxcolor.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// xlsxcolor.cpp
22

3-
#include <QtGlobal>
43
#include <QDataStream>
54
#include <QXmlStreamReader>
65
#include <QXmlStreamWriter>
@@ -32,9 +31,7 @@ XlsxColor::XlsxColor(int index)
3231

3332
bool XlsxColor::isRgbColor() const
3433
{
35-
if (val.userType() == qMetaTypeId<QColor>() && val.value<QColor>().isValid())
36-
return true;
37-
return false;
34+
return val.userType() == qMetaTypeId<QColor>() && val.value<QColor>().isValid();
3835
}
3936

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

5552
QColor XlsxColor::rgbColor() const
5653
{
57-
if (isRgbColor())
58-
return val.value<QColor>();
59-
return QColor();
54+
return isRgbColor() ? val.value<QColor>() : QColor();
6055
}
6156

6257
int XlsxColor::indexedColor() const
6358
{
64-
if (isIndexedColor())
65-
return val.toInt();
66-
return -1;
59+
return isIndexedColor() ? val.toInt() : -1;
6760
}
6861

6962
QStringList XlsxColor::themeColor() const
7063
{
71-
if (isThemeColor())
72-
return val.toStringList();
73-
return QStringList();
64+
return isThemeColor() ? val.toStringList() : QStringList();
7465
}
7566

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

9990
bool XlsxColor::loadFromXml(QXmlStreamReader &reader)
10091
{
101-
QXmlStreamAttributes attributes = reader.attributes();
92+
const auto& attributes = reader.attributes();
10293

10394
if (attributes.hasAttribute(QLatin1String("rgb"))) {
104-
QString colorString = attributes.value(QLatin1String("rgb")).toString();
95+
const auto& colorString = attributes.value(QLatin1String("rgb")).toString();
10596
val.setValue(fromARGBString(colorString));
10697
} else if (attributes.hasAttribute(QLatin1String("indexed"))) {
10798
int index = attributes.value(QLatin1String("indexed")).toString().toInt();
10899
val.setValue(index);
109100
} else if (attributes.hasAttribute(QLatin1String("theme"))) {
110-
QString theme = attributes.value(QLatin1String("theme")).toString();
111-
QString tint = attributes.value(QLatin1String("tint")).toString();
101+
const auto& theme = attributes.value(QLatin1String("theme")).toString();
102+
const auto& tint = attributes.value(QLatin1String("tint")).toString();
112103
val.setValue(QStringList()<<theme<<tint);
113104
}
114105
return true;
115106
}
116107

117108
XlsxColor::operator QVariant() const
118109
{
110+
const auto& cref
119111
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
120-
return QVariant((QMetaType) qMetaTypeId<XlsxColor>(), this);
112+
= QMetaType::fromType<XlsxColor>();
121113
#else
122-
return QVariant(qMetaTypeId<XlsxColor>(), this);
114+
= qMetaTypeId<XlsxColor>() ;
123115
#endif
116+
return QVariant(cref, this);
124117
}
125118

126119

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

147140
QString XlsxColor::toARGBString(const QColor &c)
148141
{
149-
QString color;
150-
151142
#if QT_VERSION >= 0x050600 // Qt 5.6 or over
152-
color = QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
143+
return QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
153144
#else
145+
QString color;
154146
color.sprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
155-
#endif
156-
157147
return color;
148+
#endif
158149
}
159150

160151
#if !defined(QT_NO_DATASTREAM)

QXlsx/source/xlsxdocpropscore.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,8 @@ bool DocPropsCore::loadFromXmlFile(QIODevice *device)
128128
if (token == QXmlStreamReader::StartElement)
129129
{
130130

131-
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
132-
const QStringView nsUri = reader.namespaceUri();
133-
const QStringView name = reader.name();
134-
#else
135-
const QStringRef nsUri = reader.namespaceUri();
136-
const QStringRef name = reader.name();
137-
#endif
131+
const auto& nsUri = reader.namespaceUri();
132+
const auto& name = reader.name();
138133

139134
if (name == QStringLiteral("subject") && nsUri == dc)
140135
{

QXlsx/source/xlsxrichstring.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ RichString &RichString::operator =(const RichString &other)
8484
*/
8585
RichString::operator QVariant() const
8686
{
87-
#if QT_VERSION >= 0x060000 // ver 6.0
88-
return QVariant((QMetaType) qMetaTypeId<RichString>(), this);
87+
const auto& cref
88+
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
89+
= QMetaType::fromType<RichString>();
8990
#else
90-
return QVariant(qMetaTypeId<RichString>(), this);
91+
= qMetaTypeId<RichString>() ;
9192
#endif
93+
return QVariant(cref, this);
9294
}
9395

9496
/*!

0 commit comments

Comments
 (0)