* @brief Selects and configures the appropriate widget for the given @a index. */
| 223 | * @brief Selects and configures the appropriate widget for the given @a index. |
| 224 | */ |
| 225 | void UI::DashboardWidget::setWidgetIndex(const int index) |
| 226 | { |
| 227 | if (index < 0 || index >= UI::Dashboard::instance().totalWidgetCount()) |
| 228 | return; |
| 229 | |
| 230 | m_index = index; |
| 231 | m_widgetType = UI::Dashboard::instance().widgetType(index); |
| 232 | m_relativeIndex = UI::Dashboard::instance().relativeIndex(index); |
| 233 | |
| 234 | if (m_dbWidget) { |
| 235 | m_dbWidget->deleteLater(); |
| 236 | m_dbWidget = nullptr; |
| 237 | } |
| 238 | |
| 239 | buildWidgetForType(); |
| 240 | |
| 241 | if (m_dbWidget) |
| 242 | m_dbWidget->setParentItem(this); |
| 243 | |
| 244 | Q_EMIT widgetIndexChanged(); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * @brief Constructs the QQuickItem and selects the QML path for the current widget type. |
nothing calls this directly
no test coverage detected