Skip to content

Commit

Permalink
Cleanup Remnants of Widget Actions (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
thestr4ng3r authored Jul 4, 2019
1 parent 2ac1455 commit a7a7bad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
14 changes: 5 additions & 9 deletions src/core/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/core/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,9 @@ private slots:
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
16 changes: 0 additions & 16 deletions src/core/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit a7a7bad

Please sign in to comment.