From 413e5947c4b370eab8bed95817b084b6b0b7c7fb Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 10 Jan 2014 11:46:52 +0800 Subject: [PATCH] Code refactoring: rename one internal variable only --- src/xlsx/xlsxformat.cpp | 46 ++++++++++++++++++++--------------------- src/xlsx/xlsxformat_p.h | 3 ++- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/xlsx/xlsxformat.cpp b/src/xlsx/xlsxformat.cpp index 1624798..cb88300 100755 --- a/src/xlsx/xlsxformat.cpp +++ b/src/xlsx/xlsxformat.cpp @@ -51,7 +51,7 @@ FormatPrivate::FormatPrivate(const FormatPrivate &other) , xf_index(other.xf_index), xf_indexValid(other.xf_indexValid) , is_dxf_fomat(other.is_dxf_fomat), dxf_index(other.dxf_index), dxf_indexValid(other.dxf_indexValid) , theme(other.theme) - , property(other.property) + , properties(other.properties) { } @@ -538,8 +538,8 @@ QByteArray Format::fontKey() const QByteArray key; QDataStream stream(&key, QIODevice::WriteOnly); for (int i=FormatPrivate::P_Font_STARTID; iproperty.contains(i)) - stream << i << d->property[i]; + if (d->properties.contains(i)) + stream << i << d->properties[i]; }; const_cast(this)->d->font_key = key; @@ -946,8 +946,8 @@ QByteArray Format::borderKey() const QByteArray key; QDataStream stream(&key, QIODevice::WriteOnly); for (int i=FormatPrivate::P_Border_STARTID; iproperty.contains(i)) - stream << i << d->property[i]; + if (d->properties.contains(i)) + stream << i << d->properties[i]; }; const_cast(this)->d->border_key = key; @@ -1066,8 +1066,8 @@ QByteArray Format::fillKey() const QByteArray key; QDataStream stream(&key, QIODevice::WriteOnly); for (int i=FormatPrivate::P_Fill_STARTID; iproperty.contains(i)) - stream << i << d->property[i]; + if (d->properties.contains(i)) + stream << i << d->properties[i]; }; const_cast(this)->d->fill_key = key; @@ -1150,7 +1150,7 @@ void Format::mergeFormat(const Format &modifier) return; } - QMapIterator it(modifier.d->property); + QMapIterator it(modifier.d->properties); while(it.hasNext()) { it.next(); setProperty(it.key(), it.value()); @@ -1174,7 +1174,7 @@ bool Format::isEmpty() const { if (!d) return true; - return d->property.isEmpty(); + return d->properties.isEmpty(); } /*! @@ -1189,7 +1189,7 @@ QByteArray Format::formatKey() const QByteArray key; QDataStream stream(&key, QIODevice::WriteOnly); - QMapIterator i(d->property); + QMapIterator i(d->properties); while (i.hasNext()) { i.next(); stream<property.contains(propertyId)) - return d->property[propertyId]; + if (d && d->properties.contains(propertyId)) + return d->properties[propertyId]; return defaultValue; } @@ -1308,17 +1308,17 @@ void Format::setProperty(int propertyId, const QVariant &value, const QVariant & d = new FormatPrivate; if (value != clearValue) { - if (d->property.contains(propertyId) && d->property[propertyId] == value) + if (d->properties.contains(propertyId) && d->properties[propertyId] == value) return; if (detach) d.detach(); - d->property[propertyId] = value; + d->properties[propertyId] = value; } else { - if (!d->property.contains(propertyId)) + if (!d->properties.contains(propertyId)) return; if (detach) d.detach(); - d->property.remove(propertyId); + d->properties.remove(propertyId); } d->dirty = true; @@ -1352,7 +1352,7 @@ bool Format::hasProperty(int propertyId) const { if (!d) return false; - return d->property.contains(propertyId); + return d->properties.contains(propertyId); } /*! @@ -1363,7 +1363,7 @@ bool Format::boolProperty(int propertyId, bool defaultValue) const if (!hasProperty(propertyId)) return defaultValue; - const QVariant prop = d->property[propertyId]; + const QVariant prop = d->properties[propertyId]; if (prop.userType() != QMetaType::Bool) return defaultValue; return prop.toBool(); @@ -1377,7 +1377,7 @@ int Format::intProperty(int propertyId, int defaultValue) const if (!hasProperty(propertyId)) return defaultValue; - const QVariant prop = d->property[propertyId]; + const QVariant prop = d->properties[propertyId]; if (prop.userType() != QMetaType::Int) return defaultValue; return prop.toInt(); @@ -1391,7 +1391,7 @@ double Format::doubleProperty(int propertyId, double defaultValue) const if (!hasProperty(propertyId)) return defaultValue; - const QVariant prop = d->property[propertyId]; + const QVariant prop = d->properties[propertyId]; if (prop.userType() != QMetaType::Double && prop.userType() != QMetaType::Float) return defaultValue; return prop.toDouble(); @@ -1405,7 +1405,7 @@ QString Format::stringProperty(int propertyId, const QString &defaultValue) cons if (!hasProperty(propertyId)) return defaultValue; - const QVariant prop = d->property[propertyId]; + const QVariant prop = d->properties[propertyId]; if (prop.userType() != QMetaType::QString) return defaultValue; return prop.toString(); @@ -1419,7 +1419,7 @@ QColor Format::colorProperty(int propertyId, const QColor &defaultValue) const if (!hasProperty(propertyId)) return defaultValue; - const QVariant prop = d->property[propertyId]; + const QVariant prop = d->properties[propertyId]; if (prop.userType() != qMetaTypeId()) return defaultValue; return qvariant_cast(prop).rgbColor(); @@ -1428,7 +1428,7 @@ QColor Format::colorProperty(int propertyId, const QColor &defaultValue) const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const Format &f) { - dbg.nospace() << "QXlsx::Format(" << f.d->property << ")"; + dbg.nospace() << "QXlsx::Format(" << f.d->properties << ")"; return dbg.space(); } #endif diff --git a/src/xlsx/xlsxformat_p.h b/src/xlsx/xlsxformat_p.h index 4c1ad4e..85752f5 100644 --- a/src/xlsx/xlsxformat_p.h +++ b/src/xlsx/xlsxformat_p.h @@ -39,6 +39,7 @@ #include "xlsxformat.h" #include #include +#include namespace QXlsx { @@ -152,7 +153,7 @@ public: int theme; - QMap property; + QMap properties; }; }