117 case 14: return Qt::DiagCrossPattern; |
117 case 14: return Qt::DiagCrossPattern; |
118 } |
118 } |
119 return Qt::NoBrush; |
119 return Qt::NoBrush; |
120 } |
120 } |
121 |
121 |
|
122 |
|
123 typedef QMap<int, QIcon> EnumIndexIconMap; |
|
124 |
|
125 static void clearBrushIcons(); |
|
126 Q_GLOBAL_STATIC_WITH_INITIALIZER(EnumIndexIconMap, brushIcons, qAddPostRoutine(clearBrushIcons)) |
|
127 |
|
128 static void clearBrushIcons() |
|
129 { |
|
130 brushIcons()->clear(); |
|
131 } |
|
132 |
122 const BrushPropertyManager::EnumIndexIconMap &BrushPropertyManager::brushStyleIcons() |
133 const BrushPropertyManager::EnumIndexIconMap &BrushPropertyManager::brushStyleIcons() |
123 { |
134 { |
124 // Create a map of icons for the brush style editor |
135 // Create a map of icons for the brush style editor |
125 static EnumIndexIconMap rc; |
136 if (brushIcons()->empty()) { |
126 if (rc.empty()) { |
|
127 const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); |
137 const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); |
128 QBrush brush(Qt::black); |
138 QBrush brush(Qt::black); |
129 const QIcon solidIcon = QtPropertyBrowserUtils::brushValueIcon(brush); |
139 const QIcon solidIcon = QtPropertyBrowserUtils::brushValueIcon(brush); |
130 for (int i = 0; i < brushStyleCount; i++) { |
140 for (int i = 0; i < brushStyleCount; i++) { |
131 const Qt::BrushStyle style = brushStyleIndexToStyle(i); |
141 const Qt::BrushStyle style = brushStyleIndexToStyle(i); |
132 brush.setStyle(style); |
142 brush.setStyle(style); |
133 rc.insert(i, QtPropertyBrowserUtils::brushValueIcon(brush)); |
143 brushIcons()->insert(i, QtPropertyBrowserUtils::brushValueIcon(brush)); |
134 } |
144 } |
135 } |
145 } |
136 return rc; |
146 return *(brushIcons()); |
137 } |
147 } |
138 |
148 |
139 QString BrushPropertyManager::brushStyleIndexToString(int brushStyleIndex) |
149 QString BrushPropertyManager::brushStyleIndexToString(int brushStyleIndex) |
140 { |
150 { |
141 const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); |
151 const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); |