| 1214 | } |
| 1215 | |
| 1216 | static tl::Variant |
| 1217 | probe_widget (QTreeView *tv) |
| 1218 | { |
| 1219 | tl::Variant list = tl::Variant::empty_list (); |
| 1220 | |
| 1221 | QAbstractItemModel *model = tv->model (); |
| 1222 | |
| 1223 | int rows = model->rowCount (); |
| 1224 | int columns = model->columnCount (); |
| 1225 | |
| 1226 | if (rows > 0 && columns > 0) { |
| 1227 | |
| 1228 | QModelIndex col0 (model->index (0, 0)); |
| 1229 | while (col0.isValid ()) { |
| 1230 | |
| 1231 | int lvl = 0; |
| 1232 | for (QModelIndex pindex = col0; pindex.isValid (); ++lvl) { |
| 1233 | pindex = model->parent (pindex); |
| 1234 | } |
| 1235 | |
| 1236 | tl::Variant el = tl::Variant::empty_list (); |
| 1237 | el.push (tl::Variant (long (lvl))); |
| 1238 | el.push (tl::Variant ((tv->selectionModel ()->isSelected (col0)) ? "Selected" : "Not selected")); |
| 1239 | |
| 1240 | for (int c = 0; c < columns; ++c) { |
| 1241 | |
| 1242 | QModelIndex coln (col0.sibling (col0.row (), c)); |
| 1243 | QVariant font = model->data (coln, Qt::FontRole); |
| 1244 | QVariant deco = model->data (coln, Qt::DecorationRole); |
| 1245 | QVariant display = model->data (coln, Qt::DisplayRole); |
| 1246 | |
| 1247 | if (! deco.value<QIcon> ().isNull ()) { |
| 1248 | |
| 1249 | QImage img = deco.value<QIcon> ().pixmap (tv->iconSize ()).toImage (); |
| 1250 | el.push (image_to_variant (img)); |
| 1251 | |
| 1252 | } else { |
| 1253 | |
| 1254 | std::string t = tl::to_string (display.toString ()); |
| 1255 | t += " ("; |
| 1256 | QFont f (font.value<QFont> ()); |
| 1257 | bool first = true; |
| 1258 | if (f.bold ()) { |
| 1259 | t += "Bold"; |
| 1260 | first = false; |
| 1261 | } |
| 1262 | if (f.strikeOut ()) { |
| 1263 | if (! first) { |
| 1264 | t += ","; |
| 1265 | } |
| 1266 | t += "StrikeOut"; |
| 1267 | first = false; |
| 1268 | } |
| 1269 | if (f.italic ()) { |
| 1270 | if (! first) { |
| 1271 | t += ","; |
| 1272 | } |
| 1273 | t += "Italic"; |
no test coverage detected