Browse Source

Code refactoring: rename one internal variable only

master
Debao Zhang 11 years ago
parent
commit
413e5947c4
  1. 46
      src/xlsx/xlsxformat.cpp
  2. 3
      src/xlsx/xlsxformat_p.h

46
src/xlsx/xlsxformat.cpp

@ -51,7 +51,7 @@ FormatPrivate::FormatPrivate(const FormatPrivate &other)
, xf_index(other.xf_index), xf_indexValid(other.xf_indexValid) , 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) , is_dxf_fomat(other.is_dxf_fomat), dxf_index(other.dxf_index), dxf_indexValid(other.dxf_indexValid)
, theme(other.theme) , theme(other.theme)
, property(other.property) , properties(other.properties)
{ {
} }
@ -538,8 +538,8 @@ QByteArray Format::fontKey() const
QByteArray key; QByteArray key;
QDataStream stream(&key, QIODevice::WriteOnly); QDataStream stream(&key, QIODevice::WriteOnly);
for (int i=FormatPrivate::P_Font_STARTID; i<FormatPrivate::P_Font_ENDID; ++i) { for (int i=FormatPrivate::P_Font_STARTID; i<FormatPrivate::P_Font_ENDID; ++i) {
if (d->property.contains(i)) if (d->properties.contains(i))
stream << i << d->property[i]; stream << i << d->properties[i];
}; };
const_cast<Format*>(this)->d->font_key = key; const_cast<Format*>(this)->d->font_key = key;
@ -946,8 +946,8 @@ QByteArray Format::borderKey() const
QByteArray key; QByteArray key;
QDataStream stream(&key, QIODevice::WriteOnly); QDataStream stream(&key, QIODevice::WriteOnly);
for (int i=FormatPrivate::P_Border_STARTID; i<FormatPrivate::P_Border_ENDID; ++i) { for (int i=FormatPrivate::P_Border_STARTID; i<FormatPrivate::P_Border_ENDID; ++i) {
if (d->property.contains(i)) if (d->properties.contains(i))
stream << i << d->property[i]; stream << i << d->properties[i];
}; };
const_cast<Format*>(this)->d->border_key = key; const_cast<Format*>(this)->d->border_key = key;
@ -1066,8 +1066,8 @@ QByteArray Format::fillKey() const
QByteArray key; QByteArray key;
QDataStream stream(&key, QIODevice::WriteOnly); QDataStream stream(&key, QIODevice::WriteOnly);
for (int i=FormatPrivate::P_Fill_STARTID; i<FormatPrivate::P_Fill_ENDID; ++i) { for (int i=FormatPrivate::P_Fill_STARTID; i<FormatPrivate::P_Fill_ENDID; ++i) {
if (d->property.contains(i)) if (d->properties.contains(i))
stream << i << d->property[i]; stream << i << d->properties[i];
}; };
const_cast<Format*>(this)->d->fill_key = key; const_cast<Format*>(this)->d->fill_key = key;
@ -1150,7 +1150,7 @@ void Format::mergeFormat(const Format &modifier)
return; return;
} }
QMapIterator<int, QVariant> it(modifier.d->property); QMapIterator<int, QVariant> it(modifier.d->properties);
while(it.hasNext()) { while(it.hasNext()) {
it.next(); it.next();
setProperty(it.key(), it.value()); setProperty(it.key(), it.value());
@ -1174,7 +1174,7 @@ bool Format::isEmpty() const
{ {
if (!d) if (!d)
return true; return true;
return d->property.isEmpty(); return d->properties.isEmpty();
} }
/*! /*!
@ -1189,7 +1189,7 @@ QByteArray Format::formatKey() const
QByteArray key; QByteArray key;
QDataStream stream(&key, QIODevice::WriteOnly); QDataStream stream(&key, QIODevice::WriteOnly);
QMapIterator<int, QVariant> i(d->property); QMapIterator<int, QVariant> i(d->properties);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
stream<<i.key()<<i.value(); stream<<i.key()<<i.value();
@ -1294,8 +1294,8 @@ int Format::theme() const
*/ */
QVariant Format::property(int propertyId, const QVariant &defaultValue) const QVariant Format::property(int propertyId, const QVariant &defaultValue) const
{ {
if (d && d->property.contains(propertyId)) if (d && d->properties.contains(propertyId))
return d->property[propertyId]; return d->properties[propertyId];
return defaultValue; return defaultValue;
} }
@ -1308,17 +1308,17 @@ void Format::setProperty(int propertyId, const QVariant &value, const QVariant &
d = new FormatPrivate; d = new FormatPrivate;
if (value != clearValue) { if (value != clearValue) {
if (d->property.contains(propertyId) && d->property[propertyId] == value) if (d->properties.contains(propertyId) && d->properties[propertyId] == value)
return; return;
if (detach) if (detach)
d.detach(); d.detach();
d->property[propertyId] = value; d->properties[propertyId] = value;
} else { } else {
if (!d->property.contains(propertyId)) if (!d->properties.contains(propertyId))
return; return;
if (detach) if (detach)
d.detach(); d.detach();
d->property.remove(propertyId); d->properties.remove(propertyId);
} }
d->dirty = true; d->dirty = true;
@ -1352,7 +1352,7 @@ bool Format::hasProperty(int propertyId) const
{ {
if (!d) if (!d)
return false; 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)) if (!hasProperty(propertyId))
return defaultValue; return defaultValue;
const QVariant prop = d->property[propertyId]; const QVariant prop = d->properties[propertyId];
if (prop.userType() != QMetaType::Bool) if (prop.userType() != QMetaType::Bool)
return defaultValue; return defaultValue;
return prop.toBool(); return prop.toBool();
@ -1377,7 +1377,7 @@ int Format::intProperty(int propertyId, int defaultValue) const
if (!hasProperty(propertyId)) if (!hasProperty(propertyId))
return defaultValue; return defaultValue;
const QVariant prop = d->property[propertyId]; const QVariant prop = d->properties[propertyId];
if (prop.userType() != QMetaType::Int) if (prop.userType() != QMetaType::Int)
return defaultValue; return defaultValue;
return prop.toInt(); return prop.toInt();
@ -1391,7 +1391,7 @@ double Format::doubleProperty(int propertyId, double defaultValue) const
if (!hasProperty(propertyId)) if (!hasProperty(propertyId))
return defaultValue; return defaultValue;
const QVariant prop = d->property[propertyId]; const QVariant prop = d->properties[propertyId];
if (prop.userType() != QMetaType::Double && prop.userType() != QMetaType::Float) if (prop.userType() != QMetaType::Double && prop.userType() != QMetaType::Float)
return defaultValue; return defaultValue;
return prop.toDouble(); return prop.toDouble();
@ -1405,7 +1405,7 @@ QString Format::stringProperty(int propertyId, const QString &defaultValue) cons
if (!hasProperty(propertyId)) if (!hasProperty(propertyId))
return defaultValue; return defaultValue;
const QVariant prop = d->property[propertyId]; const QVariant prop = d->properties[propertyId];
if (prop.userType() != QMetaType::QString) if (prop.userType() != QMetaType::QString)
return defaultValue; return defaultValue;
return prop.toString(); return prop.toString();
@ -1419,7 +1419,7 @@ QColor Format::colorProperty(int propertyId, const QColor &defaultValue) const
if (!hasProperty(propertyId)) if (!hasProperty(propertyId))
return defaultValue; return defaultValue;
const QVariant prop = d->property[propertyId]; const QVariant prop = d->properties[propertyId];
if (prop.userType() != qMetaTypeId<XlsxColor>()) if (prop.userType() != qMetaTypeId<XlsxColor>())
return defaultValue; return defaultValue;
return qvariant_cast<XlsxColor>(prop).rgbColor(); return qvariant_cast<XlsxColor>(prop).rgbColor();
@ -1428,7 +1428,7 @@ QColor Format::colorProperty(int propertyId, const QColor &defaultValue) const
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Format &f) QDebug operator<<(QDebug dbg, const Format &f)
{ {
dbg.nospace() << "QXlsx::Format(" << f.d->property << ")"; dbg.nospace() << "QXlsx::Format(" << f.d->properties << ")";
return dbg.space(); return dbg.space();
} }
#endif #endif

3
src/xlsx/xlsxformat_p.h

@ -39,6 +39,7 @@
#include "xlsxformat.h" #include "xlsxformat.h"
#include <QSharedData> #include <QSharedData>
#include <QMap> #include <QMap>
#include <QSet>
namespace QXlsx { namespace QXlsx {
@ -152,7 +153,7 @@ public:
int theme; int theme;
QMap<int, QVariant> property; QMap<int, QVariant> properties;
}; };
} }

Loading…
Cancel
Save