You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.7 KiB

4 years ago
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFileDialog>
#include <QtCore>
#include <QtGui>
#include <QtXml>
#include <QDebug>
#include "XMLReader.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
enum eElementType:quint8
{
root,
database,
table,
field,
unknown
};
private slots:
void on_actionOpen_triggered();
void on_treeView_doubleClicked(const QModelIndex &index);
void on_pushButton_clicked();
void on_pushButton_3_clicked();
void on_actionSave_triggered();
private:
Ui::MainWindow *ui;
QStandardItemModel *_model;
QString _fileName;
//dbData
QDomDocument _xmlDoc;
QDomElement _rootData;
QDomElement _lastDBElement;
QDomElement _lastTableElement;
QVector<QDomElement> _fieldElemensVector;
//
QString _xmlDBAddress;
//initData
QDomDocument _xmlInitDataDoc;
QDomElement _rootInitData;
QDomElement _lastDBElementInitData;
QDomElement _lastTableElementInitData;
QDomElement _lastEntityElementInitData;
QDomElement _lastFieldElementInitData;
XMLReader* _xmlReader;
QVector<QString> _DBNameVector;
QVector<QDomElement> _DBElementVector;
eElementType getElementType(QModelIndex indInput);
bool hasDatabaseChild(QDomElement xmlRoot, QString DBName);
bool hasTableChild(QDomElement database, QString tableName);
void initUI();
int _fieldIndex = 0;
void readFile();
void writeFile();
void hideWidgets();
};
#endif // MAINWINDOW_H