Merge branch 'develop' into feature/print-as-qtextdocument
This commit is contained in:
commit
e2237110cf
@ -34,7 +34,7 @@ protobuf_generate_cpp(DataModel_PROTO_SRCS DataModel_PROTO_HDRS
|
|||||||
${DataModel_PROTO_FILES})
|
${DataModel_PROTO_FILES})
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} WIN32
|
add_executable(${PROJECT_NAME} WIN32
|
||||||
LogoTest.cpp
|
ESGRAF48.cpp
|
||||||
DataModel.cpp
|
DataModel.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
${LOGO_TEST_UI}
|
${LOGO_TEST_UI}
|
||||||
|
21
source/ESGRAF48.cpp
Normal file
21
source/ESGRAF48.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
std::unique_ptr<MainWindow> mainWindow;
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
mainWindow = std::make_unique<MainWindow>(nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainWindow = std::make_unique<MainWindow>(nullptr, argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow->show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
MainWindow mainWindow;
|
|
||||||
mainWindow.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include "DataModel.h"
|
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -21,16 +19,45 @@
|
|||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
|
, m_dataModel(this)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
setupUi();
|
||||||
|
|
||||||
|
newFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent, const QString &filename)
|
||||||
|
: QMainWindow(parent)
|
||||||
|
, ui(new Ui::MainWindow)
|
||||||
|
, m_dataModel(this)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
setupUi();
|
||||||
|
|
||||||
|
openFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupUi()
|
||||||
|
{
|
||||||
|
ui->metaDataWidget->setModel(&m_dataModel.m_metaData);
|
||||||
|
ui->verbEndWidget->setModel(&m_dataModel.m_verbEnd);
|
||||||
|
ui->genusWidget->setModel(&m_dataModel.m_genus);
|
||||||
|
ui->pluralWidget->setModel(&m_dataModel.m_plural);
|
||||||
|
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ);
|
||||||
|
ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ);
|
||||||
|
ui->v2SvkWidget->setV2SvkModel(&m_dataModel.m_v2Svk);
|
||||||
|
ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv);
|
||||||
|
ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv);
|
||||||
|
ui->resultWidget->setModel(&m_dataModel.m_results);
|
||||||
|
|
||||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
||||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openFile);
|
connect(ui->actionOpen, &QAction::triggered, this, qOverload<>(&MainWindow::openFile));
|
||||||
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
||||||
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
||||||
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
||||||
|
|
||||||
newFile();
|
connect(&m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -42,21 +69,6 @@ void MainWindow::newFile()
|
|||||||
{
|
{
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
||||||
m_dataModel = std::make_unique<DataModel>(this);
|
|
||||||
ui->metaDataWidget->setModel(&m_dataModel->m_metaData);
|
|
||||||
ui->verbEndWidget->setModel(&m_dataModel->m_verbEnd);
|
|
||||||
ui->genusWidget->setModel(&m_dataModel->m_genus);
|
|
||||||
ui->pluralWidget->setModel(&m_dataModel->m_plural);
|
|
||||||
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ);
|
|
||||||
ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ);
|
|
||||||
ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk);
|
|
||||||
ui->lateSkillsWidget->setPassivModel(&m_dataModel->m_passiv);
|
|
||||||
ui->lateSkillsWidget->setGenitivModel(&m_dataModel->m_genitiv);
|
|
||||||
|
|
||||||
ui->resultWidget->setModel(&m_dataModel->m_results);
|
|
||||||
|
|
||||||
connect(&*m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle("untitled[*]");
|
setWindowTitle("untitled[*]");
|
||||||
m_filename = "";
|
m_filename = "";
|
||||||
@ -72,10 +84,15 @@ void MainWindow::openFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openFile(const QString &filename)
|
||||||
|
{
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
||||||
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||||
m_dataModel->read(protoInFile);
|
m_dataModel.read(protoInFile);
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle(filename + "[*]");
|
setWindowTitle(filename + "[*]");
|
||||||
@ -142,7 +159,9 @@ void MainWindow::print() const
|
|||||||
|
|
||||||
QTextDocument printDoc;
|
QTextDocument printDoc;
|
||||||
QTextCursor printCursor(&printDoc);
|
QTextCursor printCursor(&printDoc);
|
||||||
m_dataModel->printTo(printCursor);
|
m_dataModel.printTo(printCursor);
|
||||||
|
|
||||||
|
printDoc.print(&printer);
|
||||||
|
|
||||||
printDoc.print(&printer);
|
printDoc.print(&printer);
|
||||||
}
|
}
|
||||||
@ -162,7 +181,7 @@ void MainWindow::saveFile(const QString &filename)
|
|||||||
{
|
{
|
||||||
std::fstream protoOutFile(filename.toStdString(),
|
std::fstream protoOutFile(filename.toStdString(),
|
||||||
std::ios::out | std::ios::trunc | std::ios::binary);
|
std::ios::out | std::ios::trunc | std::ios::binary);
|
||||||
m_dataModel->write(protoOutFile);
|
m_dataModel.write(protoOutFile);
|
||||||
|
|
||||||
qDebug() << "Wrote" << filename;
|
qDebug() << "Wrote" << filename;
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include "DataModel.h"
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class DataModel;
|
class DataModel;
|
||||||
class QDataWidgetMapper;
|
class QDataWidgetMapper;
|
||||||
@ -17,17 +19,19 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
std::unique_ptr<DataModel> m_dataModel;
|
DataModel m_dataModel;
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
bool m_saveOnClose = false;
|
bool m_saveOnClose = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent);
|
||||||
|
MainWindow(QWidget *parent, const QString &filename);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newFile();
|
void newFile();
|
||||||
void openFile();
|
void openFile();
|
||||||
|
void openFile(const QString &filename);
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void saveFileAs();
|
void saveFileAs();
|
||||||
void closeFile();
|
void closeFile();
|
||||||
@ -38,5 +42,6 @@ protected:
|
|||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupUi();
|
||||||
void saveFile(const QString &filename);
|
void saveFile(const QString &filename);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user