Cleanup Remnants of Widget Actions (#1637)

This commit is contained in:
Florian Märkl 2019-07-04 20:51:44 +02:00 committed by GitHub
parent 2ac1455642
commit a7a7bad6d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 28 deletions

View File

@ -131,12 +131,9 @@ void MainWindow::initUI()
connect(ui->actionExtraDisassembly, &QAction::triggered, this, &MainWindow::addExtraDisassembly);
connect(ui->actionExtraHexdump, &QAction::triggered, this, &MainWindow::addExtraHexdump);
classNameToConstructorAndActionMap.insert(GraphWidget::getWidgetType(),
{getNewInstance<GraphWidget>, ui->actionGraph});
classNameToConstructorAndActionMap.insert(DisassemblyWidget::getWidgetType(),
{getNewInstance<DisassemblyWidget>, ui->actionDisassembly});
classNameToConstructorAndActionMap.insert(HexdumpWidget::getWidgetType(),
{getNewInstance<HexdumpWidget>, ui->actionHexdump});
widgetTypeToConstructorMap.insert(GraphWidget::getWidgetType(), getNewInstance<GraphWidget>);
widgetTypeToConstructorMap.insert(DisassemblyWidget::getWidgetType(), getNewInstance<DisassemblyWidget>);
widgetTypeToConstructorMap.insert(HexdumpWidget::getWidgetType(), getNewInstance<HexdumpWidget>);
initToolBar();
initDocks();
@ -324,9 +321,8 @@ void MainWindow::initDocks()
if (std::none_of(dockWidgets.constBegin(), dockWidgets.constEnd(),
[&it](QDockWidget *w) { return w->objectName() == it; })) {
className = it.split(';').at(0);
if (classNameToConstructorAndActionMap.contains(className)) {
auto widget = classNameToConstructorAndActionMap[className]
.first(this, classNameToConstructorAndActionMap[className].second);
if (widgetTypeToConstructorMap.contains(className)) {
auto widget = widgetTypeToConstructorMap[className](this, nullptr);
widget->setObjectName(it);
addExtraWidget(widget);
}

View File

@ -272,10 +272,9 @@ private:
bool isOverviewActive();
/**
* @brief Map, where key is class name an value is pair of
* pointer to class constructor and action that passed to this constructor.
* @brief Map from a widget type (e.g. DisassemblyWidget::getWidgetType()) to the respective contructor of the widget
*/
QMap<QString, std::pair<std::function<CutterDockWidget*(MainWindow*, QAction*)>, QAction*>> classNameToConstructorAndActionMap;
QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap;
};
#endif // MAINWINDOW_H

View File

@ -881,14 +881,6 @@
<string>Tmp</string>
</property>
</action>
<action name="actionDisassembly">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Disassembly</string>
</property>
</action>
<action name="actionGraph">
<property name="checkable">
<bool>true</bool>
@ -913,14 +905,6 @@
<string>Pseudocode</string>
</property>
</action>
<action name="actionHexdump">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hexdump</string>
</property>
</action>
<action name="actionConsole">
<property name="checkable">
<bool>true</bool>