* @brief Returns a flat list of widgets matching the current search filter. */
| 1289 | * @brief Returns a flat list of widgets matching the current search filter. |
| 1290 | */ |
| 1291 | QVariantList UI::Taskbar::searchResults() const |
| 1292 | { |
| 1293 | QVariantList results; |
| 1294 | const auto filter = m_searchFilter.trimmed(); |
| 1295 | const bool noFilter = filter.isEmpty(); |
| 1296 | |
| 1297 | for (int i = 0; i < m_fullModel->rowCount() && results.size() < 30; ++i) { |
| 1298 | auto* groupItem = m_fullModel->item(i); |
| 1299 | if (!groupItem) |
| 1300 | continue; |
| 1301 | |
| 1302 | const auto groupName = groupItem->data(TaskbarModel::GroupNameRole).toString(); |
| 1303 | |
| 1304 | const auto groupWidgetName = groupItem->data(TaskbarModel::WidgetNameRole).toString(); |
| 1305 | const auto groupType = groupItem->data(TaskbarModel::WidgetTypeRole).toInt(); |
| 1306 | if (groupType != SerialStudio::DashboardNoWidget |
| 1307 | && (noFilter || groupWidgetName.contains(filter, Qt::CaseInsensitive) |
| 1308 | || groupName.contains(filter, Qt::CaseInsensitive))) { |
| 1309 | QVariantMap entry; |
| 1310 | entry[QStringLiteral("windowId")] = groupItem->data(TaskbarModel::WindowIdRole); |
| 1311 | entry[QStringLiteral("widgetName")] = groupWidgetName; |
| 1312 | entry[QStringLiteral("widgetIcon")] = groupItem->data(TaskbarModel::WidgetIconRole); |
| 1313 | entry[QStringLiteral("widgetType")] = groupType; |
| 1314 | entry[QStringLiteral("groupName")] = groupName; |
| 1315 | entry[QStringLiteral("groupId")] = groupItem->data(TaskbarModel::GroupIdRole); |
| 1316 | entry[QStringLiteral("isWorkspace")] = false; |
| 1317 | results.append(entry); |
| 1318 | } |
| 1319 | |
| 1320 | for (int j = 0; j < groupItem->rowCount() && results.size() < 30; ++j) { |
| 1321 | auto* child = groupItem->child(j); |
| 1322 | if (!child) |
| 1323 | continue; |
| 1324 | |
| 1325 | const auto childType = child->data(TaskbarModel::WidgetTypeRole).toInt(); |
| 1326 | if (childType == SerialStudio::DashboardNoWidget) |
| 1327 | continue; |
| 1328 | |
| 1329 | const auto name = child->data(TaskbarModel::WidgetNameRole).toString(); |
| 1330 | if (noFilter || name.contains(filter, Qt::CaseInsensitive) |
| 1331 | || groupName.contains(filter, Qt::CaseInsensitive)) { |
| 1332 | QVariantMap entry; |
| 1333 | entry[QStringLiteral("windowId")] = child->data(TaskbarModel::WindowIdRole); |
| 1334 | entry[QStringLiteral("widgetName")] = name; |
| 1335 | entry[QStringLiteral("widgetIcon")] = child->data(TaskbarModel::WidgetIconRole); |
| 1336 | entry[QStringLiteral("widgetType")] = child->data(TaskbarModel::WidgetTypeRole); |
| 1337 | entry[QStringLiteral("groupName")] = groupName; |
| 1338 | entry[QStringLiteral("groupId")] = child->data(TaskbarModel::GroupIdRole); |
| 1339 | entry[QStringLiteral("isWorkspace")] = false; |
| 1340 | results.append(entry); |
| 1341 | } |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | return results; |
| 1346 | } |
| 1347 | |
| 1348 | /** |