| 216 | } |
| 217 | |
| 218 | QWidget *ClientToolManager::widgetForIndex(int index) const |
| 219 | { |
| 220 | if (index < 0 || index >= m_tools.size()) |
| 221 | return nullptr; |
| 222 | const ToolInfo &tool = m_tools.at(index); |
| 223 | if (!tool.isEnabled()) |
| 224 | return nullptr; |
| 225 | auto it = m_widgets.constFind(tool.id()); |
| 226 | if (it != m_widgets.constEnd() && it.value()) |
| 227 | return it.value(); |
| 228 | ToolUiFactory *factory = s_pluginRepository()->factories.value(tool.id()); |
| 229 | if (!factory) |
| 230 | return nullptr; |
| 231 | if (s_pluginRepository()->uninitializedTools.contains(factory)) { |
| 232 | factory->initUi(); |
| 233 | s_pluginRepository()->uninitializedTools.remove(factory); |
| 234 | } |
| 235 | QWidget *widget = factory->createWidget(m_parentWidget); |
| 236 | m_widgets.insert(tool.id(), widget); |
| 237 | return widget; |
| 238 | } |
| 239 | |
| 240 | void ClientToolManager::gotTools(const QVector<GammaRay::ToolData> &tools) |
| 241 | { |