11 #include "QtToString.h"
13 static QHash<Qt::CursorShape, QString> cursorShapesLookupTable;
14 static QHash<int, QString> rolesAsStringsLookupTable;
15 static QHash<QXmlStreamReader::TokenType, QString> xmlTokenTypeLookupTable;
17 QString QPointFToString (
const QPointF &pos)
19 QString str = QString (
"(%1, %2)")
26 QString QtCursorToString (Qt::CursorShape cursorShape)
28 if (cursorShapesLookupTable.count () == 0) {
31 cursorShapesLookupTable [Qt::ArrowCursor] =
"Qt::ArrowCursor";
32 cursorShapesLookupTable [Qt::BitmapCursor] =
"Qt::BitmapCursor";
33 cursorShapesLookupTable [Qt::CrossCursor] =
"Qt::CrossCursor";
34 cursorShapesLookupTable [Qt::WaitCursor] =
"Qt::WaitCursor";
37 if (cursorShapesLookupTable.contains (cursorShape)) {
39 return cursorShapesLookupTable [cursorShape];
43 return "Qt::<unknown>";
48 QString QLocaleToString (
const QLocale &locale)
50 return QString (
"%1/%2")
51 .arg (QLocale::languageToString (locale.language()))
52 .arg (QLocale::countryToString(locale.country()));
55 QString QTransformToString (
const QTransform &transform)
57 const int FIELD_WIDTH = 12;
59 QString str = QString (
"%1 %2 %3 %4\n"
62 .arg (INDENTATION_PAST_TIMESTAMP)
63 .arg (transform.m11 (), FIELD_WIDTH)
64 .arg (transform.m12 (), FIELD_WIDTH)
65 .arg (transform.m13 (), FIELD_WIDTH)
66 .arg (INDENTATION_PAST_TIMESTAMP)
67 .arg (transform.m21 (), FIELD_WIDTH)
68 .arg (transform.m22 (), FIELD_WIDTH)
69 .arg (transform.m23 (), FIELD_WIDTH)
70 .arg (INDENTATION_PAST_TIMESTAMP)
71 .arg (transform.m31 (), FIELD_WIDTH)
72 .arg (transform.m32 (), FIELD_WIDTH)
73 .arg (transform.m33 (), FIELD_WIDTH);
78 QString QXmlStreamReaderTokenTypeToString (QXmlStreamReader::TokenType tokenType)
80 if (xmlTokenTypeLookupTable.count () == 0) {
83 xmlTokenTypeLookupTable [QXmlStreamReader::Characters] =
"Characters";
84 xmlTokenTypeLookupTable [QXmlStreamReader::Comment] =
"Comment";
85 xmlTokenTypeLookupTable [QXmlStreamReader::DTD] =
"DTD";
86 xmlTokenTypeLookupTable [QXmlStreamReader::EndDocument] =
"EndDocument";
87 xmlTokenTypeLookupTable [QXmlStreamReader::EndElement] =
"EndElement";
88 xmlTokenTypeLookupTable [QXmlStreamReader::EntityReference] =
"EntityReference";
89 xmlTokenTypeLookupTable [QXmlStreamReader::Invalid] =
"Invalid";
90 xmlTokenTypeLookupTable [QXmlStreamReader::NoToken] =
"NoToken";
91 xmlTokenTypeLookupTable [QXmlStreamReader::ProcessingInstruction] =
"ProcessingInstruction";
92 xmlTokenTypeLookupTable [QXmlStreamReader::StartDocument] =
"StartDocument";
93 xmlTokenTypeLookupTable [QXmlStreamReader::StartElement] =
"StartElement";
96 if (xmlTokenTypeLookupTable.contains (tokenType)) {
98 return xmlTokenTypeLookupTable [tokenType];
107 QString roleAsString (
int role)
109 if (rolesAsStringsLookupTable.count () == 0) {
112 rolesAsStringsLookupTable [Qt::AccessibleDescriptionRole] =
"AccessibleDescriptionRole";
113 rolesAsStringsLookupTable [Qt::AccessibleTextRole] =
"AccessibleTextRole";
114 rolesAsStringsLookupTable [Qt::BackgroundRole] =
"BackgroundRole";
115 rolesAsStringsLookupTable [Qt::BackgroundColorRole] =
"BackgroundColorRole";
116 rolesAsStringsLookupTable [Qt::CheckStateRole] =
"CheckStateRole";
117 rolesAsStringsLookupTable [Qt::DecorationRole] =
"DecorationRole";
118 rolesAsStringsLookupTable [Qt::DisplayRole] =
"DisplayRole";
119 rolesAsStringsLookupTable [Qt::EditRole] =
"EditRole";
120 rolesAsStringsLookupTable [Qt::FontRole] =
"FontRole";
121 rolesAsStringsLookupTable [Qt::ForegroundRole] =
"ForegroundRole";
122 rolesAsStringsLookupTable [Qt::InitialSortOrderRole] =
"InitialSortOrderRole";
123 rolesAsStringsLookupTable [Qt::SizeHintRole] =
"SizeHintRole";
124 rolesAsStringsLookupTable [Qt::StatusTipRole] =
"StatusTipRole";
125 rolesAsStringsLookupTable [Qt::TextAlignmentRole] =
"TextAlignmentRole";
126 rolesAsStringsLookupTable [Qt::TextColorRole] =
"TextColorRole";
127 rolesAsStringsLookupTable [Qt::ToolTipRole] =
"ToolTipRole";
128 rolesAsStringsLookupTable [Qt::UserRole] =
"UserRole";
129 rolesAsStringsLookupTable [Qt::WhatsThisRole] =
"WhatsThisRole";
132 if (rolesAsStringsLookupTable.contains (role)) {
134 return rolesAsStringsLookupTable [role];
138 return QString (
"%1?").arg (role);
143 QString rolesAsString (
const QVector<int> &roles)
147 for (
int i = 0; i < roles.count (); i++) {
151 str += roleAsString (roles [i]);