QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsvariantutils.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvariantutils.h
3  ------------------
4  Date : January 2022
5  Copyright : (C) 2022 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsvariantutils.h"
17 
18 
19 QString QgsVariantUtils::typeToDisplayString( QVariant::Type type, QVariant::Type subType )
20 {
21  switch ( type )
22  {
23  case QVariant::Invalid:
24  break;
25  case QVariant::Bool:
26  return QObject::tr( "Boolean" );
27  case QVariant::Int:
28  return QObject::tr( "Integer (32 bit)" );
29  case QVariant::UInt:
30  return QObject::tr( "Integer (unsigned 32 bit)" );
31  case QVariant::LongLong:
32  return QObject::tr( "Integer (64 bit)" );
33  case QVariant::ULongLong:
34  return QObject::tr( "Integer (unsigned 64 bit)" );
35  case QVariant::Double:
36  return QObject::tr( "Decimal (double)" );
37  case QVariant::Char:
38  return QObject::tr( "Character" );
39  case QVariant::Map:
40  return QObject::tr( "Map" );
41  case QVariant::List:
42  {
43  switch ( subType )
44  {
45  case QVariant::Int:
46  return QObject::tr( "Integer List" );
47  case QVariant::LongLong:
48  return QObject::tr( "Integer (64 bit) List" );
49  case QVariant::Double:
50  return QObject::tr( "Decimal (double) List" );
51  default:
52  return QObject::tr( "List" );
53  }
54  }
55  case QVariant::String:
56  return QObject::tr( "Text (string)" );
57  case QVariant::StringList:
58  return QObject::tr( "String List" );
59  case QVariant::ByteArray:
60  return QObject::tr( "Binary Object (BLOB)" );
61  case QVariant::BitArray:
62  return QObject::tr( "Bit Array" );
63  case QVariant::Date:
64  return QObject::tr( "Date" );
65  case QVariant::Time:
66  return QObject::tr( "Time" );
67  case QVariant::DateTime:
68  return QObject::tr( "Date & Time" );
69  case QVariant::Url:
70  return QObject::tr( "URL" );
71  case QVariant::Locale:
72  return QObject::tr( "Locale" );
73  case QVariant::Rect:
74  case QVariant::RectF:
75  return QObject::tr( "Rectangle" );
76  case QVariant::Size:
77  case QVariant::SizeF:
78  return QObject::tr( "Size" );
79  case QVariant::Line:
80  case QVariant::LineF:
81  return QObject::tr( "Line" );
82  case QVariant::Point:
83  case QVariant::PointF:
84  return QObject::tr( "Point" );
85  case QVariant::RegularExpression:
86  return QObject::tr( "Regular Expression" );
87  case QVariant::Hash:
88  return QObject::tr( "Hash" );
89  case QVariant::EasingCurve:
90  return QObject::tr( "Easing Curve" );
91  case QVariant::Uuid:
92  return QObject::tr( "UUID" );
93  case QVariant::ModelIndex:
94  case QVariant::PersistentModelIndex:
95  return QObject::tr( "Model Index" );
96  case QVariant::Font:
97  return QObject::tr( "Font" );
98  case QVariant::Pixmap:
99  return QObject::tr( "Pixmap" );
100  case QVariant::Brush:
101  return QObject::tr( "Brush" );
102  case QVariant::Color:
103  return QObject::tr( "Color" );
104  case QVariant::Palette:
105  return QObject::tr( "Palette" );
106  case QVariant::Image:
107  return QObject::tr( "Image" );
108  case QVariant::Polygon:
109  case QVariant::PolygonF:
110  return QObject::tr( "Polygon" );
111  case QVariant::Region:
112  return QObject::tr( "Region" );
113  case QVariant::Bitmap:
114  return QObject::tr( "Bitmap" );
115  case QVariant::Cursor:
116  return QObject::tr( "Cursor" );
117  case QVariant::KeySequence:
118  return QObject::tr( "Key Sequence" );
119  case QVariant::Pen:
120  return QObject::tr( "Pen" );
121  case QVariant::TextLength:
122  return QObject::tr( "Text Length" );
123  case QVariant::TextFormat:
124  return QObject::tr( "Text Format" );
125  case QVariant::Matrix4x4:
126  return QObject::tr( "Matrix" );
127  case QVariant::Transform:
128  return QObject::tr( "Transform" );
129  case QVariant::Vector2D:
130  case QVariant::Vector3D:
131  case QVariant::Vector4D:
132  return QObject::tr( "Vector" );
133  case QVariant::Quaternion:
134  return QObject::tr( "Quaternion" );
135  case QVariant::Icon:
136  return QObject::tr( "Icon" );
137  case QVariant::SizePolicy:
138  return QObject::tr( "Size Policy" );
139 
140  default:
141  break;
142  }
143  return QString();
144 }
static QString typeToDisplayString(QVariant::Type type, QVariant::Type subType=QVariant::Type::Invalid)
Returns a user-friendly translated string representing a QVariant type.