PDF4QT/CodeGenerator/generatormainwindow.h

92 lines
2.4 KiB
C
Raw Normal View History

2020-03-11 20:09:14 +01:00
// Copyright (C) 2020 Jakub Melka
//
// This file is part of PdfForQt.
//
// PdfForQt is free software: you can redistribute it and/or modify
// 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
// (at your option) any later version.
//
// PdfForQt is distributed in the hope that it will be useful,
// 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
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
#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-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-11 20:09:14 +01:00
private:
void loadSettings();
void saveSettings();
2020-03-14 14:29:25 +01:00
void updateFunctionListUI();
void setCurrentFunction(codegen::GeneratedFunction* currentFunction);
void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
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-11 20:09:14 +01:00
QString m_defaultFileName;
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