Reading the Raw Layout Data file in Puzzle.

This commit is contained in:
Roman Telezhynskyi 2020-04-21 19:03:36 +03:00
parent 3b37d22a0b
commit b2fd02b510
5 changed files with 81 additions and 48 deletions

View file

@ -7,7 +7,7 @@
# File with common stuff for whole project
include(../../../common.pri)
QT += core gui widgets network xml xmlpatterns printsupport
QT += core gui widgets network xml xmlpatterns printsupport concurrent
# Name of binary file
TARGET = puzzle
@ -187,7 +187,7 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath
# When the GNU linker sees a library, it discards all symbols that it doesn't need.
# Dependent library go first.
#VTools static library (depend on VWidgets, VMisc, VPatternDB)
##VTools static library (depend on VWidgets, VMisc, VPatternDB)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vtools/$${DESTDIR}/ -lvtools
#INCLUDEPATH += $$PWD/../../libs/vtools
@ -215,14 +215,23 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a
##VPatternDB static library (depend on vgeometry, vmisc, VLayout)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
# VLayout static library (depend on VGeometry)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout
#INCLUDEPATH += $$PWD/../../libs/vpatterndb
#DEPENDPATH += $$PWD/../../libs/vpatterndb
INCLUDEPATH += $$PWD/../../libs/vlayout
DEPENDPATH += $$PWD/../../libs/vlayout
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a
#VPatternDB static library (depend on vgeometry, vmisc)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
INCLUDEPATH += $$PWD/../../libs/vpatterndb
DEPENDPATH += $$PWD/../../libs/vpatterndb
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a
# Fervor static library (depend on VMisc, IFC)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/fervor/$${DESTDIR}/ -lfervor
@ -251,31 +260,22 @@ DEPENDPATH += $$PWD/../../libs/vmisc
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/vmisc.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/libvmisc.a
## VLayout static library (depend on VGeometry)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout
# VGeometry static library (depend on ifc)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/ -lvgeometry
#INCLUDEPATH += $$PWD/../../libs/vlayout
#DEPENDPATH += $$PWD/../../libs/vlayout
INCLUDEPATH += $$PWD/../../libs/vgeometry
DEPENDPATH += $$PWD/../../libs/vgeometry
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a
## VGeometry static library (depend on ifc)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/ -lvgeometry
# QMuParser library
win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser
#INCLUDEPATH += $$PWD/../../libs/vgeometry
#DEPENDPATH += $$PWD/../../libs/vgeometry
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a
## QMuParser library
#win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
#else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
#else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser
#INCLUDEPATH += $${PWD}/../../libs/qmuparser
#DEPENDPATH += $${PWD}/../../libs/qmuparser
INCLUDEPATH += $${PWD}/../../libs/qmuparser
DEPENDPATH += $${PWD}/../../libs/qmuparser
## VPropertyExplorer library
#win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer

View file

@ -337,7 +337,7 @@ PuzzleMainWindow *PuzzleApplication::MainWindow()
{
VPuzzleCommandLinePtr cmd;
VPuzzleCommandLine::ProcessInstance(cmd, QStringList());
NewMainWindow(true);
NewMainWindow(VPuzzleCommandLinePtr());
}
return mainWindows[0];
}
@ -355,11 +355,11 @@ QList<PuzzleMainWindow *> PuzzleApplication::MainWindows()
}
//---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow *PuzzleApplication::NewMainWindow(bool guiMode)
PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd)
{
PuzzleMainWindow *puzzle = new PuzzleMainWindow();
PuzzleMainWindow *puzzle = new PuzzleMainWindow(cmd);
mainWindows.prepend(puzzle);
if (guiMode)
if (cmd->IsGuiEnabled())
{
puzzle->show();
}
@ -505,7 +505,7 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd)
for (auto &arg : args)
{
NewMainWindow(cmd->IsGuiEnabled());
NewMainWindow(cmd);
if (not MainWindow()->LoadFile(arg))
{
if (not cmd->IsGuiEnabled())
@ -516,10 +516,10 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd)
continue;
}
// if (rawLayouts.size() > 0)
// {
// MainWindow()->ImportRawLayouts(rawLayouts);
// }
if (rawLayouts.size() > 0)
{
MainWindow()->ImportRawLayouts(rawLayouts);
}
}
}
else
@ -530,12 +530,12 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd)
cmd.get()->parser.showHelp(V_EX_USAGE);
}
NewMainWindow(cmd->IsGuiEnabled());
// if (rawLayouts.size() > 0)
// {
NewMainWindow(cmd);
if (rawLayouts.size() > 0)
{
// MainWindow()->New(); // prepare layout settings
// MainWindow()->ImportRawLayouts(rawLayouts);
// }
MainWindow()->ImportRawLayouts(rawLayouts);
}
}
if (not cmd->IsGuiEnabled())

View file

@ -58,7 +58,7 @@ public:
virtual bool IsAppInGUIMode() const override;
PuzzleMainWindow *MainWindow();
QList<PuzzleMainWindow*> MainWindows();
PuzzleMainWindow *NewMainWindow(bool guiMode);
PuzzleMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd);
void InitOptions();

View file

@ -28,12 +28,25 @@
#include "puzzlemainwindow.h"
#include "ui_puzzlemainwindow.h"
#include "dialogs/dialogaboutpuzzle.h"
#include "../vlayout/vrawlayout.h"
#include "../vmisc/vsysexits.h"
#include <QLoggingCategory>
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pWindow, "p.window")
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) :
PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PuzzleMainWindow),
pieceCarrousel(new VPieceCarrousel)
pieceCarrousel(new VPieceCarrousel),
m_cmd(cmd)
{
ui->setupUi(this);
@ -59,7 +72,25 @@ bool PuzzleMainWindow::LoadFile(const QString &path)
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts)
{
Q_UNUSED(layouts)
VRawLayout layoutReader;
for(auto &path : layouts)
{
VRawLayoutData data;
if (layoutReader.ReadFile(path, data))
{
// Do somethinmg with raw layout data
}
else
{
qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2")
.arg(path, layoutReader.ErrorString())));
if (m_cmd != nullptr && not m_cmd->IsGuiEnabled())
{
m_cmd->ShowHelp(V_EX_DATAERR);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -33,6 +33,7 @@
#include "../vmisc/def.h"
#include "vpiececarrousel.h"
#include "vpuzzlecommandline.h"
namespace Ui
{
@ -44,7 +45,7 @@ class PuzzleMainWindow : public QMainWindow
Q_OBJECT
public:
explicit PuzzleMainWindow(QWidget *parent = nullptr);
PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr);
virtual ~PuzzleMainWindow();
bool LoadFile(const QString &path);
@ -58,6 +59,7 @@ private:
Q_DISABLE_COPY(PuzzleMainWindow)
Ui::PuzzleMainWindow *ui;
VPieceCarrousel *pieceCarrousel;
VPuzzleCommandLinePtr m_cmd;
void InitMenuBar();
void InitProperties();