Mercurial > projects > qtd
comparison tools/duic/d/dwriteinitialization.cpp @ 48:2085c2157b50
started work on duic
author | eldar |
---|---|
date | Mon, 18 May 2009 00:22:14 +0000 |
parents | e78566595089 |
children | d5a6b6269f44 |
comparison
equal
deleted
inserted
replaced
47:bbdccfc07d8e | 48:2085c2157b50 |
---|---|
52 namespace { | 52 namespace { |
53 // Fixup an enumeration name from class Qt. | 53 // Fixup an enumeration name from class Qt. |
54 // They are currently stored as "BottomToolBarArea" instead of "Qt::BottomToolBarArea". | 54 // They are currently stored as "BottomToolBarArea" instead of "Qt::BottomToolBarArea". |
55 // due to MO issues. This might be fixed in the future. | 55 // due to MO issues. This might be fixed in the future. |
56 void fixQtEnumerationName(QString& name) { | 56 void fixQtEnumerationName(QString& name) { |
57 static const QLatin1String prefix("qt.core.Qt."); | 57 static const QLatin1String prefix("Qt."); |
58 if (name.indexOf(prefix) != 0) | 58 if (name.indexOf(prefix) != 0) |
59 name.prepend(prefix); | 59 name.prepend(prefix); |
60 } | 60 } |
61 // figure out the toolbar area of a DOM attrib list. | 61 // figure out the toolbar area of a DOM attrib list. |
62 // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. | 62 // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. |
65 if (!pstyle) | 65 if (!pstyle) |
66 return QString(); | 66 return QString(); |
67 | 67 |
68 switch (pstyle->kind()) { | 68 switch (pstyle->kind()) { |
69 case DomProperty::Number: { | 69 case DomProperty::Number: { |
70 QString area = QLatin1String("(cast(qt.core.Qt.ToolBarArea)("); | 70 QString area = QLatin1String("(cast(Qt.ToolBarArea)("); |
71 area += QString::number(pstyle->elementNumber()); | 71 area += QString::number(pstyle->elementNumber()); |
72 area += QLatin1String(")), "); | 72 area += QLatin1String(")), "); |
73 return area; | 73 return area; |
74 } | 74 } |
75 case DomProperty::Enum: { | 75 case DomProperty::Enum: { |
97 // size type | 97 // size type |
98 QString sizeType = properties.contains(QLatin1String("sizeType")) ? | 98 QString sizeType = properties.contains(QLatin1String("sizeType")) ? |
99 properties.value(QLatin1String("sizeType"))->elementEnum() : | 99 properties.value(QLatin1String("sizeType"))->elementEnum() : |
100 QString::fromLatin1("Expanding"); | 100 QString::fromLatin1("Expanding"); |
101 | 101 |
102 if (!sizeType.startsWith(QLatin1String("qt.core.QSizePolicy."))) | 102 if (!sizeType.startsWith(QLatin1String("QSizePolicy."))) |
103 sizeType.prepend(QLatin1String("qt.core.QSizePolicy.")); | 103 sizeType.prepend(QLatin1String("QSizePolicy.")); |
104 // orientation | 104 // orientation |
105 bool isVspacer = false; | 105 bool isVspacer = false; |
106 if (properties.contains(QLatin1String("orientation"))) { | 106 if (properties.contains(QLatin1String("orientation"))) { |
107 const QString orientation = properties.value(QLatin1String("orientation"))->elementEnum(); | 107 const QString orientation = properties.value(QLatin1String("orientation"))->elementEnum(); |
108 if (orientation == QLatin1String("qt.core.Qt.Vertical") || orientation == QLatin1String("Vertical")) isVspacer = true; | 108 if (orientation == QLatin1String("Qt.Vertical") || orientation == QLatin1String("Vertical")) isVspacer = true; |
109 } | 109 } |
110 | 110 |
111 if (isVspacer) | 111 if (isVspacer) |
112 output << "qt.core.QSizePolicy.Minimum, " << sizeType << ')'; | 112 output << "QSizePolicy.Minimum, " << sizeType << ')'; |
113 else | 113 else |
114 output << sizeType << ", qt.core.QSizePolicy.Minimum)"; | 114 output << sizeType << ", QSizePolicy.Minimum)"; |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 // Helper for implementing comparison functions for integers. | 118 // Helper for implementing comparison functions for integers. |
119 int compareInt(int i1, int i2) { | 119 int compareInt(int i1, int i2) { |
670 } | 670 } |
671 | 671 |
672 } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QDockWidget"))) { | 672 } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QDockWidget"))) { |
673 QString area; | 673 QString area; |
674 if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) { | 674 if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) { |
675 area += QLatin1String("(cast(qt.core.Qt.DockWidgetArea)("); | 675 area += QLatin1String("(cast(Qt.DockWidgetArea)("); |
676 area += QString::number(pstyle->elementNumber()); | 676 area += QString::number(pstyle->elementNumber()); |
677 area += QLatin1String(")), "); | 677 area += QLatin1String(")), "); |
678 } | 678 } |
679 | 679 |
680 m_output << m_option.indent << parentWidget << ".addDockWidget(" << area << varName << ");\n"; | 680 m_output << m_option.indent << parentWidget << ".addDockWidget(" << area << varName << ");\n"; |
790 const QString parent = m_driver->findOrInsertWidget(m_widgetChain.top()); | 790 const QString parent = m_driver->findOrInsertWidget(m_widgetChain.top()); |
791 | 791 |
792 isGroupBox = true; | 792 isGroupBox = true; |
793 // special case for group box | 793 // special case for group box |
794 | 794 |
795 m_output << m_option.indent << parent << ".setColumnLayout(0, qt.core.Qt.Vertical);\n"; | 795 m_output << m_option.indent << parent << ".setColumnLayout(0, Qt.Vertical);\n"; |
796 QString objectName = parent; | 796 QString objectName = parent; |
797 objectName += QLatin1String(".layout()"); | 797 objectName += QLatin1String(".layout()"); |
798 int marginType = Use43UiFile; | 798 int marginType = Use43UiFile; |
799 if (oldLayoutProperties) | 799 if (oldLayoutProperties) |
800 marginType = m_layoutMarginType; | 800 marginType = m_layoutMarginType; |
811 | 811 |
812 m_output << ");\n"; | 812 m_output << ");\n"; |
813 | 813 |
814 if (isGroupBox) { | 814 if (isGroupBox) { |
815 const QString tempName = m_driver->unique(QLatin1String("boxlayout")); | 815 const QString tempName = m_driver->unique(QLatin1String("boxlayout")); |
816 m_output << m_option.indent << "QBoxLayout *" << tempName << " = qobject_cast<QBoxLayout *>(" << | 816 m_output << m_option.indent << "QBoxLayout " << tempName << " = qobject_cast<QBoxLayout *>(" << |
817 m_driver->findOrInsertWidget(m_widgetChain.top()) << ".layout());\n"; | 817 m_driver->findOrInsertWidget(m_widgetChain.top()) << ".layout());\n"; |
818 m_output << m_option.indent << "if (" << tempName << ")\n"; | 818 m_output << m_option.indent << "if (" << tempName << ")\n"; |
819 m_output << m_option.indent << " " << tempName << ".addLayout(" << varName << ");\n"; | 819 m_output << m_option.indent << " " << tempName << ".addLayout(" << varName << ");\n"; |
820 } | 820 } |
821 | 821 |
822 if (isGroupBox) { | 822 if (isGroupBox) { |
823 m_output << m_option.indent << varName << ".setAlignment(qt.core.Qt.AlignTop);\n"; | 823 m_output << m_option.indent << varName << ".setAlignment(Qt.AlignTop);\n"; |
824 } else { | 824 } else { |
825 // Suppress margin on a read child layout | 825 // Suppress margin on a read child layout |
826 const bool suppressMarginDefault = m_layoutChain.top(); | 826 const bool suppressMarginDefault = m_layoutChain.top(); |
827 int marginType = Use43UiFile; | 827 int marginType = Use43UiFile; |
828 if (oldLayoutProperties) | 828 if (oldLayoutProperties) |
918 addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan); | 918 addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan); |
919 } else { | 919 } else { |
920 if (layout->attributeClass() == QLatin1String("QFormLayout")) { | 920 if (layout->attributeClass() == QLatin1String("QFormLayout")) { |
921 methodPrefix = QLatin1String("set"); | 921 methodPrefix = QLatin1String("set"); |
922 const int row = node->attributeRow(); | 922 const int row = node->attributeRow(); |
923 const QString role = node->attributeColumn() == 0 ? QLatin1String("qt.gui.QFormLayout.LabelRole") : QLatin1String("qt.gui.QFormLayout.FieldRole"); | 923 const QString role = node->attributeColumn() == 0 ? QLatin1String("QFormLayout.LabelRole") : QLatin1String("QFormLayout.FieldRole"); |
924 addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName); | 924 addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName); |
925 } else { | 925 } else { |
926 addArgs = itemName; | 926 addArgs = itemName; |
927 } | 927 } |
928 } | 928 } |
1023 | 1023 |
1024 if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { | 1024 if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { |
1025 DomPropertyMap properties = propertyMap(lst); | 1025 DomPropertyMap properties = propertyMap(lst); |
1026 if (properties.contains(QLatin1String("control"))) { | 1026 if (properties.contains(QLatin1String("control"))) { |
1027 DomProperty *p = properties.value(QLatin1String("control")); | 1027 DomProperty *p = properties.value(QLatin1String("control")); |
1028 m_output << m_option.indent << varName << ".setControl(qt.core.QString.fromUtf8(" | 1028 m_output << m_option.indent << varName << ".setControl(QString.fromUtf8(" |
1029 << fixString(toString(p->elementString()), m_option.indent) << "));\n"; | 1029 << fixString(toString(p->elementString()), m_option.indent) << "));\n"; |
1030 } | 1030 } |
1031 } | 1031 } |
1032 | 1032 |
1033 DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup")); | 1033 DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup")); |
1035 QString indent; | 1035 QString indent; |
1036 if (!m_widgetChain.top()) { | 1036 if (!m_widgetChain.top()) { |
1037 indent = QLatin1String(" "); | 1037 indent = QLatin1String(" "); |
1038 m_output << m_option.indent << "if (" << varName << ".objectName().isEmpty())\n"; | 1038 m_output << m_option.indent << "if (" << varName << ".objectName().isEmpty())\n"; |
1039 } | 1039 } |
1040 m_output << m_option.indent << indent << varName << ".setObjectName(qt.core.QString.fromUtf8(" << fixString(varName, m_option.indent) << "));\n"; | 1040 m_output << m_option.indent << indent << varName << ".setObjectName(QString.fromUtf8(" << fixString(varName, m_option.indent) << "));\n"; |
1041 | 1041 |
1042 int leftMargin, topMargin, rightMargin, bottomMargin; | 1042 int leftMargin, topMargin, rightMargin, bottomMargin; |
1043 leftMargin = topMargin = rightMargin = bottomMargin = -1; | 1043 leftMargin = topMargin = rightMargin = bottomMargin = -1; |
1044 bool frameShadowEncountered = false; | 1044 bool frameShadowEncountered = false; |
1045 | 1045 |
1090 // Sql support | 1090 // Sql support |
1091 continue; | 1091 continue; |
1092 } else if (propertyName == QLatin1String("orientation") | 1092 } else if (propertyName == QLatin1String("orientation") |
1093 && m_uic->customWidgetsInfo()->extends(className, QLatin1String("Line"))) { | 1093 && m_uic->customWidgetsInfo()->extends(className, QLatin1String("Line"))) { |
1094 // Line support | 1094 // Line support |
1095 QString shape = QLatin1String("qt.gui.QFrame.HLine"); | 1095 QString shape = QLatin1String("QFrame.HLine"); |
1096 if (p->elementEnum() == QLatin1String("qt.core.Qt.Vertical")) | 1096 if (p->elementEnum() == QLatin1String("Qt.Vertical")) |
1097 shape = QLatin1String("qt.gui.QFrame.VLine"); | 1097 shape = QLatin1String("QFrame.VLine"); |
1098 | 1098 |
1099 m_output << m_option.indent << varName << ".setFrameShape(" << shape << ");\n"; | 1099 m_output << m_option.indent << varName << ".setFrameShape(" << shape << ");\n"; |
1100 // QFrame Default is 'Plain'. Make the line 'Sunken' unless otherwise specified | 1100 // QFrame Default is 'Plain'. Make the line 'Sunken' unless otherwise specified |
1101 if (!frameShadowEncountered) | 1101 if (!frameShadowEncountered) |
1102 m_output << m_option.indent << varName << ".setFrameShadow(qt.gui.QFrame.Sunken);\n"; | 1102 m_output << m_option.indent << varName << ".setFrameShadow(QFrame.Sunken);\n"; |
1103 continue; | 1103 continue; |
1104 } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) { | 1104 } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) { |
1105 continue; | 1105 continue; |
1106 } else if ((flags & WritePropertyIgnoreSpacing) && propertyName == QLatin1String("spacing")) { | 1106 } else if ((flags & WritePropertyIgnoreSpacing) && propertyName == QLatin1String("spacing")) { |
1107 continue; | 1107 continue; |
1159 propertyValue += QLatin1Char(')'); | 1159 propertyValue += QLatin1Char(')'); |
1160 } | 1160 } |
1161 } | 1161 } |
1162 break; | 1162 break; |
1163 case DomProperty::Cursor: | 1163 case DomProperty::Cursor: |
1164 propertyValue = QString::fromLatin1("qt.gui.QCursor(cast(qt.core.Qt.CursorShape)(%1))") | 1164 propertyValue = QString::fromLatin1("QCursor(cast(Qt.CursorShape)(%1))") |
1165 .arg(p->elementCursor()); | 1165 .arg(p->elementCursor()); |
1166 break; | 1166 break; |
1167 case DomProperty::CursorShape: | 1167 case DomProperty::CursorShape: |
1168 if (p->hasAttributeStdset() && !p->attributeStdset()) | 1168 if (p->hasAttributeStdset() && !p->attributeStdset()) |
1169 varNewName += QLatin1String(".viewport()"); | 1169 varNewName += QLatin1String(".viewport()"); |
1170 propertyValue = QString::fromLatin1("QCursor(qt.core.Qt.%1)") | 1170 propertyValue = QString::fromLatin1("QCursor(Qt.%1)") |
1171 .arg(p->elementCursorShape()); | 1171 .arg(p->elementCursorShape()); |
1172 break; | 1172 break; |
1173 case DomProperty::Enum: | 1173 case DomProperty::Enum: |
1174 propertyValue = p->elementEnum(); | 1174 propertyValue = p->elementEnum(); |
1175 if (!propertyValue.contains(QLatin1String("."))) { | 1175 if (!propertyValue.contains(QLatin1String("."))) { |
1193 case DomProperty::Palette: { | 1193 case DomProperty::Palette: { |
1194 const DomPalette *pal = p->elementPalette(); | 1194 const DomPalette *pal = p->elementPalette(); |
1195 const QString paletteName = m_driver->unique(QLatin1String("palette")); | 1195 const QString paletteName = m_driver->unique(QLatin1String("palette")); |
1196 m_output << m_option.indent << "QPalette " << paletteName << ";\n"; | 1196 m_output << m_option.indent << "QPalette " << paletteName << ";\n"; |
1197 | 1197 |
1198 writeColorGroup(pal->elementActive(), QLatin1String("qt.gui.QPalette.Active"), paletteName); | 1198 writeColorGroup(pal->elementActive(), QLatin1String("QPalette.Active"), paletteName); |
1199 writeColorGroup(pal->elementInactive(), QLatin1String("qt.gui.QPalette.Inactive"), paletteName); | 1199 writeColorGroup(pal->elementInactive(), QLatin1String("QPalette.Inactive"), paletteName); |
1200 writeColorGroup(pal->elementDisabled(), QLatin1String("qt.gui.QPalette.Disabled"), paletteName); | 1200 writeColorGroup(pal->elementDisabled(), QLatin1String("QPalette.Disabled"), paletteName); |
1201 | 1201 |
1202 propertyValue = paletteName; | 1202 propertyValue = paletteName; |
1203 break; | 1203 break; |
1204 } | 1204 } |
1205 case DomProperty::Point: { | 1205 case DomProperty::Point: { |
1206 const DomPoint *po = p->elementPoint(); | 1206 const DomPoint *po = p->elementPoint(); |
1207 propertyValue = QString::fromLatin1("qt.core.QPoint(%1, %2)") | 1207 propertyValue = QString::fromLatin1("QPoint(%1, %2)") |
1208 .arg(po->elementX()).arg(po->elementY()); | 1208 .arg(po->elementX()).arg(po->elementY()); |
1209 break; | 1209 break; |
1210 } | 1210 } |
1211 case DomProperty::PointF: { | 1211 case DomProperty::PointF: { |
1212 const DomPointF *pof = p->elementPointF(); | 1212 const DomPointF *pof = p->elementPointF(); |
1213 propertyValue = QString::fromLatin1("qt.core.QPointF(%1, %2)") | 1213 propertyValue = QString::fromLatin1("QPointF(%1, %2)") |
1214 .arg(pof->elementX()).arg(pof->elementY()); | 1214 .arg(pof->elementX()).arg(pof->elementY()); |
1215 break; | 1215 break; |
1216 } | 1216 } |
1217 case DomProperty::Rect: { | 1217 case DomProperty::Rect: { |
1218 const DomRect *r = p->elementRect(); | 1218 const DomRect *r = p->elementRect(); |
1219 propertyValue = QString::fromLatin1("qt.core.QRect(%1, %2, %3, %4)") | 1219 propertyValue = QString::fromLatin1("QRect(%1, %2, %3, %4)") |
1220 .arg(r->elementX()).arg(r->elementY()) | 1220 .arg(r->elementX()).arg(r->elementY()) |
1221 .arg(r->elementWidth()).arg(r->elementHeight()); | 1221 .arg(r->elementWidth()).arg(r->elementHeight()); |
1222 break; | 1222 break; |
1223 } | 1223 } |
1224 case DomProperty::RectF: { | 1224 case DomProperty::RectF: { |
1225 const DomRectF *rf = p->elementRectF(); | 1225 const DomRectF *rf = p->elementRectF(); |
1226 propertyValue = QString::fromLatin1("qt.core.QRectF(%1, %2, %3, %4)") | 1226 propertyValue = QString::fromLatin1("QRectF(%1, %2, %3, %4)") |
1227 .arg(rf->elementX()).arg(rf->elementY()) | 1227 .arg(rf->elementX()).arg(rf->elementY()) |
1228 .arg(rf->elementWidth()).arg(rf->elementHeight()); | 1228 .arg(rf->elementWidth()).arg(rf->elementHeight()); |
1229 break; | 1229 break; |
1230 } | 1230 } |
1231 case DomProperty::Locale: { | 1231 case DomProperty::Locale: { |
1232 const DomLocale *locale = p->elementLocale(); | 1232 const DomLocale *locale = p->elementLocale(); |
1233 propertyValue = QString::fromLatin1("qt.core.QLocale(qt.core.QLocale.%1, qt.core.QLocale.%2)") | 1233 propertyValue = QString::fromLatin1("QLocale(QLocale.%1, QLocale.%2)") |
1234 .arg(locale->attributeLanguage()).arg(locale->attributeCountry()); | 1234 .arg(locale->attributeLanguage()).arg(locale->attributeCountry()); |
1235 break; | 1235 break; |
1236 } | 1236 } |
1237 case DomProperty::SizePolicy: { | 1237 case DomProperty::SizePolicy: { |
1238 const QString spName = writeSizePolicy( p->elementSizePolicy()); | 1238 const QString spName = writeSizePolicy( p->elementSizePolicy()); |
1243 propertyValue = spName; | 1243 propertyValue = spName; |
1244 break; | 1244 break; |
1245 } | 1245 } |
1246 case DomProperty::Size: { | 1246 case DomProperty::Size: { |
1247 const DomSize *s = p->elementSize(); | 1247 const DomSize *s = p->elementSize(); |
1248 propertyValue = QString::fromLatin1("qt.core.QSize(%1, %2)") | 1248 propertyValue = QString::fromLatin1("QSize(%1, %2)") |
1249 .arg(s->elementWidth()).arg(s->elementHeight()); | 1249 .arg(s->elementWidth()).arg(s->elementHeight()); |
1250 break; | 1250 break; |
1251 } | 1251 } |
1252 case DomProperty::SizeF: { | 1252 case DomProperty::SizeF: { |
1253 const DomSizeF *sf = p->elementSizeF(); | 1253 const DomSizeF *sf = p->elementSizeF(); |
1254 propertyValue = QString::fromLatin1("qt.core.QSizeF(%1, %2)") | 1254 propertyValue = QString::fromLatin1("QSizeF(%1, %2)") |
1255 .arg(sf->elementWidth()).arg(sf->elementHeight()); | 1255 .arg(sf->elementWidth()).arg(sf->elementHeight()); |
1256 break; | 1256 break; |
1257 } | 1257 } |
1258 case DomProperty::String: { | 1258 case DomProperty::String: { |
1259 if (propertyName == QLatin1String("objectName")) { | 1259 if (propertyName == QLatin1String("objectName")) { |
1297 case DomProperty::Double: | 1297 case DomProperty::Double: |
1298 propertyValue = QString::number(p->elementDouble()); | 1298 propertyValue = QString::number(p->elementDouble()); |
1299 break; | 1299 break; |
1300 case DomProperty::Char: { | 1300 case DomProperty::Char: { |
1301 const DomChar *c = p->elementChar(); | 1301 const DomChar *c = p->elementChar(); |
1302 propertyValue = QString::fromLatin1("qt.core.QChar(%1)") | 1302 propertyValue = QString::fromLatin1("QChar(%1)") |
1303 .arg(c->elementUnicode()); | 1303 .arg(c->elementUnicode()); |
1304 break; | 1304 break; |
1305 } | 1305 } |
1306 case DomProperty::Date: { | 1306 case DomProperty::Date: { |
1307 const DomDate *d = p->elementDate(); | 1307 const DomDate *d = p->elementDate(); |
1308 propertyValue = QString::fromLatin1("qt.core.QDate(%1, %2, %3)") | 1308 propertyValue = QString::fromLatin1("QDate(%1, %2, %3)") |
1309 .arg(d->elementYear()) | 1309 .arg(d->elementYear()) |
1310 .arg(d->elementMonth()) | 1310 .arg(d->elementMonth()) |
1311 .arg(d->elementDay()); | 1311 .arg(d->elementDay()); |
1312 break; | 1312 break; |
1313 } | 1313 } |
1314 case DomProperty::Time: { | 1314 case DomProperty::Time: { |
1315 const DomTime *t = p->elementTime(); | 1315 const DomTime *t = p->elementTime(); |
1316 propertyValue = QString::fromLatin1("qt.core.QTime(%1, %2, %3)") | 1316 propertyValue = QString::fromLatin1("QTime(%1, %2, %3)") |
1317 .arg(t->elementHour()) | 1317 .arg(t->elementHour()) |
1318 .arg(t->elementMinute()) | 1318 .arg(t->elementMinute()) |
1319 .arg(t->elementSecond()); | 1319 .arg(t->elementSecond()); |
1320 break; | 1320 break; |
1321 } | 1321 } |
1322 case DomProperty::DateTime: { | 1322 case DomProperty::DateTime: { |
1323 const DomDateTime *dt = p->elementDateTime(); | 1323 const DomDateTime *dt = p->elementDateTime(); |
1324 propertyValue = QString::fromLatin1("qt.core.QDateTime(qt.core.QDate(%1, %2, %3), qt.core.QTime(%4, %5, %6))") | 1324 propertyValue = QString::fromLatin1("QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))") |
1325 .arg(dt->elementYear()) | 1325 .arg(dt->elementYear()) |
1326 .arg(dt->elementMonth()) | 1326 .arg(dt->elementMonth()) |
1327 .arg(dt->elementDay()) | 1327 .arg(dt->elementDay()) |
1328 .arg(dt->elementHour()) | 1328 .arg(dt->elementHour()) |
1329 .arg(dt->elementMinute()) | 1329 .arg(dt->elementMinute()) |
1330 .arg(dt->elementSecond()); | 1330 .arg(dt->elementSecond()); |
1331 break; | 1331 break; |
1332 } | 1332 } |
1333 case DomProperty::StringList: | 1333 case DomProperty::StringList: |
1334 propertyValue = QLatin1String("qt.core.QStringList()"); | 1334 propertyValue = QLatin1String("QStringList()"); |
1335 if (p->elementStringList()->elementString().size()) { | 1335 if (p->elementStringList()->elementString().size()) { |
1336 const QStringList lst = p->elementStringList()->elementString(); | 1336 const QStringList lst = p->elementStringList()->elementString(); |
1337 for (int i=0; i<lst.size(); ++i) { | 1337 for (int i=0; i<lst.size(); ++i) { |
1338 propertyValue += QLatin1String(" << "); | 1338 propertyValue += QLatin1String(" << "); |
1339 propertyValue +=fixString(lst.at(i), m_option.indent); | 1339 propertyValue +=fixString(lst.at(i), m_option.indent); |
1341 } | 1341 } |
1342 break; | 1342 break; |
1343 | 1343 |
1344 case DomProperty::Url: { | 1344 case DomProperty::Url: { |
1345 const DomUrl* u = p->elementUrl(); | 1345 const DomUrl* u = p->elementUrl(); |
1346 propertyValue = QString::fromLatin1("qt.core.QUrl(%1)") | 1346 propertyValue = QString::fromLatin1("QUrl(%1)") |
1347 .arg(fixString(u->elementString()->text(), m_option.indent)); | 1347 .arg(fixString(u->elementString()->text(), m_option.indent)); |
1348 break; | 1348 break; |
1349 } | 1349 } |
1350 case DomProperty::Brush: | 1350 case DomProperty::Brush: |
1351 propertyValue = writeBrushInitialization(p->elementBrush()); | 1351 propertyValue = writeBrushInitialization(p->elementBrush()); |
1409 | 1409 |
1410 // insert with new name | 1410 // insert with new name |
1411 const QString spName = m_driver->unique(QLatin1String("sizePolicy")); | 1411 const QString spName = m_driver->unique(QLatin1String("sizePolicy")); |
1412 m_sizePolicyNameMap.insert(sizePolicyHandle, spName); | 1412 m_sizePolicyNameMap.insert(sizePolicyHandle, spName); |
1413 | 1413 |
1414 m_output << m_option.indent << "qt.core.QSizePolicy " << spName; | 1414 m_output << m_option.indent << "QSizePolicy " << spName; |
1415 do { | 1415 do { |
1416 if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) { | 1416 if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) { |
1417 m_output << "(cast(qt.core.QSizePolicy.Policy)(" << sp->elementHSizeType() | 1417 m_output << "(cast(QSizePolicy.Policy)(" << sp->elementHSizeType() |
1418 << "), cast(qt.core.QSizePolicy.Policy)(" << sp->elementVSizeType() << "));\n"; | 1418 << "), cast(QSizePolicy.Policy)(" << sp->elementVSizeType() << "));\n"; |
1419 break; | 1419 break; |
1420 } | 1420 } |
1421 if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) { | 1421 if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) { |
1422 m_output << "(qt.core.QSizePolicy." << sp->attributeHSizeType() << ", QSizePolicy." | 1422 m_output << "(QSizePolicy." << sp->attributeHSizeType() << ", QSizePolicy." |
1423 << sp->attributeVSizeType() << ");\n"; | 1423 << sp->attributeVSizeType() << ");\n"; |
1424 break; | 1424 break; |
1425 } | 1425 } |
1426 m_output << ";\n"; | 1426 m_output << ";\n"; |
1427 } while (false); | 1427 } while (false); |
1448 const QString fontName = m_driver->unique(QLatin1String("font")); | 1448 const QString fontName = m_driver->unique(QLatin1String("font")); |
1449 m_fontPropertiesNameMap.insert(FontHandle(f), fontName); | 1449 m_fontPropertiesNameMap.insert(FontHandle(f), fontName); |
1450 | 1450 |
1451 m_output << m_option.indent << "QFont " << fontName << ";\n"; | 1451 m_output << m_option.indent << "QFont " << fontName << ";\n"; |
1452 if (f->hasElementFamily() && !f->elementFamily().isEmpty()) { | 1452 if (f->hasElementFamily() && !f->elementFamily().isEmpty()) { |
1453 m_output << m_option.indent << fontName << ".setFamily(qt.core.QString.fromUtf8(" << fixString(f->elementFamily(), m_option.indent) | 1453 m_output << m_option.indent << fontName << ".setFamily(QString.fromUtf8(" << fixString(f->elementFamily(), m_option.indent) |
1454 << "));\n"; | 1454 << "));\n"; |
1455 } | 1455 } |
1456 if (f->hasElementPointSize() && f->elementPointSize() > 0) { | 1456 if (f->hasElementPointSize() && f->elementPointSize() > 0) { |
1457 m_output << m_option.indent << fontName << ".setPointSize(" << f->elementPointSize() | 1457 m_output << m_option.indent << fontName << ".setPointSize(" << f->elementPointSize() |
1458 << ");\n"; | 1458 << ");\n"; |
1482 m_output << m_option.indent << fontName << ".setKerning(" | 1482 m_output << m_option.indent << fontName << ".setKerning(" |
1483 << (f->elementKerning() ? "true" : "false") << ");\n"; | 1483 << (f->elementKerning() ? "true" : "false") << ");\n"; |
1484 } | 1484 } |
1485 if (f->hasElementAntialiasing()) { | 1485 if (f->hasElementAntialiasing()) { |
1486 m_output << m_option.indent << fontName << ".setStyleStrategy(" | 1486 m_output << m_option.indent << fontName << ".setStyleStrategy(" |
1487 << (f->elementAntialiasing() ? "qt.gui.QFont.PreferDefault" : "qt.gui.QFont.NoAntialias") << ");\n"; | 1487 << (f->elementAntialiasing() ? "QFont.PreferDefault" : "QFont.NoAntialias") << ");\n"; |
1488 } | 1488 } |
1489 if (f->hasElementStyleStrategy()) { | 1489 if (f->hasElementStyleStrategy()) { |
1490 m_output << m_option.indent << fontName << ".setStyleStrategy(qt.core.QFont." | 1490 m_output << m_option.indent << fontName << ".setStyleStrategy(QFont." |
1491 << f->elementStyleStrategy() << ");\n"; | 1491 << f->elementStyleStrategy() << ");\n"; |
1492 } | 1492 } |
1493 return fontName; | 1493 return fontName; |
1494 } | 1494 } |
1495 | 1495 |
1504 | 1504 |
1505 // insert with new name | 1505 // insert with new name |
1506 const QString iconName = m_driver->unique(QLatin1String("icon")); | 1506 const QString iconName = m_driver->unique(QLatin1String("icon")); |
1507 m_iconPropertiesNameMap.insert(IconHandle(i), iconName); | 1507 m_iconPropertiesNameMap.insert(IconHandle(i), iconName); |
1508 if (isIconFormat44(i)) { | 1508 if (isIconFormat44(i)) { |
1509 const QString pixmap = QLatin1String("qt.gui.QPixmap"); | 1509 const QString pixmap = QLatin1String("QPixmap"); |
1510 m_output << m_option.indent << "qt.gui.QIcon " << iconName << ";\n"; | 1510 m_output << m_option.indent << "QIcon " << iconName << ";\n"; |
1511 if (i->hasElementNormalOff()) | 1511 if (i->hasElementNormalOff()) |
1512 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOff()->text()) << ", qt.gui.QIcon.Normal, qt.gui.QIcon.Off);\n"; | 1512 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOff()->text()) << ", QIcon.Normal, QIcon.Off);\n"; |
1513 if (i->hasElementNormalOn()) | 1513 if (i->hasElementNormalOn()) |
1514 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOn()->text()) << ", qt.gui.QIcon.Normal, qt.gui.QIcon.On);\n"; | 1514 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOn()->text()) << ", QIcon.Normal, QIcon.On);\n"; |
1515 if (i->hasElementDisabledOff()) | 1515 if (i->hasElementDisabledOff()) |
1516 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOff()->text()) << ", qt.gui.QIcon.Disabled, qt.gui.QIcon.Off);\n"; | 1516 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOff()->text()) << ", QIcon.Disabled, QIcon.Off);\n"; |
1517 if (i->hasElementDisabledOn()) | 1517 if (i->hasElementDisabledOn()) |
1518 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOn()->text()) << ", qt.gui.QIcon.Disabled, qt.gui.QIcon.On);\n"; | 1518 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOn()->text()) << ", QIcon.Disabled, QIcon.On);\n"; |
1519 if (i->hasElementActiveOff()) | 1519 if (i->hasElementActiveOff()) |
1520 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOff()->text()) << ", qt.gui.QIcon.Active, qt.gui.QIcon.Off);\n"; | 1520 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOff()->text()) << ", QIcon.Active, QIcon.Off);\n"; |
1521 if (i->hasElementActiveOn()) | 1521 if (i->hasElementActiveOn()) |
1522 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOn()->text()) << ", qt.gui.QIcon.Active, qt.gui.QIcon.On);\n"; | 1522 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOn()->text()) << ", QIcon.Active, QIcon.On);\n"; |
1523 if (i->hasElementSelectedOff()) | 1523 if (i->hasElementSelectedOff()) |
1524 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOff()->text()) << ", qt.gui.QIcon.Selected, qt.gui.QIcon.Off);\n"; | 1524 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOff()->text()) << ", QIcon.Selected, QIcon.Off);\n"; |
1525 if (i->hasElementSelectedOn()) | 1525 if (i->hasElementSelectedOn()) |
1526 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOn()->text()) << ", qt.gui.QIcon.Selected, qt.gui.QIcon.On);\n"; | 1526 m_output << m_option.indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOn()->text()) << ", QIcon.Selected, QIcon.On);\n"; |
1527 } else { // pre-4.4 legacy | 1527 } else { // pre-4.4 legacy |
1528 m_output << m_option.indent << "const qt.gui.QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; | 1528 m_output << m_option.indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; |
1529 } | 1529 } |
1530 return iconName; | 1530 return iconName; |
1531 } | 1531 } |
1532 | 1532 |
1533 QString WriteInitialization::domColor2QString(const DomColor *c) | 1533 QString WriteInitialization::domColor2QString(const DomColor *c) |
1534 { | 1534 { |
1535 if (c->hasAttributeAlpha()) | 1535 if (c->hasAttributeAlpha()) |
1536 return QString::fromLatin1("qt.gui.QColor(%1, %2, %3, %4)") | 1536 return QString::fromLatin1("QColor(%1, %2, %3, %4)") |
1537 .arg(c->elementRed()) | 1537 .arg(c->elementRed()) |
1538 .arg(c->elementGreen()) | 1538 .arg(c->elementGreen()) |
1539 .arg(c->elementBlue()) | 1539 .arg(c->elementBlue()) |
1540 .arg(c->attributeAlpha()); | 1540 .arg(c->attributeAlpha()); |
1541 return QString::fromLatin1("qt.gui.QColor(%1, %2, %3)") | 1541 return QString::fromLatin1("QColor(%1, %2, %3)") |
1542 .arg(c->elementRed()) | 1542 .arg(c->elementRed()) |
1543 .arg(c->elementGreen()) | 1543 .arg(c->elementGreen()) |
1544 .arg(c->elementBlue()); | 1544 .arg(c->elementBlue()); |
1545 } | 1545 } |
1546 | 1546 |
1553 const QList<DomColor*> colors = colorGroup->elementColor(); | 1553 const QList<DomColor*> colors = colorGroup->elementColor(); |
1554 for (int i=0; i<colors.size(); ++i) { | 1554 for (int i=0; i<colors.size(); ++i) { |
1555 const DomColor *color = colors.at(i); | 1555 const DomColor *color = colors.at(i); |
1556 | 1556 |
1557 m_output << m_option.indent << paletteName << ".setColor(" << group | 1557 m_output << m_option.indent << paletteName << ".setColor(" << group |
1558 << ", " << "cast(qt.gui.QPalette.ColorRole)(" << QString::number(i) << ')' | 1558 << ", " << "cast(QPalette.ColorRole)(" << QString::number(i) << ')' |
1559 << ", " << domColor2QString(color) | 1559 << ", " << domColor2QString(color) |
1560 << ");\n"; | 1560 << ");\n"; |
1561 } | 1561 } |
1562 | 1562 |
1563 // new format | 1563 // new format |
1566 while (itRole.hasNext()) { | 1566 while (itRole.hasNext()) { |
1567 const DomColorRole *colorRole = itRole.next(); | 1567 const DomColorRole *colorRole = itRole.next(); |
1568 if (colorRole->hasAttributeRole()) { | 1568 if (colorRole->hasAttributeRole()) { |
1569 const QString brushName = writeBrushInitialization(colorRole->elementBrush()); | 1569 const QString brushName = writeBrushInitialization(colorRole->elementBrush()); |
1570 m_output << m_option.indent << paletteName << ".setBrush(" << group | 1570 m_output << m_option.indent << paletteName << ".setBrush(" << group |
1571 << ", " << "qt.gui.QPalette." << colorRole->attributeRole() | 1571 << ", " << "QPalette." << colorRole->attributeRole() |
1572 << ", " << brushName << ");\n"; | 1572 << ", " << brushName << ");\n"; |
1573 } | 1573 } |
1574 } | 1574 } |
1575 } | 1575 } |
1576 | 1576 |
1630 << '(' << gradient->attributeCentralX() | 1630 << '(' << gradient->attributeCentralX() |
1631 << ", " << gradient->attributeCentralY() | 1631 << ", " << gradient->attributeCentralY() |
1632 << ", " << gradient->attributeAngle() << ");\n"; | 1632 << ", " << gradient->attributeAngle() << ");\n"; |
1633 } | 1633 } |
1634 | 1634 |
1635 m_output << m_option.indent << gradientName << ".setSpread(qt.gui.QGradient." | 1635 m_output << m_option.indent << gradientName << ".setSpread(QGradient." |
1636 << gradient->attributeSpread() << ");\n"; | 1636 << gradient->attributeSpread() << ");\n"; |
1637 | 1637 |
1638 if (gradient->hasAttributeCoordinateMode()) { | 1638 if (gradient->hasAttributeCoordinateMode()) { |
1639 m_output << m_option.indent << gradientName << ".setCoordinateMode(qt.gui.QGradient." | 1639 m_output << m_option.indent << gradientName << ".setCoordinateMode(QGradient." |
1640 << gradient->attributeCoordinateMode() << ");\n"; | 1640 << gradient->attributeCoordinateMode() << ");\n"; |
1641 } | 1641 } |
1642 | 1642 |
1643 const QList<DomGradientStop *> stops = gradient->elementGradientStop(); | 1643 const QList<DomGradientStop *> stops = gradient->elementGradientStop(); |
1644 QListIterator<DomGradientStop *> it(stops); | 1644 QListIterator<DomGradientStop *> it(stops); |
1661 const DomColor *color = brush->elementColor(); | 1661 const DomColor *color = brush->elementColor(); |
1662 m_output << m_option.indent << "QBrush " << brushName << '(' | 1662 m_output << m_option.indent << "QBrush " << brushName << '(' |
1663 << domColor2QString(color) << ");\n"; | 1663 << domColor2QString(color) << ");\n"; |
1664 | 1664 |
1665 m_output << m_option.indent << brushName << ".setStyle(" | 1665 m_output << m_option.indent << brushName << ".setStyle(" |
1666 << "qt.core.Qt." << style << ");\n"; | 1666 << "Qt." << style << ");\n"; |
1667 } | 1667 } |
1668 } | 1668 } |
1669 | 1669 |
1670 void WriteInitialization::acceptCustomWidget(DomCustomWidget *node) | 1670 void WriteInitialization::acceptCustomWidget(DomCustomWidget *node) |
1671 { | 1671 { |
1695 continue; | 1695 continue; |
1696 } else if (name.isEmpty() || lastName.isEmpty()) { | 1696 } else if (name.isEmpty() || lastName.isEmpty()) { |
1697 continue; | 1697 continue; |
1698 } | 1698 } |
1699 | 1699 |
1700 m_output << m_option.indent << "qt.gui.QWidget.setTabOrder(" << lastName << ", " << name << ");\n"; | 1700 m_output << m_option.indent << "QWidget.setTabOrder(" << lastName << ", " << name << ");\n"; |
1701 | 1701 |
1702 lastName = name; | 1702 lastName = name; |
1703 } | 1703 } |
1704 } | 1704 } |
1705 | 1705 |
1788 const DomProperty *clickable = properties.value(QLatin1String("clickable")); | 1788 const DomProperty *clickable = properties.value(QLatin1String("clickable")); |
1789 const DomProperty *resizable = properties.value(QLatin1String("resizable")); | 1789 const DomProperty *resizable = properties.value(QLatin1String("resizable")); |
1790 | 1790 |
1791 const QString txt = trCall(text->elementString()); | 1791 const QString txt = trCall(text->elementString()); |
1792 m_output << m_option.indent << varName << ".addColumn(" << txt << ");\n"; | 1792 m_output << m_option.indent << varName << ".addColumn(" << txt << ");\n"; |
1793 m_refreshOut << m_option.indent << varName << ".header()->setLabel(" << i << ", " << txt << ");\n"; | 1793 m_refreshOut << m_option.indent << varName << ".header().setLabel(" << i << ", " << txt << ");\n"; |
1794 | 1794 |
1795 if (pixmap) { | 1795 if (pixmap) { |
1796 m_output << m_option.indent << varName << ".header()->setLabel(" | 1796 m_output << m_option.indent << varName << ".header().>setLabel(" |
1797 << varName << ".header()->count() - 1, " << pixCall(pixmap) << ", " << txt << ");\n"; | 1797 << varName << ".header()->count() - 1, " << pixCall(pixmap) << ", " << txt << ");\n"; |
1798 } | 1798 } |
1799 | 1799 |
1800 if (clickable != 0) { | 1800 if (clickable != 0) { |
1801 m_output << m_option.indent << varName << ".header()->setClickEnabled(" << clickable->elementBool() << ", " << varName << ".header()->count() - 1);\n"; | 1801 m_output << m_option.indent << varName << ".header().setClickEnabled(" << clickable->elementBool() << ", " << varName << ".header()->count() - 1);\n"; |
1802 } | 1802 } |
1803 | 1803 |
1804 if (resizable != 0) { | 1804 if (resizable != 0) { |
1805 m_output << m_option.indent << varName << ".header()->setResizeEnabled(" << resizable->elementBool() << ", " << varName << ".header()->count() - 1);\n"; | 1805 m_output << m_option.indent << varName << ".header().setResizeEnabled(" << resizable->elementBool() << ", " << varName << ".header()->count() - 1);\n"; |
1806 } | 1806 } |
1807 } | 1807 } |
1808 | 1808 |
1809 if (w->elementItem().size()) { | 1809 if (w->elementItem().size()) { |
1810 m_refreshOut << m_option.indent << varName << ".clear();\n"; | 1810 m_refreshOut << m_option.indent << varName << ".clear();\n"; |
1860 | 1860 |
1861 const DomPropertyMap properties = propertyMap(column->elementProperty()); | 1861 const DomPropertyMap properties = propertyMap(column->elementProperty()); |
1862 const DomProperty *text = properties.value(QLatin1String("text")); | 1862 const DomProperty *text = properties.value(QLatin1String("text")); |
1863 const DomProperty *pixmap = properties.value(QLatin1String("pixmap")); | 1863 const DomProperty *pixmap = properties.value(QLatin1String("pixmap")); |
1864 | 1864 |
1865 m_refreshOut << m_option.indent << varName << ".horizontalHeader()->setLabel(" << i << ", "; | 1865 m_refreshOut << m_option.indent << varName << ".horizontalHeader().setLabel(" << i << ", "; |
1866 if (pixmap) { | 1866 if (pixmap) { |
1867 m_refreshOut << pixCall(pixmap) << ", "; | 1867 m_refreshOut << pixCall(pixmap) << ", "; |
1868 } | 1868 } |
1869 m_refreshOut << trCall(text->elementString()) << ");\n"; | 1869 m_refreshOut << trCall(text->elementString()) << ");\n"; |
1870 } | 1870 } |
1876 | 1876 |
1877 const DomPropertyMap properties = propertyMap(row->elementProperty()); | 1877 const DomPropertyMap properties = propertyMap(row->elementProperty()); |
1878 const DomProperty *text = properties.value(QLatin1String("text")); | 1878 const DomProperty *text = properties.value(QLatin1String("text")); |
1879 const DomProperty *pixmap = properties.value(QLatin1String("pixmap")); | 1879 const DomProperty *pixmap = properties.value(QLatin1String("pixmap")); |
1880 | 1880 |
1881 m_refreshOut << m_option.indent << varName << ".verticalHeader()->setLabel(" << i << ", "; | 1881 m_refreshOut << m_option.indent << varName << ".verticalHeader().setLabel(" << i << ", "; |
1882 if (pixmap) { | 1882 if (pixmap) { |
1883 m_refreshOut << pixCall(pixmap) << ", "; | 1883 m_refreshOut << pixCall(pixmap) << ", "; |
1884 } | 1884 } |
1885 m_refreshOut << trCall(text->elementString()) << ");\n"; | 1885 m_refreshOut << trCall(text->elementString()) << ");\n"; |
1886 } | 1886 } |
1932 } | 1932 } |
1933 if (const DomImage *image = findImage(text)) { | 1933 if (const DomImage *image = findImage(text)) { |
1934 if (m_option.extractImages) { | 1934 if (m_option.extractImages) { |
1935 const QString format = image->elementData()->attributeFormat(); | 1935 const QString format = image->elementData()->attributeFormat(); |
1936 const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower(); | 1936 const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower(); |
1937 QString rc = QLatin1String("qt.gui.QPixmap(qt.core.QString.fromUtf8(\":/"); | 1937 QString rc = QLatin1String("QPixmap(QString.fromUtf8(\":/"); |
1938 rc += m_generatedClass; | 1938 rc += m_generatedClass; |
1939 rc += QLatin1String("/images/"); | 1939 rc += QLatin1String("/images/"); |
1940 rc += text; | 1940 rc += text; |
1941 rc += QLatin1Char('.'); | 1941 rc += QLatin1Char('.'); |
1942 rc += extension; | 1942 rc += extension; |
1950 return rc; | 1950 return rc; |
1951 } | 1951 } |
1952 | 1952 |
1953 QString pixFunc = m_uic->pixmapFunction(); | 1953 QString pixFunc = m_uic->pixmapFunction(); |
1954 if (pixFunc.isEmpty()) | 1954 if (pixFunc.isEmpty()) |
1955 pixFunc = QLatin1String("qt.core.QString.fromUtf8"); | 1955 pixFunc = QLatin1String("QString.fromUtf8"); |
1956 | 1956 |
1957 type += QLatin1Char('('); | 1957 type += QLatin1Char('('); |
1958 type += pixFunc; | 1958 type += pixFunc; |
1959 type += QLatin1Char('('); | 1959 type += QLatin1Char('('); |
1960 type += fixString(text, m_option.indent); | 1960 type += fixString(text, m_option.indent); |
2059 | 2059 |
2060 QString itemCreation = QLatin1String("new QListWidgetItem(") + varName + QLatin1String(");\n"); | 2060 QString itemCreation = QLatin1String("new QListWidgetItem(") + varName + QLatin1String(");\n"); |
2061 if (icon) { | 2061 if (icon) { |
2062 const QString iconValue = iconCall(icon); | 2062 const QString iconValue = iconCall(icon); |
2063 const QString itemName = m_driver->unique(QLatin1String("__listItem")); | 2063 const QString itemName = m_driver->unique(QLatin1String("__listItem")); |
2064 m_output << m_option.indent << "QListWidgetItem *" << itemName << " = " << itemCreation; | 2064 m_output << m_option.indent << "QListWidgetItem " << itemName << " = " << itemCreation; |
2065 m_output << m_option.indent << itemName << ".setIcon(" << iconValue << ");\n"; | 2065 m_output << m_option.indent << itemName << ".setIcon(" << iconValue << ");\n"; |
2066 } else { | 2066 } else { |
2067 m_output << m_option.indent << itemCreation; | 2067 m_output << m_option.indent << itemCreation; |
2068 } | 2068 } |
2069 | 2069 |
2070 if (!toString(text->elementString()).isEmpty()) { | 2070 if (!toString(text->elementString()).isEmpty()) { |
2071 m_refreshOut << m_option.indent << varName << ".item(" << i << ")->setText(" << trCall(text->elementString()) << ");\n"; | 2071 m_refreshOut << m_option.indent << varName << ".item(" << i << ").setText(" << trCall(text->elementString()) << ");\n"; |
2072 } | 2072 } |
2073 } | 2073 } |
2074 enableSorting(w, varName, tempName); | 2074 enableSorting(w, varName, tempName); |
2075 } | 2075 } |
2076 | 2076 |
2088 const DomProperty *text = properties.value(QLatin1String("text")); | 2088 const DomProperty *text = properties.value(QLatin1String("text")); |
2089 const DomProperty *icon = properties.value(QLatin1String("icon")); | 2089 const DomProperty *icon = properties.value(QLatin1String("icon")); |
2090 | 2090 |
2091 if (!toString(text->elementString()).isEmpty()) { | 2091 if (!toString(text->elementString()).isEmpty()) { |
2092 const QString txt = trCall(text->elementString()); | 2092 const QString txt = trCall(text->elementString()); |
2093 m_refreshOut << m_option.indent << varName << ".headerItem()->setText(" << i << ", " << txt << ");\n"; | 2093 m_refreshOut << m_option.indent << varName << ".headerItem().setText(" << i << ", " << txt << ");\n"; |
2094 } | 2094 } |
2095 | 2095 |
2096 if (icon) { | 2096 if (icon) { |
2097 const QString iconValue = iconCall(icon); | 2097 const QString iconValue = iconCall(icon); |
2098 m_output << m_option.indent << varName << ".headerItem()->setIcon(" | 2098 m_output << m_option.indent << varName << ".headerItem().setIcon(" |
2099 << i << ", " << iconValue << ");\n"; | 2099 << i << ", " << iconValue << ");\n"; |
2100 } | 2100 } |
2101 } | 2101 } |
2102 | 2102 |
2103 if (w->elementItem().size()) { | 2103 if (w->elementItem().size()) { |
2123 QStringList icons; | 2123 QStringList icons; |
2124 for (int j = 0; j < properties.size(); ++j) { | 2124 for (int j = 0; j < properties.size(); ++j) { |
2125 const DomProperty *p = properties.at(j); | 2125 const DomProperty *p = properties.at(j); |
2126 if (p->attributeName() == QLatin1String("text")) { | 2126 if (p->attributeName() == QLatin1String("text")) { |
2127 if (!toString(p->elementString()).isEmpty()) { | 2127 if (!toString(p->elementString()).isEmpty()) { |
2128 m_refreshOut << m_option.indent << parentPath << i << ")->setText(" << textCount << ", " | 2128 m_refreshOut << m_option.indent << parentPath << i << ").setText(" << textCount << ", " |
2129 << trCall(p->elementString()) << ");\n"; | 2129 << trCall(p->elementString()) << ");\n"; |
2130 } | 2130 } |
2131 textCount++; | 2131 textCount++; |
2132 } | 2132 } |
2133 | 2133 |
2140 } | 2140 } |
2141 if (icons.isEmpty() && (item->elementItem().size() == 0)) { | 2141 if (icons.isEmpty() && (item->elementItem().size() == 0)) { |
2142 m_output << m_option.indent << "new QTreeWidgetItem(" << varName << ");\n"; | 2142 m_output << m_option.indent << "new QTreeWidgetItem(" << varName << ");\n"; |
2143 } else { | 2143 } else { |
2144 const QString itemName = m_driver->unique(QLatin1String("__treeItem")); | 2144 const QString itemName = m_driver->unique(QLatin1String("__treeItem")); |
2145 m_output << m_option.indent << "QTreeWidgetItem *" << itemName << " = new QTreeWidgetItem(" << varName << ");\n"; | 2145 m_output << m_option.indent << "QTreeWidgetItem " << itemName << " = new QTreeWidgetItem(" << varName << ");\n"; |
2146 | 2146 |
2147 QStringListIterator it(icons); | 2147 QStringListIterator it(icons); |
2148 while (it.hasNext()) | 2148 while (it.hasNext()) |
2149 m_output << m_option.indent << itemName << it.next(); | 2149 m_output << m_option.indent << itemName << it.next(); |
2150 | 2150 |
2210 const DomPropertyMap properties = propertyMap(row->elementProperty()); | 2210 const DomPropertyMap properties = propertyMap(row->elementProperty()); |
2211 const DomProperty *text = properties.value(QLatin1String("text")); | 2211 const DomProperty *text = properties.value(QLatin1String("text")); |
2212 const DomProperty *icon = properties.value(QLatin1String("icon")); | 2212 const DomProperty *icon = properties.value(QLatin1String("icon")); |
2213 if (text || icon) { | 2213 if (text || icon) { |
2214 const QString itemName = m_driver->unique(QLatin1String("__rowItem")); | 2214 const QString itemName = m_driver->unique(QLatin1String("__rowItem")); |
2215 m_output << m_option.indent << "QTableWidgetItem *" | 2215 m_output << m_option.indent << "QTableWidgetItem " |
2216 << itemName << " = new QTableWidgetItem();\n"; | 2216 << itemName << " = new QTableWidgetItem();\n"; |
2217 | 2217 |
2218 if (text && text->attributeName() == QLatin1String("text") && !toString(text->elementString()).isEmpty()) | 2218 if (text && text->attributeName() == QLatin1String("text") && !toString(text->elementString()).isEmpty()) |
2219 m_refreshOut << m_option.indent << varName << ".verticalHeaderItem(" << i << ")->setText(" | 2219 m_refreshOut << m_option.indent << varName << ".verticalHeaderItem(" << i << ").setText(" |
2220 << trCall(text->elementString()) << ");\n"; | 2220 << trCall(text->elementString()) << ");\n"; |
2221 | 2221 |
2222 if (icon && icon->attributeName() == QLatin1String("icon")) { | 2222 if (icon && icon->attributeName() == QLatin1String("icon")) { |
2223 const QString iconValue = iconCall(icon); | 2223 const QString iconValue = iconCall(icon); |
2224 m_output << m_option.indent << itemName << ".setIcon(" | 2224 m_output << m_option.indent << itemName << ".setIcon(" |
2239 const DomPropertyMap properties = propertyMap(item->elementProperty()); | 2239 const DomPropertyMap properties = propertyMap(item->elementProperty()); |
2240 const DomProperty *text = properties.value(QLatin1String("text")); | 2240 const DomProperty *text = properties.value(QLatin1String("text")); |
2241 const DomProperty *icon = properties.value(QLatin1String("icon")); | 2241 const DomProperty *icon = properties.value(QLatin1String("icon")); |
2242 if (text || icon) { | 2242 if (text || icon) { |
2243 const QString itemName = m_driver->unique(QLatin1String("__tableItem")); | 2243 const QString itemName = m_driver->unique(QLatin1String("__tableItem")); |
2244 m_output << m_option.indent << "QTableWidgetItem *" | 2244 m_output << m_option.indent << "QTableWidgetItem " |
2245 << itemName << " = new QTableWidgetItem();\n"; | 2245 << itemName << " = new QTableWidgetItem();\n"; |
2246 | 2246 |
2247 if (text && text->attributeName() == QLatin1String("text") && !toString(text->elementString()).isEmpty()) | 2247 if (text && text->attributeName() == QLatin1String("text") && !toString(text->elementString()).isEmpty()) |
2248 m_refreshOut << m_option.indent << varName << ".item(" << item->attributeRow() | 2248 m_refreshOut << m_option.indent << varName << ".item(" << item->attributeRow() |
2249 << ", " << item->attributeColumn() << ")->setText(" | 2249 << ", " << item->attributeColumn() << ").setText(" |
2250 << trCall(text->elementString()) << ");\n"; | 2250 << trCall(text->elementString()) << ");\n"; |
2251 | 2251 |
2252 if (icon && icon->attributeName() == QLatin1String("icon")) { | 2252 if (icon && icon->attributeName() == QLatin1String("icon")) { |
2253 const QString iconValue = iconCall(icon); | 2253 const QString iconValue = iconCall(icon); |
2254 m_output << m_option.indent << itemName << ".setIcon(" | 2254 m_output << m_option.indent << itemName << ".setIcon(" |
2272 | 2272 |
2273 QString result; | 2273 QString result; |
2274 const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_option.indent); | 2274 const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_option.indent); |
2275 | 2275 |
2276 if (m_option.translateFunction.isEmpty()) { | 2276 if (m_option.translateFunction.isEmpty()) { |
2277 result = QLatin1String("qt.gui.QApplication.translate(\""); | 2277 result = QLatin1String("QApplication.translate(\""); |
2278 result += m_generatedClass; | 2278 result += m_generatedClass; |
2279 result += QLatin1Char('"'); | 2279 result += QLatin1Char('"'); |
2280 result += QLatin1String(", "); | 2280 result += QLatin1String(", "); |
2281 } else { | 2281 } else { |
2282 result = m_option.translateFunction; | 2282 result = m_option.translateFunction; |
2287 result += QLatin1String(", "); | 2287 result += QLatin1String(", "); |
2288 result += comment; | 2288 result += comment; |
2289 | 2289 |
2290 if (m_option.translateFunction.isEmpty()) { | 2290 if (m_option.translateFunction.isEmpty()) { |
2291 result += QLatin1String(", "); | 2291 result += QLatin1String(", "); |
2292 result += QLatin1String("qt.gui.QApplication.UnicodeUTF8"); | 2292 result += QLatin1String("QApplication.UnicodeUTF8"); |
2293 } | 2293 } |
2294 | 2294 |
2295 result += QLatin1Char(')'); | 2295 result += QLatin1Char(')'); |
2296 return result; | 2296 return result; |
2297 } | 2297 } |
2484 foreach (DomWidget *child, childWidgets) { | 2484 foreach (DomWidget *child, childWidgets) { |
2485 m_output << " << " << m_driver->findOrInsertWidget(child); | 2485 m_output << " << " << m_driver->findOrInsertWidget(child); |
2486 } | 2486 } |
2487 m_output << ";\n"; | 2487 m_output << ";\n"; |
2488 } | 2488 } |
2489 m_output << m_option.indent << "scriptContext.run(qt.core.QString.fromUtf8(" | 2489 m_output << m_option.indent << "scriptContext.run(QString.fromUtf8(" |
2490 << fixString(script, m_option.indent) << "), " | 2490 << fixString(script, m_option.indent) << "), " |
2491 << m_driver->findOrInsertWidget(node) << ", childWidgets);\n"; | 2491 << m_driver->findOrInsertWidget(node) << ", childWidgets);\n"; |
2492 } | 2492 } |
2493 | 2493 |
2494 } // namespace D | 2494 } // namespace D |