Engauge Digitizer  2
Functions
QtToString.h File Reference
#include <QCursor>
#include <QString>
#include <QVector>
#include <QXmlStreamReader>
Include dependency graph for QtToString.h:

Go to the source code of this file.

Functions

QString QLocaleToString (const QLocale &locale)
 
QString QPointFToString (const QPointF &pos)
 
QString QRectFToString (const QRectF &rectF)
 
QString QtCursorToString (Qt::CursorShape cursorShape)
 
QString QTransformToString (const QTransform &transform)
 
QString QXmlStreamReaderTokenTypeToString (QXmlStreamReader::TokenType tokenType)
 
QString roleAsString (int role)
 
QString rolesAsString (const QVector< int > &roles)
 

Function Documentation

◆ QLocaleToString()

QString QLocaleToString ( const QLocale &  locale)

Definition at line 59 of file QtToString.cpp.

60 {
61  return QString ("%1/%2")
62  .arg (QLocale::languageToString (locale.language()))
63  .arg (QLocale::countryToString(locale.country()));
64 }

◆ QPointFToString()

QString QPointFToString ( const QPointF &  pos)

Definition at line 17 of file QtToString.cpp.

18 {
19  QString str = QString ("(%1, %2)")
20  .arg (pos.x ())
21  .arg (pos.y ());
22 
23  return str;
24 }

◆ QRectFToString()

QString QRectFToString ( const QRectF &  rectF)

Definition at line 26 of file QtToString.cpp.

27 {
28  QString str = QString ("(%1x%2+%3+%4)")
29  .arg (rectF.width())
30  .arg (rectF.height())
31  .arg (rectF.x())
32  .arg (rectF.y());
33 
34  return str;
35 }

◆ QtCursorToString()

QString QtCursorToString ( Qt::CursorShape  cursorShape)

Definition at line 37 of file QtToString.cpp.

38 {
39  if (cursorShapesLookupTable.count () == 0) {
40 
41  // Initialize
42  cursorShapesLookupTable [Qt::ArrowCursor] = "Qt::ArrowCursor";
43  cursorShapesLookupTable [Qt::BitmapCursor] = "Qt::BitmapCursor";
44  cursorShapesLookupTable [Qt::CrossCursor] = "Qt::CrossCursor";
45  cursorShapesLookupTable [Qt::WaitCursor] = "Qt::WaitCursor";
46  }
47 
48  if (cursorShapesLookupTable.contains (cursorShape)) {
49 
50  return cursorShapesLookupTable [cursorShape];
51 
52  } else {
53 
54  return "Qt::<unknown>";
55 
56  }
57 }

◆ QTransformToString()

QString QTransformToString ( const QTransform &  transform)

Definition at line 66 of file QtToString.cpp.

67 {
68  const int FIELD_WIDTH = 12;
69 
70  QString str = QString ("%1 %2 %3 %4\n"
71  "%5 %6 %7 %8\n"
72  "%9 %10 %11 %12")
74  .arg (transform.m11 (), FIELD_WIDTH)
75  .arg (transform.m12 (), FIELD_WIDTH)
76  .arg (transform.m13 (), FIELD_WIDTH)
78  .arg (transform.m21 (), FIELD_WIDTH)
79  .arg (transform.m22 (), FIELD_WIDTH)
80  .arg (transform.m23 (), FIELD_WIDTH)
82  .arg (transform.m31 (), FIELD_WIDTH)
83  .arg (transform.m32 (), FIELD_WIDTH)
84  .arg (transform.m33 (), FIELD_WIDTH);
85 
86  return str;
87 }
const QString INDENTATION_PAST_TIMESTAMP

◆ QXmlStreamReaderTokenTypeToString()

QString QXmlStreamReaderTokenTypeToString ( QXmlStreamReader::TokenType  tokenType)

Definition at line 89 of file QtToString.cpp.

