MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setWorkspaceWidgets

Method setWorkspaceWidgets

app/src/UI/Taskbar.cpp:1795–1844  ·  view source on GitHub ↗

* @brief Replaces the widget list of a user workspace with the given IDs. */

Source from the content-addressed store, hash-verified

1793 * @brief Replaces the widget list of a user workspace with the given IDs.
1794 */
1795void UI::Taskbar::setWorkspaceWidgets(int workspaceId, const QVariantList& windowIds)
1796{
1797 if (workspaceId < WorkspaceIds::AutoStart)
1798 return;
1799
1800 auto* pm = &DataModel::ProjectModel::instance();
1801
1802 const auto& workspaces = pm->activeWorkspaces();
1803 bool found = false;
1804 for (const auto& ws : workspaces) {
1805 if (ws.workspaceId != workspaceId)
1806 continue;
1807
1808 found = true;
1809 for (int i = static_cast<int>(ws.widgetRefs.size()) - 1; i >= 0; --i)
1810 pm->removeWidgetFromWorkspace(workspaceId, i);
1811
1812 break;
1813 }
1814
1815 if (!found)
1816 return;
1817
1818 const auto& widgetMap = UI::Dashboard::instance().widgetMap();
1819 for (const auto& idVar : windowIds) {
1820 const int windowId = idVar.toInt();
1821 auto* item = findItemByWindowId(windowId);
1822 if (!item)
1823 continue;
1824
1825 const auto widgetType = item->data(TaskbarModel::WidgetTypeRole).toInt();
1826 const auto groupId = item->data(TaskbarModel::GroupIdRole).toInt();
1827
1828 int relIdx = -1;
1829 for (auto it = widgetMap.begin(); it != widgetMap.end(); ++it) {
1830 if (it.key() == windowId) {
1831 relIdx = it.value().second;
1832 break;
1833 }
1834 }
1835
1836 if (relIdx >= 0) {
1837 const int groupUid = UI::Dashboard::instance().groupUniqueIdForGroupId(groupId);
1838 pm->addWidgetToWorkspace(workspaceId, widgetType, groupUid, relIdx);
1839 }
1840 }
1841
1842 if (m_activeGroupId == workspaceId)
1843 setActiveGroupId(workspaceId);
1844}

Callers

nothing calls this directly

Calls 8

beginMethod · 0.80
keyMethod · 0.80
addWidgetToWorkspaceMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected