Code generator - objects

This commit is contained in:
Jakub Melka
2020-03-14 14:29:25 +01:00
parent 0e4e012c64
commit c17b9c347c
5 changed files with 995 additions and 49 deletions

View File

@ -20,9 +20,12 @@
#include <QMainWindow>
class QTreeWidgetItem;
namespace codegen
{
class CodeGenerator;
class GeneratedFunction;
}
namespace Ui
@ -30,6 +33,26 @@ namespace Ui
class GeneratorMainWindow;
}
class BoolGuard
{
public:
explicit inline BoolGuard(bool& value) :
m_oldValue(value),
m_value(&value)
{
*m_value = true;
}
inline ~BoolGuard()
{
*m_value = m_oldValue;
}
private:
bool m_oldValue;
bool* m_value;
};
class GeneratorMainWindow : public QMainWindow
{
Q_OBJECT
@ -44,16 +67,25 @@ public:
private slots:
void on_actionLoad_triggered();
void on_actionSaveAs_triggered();
void on_actionSave_triggered();
void on_newFunctionButton_clicked();
void on_cloneFunctionButton_clicked();
void on_removeFunctionButton_clicked();
private:
void loadSettings();
void saveSettings();
void updateFunctionListUI();
void setCurrentFunction(codegen::GeneratedFunction* currentFunction);
void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
Ui::GeneratorMainWindow* ui;
codegen::CodeGenerator* m_generator;
codegen::GeneratedFunction* m_currentFunction;
QString m_defaultFileName;
std::map<codegen::GeneratedFunction*, QTreeWidgetItem*> m_mapFunctionToWidgetItem;
bool m_isLoadingData;
};
#endif // GENERATORMAINWINDOW_H