90 {
91  if (xmlTokenTypeLookupTable.count () == 0) {
92 
93  // Initialize
94  xmlTokenTypeLookupTable [QXmlStreamReader::Characters] = "Characters";
95  xmlTokenTypeLookupTable [QXmlStreamReader::Comment] = "Comment";
96  xmlTokenTypeLookupTable [QXmlStreamReader::DTD] = "DTD";
97  xmlTokenTypeLookupTable [QXmlStreamReader::EndDocument] = "EndDocument";
98  xmlTokenTypeLookupTable [QXmlStreamReader::EndElement] = "EndElement";
99  xmlTokenTypeLookupTable [QXmlStreamReader::EntityReference] = "EntityReference";
100  xmlTokenTypeLookupTable [QXmlStreamReader::Invalid] = "Invalid";
101  xmlTokenTypeLookupTable [QXmlStreamReader::NoToken] = "NoToken";
102  xmlTokenTypeLookupTable [QXmlStreamReader::ProcessingInstruction] = "ProcessingInstruction";
103  xmlTokenTypeLookupTable [QXmlStreamReader::StartDocument] = "StartDocument";
104  xmlTokenTypeLookupTable [QXmlStreamReader::StartElement] = "StartElement";
105  }
106 
107  if (xmlTokenTypeLookupTable.contains (tokenType)) {
108 
109  return xmlTokenTypeLookupTable [tokenType];
110 
111  } else {
112 
113  return "<Unknown>";
114 
115  }
116 }

◆ roleAsString()

QString roleAsString ( int  role)

Definition at line 118 of file QtToString.cpp.

119 {
120  if (rolesAsStringsLookupTable.count () == 0) {
121 
122  // Initialize with list from qnamespace.h
123  rolesAsStringsLookupTable [Qt::AccessibleDescriptionRole] = "AccessibleDescriptionRole";
124  rolesAsStringsLookupTable [Qt::AccessibleTextRole] = "AccessibleTextRole";
125  rolesAsStringsLookupTable [Qt::BackgroundRole] = "BackgroundRole";
126  rolesAsStringsLookupTable [Qt::BackgroundColorRole] = "BackgroundColorRole";
127  rolesAsStringsLookupTable [Qt::CheckStateRole] = "CheckStateRole";
128  rolesAsStringsLookupTable [Qt::DecorationRole] = "DecorationRole";
129  rolesAsStringsLookupTable [Qt::DisplayRole] = "DisplayRole";
130  rolesAsStringsLookupTable [Qt::EditRole] = "EditRole";
131  rolesAsStringsLookupTable [Qt::FontRole] = "FontRole";
132  rolesAsStringsLookupTable [Qt::ForegroundRole] = "ForegroundRole";
133  rolesAsStringsLookupTable [Qt::InitialSortOrderRole] = "InitialSortOrderRole";
134  rolesAsStringsLookupTable [Qt::SizeHintRole] = "SizeHintRole";
135  rolesAsStringsLookupTable [Qt::StatusTipRole] = "StatusTipRole";
136  rolesAsStringsLookupTable [Qt::TextAlignmentRole] = "TextAlignmentRole";
137  rolesAsStringsLookupTable [Qt::TextColorRole] = "TextColorRole";
138  rolesAsStringsLookupTable [Qt::ToolTipRole] = "ToolTipRole";
139  rolesAsStringsLookupTable [Qt::UserRole] = "UserRole";
140  rolesAsStringsLookupTable [Qt::WhatsThisRole] = "WhatsThisRole";
141  }
142 
143  if (rolesAsStringsLookupTable.contains (role)) {
144 
145  return rolesAsStringsLookupTable [role];
146 
147  } else {
148 
149  return QString ("%1?").arg (role);
150 
151  }
152 }

◆ rolesAsString()

QString rolesAsString ( const QVector< int > &  roles)

Definition at line 154 of file QtToString.cpp.

155 {
156  QString str;
157 
158  for (int i = 0; i < roles.count (); i++) {
159  if (i > 0) {
160  str += ",";
161  }
162  str += roleAsString (roles [i]);
163  }
164 
165  return str;
166 }
QString roleAsString(int role)
Definition: QtToString.cpp:118