Format: Use QMap instead of QHash

As the items of QHash are arbitrarily ordered, so the same formats may generate
different formatKey
This commit is contained in:
Debao Zhang
2013-11-23 13:45:17 +08:00
parent 77d727748d
commit e1d93af4b7
4 changed files with 63 additions and 38 deletions
+9 -1
View File
@@ -903,7 +903,7 @@ QByteArray Format::formatKey() const
QByteArray key;
QDataStream stream(&key, QIODevice::WriteOnly);
QHashIterator<int, QVariant> i(d->property);
QMapIterator<int, QVariant> i(d->property);
while (i.hasNext()) {
i.next();
stream<<i.key()<<i.value();
@@ -1108,4 +1108,12 @@ QColor Format::colorProperty(int propertyId) const
return qvariant_cast<QColor>(prop);
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const Format &f)
{
dbg.nospace() << "QXlsx::Format(" << f.d->property << ")";
return dbg.space();
}
#endif
QT_END_NAMESPACE_XLSX
+5
View File
@@ -237,6 +237,7 @@ private:
friend class RichStringPrivate;
friend class SharedStrings;
friend class ::FormatTest;
friend Q_XLSX_EXPORT QDebug operator<<(QDebug, const Format &f);
bool fontIndexValid() const;
int fontIndex() const;
@@ -274,6 +275,10 @@ private:
QExplicitlySharedDataPointer<FormatPrivate> d;
};
#ifndef QT_NO_DEBUG_STREAM
Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const Format &f);
#endif
QT_END_NAMESPACE_XLSX
#endif // QXLSX_FORMAT_H
+2 -2
View File
@@ -26,7 +26,7 @@
#define XLSXFORMAT_P_H
#include "xlsxformat.h"
#include <QSharedData>
#include <QHash>
#include <QMap>
namespace QXlsx {
@@ -148,7 +148,7 @@ public:
int theme;
QHash<int, QVariant> property;
QMap<int, QVariant> property;
};
}