PDF4QT/CodeGenerator/generatormainwindow.h

110 lines
3.1 KiB
C
Raw Normal View History

2021-04-30 20:12:10 +02:00
// Copyright (C) 2020-2021 Jakub Melka
2020-03-11 20:09:14 +01:00
//
2020-12-20 19:03:58 +01:00
// This file is part of Pdf4Qt.
2020-03-11 20:09:14 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is free software: you can redistribute it and/or modify
2020-03-11 20:09:14 +01:00
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
2021-04-30 20:12:10 +02:00
// with the written consent of the copyright owner, any later version.
2020-03-11 20:09:14 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is distributed in the hope that it will be useful,
2020-03-11 20:09:14 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
2020-12-20 19:03:58 +01:00
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
2020-03-11 20:09:14 +01:00
#ifndef GENERATORMAINWINDOW_H
#define GENERATORMAINWINDOW_H
#include <QMainWindow>
2020-03-14 14:29:25 +01:00
class QTreeWidgetItem;
2020-03-11 20:09:14 +01:00
namespace codegen
{
class CodeGenerator;
2020-03-14 14:29:25 +01:00
class GeneratedFunction;
2020-03-15 18:53:44 +01:00
class GeneratedBase;
2020-03-11 20:09:14 +01:00
}
namespace Ui
{
class GeneratorMainWindow;
}
2020-03-14 14:29:25 +01:00
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;
};
2020-03-11 20:09:14 +01:00
class GeneratorMainWindow : public QMainWindow
{
Q_OBJECT
public:
GeneratorMainWindow(QWidget* parent = nullptr);
virtual ~GeneratorMainWindow() override;
void load(const QString& fileName);
void save(const QString& fileName);
private slots:
void on_actionLoad_triggered();
void on_actionSaveAs_triggered();
void on_actionSave_triggered();
2020-03-14 14:29:25 +01:00
void on_newFunctionButton_clicked();
void on_cloneFunctionButton_clicked();
void on_removeFunctionButton_clicked();
2020-03-15 18:53:44 +01:00
void on_itemDeleteButton_clicked();
void on_itemUpButton_clicked();
void on_itemDownButton_clicked();
void on_itemNewChildButton_clicked();
void on_itemNewSiblingButton_clicked();
2020-03-21 16:36:27 +01:00
void on_actionSet_code_header_h_triggered();
void on_actionSet_code_source_cpp_triggered();
void on_actionGenerate_code_triggered();
2020-03-11 20:09:14 +01:00
private:
void loadSettings();
void saveSettings();
2020-03-15 18:53:44 +01:00
void loadGeneratedSettings();
void saveGeneratedSettings();
2020-03-14 14:29:25 +01:00
void updateFunctionListUI();
2020-03-15 18:53:44 +01:00
void updateGeneratedSettingsTree();
2020-03-14 14:29:25 +01:00
void setCurrentFunction(codegen::GeneratedFunction* currentFunction);
2020-03-15 18:53:44 +01:00
void setCurrentSettings(codegen::GeneratedBase* currentSettings);
2020-03-14 14:29:25 +01:00
void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
2020-03-15 18:53:44 +01:00
void onParameterTreeCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
2020-03-14 14:29:25 +01:00
2020-03-11 20:09:14 +01:00
Ui::GeneratorMainWindow* ui;
codegen::CodeGenerator* m_generator;
2020-03-14 14:29:25 +01:00
codegen::GeneratedFunction* m_currentFunction;
2020-03-15 18:53:44 +01:00
codegen::GeneratedBase* m_currentSettings;
2020-03-11 20:09:14 +01:00
QString m_defaultFileName;
2020-03-21 16:36:27 +01:00
QString m_headerFileName;
QString m_sourceFileName;
2020-03-14 14:29:25 +01:00
std::map<codegen::GeneratedFunction*, QTreeWidgetItem*> m_mapFunctionToWidgetItem;
bool m_isLoadingData;
2020-03-11 20:09:14 +01:00
};
#endif // GENERATORMAINWINDOW_H