| 450 | } |
| 451 | |
| 452 | void Controller::registerWidgetToMode(const QString &name, AbstractWidget *abstractWidget, const QString &mode, Position pos, bool replace, bool isVisible) |
| 453 | { |
| 454 | if (!d->validModeList.contains(mode)) { |
| 455 | qWarning() << "mode can only choose CM_RECENT / CM_EDIT / CM_DEBUG"; |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | if (d->allWidgets.contains(name)) { |
| 460 | auto &info = d->allWidgets[name]; |
| 461 | if (!d->modeInfo[mode].contains(name)) { |
| 462 | if (info.defaultPos != pos) |
| 463 | qWarning() << "widget named: " << name << "has registed to another position"; |
| 464 | d->modeInfo[mode].append(name); |
| 465 | } else { |
| 466 | qWarning() << "Widget named: " << name << "has alreay registed"; |
| 467 | } |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | DWidget *qWidget = static_cast<DWidget *>(abstractWidget->qWidget()); |
| 472 | if (!qWidget->parent()) |
| 473 | qWidget->setParent(d->mainWindow); |
| 474 | |
| 475 | WidgetInfo widgetInfo; |
| 476 | widgetInfo.name = name; |
| 477 | widgetInfo.defaultPos = pos; |
| 478 | widgetInfo.replace = replace; |
| 479 | widgetInfo.setWidget(qWidget); |
| 480 | widgetInfo.defaultVisible = isVisible; |
| 481 | widgetInfo.icon = abstractWidget->getDisplayIcon(); |
| 482 | |
| 483 | createDockWidget(widgetInfo); |
| 484 | d->mainWindow->hideWidget(name); |
| 485 | |
| 486 | d->allWidgets.insert(name, widgetInfo); |
| 487 | d->modeInfo[mode].append(name); |
| 488 | } |
| 489 | |
| 490 | void Controller::registerWidget(const QString &name, AbstractWidget *abstractWidget) |
| 491 | { |
no test coverage detected